@lunora/studio 1.0.0-alpha.87 → 1.0.0-alpha.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/standalone/{chunk-4JIOFDMR.js → chunk-24JLZ2Z5.js} +1 -1
  2. package/dist/standalone/{chunk-EWDLYYJM.js → chunk-3AV5CV6K.js} +1 -1
  3. package/dist/standalone/{chunk-XZN645UJ.js → chunk-4COKHD2C.js} +1 -1
  4. package/dist/standalone/{chunk-T2Q7I3V2.js → chunk-53KJRSHE.js} +1 -1
  5. package/dist/standalone/{chunk-UNVK2VZP.js → chunk-5ZXDB6LB.js} +1 -1
  6. package/dist/standalone/{chunk-LYRAWNV7.js → chunk-62EKHKTS.js} +1 -1
  7. package/dist/standalone/{chunk-B5S6GSUC.js → chunk-67DKQC23.js} +1 -1
  8. package/dist/standalone/{chunk-PDMZITZZ.js → chunk-6MKDYZ7A.js} +1 -1
  9. package/dist/standalone/{chunk-TVGKSIIW.js → chunk-6VTLIGVX.js} +1 -1
  10. package/dist/standalone/{chunk-EAIUBZA5.js → chunk-AQX2QFCN.js} +1 -1
  11. package/dist/standalone/{chunk-HYCMT2V5.js → chunk-ARP36PTE.js} +1 -1
  12. package/dist/standalone/{chunk-7DNDRUMZ.js → chunk-AUQKJYHL.js} +1 -1
  13. package/dist/standalone/{chunk-CLNB7I3O.js → chunk-AZAGCJVI.js} +1 -1
  14. package/dist/standalone/{chunk-SMEW3ZTU.js → chunk-BL6NO3U3.js} +1 -1
  15. package/dist/standalone/{chunk-L4RW5BFD.js → chunk-BRQMMGOS.js} +1 -1
  16. package/dist/standalone/{chunk-NMLCYY4H.js → chunk-BUTBQGUU.js} +1 -1
  17. package/dist/standalone/{chunk-OOWHAURL.js → chunk-C3HXK3A5.js} +1 -1
  18. package/dist/standalone/{chunk-NBUBAW3V.js → chunk-CT6ZDXLL.js} +1 -1
  19. package/dist/standalone/{chunk-EVTCXQ5D.js → chunk-D3HXVA33.js} +1 -1
  20. package/dist/standalone/{chunk-SJZQPIZB.js → chunk-DG7YINFM.js} +1 -1
  21. package/dist/standalone/{chunk-BDNDSBYM.js → chunk-DMCYISRF.js} +1 -1
  22. package/dist/standalone/{chunk-KJIBL5D4.js → chunk-E7TB4USI.js} +1 -1
  23. package/dist/standalone/{chunk-QJTGO4JG.js → chunk-GKSRVABT.js} +1 -1
  24. package/dist/standalone/{chunk-2VWWXVWK.js → chunk-GSKOAKQ2.js} +1 -1
  25. package/dist/standalone/{chunk-QXDMHM2V.js → chunk-IC64YIX5.js} +1 -1
  26. package/dist/standalone/{chunk-NCWUTRZB.js → chunk-JFW3YNVQ.js} +1 -1
  27. package/dist/standalone/{chunk-D3JTCLSF.js → chunk-LAHYLAT4.js} +1 -1
  28. package/dist/standalone/{chunk-YRYEZHOJ.js → chunk-LJIFMW67.js} +1 -1
  29. package/dist/standalone/{chunk-DABW4OOI.js → chunk-LJISXTZJ.js} +1 -1
  30. package/dist/standalone/{chunk-YFJXQUPW.js → chunk-LQAKPCFX.js} +1 -1
  31. package/dist/standalone/{chunk-6MGI5IN6.js → chunk-MHAXZQVO.js} +1 -1
  32. package/dist/standalone/{chunk-S2CXYDNT.js → chunk-OG2AMGOC.js} +1 -1
  33. package/dist/standalone/{chunk-EJ2CHD4G.js → chunk-PB7FNRDB.js} +1 -1
  34. package/dist/standalone/{chunk-5KRD6F67.js → chunk-PGC523I2.js} +1 -1
  35. package/dist/standalone/{chunk-F7NVC7YK.js → chunk-PM37X2V3.js} +1 -1
  36. package/dist/standalone/{chunk-WPUINKEO.js → chunk-QV6KV4SD.js} +1 -1
  37. package/dist/standalone/{chunk-PNAVAJAF.js → chunk-QWBRD6PX.js} +1 -1
  38. package/dist/standalone/{chunk-5X4OZ7OD.js → chunk-QYIOW7CD.js} +1 -1
  39. package/dist/standalone/{chunk-B5UFGO4E.js → chunk-SF4MF2FT.js} +1 -1
  40. package/dist/standalone/{chunk-TS6346VY.js → chunk-SHMNA6UL.js} +1 -1
  41. package/dist/standalone/{chunk-OUCGTB3Y.js → chunk-SP5SBO2W.js} +1 -1
  42. package/dist/standalone/{chunk-ORVR33FM.js → chunk-T6OAYQTX.js} +1 -1
  43. package/dist/standalone/{chunk-GZS3ORGS.js → chunk-TBBJPPZ3.js} +1 -1
  44. package/dist/standalone/{chunk-VQK34A2H.js → chunk-ULCZDGWQ.js} +1 -1
  45. package/dist/standalone/chunk-V2U5CL3S.js +11 -0
  46. package/dist/standalone/{chunk-IVCIG5J7.js → chunk-VFQDHG7I.js} +1 -1
  47. package/dist/standalone/{chunk-T3CGXSXO.js → chunk-WB5IUUUU.js} +1 -1
  48. package/dist/standalone/{chunk-GE5WTIWX.js → chunk-XZSGE5ST.js} +1 -1
  49. package/dist/standalone/{chunk-YKAO3JNJ.js → chunk-Y7JXGNXD.js} +1 -1
  50. package/dist/standalone/{chunk-UR3X4K4T.js → chunk-YOUKADZH.js} +1 -1
  51. package/dist/standalone/{chunk-SNK7TOOO.js → chunk-YU5CI2FD.js} +1 -1
  52. package/dist/standalone/{chunk-ZCFDQW4U.js → chunk-Z7G74IH4.js} +1 -1
  53. package/dist/standalone/{chunk-7FO57AZY.js → chunk-ZPLWCC4I.js} +1 -1
  54. package/dist/standalone/studio.js +1 -1
  55. package/package.json +4 -4
  56. package/dist/standalone/chunk-MIFLRBVS.js +0 -11
@@ -1 +1 @@
1
- import{a as G}from"./chunk-V53KNYRN.js";import{a as g}from"./chunk-5Y3QLNWX.js";import{a as B}from"./chunk-X665E2HU.js";import{b as U}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as O}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as h}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as w}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as M}from"./chunk-VDW32UET.js";import{f as D}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{d as K,e as _,f as z,h as P,m as q,q as E}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as s,e as T,f as ie,h as oe}from"./chunk-3XIESWL4.js";var i=T(ie(),1);var e=T(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"ie"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"oe"),ue=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ce=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ue(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(M.runAs),fe=10,pe=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),c=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),x=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[u,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,p]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return c.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(P(d))}),()=>{t=!0}},[c,r]);let j=I===""?x[0]?.path??"":I,n=x.find(t=>t.path===j),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){p("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=u.trim()===""?{}:{shardKey:u.trim()},A=o?f.trim():"",J=s(l=>{Y(L=>[{argsText:m,at:Date.now(),id:(L[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:u,status:l},...L].slice(0,fe))},"A");p("running"),N(null);try{let l=A===""?await _(c,n.kind,d,t,R):await c.query(me,{args:t,functionPath:n.path,userId:A},R);U(u),y(l),p("success"),J("success")}catch(l){y(void 0),N(l.message),p("error"),J("error")}},"_"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"q"),te=s(t=>{S(t.target.value)},"B"),re=s(t=>{b(t.target.value)},"D"),ae=s(t=>{W(t.target.value)},"E"),se=s(()=>{q(Z())},"U"),ne=s(()=>{b(ce(n?.args))},"X");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(g,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:j,children:x.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(g,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(h,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(B,{onChange:F,testId:"shard-input",value:u}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(g,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(h,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:pe(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:E(t.at)})," ",(0,e.jsx)(h,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ie");export{Fe as FunctionRunner};
1
+ import{a as G}from"./chunk-V53KNYRN.js";import{a as g}from"./chunk-5Y3QLNWX.js";import{a as B}from"./chunk-X665E2HU.js";import{b as U}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as O}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as h}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as w}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as M}from"./chunk-VDW32UET.js";import{f as D}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{d as K,e as _,f as z,h as P,m as q,q as E}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as s,e as T,f as ie,h as oe}from"./chunk-3XIESWL4.js";var i=T(ie(),1);var e=T(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"ie"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"oe"),ue=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ce=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ue(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(M.runAs),fe=10,pe=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),c=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),x=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[u,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,p]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return c.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(P(d))}),()=>{t=!0}},[c,r]);let j=I===""?x[0]?.path??"":I,n=x.find(t=>t.path===j),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){p("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=u.trim()===""?{}:{shardKey:u.trim()},A=o?f.trim():"",J=s(l=>{Y(L=>[{argsText:m,at:Date.now(),id:(L[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:u,status:l},...L].slice(0,fe))},"A");p("running"),N(null);try{let l=A===""?await _(c,n.kind,d,t,R):await c.query(me,{args:t,functionPath:n.path,userId:A},R);U(u),y(l),p("success"),J("success")}catch(l){y(void 0),N(l.message),p("error"),J("error")}},"_"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"q"),te=s(t=>{S(t.target.value)},"B"),re=s(t=>{b(t.target.value)},"D"),ae=s(t=>{W(t.target.value)},"E"),se=s(()=>{q(Z())},"U"),ne=s(()=>{b(ce(n?.args))},"X");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(g,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:j,children:x.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(g,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(h,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(B,{onChange:F,testId:"shard-input",value:u}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(g,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(h,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:pe(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:E(t.at)})," ",(0,e.jsx)(h,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ie");export{Fe as FunctionRunner};
@@ -1 +1 @@
1
- import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as v}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-MIQTKZAR.js";import{a as k,e as S}from"./chunk-UZERI5YC.js";import{d as b}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as f,e as N,g as E,h as _}from"./chunk-3XIESWL4.js";var T=N(E(),1);var r=N(_(),1);var D=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"C"),C={delete:2,list:3,read:0,write:1},O=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),W=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(R.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=O(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(v,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(w,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(S,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:D(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"U");export{W as StorageRulesPanel};
1
+ import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as v}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-MIQTKZAR.js";import{a as k,e as S}from"./chunk-UZERI5YC.js";import{d as b}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as f,e as N,g as E,h as _}from"./chunk-3XIESWL4.js";var T=N(E(),1);var r=N(_(),1);var D=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"C"),C={delete:2,list:3,read:0,write:1},O=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),W=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(R.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=O(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(v,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(w,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(S,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:D(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"U");export{W as StorageRulesPanel};
@@ -1 +1 @@
1
- import{a as We,b as De,c as Fe,d as Oe,e as be}from"./chunk-UU2QJMGJ.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as qe}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as ze}from"./chunk-3CWGJYBB.js";import{a as _e}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ie}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as Te}from"./chunk-TS6346VY.js";import{f as Ne}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{a as Le,b as je,c as Re,d as pe,e as W,f as L}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import{d as ue,f as le,g as we,h as Ke,m as re,q as Ee}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-XNGYYOLS.js";import{a as d,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var ne=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=le(D.resolveIssue),Xe=le(D.ignoreIssue),Ue=le(D.assignIssue),Ye=le(D.setIssueSeverity),Ze=le(D.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Ye"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ze"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Pe"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:C,run:j}=qe(),K;e[0]!==i||e[1]!==s||e[2]!==j||e[3]!==$?(K=d(()=>{o(void 0),j(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,we($));o(I)})},"K"),e[0]=i,e[1]=s,e[2]=j,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let E=k,T=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==E||e[14]!==s.hash||e[15]!==r?(v=E===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:E}),e[13]=E,e[14]=s.hash,e[15]=r,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let w=`issues-explain-${s.hash}`,b;e[20]!==_||e[21]!==r?(b=r(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=r,e[22]=b):b=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==b||e[26]!==w?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":w,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:b})}),e[23]=_,e[24]=z,e[25]=b,e[26]=w,e[27]=m):m=e[27];let f;e[28]!==C||e[29]!==s.hash?(f=C!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:C}),e[28]=C,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==r?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==T?(S=(0,t.jsx)(pe,{"data-testid":T,children:c}),e[41]=c,e[42]=T,e[43]=S):S=e[43],S},"es"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[o,_]=(0,ne.useState)(!1),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=d(()=>{_(ls)},"C"),e[0]=C):C=e[0];let j=C,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;re(i(s.hash,Ye,{severity:ce}))},"K"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"k"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let E=k,T=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let w;e[12]!==s.title?(w=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=w):w=e[13];let b;e[14]!==s.culprit?(b=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=b):b=e[15];let m;e[16]!==w||e[17]!==b?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[w,b]}),e[16]=w,e[17]=b,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:j,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let R=s.severity??Se,l;e[37]!==a?(l=a("Set severity"),e[37]=a,e[38]=l):l=e[38];let oe=`issues-severity-${s.hash}`,q;e[39]!==a?(q=a("\u2014"),e[39]=a,e[40]=q):q=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let A;e[44]!==q||e[45]!==N?(A=(0,t.jsx)(De,{placeholder:q,children:N}),e[44]=q,e[45]=N,e[46]=A):A=e[46];let V;e[47]!==l||e[48]!==oe||e[49]!==A?(V=(0,t.jsx)(Fe,{"aria-label":l,className:"h-7 w-[110px]","data-testid":oe,children:A}),e[47]=l,e[48]=oe,e[49]=A,e[50]=V):V=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Je.map(rs),e[51]=de):de=e[51];let F;e[52]!==a?(F=a("Clear"),e[52]=a,e[53]=F):F=e[53];let O;e[54]!==F?(O=(0,t.jsxs)(Oe,{children:[de,(0,t.jsx)(be,{value:Se,children:F})]}),e[54]=F,e[55]=O):O=e[55];let U;e[56]!==u||e[57]!==z||e[58]!==R||e[59]!==V||e[60]!==O?(U=(0,t.jsx)(L,{children:(0,t.jsxs)(We,{disabled:u,onValueChange:z,value:R,children:[V,O]})}),e[56]=u,e[57]=z,e[58]=R,e[59]=V,e[60]=O,e[61]=U):U=e[61];let B;e[62]!==a?(B=a("Assignee"),e[62]=a,e[63]=B):B=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==E||e[68]!==B||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(ke,{"aria-label":B,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:E,placeholder:G},ve)}),e[66]=u,e[67]=E,e[68]=B,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let P;e[74]!==s.count?(P=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=P):P=e[75];let J;e[76]!==s.lastSeen?(J=Ee(s.lastSeen),e[76]=s.lastSeen,e[77]=J):J=e[77];let Q;e[78]!==J?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:J}),e[78]=J,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==U||e[106]!==H||e[107]!==P||e[108]!==Q||e[109]!==T||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":T,children:[c,I,U,H,P,Q,ee]}),e[103]=c,e[104]=I,e[105]=U,e[106]=H,e[107]=P,e[108]=Q,e[109]=T,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==r?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:r},s.sampleMessage),e[112]=o,e[113]=s,e[114]=r,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"ss"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:r,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[C,j]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let E;e[2]!==i?(E={live:!0,shardKey:i},e[2]=i,e[3]=E):E=e[3];let{data:T,error:h,liveError:x}=Te(D.getIssues,k,E),M=T!==void 0,v;if(e[4]!==K||e[5]!==C||e[6]!==$||e[7]!==T||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==r||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(T),w;e[17]!==$||e[18]!==i?(w=d(async(l,oe,q)=>{z(N=>{if(!N.has(l))return N;let A=new Map(N);return A.delete(l),A}),j(N=>new Set(N).add(l));try{await $.query(oe,{...q,hash:l},we(i))}catch(N){let A=Ke(N);z(V=>new Map(V).set(l,A))}j(N=>{let A=new Set(N);return A.delete(l),A})},"N"),e[17]=$,e[18]=i,e[19]=w):w=e[19];let b=w,m;e[20]!==s?(m=d(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==r||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:r,testId:"issues-shard-input",value:a}),e[24]=r,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(Ve,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Pe.map(l=>(0,t.jsx)(ie,{"data-active":o===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:d(()=>{_(l)},"onClick"),size:"xs",variant:o===l?"default":"outline",children:f(l)},l)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let R;e[34]!==I||e[35]!==c||e[36]!==S?(R=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=R):R=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,R,M&&y.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(W,{children:s("Issue")}),(0,t.jsx)(W,{children:s("Status")}),(0,t.jsx)(W,{children:s("Severity")}),(0,t.jsx)(W,{children:s("Assignee")}),(0,t.jsx)(W,{className:"text-right",children:s("Events")}),(0,t.jsx)(W,{children:s("Last seen")}),(0,t.jsx)(W,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Re,{children:y.map(l=>(0,t.jsx)(is,{busy:C.has(l.hash),issue:l,rowError:K.get(l.hash),runTriage:b,shardKey:i},l.hash))})]})})})]}),e[4]=K,e[5]=C,e[6]=$,e[7]=T,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=r,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"ks");function ls(n){return!n}d(ls,"ts");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}d(rs,"as");function ns(){return new Set}d(ns,"is");function os(){return new Map}d(os,"rs");export{ks as IssuesPanel};
1
+ import{a as We,b as De,c as Fe,d as Oe,e as be}from"./chunk-UU2QJMGJ.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as qe}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as ze}from"./chunk-3CWGJYBB.js";import{a as _e}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ie}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as Te}from"./chunk-SHMNA6UL.js";import{f as Ne}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{a as Le,b as je,c as Re,d as pe,e as W,f as L}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import{d as ue,f as le,g as we,h as Ke,m as re,q as Ee}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-XNGYYOLS.js";import{a as d,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var ne=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=le(D.resolveIssue),Xe=le(D.ignoreIssue),Ue=le(D.assignIssue),Ye=le(D.setIssueSeverity),Ze=le(D.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Ye"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ze"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Pe"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:C,run:j}=qe(),K;e[0]!==i||e[1]!==s||e[2]!==j||e[3]!==$?(K=d(()=>{o(void 0),j(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,we($));o(I)})},"K"),e[0]=i,e[1]=s,e[2]=j,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let E=k,T=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==E||e[14]!==s.hash||e[15]!==r?(v=E===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:E}),e[13]=E,e[14]=s.hash,e[15]=r,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let w=`issues-explain-${s.hash}`,b;e[20]!==_||e[21]!==r?(b=r(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=r,e[22]=b):b=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==b||e[26]!==w?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":w,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:b})}),e[23]=_,e[24]=z,e[25]=b,e[26]=w,e[27]=m):m=e[27];let f;e[28]!==C||e[29]!==s.hash?(f=C!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:C}),e[28]=C,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==r?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==T?(S=(0,t.jsx)(pe,{"data-testid":T,children:c}),e[41]=c,e[42]=T,e[43]=S):S=e[43],S},"es"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[o,_]=(0,ne.useState)(!1),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=d(()=>{_(ls)},"C"),e[0]=C):C=e[0];let j=C,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;re(i(s.hash,Ye,{severity:ce}))},"K"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"k"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let E=k,T=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let w;e[12]!==s.title?(w=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=w):w=e[13];let b;e[14]!==s.culprit?(b=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=b):b=e[15];let m;e[16]!==w||e[17]!==b?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[w,b]}),e[16]=w,e[17]=b,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:j,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let R=s.severity??Se,l;e[37]!==a?(l=a("Set severity"),e[37]=a,e[38]=l):l=e[38];let oe=`issues-severity-${s.hash}`,q;e[39]!==a?(q=a("\u2014"),e[39]=a,e[40]=q):q=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let A;e[44]!==q||e[45]!==N?(A=(0,t.jsx)(De,{placeholder:q,children:N}),e[44]=q,e[45]=N,e[46]=A):A=e[46];let V;e[47]!==l||e[48]!==oe||e[49]!==A?(V=(0,t.jsx)(Fe,{"aria-label":l,className:"h-7 w-[110px]","data-testid":oe,children:A}),e[47]=l,e[48]=oe,e[49]=A,e[50]=V):V=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Je.map(rs),e[51]=de):de=e[51];let F;e[52]!==a?(F=a("Clear"),e[52]=a,e[53]=F):F=e[53];let O;e[54]!==F?(O=(0,t.jsxs)(Oe,{children:[de,(0,t.jsx)(be,{value:Se,children:F})]}),e[54]=F,e[55]=O):O=e[55];let U;e[56]!==u||e[57]!==z||e[58]!==R||e[59]!==V||e[60]!==O?(U=(0,t.jsx)(L,{children:(0,t.jsxs)(We,{disabled:u,onValueChange:z,value:R,children:[V,O]})}),e[56]=u,e[57]=z,e[58]=R,e[59]=V,e[60]=O,e[61]=U):U=e[61];let B;e[62]!==a?(B=a("Assignee"),e[62]=a,e[63]=B):B=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==E||e[68]!==B||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(ke,{"aria-label":B,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:E,placeholder:G},ve)}),e[66]=u,e[67]=E,e[68]=B,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let P;e[74]!==s.count?(P=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=P):P=e[75];let J;e[76]!==s.lastSeen?(J=Ee(s.lastSeen),e[76]=s.lastSeen,e[77]=J):J=e[77];let Q;e[78]!==J?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:J}),e[78]=J,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==U||e[106]!==H||e[107]!==P||e[108]!==Q||e[109]!==T||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":T,children:[c,I,U,H,P,Q,ee]}),e[103]=c,e[104]=I,e[105]=U,e[106]=H,e[107]=P,e[108]=Q,e[109]=T,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==r?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:r},s.sampleMessage),e[112]=o,e[113]=s,e[114]=r,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"ss"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:r,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[C,j]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let E;e[2]!==i?(E={live:!0,shardKey:i},e[2]=i,e[3]=E):E=e[3];let{data:T,error:h,liveError:x}=Te(D.getIssues,k,E),M=T!==void 0,v;if(e[4]!==K||e[5]!==C||e[6]!==$||e[7]!==T||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==r||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(T),w;e[17]!==$||e[18]!==i?(w=d(async(l,oe,q)=>{z(N=>{if(!N.has(l))return N;let A=new Map(N);return A.delete(l),A}),j(N=>new Set(N).add(l));try{await $.query(oe,{...q,hash:l},we(i))}catch(N){let A=Ke(N);z(V=>new Map(V).set(l,A))}j(N=>{let A=new Set(N);return A.delete(l),A})},"N"),e[17]=$,e[18]=i,e[19]=w):w=e[19];let b=w,m;e[20]!==s?(m=d(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==r||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:r,testId:"issues-shard-input",value:a}),e[24]=r,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(Ve,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Pe.map(l=>(0,t.jsx)(ie,{"data-active":o===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:d(()=>{_(l)},"onClick"),size:"xs",variant:o===l?"default":"outline",children:f(l)},l)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let R;e[34]!==I||e[35]!==c||e[36]!==S?(R=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=R):R=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,R,M&&y.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(W,{children:s("Issue")}),(0,t.jsx)(W,{children:s("Status")}),(0,t.jsx)(W,{children:s("Severity")}),(0,t.jsx)(W,{children:s("Assignee")}),(0,t.jsx)(W,{className:"text-right",children:s("Events")}),(0,t.jsx)(W,{children:s("Last seen")}),(0,t.jsx)(W,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Re,{children:y.map(l=>(0,t.jsx)(is,{busy:C.has(l.hash),issue:l,rowError:K.get(l.hash),runTriage:b,shardKey:i},l.hash))})]})})})]}),e[4]=K,e[5]=C,e[6]=$,e[7]=T,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=r,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"ks");function ls(n){return!n}d(ls,"ts");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}d(rs,"as");function ns(){return new Set}d(ns,"is");function os(){return new Map}d(os,"rs");export{ks as IssuesPanel};
@@ -1 +1 @@
1
- import{a as yt}from"./chunk-V53KNYRN.js";import{a as St}from"./chunk-NCWUTRZB.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-TS6346VY.js";import{f as re}from"./chunk-MIFLRBVS.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-XNGYYOLS.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-JFW3YNVQ.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-SHMNA6UL.js";import{f as re}from"./chunk-V2U5CL3S.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-XNGYYOLS.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{b as de,c as ie}from"./chunk-KUVMORDQ.js";import{a as le}from"./chunk-QWGT25SE.js";import{a as oe}from"./chunk-CTNB2KIA.js";import{a as se}from"./chunk-3CWGJYBB.js";import{a as ae}from"./chunk-X665E2HU.js";import{b as re}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Y}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as X}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ne}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as te}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as z,q as V}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as y,e as J,f as ue,g as he,h as fe,j as Q}from"./chunk-3XIESWL4.js";var H=J(he(),1),F=J(ue(),1);var a=J(fe(),1);var ce=y(o=>Math.min(100,Math.max(0,o)),"Q"),pe=y((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=ce(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:r}},"ue"),ge=y((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"he"),G=y(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","U"),xe=14,be=y(o=>Array.isArray(o?.traces)?o.traces:[],"pe"),we=y(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=pe(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:p,widthPercent:k}=n,g;e[3]!==t.attributes?(g=le(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];let P=g,T=t.depth*xe,C;e[5]!==T?(C={paddingLeft:T},e[5]=T,e[6]=C):C=e[6];let x=C,b=`${String(p)}%`,w=`${String(k)}%`,l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];let d=l,I=t.depth,u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let i;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(i=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=i):i=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",c;e[21]!==N?(c=Q("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==d||e[24]!==p||e[25]!==c||e[26]!==k?(m=(0,a.jsx)("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":k,style:d}),e[23]=d,e[24]=p,e[25]=c,e[26]=k,e[27]=m):m=e[27];let f;e[28]!==i||e[29]!==m?(f=(0,a.jsx)("span",{"aria-label":i,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=i,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=G(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let _;e[37]!==S?(_=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=_):_=e[38];let $;e[39]!==P?($=P===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:P,children:P}),e[39]=P,e[40]=$):$=e[40];let E;e[41]!==$?(E=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:$}),e[41]=$,e[42]=E):E=e[42];let j;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==_||e[48]!==E?(j=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":I,"data-testid":"tr-span-row",role:"row",children:[h,f,v,_,E]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=_,e[48]=E,e[49]=j):j=e[49],j},"ge"),Ne=y(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),p;e[0]!==s||e[1]!==r.traceId?(p=y(()=>{s(r.traceId)},"p"),e[0]=s,e[1]=r.traceId,e[2]=p):p=e[2];let k=p,g=`tr-row-${r.traceId}`,P=`tr-waterfall-${r.traceId}`,T=`tr-toggle-${r.traceId}`,C=t?"\u25BE":"\u25B8",x;e[3]!==C?(x=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:C}),e[3]=C,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=G(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let d;e[11]!==l?(d=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=d):d=e[12];let I;e[13]!==n||e[14]!==r.spans.length?(I=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=I):I=e[15];let u;e[16]!==I?(u=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:I}),e[16]=I,e[17]=u):u=e[17];let h=r.ok?"secondary":"destructive",i;e[18]!==n||e[19]!==r.ok?(i=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=i):i=e[20];let N;e[21]!==h||e[22]!==i?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(X,{variant:h,children:i})}),e[21]=h,e[22]=i,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=V(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==k||e[30]!==d||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==P||e[35]!==T||e[36]!==x||e[37]!==b||e[38]!==w?(f=(0,a.jsxs)("button",{"aria-controls":P,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":T,onClick:k,type:"button",children:[x,b,w,d,u,N,m]}),e[28]=t,e[29]=k,e[30]=d,e[31]=u,e[32]=N,e[33]=m,e[34]=P,e[35]=T,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(we,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},"xe"),De=y(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,F.useState)(de),{queryShardKey:n,setShardKey:p,shardKey:k}=se(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,P]=(0,F.useState)(r?.traceId??""),[T,C]=(0,F.useState)(Me),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],(0,F.useEffect)(ve,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];let{data:l,error:d,errorSource:I,isLoading:u,liveError:h}=ee(te.getTraces,b,w),i,N;e[4]!==l||e[5]!==n?(i=y(()=>{l!==void 0&&re(n)},"d"),N=[l,n],e[4]=l,e[5]=n,e[6]=i,e[7]=N):(i=e[6],N=e[7]),(0,F.useEffect)(i,N);let c;if(e[8]!==l||e[9]!==d||e[10]!==I||e[11]!==T||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==k||e[17]!==s){let m=be(l),f=l?.total??m.length,M=f>m.length,v=ge(m,g),S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=y(K=>{P(K.target.value)},"S"),e[19]=S):S=e[19];let _=S,$;e[20]===Symbol.for("react.memo_cache_sentinel")?($=y(K=>{C(me=>{let W=new Set(me);return W.has(K)?W.delete(K):W.add(K),W})},"T"),e[20]=$):$=e[20];let E=$,j=d===null&&v.length===0&&!u,L;e[21]!==p||e[22]!==k?(L=(0,a.jsx)(ae,{onChange:p,testId:"tr-shard-input",value:k}),e[21]=p,e[22]=k,e[23]=L):L=e[23];let A;e[24]!==s?(A=s("Search traces"),e[24]=s,e[25]=A):A=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let q;e[28]!==g||e[29]!==A||e[30]!==D?(q=(0,a.jsx)(Y,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:_,placeholder:D,value:g}),e[28]=g,e[29]=A,e[30]=D,e[31]=q):q=e[31];let B;e[32]!==h?(B=(0,a.jsx)(oe,{message:h,prefix:"tr"}),e[32]=h,e[33]=B):B=e[33];let O;e[34]!==q||e[35]!==B||e[36]!==L?(O=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L,q,B]}),e[34]=q,e[35]=B,e[36]=L,e[37]=O):O=e[37];let R;e[38]!==d||e[39]!==I?(R=d!==null&&(0,a.jsx)(ne,{error:I,testId:"tr-error"}),e[38]=d,e[39]=I,e[40]=R):R=e[40];let U;e[41]!==j||e[42]!==s?(U=j&&(0,a.jsx)(Z,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=j,e[42]=s,e[43]=U):U=e[43],c=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[O,R,U,d===null&&M&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),d===null&&v.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(K=>(0,a.jsx)(Ne,{expanded:T.has(K.traceId),onToggle:E,trace:K},K.traceId))})]}),e[8]=l,e[9]=d,e[10]=I,e[11]=T,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=k,e[17]=s,e[18]=c}else c=e[18];return c},"je");function Me(){return new Set}y(Me,"be");function ve(){ie()}y(ve,"we");export{De as TracesPanel};
1
+ import{b as de,c as ie}from"./chunk-KUVMORDQ.js";import{a as le}from"./chunk-QWGT25SE.js";import{a as oe}from"./chunk-CTNB2KIA.js";import{a as se}from"./chunk-3CWGJYBB.js";import{a as ae}from"./chunk-X665E2HU.js";import{b as re}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Y}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as X}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ne}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as te}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{d as z,q as V}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as y,e as J,f as ue,g as he,h as fe,j as Q}from"./chunk-3XIESWL4.js";var H=J(he(),1),F=J(ue(),1);var a=J(fe(),1);var ce=y(o=>Math.min(100,Math.max(0,o)),"Q"),pe=y((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=ce(o.offsetMs/e*100),s=o.durationMs/e*100,r=Math.max(.5,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:r}},"ue"),ge=y((o,e)=>{let t=e.trim().toLowerCase();return t===""?[...o]:o.filter(s=>s.rootName.toLowerCase().includes(t)||s.functionPath.toLowerCase().includes(t)||s.traceId.toLowerCase().includes(t))},"he"),G=y(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","U"),xe=14,be=y(o=>Array.isArray(o?.traces)?o.traces:[],"pe"),we=y(o=>{let e=(0,H.c)(50),{span:t,traceDurationMs:s}=o,r=z(),n;e[0]!==t||e[1]!==s?(n=pe(t,s),e[0]=t,e[1]=s,e[2]=n):n=e[2];let{leftPercent:p,widthPercent:k}=n,g;e[3]!==t.attributes?(g=le(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];let P=g,T=t.depth*xe,C;e[5]!==T?(C={paddingLeft:T},e[5]=T,e[6]=C):C=e[6];let x=C,b=`${String(p)}%`,w=`${String(k)}%`,l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];let d=l,I=t.depth,u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:(0,a.jsx)("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=(0,a.jsxs)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let i;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(i=r("starts {offset} in, runs {duration}",{duration:G(t.durationMs),offset:G(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=i):i=e[20];let N=t.ok?"bg-primary/70":"bg-destructive",c;e[21]!==N?(c=Q("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==d||e[24]!==p||e[25]!==c||e[26]!==k?(m=(0,a.jsx)("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":k,style:d}),e[23]=d,e[24]=p,e[25]=c,e[26]=k,e[27]=m):m=e[27];let f;e[28]!==i||e[29]!==m?(f=(0,a.jsx)("span",{"aria-label":i,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=i,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=G(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=(0,a.jsx)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:(0,a.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let _;e[37]!==S?(_=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=_):_=e[38];let $;e[39]!==P?($=P===""?null:(0,a.jsx)("span",{"data-testid":"tr-span-attributes",title:P,children:P}),e[39]=P,e[40]=$):$=e[40];let E;e[41]!==$?(E=(0,a.jsx)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:$}),e[41]=$,e[42]=E):E=e[42];let j;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==_||e[48]!==E?(j=(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":I,"data-testid":"tr-span-row",role:"row",children:[h,f,v,_,E]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=_,e[48]=E,e[49]=j):j=e[49],j},"ge"),Ne=y(o=>{let e=(0,H.c)(50),{expanded:t,onToggle:s,trace:r}=o,n=z(),p;e[0]!==s||e[1]!==r.traceId?(p=y(()=>{s(r.traceId)},"p"),e[0]=s,e[1]=r.traceId,e[2]=p):p=e[2];let k=p,g=`tr-row-${r.traceId}`,P=`tr-waterfall-${r.traceId}`,T=`tr-toggle-${r.traceId}`,C=t?"\u25BE":"\u25B8",x;e[3]!==C?(x=(0,a.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:C}),e[3]=C,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=(0,a.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=(0,a.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=G(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let d;e[11]!==l?(d=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=d):d=e[12];let I;e[13]!==n||e[14]!==r.spans.length?(I=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=I):I=e[15];let u;e[16]!==I?(u=(0,a.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:I}),e[16]=I,e[17]=u):u=e[17];let h=r.ok?"secondary":"destructive",i;e[18]!==n||e[19]!==r.ok?(i=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=i):i=e[20];let N;e[21]!==h||e[22]!==i?(N=(0,a.jsx)("span",{className:"shrink-0",children:(0,a.jsx)(X,{variant:h,children:i})}),e[21]=h,e[22]=i,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=V(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=(0,a.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==k||e[30]!==d||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==P||e[35]!==T||e[36]!==x||e[37]!==b||e[38]!==w?(f=(0,a.jsxs)("button",{"aria-controls":P,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":T,onClick:k,type:"button",children:[x,b,w,d,u,N,m]}),e[28]=t,e[29]=k,e[30]=d,e[31]=u,e[32]=N,e[33]=m,e[34]=P,e[35]=T,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&(0,a.jsx)("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>(0,a.jsx)(we,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=(0,a.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},"xe"),De=y(o=>{let e=(0,H.c)(44),{initialShardKey:t}=o,s=z(),[r]=(0,F.useState)(de),{queryShardKey:n,setShardKey:p,shardKey:k}=se(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,P]=(0,F.useState)(r?.traceId??""),[T,C]=(0,F.useState)(Me),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],(0,F.useEffect)(ve,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];let{data:l,error:d,errorSource:I,isLoading:u,liveError:h}=ee(te.getTraces,b,w),i,N;e[4]!==l||e[5]!==n?(i=y(()=>{l!==void 0&&re(n)},"d"),N=[l,n],e[4]=l,e[5]=n,e[6]=i,e[7]=N):(i=e[6],N=e[7]),(0,F.useEffect)(i,N);let c;if(e[8]!==l||e[9]!==d||e[10]!==I||e[11]!==T||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==k||e[17]!==s){let m=be(l),f=l?.total??m.length,M=f>m.length,v=ge(m,g),S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=y(K=>{P(K.target.value)},"S"),e[19]=S):S=e[19];let _=S,$;e[20]===Symbol.for("react.memo_cache_sentinel")?($=y(K=>{C(me=>{let W=new Set(me);return W.has(K)?W.delete(K):W.add(K),W})},"T"),e[20]=$):$=e[20];let E=$,j=d===null&&v.length===0&&!u,L;e[21]!==p||e[22]!==k?(L=(0,a.jsx)(ae,{onChange:p,testId:"tr-shard-input",value:k}),e[21]=p,e[22]=k,e[23]=L):L=e[23];let A;e[24]!==s?(A=s("Search traces"),e[24]=s,e[25]=A):A=e[25];let D;e[26]!==s?(D=s("search trace or function"),e[26]=s,e[27]=D):D=e[27];let q;e[28]!==g||e[29]!==A||e[30]!==D?(q=(0,a.jsx)(Y,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:_,placeholder:D,value:g}),e[28]=g,e[29]=A,e[30]=D,e[31]=q):q=e[31];let B;e[32]!==h?(B=(0,a.jsx)(oe,{message:h,prefix:"tr"}),e[32]=h,e[33]=B):B=e[33];let O;e[34]!==q||e[35]!==B||e[36]!==L?(O=(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L,q,B]}),e[34]=q,e[35]=B,e[36]=L,e[37]=O):O=e[37];let R;e[38]!==d||e[39]!==I?(R=d!==null&&(0,a.jsx)(ne,{error:I,testId:"tr-error"}),e[38]=d,e[39]=I,e[40]=R):R=e[40];let U;e[41]!==j||e[42]!==s?(U=j&&(0,a.jsx)(Z,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[41]=j,e[42]=s,e[43]=U):U=e[43],c=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[O,R,U,d===null&&M&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),d===null&&v.length>0&&(0,a.jsx)("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(K=>(0,a.jsx)(Ne,{expanded:T.has(K.traceId),onToggle:E,trace:K},K.traceId))})]}),e[8]=l,e[9]=d,e[10]=I,e[11]=T,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=k,e[17]=s,e[18]=c}else c=e[18];return c},"je");function Me(){return new Set}y(Me,"be");function ve(){ie()}y(ve,"we");export{De as TracesPanel};
@@ -1 +1 @@
1
- import{a as re}from"./chunk-CTNB2KIA.js";import{a as X}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as R}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as O}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Y}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as Q}from"./chunk-VDW32UET.js";import{c as J}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as G}from"./chunk-XQCVZAGU.js";import{a as Z,b as ee,c as te,d as z,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as U,e as W}from"./chunk-UZERI5YC.js";import{d as B,q as H}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a,e as T,f as de,g as me,h as he,j as P}from"./chunk-3XIESWL4.js";var le=T(me(),1),ae=T(de(),1);var t=T(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},se=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"z"),fe=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=a(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:a((r,e)=>e.calls-r.calls,"calls"),recent:a((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ee=a(r=>{let e=(0,le.c)(47),{functions:K,initialShardKey:ne}=r,l=B(),{queryShardKey:_,setShardKey:y,shardKey:v}=X(ne),[i,oe]=(0,ae.useState)("recent"),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let $;e[1]!==_?($={live:!0,shardKey:_},e[1]=_,e[2]=$):$=e[2];let{data:ie,error:c,errorSource:S,liveError:k}=J(Q.getFunctionStats,w,$),b=ie?.functions??null,C;e[3]!==K?(C=new Map((K??[]).map(ge)),e[3]=K,e[4]=C):C=e[4];let j=C,F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=a(M=>{oe(M.currentTarget.dataset.sort)},"C"),e[5]=F):F=e[5];let ce=F,I;if(e[6]!==c||e[7]!==S||e[8]!==j||e[9]!==k||e[10]!==y||e[11]!==v||e[12]!==i||e[13]!==b||e[14]!==l){let M=b===null?[]:b.toSorted(xe[i]),d;e[16]!==l?(d=l("Recent"),e[16]=l,e[17]=d):d=e[17];let m;e[18]!==d?(m={key:"recent",label:d},e[18]=d,e[19]=m):m=e[19];let h;e[20]!==l?(h=l("Most called"),e[20]=l,e[21]=h):h=e[21];let u;e[22]!==h?(u={key:"calls",label:h},e[22]=h,e[23]=u):u=e[23];let f;e[24]!==l?(f=l("Slowest"),e[24]=l,e[25]=f):f=e[25];let p;e[26]!==f?(p={key:"slowest",label:f},e[26]=f,e[27]=p):p=e[27];let A;e[28]!==p||e[29]!==m||e[30]!==u?(A=[m,u,p],e[28]=p,e[29]=m,e[30]=u,e[31]=A):A=e[31];let q=A,x;e[32]!==y||e[33]!==v?(x=(0,t.jsx)(V,{onChange:y,testId:"fs-shard-input",value:v}),e[32]=y,e[33]=v,e[34]=x):x=e[34];let g;e[35]!==k?(g=(0,t.jsx)(re,{message:k,prefix:"fs"}),e[35]=k,e[36]=g):g=e[36];let N;e[37]!==q||e[38]!==i?(N=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:q.map(s=>(0,t.jsx)(R,{"data-sort":s.key,"data-testid":`fs-sort-${s.key}`,onClick:ce,size:"sm",type:"button",variant:i===s.key?"secondary":"ghost",children:s.label},s.key))}),e[37]=q,e[38]=i,e[39]=N):N=e[39];let D;e[40]!==x||e[41]!==g||e[42]!==N?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,N]}),e[40]=x,e[41]=g,e[42]=N,e[43]=D):D=e[43];let E;e[44]!==c||e[45]!==S?(E=c!==null&&(0,t.jsx)(Y,{error:S,testId:"fs-error"}),e[44]=c,e[45]=S,e[46]=E):E=e[46],I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,b!==null&&M.length===0&&c===null&&(0,t.jsx)(G,{description:l("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxs)("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:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:l("No functions have run on this shard yet.")}),M.length>0&&(0,t.jsx)(U,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(n,{children:l("function")}),(0,t.jsx)(n,{children:l("kind")}),(0,t.jsx)(n,{className:"text-right",children:l("calls")}),(0,t.jsx)(n,{className:"text-right",children:l("errors")}),(0,t.jsx)(n,{className:"text-right",children:l("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:l("avg")}),(0,t.jsx)(n,{className:"text-right",children:l("max")}),(0,t.jsx)(n,{children:l("last run")}),(0,t.jsx)(n,{children:l("last error")})]})}),(0,t.jsx)(te,{children:M.map(s=>{let L=j.get(s.path);return(0,t.jsxs)(z,{"data-testid":`fs-row-${s.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:s.path}),(0,t.jsx)(o,{children:L===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(O,{variant:ue[L],children:L})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls}),(0,t.jsx)(o,{className:P("text-right tabular-nums",s.errors>0&&"text-destructive"),children:fe(s)}),(0,t.jsx)(o,{className:P("text-right tabular-nums",(s.conflicts??0)>0&&"text-warning"),children:pe(s)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":se(s.totalDurationMs/s.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":se(s.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:H(s.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:s.lastErrorMessage??void 0,children:s.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.path)})})]})})})]}),e[6]=c,e[7]=S,e[8]=j,e[9]=k,e[10]=y,e[11]=v,e[12]=i,e[13]=b,e[14]=l,e[15]=I}else I=e[15];return I},"Ae");function ge(r){return[r.path,r.kind]}a(ge,"he");export{Ee as FunctionStatsPanel};
1
+ import{a as re}from"./chunk-CTNB2KIA.js";import{a as X}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as R}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as O}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Y}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as Q}from"./chunk-VDW32UET.js";import{c as J}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as G}from"./chunk-XQCVZAGU.js";import{a as Z,b as ee,c as te,d as z,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as U,e as W}from"./chunk-UZERI5YC.js";import{d as B,q as H}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a,e as T,f as de,g as me,h as he,j as P}from"./chunk-3XIESWL4.js";var le=T(me(),1),ae=T(de(),1);var t=T(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},se=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"z"),fe=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=a(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:a((r,e)=>e.calls-r.calls,"calls"),recent:a((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ee=a(r=>{let e=(0,le.c)(47),{functions:K,initialShardKey:ne}=r,l=B(),{queryShardKey:_,setShardKey:y,shardKey:v}=X(ne),[i,oe]=(0,ae.useState)("recent"),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let $;e[1]!==_?($={live:!0,shardKey:_},e[1]=_,e[2]=$):$=e[2];let{data:ie,error:c,errorSource:S,liveError:k}=J(Q.getFunctionStats,w,$),b=ie?.functions??null,C;e[3]!==K?(C=new Map((K??[]).map(ge)),e[3]=K,e[4]=C):C=e[4];let j=C,F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=a(M=>{oe(M.currentTarget.dataset.sort)},"C"),e[5]=F):F=e[5];let ce=F,I;if(e[6]!==c||e[7]!==S||e[8]!==j||e[9]!==k||e[10]!==y||e[11]!==v||e[12]!==i||e[13]!==b||e[14]!==l){let M=b===null?[]:b.toSorted(xe[i]),d;e[16]!==l?(d=l("Recent"),e[16]=l,e[17]=d):d=e[17];let m;e[18]!==d?(m={key:"recent",label:d},e[18]=d,e[19]=m):m=e[19];let h;e[20]!==l?(h=l("Most called"),e[20]=l,e[21]=h):h=e[21];let u;e[22]!==h?(u={key:"calls",label:h},e[22]=h,e[23]=u):u=e[23];let f;e[24]!==l?(f=l("Slowest"),e[24]=l,e[25]=f):f=e[25];let p;e[26]!==f?(p={key:"slowest",label:f},e[26]=f,e[27]=p):p=e[27];let A;e[28]!==p||e[29]!==m||e[30]!==u?(A=[m,u,p],e[28]=p,e[29]=m,e[30]=u,e[31]=A):A=e[31];let q=A,x;e[32]!==y||e[33]!==v?(x=(0,t.jsx)(V,{onChange:y,testId:"fs-shard-input",value:v}),e[32]=y,e[33]=v,e[34]=x):x=e[34];let g;e[35]!==k?(g=(0,t.jsx)(re,{message:k,prefix:"fs"}),e[35]=k,e[36]=g):g=e[36];let N;e[37]!==q||e[38]!==i?(N=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:q.map(s=>(0,t.jsx)(R,{"data-sort":s.key,"data-testid":`fs-sort-${s.key}`,onClick:ce,size:"sm",type:"button",variant:i===s.key?"secondary":"ghost",children:s.label},s.key))}),e[37]=q,e[38]=i,e[39]=N):N=e[39];let D;e[40]!==x||e[41]!==g||e[42]!==N?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,N]}),e[40]=x,e[41]=g,e[42]=N,e[43]=D):D=e[43];let E;e[44]!==c||e[45]!==S?(E=c!==null&&(0,t.jsx)(Y,{error:S,testId:"fs-error"}),e[44]=c,e[45]=S,e[46]=E):E=e[46],I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,b!==null&&M.length===0&&c===null&&(0,t.jsx)(G,{description:l("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxs)("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:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:l("No functions have run on this shard yet.")}),M.length>0&&(0,t.jsx)(U,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(z,{children:[(0,t.jsx)(n,{children:l("function")}),(0,t.jsx)(n,{children:l("kind")}),(0,t.jsx)(n,{className:"text-right",children:l("calls")}),(0,t.jsx)(n,{className:"text-right",children:l("errors")}),(0,t.jsx)(n,{className:"text-right",children:l("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:l("avg")}),(0,t.jsx)(n,{className:"text-right",children:l("max")}),(0,t.jsx)(n,{children:l("last run")}),(0,t.jsx)(n,{children:l("last error")})]})}),(0,t.jsx)(te,{children:M.map(s=>{let L=j.get(s.path);return(0,t.jsxs)(z,{"data-testid":`fs-row-${s.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:s.path}),(0,t.jsx)(o,{children:L===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(O,{variant:ue[L],children:L})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls}),(0,t.jsx)(o,{className:P("text-right tabular-nums",s.errors>0&&"text-destructive"),children:fe(s)}),(0,t.jsx)(o,{className:P("text-right tabular-nums",(s.conflicts??0)>0&&"text-warning"),children:pe(s)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":se(s.totalDurationMs/s.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:s.calls===0?"\u2014":se(s.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:H(s.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:s.lastErrorMessage??void 0,children:s.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},s.path)})})]})})})]}),e[6]=c,e[7]=S,e[8]=j,e[9]=k,e[10]=y,e[11]=v,e[12]=i,e[13]=b,e[14]=l,e[15]=I}else I=e[15];return I},"Ae");function ge(r){return[r.path,r.kind]}a(ge,"he");export{Ee as FunctionStatsPanel};
@@ -1 +1 @@
1
- import{b as l}from"./chunk-TS6346VY.js";import{f as c}from"./chunk-MIFLRBVS.js";import{a as r,e as f,g}from"./chunk-3XIESWL4.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=c(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"o"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=l(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"A");export{y as a};
1
+ import{b as l}from"./chunk-SHMNA6UL.js";import{f as c}from"./chunk-V2U5CL3S.js";import{a as r,e as f,g}from"./chunk-3XIESWL4.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=c(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"o"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=l(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"A");export{y as a};
@@ -1 +1 @@
1
- import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as F,d as f,e as l,f as s}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as x}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as n,e as p,f as L,h as _}from"./chunk-3XIESWL4.js";var C=p(L(),1);var e=p(_(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"_"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,C.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,V=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],d;return u&&!V?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(F,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(T,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"X");export{Y as FlagsPanel};
1
+ import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as F,d as f,e as l,f as s}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as x}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as n,e as p,f as L,h as _}from"./chunk-3XIESWL4.js";var C=p(L(),1);var e=p(_(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"_"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,C.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,V=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],d;return u&&!V?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(F,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(T,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"X");export{Y as FlagsPanel};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-XXQUMVWH.js";import{a as O}from"./chunk-PNAVAJAF.js";import{b as q}from"./chunk-QLQADHFE.js";import{d as A,h as C,j as E,k as H}from"./chunk-OG4N2XHD.js";import{a as V}from"./chunk-XNGYYOLS.js";import{a as y,e as I,g as T,h as _}from"./chunk-3XIESWL4.js";var G=I(T(),1);var i=I(_(),1);var L=y(S=>{let e=(0,G.c)(38),{className:w,error:t,testId:N}=S,g=A(),r=q(),l,s,n,a,c,m,o,d;if(e[0]!==w||e[1]!==t||e[2]!==r||e[3]!==N){let j=E(t),h;e[12]!==t?(h=H(t),e[12]=t,e[13]=h):h=e[13],s=h;let x;e[14]!==t?(x=O(t),e[14]=t,e[15]=x):x=e[15];let k=x,v;e[16]!==r||e[17]!==k?(v=y(()=>{r?.openConsole({errorsOnly:!0,seq:k})},"x"),e[16]=r,e[17]=k,e[18]=v):v=e[18],n=v,l=D,a=w,c=N,m="destructive";let u;e[19]!==t?(u=C(t),e[19]=t,e[20]=u):u=e[20],e[21]!==u?(o=(0,i.jsx)("p",{className:"font-medium",children:u}),e[21]=u,e[22]=o):o=e[22],d=j===void 0?null:(0,i.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:V(j)}),e[0]=w,e[1]=t,e[2]=r,e[3]=N,e[4]=l,e[5]=s,e[6]=n,e[7]=a,e[8]=c,e[9]=m,e[10]=o,e[11]=d}else l=e[4],s=e[5],n=e[6],a=e[7],c=e[8],m=e[9],o=e[10],d=e[11];let p;e[23]!==s?(p=s===void 0?null:(0,i.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:s,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[23]=s,e[24]=p):p=e[24];let f;e[25]!==r||e[26]!==n||e[27]!==g?(f=r===void 0?null:(0,i.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:n,type:"button",children:g("Show in console")}),e[25]=r,e[26]=n,e[27]=g,e[28]=f):f=e[28];let b;return e[29]!==l||e[30]!==a||e[31]!==c||e[32]!==m||e[33]!==o||e[34]!==d||e[35]!==p||e[36]!==f?(b=(0,i.jsxs)(l,{className:a,testId:c,variant:m,children:[o,d,p,f]}),e[29]=l,e[30]=a,e[31]=c,e[32]=m,e[33]=o,e[34]=d,e[35]=p,e[36]=f,e[37]=b):b=e[37],b},"G");export{L as a};
1
+ import{a as D}from"./chunk-XXQUMVWH.js";import{a as O}from"./chunk-QWBRD6PX.js";import{b as q}from"./chunk-QLQADHFE.js";import{d as A,h as C,j as E,k as H}from"./chunk-OG4N2XHD.js";import{a as V}from"./chunk-XNGYYOLS.js";import{a as y,e as I,g as T,h as _}from"./chunk-3XIESWL4.js";var G=I(T(),1);var i=I(_(),1);var L=y(S=>{let e=(0,G.c)(38),{className:w,error:t,testId:N}=S,g=A(),r=q(),l,s,n,a,c,m,o,d;if(e[0]!==w||e[1]!==t||e[2]!==r||e[3]!==N){let j=E(t),h;e[12]!==t?(h=H(t),e[12]=t,e[13]=h):h=e[13],s=h;let x;e[14]!==t?(x=O(t),e[14]=t,e[15]=x):x=e[15];let k=x,v;e[16]!==r||e[17]!==k?(v=y(()=>{r?.openConsole({errorsOnly:!0,seq:k})},"x"),e[16]=r,e[17]=k,e[18]=v):v=e[18],n=v,l=D,a=w,c=N,m="destructive";let u;e[19]!==t?(u=C(t),e[19]=t,e[20]=u):u=e[20],e[21]!==u?(o=(0,i.jsx)("p",{className:"font-medium",children:u}),e[21]=u,e[22]=o):o=e[22],d=j===void 0?null:(0,i.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:V(j)}),e[0]=w,e[1]=t,e[2]=r,e[3]=N,e[4]=l,e[5]=s,e[6]=n,e[7]=a,e[8]=c,e[9]=m,e[10]=o,e[11]=d}else l=e[4],s=e[5],n=e[6],a=e[7],c=e[8],m=e[9],o=e[10],d=e[11];let p;e[23]!==s?(p=s===void 0?null:(0,i.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:s,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[23]=s,e[24]=p):p=e[24];let f;e[25]!==r||e[26]!==n||e[27]!==g?(f=r===void 0?null:(0,i.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:n,type:"button",children:g("Show in console")}),e[25]=r,e[26]=n,e[27]=g,e[28]=f):f=e[28];let b;return e[29]!==l||e[30]!==a||e[31]!==c||e[32]!==m||e[33]!==o||e[34]!==d||e[35]!==p||e[36]!==f?(b=(0,i.jsxs)(l,{className:a,testId:c,variant:m,children:[o,d,p,f]}),e[29]=l,e[30]=a,e[31]=c,e[32]=m,e[33]=o,e[34]=d,e[35]=p,e[36]=f,e[37]=b):b=e[37],b},"G");export{L as a};
@@ -1 +1 @@
1
- import{a as Y}from"./chunk-QXXIJAD5.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-X665E2HU.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-FW75RYZU.js";import{a as _,b as W}from"./chunk-UR3X4K4T.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-TS6346VY.js";import{f as B}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as A,f as H,g as K,m as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
1
+ import{a as Y}from"./chunk-QXXIJAD5.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-X665E2HU.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-FW75RYZU.js";import{a as _,b as W}from"./chunk-YOUKADZH.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-SHMNA6UL.js";import{f as B}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as A,f as H,g as K,m as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
@@ -1 +1 @@
1
- import{a as O,b as B}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-CTNB2KIA.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{a as A,b as T,c as q,d as p,e as n,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{d as b,q as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as i,e as y,f as ee,h as te}from"./chunk-3XIESWL4.js";var o=y(ee(),1);var e=y(te(),1);var D=80,re=i(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=i((s,t)=>O(s,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(s),[c,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),h=(0,o.useMemo)(()=>f?.entries??[],[f]),m=(0,o.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,o.useRef)(null),v=B({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>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=i(a=>{W(a.target.value)},"k");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)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{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)(z,{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)(A,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{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:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(L,{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
+ import{a as O,b as B}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-CTNB2KIA.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{a as A,b as T,c as q,d as p,e as n,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{d as b,q as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as i,e as y,f as ee,h as te}from"./chunk-3XIESWL4.js";var o=y(ee(),1);var e=y(te(),1);var D=80,re=i(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=i((s,t)=>O(s,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(s),[c,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),h=(0,o.useMemo)(()=>f?.entries??[],[f]),m=(0,o.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,o.useRef)(null),v=B({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>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=i(a=>{W(a.target.value)},"k");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)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{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)(z,{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)(A,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{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:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(L,{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};