@lunora/studio 1.0.0-alpha.341 → 1.0.0-alpha.342

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 (131) hide show
  1. package/dist/index.d.mts +5 -4
  2. package/dist/index.d.ts +5 -4
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.mjs +8 -6
  8. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  9. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  10. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  11. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  12. package/dist/packem_chunks/MailPanel.mjs +1 -1
  13. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  14. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  15. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  16. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  17. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  18. package/dist/packem_chunks/TableEditor.mjs +1 -1
  19. package/dist/packem_chunks/agents-panel.mjs +1 -1
  20. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  21. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  22. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  23. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  24. package/dist/packem_chunks/containers-panel.mjs +1 -1
  25. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  26. package/dist/packem_chunks/evals-panel.mjs +1 -1
  27. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  28. package/dist/packem_chunks/flags-panel.mjs +1 -1
  29. package/dist/packem_chunks/issues-panel.mjs +1 -1
  30. package/dist/packem_chunks/kv-browser.mjs +1 -1
  31. package/dist/packem_chunks/migrations-route.mjs +1 -1
  32. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  33. package/dist/packem_chunks/payments-panel.mjs +1 -1
  34. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  35. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  36. package/dist/packem_chunks/queues-panel.mjs +1 -1
  37. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  38. package/dist/packem_chunks/rls-panel.mjs +1 -1
  39. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  40. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  41. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  42. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  43. package/dist/packem_chunks/traces-panel.mjs +1 -1
  44. package/dist/packem_chunks/users-panel.mjs +1 -1
  45. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  46. package/dist/packem_shared/{DataBrowser-DxlLv5x1.mjs → DataBrowser-BDsxK-Jk.mjs} +1 -1
  47. package/dist/packem_shared/{GlobalDataBrowser-TFTQpSVj.mjs → GlobalDataBrowser-CPfjubP_.mjs} +1 -1
  48. package/dist/packem_shared/{HomePanel-BVz2sDQ4.mjs → HomePanel-C8sb1fFJ.mjs} +1 -1
  49. package/dist/packem_shared/{MigrationsPanel-fUyhbt0w.mjs → MigrationsPanel-Dzjf42y8.mjs} +1 -1
  50. package/dist/packem_shared/{ScheduledJobs-zSeU_6cN.mjs → ScheduledJobs-BJ1uZW1U.mjs} +1 -1
  51. package/dist/packem_shared/{Studio-CNqMkRmB.mjs → Studio-CL3-IiIi.mjs} +1 -1
  52. package/dist/packem_shared/{StudioApp-CUxEVr__.mjs → StudioApp-ClaUkjR_.mjs} +1 -1
  53. package/dist/packem_shared/{advisor-view-CXiPdw4B.mjs → advisor-view-B8oIluyS.mjs} +1 -1
  54. package/dist/packem_shared/{error-alert-D-ftqyo-.mjs → error-alert-CNQjdAhi.mjs} +1 -1
  55. package/dist/packem_shared/{home-panel-CF-MfsnH.mjs → home-panel-BJXZsAaD.mjs} +1 -1
  56. package/dist/packem_shared/{recording-client-CFBkH4uZ.mjs → recording-client-neIRrUNz.mjs} +1 -1
  57. package/dist/packem_shared/{studio-BcHsk7mT.mjs → studio-BSiyNdXi.mjs} +1 -1
  58. package/dist/packem_shared/{table-list-sidebar-DwqtHSHU.mjs → table-list-sidebar-B7IOSxLN.mjs} +1 -1
  59. package/dist/packem_shared/{use-admin-query-I1uILsUP.mjs → use-admin-query-CLStXJ7v.mjs} +1 -1
  60. package/dist/packem_shared/{use-auth-config-DQ8tNyBh.mjs → use-auth-config-DtZeS_qf.mjs} +1 -1
  61. package/dist/packem_shared/{use-sql-assistant-DetnUyFf.mjs → use-sql-assistant-DxNeNdCs.mjs} +1 -1
  62. package/dist/standalone/{chunk-M3QKMHAP.js → chunk-35Q6XYRL.js} +1 -1
  63. package/dist/standalone/{chunk-OLIKYC3C.js → chunk-3BCMZMOX.js} +1 -1
  64. package/dist/standalone/{chunk-VJ7RCBJ7.js → chunk-3BF2QRJM.js} +1 -1
  65. package/dist/standalone/{chunk-VNMKNORK.js → chunk-3F3742NV.js} +1 -1
  66. package/dist/standalone/{chunk-ENIA26XP.js → chunk-4RLRI34N.js} +1 -1
  67. package/dist/standalone/{chunk-7GVT36VI.js → chunk-5CW7W7LQ.js} +1 -1
  68. package/dist/standalone/{chunk-43GV7LQK.js → chunk-5DKOUMFY.js} +1 -1
  69. package/dist/standalone/{chunk-O2FW4VRL.js → chunk-5QTTNVDW.js} +1 -1
  70. package/dist/standalone/{chunk-K3UAOIR7.js → chunk-5X7LJ6UT.js} +1 -1
  71. package/dist/standalone/{chunk-VENSZ6LF.js → chunk-66MXYZBW.js} +1 -1
  72. package/dist/standalone/{chunk-R3ADWOYR.js → chunk-6ZRYMZEX.js} +1 -1
  73. package/dist/standalone/{chunk-UVL7N5IL.js → chunk-A4WUN5R3.js} +1 -1
  74. package/dist/standalone/{chunk-KF7Y5S5O.js → chunk-ATVJ7XYZ.js} +1 -1
  75. package/dist/standalone/{chunk-HPYJUVCC.js → chunk-BEODZ54J.js} +1 -1
  76. package/dist/standalone/{chunk-GWVYDOBH.js → chunk-CT7KV34V.js} +1 -1
  77. package/dist/standalone/{chunk-HCFJBY65.js → chunk-CUIPEXIW.js} +1 -1
  78. package/dist/standalone/{chunk-VVCXVAA7.js → chunk-D6CNULEI.js} +1 -1
  79. package/dist/standalone/{chunk-UIIKW4II.js → chunk-DD7J6RMR.js} +1 -1
  80. package/dist/standalone/{chunk-DHGPCQ2F.js → chunk-DFVQBXUZ.js} +1 -1
  81. package/dist/standalone/{chunk-4NOMAGEO.js → chunk-DNIDQC3K.js} +1 -1
  82. package/dist/standalone/{chunk-LHG2JVIM.js → chunk-DQAXICZV.js} +1 -1
  83. package/dist/standalone/{chunk-BFQMOALO.js → chunk-E57JT34T.js} +1 -1
  84. package/dist/standalone/{chunk-SU6QNITV.js → chunk-EJSTZM7A.js} +1 -1
  85. package/dist/standalone/{chunk-BTG6YDYM.js → chunk-EUTV2OGD.js} +1 -1
  86. package/dist/standalone/{chunk-5SLTDY4C.js → chunk-EYTZURBK.js} +1 -1
  87. package/dist/standalone/{chunk-DBZ4TBP5.js → chunk-FMSWGAHK.js} +1 -1
  88. package/dist/standalone/{chunk-ICRKYAYO.js → chunk-FR2MJIZG.js} +1 -1
  89. package/dist/standalone/{chunk-3FYMEXVB.js → chunk-G5P5DUVD.js} +1 -1
  90. package/dist/standalone/{chunk-GC4XRCRZ.js → chunk-GTEER76O.js} +1 -1
  91. package/dist/standalone/{chunk-NCBLHBRW.js → chunk-GWCMBJ2U.js} +1 -1
  92. package/dist/standalone/{chunk-GYBCO7NN.js → chunk-GXRBCKNP.js} +1 -1
  93. package/dist/standalone/{chunk-G2F22AMT.js → chunk-HXC2I6YI.js} +1 -1
  94. package/dist/standalone/{chunk-RB3WPSY5.js → chunk-IC2NNXPZ.js} +1 -1
  95. package/dist/standalone/{chunk-YZ72ZAGX.js → chunk-IDX6KQRG.js} +1 -1
  96. package/dist/standalone/chunk-ITFHDBLD.js +8 -0
  97. package/dist/standalone/{chunk-HH52IEFY.js → chunk-J5CU2YKR.js} +1 -1
  98. package/dist/standalone/{chunk-XBQ66PGW.js → chunk-JAPCIIQC.js} +1 -1
  99. package/dist/standalone/{chunk-SC6P4M3S.js → chunk-KLQVRXER.js} +1 -1
  100. package/dist/standalone/{chunk-ZKV2XC5B.js → chunk-L7OWZOME.js} +1 -1
  101. package/dist/standalone/{chunk-BTQ72TPT.js → chunk-N36IWCKG.js} +1 -1
  102. package/dist/standalone/{chunk-VXJJSPX3.js → chunk-N66HNAEX.js} +1 -1
  103. package/dist/standalone/{chunk-UJQNKTYE.js → chunk-NJ3YQOVN.js} +1 -1
  104. package/dist/standalone/{chunk-FUL4ROKH.js → chunk-NQZMPZNU.js} +1 -1
  105. package/dist/standalone/{chunk-HGHIVU76.js → chunk-OIG3OORA.js} +1 -1
  106. package/dist/standalone/{chunk-DEFCA7GG.js → chunk-PMNMWB3N.js} +1 -1
  107. package/dist/standalone/{chunk-IRSSZXC3.js → chunk-QMJTL4SW.js} +1 -1
  108. package/dist/standalone/{chunk-E5DXYVPB.js → chunk-QNAKWBFW.js} +1 -1
  109. package/dist/standalone/{chunk-T6IV7OKH.js → chunk-RGCYH5VO.js} +1 -1
  110. package/dist/standalone/{chunk-NCCORPSU.js → chunk-RGDSRUIX.js} +1 -1
  111. package/dist/standalone/{chunk-KCFO2BVI.js → chunk-S3KIA2QB.js} +1 -1
  112. package/dist/standalone/{chunk-6XKL22OG.js → chunk-S7XJPD6Z.js} +2 -2
  113. package/dist/standalone/chunk-SFMWHWJG.js +1 -0
  114. package/dist/standalone/{chunk-ZJQIGWLG.js → chunk-SMZHXNCR.js} +1 -1
  115. package/dist/standalone/{chunk-JR4ROUBB.js → chunk-SPLVBIFP.js} +1 -1
  116. package/dist/standalone/{chunk-5Y5UTG4N.js → chunk-SQ4ZU5YB.js} +1 -1
  117. package/dist/standalone/{chunk-DBHZXRL6.js → chunk-SRNH27XV.js} +1 -1
  118. package/dist/standalone/{chunk-WVYIBXUH.js → chunk-TFLKMZK5.js} +1 -1
  119. package/dist/standalone/{chunk-ZPNTFCVI.js → chunk-UMPQDFU6.js} +1 -1
  120. package/dist/standalone/{chunk-GOFZ4Y74.js → chunk-VVHORMP3.js} +1 -1
  121. package/dist/standalone/{chunk-OI5HX3ZO.js → chunk-WXMYNIXK.js} +1 -1
  122. package/dist/standalone/{chunk-2SNK7KHX.js → chunk-WZ2CXW4B.js} +1 -1
  123. package/dist/standalone/{chunk-WUI2PUY6.js → chunk-XUS6E3C7.js} +1 -1
  124. package/dist/standalone/{chunk-EE227HDE.js → chunk-YNJEO3WB.js} +1 -1
  125. package/dist/standalone/{chunk-APEQELK3.js → chunk-YR5YXUZT.js} +1 -1
  126. package/dist/standalone/{chunk-FCXFQF2W.js → chunk-YYEQLN53.js} +1 -1
  127. package/dist/standalone/{chunk-ITT6MM23.js → chunk-ZUB5DMJT.js} +1 -1
  128. package/dist/standalone/studio.js +1 -1
  129. package/package.json +5 -5
  130. package/dist/standalone/chunk-3N5PRV3V.js +0 -1
  131. package/dist/standalone/chunk-6ZSIPBTC.js +0 -6
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card-By2O8ULa.mjs";import{E as W}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{b as H}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-zSeU_6cN.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=V(),a=M(),[p,o]=F({}),s=H(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(W,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"cron-table",children:[t(K,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(z,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=V(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=H(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>i.poll(),e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const L=I,T=v!==void 0||S!==void 0;let J;e[18]!==N?(J=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=J):J=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(W,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==L||e[24]!==T||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"dlq-table",children:[t(K,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),T&&t(x,{"aria-label":r("Actions")})]})}),t(z,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),T&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(L(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=L,e[24]=T,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==J||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[J,w,_]}),e[30]=_,e[31]=J,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=V(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=H(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>h.poll(),e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(W,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"pools-table",children:[t(K,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(z,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let L;e[30]!==r?(L=r==="pools"&&t(ae,{}),e[30]=r,e[31]=L):L=e[31];let T;e[32]!==a||e[33]!==r?(T=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=T):T=e[34];let J;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==L||e[39]!==T?(J=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,L,T]}),e[35]=S,e[36]=$,e[37]=I,e[38]=L,e[39]=T,e[40]=J):J=e[40],J};export{Ie as SchedulePanel};
1
+ import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card-By2O8ULa.mjs";import{E as W}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{a as H}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-BJ1uZW1U.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=V(),a=M(),[p,o]=F({}),s=H(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(W,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"cron-table",children:[t(K,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(z,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=V(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=H(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>i.poll(),e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const L=I,T=v!==void 0||S!==void 0;let J;e[18]!==N?(J=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=J):J=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(W,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==L||e[24]!==T||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"dlq-table",children:[t(K,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),T&&t(x,{"aria-label":r("Actions")})]})}),t(z,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),T&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(L(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=L,e[24]=T,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==J||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[J,w,_]}),e[30]=_,e[31]=J,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=V(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=H(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>h.poll(),e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(W,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"pools-table",children:[t(K,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(z,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let L;e[30]!==r?(L=r==="pools"&&t(ae,{}),e[30]=r,e[31]=L):L=e[31];let T;e[32]!==a||e[33]!==r?(T=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=T):T=e[34];let J;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==L||e[39]!==T?(J=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,L,T]}),e[35]=S,e[36]=$,e[37]=I,e[38]=L,e[39]=T,e[40]=J):J=e[40],J};export{Ie as SchedulePanel};
@@ -1 +1 @@
1
- import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=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]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{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")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
1
+ import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=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]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{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")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{k as q}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const o of c){const n=o.id.toString();if(o.subscriptions.length===0){e.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((u,r)=>{e.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${r.toString()}`,subscription:u})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=R(22),{initialShardKey:o}=c,n=O(),{queryShardKey:u,setShardKey:r,shardKey:m}=L(o);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==r||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==r||e[11]!==m?(l=t(E,{onChange:r,testId:"subs-shard-input",value:m}),e[10]=r,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(j,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(T,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:k}=v,I=G(k?.args);return a(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=r,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
1
+ import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{k as q}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const o of c){const n=o.id.toString();if(o.subscriptions.length===0){e.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((u,r)=>{e.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${r.toString()}`,subscription:u})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=R(22),{initialShardKey:o}=c,n=O(),{queryShardKey:u,setShardKey:r,shardKey:m}=L(o);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==r||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==r||e[11]!==m?(l=t(E,{onChange:r,testId:"subs-shard-input",value:m}),e[10]=r,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(j,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(T,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:k}=v,I=G(k?.args);return a(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=r,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
@@ -1 +1 @@
1
- import{c as q}from"react/compiler-runtime";import{useLunora as I}from"@lunora/react";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-D0SBiDu-.mjs";import{b as Q}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as n,jsxs as s}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:S}=W,t=Y(),L=I();let T;e[0]!==L||e[1]!==S?(T=()=>Promise.resolve(S?S():L.debug()),e[0]=L,e[1]=S,e[2]=T):T=e[2];const M=T,A=S?"injected":"live";let x;e[3]!==A?(x=["lunora-studio","sync-client-debug",A],e[3]=A,e[4]=x):x=e[4];const{data:c,poll:O}=Q(x,M);if(V(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let k;return e[9]!==i||e[10]!==g?(k=n(R,{children:n(H,{children:n(P,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=k):k=e[11],k}const{pendingWrites:v,shards:C,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const E=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==E?(d=n(_,{variant:E,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=E,e[18]=d):d=e[18];let h;e[19]!==v||e[20]!==t?(h=v>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:v})}):null,e[19]=v,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=s("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==C||e[31]!==t?(p=C.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:C.map(i=>s(w,{children:[n(r,{children:i.shardKey??t("(default)")}),n(r,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(r,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=C,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>s(w,{children:[n(r,{className:"font-mono text-xs",children:i.functionPath}),n(r,{children:i.kind}),n(r,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(r,{children:i.serverCursor??"—"}),n(r,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:s(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
1
+ import{c as q}from"react/compiler-runtime";import{useLunora as I}from"@lunora/react";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Q}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as n,jsxs as s}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:S}=W,t=Y(),L=I();let T;e[0]!==L||e[1]!==S?(T=()=>Promise.resolve(S?S():L.debug()),e[0]=L,e[1]=S,e[2]=T):T=e[2];const M=T,A=S?"injected":"live";let x;e[3]!==A?(x=["lunora-studio","sync-client-debug",A],e[3]=A,e[4]=x):x=e[4];const{data:c,poll:O}=Q(x,M);if(V(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let k;return e[9]!==i||e[10]!==g?(k=n(R,{children:n(H,{children:n(P,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=k):k=e[11],k}const{pendingWrites:v,shards:C,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const E=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==E?(d=n(_,{variant:E,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=E,e[18]=d):d=e[18];let h;e[19]!==v||e[20]!==t?(h=v>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:v})}):null,e[19]=v,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=s("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==C||e[31]!==t?(p=C.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:C.map(i=>s(w,{children:[n(r,{children:i.shardKey??t("(default)")}),n(r,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(r,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=C,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>s(w,{children:[n(r,{className:"font-mono text-xs",children:i.functionPath}),n(r,{children:i.kind}),n(r,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(r,{children:i.serverCursor??"—"}),n(r,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:s(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{L as be}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me,k as Se}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Ke)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Ke(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let F;e[33]!==j?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=F):F=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("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]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,F,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("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]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,F=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[25]=C):C=e[25];const O=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("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:L.length,total:A})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=D}else D=e[24];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};
1
+ import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{L as be}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me,k as Se}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Ke)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Ke(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let F;e[33]!==j?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=F):F=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("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]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,F,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("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]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,F=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[25]=C):C=e[25];const O=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("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:L.length,total:A})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=D}else D=e[24];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};
@@ -1 +1 @@
1
- import{useLunora as K}from"@lunora/react";import{useState as S,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as X,a as ee}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{b as qe}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-DQ8tNyBh.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-BXEjuLPN.mjs";import{A as Xe}from"../packem_shared/auth-pager-DiDnXsfe.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-2eBBD0-m.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=S(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let I;return e[30]!==i||e[31]!==w||e[32]!==m?(I=t(X,{children:u(ee,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=I):I=e[33],I},rt=()=>{const h=K(),e=W(),[l,n]=S(""),[o,s]=S(null),[f,a]=S(null),[c,d]=S(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(X,{children:t(ee,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=K(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=S(""),[g,w]=S(""),[k,v]=S(""),[r,m]=S("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=S(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=A=>{w(A.target.value)},e[2]=I):I=e[2];const T=I;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Ie;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Ie=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Ie):Ie=e[90];let Se;e[91]!==we||e[92]!==Ie?(Se=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ie]}),e[91]=we,e[92]=Ie,e[93]=Se):Se=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Se?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Se]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Se,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=K(),a=W(),[c,d]=S(null),[y,C]=S(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const I=i;d(null),C(Ve(I))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=K(),a=W(),[c,d]=S(null),[y,C]=S(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const I=i;d(null),C(Ve(I))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const I=Pe(i.id);return u(Q,{"data-testid":`ud-account-${I}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${I}`,disabled:l,onClick:()=>{v(I)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},I)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=K(),c=W(),[d,y]=S(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=I=>{o(()=>a.deleteAuthPasskey({passkeyId:I}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(I=>{const T=Pe(I.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(I.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=S(""),[a,c]=S(""),[d,y]=S(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let I;e[21]!==a||e[22]!==g?(I=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=I):I=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==I?(z=t(B,{"aria-invalid":I,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=I,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=K(),s=W(),f=n.banned===!0,[a,c]=S(null),[d,y]=S(!1),[C,g]=S(0),[w,k]=S(typeof n.role=="string"?n.role:""),[v,r]=S(""),[m,b]=S(null),[x,N]=S(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},I=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(X,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(ee,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:I,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=K(),l=W(),[n,o]=S(""),[s,f]=S(""),[a,c]=S(0),d=Je(n),[y,C]=S(null),[g,w]=S(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};
1
+ import{useLunora as K}from"@lunora/react";import{useState as S,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as X,a as ee}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as qe}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-DtZeS_qf.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-BXEjuLPN.mjs";import{A as Xe}from"../packem_shared/auth-pager-DiDnXsfe.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-2eBBD0-m.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=S(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let I;return e[30]!==i||e[31]!==w||e[32]!==m?(I=t(X,{children:u(ee,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=I):I=e[33],I},rt=()=>{const h=K(),e=W(),[l,n]=S(""),[o,s]=S(null),[f,a]=S(null),[c,d]=S(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(X,{children:t(ee,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=K(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=S(""),[g,w]=S(""),[k,v]=S(""),[r,m]=S("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=S(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=A=>{w(A.target.value)},e[2]=I):I=e[2];const T=I;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Ie;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Ie=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Ie):Ie=e[90];let Se;e[91]!==we||e[92]!==Ie?(Se=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ie]}),e[91]=we,e[92]=Ie,e[93]=Se):Se=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Se?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Se]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Se,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=K(),a=W(),[c,d]=S(null),[y,C]=S(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const I=i;d(null),C(Ve(I))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=K(),a=W(),[c,d]=S(null),[y,C]=S(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const I=i;d(null),C(Ve(I))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const I=Pe(i.id);return u(Q,{"data-testid":`ud-account-${I}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${I}`,disabled:l,onClick:()=>{v(I)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},I)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=K(),c=W(),[d,y]=S(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=I=>{o(()=>a.deleteAuthPasskey({passkeyId:I}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(I=>{const T=Pe(I.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(I.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=S(""),[a,c]=S(""),[d,y]=S(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let I;e[21]!==a||e[22]!==g?(I=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=I):I=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==I?(z=t(B,{"aria-invalid":I,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=I,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=K(),s=W(),f=n.banned===!0,[a,c]=S(null),[d,y]=S(!1),[C,g]=S(0),[w,k]=S(typeof n.role=="string"?n.role:""),[v,r]=S(""),[m,b]=S(null),[x,N]=S(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},I=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(X,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(ee,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:I,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=K(),l=W(),[n,o]=S(""),[s,f]=S(""),[a,c]=S(0),d=Je(n),[y,C]=S(null),[g,w]=S(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(X,{className:"overflow-hidden py-0",children:t(ee,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};
@@ -1 +1 @@
1
- import{useLunora as ee}from"@lunora/react";import{useState as f,useRef as G,useEffect as se}from"react";import{B as W}from"../packem_shared/button-q0UYSmrn.mjs";import{C as P,a as q}from"../packem_shared/card-By2O8ULa.mjs";import{E as H}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as j,b as y,c as i,d as z,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{T as ae}from"../packem_shared/textarea--40GKAyz.mjs";import{u as oe}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as A,b as E,k as te,d as Z,c as re}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as le}from"react/compiler-runtime";import{ConfirmButton as ie}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{jsxs as o,jsx as t,Fragment as de}from"react/jsx-runtime";const ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],ue=["pause","resume","restart","terminate"],me=l=>{const r=le(7),{busy:h,id:g,onAct:u}=l,x=M();let s;r[0]!==h||r[1]!==g||r[2]!==u||r[3]!==x?(s=ue.map(c=>c==="restart"?t(ie,{confirmLabel:x("Restart?"),disabled:h,onConfirm:()=>{u(c)},testId:`workflow-instance-${c}-${g}`,children:x(c)},c):t(W,{"data-testid":`workflow-instance-${c}-${g}`,disabled:h,onClick:()=>{u(c)},size:"sm",type:"button",variant:"ghost",children:x(c)},c)),r[0]=h,r[1]=g,r[2]=u,r[3]=x,r[4]=s):s=r[4];let m;return r[5]!==s?(m=t(de,{children:s}),r[5]=s,r[6]=m):m=r[6],m},fe="WORKFLOWS_NOT_CONFIGURED",he=l=>typeof l=="object"&&l!==null&&l.code===fe,pe=l=>{const r=l.error??l.output;if(r===void 0)return"—";try{return JSON.stringify(r,te)}catch{return"(unserializable)"}},xe=({loadDetail:l,loadInstances:r,readOnly:h,runAction:g,workflowName:u})=>{const x=ee(),s=M(),[m,c]=f(null),[S,C]=f(null),[k,R]=f(""),[I,b]=f(null),[$,O]=f(!1),[_,F]=f(null),w=G(0),N=G(0),v=G(0),D=l??(e=>x.getWorkflowInstance(e)),T=h?void 0:g??(r===void 0?e=>x.setWorkflowInstanceStatus(e):void 0),L=async()=>{N.current+=1;const e=N.current;b(null),O(!1);const n=k===""?void 0:k;try{if(r===void 0){const p=await x.listWorkflowInstances({name:u,status:n});if(e!==N.current)return;if(p.configured===!1){c(null),O(!0);return}c(p.instances);return}const a=await r({name:u,status:n});e===N.current&&c(a)}catch(a){if(e!==N.current)return;c(null),he(a)?O(!0):b(E(a))}};se(()=>{w.current+=1,v.current+=1,C(null),A(L())},[u,k]);const B=async e=>{v.current+=1;const n=v.current;b(null);try{const a=await D({id:e,name:u});n===v.current&&C(a)}catch(a){n===v.current&&b(E(a))}},J=()=>{v.current+=1,C(null)},K=async(e,n)=>{if(T===void 0)return;const a=w.current;F(e),b(null);try{await T({action:n,id:e,name:u}),a===w.current&&await L()}catch(p){b(E(p))}F(null)};return o("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[o("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),o("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:e=>{R(e.target.value)},value:k,children:[t("option",{value:"",children:s("All statuses")}),ce.map(e=>t("option",{value:e,children:e},e))]})]}),I!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:I}),$&&t(H,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&m!==null&&m.length===0&&t(H,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),m!==null&&m.length>0&&t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflow-instances-table",children:[t(j,{children:o(y,{children:[t(i,{children:s("Instance id")}),t(i,{children:s("Status")}),t(i,{children:s("Created")}),t(i,{children:s("Ended")}),t(i,{"aria-label":s("Actions")})]})}),t(z,{children:m.map(e=>o(y,{"data-testid":`workflow-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"text-muted-foreground tabular-nums",children:e.createdOn??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.endedOn??"—"}),t(d,{className:"text-right",children:o("div",{className:"flex justify-end gap-1.5",children:[t(W,{"data-testid":`workflow-instance-steps-${e.id}`,onClick:()=>{A(B(e.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),T!==void 0&&t(me,{busy:_===e.id,id:e.id,onAct:n=>{A(K(e.id,n))}},u)]})})]},e.id))})]})})}),S!==null&&t(P,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:o(q,{className:"flex flex-col gap-2 px-4 py-3",children:[o("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-mono text-xs",children:[s("Steps")," · ",S.id]}),t(W,{"data-testid":"workflow-instance-detail-close",onClick:J,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):o(U,{"data-testid":"workflow-instance-steps",children:[t(j,{children:o(y,{children:[t(i,{children:s("Step")}),t(i,{children:s("Type")}),t(i,{children:s("Attempts")}),t(i,{children:s("Started")}),t(i,{children:s("Output")})]})}),t(z,{children:S.steps.map((e,n)=>o(y,{"data-testid":`workflow-step-${String(n)}`,children:[t(d,{className:"font-mono text-xs",children:e.name}),t(d,{className:"text-xs text-muted-foreground",children:e.type??"—"}),t(d,{className:"tabular-nums",children:e.attempts??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.start??"—"}),t(d,{className:"font-mono text-xs text-muted-foreground",children:pe(e)})]},`${e.name}:${String(n)}`))})]})]})})]})},we=re(Q.createWorkflowInstance),Ne=re(Q.getWorkflowInstanceStatus),ge=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,te)}catch{return"(unserializable)"}},be=(l,r)=>l.some(h=>h.exportName===r)?r:l[0]?.exportName??"",De=()=>{const l=ee(),r=M(),{data:h,error:g}=oe(Q.listWorkflows,{}),[u,x]=f(""),[s,m]=f(""),[c,S]=f(""),[C,k]=f(!1),[R,I]=f(null),[b,$]=f([]),[O,_]=f(null),F=h!==void 0,w=Array.isArray(h?.workflows)?[...h.workflows].toSorted((e,n)=>e.exportName.localeCompare(n.exportName)):[],N=be(w,u),v=w.find(e=>e.exportName===N),D=e=>{$(n=>{const a=n.filter(p=>!(p.exportName===e.exportName&&p.id===e.id));return[e,...a]})},V=async()=>{const e=N;if(e==="")return;let n;const a=c.trim();if(a!=="")try{n=JSON.parse(a)}catch{I(r("Params must be valid JSON"));return}k(!0),I(null);try{const p=s.trim(),Y=await l.query(we,{exportName:e,id:p===""?void 0:p,params:n},Z(""));D({exportName:e,id:Y.id,status:Y.status}),m("")}catch(p){I(E(p))}k(!1)},X=()=>{A(V())},T=async(e,n)=>{_(n);try{const a=await l.query(Ne,{exportName:e,id:n},Z(""));D({error:a.error,exportName:e,id:a.id,output:a.output,status:a.status})}catch(a){I(E(a))}_(null)},L=e=>{x(e.target.value)},B=e=>{m(e.target.value)},J=e=>{S(e.target.value)},K=e=>{const{export:n,id:a}=e.currentTarget.dataset;n!==void 0&&a!==void 0&&A(T(n,a))};return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:g}),t("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),F&&w.length===0?t(H,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflows-table",children:[t(j,{children:o(y,{children:[t(i,{children:r("Export")}),t(i,{children:r("Name")}),t(i,{children:r("Class")})]})}),t(z,{children:w.map(e=>o(y,{"data-testid":`workflows-row-${e.exportName}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.name}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.className})]},e.exportName))})]})})}),w.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:r("Start instance")}),R!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:R}),o("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:L,value:N,children:w.map(e=>t("option",{value:e.exportName,children:e.exportName},e.exportName))}),t(ne,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:B,placeholder:r("Instance id (optional)"),value:s}),t(W,{"data-testid":"workflows-start-button",disabled:C||N==="",onClick:X,children:r(C?"Starting…":"Start instance")})]}),t(ae,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:J,placeholder:r("Params (JSON, optional)"),value:c})]}),b.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:r("Instances")}),t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflows-instances-table",children:[t(j,{children:o(y,{children:[t(i,{children:r("Workflow")}),t(i,{children:r("Instance id")}),t(i,{children:r("Status")}),t(i,{children:r("Output")}),t(i,{})]})}),t(z,{children:b.map(e=>o(y,{"data-testid":`workflows-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"font-mono text-xs text-muted-foreground",children:ge(e)}),t(d,{children:t(W,{"data-export":e.exportName,"data-id":e.id,"data-testid":`workflows-instance-refresh-${e.id}`,disabled:O===e.id,onClick:K,size:"xs",variant:"outline",children:O===e.id?r("Refreshing…"):r("Refresh")})})]},`${e.exportName}:${e.id}`))})]})})})]}),v!==void 0&&t(xe,{workflowName:v.name})]})};export{De as default};
1
+ import{useLunora as ee}from"@lunora/react";import{useState as f,useRef as G,useEffect as se}from"react";import{B as W}from"../packem_shared/button-q0UYSmrn.mjs";import{C as P,a as q}from"../packem_shared/card-By2O8ULa.mjs";import{E as H}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as j,b as y,c as i,d as z,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{T as ae}from"../packem_shared/textarea--40GKAyz.mjs";import{u as oe}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as A,b as E,k as te,d as Z,c as re}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as le}from"react/compiler-runtime";import{ConfirmButton as ie}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{jsxs as o,jsx as t,Fragment as de}from"react/jsx-runtime";const ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],ue=["pause","resume","restart","terminate"],me=l=>{const r=le(7),{busy:h,id:g,onAct:u}=l,x=M();let s;r[0]!==h||r[1]!==g||r[2]!==u||r[3]!==x?(s=ue.map(c=>c==="restart"?t(ie,{confirmLabel:x("Restart?"),disabled:h,onConfirm:()=>{u(c)},testId:`workflow-instance-${c}-${g}`,children:x(c)},c):t(W,{"data-testid":`workflow-instance-${c}-${g}`,disabled:h,onClick:()=>{u(c)},size:"sm",type:"button",variant:"ghost",children:x(c)},c)),r[0]=h,r[1]=g,r[2]=u,r[3]=x,r[4]=s):s=r[4];let m;return r[5]!==s?(m=t(de,{children:s}),r[5]=s,r[6]=m):m=r[6],m},fe="WORKFLOWS_NOT_CONFIGURED",he=l=>typeof l=="object"&&l!==null&&l.code===fe,pe=l=>{const r=l.error??l.output;if(r===void 0)return"—";try{return JSON.stringify(r,te)}catch{return"(unserializable)"}},xe=({loadDetail:l,loadInstances:r,readOnly:h,runAction:g,workflowName:u})=>{const x=ee(),s=M(),[m,c]=f(null),[S,C]=f(null),[k,R]=f(""),[I,b]=f(null),[$,O]=f(!1),[_,F]=f(null),w=G(0),N=G(0),v=G(0),D=l??(e=>x.getWorkflowInstance(e)),T=h?void 0:g??(r===void 0?e=>x.setWorkflowInstanceStatus(e):void 0),L=async()=>{N.current+=1;const e=N.current;b(null),O(!1);const n=k===""?void 0:k;try{if(r===void 0){const p=await x.listWorkflowInstances({name:u,status:n});if(e!==N.current)return;if(p.configured===!1){c(null),O(!0);return}c(p.instances);return}const a=await r({name:u,status:n});e===N.current&&c(a)}catch(a){if(e!==N.current)return;c(null),he(a)?O(!0):b(E(a))}};se(()=>{w.current+=1,v.current+=1,C(null),A(L())},[u,k]);const B=async e=>{v.current+=1;const n=v.current;b(null);try{const a=await D({id:e,name:u});n===v.current&&C(a)}catch(a){n===v.current&&b(E(a))}},J=()=>{v.current+=1,C(null)},K=async(e,n)=>{if(T===void 0)return;const a=w.current;F(e),b(null);try{await T({action:n,id:e,name:u}),a===w.current&&await L()}catch(p){b(E(p))}F(null)};return o("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[o("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),o("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:e=>{R(e.target.value)},value:k,children:[t("option",{value:"",children:s("All statuses")}),ce.map(e=>t("option",{value:e,children:e},e))]})]}),I!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:I}),$&&t(H,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&m!==null&&m.length===0&&t(H,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),m!==null&&m.length>0&&t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflow-instances-table",children:[t(j,{children:o(y,{children:[t(i,{children:s("Instance id")}),t(i,{children:s("Status")}),t(i,{children:s("Created")}),t(i,{children:s("Ended")}),t(i,{"aria-label":s("Actions")})]})}),t(z,{children:m.map(e=>o(y,{"data-testid":`workflow-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"text-muted-foreground tabular-nums",children:e.createdOn??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.endedOn??"—"}),t(d,{className:"text-right",children:o("div",{className:"flex justify-end gap-1.5",children:[t(W,{"data-testid":`workflow-instance-steps-${e.id}`,onClick:()=>{A(B(e.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),T!==void 0&&t(me,{busy:_===e.id,id:e.id,onAct:n=>{A(K(e.id,n))}},u)]})})]},e.id))})]})})}),S!==null&&t(P,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:o(q,{className:"flex flex-col gap-2 px-4 py-3",children:[o("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-mono text-xs",children:[s("Steps")," · ",S.id]}),t(W,{"data-testid":"workflow-instance-detail-close",onClick:J,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):o(U,{"data-testid":"workflow-instance-steps",children:[t(j,{children:o(y,{children:[t(i,{children:s("Step")}),t(i,{children:s("Type")}),t(i,{children:s("Attempts")}),t(i,{children:s("Started")}),t(i,{children:s("Output")})]})}),t(z,{children:S.steps.map((e,n)=>o(y,{"data-testid":`workflow-step-${String(n)}`,children:[t(d,{className:"font-mono text-xs",children:e.name}),t(d,{className:"text-xs text-muted-foreground",children:e.type??"—"}),t(d,{className:"tabular-nums",children:e.attempts??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.start??"—"}),t(d,{className:"font-mono text-xs text-muted-foreground",children:pe(e)})]},`${e.name}:${String(n)}`))})]})]})})]})},we=re(Q.createWorkflowInstance),Ne=re(Q.getWorkflowInstanceStatus),ge=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,te)}catch{return"(unserializable)"}},be=(l,r)=>l.some(h=>h.exportName===r)?r:l[0]?.exportName??"",De=()=>{const l=ee(),r=M(),{data:h,error:g}=oe(Q.listWorkflows,{}),[u,x]=f(""),[s,m]=f(""),[c,S]=f(""),[C,k]=f(!1),[R,I]=f(null),[b,$]=f([]),[O,_]=f(null),F=h!==void 0,w=Array.isArray(h?.workflows)?[...h.workflows].toSorted((e,n)=>e.exportName.localeCompare(n.exportName)):[],N=be(w,u),v=w.find(e=>e.exportName===N),D=e=>{$(n=>{const a=n.filter(p=>!(p.exportName===e.exportName&&p.id===e.id));return[e,...a]})},V=async()=>{const e=N;if(e==="")return;let n;const a=c.trim();if(a!=="")try{n=JSON.parse(a)}catch{I(r("Params must be valid JSON"));return}k(!0),I(null);try{const p=s.trim(),Y=await l.query(we,{exportName:e,id:p===""?void 0:p,params:n},Z(""));D({exportName:e,id:Y.id,status:Y.status}),m("")}catch(p){I(E(p))}k(!1)},X=()=>{A(V())},T=async(e,n)=>{_(n);try{const a=await l.query(Ne,{exportName:e,id:n},Z(""));D({error:a.error,exportName:e,id:a.id,output:a.output,status:a.status})}catch(a){I(E(a))}_(null)},L=e=>{x(e.target.value)},B=e=>{m(e.target.value)},J=e=>{S(e.target.value)},K=e=>{const{export:n,id:a}=e.currentTarget.dataset;n!==void 0&&a!==void 0&&A(T(n,a))};return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:g}),t("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),F&&w.length===0?t(H,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflows-table",children:[t(j,{children:o(y,{children:[t(i,{children:r("Export")}),t(i,{children:r("Name")}),t(i,{children:r("Class")})]})}),t(z,{children:w.map(e=>o(y,{"data-testid":`workflows-row-${e.exportName}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.name}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.className})]},e.exportName))})]})})}),w.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:r("Start instance")}),R!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:R}),o("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:L,value:N,children:w.map(e=>t("option",{value:e.exportName,children:e.exportName},e.exportName))}),t(ne,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:B,placeholder:r("Instance id (optional)"),value:s}),t(W,{"data-testid":"workflows-start-button",disabled:C||N==="",onClick:X,children:r(C?"Starting…":"Start instance")})]}),t(ae,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:J,placeholder:r("Params (JSON, optional)"),value:c})]}),b.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:r("Instances")}),t(P,{className:"overflow-hidden py-0",children:t(q,{className:"px-0",children:o(U,{"data-testid":"workflows-instances-table",children:[t(j,{children:o(y,{children:[t(i,{children:r("Workflow")}),t(i,{children:r("Instance id")}),t(i,{children:r("Status")}),t(i,{children:r("Output")}),t(i,{})]})}),t(z,{children:b.map(e=>o(y,{"data-testid":`workflows-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"font-mono text-xs text-muted-foreground",children:ge(e)}),t(d,{children:t(W,{"data-export":e.exportName,"data-id":e.id,"data-testid":`workflows-instance-refresh-${e.id}`,disabled:O===e.id,onClick:K,size:"xs",variant:"outline",children:O===e.id?r("Refreshing…"):r("Refresh")})})]},`${e.exportName}:${e.id}`))})]})})})]}),v!==void 0&&t(xe,{workflowName:v.name})]})};export{De as default};