@lunora/studio 1.0.0-alpha.113 → 1.0.0-alpha.115

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 (153) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/mount.js +1 -1
  3. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  4. package/dist/packem_chunks/ApiTab.js +1 -1
  5. package/dist/packem_chunks/AuditPanel.js +1 -1
  6. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +1 -1
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/analytics-panel.js +1 -1
  25. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  26. package/dist/packem_chunks/auth-config-panel.js +1 -1
  27. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  28. package/dist/packem_chunks/containers-panel.js +1 -1
  29. package/dist/packem_chunks/dashboards-panel.js +1 -1
  30. package/dist/packem_chunks/evals-panel.js +1 -1
  31. package/dist/packem_chunks/fanout-panel.js +1 -1
  32. package/dist/packem_chunks/flags-panel.js +1 -1
  33. package/dist/packem_chunks/issues-panel.js +1 -1
  34. package/dist/packem_chunks/kv-browser.js +1 -1
  35. package/dist/packem_chunks/log-drains-panel.js +1 -1
  36. package/dist/packem_chunks/migrations-route.js +1 -1
  37. package/dist/packem_chunks/organizations-panel.js +1 -1
  38. package/dist/packem_chunks/payments-panel.js +1 -1
  39. package/dist/packem_chunks/permissions-panel.js +1 -1
  40. package/dist/packem_chunks/queues-panel.js +1 -1
  41. package/dist/packem_chunks/rls-panel.js +1 -1
  42. package/dist/packem_chunks/schedule-panel.js +1 -1
  43. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  44. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  45. package/dist/packem_chunks/sync-client-panel.js +1 -1
  46. package/dist/packem_chunks/traces-panel.js +1 -1
  47. package/dist/packem_chunks/users-panel.js +1 -1
  48. package/dist/packem_chunks/vector-browser.js +1 -1
  49. package/dist/packem_chunks/workflows-panel.js +1 -1
  50. package/dist/packem_shared/{ApiDocsPanel-BL5lMig5.js → ApiDocsPanel-C_dZt4ve.js} +1 -1
  51. package/dist/packem_shared/{ApiReferencePanel-CkCFMCBb.js → ApiReferencePanel-6W_QfOlv.js} +1 -1
  52. package/dist/packem_shared/{CommandPalette-B5yLEABs.js → CommandPalette-BAiOc1hT.js} +1 -1
  53. package/dist/packem_shared/{DataBrowser-BnDIFN-S.js → DataBrowser-CrkvQAMf.js} +1 -1
  54. package/dist/packem_shared/{GlobalDataBrowser-DusjXzRF.js → GlobalDataBrowser-BHFgEqMl.js} +1 -1
  55. package/dist/packem_shared/{HomePanel-BcaHVBJh.js → HomePanel-B8U_LJkK.js} +1 -1
  56. package/dist/packem_shared/{MigrationsPanel-CCOENX4X.js → MigrationsPanel-CW4MNUa4.js} +1 -1
  57. package/dist/packem_shared/{OpenRpcReferencePanel-21OWMH45.js → OpenRpcReferencePanel-Cx-qwpZW.js} +1 -1
  58. package/dist/packem_shared/{ScheduledJobs-CiO3eXgI.js → ScheduledJobs-DRmOKtDa.js} +1 -1
  59. package/dist/packem_shared/Studio-k_HuJZYW.js +1 -0
  60. package/dist/packem_shared/{StudioApp-DCdbsciH.js → StudioApp-CWpwayvp.js} +1 -1
  61. package/dist/packem_shared/{advisor-view-C1KFTXSH.js → advisor-view-CqCG22DB.js} +1 -1
  62. package/dist/packem_shared/{data-grid-BFTQnkXq.js → data-grid-pjv4t5Yi.js} +1 -1
  63. package/dist/packem_shared/{error-alert-TYdKetJd.js → error-alert-CKqB2CiN.js} +1 -1
  64. package/dist/packem_shared/{grid-features-C_yXlMc_.js → grid-features-3wfN2PeE.js} +4 -4
  65. package/dist/packem_shared/{home-panel-BiJHXeDC.js → home-panel-DywiFhDs.js} +1 -1
  66. package/dist/packem_shared/{internal-CwaF9YNk.js → internal-7bgd8inO.js} +1 -1
  67. package/dist/packem_shared/{log-line-UnE93Ovi.js → log-line-D0XBZaDn.js} +1 -1
  68. package/dist/packem_shared/{recording-client-CKn4-vUx.js → recording-client-BPY8sYUl.js} +1 -1
  69. package/dist/packem_shared/{reference-view-CUIDzLf0.js → reference-view-DhxnzBtf.js} +1 -1
  70. package/dist/packem_shared/{result-chart-Ca3YLzt8.js → result-chart-Q-gVLi4_.js} +1 -1
  71. package/dist/packem_shared/{schema-diagram-DHD13TjS.js → schema-diagram-CPcjPZj3.js} +1 -1
  72. package/dist/packem_shared/{studio-B3eEcBK0.js → studio-BFvT56qK.js} +1 -1
  73. package/dist/packem_shared/{table-list-sidebar-Bluzd1_2.js → table-list-sidebar-BCxqrZ0s.js} +1 -1
  74. package/dist/packem_shared/{use-admin-query-P0RJrjsD.js → use-admin-query-DV9xmFl8.js} +1 -1
  75. package/dist/packem_shared/{use-async-submit-DdLd0MdK.js → use-async-submit-C9xXjXWX.js} +1 -1
  76. package/dist/packem_shared/{use-auth-config-z3KRWAqD.js → use-auth-config-DIAyVsa3.js} +1 -1
  77. package/dist/packem_shared/{use-open-trace-4tIa0SXZ.js → use-open-trace-IfIlKEWd.js} +1 -1
  78. package/dist/packem_shared/{use-sql-assistant-CP90nLLh.js → use-sql-assistant-DFO2i-n-.js} +1 -1
  79. package/dist/standalone/chunk-22WJHOC4.js +11 -0
  80. package/dist/standalone/{chunk-ZN6KUP3O.js → chunk-2CHFHPR3.js} +1 -1
  81. package/dist/standalone/{chunk-OG57FC7W.js → chunk-2EJQ7SPV.js} +1 -1
  82. package/dist/standalone/{chunk-FSWPREH3.js → chunk-2Q7HAFRK.js} +1 -1
  83. package/dist/standalone/{chunk-44WNSIGQ.js → chunk-2UIT2HC2.js} +1 -1
  84. package/dist/standalone/{chunk-YUWMB6EV.js → chunk-2UWKGSEA.js} +1 -1
  85. package/dist/standalone/{chunk-ZQLIKKIY.js → chunk-3IXTF53Q.js} +1 -1
  86. package/dist/standalone/{chunk-J6MNOKO5.js → chunk-44FJEOAY.js} +1 -1
  87. package/dist/standalone/{chunk-26VREVWU.js → chunk-5XMZP64Z.js} +1 -1
  88. package/dist/standalone/{chunk-45YWYMD5.js → chunk-6MRGARL5.js} +1 -1
  89. package/dist/standalone/{chunk-3F5I435D.js → chunk-6UOC4ZJL.js} +1 -1
  90. package/dist/standalone/{chunk-FBAZHG35.js → chunk-6ZSAMAYN.js} +1 -1
  91. package/dist/standalone/{chunk-BORG7WUC.js → chunk-7IQT5M4O.js} +1 -1
  92. package/dist/standalone/{chunk-KQIHXYE6.js → chunk-7TFEJVX4.js} +1 -1
  93. package/dist/standalone/{chunk-3QB5JI32.js → chunk-7W6TQTW7.js} +1 -1
  94. package/dist/standalone/{chunk-4MAJFNON.js → chunk-A7WKYEQ4.js} +1 -1
  95. package/dist/standalone/chunk-AG265V66.js +1 -0
  96. package/dist/standalone/{chunk-6SAAMM4S.js → chunk-BE76GAFE.js} +1 -1
  97. package/dist/standalone/{chunk-6ZPTNC34.js → chunk-BKM6PMSO.js} +1 -1
  98. package/dist/standalone/{chunk-D7DUQS2Y.js → chunk-CE7WVPLK.js} +1 -1
  99. package/dist/standalone/{chunk-MSFUDXBA.js → chunk-D4HJ2VM2.js} +1 -1
  100. package/dist/standalone/{chunk-FLCK2WWQ.js → chunk-DC5AAWSA.js} +1 -1
  101. package/dist/standalone/{chunk-6NJAHOGO.js → chunk-DEGERMXH.js} +1 -1
  102. package/dist/standalone/{chunk-JURAVSE7.js → chunk-E6P2ERQV.js} +1 -1
  103. package/dist/standalone/{chunk-TLPWZ5NI.js → chunk-EQSVW6LZ.js} +1 -1
  104. package/dist/standalone/{chunk-T2LDA6WP.js → chunk-FCEPVFIJ.js} +1 -1
  105. package/dist/standalone/chunk-FEEZPSMA.js +1 -0
  106. package/dist/standalone/{chunk-25OIGX2A.js → chunk-FEW2WNS7.js} +1 -1
  107. package/dist/standalone/{chunk-KFZ37KQP.js → chunk-FRSTZO5P.js} +1 -1
  108. package/dist/standalone/{chunk-X6Q5DWLZ.js → chunk-GKHUQDVI.js} +1 -1
  109. package/dist/standalone/{chunk-SL5R7WBN.js → chunk-H2WBIULE.js} +1 -1
  110. package/dist/standalone/{chunk-WIG3HCUJ.js → chunk-H3M57MCN.js} +1 -1
  111. package/dist/standalone/{chunk-UIF57LBO.js → chunk-H4SLAZAN.js} +1 -1
  112. package/dist/standalone/{chunk-6FWN26RH.js → chunk-HLEXBOCL.js} +1 -1
  113. package/dist/standalone/{chunk-QZ55OWAB.js → chunk-HLHO5AHK.js} +1 -1
  114. package/dist/standalone/{chunk-MOUI44OT.js → chunk-INLHZKCS.js} +1 -1
  115. package/dist/standalone/{chunk-L7CJ5PGH.js → chunk-JACBQWRB.js} +1 -1
  116. package/dist/standalone/{chunk-YS7HEZC2.js → chunk-KEMHRM53.js} +1 -1
  117. package/dist/standalone/{chunk-GIRZD3UB.js → chunk-KOH52XKG.js} +1 -1
  118. package/dist/standalone/{chunk-C5E5PLJT.js → chunk-LDVDE3LE.js} +1 -1
  119. package/dist/standalone/{chunk-3RYEUXY2.js → chunk-LFEDP3Y6.js} +1 -1
  120. package/dist/standalone/{chunk-V6QPVFDL.js → chunk-MG7VPUFA.js} +1 -1
  121. package/dist/standalone/{chunk-OE4KGVJW.js → chunk-MLYZZD5C.js} +1 -1
  122. package/dist/standalone/{chunk-WHRG6S5P.js → chunk-NSR345ID.js} +1 -1
  123. package/dist/standalone/{chunk-IWNVQHF7.js → chunk-OAXOITHK.js} +1 -1
  124. package/dist/standalone/chunk-OQS4HFKC.js +1 -0
  125. package/dist/standalone/{chunk-XGIG4EDG.js → chunk-OTZRXUHF.js} +1 -1
  126. package/dist/standalone/{chunk-PJDKRUWT.js → chunk-PNLUMMXO.js} +1 -1
  127. package/dist/standalone/{chunk-AOE75NAT.js → chunk-Q2G22JHG.js} +1 -1
  128. package/dist/standalone/{chunk-BELLXCN7.js → chunk-RUIWLLAI.js} +1 -1
  129. package/dist/standalone/{chunk-S77D4SHR.js → chunk-RVQRXKRJ.js} +1 -1
  130. package/dist/standalone/{chunk-JVAYDDMK.js → chunk-SCXAZ74Y.js} +1 -1
  131. package/dist/standalone/{chunk-2DC6F7NH.js → chunk-SLOB2B2T.js} +1 -1
  132. package/dist/standalone/{chunk-LT4XQDD2.js → chunk-SM764GPA.js} +1 -1
  133. package/dist/standalone/{chunk-5T7KRUPX.js → chunk-U2KBAKZ6.js} +1 -1
  134. package/dist/standalone/chunk-U7J3LXJ4.js +6 -0
  135. package/dist/standalone/{chunk-KEKIGANB.js → chunk-UCA5MYCL.js} +1 -1
  136. package/dist/standalone/{chunk-GPP4VSUO.js → chunk-UJXKS27L.js} +1 -1
  137. package/dist/standalone/{chunk-C7E4I7JZ.js → chunk-UKIDHICQ.js} +1 -1
  138. package/dist/standalone/{chunk-5NRQIDQA.js → chunk-V2KCESII.js} +1 -1
  139. package/dist/standalone/{chunk-OOBJFXYB.js → chunk-W5CYX66B.js} +1 -1
  140. package/dist/standalone/{chunk-2BDM6HNL.js → chunk-WSNFV7ZW.js} +1 -1
  141. package/dist/standalone/{chunk-OLQWBGKT.js → chunk-YYFHDYYT.js} +1 -1
  142. package/dist/standalone/{chunk-PHHMPYEP.js → chunk-ZHDCWHRT.js} +1 -1
  143. package/dist/standalone/{chunk-CEPMQS24.js → chunk-ZIHYXKQJ.js} +1 -1
  144. package/dist/standalone/{chunk-DL3UOEWN.js → chunk-ZIYO55T2.js} +1 -1
  145. package/dist/standalone/{chunk-6JGXSMKV.js → chunk-ZNNKKJRT.js} +1 -1
  146. package/dist/standalone/studio.js +1 -1
  147. package/package.json +5 -5
  148. package/dist/packem_shared/Studio-CHmLCjBR.js +0 -1
  149. package/dist/standalone/chunk-GZMBMNL3.js +0 -6
  150. package/dist/standalone/chunk-RBUVNO22.js +0 -1
  151. package/dist/standalone/chunk-SMKRXJUC.js +0 -1
  152. package/dist/standalone/chunk-T6HLABZW.js +0 -1
  153. package/dist/standalone/chunk-TBXK3FKP.js +0 -11
@@ -1 +1 @@
1
- import{c as P}from"react/compiler-runtime";import{useLunora as Ve}from"@lunora/react";import{useState as M}from"react";import{ConfirmButton as Ye}from"../packem_shared/ConfirmButton-Cj2SOapE.js";import{E as Xe}from"../packem_shared/error-alert-TYdKetJd.js";import{A as Ke}from"../packem_shared/alert-C2SEhYS9.js";import{B as ve}from"../packem_shared/badge-cAk9Di1Q.js";import{B as Qe}from"../packem_shared/button-BOPLD1un.js";import{C as $e,a as Oe}from"../packem_shared/card-BGlQzQY-.js";import{E as we}from"../packem_shared/empty-state-B939z6K2.js";import{I as Ze}from"../packem_shared/input-CY5W3wzv.js";import{S as et}from"../packem_shared/scroll-area-DSJftwu_.js";import{T as ke,a as Ue,b as oe,c as _,d as Je,e as T}from"../packem_shared/table-BMsuYFhk.js";import{T as tt}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as Be}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as st}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as _e,b as Te,c as Ae,f as Ce,i as at}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as s,jsxs as q,Fragment as Fe}from"react/jsx-runtime";const rt=(n,e)=>{const t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),d=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),l=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:l,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||l>0}},nt=200,ot=Ae(G.sendQueueMessage),lt=Ae(G.replayQueueMessage),dt=Ae(G.clearQueueMessages),Re=96,it=n=>{if(n===void 0)return"—";try{return JSON.stringify(n)}catch{return"[unserializable]"}},ct=n=>n.length>Re?`${n.slice(0,Re)}…`:n,ut=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",mt=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ft=n=>{const e=P(11),{loaded:t,queues:d}=n,l=j();let a;e[0]!==l?(a=l("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=l,e[1]=a):a=e[1];let o;e[2]!==a?(o=s("p",{className:"text-sm text-muted-foreground",children:a}),e[2]=a,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==d||e[6]!==l?(r=t&&d.length===0?s(we,{description:l("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:l("No queues defined")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:q(ke,{"data-testid":"queues-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:l("Export")}),s(_,{children:l("Queue")}),s(_,{children:l("Mode")}),s(_,{children:l("Binding")}),s(_,{children:l("Dead-letter")})]})}),s(Je,{children:d.map(xt)})]})})}),e[4]=t,e[5]=d,e[6]=l,e[7]=r):r=e[7];let f;return e[8]!==o||e[9]!==r?(f=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=f):f=e[10],f},ht=n=>{const e=P(67),{message:t,onReplay:d,replayingId:l}=n,a=j();let o,r,f,u,g,y,x,i,m,p;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){const U=it(t.body);r=oe,y=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(x=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=x):x=e[20],e[21]!==t.messageId?(i=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=i):i=e[22],e[23]!==t.attempts?(m=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=ut(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(ve,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let L;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(L=t.deadLettered&&s(ve,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=L):L=e[34],e[35]!==C||e[36]!==L?(p=s(T,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,L]})}),e[35]=C,e[36]=L,e[37]=p):p=e[37],o=T,f="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=U,g=ct(U),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=o,e[10]=r,e[11]=f,e[12]=u,e[13]=g,e[14]=y,e[15]=x,e[16]=i,e[17]=m,e[18]=p}else o=e[9],r=e[10],f=e[11],u=e[12],g=e[13],y=e[14],x=e[15],i=e[16],m=e[17],p=e[18];let h;e[38]!==o||e[39]!==f||e[40]!==u||e[41]!==g?(h=s(o,{className:f,title:u,children:g}),e[38]=o,e[39]=f,e[40]=u,e[41]=g,e[42]=h):h=e[42];let N;e[43]!==t.capturedAt?(N=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=b):b=e[46];const E=`queues-replay-${t.id}`,w=l!==null;let v;e[47]!==t.id||e[48]!==l||e[49]!==a?(v=l===t.id?a("Replaying…"):a("Replay"),e[47]=t.id,e[48]=l,e[49]=a,e[50]=v):v=e[50];let Q;e[51]!==t.id||e[52]!==d||e[53]!==E||e[54]!==w||e[55]!==v?(Q=s(T,{children:s(Qe,{"data-id":t.id,"data-testid":E,disabled:w,onClick:d,size:"xs",type:"button",variant:"outline",children:v})}),e[51]=t.id,e[52]=d,e[53]=E,e[54]=w,e[55]=v,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==y||e[61]!==x||e[62]!==i||e[63]!==m||e[64]!==p||e[65]!==h?(D=q(r,{"data-testid":y,children:[x,i,m,p,h,b,Q]}),e[57]=r,e[58]=b,e[59]=Q,e[60]=y,e[61]=x,e[62]=i,e[63]=m,e[64]=p,e[65]=h,e[66]=D):D=e[66],D},pt=n=>{const e=P(30),{hasError:t,messages:d,onClear:l,onReplay:a,replayingId:o}=n,r=j();let f;e[0]!==r?(f=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=f):f=e[1];let u;e[2]!==f?(u=s("p",{className:"text-sm text-muted-foreground",children:f}),e[2]=f,e[3]=u):u=e[3];let g;e[4]!==d.length||e[5]!==r?(g=r("Clear {count} messages?",{count:d.length}),e[4]=d.length,e[5]=r,e[6]=g):g=e[6];const y=d.length===0;let x;e[7]!==r?(x=r("Clear log"),e[7]=r,e[8]=x):x=e[8];let i;e[9]!==l||e[10]!==g||e[11]!==y||e[12]!==x?(i=s("div",{className:"ml-auto",children:s(Ye,{confirmLabel:g,disabled:y,onConfirm:l,testId:"queues-clear",children:x})}),e[9]=l,e[10]=g,e[11]=y,e[12]=x,e[13]=i):i=e[13];let m;e[14]!==d.length||e[15]!==r?(m=d.length>0&&s(ve,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:d.length})}),e[14]=d.length,e[15]=r,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==i||e[19]!==m?(p=q("div",{className:"flex flex-wrap items-center gap-2",children:[u,i,m]}),e[17]=u,e[18]=i,e[19]=m,e[20]=p):p=e[20];let h;e[21]!==t||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==r?(h=!t&&d.length===0?s(we,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:s(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(ke,{"data-testid":"queues-messages-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:r("Export")}),s(_,{children:r("Message")}),s(_,{children:r("Attempts")}),s(_,{children:r("Outcome")}),s(_,{children:r("Body")}),s(_,{children:r("Captured")}),s(_,{})]})}),s(Je,{children:d.map(b=>s(ht,{message:b,onReplay:a,replayingId:o},b.id))})]})})})}),e[21]=t,e[22]=d,e[23]=a,e[24]=o,e[25]=r,e[26]=h):h=e[26];let N;return e[27]!==p||e[28]!==h?(N=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[p,h]}),e[27]=p,e[28]=h,e[29]=N):N=e[29],N},gt=n=>{const e=P(20),{batchMode:t,bodyText:d,delayText:l,onBatchModeChange:a,onBodyChange:o,onDelayChange:r,onSelectExport:f,onSend:u,queues:g,selectedExportName:y,sending:x}=n,i=j();let m;e[0]!==i?(m=i("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=i,e[1]=m):m=e[1];let p;e[2]!==m?(p=s("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3];let h;e[4]!==t||e[5]!==d||e[6]!==l||e[7]!==a||e[8]!==o||e[9]!==r||e[10]!==f||e[11]!==u||e[12]!==g||e[13]!==y||e[14]!==x||e[15]!==i?(h=g.length===0?s(we,{description:i("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:i("No queues to send to")}):q(Fe,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[s("select",{"aria-label":i("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:f,value:y,children:g.map(yt)}),s(Ze,{"aria-label":i("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:i("Delay (s)"),type:"number",value:l}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),i("Send as batch (JSON array)")]}),s(Qe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:u,type:"button",children:i(x?"Sending…":"Send message")})]}),s(tt,{"aria-label":i("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=t,e[5]=d,e[6]=l,e[7]=a,e[8]=o,e[9]=r,e[10]=f,e[11]=u,e[12]=g,e[13]=y,e[14]=x,e[15]=i,e[16]=h):h=e[16];let N;return e[17]!==p||e[18]!==h?(N=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[p,h]}),e[17]=p,e[18]=h,e[19]=N):N=e[19],N},Ft=n=>{const e=P(59),{limit:t}=n,d=t??nt,l=Ve(),a=j(),[o,r]=M("declared"),[f,u]=M(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:y,error:x,errorSource:i}=Be(G.listQueues,g);let m;e[1]!==d?(m={limit:d},e[1]=d,e[2]=m):m=e[2];const{data:p,error:h,errorSource:N,refetch:b}=Be(G.getQueueMessages,m),E=Array.isArray(y?.queues)?[...y.queues].toSorted(bt):[],w=p?.entries??[],{deadLetteredCount:v,queuesWithoutDlq:Q,showReliabilityWarning:D}=rt(E,w),[U,J]=M(""),[A,I]=M(""),[C,L]=M(""),[F,We]=M(!1),[le,Ie]=M(!1),[de,Le]=M(null),z=E.some(c=>c.exportName===U)?U:E[0]?.exportName??"",Me=o==="messages"?h:x,Ge=o==="messages"?N:i,ie=Me??f,ce=Me===null?f:Ge;let H;e[3]!==b?(H=()=>{b()},e[3]=b,e[4]=H):H=e[4],st(H,o==="messages");const ue=async()=>{u(null);const c=z;if(c==="")return;let S=null;const Se=A.trim();if(Se!=="")try{S=JSON.parse(Se)}catch{u(a("Body must be valid JSON."));return}let Ee;const De=C.trim();if(De!==""){const W=Number(De);if(!Number.isFinite(W)||W<0){u(a("Delay must be a non-negative number of seconds."));return}Ee=W}if(F&&!Array.isArray(S)){u(a("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const He=F?{batch:S,delaySeconds:Ee,exportName:c}:{body:S,delaySeconds:Ee,exportName:c};try{await l.query(ot,He,_e("")),b()}catch(W){u(Te(W))}Ie(!1)};let V;e[5]!==l||e[6]!==b?(V=async c=>{u(null),Le(c);try{await l.query(lt,{id:c},_e("")),b()}catch(S){u(Te(S))}Le(null)},e[5]=l,e[6]=b,e[7]=V):V=e[7];const me=V;let Y;e[8]!==l||e[9]!==b?(Y=async()=>{u(null);try{await l.query(dt,{},_e("")),b()}catch(c){u(Te(c))}},e[8]=l,e[9]=b,e[10]=Y):Y=e[10];const fe=Y;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const S=c.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&r(S)},e[11]=X):X=e[11];const Pe=X;let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=c=>{J(c.currentTarget.value)},e[12]=K):K=e[12];const he=K;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{I(c.currentTarget.value)},e[13]=Z):Z=e[13];const pe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{L(c.currentTarget.value)},e[14]=ee):ee=e[14];const ge=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{We(c.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let se;e[16]!==ue?(se=()=>{Ce(ue())},e[16]=ue,e[17]=se):se=e[17];const ye=se;let ae;e[18]!==me?(ae=c=>{const{id:S}=c.currentTarget.dataset;S!==void 0&&Ce(me(S))},e[18]=me,e[19]=ae):ae=e[19];const be=ae;let re;e[20]!==fe?(re=()=>{Ce(fe())},e[20]=fe,e[21]=re):re=e[21];const Ne=re,je="flex flex-col gap-6",ze="lunora-queues-panel";let B;e[22]!==a||e[23]!==o?(B=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>s(Qe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:mt(c,a)},c))}),e[22]=a,e[23]=o,e[24]=B):B=e[24];let R;e[25]!==ie||e[26]!==ce?(R=ie!==null&&s(Xe,{error:ce,testId:"queues-error"}),e[25]=ie,e[26]=ce,e[27]=R):R=e[27];const qe=D&&s(Ke,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[Q.length>0&&q(Fe,{children:[s("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(Nt).join(", ")})}),s("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),v>0&&s("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:v===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:v})})]})});let $;e[28]!==E||e[29]!==y||e[30]!==o?($=o==="declared"&&s(ft,{loaded:y!==void 0,queues:E}),e[28]=E,e[29]=y,e[30]=o,e[31]=$):$=e[31];let O;e[32]!==w||e[33]!==h||e[34]!==Ne||e[35]!==be||e[36]!==de||e[37]!==o?(O=o==="messages"&&s(pt,{hasError:h!==null,messages:w,onClear:Ne,onReplay:be,replayingId:de}),e[32]=w,e[33]=h,e[34]=Ne,e[35]=be,e[36]=de,e[37]=o,e[38]=O):O=e[38];let k;e[39]!==F||e[40]!==A||e[41]!==C||e[42]!==xe||e[43]!==pe||e[44]!==ge||e[45]!==he||e[46]!==ye||e[47]!==E||e[48]!==z||e[49]!==le||e[50]!==o?(k=o==="send"&&s(gt,{batchMode:F,bodyText:A,delayText:C,onBatchModeChange:xe,onBodyChange:pe,onDelayChange:ge,onSelectExport:he,onSend:ye,queues:E,selectedExportName:z,sending:le}),e[39]=F,e[40]=A,e[41]=C,e[42]=xe,e[43]=pe,e[44]=ge,e[45]=he,e[46]=ye,e[47]=E,e[48]=z,e[49]=le,e[50]=o,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=q("div",{className:je,"data-testid":ze,children:[B,R,qe,$,O,k]}),e[52]=B,e[53]=R,e[54]=qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne};function xt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[s(T,{className:"font-mono text-xs",children:n.exportName}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.name}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function yt(n){return s("option",{value:n.exportName,children:n.exportName},n.exportName)}function bt(n,e){return n.exportName.localeCompare(e.exportName)}function Nt(n){return n.name}export{Ft as default};
1
+ import{c as P}from"react/compiler-runtime";import{useLunora as Ve}from"@lunora/react";import{useState as M}from"react";import{ConfirmButton as Ye}from"../packem_shared/ConfirmButton-Cj2SOapE.js";import{E as Xe}from"../packem_shared/error-alert-CKqB2CiN.js";import{A as Ke}from"../packem_shared/alert-C2SEhYS9.js";import{B as ve}from"../packem_shared/badge-cAk9Di1Q.js";import{B as Qe}from"../packem_shared/button-BOPLD1un.js";import{C as $e,a as Oe}from"../packem_shared/card-BGlQzQY-.js";import{E as we}from"../packem_shared/empty-state-B939z6K2.js";import{I as Ze}from"../packem_shared/input-CY5W3wzv.js";import{S as et}from"../packem_shared/scroll-area-DSJftwu_.js";import{T as ke,a as Ue,b as oe,c as _,d as Je,e as T}from"../packem_shared/table-BMsuYFhk.js";import{T as tt}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as Be}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useAutoRefresh as st}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as _e,b as Te,c as Ae,f as Ce,i as at}from"../packem_shared/internal-7bgd8inO.js";import{jsx as s,jsxs as q,Fragment as Fe}from"react/jsx-runtime";const rt=(n,e)=>{const t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),d=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),l=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:l,queuesWithoutDlq:d,showReliabilityWarning:d.length>0||l>0}},nt=200,ot=Ae(G.sendQueueMessage),lt=Ae(G.replayQueueMessage),dt=Ae(G.clearQueueMessages),Re=96,it=n=>{if(n===void 0)return"—";try{return JSON.stringify(n)}catch{return"[unserializable]"}},ct=n=>n.length>Re?`${n.slice(0,Re)}…`:n,ut=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",mt=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ft=n=>{const e=P(11),{loaded:t,queues:d}=n,l=j();let a;e[0]!==l?(a=l("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=l,e[1]=a):a=e[1];let o;e[2]!==a?(o=s("p",{className:"text-sm text-muted-foreground",children:a}),e[2]=a,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==d||e[6]!==l?(r=t&&d.length===0?s(we,{description:l("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:l("No queues defined")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:q(ke,{"data-testid":"queues-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:l("Export")}),s(_,{children:l("Queue")}),s(_,{children:l("Mode")}),s(_,{children:l("Binding")}),s(_,{children:l("Dead-letter")})]})}),s(Je,{children:d.map(xt)})]})})}),e[4]=t,e[5]=d,e[6]=l,e[7]=r):r=e[7];let f;return e[8]!==o||e[9]!==r?(f=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=f):f=e[10],f},ht=n=>{const e=P(67),{message:t,onReplay:d,replayingId:l}=n,a=j();let o,r,f,u,g,y,x,i,m,p;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){const U=it(t.body);r=oe,y=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(x=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=x):x=e[20],e[21]!==t.messageId?(i=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=i):i=e[22],e[23]!==t.attempts?(m=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=ut(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(ve,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let L;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(L=t.deadLettered&&s(ve,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=L):L=e[34],e[35]!==C||e[36]!==L?(p=s(T,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,L]})}),e[35]=C,e[36]=L,e[37]=p):p=e[37],o=T,f="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=U,g=ct(U),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=o,e[10]=r,e[11]=f,e[12]=u,e[13]=g,e[14]=y,e[15]=x,e[16]=i,e[17]=m,e[18]=p}else o=e[9],r=e[10],f=e[11],u=e[12],g=e[13],y=e[14],x=e[15],i=e[16],m=e[17],p=e[18];let h;e[38]!==o||e[39]!==f||e[40]!==u||e[41]!==g?(h=s(o,{className:f,title:u,children:g}),e[38]=o,e[39]=f,e[40]=u,e[41]=g,e[42]=h):h=e[42];let N;e[43]!==t.capturedAt?(N=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=b):b=e[46];const E=`queues-replay-${t.id}`,w=l!==null;let v;e[47]!==t.id||e[48]!==l||e[49]!==a?(v=l===t.id?a("Replaying…"):a("Replay"),e[47]=t.id,e[48]=l,e[49]=a,e[50]=v):v=e[50];let Q;e[51]!==t.id||e[52]!==d||e[53]!==E||e[54]!==w||e[55]!==v?(Q=s(T,{children:s(Qe,{"data-id":t.id,"data-testid":E,disabled:w,onClick:d,size:"xs",type:"button",variant:"outline",children:v})}),e[51]=t.id,e[52]=d,e[53]=E,e[54]=w,e[55]=v,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==y||e[61]!==x||e[62]!==i||e[63]!==m||e[64]!==p||e[65]!==h?(D=q(r,{"data-testid":y,children:[x,i,m,p,h,b,Q]}),e[57]=r,e[58]=b,e[59]=Q,e[60]=y,e[61]=x,e[62]=i,e[63]=m,e[64]=p,e[65]=h,e[66]=D):D=e[66],D},pt=n=>{const e=P(30),{hasError:t,messages:d,onClear:l,onReplay:a,replayingId:o}=n,r=j();let f;e[0]!==r?(f=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=f):f=e[1];let u;e[2]!==f?(u=s("p",{className:"text-sm text-muted-foreground",children:f}),e[2]=f,e[3]=u):u=e[3];let g;e[4]!==d.length||e[5]!==r?(g=r("Clear {count} messages?",{count:d.length}),e[4]=d.length,e[5]=r,e[6]=g):g=e[6];const y=d.length===0;let x;e[7]!==r?(x=r("Clear log"),e[7]=r,e[8]=x):x=e[8];let i;e[9]!==l||e[10]!==g||e[11]!==y||e[12]!==x?(i=s("div",{className:"ml-auto",children:s(Ye,{confirmLabel:g,disabled:y,onConfirm:l,testId:"queues-clear",children:x})}),e[9]=l,e[10]=g,e[11]=y,e[12]=x,e[13]=i):i=e[13];let m;e[14]!==d.length||e[15]!==r?(m=d.length>0&&s(ve,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:d.length})}),e[14]=d.length,e[15]=r,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==i||e[19]!==m?(p=q("div",{className:"flex flex-wrap items-center gap-2",children:[u,i,m]}),e[17]=u,e[18]=i,e[19]=m,e[20]=p):p=e[20];let h;e[21]!==t||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==r?(h=!t&&d.length===0?s(we,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:s(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(ke,{"data-testid":"queues-messages-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:r("Export")}),s(_,{children:r("Message")}),s(_,{children:r("Attempts")}),s(_,{children:r("Outcome")}),s(_,{children:r("Body")}),s(_,{children:r("Captured")}),s(_,{})]})}),s(Je,{children:d.map(b=>s(ht,{message:b,onReplay:a,replayingId:o},b.id))})]})})})}),e[21]=t,e[22]=d,e[23]=a,e[24]=o,e[25]=r,e[26]=h):h=e[26];let N;return e[27]!==p||e[28]!==h?(N=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[p,h]}),e[27]=p,e[28]=h,e[29]=N):N=e[29],N},gt=n=>{const e=P(20),{batchMode:t,bodyText:d,delayText:l,onBatchModeChange:a,onBodyChange:o,onDelayChange:r,onSelectExport:f,onSend:u,queues:g,selectedExportName:y,sending:x}=n,i=j();let m;e[0]!==i?(m=i("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=i,e[1]=m):m=e[1];let p;e[2]!==m?(p=s("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3];let h;e[4]!==t||e[5]!==d||e[6]!==l||e[7]!==a||e[8]!==o||e[9]!==r||e[10]!==f||e[11]!==u||e[12]!==g||e[13]!==y||e[14]!==x||e[15]!==i?(h=g.length===0?s(we,{description:i("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:i("No queues to send to")}):q(Fe,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[s("select",{"aria-label":i("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:f,value:y,children:g.map(yt)}),s(Ze,{"aria-label":i("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:i("Delay (s)"),type:"number",value:l}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),i("Send as batch (JSON array)")]}),s(Qe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:u,type:"button",children:i(x?"Sending…":"Send message")})]}),s(tt,{"aria-label":i("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:d})]}),e[4]=t,e[5]=d,e[6]=l,e[7]=a,e[8]=o,e[9]=r,e[10]=f,e[11]=u,e[12]=g,e[13]=y,e[14]=x,e[15]=i,e[16]=h):h=e[16];let N;return e[17]!==p||e[18]!==h?(N=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[p,h]}),e[17]=p,e[18]=h,e[19]=N):N=e[19],N},Ft=n=>{const e=P(59),{limit:t}=n,d=t??nt,l=Ve(),a=j(),[o,r]=M("declared"),[f,u]=M(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:y,error:x,errorSource:i}=Be(G.listQueues,g);let m;e[1]!==d?(m={limit:d},e[1]=d,e[2]=m):m=e[2];const{data:p,error:h,errorSource:N,refetch:b}=Be(G.getQueueMessages,m),E=Array.isArray(y?.queues)?[...y.queues].toSorted(bt):[],w=p?.entries??[],{deadLetteredCount:v,queuesWithoutDlq:Q,showReliabilityWarning:D}=rt(E,w),[U,J]=M(""),[A,I]=M(""),[C,L]=M(""),[F,We]=M(!1),[le,Ie]=M(!1),[de,Le]=M(null),z=E.some(c=>c.exportName===U)?U:E[0]?.exportName??"",Me=o==="messages"?h:x,Ge=o==="messages"?N:i,ie=Me??f,ce=Me===null?f:Ge;let H;e[3]!==b?(H=()=>{b()},e[3]=b,e[4]=H):H=e[4],st(H,o==="messages");const ue=async()=>{u(null);const c=z;if(c==="")return;let S=null;const Se=A.trim();if(Se!=="")try{S=JSON.parse(Se)}catch{u(a("Body must be valid JSON."));return}let Ee;const De=C.trim();if(De!==""){const W=Number(De);if(!Number.isFinite(W)||W<0){u(a("Delay must be a non-negative number of seconds."));return}Ee=W}if(F&&!Array.isArray(S)){u(a("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const He=F?{batch:S,delaySeconds:Ee,exportName:c}:{body:S,delaySeconds:Ee,exportName:c};try{await l.query(ot,He,_e("")),b()}catch(W){u(Te(W))}Ie(!1)};let V;e[5]!==l||e[6]!==b?(V=async c=>{u(null),Le(c);try{await l.query(lt,{id:c},_e("")),b()}catch(S){u(Te(S))}Le(null)},e[5]=l,e[6]=b,e[7]=V):V=e[7];const me=V;let Y;e[8]!==l||e[9]!==b?(Y=async()=>{u(null);try{await l.query(dt,{},_e("")),b()}catch(c){u(Te(c))}},e[8]=l,e[9]=b,e[10]=Y):Y=e[10];const fe=Y;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const S=c.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&r(S)},e[11]=X):X=e[11];const Pe=X;let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=c=>{J(c.currentTarget.value)},e[12]=K):K=e[12];const he=K;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{I(c.currentTarget.value)},e[13]=Z):Z=e[13];const pe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{L(c.currentTarget.value)},e[14]=ee):ee=e[14];const ge=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{We(c.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let se;e[16]!==ue?(se=()=>{Ce(ue())},e[16]=ue,e[17]=se):se=e[17];const ye=se;let ae;e[18]!==me?(ae=c=>{const{id:S}=c.currentTarget.dataset;S!==void 0&&Ce(me(S))},e[18]=me,e[19]=ae):ae=e[19];const be=ae;let re;e[20]!==fe?(re=()=>{Ce(fe())},e[20]=fe,e[21]=re):re=e[21];const Ne=re,je="flex flex-col gap-6",ze="lunora-queues-panel";let B;e[22]!==a||e[23]!==o?(B=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>s(Qe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:mt(c,a)},c))}),e[22]=a,e[23]=o,e[24]=B):B=e[24];let R;e[25]!==ie||e[26]!==ce?(R=ie!==null&&s(Xe,{error:ce,testId:"queues-error"}),e[25]=ie,e[26]=ce,e[27]=R):R=e[27];const qe=D&&s(Ke,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[Q.length>0&&q(Fe,{children:[s("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(Nt).join(", ")})}),s("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),v>0&&s("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:v===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:v})})]})});let $;e[28]!==E||e[29]!==y||e[30]!==o?($=o==="declared"&&s(ft,{loaded:y!==void 0,queues:E}),e[28]=E,e[29]=y,e[30]=o,e[31]=$):$=e[31];let O;e[32]!==w||e[33]!==h||e[34]!==Ne||e[35]!==be||e[36]!==de||e[37]!==o?(O=o==="messages"&&s(pt,{hasError:h!==null,messages:w,onClear:Ne,onReplay:be,replayingId:de}),e[32]=w,e[33]=h,e[34]=Ne,e[35]=be,e[36]=de,e[37]=o,e[38]=O):O=e[38];let k;e[39]!==F||e[40]!==A||e[41]!==C||e[42]!==xe||e[43]!==pe||e[44]!==ge||e[45]!==he||e[46]!==ye||e[47]!==E||e[48]!==z||e[49]!==le||e[50]!==o?(k=o==="send"&&s(gt,{batchMode:F,bodyText:A,delayText:C,onBatchModeChange:xe,onBodyChange:pe,onDelayChange:ge,onSelectExport:he,onSend:ye,queues:E,selectedExportName:z,sending:le}),e[39]=F,e[40]=A,e[41]=C,e[42]=xe,e[43]=pe,e[44]=ge,e[45]=he,e[46]=ye,e[47]=E,e[48]=z,e[49]=le,e[50]=o,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=q("div",{className:je,"data-testid":ze,children:[B,R,qe,$,O,k]}),e[52]=B,e[53]=R,e[54]=qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne};function xt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[s(T,{className:"font-mono text-xs",children:n.exportName}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.name}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function yt(n){return s("option",{value:n.exportName,children:n.exportName},n.exportName)}function bt(n,e){return n.exportName.localeCompare(e.exportName)}function Nt(n){return n.name}export{Ft as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-TYdKetJd.js";import{B as M}from"../packem_shared/badge-cAk9Di1Q.js";import{a as _,C as j}from"../packem_shared/card-BGlQzQY-.js";import{E as D}from"../packem_shared/empty-state-B939z6K2.js";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as L}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=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:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=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:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
1
+ import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-CKqB2CiN.js";import{B as M}from"../packem_shared/badge-cAk9Di1Q.js";import{a as _,C as j}from"../packem_shared/card-BGlQzQY-.js";import{E as D}from"../packem_shared/empty-state-B939z6K2.js";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as L}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=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:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=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:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
@@ -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-BOPLD1un.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-Cj2SOapE.js";import{B as O}from"../packem_shared/badge-cAk9Di1Q.js";import{C as P,a as R}from"../packem_shared/card-BGlQzQY-.js";import{E as W}from"../packem_shared/empty-state-B939z6K2.js";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-BMsuYFhk.js";import{b as H}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{f as A,b as U,i as j}from"../packem_shared/internal-CwaF9YNk.js";import{jsxs as u,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-CiO3eXgI.js";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 u("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:u("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:u(Q,{"data-testid":"cron-table",children:[t(K,{children:u(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 u(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:u("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:u("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?m=>s.retryDeadJob(m):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?m=>s.removeDeadJob(m):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.refetch()},e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async m=>{g(void 0);try{await m,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:u(Q,{"data-testid":"dlq-table",children:[t(K,{children:u(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(m=>u(q,{"data-testid":`dlq-row-${m.id}`,children:[t(b,{className:"font-mono text-xs",children:m.functionPath}),t(b,{className:"tabular-nums",children:m.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(m.scheduledFor)}),t(b,{className:"font-mono text-xs",children:m.pool??""}),t(b,{children:m.shardKey??""}),t(b,{className:"font-mono text-xs",children:m.id}),T&&t(b,{className:"text-right",children:u("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${m.id}`,onClick:()=>{A(L(v(m.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(m.id)))},testId:`dlq-remove-${m.id}`,children:r("Drop")})]})})]},m.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=u("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:u(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.refetch()},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&&u("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:u(Q,{"data-testid":"pools-table",children:[t(K,{children:u(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=u("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 u(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}),u(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=u("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-BOPLD1un.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-Cj2SOapE.js";import{B as O}from"../packem_shared/badge-cAk9Di1Q.js";import{C as P,a as R}from"../packem_shared/card-BGlQzQY-.js";import{E as W}from"../packem_shared/empty-state-B939z6K2.js";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-BMsuYFhk.js";import{b as H}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{f as A,b as U,i as j}from"../packem_shared/internal-7bgd8inO.js";import{jsxs as u,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-DRmOKtDa.js";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 u("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:u("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:u(Q,{"data-testid":"cron-table",children:[t(K,{children:u(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 u(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:u("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:u("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?m=>s.retryDeadJob(m):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?m=>s.removeDeadJob(m):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.refetch()},e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async m=>{g(void 0);try{await m,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:u(Q,{"data-testid":"dlq-table",children:[t(K,{children:u(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(m=>u(q,{"data-testid":`dlq-row-${m.id}`,children:[t(b,{className:"font-mono text-xs",children:m.functionPath}),t(b,{className:"tabular-nums",children:m.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(m.scheduledFor)}),t(b,{className:"font-mono text-xs",children:m.pool??""}),t(b,{children:m.shardKey??""}),t(b,{className:"font-mono text-xs",children:m.id}),T&&t(b,{className:"text-right",children:u("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${m.id}`,onClick:()=>{A(L(v(m.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(m.id)))},testId:`dlq-remove-${m.id}`,children:r("Drop")})]})})]},m.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=u("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:u(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.refetch()},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&&u("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:u(Q,{"data-testid":"pools-table",children:[t(K,{children:u(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=u("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 u(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}),u(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=u("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-TYdKetJd.js";import{B as R}from"../packem_shared/badge-cAk9Di1Q.js";import{C as T,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as S}from"../packem_shared/empty-state-B939z6K2.js";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-BMsuYFhk.js";import{u as A}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";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-CKqB2CiN.js";import{B as R}from"../packem_shared/badge-cAk9Di1Q.js";import{C as T,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as S}from"../packem_shared/empty-state-B939z6K2.js";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-BMsuYFhk.js";import{u as A}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";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 E}from"react/compiler-runtime";import{E as M}from"../packem_shared/error-alert-TYdKetJd.js";import{ShardInput as $}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as C}from"../packem_shared/badge-cAk9Di1Q.js";import{C as j,a as B}from"../packem_shared/card-BGlQzQY-.js";import{E as R}from"../packem_shared/empty-state-B939z6K2.js";import{T as _,a as D,b as k,c as y,d as H,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as P}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,q=c=>{if(c===void 0)return"";const e=JSON.stringify(c);return e.length>w?`${e.slice(0,w)}…`:e},G=c=>{const e=[];for(const r of c){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((u,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:u})})}return e},I=t("span",{className:"text-muted-foreground",children:"—"}),oe=c=>{const e=E(22),{initialShardKey:r}=c,n=O(),{queryShardKey:u,setShardKey:o,shardKey:m}=L(r);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let p;e[1]!==u?(p={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=p):p=e[2];const{data:s,error:i,errorSource:h,refetch:K}=P(W.listSubscriptions,f,p);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){const N=s===void 0?[]:G(s.connections);let l;e[10]!==o||e[11]!==m?(l=t($,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,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(C,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(C,{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(M,{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(R,{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(j,{className:"overflow-hidden py-0",children:t(B,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(k,{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:A}=v,T=q(A?.args);return a(k,{"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(C,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:A?.functionPath??I}),t(S,{children:A?.table??I}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:T||void 0,children:T||I})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{oe as default};
1
+ import{c as E}from"react/compiler-runtime";import{E as M}from"../packem_shared/error-alert-CKqB2CiN.js";import{ShardInput as $}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as C}from"../packem_shared/badge-cAk9Di1Q.js";import{C as j,a as B}from"../packem_shared/card-BGlQzQY-.js";import{E as R}from"../packem_shared/empty-state-B939z6K2.js";import{T as _,a as D,b as k,c as y,d as H,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as P}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,q=c=>{if(c===void 0)return"";const e=JSON.stringify(c);return e.length>w?`${e.slice(0,w)}…`:e},G=c=>{const e=[];for(const r of c){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((u,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:u})})}return e},I=t("span",{className:"text-muted-foreground",children:"—"}),oe=c=>{const e=E(22),{initialShardKey:r}=c,n=O(),{queryShardKey:u,setShardKey:o,shardKey:m}=L(r);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let p;e[1]!==u?(p={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=p):p=e[2];const{data:s,error:i,errorSource:h,refetch:K}=P(W.listSubscriptions,f,p);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){const N=s===void 0?[]:G(s.connections);let l;e[10]!==o||e[11]!==m?(l=t($,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,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(C,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(C,{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(M,{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(R,{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(j,{className:"overflow-hidden py-0",children:t(B,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(k,{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:A}=v,T=q(A?.args);return a(k,{"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(C,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:A?.functionPath??I}),t(S,{children:A?.table??I}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:T||void 0,children:T||I})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{oe 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-cAk9Di1Q.js";import{C as R,a as H}from"../packem_shared/card-BGlQzQY-.js";import{E as P}from"../packem_shared/empty-state-B939z6K2.js";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-BMsuYFhk.js";import{b as Q}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";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,refetch: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-cAk9Di1Q.js";import{C as R,a as H}from"../packem_shared/card-BGlQzQY-.js";import{E as P}from"../packem_shared/empty-state-B939z6K2.js";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-BMsuYFhk.js";import{b as Q}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";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,refetch: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-TYdKetJd.js";import{L as be}from"../packem_shared/live-status-Bf7rR8o8.js";import{ShardInput as xe}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as fe}from"../packem_shared/badge-cAk9Di1Q.js";import{C as ye}from"../packem_shared/checkbox-C5w53W-E.js";import{E as Ne}from"../packem_shared/empty-state-B939z6K2.js";import{I as ve}from"../packem_shared/input-CY5W3wzv.js";import{u as oe}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{u as Se}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as me}from"../packem_shared/internal-CwaF9YNk.js";import{r as we}from"../packem_shared/shard-history-QcjcMnCA.js";import{p as _e,c as Ie}from"../packem_shared/trace-handoff-C0CFV2ix.js";import{L as ke}from"../packem_shared/log-line-UnE93Ovi.js";import{f as Me}from"../packem_shared/log-fields-SBxKyBug.js";import{c as ne}from"../packem_shared/utils-bhneXptQ.js";import{jsx as n,jsxs as k,Fragment as $e}from"react/jsx-runtime";const Te=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Le=(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(Te,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ce=(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`:"—",Ee=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)}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},Pe=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 S;e[22]!==s?(S=s("Parent span ID"),e[22]=s,e[23]=S):S=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]!==S?(u=n(Y,{label:S,value:m}),e[27]=m,e[28]=S,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 w;e[35]!==s?(w=s("Started at"),e[35]=s,e[36]=w):w=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]!==w||e[41]!==g?(b=n(Y,{label:w,value:g}),e[40]=w,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(Fe)})]}),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 Fe(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Ke(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(Ke).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",Re=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=Ee(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(je)}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=Le(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=Me(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)}%`,S=`${String(f)}%`;let m;e[7]!==v||e[8]!==S?(m={left:v,width:S},e[7]=v,e[8]=S,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(We)},e[10]=h):h=e[10];const T=h,_=t.depth,w=`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 R=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==R?(L=ne("absolute inset-y-0 rounded-sm",R),e[24]=R,e[25]=L):L=e[25];let D;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(D=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]=D):D=e[30];let B;e[31]!==t.durationMs?(B=q(t.durationMs),e[31]=t.durationMs,e[32]=B):B=e[32];let F;e[33]!==B?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:B}),e[33]=B,e[34]=F):F=e[34];let O;e[35]!==t.error?(O=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]=O):O=e[36];let C;e[37]!==O?(C=n("span",{className:"truncate text-muted-foreground",children:O}),e[37]=O,e[38]=C):C=e[38];let j;e[39]!==y?(j=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=j):j=e[40];let E;e[41]!==j?(E=n("span",{className:"truncate text-muted-foreground",children:j}),e[41]=j,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==w||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==D||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":w,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,D,F,C,E]}),e[43]=r,e[44]=w,e[45]=g,e[46]=I,e[47]=x,e[48]=D,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(Pe,{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(Re,{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($e,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function je(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 We(a){return!a}const Ue=a=>Array.isArray(a?.traces)?a.traces:[],qe=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(Ge),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},ze=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 S;e[9]!==r.durationMs?(S=q(r.durationMs),e[9]=r.durationMs,e[10]=S):S=e[10];let m;e[11]!==S?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:S}),e[11]=S,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 w;e[21]!==T||e[22]!==_?(w=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=w):w=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]!==w||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,w,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=w,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(qe,{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},gt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(_e),{queryShardKey:r,setShardKey:o,shardKey:i}=Se(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(He);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Je,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let S;e[2]!==r?(S={live:!0,shardKey:r},e[2]=r,e[3]=S):S=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,S);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w={},e[4]=w):w=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,w,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&we(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 R;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=Ue(m),D=m?.total??L.length,B=D>L.length,F=Ce(L,d,c),O=Map.groupBy((I?.entries??[]).toReversed(),Qe);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=A=>{f(A.target.value)},e[25]=C):C=e[25];const j=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=A=>{M(he=>{const ae=new Set(he);return ae.has(A)?ae.delete(A):ae.add(A),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:j,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],R=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&B&&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:D})}),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(A=>n(ze,{expanded:$.has(A.traceId),logs:O.get(A.traceId)??[],onToggle:W,trace:A},A.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]=R}else R=e[24];return R};function Ge(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(ke,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function He(){return new Set}function Je(){Ie()}function Qe(a){return a.traceId}export{gt 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-CKqB2CiN.js";import{L as be}from"../packem_shared/live-status-Bf7rR8o8.js";import{ShardInput as xe}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as fe}from"../packem_shared/badge-cAk9Di1Q.js";import{C as ye}from"../packem_shared/checkbox-C5w53W-E.js";import{E as Ne}from"../packem_shared/empty-state-B939z6K2.js";import{I as ve}from"../packem_shared/input-CY5W3wzv.js";import{u as oe}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{u as Se}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as me}from"../packem_shared/internal-7bgd8inO.js";import{r as we}from"../packem_shared/shard-history-QcjcMnCA.js";import{p as _e,c as Ie}from"../packem_shared/trace-handoff-C0CFV2ix.js";import{L as ke}from"../packem_shared/log-line-D0XBZaDn.js";import{f as Me}from"../packem_shared/log-fields-SBxKyBug.js";import{c as ne}from"../packem_shared/utils-bhneXptQ.js";import{jsx as n,jsxs as k,Fragment as $e}from"react/jsx-runtime";const Te=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Le=(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(Te,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ce=(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`:"—",Ee=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)}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},Pe=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 S;e[22]!==s?(S=s("Parent span ID"),e[22]=s,e[23]=S):S=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]!==S?(u=n(Y,{label:S,value:m}),e[27]=m,e[28]=S,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 w;e[35]!==s?(w=s("Started at"),e[35]=s,e[36]=w):w=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]!==w||e[41]!==g?(b=n(Y,{label:w,value:g}),e[40]=w,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(Fe)})]}),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 Fe(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Ke(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(Ke).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",Re=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=Ee(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(je)}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=Le(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=Me(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)}%`,S=`${String(f)}%`;let m;e[7]!==v||e[8]!==S?(m={left:v,width:S},e[7]=v,e[8]=S,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(We)},e[10]=h):h=e[10];const T=h,_=t.depth,w=`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 R=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==R?(L=ne("absolute inset-y-0 rounded-sm",R),e[24]=R,e[25]=L):L=e[25];let D;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(D=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]=D):D=e[30];let B;e[31]!==t.durationMs?(B=q(t.durationMs),e[31]=t.durationMs,e[32]=B):B=e[32];let F;e[33]!==B?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:B}),e[33]=B,e[34]=F):F=e[34];let O;e[35]!==t.error?(O=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]=O):O=e[36];let C;e[37]!==O?(C=n("span",{className:"truncate text-muted-foreground",children:O}),e[37]=O,e[38]=C):C=e[38];let j;e[39]!==y?(j=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=j):j=e[40];let E;e[41]!==j?(E=n("span",{className:"truncate text-muted-foreground",children:j}),e[41]=j,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==w||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==D||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":w,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,D,F,C,E]}),e[43]=r,e[44]=w,e[45]=g,e[46]=I,e[47]=x,e[48]=D,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(Pe,{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(Re,{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($e,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function je(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 We(a){return!a}const Ue=a=>Array.isArray(a?.traces)?a.traces:[],qe=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(Ge),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},ze=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 S;e[9]!==r.durationMs?(S=q(r.durationMs),e[9]=r.durationMs,e[10]=S):S=e[10];let m;e[11]!==S?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:S}),e[11]=S,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 w;e[21]!==T||e[22]!==_?(w=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=w):w=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]!==w||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,w,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=w,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(qe,{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},gt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(_e),{queryShardKey:r,setShardKey:o,shardKey:i}=Se(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(He);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Je,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let S;e[2]!==r?(S={live:!0,shardKey:r},e[2]=r,e[3]=S):S=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,S);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w={},e[4]=w):w=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,w,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&we(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 R;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=Ue(m),D=m?.total??L.length,B=D>L.length,F=Ce(L,d,c),O=Map.groupBy((I?.entries??[]).toReversed(),Qe);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=A=>{f(A.target.value)},e[25]=C):C=e[25];const j=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=A=>{M(he=>{const ae=new Set(he);return ae.has(A)?ae.delete(A):ae.add(A),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:j,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],R=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&B&&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:D})}),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(A=>n(ze,{expanded:$.has(A.traceId),logs:O.get(A.traceId)??[],onToggle:W,trace:A},A.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]=R}else R=e[24];return R};function Ge(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(ke,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function He(){return new Set}function Je(){Ie()}function Qe(a){return a.traceId}export{gt as default};
@@ -1 +1 @@
1
- import{useLunora as ge}from"@lunora/react";import{useState as F,useEffect as Ve}from"react";import{B as M}from"../packem_shared/badge-cAk9Di1Q.js";import{B as U}from"../packem_shared/button-BOPLD1un.js";import{C as Fe,a as Ie}from"../packem_shared/card-BGlQzQY-.js";import{E as Qe}from"../packem_shared/empty-state-B939z6K2.js";import{I as B}from"../packem_shared/input-CY5W3wzv.js";import{T as Re,a as Pe,b as O,c as D,d as Te,e as R}from"../packem_shared/table-BMsuYFhk.js";import{b as Ze}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{c as Ne}from"react/compiler-runtime";import{u as qe,D as We}from"../packem_shared/use-auth-config-z3KRWAqD.js";import{useAutoRefresh as Je}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import Ke from"../packem_shared/useDebounced-DVeQ5-oW.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{i as Se,h as Ae,f as Ee,b as je}from"../packem_shared/internal-CwaF9YNk.js";import{C as Xe}from"../packem_shared/checkbox-C5w53W-E.js";import{L as V}from"../packem_shared/label-BOUo-DP0.js";import{M as Ye}from"../packem_shared/modal-shell-wGW4CKEW.js";import{u as _e}from"../packem_shared/use-async-submit-DdLd0MdK.js";import{jsxs as i,jsx as t,Fragment as et}from"react/jsx-runtime";We.capabilities;const tt=()=>{const u=Ne(3),{config:e,ready:a}=qe();let l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),at=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){const l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},nt=u=>{const e=Ne(105),{onClose:a,onCreated:l}=u,c=ge(),s=ke(),{config:d}=qe(),{busy:n,error:r,run:m}=_e(),[k,S]=F(""),[x,w]=F(""),[y,A]=F(""),[h,g]=F("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[p,o]=F(b);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=f=>{S(f.target.value)},e[1]=C):C=e[1];const v=C;let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=f=>{w(f.target.value)},e[2]=I):I=e[2];const $=I;let T;e[3]===Symbol.for("react.memo_cache_sentinel")?(T=f=>{A(f.target.value)},e[3]=T):T=e[3];const ze=T;let q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q=f=>{g(f.target.value)},e[4]=q):q=e[4];const Be=q;let Y;e[5]===Symbol.for("react.memo_cache_sentinel")?(Y=(f,P)=>{o(H=>({...H,[f]:P}))},e[5]=Y):Y=e[5];const Ue=Y;let G;e[6]!==p?(G=f=>p[f.name]??(f.type==="boolean"?!1:""),e[6]=p,e[7]=G):G=e[7];const E=G;let Q;if(e[8]!==d.userFields||e[9]!==E){let f;e[11]!==E?(f=P=>!P.required||lt(P,E(P)),e[11]=E,e[12]=f):f=e[12],Q=d.userFields.every(f),e[8]=d.userFields,e[9]=E,e[10]=Q}else Q=e[10];const we=Q;let Z;e[13]!==n||e[14]!==k||e[15]!==x||e[16]!==we?(Z=!n&&k.trim()!==""&&x.trim()!==""&&we,e[13]=n,e[14]=k,e[15]=x,e[16]=we,e[17]=Z):Z=e[17];const $e=Z;let W;e[18]!==d.userFields||e[19]!==E?(W=()=>{const f={};for(const P of d.userFields){const H=at(P,E(P));H!==void 0&&(f[P.name]=H.value)}return Object.keys(f).length===0?void 0:f},e[18]=d.userFields,e[19]=E,e[20]=W):W=e[20];const Ce=W;let J;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(J=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),a()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=J):J=e[30];const N=J;let z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let j;e[35]!==L?(j=t("h2",{className:"text-sm font-semibold text-foreground",children:L}),e[35]=L,e[36]=j):j=e[36];let K;e[37]!==s?(K=s("email"),e[37]=s,e[38]=K):K=e[38];let X;e[39]!==K?(X=t(V,{htmlFor:"uc-email",children:K}),e[39]=K,e[40]=X):X=e[40];let _;e[41]!==k?(_=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:v,type:"email",value:k}),e[41]=k,e[42]=_):_=e[42];let ee;e[43]!==X||e[44]!==_?(ee=i("div",{className:"flex flex-col gap-1",children:[X,_]}),e[43]=X,e[44]=_,e[45]=ee):ee=e[45];let te;e[46]!==s?(te=s("name"),e[46]=s,e[47]=te):te=e[47];let se;e[48]!==te?(se=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=se):se=e[49];let le;e[50]!==x?(le=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:x}),e[50]=x,e[51]=le):le=e[51];let ae;e[52]!==se||e[53]!==le?(ae=i("div",{className:"flex flex-col gap-1",children:[se,le]}),e[52]=se,e[53]=le,e[54]=ae):ae=e[54];let ne;e[55]!==s?(ne=s("Password (optional)"),e[55]=s,e[56]=ne):ne=e[56];let re;e[57]!==ne?(re=t(V,{htmlFor:"uc-password",children:ne}),e[57]=ne,e[58]=re):re=e[58];let ie;e[59]!==y?(ie=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:ze,type:"password",value:y}),e[59]=y,e[60]=ie):ie=e[60];let oe;e[61]!==re||e[62]!==ie?(oe=i("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[61]=re,e[62]=ie,e[63]=oe):oe=e[63];let de;e[64]!==s?(de=s("Role (optional)"),e[64]=s,e[65]=de):de=e[65];let ce;e[66]!==de?(ce=t(V,{htmlFor:"uc-role",children:de}),e[66]=de,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:Be,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=i("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==d.userFields||e[74]!==E||e[75]!==s?(he=d.userFields.length>0&&i("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")}),d.userFields.map(f=>{const P=`uc-field-${f.name}`,H=f.required?"":` (${s("optional")})`;if(f.type==="boolean"){const Me=E(f)===!0;return i("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Xe,{checked:Me,"data-testid":P,id:P,onCheckedChange:Ge=>{Ue(f.name,Ge)}}),i("span",{className:"text-sm",children:[f.name,H]})]},f.name)}const He=E(f);return i("div",{className:"flex flex-col gap-1",children:[i(V,{htmlFor:P,children:[f.name,H]}),t(B,{"data-testid":P,id:P,onChange:Me=>{Ue(f.name,Me.target.value)},type:st[f.type],value:typeof He=="string"?He:""})]},f.name)})]}),e[73]=d.userFields,e[74]=E,e[75]=s,e[76]=he):he=e[76];let fe;e[77]!==r?(fe=r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:r}),e[77]=r,e[78]=fe):fe=e[78];let pe;e[79]!==s?(pe=s("Cancel"),e[79]=s,e[80]=pe):pe=e[80];let be;e[81]!==a||e[82]!==pe?(be=t(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:pe}),e[81]=a,e[82]=pe,e[83]=be):be=e[83];const Le=!$e;let ve;e[84]!==n||e[85]!==s?(ve=s(n?"Creating…":"Create"),e[84]=n,e[85]=s,e[86]=ve):ve=e[86];let xe;e[87]!==N||e[88]!==Le||e[89]!==ve?(xe=t(U,{"data-testid":"uc-submit",disabled:Le,onClick:N,size:"sm",type:"button",children:ve}),e[87]=N,e[88]=Le,e[89]=ve,e[90]=xe):xe=e[90];let ye;e[91]!==be||e[92]!==xe?(ye=i("div",{className:"flex justify-end gap-2 pt-1",children:[be,xe]}),e[91]=be,e[92]=xe,e[93]=ye):ye=e[93];let De;return e[94]!==a||e[95]!==z||e[96]!==j||e[97]!==ee||e[98]!==ae||e[99]!==oe||e[100]!==me||e[101]!==he||e[102]!==fe||e[103]!==ye?(De=i(Ye,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[j,ee,ae,oe,me,he,fe,ye]}),e[94]=a,e[95]=z,e[96]=j,e[97]=ee,e[98]=ae,e[99]=oe,e[100]=me,e[101]=he,e[102]=fe,e[103]=ye,e[104]=De):De=e[104],De},Oe=u=>{const e=Ne(2),{children:a}=u;let l;return e[0]!==a?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[0]=a,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:a,runAction:l,userId:c,version:s}=u,d=ge(),n=ke(),[r,m]=F(null),[k,S]=F(null);let x;e[0]!==d||e[1]!==c?(x=()=>{Ee((async()=>{S(null);try{const v=await d.listAuthSessions({limit:50,userId:c});m(v.rows)}catch(v){const I=v;m(null),S(je(I))}})())},e[0]=d,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==d||e[4]!==c||e[5]!==s?(w=[d,c,s],e[3]=d,e[4]=c,e[5]=s,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==d||e[8]!==l?(y=v=>{l(()=>d.revokeAuthSession({sessionId:v}))},e[7]=d,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==n?(h=n("Sessions"),e[10]=n,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Oe,{children:h}),e[12]=h,e[13]=g):g=e[13];let b;e[14]!==k?(b=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=b):b=e[15];let p;e[16]!==r||e[17]!==n?(p=r!==null&&r.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=r,e[17]=n,e[18]=p):p=e[18];let o;e[19]!==a||e[20]!==A||e[21]!==r||e[22]!==n?(o=r!==null&&r.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:n("expires")}),t(D,{children:n("ip")}),t(D,{children:n("user agent")}),t(D,{"aria-label":n("Actions")})]})}),t(Te,{children:r.map(v=>i(O,{"data-testid":`ud-session-${v.id}`,children:[t(R,{className:"text-muted-foreground tabular-nums",children:Se(v.expiresAt)}),t(R,{children:v.ipAddress??""}),t(R,{className:"max-w-40 truncate",children:v.userAgent??""}),t(R,{children:t(U,{"data-testid":`ud-revoke-${v.id}`,disabled:a,onClick:()=>{A(v.id)},size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},v.id))})]})})}),e[19]=a,e[20]=A,e[21]=r,e[22]=n,e[23]=o):o=e[23];let C;return e[24]!==g||e[25]!==b||e[26]!==p||e[27]!==o?(C=i("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,b,p,o]}),e[24]=g,e[25]=b,e[26]=p,e[27]=o,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:a,runAction:l,userId:c,version:s}=u,d=ge(),n=ke(),[r,m]=F(null),[k,S]=F(null);let x;e[0]!==d||e[1]!==c?(x=()=>{Ee((async()=>{S(null);try{m(await d.listAuthAccounts({userId:c}))}catch(v){const I=v;m(null),S(je(I))}})())},e[0]=d,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==d||e[4]!==c||e[5]!==s?(w=[d,c,s],e[3]=d,e[4]=c,e[5]=s,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==d||e[8]!==l||e[9]!==c?(y=v=>{l(()=>d.unlinkAuthAccount({accountId:v,userId:c}))},e[7]=d,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==n?(h=n("Linked accounts"),e[11]=n,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Oe,{children:h}),e[13]=h,e[14]=g):g=e[14];let b;e[15]!==k?(b=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=b):b=e[16];let p;e[17]!==r||e[18]!==n?(p=r!==null&&r.length===0&&t("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=r,e[18]=n,e[19]=p):p=e[19];let o;e[20]!==r||e[21]!==a||e[22]!==A||e[23]!==n?(o=r!==null&&r.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:n("provider")}),t(D,{children:n("created")}),t(D,{"aria-label":n("Actions")})]})}),t(Te,{children:r.map(v=>{const I=Ae(v.id);return i(O,{"data-testid":`ud-account-${I}`,children:[t(R,{children:Ae(v.providerId)}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(v.createdAt)}),t(R,{children:t(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:()=>{A(I)},size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},I)})})]})})}),e[20]=r,e[21]=a,e[22]=A,e[23]=n,e[24]=o):o=e[24];let C;return e[25]!==g||e[26]!==b||e[27]!==p||e[28]!==o?(C=i("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,b,p,o]}),e[25]=g,e[26]=b,e[27]=p,e[28]=o,e[29]=C):C=e[29],C},ot=u=>{const e=Ne(40),{busy:a,capabilities:l,runAction:c,userId:s,version:d}=u,n=ge(),r=ke(),[m,k]=F(null);let S;e[0]!==l.passkey||e[1]!==n||e[2]!==s?(S=()=>{l.passkey&&Ee((async()=>{try{k(await n.listAuthPasskeys({userId:s}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=n,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==n||e[6]!==s||e[7]!==d?(x=[l.passkey,n,s,d],e[4]=l.passkey,e[5]=n,e[6]=s,e[7]=d,e[8]=x):x=e[8],Ve(S,x);let w;e[9]!==n||e[10]!==c||e[11]!==s?(w=()=>{c(()=>n.disableAuthTwoFactor({userId:s}))},e[9]=n,e[10]=c,e[11]=s,e[12]=w):w=e[12];const y=w;let A;e[13]!==n||e[14]!==c?(A=I=>{c(()=>n.deleteAuthPasskey({passkeyId:I}))},e[13]=n,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==r?(g=r("Security"),e[16]=r,e[17]=g):g=e[17];let b;e[18]!==g?(b=t(Oe,{children:g}),e[18]=g,e[19]=b):b=e[19];let p;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==r?(p=l.twoFactor&&t(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:r("Disable two-factor")}),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=r,e[24]=p):p=e[24];let o;e[25]!==l.passkey||e[26]!==m||e[27]!==r?(o=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=r,e[28]=o):o=e[28];let C;e[29]!==a||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==r?(C=l.passkey&&m!==null&&m.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:r("name")}),t(D,{children:r("created")}),t(D,{"aria-label":r("Actions")})]})}),t(Te,{children:m.map(I=>{const $=Ae(I.id);return i(O,{"data-testid":`ud-passkey-${$}`,children:[t(R,{children:Ae(I.name)||$}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(I.createdAt)}),t(R,{children:t(U,{"data-testid":`ud-delete-passkey-${$}`,disabled:a,onClick:()=>{h($)},size:"xs",type:"button",variant:"ghost",children:r("Delete")})})]},$)})})]})})}),e[29]=a,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=r,e[34]=C):C=e[34];let v;return e[35]!==b||e[36]!==p||e[37]!==o||e[38]!==C?(v=i("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,p,o,C]}),e[35]=b,e[36]=p,e[37]=o,e[38]=C,e[39]=v):v=e[39],v},dt=/(?:at|expires)$/iu,ct=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ut=(u,e)=>typeof e=="number"&&dt.test(u)?Se(e):Ae(e),mt=({capabilities:u,onChanged:e,onClose:a,user:l})=>{const c=ge(),s=ke(),d=l.banned===!0,[n,r]=F(null),[m,k]=F(!1),[S,x]=F(0),[w,y]=F(typeof l.role=="string"?l.role:""),[A,h]=F(""),[g,b]=F(""),[p,o]=F(""),[C,v]=F(null),[I,$]=F(!1),T=(N,z)=>{Ee((async()=>{k(!0),r(null);try{const L=await N();z?.refresh!==!1&&(x(j=>j+1),e()),z?.onResult?.(L)}catch(L){r(je(L))}k(!1)})())},ze=N=>{y(N.target.value)},q=N=>{h(N.target.value)},Be=N=>{b(N.target.value)},Y=N=>{o(N.target.value)},Ue=()=>{const N=w.trim();N!==""&&T(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},G=()=>{const N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;T(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},E=()=>{T(async()=>{await c.unbanAuthUser({userId:l.id})})},Q=()=>{T(async()=>{await c.setAuthUserPassword({newPassword:p,userId:l.id}),o("")})},we=()=>{T(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{v(N.token)},refresh:!1})},Z=()=>{T(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},$e=()=>{T(async()=>{await c.removeAuthUser({userId:l.id}),a()})},W=()=>{$(!0)},Ce=()=>{$(!1)},J=Object.entries(l).filter(([N])=>!ct.has(N));return i(Ye,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[i("div",{className:"flex items-start justify-between gap-2",children:[i("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),i("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),d?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"outline",children:s("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:s("verified")}):t(M,{variant:"outline",children:s("unverified")})]})]}),t(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),n!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),u.admin&&i(Fe,{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")})}),i(Ie,{className:"flex flex-col gap-3 p-3",children:[i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:ze,value:w})]}),t(U,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Ue,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),d?t(U,{"data-testid":"ud-unban",disabled:m,onClick:E,size:"sm",type:"button",variant:"outline",children:s("Unban")}):i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")}),t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:q,value:A})]}),i("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:s("Days")}),t(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Be,type:"number",value:g})]}),t(U,{"data-testid":"ud-ban",disabled:m,onClick:G,size:"sm",type:"button",variant:"destructive",children:s("Ban user")})]}),i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:Y,type:"password",value:p})]}),t(U,{"data-testid":"ud-set-password",disabled:m||p==="",onClick:Q,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),i("div",{className:"flex flex-wrap gap-2",children:[t(U,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(U,{"data-testid":"ud-revoke-all",disabled:m,onClick:Z,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),I?i(et,{children:[t(U,{"data-testid":"ud-delete-confirm",disabled:m,onClick:$e,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(U,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(U,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),C!==null&&i("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:T,userId:l.id,version:S}),u.accounts&&t(it,{busy:m,runAction:T,userId:l.id,version:S}),(u.twoFactor||u.passkey)&&t(ot,{busy:m,capabilities:u,runAction:T,userId:l.id,version:S}),i("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:J.map(([N,z])=>i("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ut(N,z)})]},N))})]})]})},ht=50,Et=({pageSize:u=ht}={})=>{const e=ge(),a=ke(),[l,c]=F(""),[s,d]=F(""),n=Ke(l),[r,m]=F(null),[k,S]=F(!1),{capabilities:x}=tt(),w=n.trim(),y=s.trim(),A=Ze(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,b=()=>{A.refetch()};Je(()=>{A.refetch()},!0);const p=r===null?null:h?.find(o=>o.id===r)??null;return i("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[i("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:o=>{c(o.target.value)},placeholder:a("Search by email or name…"),value:l}),t(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:o=>{d(o.target.value)},placeholder:a("Filter by role"),value:s}),t(U,{"data-testid":"us-new",onClick:()=>{S(!0)},size:"sm",type:"button",children:a("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Qe,{description:a("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:a("No users.")}),h!==null&&h.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"us-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:a("id")}),t(D,{children:a("email")}),t(D,{children:a("name")}),t(D,{children:a("role")}),t(D,{children:a("status")}),t(D,{children:a("verified")}),t(D,{children:a("created")}),t(D,{"aria-label":a("Actions")})]})}),t(Te,{children:h.map(o=>i(O,{"data-testid":`us-row-${o.id}`,children:[t(R,{className:"font-mono text-xs",children:o.id}),t(R,{children:o.email??""}),t(R,{children:o.name??""}),t(R,{children:typeof o.role=="string"&&o.role!==""?t(M,{variant:"secondary",children:o.role}):""}),t(R,{children:o.banned===!0?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"success",children:a("Active")})}),t(R,{children:o.emailVerified===!0?t(M,{variant:"success",children:a("yes")}):t(M,{variant:"outline",children:a("no")})}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(o.createdAt)}),t(R,{children:t(U,{"data-testid":`us-manage-${o.id}`,onClick:()=>{m(o.id)},size:"xs",type:"button",variant:"ghost",children:a("Manage")})})]},o.id))})]})})}),p!==null&&t(mt,{capabilities:x,onChanged:b,onClose:()=>{m(null)},user:p}),k&&t(nt,{onClose:()=>{S(!1)},onCreated:b})]})};export{Et as UsersPanel};
1
+ import{useLunora as ge}from"@lunora/react";import{useState as F,useEffect as Ve}from"react";import{B as M}from"../packem_shared/badge-cAk9Di1Q.js";import{B as U}from"../packem_shared/button-BOPLD1un.js";import{C as Fe,a as Ie}from"../packem_shared/card-BGlQzQY-.js";import{E as Qe}from"../packem_shared/empty-state-B939z6K2.js";import{I as B}from"../packem_shared/input-CY5W3wzv.js";import{T as Re,a as Pe,b as O,c as D,d as Te,e as R}from"../packem_shared/table-BMsuYFhk.js";import{b as Ze}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{c as Ne}from"react/compiler-runtime";import{u as qe,D as We}from"../packem_shared/use-auth-config-DIAyVsa3.js";import{useAutoRefresh as Je}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import Ke from"../packem_shared/useDebounced-DVeQ5-oW.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{i as Se,h as Ae,f as Ee,b as je}from"../packem_shared/internal-7bgd8inO.js";import{C as Xe}from"../packem_shared/checkbox-C5w53W-E.js";import{L as V}from"../packem_shared/label-BOUo-DP0.js";import{M as Ye}from"../packem_shared/modal-shell-wGW4CKEW.js";import{u as _e}from"../packem_shared/use-async-submit-C9xXjXWX.js";import{jsxs as i,jsx as t,Fragment as et}from"react/jsx-runtime";We.capabilities;const tt=()=>{const u=Ne(3),{config:e,ready:a}=qe();let l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),at=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){const l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},nt=u=>{const e=Ne(105),{onClose:a,onCreated:l}=u,c=ge(),s=ke(),{config:d}=qe(),{busy:n,error:r,run:m}=_e(),[k,S]=F(""),[x,w]=F(""),[y,A]=F(""),[h,g]=F("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[p,o]=F(b);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=f=>{S(f.target.value)},e[1]=C):C=e[1];const v=C;let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=f=>{w(f.target.value)},e[2]=I):I=e[2];const $=I;let T;e[3]===Symbol.for("react.memo_cache_sentinel")?(T=f=>{A(f.target.value)},e[3]=T):T=e[3];const ze=T;let q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q=f=>{g(f.target.value)},e[4]=q):q=e[4];const Be=q;let Y;e[5]===Symbol.for("react.memo_cache_sentinel")?(Y=(f,P)=>{o(H=>({...H,[f]:P}))},e[5]=Y):Y=e[5];const Ue=Y;let G;e[6]!==p?(G=f=>p[f.name]??(f.type==="boolean"?!1:""),e[6]=p,e[7]=G):G=e[7];const E=G;let Q;if(e[8]!==d.userFields||e[9]!==E){let f;e[11]!==E?(f=P=>!P.required||lt(P,E(P)),e[11]=E,e[12]=f):f=e[12],Q=d.userFields.every(f),e[8]=d.userFields,e[9]=E,e[10]=Q}else Q=e[10];const we=Q;let Z;e[13]!==n||e[14]!==k||e[15]!==x||e[16]!==we?(Z=!n&&k.trim()!==""&&x.trim()!==""&&we,e[13]=n,e[14]=k,e[15]=x,e[16]=we,e[17]=Z):Z=e[17];const $e=Z;let W;e[18]!==d.userFields||e[19]!==E?(W=()=>{const f={};for(const P of d.userFields){const H=at(P,E(P));H!==void 0&&(f[P.name]=H.value)}return Object.keys(f).length===0?void 0:f},e[18]=d.userFields,e[19]=E,e[20]=W):W=e[20];const Ce=W;let J;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(J=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),a()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=J):J=e[30];const N=J;let z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let j;e[35]!==L?(j=t("h2",{className:"text-sm font-semibold text-foreground",children:L}),e[35]=L,e[36]=j):j=e[36];let K;e[37]!==s?(K=s("email"),e[37]=s,e[38]=K):K=e[38];let X;e[39]!==K?(X=t(V,{htmlFor:"uc-email",children:K}),e[39]=K,e[40]=X):X=e[40];let _;e[41]!==k?(_=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:v,type:"email",value:k}),e[41]=k,e[42]=_):_=e[42];let ee;e[43]!==X||e[44]!==_?(ee=i("div",{className:"flex flex-col gap-1",children:[X,_]}),e[43]=X,e[44]=_,e[45]=ee):ee=e[45];let te;e[46]!==s?(te=s("name"),e[46]=s,e[47]=te):te=e[47];let se;e[48]!==te?(se=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=se):se=e[49];let le;e[50]!==x?(le=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:x}),e[50]=x,e[51]=le):le=e[51];let ae;e[52]!==se||e[53]!==le?(ae=i("div",{className:"flex flex-col gap-1",children:[se,le]}),e[52]=se,e[53]=le,e[54]=ae):ae=e[54];let ne;e[55]!==s?(ne=s("Password (optional)"),e[55]=s,e[56]=ne):ne=e[56];let re;e[57]!==ne?(re=t(V,{htmlFor:"uc-password",children:ne}),e[57]=ne,e[58]=re):re=e[58];let ie;e[59]!==y?(ie=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:ze,type:"password",value:y}),e[59]=y,e[60]=ie):ie=e[60];let oe;e[61]!==re||e[62]!==ie?(oe=i("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[61]=re,e[62]=ie,e[63]=oe):oe=e[63];let de;e[64]!==s?(de=s("Role (optional)"),e[64]=s,e[65]=de):de=e[65];let ce;e[66]!==de?(ce=t(V,{htmlFor:"uc-role",children:de}),e[66]=de,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:Be,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=i("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==d.userFields||e[74]!==E||e[75]!==s?(he=d.userFields.length>0&&i("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")}),d.userFields.map(f=>{const P=`uc-field-${f.name}`,H=f.required?"":` (${s("optional")})`;if(f.type==="boolean"){const Me=E(f)===!0;return i("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Xe,{checked:Me,"data-testid":P,id:P,onCheckedChange:Ge=>{Ue(f.name,Ge)}}),i("span",{className:"text-sm",children:[f.name,H]})]},f.name)}const He=E(f);return i("div",{className:"flex flex-col gap-1",children:[i(V,{htmlFor:P,children:[f.name,H]}),t(B,{"data-testid":P,id:P,onChange:Me=>{Ue(f.name,Me.target.value)},type:st[f.type],value:typeof He=="string"?He:""})]},f.name)})]}),e[73]=d.userFields,e[74]=E,e[75]=s,e[76]=he):he=e[76];let fe;e[77]!==r?(fe=r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:r}),e[77]=r,e[78]=fe):fe=e[78];let pe;e[79]!==s?(pe=s("Cancel"),e[79]=s,e[80]=pe):pe=e[80];let be;e[81]!==a||e[82]!==pe?(be=t(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:pe}),e[81]=a,e[82]=pe,e[83]=be):be=e[83];const Le=!$e;let ve;e[84]!==n||e[85]!==s?(ve=s(n?"Creating…":"Create"),e[84]=n,e[85]=s,e[86]=ve):ve=e[86];let xe;e[87]!==N||e[88]!==Le||e[89]!==ve?(xe=t(U,{"data-testid":"uc-submit",disabled:Le,onClick:N,size:"sm",type:"button",children:ve}),e[87]=N,e[88]=Le,e[89]=ve,e[90]=xe):xe=e[90];let ye;e[91]!==be||e[92]!==xe?(ye=i("div",{className:"flex justify-end gap-2 pt-1",children:[be,xe]}),e[91]=be,e[92]=xe,e[93]=ye):ye=e[93];let De;return e[94]!==a||e[95]!==z||e[96]!==j||e[97]!==ee||e[98]!==ae||e[99]!==oe||e[100]!==me||e[101]!==he||e[102]!==fe||e[103]!==ye?(De=i(Ye,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[j,ee,ae,oe,me,he,fe,ye]}),e[94]=a,e[95]=z,e[96]=j,e[97]=ee,e[98]=ae,e[99]=oe,e[100]=me,e[101]=he,e[102]=fe,e[103]=ye,e[104]=De):De=e[104],De},Oe=u=>{const e=Ne(2),{children:a}=u;let l;return e[0]!==a?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[0]=a,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:a,runAction:l,userId:c,version:s}=u,d=ge(),n=ke(),[r,m]=F(null),[k,S]=F(null);let x;e[0]!==d||e[1]!==c?(x=()=>{Ee((async()=>{S(null);try{const v=await d.listAuthSessions({limit:50,userId:c});m(v.rows)}catch(v){const I=v;m(null),S(je(I))}})())},e[0]=d,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==d||e[4]!==c||e[5]!==s?(w=[d,c,s],e[3]=d,e[4]=c,e[5]=s,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==d||e[8]!==l?(y=v=>{l(()=>d.revokeAuthSession({sessionId:v}))},e[7]=d,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==n?(h=n("Sessions"),e[10]=n,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Oe,{children:h}),e[12]=h,e[13]=g):g=e[13];let b;e[14]!==k?(b=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=b):b=e[15];let p;e[16]!==r||e[17]!==n?(p=r!==null&&r.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=r,e[17]=n,e[18]=p):p=e[18];let o;e[19]!==a||e[20]!==A||e[21]!==r||e[22]!==n?(o=r!==null&&r.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:n("expires")}),t(D,{children:n("ip")}),t(D,{children:n("user agent")}),t(D,{"aria-label":n("Actions")})]})}),t(Te,{children:r.map(v=>i(O,{"data-testid":`ud-session-${v.id}`,children:[t(R,{className:"text-muted-foreground tabular-nums",children:Se(v.expiresAt)}),t(R,{children:v.ipAddress??""}),t(R,{className:"max-w-40 truncate",children:v.userAgent??""}),t(R,{children:t(U,{"data-testid":`ud-revoke-${v.id}`,disabled:a,onClick:()=>{A(v.id)},size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},v.id))})]})})}),e[19]=a,e[20]=A,e[21]=r,e[22]=n,e[23]=o):o=e[23];let C;return e[24]!==g||e[25]!==b||e[26]!==p||e[27]!==o?(C=i("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,b,p,o]}),e[24]=g,e[25]=b,e[26]=p,e[27]=o,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:a,runAction:l,userId:c,version:s}=u,d=ge(),n=ke(),[r,m]=F(null),[k,S]=F(null);let x;e[0]!==d||e[1]!==c?(x=()=>{Ee((async()=>{S(null);try{m(await d.listAuthAccounts({userId:c}))}catch(v){const I=v;m(null),S(je(I))}})())},e[0]=d,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==d||e[4]!==c||e[5]!==s?(w=[d,c,s],e[3]=d,e[4]=c,e[5]=s,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==d||e[8]!==l||e[9]!==c?(y=v=>{l(()=>d.unlinkAuthAccount({accountId:v,userId:c}))},e[7]=d,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==n?(h=n("Linked accounts"),e[11]=n,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Oe,{children:h}),e[13]=h,e[14]=g):g=e[14];let b;e[15]!==k?(b=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=b):b=e[16];let p;e[17]!==r||e[18]!==n?(p=r!==null&&r.length===0&&t("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=r,e[18]=n,e[19]=p):p=e[19];let o;e[20]!==r||e[21]!==a||e[22]!==A||e[23]!==n?(o=r!==null&&r.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:n("provider")}),t(D,{children:n("created")}),t(D,{"aria-label":n("Actions")})]})}),t(Te,{children:r.map(v=>{const I=Ae(v.id);return i(O,{"data-testid":`ud-account-${I}`,children:[t(R,{children:Ae(v.providerId)}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(v.createdAt)}),t(R,{children:t(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:()=>{A(I)},size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},I)})})]})})}),e[20]=r,e[21]=a,e[22]=A,e[23]=n,e[24]=o):o=e[24];let C;return e[25]!==g||e[26]!==b||e[27]!==p||e[28]!==o?(C=i("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,b,p,o]}),e[25]=g,e[26]=b,e[27]=p,e[28]=o,e[29]=C):C=e[29],C},ot=u=>{const e=Ne(40),{busy:a,capabilities:l,runAction:c,userId:s,version:d}=u,n=ge(),r=ke(),[m,k]=F(null);let S;e[0]!==l.passkey||e[1]!==n||e[2]!==s?(S=()=>{l.passkey&&Ee((async()=>{try{k(await n.listAuthPasskeys({userId:s}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=n,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==n||e[6]!==s||e[7]!==d?(x=[l.passkey,n,s,d],e[4]=l.passkey,e[5]=n,e[6]=s,e[7]=d,e[8]=x):x=e[8],Ve(S,x);let w;e[9]!==n||e[10]!==c||e[11]!==s?(w=()=>{c(()=>n.disableAuthTwoFactor({userId:s}))},e[9]=n,e[10]=c,e[11]=s,e[12]=w):w=e[12];const y=w;let A;e[13]!==n||e[14]!==c?(A=I=>{c(()=>n.deleteAuthPasskey({passkeyId:I}))},e[13]=n,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==r?(g=r("Security"),e[16]=r,e[17]=g):g=e[17];let b;e[18]!==g?(b=t(Oe,{children:g}),e[18]=g,e[19]=b):b=e[19];let p;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==r?(p=l.twoFactor&&t(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:r("Disable two-factor")}),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=r,e[24]=p):p=e[24];let o;e[25]!==l.passkey||e[26]!==m||e[27]!==r?(o=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=r,e[28]=o):o=e[28];let C;e[29]!==a||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==r?(C=l.passkey&&m!==null&&m.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:r("name")}),t(D,{children:r("created")}),t(D,{"aria-label":r("Actions")})]})}),t(Te,{children:m.map(I=>{const $=Ae(I.id);return i(O,{"data-testid":`ud-passkey-${$}`,children:[t(R,{children:Ae(I.name)||$}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(I.createdAt)}),t(R,{children:t(U,{"data-testid":`ud-delete-passkey-${$}`,disabled:a,onClick:()=>{h($)},size:"xs",type:"button",variant:"ghost",children:r("Delete")})})]},$)})})]})})}),e[29]=a,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=r,e[34]=C):C=e[34];let v;return e[35]!==b||e[36]!==p||e[37]!==o||e[38]!==C?(v=i("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,p,o,C]}),e[35]=b,e[36]=p,e[37]=o,e[38]=C,e[39]=v):v=e[39],v},dt=/(?:at|expires)$/iu,ct=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ut=(u,e)=>typeof e=="number"&&dt.test(u)?Se(e):Ae(e),mt=({capabilities:u,onChanged:e,onClose:a,user:l})=>{const c=ge(),s=ke(),d=l.banned===!0,[n,r]=F(null),[m,k]=F(!1),[S,x]=F(0),[w,y]=F(typeof l.role=="string"?l.role:""),[A,h]=F(""),[g,b]=F(""),[p,o]=F(""),[C,v]=F(null),[I,$]=F(!1),T=(N,z)=>{Ee((async()=>{k(!0),r(null);try{const L=await N();z?.refresh!==!1&&(x(j=>j+1),e()),z?.onResult?.(L)}catch(L){r(je(L))}k(!1)})())},ze=N=>{y(N.target.value)},q=N=>{h(N.target.value)},Be=N=>{b(N.target.value)},Y=N=>{o(N.target.value)},Ue=()=>{const N=w.trim();N!==""&&T(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},G=()=>{const N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;T(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},E=()=>{T(async()=>{await c.unbanAuthUser({userId:l.id})})},Q=()=>{T(async()=>{await c.setAuthUserPassword({newPassword:p,userId:l.id}),o("")})},we=()=>{T(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{v(N.token)},refresh:!1})},Z=()=>{T(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},$e=()=>{T(async()=>{await c.removeAuthUser({userId:l.id}),a()})},W=()=>{$(!0)},Ce=()=>{$(!1)},J=Object.entries(l).filter(([N])=>!ct.has(N));return i(Ye,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[i("div",{className:"flex items-start justify-between gap-2",children:[i("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),i("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),d?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"outline",children:s("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:s("verified")}):t(M,{variant:"outline",children:s("unverified")})]})]}),t(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),n!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),u.admin&&i(Fe,{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")})}),i(Ie,{className:"flex flex-col gap-3 p-3",children:[i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:ze,value:w})]}),t(U,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Ue,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),d?t(U,{"data-testid":"ud-unban",disabled:m,onClick:E,size:"sm",type:"button",variant:"outline",children:s("Unban")}):i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")}),t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:q,value:A})]}),i("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:s("Days")}),t(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Be,type:"number",value:g})]}),t(U,{"data-testid":"ud-ban",disabled:m,onClick:G,size:"sm",type:"button",variant:"destructive",children:s("Ban user")})]}),i("div",{className:"flex items-end gap-2",children:[i("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:Y,type:"password",value:p})]}),t(U,{"data-testid":"ud-set-password",disabled:m||p==="",onClick:Q,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),i("div",{className:"flex flex-wrap gap-2",children:[t(U,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(U,{"data-testid":"ud-revoke-all",disabled:m,onClick:Z,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),I?i(et,{children:[t(U,{"data-testid":"ud-delete-confirm",disabled:m,onClick:$e,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(U,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(U,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),C!==null&&i("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:T,userId:l.id,version:S}),u.accounts&&t(it,{busy:m,runAction:T,userId:l.id,version:S}),(u.twoFactor||u.passkey)&&t(ot,{busy:m,capabilities:u,runAction:T,userId:l.id,version:S}),i("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:J.map(([N,z])=>i("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ut(N,z)})]},N))})]})]})},ht=50,Et=({pageSize:u=ht}={})=>{const e=ge(),a=ke(),[l,c]=F(""),[s,d]=F(""),n=Ke(l),[r,m]=F(null),[k,S]=F(!1),{capabilities:x}=tt(),w=n.trim(),y=s.trim(),A=Ze(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,b=()=>{A.refetch()};Je(()=>{A.refetch()},!0);const p=r===null?null:h?.find(o=>o.id===r)??null;return i("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[i("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:o=>{c(o.target.value)},placeholder:a("Search by email or name…"),value:l}),t(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:o=>{d(o.target.value)},placeholder:a("Filter by role"),value:s}),t(U,{"data-testid":"us-new",onClick:()=>{S(!0)},size:"sm",type:"button",children:a("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Qe,{description:a("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:a("No users.")}),h!==null&&h.length>0&&t(Fe,{className:"overflow-hidden py-0",children:t(Ie,{className:"px-0",children:i(Re,{"data-testid":"us-table",children:[t(Pe,{children:i(O,{children:[t(D,{children:a("id")}),t(D,{children:a("email")}),t(D,{children:a("name")}),t(D,{children:a("role")}),t(D,{children:a("status")}),t(D,{children:a("verified")}),t(D,{children:a("created")}),t(D,{"aria-label":a("Actions")})]})}),t(Te,{children:h.map(o=>i(O,{"data-testid":`us-row-${o.id}`,children:[t(R,{className:"font-mono text-xs",children:o.id}),t(R,{children:o.email??""}),t(R,{children:o.name??""}),t(R,{children:typeof o.role=="string"&&o.role!==""?t(M,{variant:"secondary",children:o.role}):""}),t(R,{children:o.banned===!0?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"success",children:a("Active")})}),t(R,{children:o.emailVerified===!0?t(M,{variant:"success",children:a("yes")}):t(M,{variant:"outline",children:a("no")})}),t(R,{className:"text-muted-foreground tabular-nums",children:Se(o.createdAt)}),t(R,{children:t(U,{"data-testid":`us-manage-${o.id}`,onClick:()=>{m(o.id)},size:"xs",type:"button",variant:"ghost",children:a("Manage")})})]},o.id))})]})})}),p!==null&&t(mt,{capabilities:x,onChanged:b,onClose:()=>{m(null)},user:p}),k&&t(nt,{onClose:()=>{S(!1)},onCreated:b})]})};export{Et as UsersPanel};
@@ -1 +1 @@
1
- import{c as H}from"react/compiler-runtime";import{useLunora as K}from"@lunora/react";import{useState as h,useEffect as z}from"react";import{B as O}from"../packem_shared/button-BOPLD1un.js";import{C as E,a as q}from"../packem_shared/card-BGlQzQY-.js";import{E as P}from"../packem_shared/empty-state-B939z6K2.js";import{I as R}from"../packem_shared/input-CY5W3wzv.js";import{T as B,a as j,b,c as d,d as L,e as i}from"../packem_shared/table-BMsuYFhk.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{f as M,b as V,h as W}from"../packem_shared/internal-CwaF9YNk.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const Z=10,g=x=>{const a=H(7),{label:m,value:r}=x;let l;a[0]!==m?(l=e("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),a[0]=m,a[1]=l):l=a[1];const f=r??"—";let s;a[2]!==f?(s=e("span",{className:"font-mono text-sm",children:f}),a[2]=f,a[3]=s):s=a[3];let u;return a[4]!==l||a[5]!==s?(u=n("div",{className:"flex flex-col gap-0.5",children:[l,s]}),a[4]=l,a[5]=s,a[6]=u):u=a[6],u},se=({loadIndexes:x,runQuery:a}={})=>{const m=K(),r=U(),[l,f]=h(null),[s,u]=h(null),[v,C]=h(null),[N,F]=h(""),[p,y]=h(null),[S,w]=h(null),[k,I]=h(!1);z(()=>{const t={cancelled:!1};return M((async()=>{try{const o=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(f(o),u(null),C(T=>T??o[0]?.name??null))}catch(o){t.cancelled||(f(null),u(V(o)))}})()),()=>{t.cancelled=!0}},[m,x]);const c=l?.find(t=>t.name===v)??null,Q=t=>{C(t.currentTarget.dataset.index??null),y(null),w(null)},$=t=>{F(t.target.value)},A=async()=>{const t=N.trim();if(!(v===null||t==="")){I(!0),w(null);try{const o=await(a??(T=>m.queryVectorIndex(T)))({name:v,text:t,topK:Z});y(o)}catch(o){y(null),w(V(o))}I(!1)}},D=()=>{M(A())};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&e("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),l!==null&&l.length===0&&e(P,{description:r("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:r("No vector indexes.")}),l!==null&&l.length>0&&e(E,{className:"overflow-hidden py-0",children:e(q,{className:"px-0",children:n(B,{"data-testid":"vector-table",children:[e(j,{children:n(b,{children:[e(d,{children:r("name")}),e(d,{children:r("table")}),e(d,{children:r("dimensions")}),e(d,{children:r("metric")}),e(d,{children:r("vectors")})]})}),e(L,{children:l.map(t=>n(b,{className:t.name===v?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:Q,children:[e(i,{className:"font-mono text-xs",children:t.name}),e(i,{className:"font-mono text-xs",children:t.table}),e(i,{className:"tabular-nums",children:t.dimensions??"—"}),e(i,{children:t.metric??"—"}),e(i,{className:"tabular-nums",children:t.vectorsCount??"—"})]},t.name))})]})})}),c!==null&&n("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[n("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e(g,{label:r("field"),value:c.field}),e(g,{label:r("dimensions"),value:c.dimensions}),e(g,{label:r("metric"),value:c.metric}),e(g,{label:r("vectors"),value:c.vectorsCount})]}),c.metadata!==void 0&&c.metadata.length>0&&n("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[r("metadata"),": ",e("span",{className:"font-mono",children:c.metadata.join(", ")})]}),n("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e(R,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:$,placeholder:r("Search by similarity…"),value:N}),e(O,{"data-testid":"vector-search",disabled:k||N.trim()==="",onClick:D,children:r(k?"Searching…":"Search")})]}),S!==null&&e("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:S}),p!==null&&p.length===0&&e("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:r("No matches.")}),p!==null&&p.length>0&&e(E,{className:"mt-3 overflow-hidden py-0",children:e(q,{className:"px-0",children:n(B,{"data-testid":"vector-matches",children:[e(j,{children:n(b,{children:[e(d,{children:r("id")}),e(d,{children:r("score")}),e(d,{children:r("metadata")})]})}),e(L,{children:p.map(t=>n(b,{"data-testid":`vector-match-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.id}),e(i,{className:"tabular-nums",children:t.score.toFixed(4)}),e(i,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"—":W(t.metadata)})]},t.id))})]})})})]})]})};export{se as VectorBrowser};
1
+ import{c as H}from"react/compiler-runtime";import{useLunora as K}from"@lunora/react";import{useState as h,useEffect as z}from"react";import{B as O}from"../packem_shared/button-BOPLD1un.js";import{C as E,a as q}from"../packem_shared/card-BGlQzQY-.js";import{E as P}from"../packem_shared/empty-state-B939z6K2.js";import{I as R}from"../packem_shared/input-CY5W3wzv.js";import{T as B,a as j,b,c as d,d as L,e as i}from"../packem_shared/table-BMsuYFhk.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{f as M,b as V,h as W}from"../packem_shared/internal-7bgd8inO.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const Z=10,g=x=>{const a=H(7),{label:m,value:r}=x;let l;a[0]!==m?(l=e("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),a[0]=m,a[1]=l):l=a[1];const f=r??"—";let s;a[2]!==f?(s=e("span",{className:"font-mono text-sm",children:f}),a[2]=f,a[3]=s):s=a[3];let u;return a[4]!==l||a[5]!==s?(u=n("div",{className:"flex flex-col gap-0.5",children:[l,s]}),a[4]=l,a[5]=s,a[6]=u):u=a[6],u},se=({loadIndexes:x,runQuery:a}={})=>{const m=K(),r=U(),[l,f]=h(null),[s,u]=h(null),[v,C]=h(null),[N,F]=h(""),[p,y]=h(null),[S,w]=h(null),[k,I]=h(!1);z(()=>{const t={cancelled:!1};return M((async()=>{try{const o=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(f(o),u(null),C(T=>T??o[0]?.name??null))}catch(o){t.cancelled||(f(null),u(V(o)))}})()),()=>{t.cancelled=!0}},[m,x]);const c=l?.find(t=>t.name===v)??null,Q=t=>{C(t.currentTarget.dataset.index??null),y(null),w(null)},$=t=>{F(t.target.value)},A=async()=>{const t=N.trim();if(!(v===null||t==="")){I(!0),w(null);try{const o=await(a??(T=>m.queryVectorIndex(T)))({name:v,text:t,topK:Z});y(o)}catch(o){y(null),w(V(o))}I(!1)}},D=()=>{M(A())};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&e("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),l!==null&&l.length===0&&e(P,{description:r("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:r("No vector indexes.")}),l!==null&&l.length>0&&e(E,{className:"overflow-hidden py-0",children:e(q,{className:"px-0",children:n(B,{"data-testid":"vector-table",children:[e(j,{children:n(b,{children:[e(d,{children:r("name")}),e(d,{children:r("table")}),e(d,{children:r("dimensions")}),e(d,{children:r("metric")}),e(d,{children:r("vectors")})]})}),e(L,{children:l.map(t=>n(b,{className:t.name===v?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:Q,children:[e(i,{className:"font-mono text-xs",children:t.name}),e(i,{className:"font-mono text-xs",children:t.table}),e(i,{className:"tabular-nums",children:t.dimensions??"—"}),e(i,{children:t.metric??"—"}),e(i,{className:"tabular-nums",children:t.vectorsCount??"—"})]},t.name))})]})})}),c!==null&&n("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[n("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e(g,{label:r("field"),value:c.field}),e(g,{label:r("dimensions"),value:c.dimensions}),e(g,{label:r("metric"),value:c.metric}),e(g,{label:r("vectors"),value:c.vectorsCount})]}),c.metadata!==void 0&&c.metadata.length>0&&n("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[r("metadata"),": ",e("span",{className:"font-mono",children:c.metadata.join(", ")})]}),n("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e(R,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:$,placeholder:r("Search by similarity…"),value:N}),e(O,{"data-testid":"vector-search",disabled:k||N.trim()==="",onClick:D,children:r(k?"Searching…":"Search")})]}),S!==null&&e("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:S}),p!==null&&p.length===0&&e("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:r("No matches.")}),p!==null&&p.length>0&&e(E,{className:"mt-3 overflow-hidden py-0",children:e(q,{className:"px-0",children:n(B,{"data-testid":"vector-matches",children:[e(j,{children:n(b,{children:[e(d,{children:r("id")}),e(d,{children:r("score")}),e(d,{children:r("metadata")})]})}),e(L,{children:p.map(t=>n(b,{"data-testid":`vector-match-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.id}),e(i,{className:"tabular-nums",children:t.score.toFixed(4)}),e(i,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"—":W(t.metadata)})]},t.id))})]})})})]})]})};export{se as VectorBrowser};
@@ -1 +1 @@
1
- import{useLunora as X}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{B as E}from"../packem_shared/button-BOPLD1un.js";import{C as P,a as U}from"../packem_shared/card-BGlQzQY-.js";import{E as H}from"../packem_shared/empty-state-B939z6K2.js";import{I as re}from"../packem_shared/input-CY5W3wzv.js";import{T as j,a as z,b as x,c as i,d as J,e as d}from"../packem_shared/table-BMsuYFhk.js";import{T as se}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as ae}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as W,b as A,d as V,c as Z}from"../packem_shared/internal-CwaF9YNk.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const ne=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const s=o.error??o.output;if(s===void 0)return"—";try{return JSON.stringify(s)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:s,readOnly:N,runAction:R,workflowName:w})=>{const O=X(),a=Y(),[h,g]=m(null),[k,I]=m(null),[v,_]=m(""),[b,f]=m(null),[$,S]=m(!1),[F,D]=m(null),p=o??(r=>O.getWorkflowInstance(r)),C=N?void 0:R??(s===void 0?r=>O.setWorkflowInstanceStatus(r):void 0),L=async()=>{f(null),S(!1);const r=v===""?void 0:v;try{if(s===void 0){const l=await O.listWorkflowInstances({name:w,status:r});if(l.configured===!1){g(null),S(!0);return}g(l.instances);return}g(await s({name:w,status:r}))}catch(l){g(null),ie(l)?S(!0):f(A(l))}};te(()=>{I(null),W(L())},[w,v]);const K=async r=>{f(null);try{I(await p({id:r,name:w}))}catch(l){f(A(l))}},q=async(r,l)=>{if(C!==void 0){D(r),f(null);try{await C({action:l,id:r,name:w}),await L()}catch(G){f(A(G))}D(null)}};return n("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[n("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:a("Instance history")}),n("select",{"aria-label":a("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:r=>{_(r.target.value)},value:v,children:[e("option",{value:"",children:a("All statuses")}),ne.map(r=>e("option",{value:r,children:r},r))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),$&&e(H,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!$&&h!==null&&h.length===0&&e(H,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),h!==null&&h.length>0&&e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflow-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:a("Instance id")}),e(i,{children:a("Status")}),e(i,{children:a("Created")}),e(i,{children:a("Ended")}),e(i,{"aria-label":a("Actions")})]})}),e(J,{children:h.map(r=>n(x,{"data-testid":`workflow-instance-${r.id}`,children:[e(d,{className:"font-mono text-xs",children:r.id}),e(d,{className:"font-mono text-xs",children:r.status}),e(d,{className:"text-muted-foreground tabular-nums",children:r.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.endedOn??"—"}),e(d,{className:"text-right",children:n("div",{className:"flex justify-end gap-1.5",children:[e(E,{"data-testid":`workflow-instance-steps-${r.id}`,onClick:()=>{W(K(r.id))},size:"sm",type:"button",variant:"outline",children:a("Steps")}),C!==void 0&&oe.map(l=>e(E,{"data-testid":`workflow-instance-${l}-${r.id}`,disabled:F===r.id,onClick:()=>{W(q(r.id,l))},size:"sm",type:"button",variant:"ghost",children:a(l)},l))]})})]},r.id))})]})})}),k!==null&&e(P,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:n(U,{className:"flex flex-col gap-2 px-4 py-3",children:[n("div",{className:"flex items-center justify-between",children:[n("span",{className:"font-mono text-xs",children:[a("Steps")," · ",k.id]}),e(E,{"data-testid":"workflow-instance-detail-close",onClick:()=>{I(null)},size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),k.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):n(j,{"data-testid":"workflow-instance-steps",children:[e(z,{children:n(x,{children:[e(i,{children:a("Step")}),e(i,{children:a("Type")}),e(i,{children:a("Attempts")}),e(i,{children:a("Started")}),e(i,{children:a("Output")})]})}),e(J,{children:k.steps.map((r,l)=>n(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:r.name}),e(d,{className:"text-xs text-muted-foreground",children:r.type??"—"}),e(d,{className:"tabular-nums",children:r.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(r)})]},`${r.name}:${String(l)}`))})]})]})})]})},me=Z(M.createWorkflowInstance),ue=Z(M.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,s)=>o.some(N=>N.exportName===s)?s:o[0]?.exportName??"",Te=()=>{const o=X(),s=Y(),{data:N,error:R}=ae(M.listWorkflows,{}),[w,O]=m(""),[a,h]=m(""),[g,k]=m(""),[I,v]=m(!1),[_,b]=m(null),[f,$]=m([]),[S,F]=m(null),D=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],T=he(p,w),B=p.find(t=>t.exportName===T),C=t=>{$(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},L=async()=>{const t=T;if(t==="")return;let u;const c=g.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(s("Params must be valid JSON"));return}v(!0),b(null);try{const y=a.trim(),Q=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},V(""));C({exportName:t,id:Q.id,status:Q.status}),h("")}catch(y){b(A(y))}v(!1)},K=()=>{W(L())},q=async(t,u)=>{F(u);try{const c=await o.query(ue,{exportName:t,id:u},V(""));C({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(A(c))}F(null)},r=t=>{O(t.target.value)},l=t=>{h(t.target.value)},G=t=>{k(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&W(q(u,c))};return n("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),e("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),D&&p.length===0?e(H,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")}):e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflows-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Export")}),e(i,{children:s("Name")}),e(i,{children:s("Class")}),e(i,{children:s("Binding")})]})}),e(J,{children:p.map(t=>n(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:s("Start instance")}),_!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),n("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":s("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:r,value:T,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(re,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:l,placeholder:s("Instance id (optional)"),value:a}),e(E,{"data-testid":"workflows-start-button",disabled:I||T==="",onClick:K,children:s(I?"Starting…":"Start instance")})]}),e(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:G,placeholder:s("Params (JSON, optional)"),value:g})]}),f.length>0&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:s("Instances")}),e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflows-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Workflow")}),e(i,{children:s("Instance id")}),e(i,{children:s("Status")}),e(i,{children:s("Output")}),e(i,{})]})}),e(J,{children:f.map(t=>n(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(E,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:ee,size:"xs",variant:"outline",children:S===t.id?s("Refreshing…"):s("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),B!==void 0&&e(ce,{workflowName:B.name})]})};export{Te as default};
1
+ import{useLunora as X}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{B as E}from"../packem_shared/button-BOPLD1un.js";import{C as P,a as U}from"../packem_shared/card-BGlQzQY-.js";import{E as H}from"../packem_shared/empty-state-B939z6K2.js";import{I as re}from"../packem_shared/input-CY5W3wzv.js";import{T as j,a as z,b as x,c as i,d as J,e as d}from"../packem_shared/table-BMsuYFhk.js";import{T as se}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as ae}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as W,b as A,d as V,c as Z}from"../packem_shared/internal-7bgd8inO.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const ne=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const s=o.error??o.output;if(s===void 0)return"—";try{return JSON.stringify(s)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:s,readOnly:N,runAction:R,workflowName:w})=>{const O=X(),a=Y(),[h,g]=m(null),[k,I]=m(null),[v,_]=m(""),[b,f]=m(null),[$,S]=m(!1),[F,D]=m(null),p=o??(r=>O.getWorkflowInstance(r)),C=N?void 0:R??(s===void 0?r=>O.setWorkflowInstanceStatus(r):void 0),L=async()=>{f(null),S(!1);const r=v===""?void 0:v;try{if(s===void 0){const l=await O.listWorkflowInstances({name:w,status:r});if(l.configured===!1){g(null),S(!0);return}g(l.instances);return}g(await s({name:w,status:r}))}catch(l){g(null),ie(l)?S(!0):f(A(l))}};te(()=>{I(null),W(L())},[w,v]);const K=async r=>{f(null);try{I(await p({id:r,name:w}))}catch(l){f(A(l))}},q=async(r,l)=>{if(C!==void 0){D(r),f(null);try{await C({action:l,id:r,name:w}),await L()}catch(G){f(A(G))}D(null)}};return n("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[n("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:a("Instance history")}),n("select",{"aria-label":a("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:r=>{_(r.target.value)},value:v,children:[e("option",{value:"",children:a("All statuses")}),ne.map(r=>e("option",{value:r,children:r},r))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),$&&e(H,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!$&&h!==null&&h.length===0&&e(H,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),h!==null&&h.length>0&&e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflow-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:a("Instance id")}),e(i,{children:a("Status")}),e(i,{children:a("Created")}),e(i,{children:a("Ended")}),e(i,{"aria-label":a("Actions")})]})}),e(J,{children:h.map(r=>n(x,{"data-testid":`workflow-instance-${r.id}`,children:[e(d,{className:"font-mono text-xs",children:r.id}),e(d,{className:"font-mono text-xs",children:r.status}),e(d,{className:"text-muted-foreground tabular-nums",children:r.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.endedOn??"—"}),e(d,{className:"text-right",children:n("div",{className:"flex justify-end gap-1.5",children:[e(E,{"data-testid":`workflow-instance-steps-${r.id}`,onClick:()=>{W(K(r.id))},size:"sm",type:"button",variant:"outline",children:a("Steps")}),C!==void 0&&oe.map(l=>e(E,{"data-testid":`workflow-instance-${l}-${r.id}`,disabled:F===r.id,onClick:()=>{W(q(r.id,l))},size:"sm",type:"button",variant:"ghost",children:a(l)},l))]})})]},r.id))})]})})}),k!==null&&e(P,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:n(U,{className:"flex flex-col gap-2 px-4 py-3",children:[n("div",{className:"flex items-center justify-between",children:[n("span",{className:"font-mono text-xs",children:[a("Steps")," · ",k.id]}),e(E,{"data-testid":"workflow-instance-detail-close",onClick:()=>{I(null)},size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),k.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):n(j,{"data-testid":"workflow-instance-steps",children:[e(z,{children:n(x,{children:[e(i,{children:a("Step")}),e(i,{children:a("Type")}),e(i,{children:a("Attempts")}),e(i,{children:a("Started")}),e(i,{children:a("Output")})]})}),e(J,{children:k.steps.map((r,l)=>n(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:r.name}),e(d,{className:"text-xs text-muted-foreground",children:r.type??"—"}),e(d,{className:"tabular-nums",children:r.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(r)})]},`${r.name}:${String(l)}`))})]})]})})]})},me=Z(M.createWorkflowInstance),ue=Z(M.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,s)=>o.some(N=>N.exportName===s)?s:o[0]?.exportName??"",Te=()=>{const o=X(),s=Y(),{data:N,error:R}=ae(M.listWorkflows,{}),[w,O]=m(""),[a,h]=m(""),[g,k]=m(""),[I,v]=m(!1),[_,b]=m(null),[f,$]=m([]),[S,F]=m(null),D=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],T=he(p,w),B=p.find(t=>t.exportName===T),C=t=>{$(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},L=async()=>{const t=T;if(t==="")return;let u;const c=g.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(s("Params must be valid JSON"));return}v(!0),b(null);try{const y=a.trim(),Q=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},V(""));C({exportName:t,id:Q.id,status:Q.status}),h("")}catch(y){b(A(y))}v(!1)},K=()=>{W(L())},q=async(t,u)=>{F(u);try{const c=await o.query(ue,{exportName:t,id:u},V(""));C({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(A(c))}F(null)},r=t=>{O(t.target.value)},l=t=>{h(t.target.value)},G=t=>{k(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&W(q(u,c))};return n("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),e("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),D&&p.length===0?e(H,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")}):e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflows-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Export")}),e(i,{children:s("Name")}),e(i,{children:s("Class")}),e(i,{children:s("Binding")})]})}),e(J,{children:p.map(t=>n(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:s("Start instance")}),_!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),n("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":s("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:r,value:T,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(re,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:l,placeholder:s("Instance id (optional)"),value:a}),e(E,{"data-testid":"workflows-start-button",disabled:I||T==="",onClick:K,children:s(I?"Starting…":"Start instance")})]}),e(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:G,placeholder:s("Params (JSON, optional)"),value:g})]}),f.length>0&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:s("Instances")}),e(P,{className:"overflow-hidden py-0",children:e(U,{className:"px-0",children:n(j,{"data-testid":"workflows-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Workflow")}),e(i,{children:s("Instance id")}),e(i,{children:s("Status")}),e(i,{children:s("Output")}),e(i,{})]})}),e(J,{children:f.map(t=>n(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(E,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:ee,size:"xs",variant:"outline",children:S===t.id?s("Refreshing…"):s("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),B!==void 0&&e(ce,{workflowName:B.name})]})};export{Te as default};