@lunora/studio 1.0.0-alpha.370 → 1.0.0-alpha.372

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 (170) hide show
  1. package/dist/index.d.mts +6 -3
  2. package/dist/index.d.ts +6 -3
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.d.mts +1 -1
  5. package/dist/mount.d.ts +1 -1
  6. package/dist/mount.mjs +1 -1
  7. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  8. package/dist/packem_chunks/ApiTab.mjs +1 -1
  9. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  10. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  11. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  12. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  13. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  14. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  15. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  16. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  17. package/dist/packem_chunks/MailPanel.mjs +1 -1
  18. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  19. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  20. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  21. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  22. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  23. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  24. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  25. package/dist/packem_chunks/TableEditor.mjs +1 -1
  26. package/dist/packem_chunks/agents-panel.mjs +1 -1
  27. package/dist/packem_chunks/ai-knowledge.mjs +1 -1
  28. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  29. package/dist/packem_chunks/assistant-panel.mjs +1 -1
  30. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  31. package/dist/packem_chunks/containers-panel.mjs +1 -1
  32. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  33. package/dist/packem_chunks/evals-panel.mjs +1 -1
  34. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  35. package/dist/packem_chunks/flags-panel.mjs +1 -1
  36. package/dist/packem_chunks/issues-panel.mjs +1 -1
  37. package/dist/packem_chunks/kv-browser.mjs +1 -1
  38. package/dist/packem_chunks/migrations-route.mjs +1 -1
  39. package/dist/packem_chunks/payments-panel.mjs +1 -1
  40. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  41. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  42. package/dist/packem_chunks/queues-panel.mjs +1 -1
  43. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  44. package/dist/packem_chunks/rls-panel.mjs +1 -1
  45. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  46. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  47. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  48. package/dist/packem_chunks/traces-panel.mjs +1 -1
  49. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  50. package/dist/packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs +1 -0
  51. package/dist/packem_shared/{ApiDocsPanel-B9S9l1Ce.mjs → ApiDocsPanel-xqgxgYCy.mjs} +1 -1
  52. package/dist/packem_shared/{DataBrowser-Dm-jhIUP.mjs → DataBrowser-BrRWqnCr.mjs} +1 -1
  53. package/dist/packem_shared/{GlobalDataBrowser-C1Y8GUhe.mjs → GlobalDataBrowser-D8ZheGwm.mjs} +1 -1
  54. package/dist/packem_shared/{HomePanel-B5ytwPIo.mjs → HomePanel-CHq9VBrh.mjs} +1 -1
  55. package/dist/packem_shared/{MigrationsPanel-CwLikxDT.mjs → MigrationsPanel-BWGgOwmX.mjs} +1 -1
  56. package/dist/packem_shared/{Studio-wrwGcG7J.mjs → Studio-pDEG4JTx.mjs} +1 -1
  57. package/dist/packem_shared/{StudioApp-D1XLXXe_.mjs → StudioApp-C4IOJPR6.mjs} +1 -1
  58. package/dist/packem_shared/{advisor-view-CzieqKMe.mjs → advisor-view-Dj-mZPAq.mjs} +1 -1
  59. package/dist/packem_shared/{app.d-jC98McBG.d.mts → app.d-BXrVLb99.d.mts} +2 -0
  60. package/dist/packem_shared/{app.d-jC98McBG.d.ts → app.d-BXrVLb99.d.ts} +2 -0
  61. package/dist/packem_shared/{assistant-provider-Bp72uWsq.mjs → assistant-provider-BQG7QZAu.mjs} +1 -1
  62. package/dist/packem_shared/{error-alert-DKXm5h19.mjs → error-alert-BzZfqmf4.mjs} +1 -1
  63. package/dist/packem_shared/{home-panel-5fGktYeD.mjs → home-panel-DTWHlX5S.mjs} +1 -1
  64. package/dist/packem_shared/{studio-Cm9ea8j7.mjs → studio-DE7i2--m.mjs} +1 -1
  65. package/dist/packem_shared/{table-list-sidebar-kpHaDWjy.mjs → table-list-sidebar-DUnCjFL7.mjs} +1 -1
  66. package/dist/packem_shared/{use-assistant-rpc-GCUK2zPa.mjs → use-assistant-rpc-DCC6ph2u.mjs} +1 -1
  67. package/dist/standalone/{chunk-ZYZ5ATT2.js → chunk-2ENIONNZ.js} +1 -1
  68. package/dist/standalone/{chunk-VGIDGJ5K.js → chunk-2USDHESR.js} +1 -1
  69. package/dist/standalone/{chunk-J77YDVBD.js → chunk-2Z4FB527.js} +1 -1
  70. package/dist/standalone/{chunk-IDNHNCZV.js → chunk-3DBV6QGB.js} +1 -1
  71. package/dist/standalone/{chunk-TDPAITW5.js → chunk-3H2ATHKG.js} +1 -1
  72. package/dist/standalone/{chunk-HLWDT5VZ.js → chunk-3LPWFZNJ.js} +1 -1
  73. package/dist/standalone/{chunk-AA3R3QNN.js → chunk-3SD5I425.js} +1 -1
  74. package/dist/standalone/{chunk-H6KIDQ6V.js → chunk-4E35ZI3H.js} +1 -1
  75. package/dist/standalone/{chunk-UCJWHNUJ.js → chunk-4KCL4VXL.js} +1 -1
  76. package/dist/standalone/{chunk-VB2XDTVB.js → chunk-4R3EKQ2A.js} +1 -1
  77. package/dist/standalone/{chunk-OCYIIOBX.js → chunk-4R3JFKEL.js} +1 -1
  78. package/dist/standalone/{chunk-6XL3EV2X.js → chunk-5YL3SK5T.js} +1 -1
  79. package/dist/standalone/chunk-6A6AELDJ.js +1 -0
  80. package/dist/standalone/{chunk-O6W2YLME.js → chunk-6ALZ2WSG.js} +1 -1
  81. package/dist/standalone/{chunk-NSAQ3EDS.js → chunk-6TPZKFPG.js} +1 -1
  82. package/dist/standalone/{chunk-GM7MBMYI.js → chunk-7K3VSMEZ.js} +1 -1
  83. package/dist/standalone/{chunk-VJC5PQ7D.js → chunk-7LMMVPE3.js} +1 -1
  84. package/dist/standalone/chunk-A4AUTJPE.js +7 -0
  85. package/dist/standalone/{chunk-36RORAX3.js → chunk-AJIXOUOQ.js} +1 -1
  86. package/dist/standalone/{chunk-ZM3A5WO5.js → chunk-AR5HF7G5.js} +1 -1
  87. package/dist/standalone/{chunk-MQBQBEGM.js → chunk-ATN6HPYI.js} +1 -1
  88. package/dist/standalone/{chunk-G2Z7WFAT.js → chunk-AVHCLWWI.js} +1 -1
  89. package/dist/standalone/{chunk-KZ6YQ234.js → chunk-BPNGCNB2.js} +1 -1
  90. package/dist/standalone/{chunk-YLXNXB7E.js → chunk-BUDP4EJL.js} +1 -1
  91. package/dist/standalone/{chunk-7N2OPADC.js → chunk-CHIGIVHM.js} +1 -1
  92. package/dist/standalone/{chunk-IHWSRI72.js → chunk-DCWSHHUX.js} +1 -1
  93. package/dist/standalone/{chunk-K5BAERB3.js → chunk-DH6BG54K.js} +1 -1
  94. package/dist/standalone/{chunk-O24UFHUY.js → chunk-DM3YNFK3.js} +1 -1
  95. package/dist/standalone/{chunk-HWFV5UCF.js → chunk-DVQVIQBT.js} +1 -1
  96. package/dist/standalone/{chunk-NHUEXULQ.js → chunk-DWFXPFDT.js} +1 -1
  97. package/dist/standalone/{chunk-KAK3HS5E.js → chunk-E3PLSEDK.js} +1 -1
  98. package/dist/standalone/{chunk-QBRBGDCL.js → chunk-EHJ2IIDG.js} +1 -1
  99. package/dist/standalone/{chunk-VFB22IM2.js → chunk-F5YWZPEQ.js} +1 -1
  100. package/dist/standalone/{chunk-5X6BEWUI.js → chunk-F6JSRYQT.js} +1 -1
  101. package/dist/standalone/{chunk-MGJZKA6O.js → chunk-FHASF32O.js} +1 -1
  102. package/dist/standalone/{chunk-WGGSW4E2.js → chunk-G2ER6ZFN.js} +1 -1
  103. package/dist/standalone/{chunk-Y2JFJP4B.js → chunk-GVROUDAI.js} +1 -1
  104. package/dist/standalone/{chunk-NEFVDZHP.js → chunk-H5CTBNMP.js} +1 -1
  105. package/dist/standalone/{chunk-JG74C6DH.js → chunk-HAK3FCOV.js} +1 -1
  106. package/dist/standalone/{chunk-7TTX42IR.js → chunk-HOK6O3US.js} +1 -1
  107. package/dist/standalone/{chunk-OOOT4H45.js → chunk-HYNCYK4O.js} +1 -1
  108. package/dist/standalone/{chunk-V3SVDOVD.js → chunk-I3AJWD67.js} +1 -1
  109. package/dist/standalone/{chunk-YYIW5EKO.js → chunk-I4EHU6GZ.js} +1 -1
  110. package/dist/standalone/{chunk-PFNK2MGW.js → chunk-IBCJ4VGA.js} +1 -1
  111. package/dist/standalone/{chunk-E6NWADUS.js → chunk-INTNKBFO.js} +1 -1
  112. package/dist/standalone/{chunk-3IMLG2OT.js → chunk-IRC3PGZV.js} +1 -1
  113. package/dist/standalone/{chunk-FHKZP25N.js → chunk-IVISXJR4.js} +1 -1
  114. package/dist/standalone/{chunk-5BXW4BR6.js → chunk-IXV3EMNQ.js} +1 -1
  115. package/dist/standalone/{chunk-NYJXRBOK.js → chunk-IYX53XCW.js} +1 -1
  116. package/dist/standalone/{chunk-G6PUHYKD.js → chunk-JLGY2EV4.js} +1 -1
  117. package/dist/standalone/{chunk-ZEWRYBCB.js → chunk-KBAJLVHY.js} +1 -1
  118. package/dist/standalone/{chunk-F7EKRF7I.js → chunk-KXFU34K6.js} +1 -1
  119. package/dist/standalone/{chunk-B4K4IET7.js → chunk-LBPNDQST.js} +1 -1
  120. package/dist/standalone/{chunk-ARGGBECJ.js → chunk-LM344LXC.js} +1 -1
  121. package/dist/standalone/{chunk-PDBCAPP6.js → chunk-MYSRHHC4.js} +1 -1
  122. package/dist/standalone/chunk-MZJY3N7N.js +1 -0
  123. package/dist/standalone/{chunk-V6YA4TAL.js → chunk-NS3LKZU2.js} +1 -1
  124. package/dist/standalone/{chunk-QSUQAWEP.js → chunk-O2U7PWU2.js} +1 -1
  125. package/dist/standalone/{chunk-DBLSNTHL.js → chunk-O3ZVMZSA.js} +1 -1
  126. package/dist/standalone/{chunk-OBYE3IXP.js → chunk-O4YNHJSC.js} +1 -1
  127. package/dist/standalone/{chunk-Q3WMP7OA.js → chunk-OFMI2ROE.js} +1 -1
  128. package/dist/standalone/{chunk-JT7UYB6L.js → chunk-P3JNXC5P.js} +1 -1
  129. package/dist/standalone/{chunk-O7XG7DTU.js → chunk-PRPZCRYY.js} +1 -1
  130. package/dist/standalone/{chunk-5SKGLIO5.js → chunk-PZMCBA23.js} +1 -1
  131. package/dist/standalone/{chunk-OQOKF4LL.js → chunk-R5Y2LHHL.js} +1 -1
  132. package/dist/standalone/{chunk-Q65X2ZIP.js → chunk-R7363SOB.js} +1 -1
  133. package/dist/standalone/{chunk-LZHT6UGJ.js → chunk-RGER5Q3A.js} +1 -1
  134. package/dist/standalone/{chunk-7YZKGLGA.js → chunk-S4PIGHQL.js} +1 -1
  135. package/dist/standalone/{chunk-AMOPLAX6.js → chunk-S5IY62X6.js} +1 -1
  136. package/dist/standalone/{chunk-6VLPJOPR.js → chunk-SBFFTOVT.js} +1 -1
  137. package/dist/standalone/{chunk-2TBMJ7XV.js → chunk-SCGQXYRJ.js} +1 -1
  138. package/dist/standalone/{chunk-IDHU47FP.js → chunk-SKVT5IO6.js} +1 -1
  139. package/dist/standalone/{chunk-OS5DOPZW.js → chunk-T43I73OA.js} +1 -1
  140. package/dist/standalone/{chunk-E5LR7G22.js → chunk-T6CRFQVI.js} +1 -1
  141. package/dist/standalone/{chunk-ZGZSTTKN.js → chunk-TA3D6GCA.js} +1 -1
  142. package/dist/standalone/{chunk-TZ5PSNZW.js → chunk-TOWZ7WYZ.js} +1 -1
  143. package/dist/standalone/{chunk-6FLYVL6K.js → chunk-TUFZY4AM.js} +1 -1
  144. package/dist/standalone/{chunk-K3DHV2YQ.js → chunk-U4X2I55T.js} +1 -1
  145. package/dist/standalone/{chunk-ZCN4YUCA.js → chunk-U76UITHC.js} +1 -1
  146. package/dist/standalone/{chunk-W42GZL6T.js → chunk-VOM5M3GA.js} +1 -1
  147. package/dist/standalone/{chunk-STK3KLLV.js → chunk-VYGJX3UB.js} +1 -1
  148. package/dist/standalone/{chunk-PMDLNIHA.js → chunk-WBLJB5GM.js} +1 -1
  149. package/dist/standalone/{chunk-PZGLD7G7.js → chunk-WEHLWY2J.js} +1 -1
  150. package/dist/standalone/{chunk-5XN5GQP5.js → chunk-WVMJYTWY.js} +1 -1
  151. package/dist/standalone/{chunk-62XXKQH3.js → chunk-WWVOUPO3.js} +1 -1
  152. package/dist/standalone/{chunk-CLYI7JF2.js → chunk-XICMCBFN.js} +1 -1
  153. package/dist/standalone/{chunk-2JD7ZSZV.js → chunk-XIV3Q3NC.js} +1 -1
  154. package/dist/standalone/{chunk-6FNFOTRR.js → chunk-XSJHOZY3.js} +1 -1
  155. package/dist/standalone/{chunk-FTJ6RR64.js → chunk-XWXZPKL2.js} +1 -1
  156. package/dist/standalone/{chunk-HGNPJO7S.js → chunk-XXH2XHDM.js} +1 -1
  157. package/dist/standalone/{chunk-5QUEED5Z.js → chunk-Y5N4LSAB.js} +1 -1
  158. package/dist/standalone/{chunk-5KZIXB6E.js → chunk-Y6N2MJKJ.js} +1 -1
  159. package/dist/standalone/{chunk-XMOG3LIP.js → chunk-YK66QDSW.js} +1 -1
  160. package/dist/standalone/{chunk-6LLUZFDD.js → chunk-YPEYNYYK.js} +1 -1
  161. package/dist/standalone/{chunk-RLJYW6TY.js → chunk-YQCQZXJH.js} +1 -1
  162. package/dist/standalone/{chunk-SGIBDCPB.js → chunk-YR5RQPV4.js} +1 -1
  163. package/dist/standalone/{chunk-QR6RYVUD.js → chunk-YX3H4WA3.js} +1 -1
  164. package/dist/standalone/{chunk-E6FH3ZOB.js → chunk-Z3PS37OB.js} +1 -1
  165. package/dist/standalone/studio.js +1 -1
  166. package/package.json +5 -5
  167. package/dist/packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs +0 -1
  168. package/dist/standalone/chunk-2W4UO5BC.js +0 -1
  169. package/dist/standalone/chunk-CNQBTB5C.js +0 -1
  170. package/dist/standalone/chunk-JWQOB4EW.js +0 -7
@@ -1 +1 @@
1
- import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{h as J}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
1
+ import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{h as J}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
@@ -1 +1 @@
1
- import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-DKXm5h19.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;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]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),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]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("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:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
1
+ import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;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]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),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]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("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:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
@@ -1 +1 @@
1
- import{E as g}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as A,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as E}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as S}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=S(),{data:l,error:p,errorSource:u,liveError:f}=E(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(A,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,shardKey:a,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
1
+ import{E as g}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as A,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as E}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as S}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=S(),{data:l,error:p,errorSource:u,liveError:f}=E(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(A,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,shardKey:a,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
@@ -1 +1 @@
1
- import{c as W}from"react/compiler-runtime";import{u as G}from"../packem_shared/assistant-provider-Bp72uWsq.mjs";import{E as F}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as U}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as B,C as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as H,b as C,c as A,d as O,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{jsx as s,jsxs as a}from"react/jsx-runtime";const _=["read","insert","update","delete"],P=30,z=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],J=e=>{const t=new Map;for(const l of e){const r=t.get(l.table)??{operations:new Set,procedures:new Set,table:l.table};r.operations.add(l.on),r.procedures.add(l.procedure),t.set(l.table,r)}return[...t.values()].toSorted((l,r)=>l.table.localeCompare(r.table))},K=e=>{const t=e.slice(0,P).map(l=>`${l.table}: ${_.filter(r=>l.operations.has(r)).join("/")}`).join("; ");return e.length>P?`${t}; and ${String(e.length-P)} more tables`:t},ce=()=>{const e=W(45),t=X(),l=G(),r=l!==void 0&&!l.unavailable;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const{data:i,error:E,errorSource:$}=Q(q.rlsPolicies,S),o=i!==void 0;let c;e[1]!==i?(c=Array.isArray(i?.policies)?i.policies:[],e[1]=i,e[2]=c):c=e[2];let v;e[3]!==c?(v=J(c),e[3]=c,e[4]=v):v=e[4];const n=v;let I;e[5]!==i?(I=Array.isArray(i?.roles)?i.roles:[],e[5]=i,e[6]=I):I=e[6];const R=I;let p;e[7]!==E||e[8]!==$?(p=E!==null&&s(F,{error:$,testId:"rls-error"}),e[7]=E,e[8]=$,e[9]=p):p=e[9];let m;e[10]!==t?(m=t("Policies"),e[10]=t,e[11]=m):m=e[11];let h;e[12]!==m?(h=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[12]=m,e[13]=h):h=e[13];let u;e[14]!==l||e[15]!==r||e[16]!==o||e[17]!==t||e[18]!==n?(u=o&&r&&s("button",{className:"ms-auto text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"rls-ask-assistant",onClick:()=>{l.openAssistant({ask:n.length===0?t("This app declares no row-level-security policies at all. Which tables most need one, and what policy should I write for them?"):t("The Lunora RLS inspector shows these declared policies — {coverage}. Which tables and operations are still unguarded, and what policy should I add?",{coverage:K(n)}),suggestions:[t("Which procedures still need .use(rls(...))?"),t("How do I test a policy?")],title:t("Access rules")})},type:"button",children:t("Ask the assistant")}),e[14]=l,e[15]=r,e[16]=o,e[17]=t,e[18]=n,e[19]=u):u=e[19];let f;e[20]!==h||e[21]!==u?(f=a("header",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[h,u]}),e[20]=h,e[21]=u,e[22]=f):f=e[22];let b;e[23]!==o||e[24]!==t||e[25]!==n?(b=o&&n.length===0?s(D,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-policies-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Table")}),_.map(d=>s(A,{children:z(t,d)},d)),s(A,{children:t("Guarded by")})]})}),s(O,{children:n.map(d=>a(C,{"data-testid":`rls-table-${d.table}`,children:[s(T,{className:"font-mono text-xs",children:d.table}),_.map(j=>s(T,{children:d.operations.has(j)?s(U,{variant:"secondary",children:t("Guarded")}):s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},j)),s(T,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[23]=o,e[24]=t,e[25]=n,e[26]=b):b=e[26];let x;e[27]!==f||e[28]!==b?(x=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[f,b]})}),e[27]=f,e[28]=b,e[29]=x):x=e[29];let g;e[30]!==t?(g=t("Roles"),e[30]=t,e[31]=g):g=e[31];let y;e[32]!==g?(y=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[32]=g,e[33]=y):y=e[33];let N;e[34]!==o||e[35]!==R||e[36]!==t?(N=o&&R.length===0?s(D,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-roles-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Role")}),s(A,{children:t("Description")}),s(A,{children:t("Permissions")})]})}),s(O,{children:R.map(Y)})]})}),e[34]=o,e[35]=R,e[36]=t,e[37]=N):N=e[37];let w;e[38]!==y||e[39]!==N?(w=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[y,N]})}),e[38]=y,e[39]=N,e[40]=w):w=e[40];let k;return e[41]!==x||e[42]!==w||e[43]!==p?(k=a("div",{className:"flex flex-col gap-6","data-testid":"lunora-rls-panel",children:[p,x,w]}),e[41]=x,e[42]=w,e[43]=p,e[44]=k):k=e[44],k};function V(e){return s(U,{variant:"outline",children:e},e)}function Y(e){return a(C,{"data-testid":`rls-role-${e.name}`,children:[s(T,{className:"font-mono text-xs",children:e.name}),s(T,{className:"text-muted-foreground",children:e.description??""}),s(T,{children:e.permissions.length===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(V)})})]},e.name)}export{ce as default};
1
+ import{c as W}from"react/compiler-runtime";import{u as G}from"../packem_shared/assistant-provider-BQG7QZAu.mjs";import{E as F}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as U}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as B,C as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as H,b as C,c as A,d as O,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{jsx as s,jsxs as a}from"react/jsx-runtime";const _=["read","insert","update","delete"],P=30,z=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],J=e=>{const t=new Map;for(const l of e){const r=t.get(l.table)??{operations:new Set,procedures:new Set,table:l.table};r.operations.add(l.on),r.procedures.add(l.procedure),t.set(l.table,r)}return[...t.values()].toSorted((l,r)=>l.table.localeCompare(r.table))},K=e=>{const t=e.slice(0,P).map(l=>`${l.table}: ${_.filter(r=>l.operations.has(r)).join("/")}`).join("; ");return e.length>P?`${t}; and ${String(e.length-P)} more tables`:t},ce=()=>{const e=W(45),t=X(),l=G(),r=l!==void 0&&!l.unavailable;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const{data:i,error:E,errorSource:$}=Q(q.rlsPolicies,S),o=i!==void 0;let c;e[1]!==i?(c=Array.isArray(i?.policies)?i.policies:[],e[1]=i,e[2]=c):c=e[2];let v;e[3]!==c?(v=J(c),e[3]=c,e[4]=v):v=e[4];const n=v;let I;e[5]!==i?(I=Array.isArray(i?.roles)?i.roles:[],e[5]=i,e[6]=I):I=e[6];const R=I;let p;e[7]!==E||e[8]!==$?(p=E!==null&&s(F,{error:$,testId:"rls-error"}),e[7]=E,e[8]=$,e[9]=p):p=e[9];let m;e[10]!==t?(m=t("Policies"),e[10]=t,e[11]=m):m=e[11];let h;e[12]!==m?(h=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[12]=m,e[13]=h):h=e[13];let u;e[14]!==l||e[15]!==r||e[16]!==o||e[17]!==t||e[18]!==n?(u=o&&r&&s("button",{className:"ms-auto text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"rls-ask-assistant",onClick:()=>{l.openAssistant({ask:n.length===0?t("This app declares no row-level-security policies at all. Which tables most need one, and what policy should I write for them?"):t("The Lunora RLS inspector shows these declared policies — {coverage}. Which tables and operations are still unguarded, and what policy should I add?",{coverage:K(n)}),suggestions:[t("Which procedures still need .use(rls(...))?"),t("How do I test a policy?")],title:t("Access rules")})},type:"button",children:t("Ask the assistant")}),e[14]=l,e[15]=r,e[16]=o,e[17]=t,e[18]=n,e[19]=u):u=e[19];let f;e[20]!==h||e[21]!==u?(f=a("header",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[h,u]}),e[20]=h,e[21]=u,e[22]=f):f=e[22];let b;e[23]!==o||e[24]!==t||e[25]!==n?(b=o&&n.length===0?s(D,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-policies-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Table")}),_.map(d=>s(A,{children:z(t,d)},d)),s(A,{children:t("Guarded by")})]})}),s(O,{children:n.map(d=>a(C,{"data-testid":`rls-table-${d.table}`,children:[s(T,{className:"font-mono text-xs",children:d.table}),_.map(j=>s(T,{children:d.operations.has(j)?s(U,{variant:"secondary",children:t("Guarded")}):s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},j)),s(T,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[23]=o,e[24]=t,e[25]=n,e[26]=b):b=e[26];let x;e[27]!==f||e[28]!==b?(x=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[f,b]})}),e[27]=f,e[28]=b,e[29]=x):x=e[29];let g;e[30]!==t?(g=t("Roles"),e[30]=t,e[31]=g):g=e[31];let y;e[32]!==g?(y=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[32]=g,e[33]=y):y=e[33];let N;e[34]!==o||e[35]!==R||e[36]!==t?(N=o&&R.length===0?s(D,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-roles-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Role")}),s(A,{children:t("Description")}),s(A,{children:t("Permissions")})]})}),s(O,{children:R.map(Y)})]})}),e[34]=o,e[35]=R,e[36]=t,e[37]=N):N=e[37];let w;e[38]!==y||e[39]!==N?(w=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[y,N]})}),e[38]=y,e[39]=N,e[40]=w):w=e[40];let k;return e[41]!==x||e[42]!==w||e[43]!==p?(k=a("div",{className:"flex flex-col gap-6","data-testid":"lunora-rls-panel",children:[p,x,w]}),e[41]=x,e[42]=w,e[43]=p,e[44]=k):k=e[44],k};function V(e){return s(U,{variant:"outline",children:e},e)}function Y(e){return a(C,{"data-testid":`rls-role-${e.name}`,children:[s(T,{className:"font-mono text-xs",children:e.name}),s(T,{className:"text-muted-foreground",children:e.description??""}),s(T,{children:e.permissions.length===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(V)})})]},e.name)}export{ce as default};
@@ -1 +1 @@
1
- import{c as z}from"react/compiler-runtime";import{useState as W}from"react";import{D as pe}from"../packem_shared/studio-Cm9ea8j7.mjs";import{B as ce}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as he}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as Z,a as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as se,c as R,a as le,b as U,d as re,e as D}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ee}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ie}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as oe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as te,f as X,j as xe,b as ue}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as C}from"react/jsx-runtime";import{I as ge}from"../packem_shared/input-CXhxesPC.mjs";import{u as ve}from"../packem_shared/use-assistant-rpc-GCUK2zPa.mjs";import{c as be}from"../packem_shared/utils-bhneXptQ.mjs";import{ScheduledJobs as Ne}from"../packem_shared/ScheduledJobs-QCTRdugp.mjs";const me={failed:"destructive",skipped:"warning",succeeded:"success"},ye=25,we=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,ke=t=>{const e=z(39),{inFlight:u,last:r}=t,a=G();if(u!==void 0){let c;e[0]!==a?(c=a("running"),e[0]=a,e[1]=c):c=e[1];let m;e[2]!==c?(m=s(Y,{variant:"info",children:c}),e[2]=c,e[3]=m):m=e[3];let b;e[4]!==u.startedAt?(b=te(u.startedAt,"—"),e[4]=u.startedAt,e[5]=b):b=e[5];let y;e[6]!==b?(y=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=y):y=e[7];let I;e[8]!==u.skipped||e[9]!==a?(I=u.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:a("{count} ticks skipped",{count:u.skipped})}),e[8]=u.skipped,e[9]=a,e[10]=I):I=e[10];let w;return e[11]!==m||e[12]!==y||e[13]!==I?(w=C("span",{className:"flex items-center gap-2",children:[m,y,I]}),e[11]=m,e[12]=y,e[13]=I,e[14]=w):w=e[14],w}if(r===void 0){let c;e[15]!==a?(c=a("never"),e[15]=a,e[16]=c):c=e[16];let m;return e[17]!==c?(m=s("span",{className:"text-xs text-muted-foreground",children:c}),e[17]=c,e[18]=m):m=e[18],m}let l;e[19]!==a?(l=a("failed"),e[19]=a,e[20]=l):l=e[20];let i;e[21]!==a?(i=a("skipped"),e[21]=a,e[22]=i):i=e[22];let n;e[23]!==a?(n=a("succeeded"),e[23]=a,e[24]=n):n=e[24];let N;e[25]!==l||e[26]!==i||e[27]!==n?(N={failed:l,skipped:i,succeeded:n},e[25]=l,e[26]=i,e[27]=n,e[28]=N):N=e[28];const v=N,d=me[r.status],f=v[r.status];let g;e[29]!==d||e[30]!==f?(g=s(Y,{variant:d,children:f}),e[29]=d,e[30]=f,e[31]=g):g=e[31];let x;e[32]!==r.startedAt?(x=te(r.startedAt,"—"),e[32]=r.startedAt,e[33]=x):x=e[33];let p;e[34]!==x?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:x}),e[34]=x,e[35]=p):p=e[35];let o;return e[36]!==g||e[37]!==p?(o=C("span",{className:"flex items-center gap-2",children:[g,p]}),e[36]=g,e[37]=p,e[38]=o):o=e[38],o},Ce=t=>{const e=z(80),{runs:u}=t,r=G();if(u.length===0)return;let a,l,i,n,N,v,d,f,g,x,p;if(e[0]!==u||e[1]!==r){const I=u.toSorted(Te).slice(0,ye);let w;e[13]!==r?(w=r("failed"),e[13]=r,e[14]=w):w=e[14];let A;e[15]!==r?(A=r("skipped"),e[15]=r,e[16]=A):A=e[16];let S;e[17]!==r?(S=r("succeeded"),e[17]=r,e[18]=S):S=e[18];let L;e[19]!==S||e[20]!==w||e[21]!==A?(L={failed:w,skipped:A,succeeded:S},e[19]=S,e[20]=w,e[21]=A,e[22]=L):L=e[22];const T=L;g="flex flex-col gap-2",x="cron-run-history";let k;e[23]!==r?(k=r("Recent runs"),e[23]=r,e[24]=k):k=e[24],e[25]!==k?(p=s("h3",{className:"text-sm font-medium",children:k}),e[25]=k,e[26]=p):p=e[26],n=Z,f="overflow-hidden py-0",i=j,d="px-0",l=se;let $;e[27]!==r?($=r("name"),e[27]=r,e[28]=$):$=e[28];let h;e[29]!==$?(h=s(R,{children:$}),e[29]=$,e[30]=h):h=e[30];let E;e[31]!==r?(E=r("status"),e[31]=r,e[32]=E):E=e[32];let F;e[33]!==E?(F=s(R,{children:E}),e[33]=E,e[34]=F):F=e[34];let J;e[35]!==r?(J=r("started"),e[35]=r,e[36]=J):J=e[36];let P;e[37]!==J?(P=s(R,{children:J}),e[37]=J,e[38]=P):P=e[38];let H;e[39]!==r?(H=r("duration"),e[39]=r,e[40]=H):H=e[40];let K;e[41]!==H?(K=s(R,{children:H}),e[41]=H,e[42]=K):K=e[42];let q;e[43]!==r?(q=r("skipped"),e[43]=r,e[44]=q):q=e[44];let V;e[45]!==q?(V=s(R,{children:q}),e[45]=q,e[46]=V):V=e[46];let Q;e[47]!==r?(Q=r("error"),e[47]=r,e[48]=Q):Q=e[48];let M;e[49]!==Q?(M=s(R,{children:Q}),e[49]=Q,e[50]=M):M=e[50],e[51]!==h||e[52]!==F||e[53]!==P||e[54]!==K||e[55]!==V||e[56]!==M?(v=s(le,{children:C(U,{children:[h,F,P,K,V,M]})}),e[51]=h,e[52]=F,e[53]=P,e[54]=K,e[55]=V,e[56]=M,e[57]=v):v=e[57],a=re;let B;e[58]!==T?(B=O=>C(U,{"data-testid":`cron-run-row-${O.runId}`,children:[s(D,{children:O.name}),s(D,{children:s(Y,{variant:me[O.status],children:T[O.status]})}),s(D,{className:"text-muted-foreground tabular-nums",children:te(O.startedAt,"—")}),s(D,{className:"tabular-nums",children:O.status==="skipped"?"":we(O.durationMs)}),s(D,{className:"tabular-nums",children:O.skipped>0?O.skipped:""}),s(D,{className:"text-xs text-destructive",children:O.error??""})]},O.runId),e[58]=T,e[59]=B):B=e[59],N=I.map(B),e[0]=u,e[1]=r,e[2]=a,e[3]=l,e[4]=i,e[5]=n,e[6]=N,e[7]=v,e[8]=d,e[9]=f,e[10]=g,e[11]=x,e[12]=p}else a=e[2],l=e[3],i=e[4],n=e[5],N=e[6],v=e[7],d=e[8],f=e[9],g=e[10],x=e[11],p=e[12];let o;e[60]!==a||e[61]!==N?(o=s(a,{children:N}),e[60]=a,e[61]=N,e[62]=o):o=e[62];let c;e[63]!==l||e[64]!==v||e[65]!==o?(c=C(l,{children:[v,o]}),e[63]=l,e[64]=v,e[65]=o,e[66]=c):c=e[66];let m;e[67]!==i||e[68]!==d||e[69]!==c?(m=s(i,{className:d,children:c}),e[67]=i,e[68]=d,e[69]=c,e[70]=m):m=e[70];let b;e[71]!==n||e[72]!==m||e[73]!==f?(b=s(n,{className:f,children:m}),e[71]=n,e[72]=m,e[73]=f,e[74]=b):b=e[74];let y;return e[75]!==b||e[76]!==g||e[77]!==x||e[78]!==p?(y=C("div",{className:g,"data-testid":x,children:[p,b]}),e[75]=b,e[76]=g,e[77]=x,e[78]=p,e[79]=y):y=e[79],y};function Te(t,e){return e.startedAt-t.startedAt}const Se=()=>{const t=z(50),e=G(),u=ve(""),[r,a]=W(""),[l,i]=W(void 0),[n,N]=W(!1);if(u.unavailable)return null;let v;t[0]!==u?(v=u.pending("cron"),t[0]=u,t[1]=v):v=t[1];const d=v;let f;t[2]!==u?(f=u.reason("cron"),t[2]=u,t[3]=f):f=t[3];const g=f;let x;t[4]!==r||t[5]!==u?(x=()=>{const J=r.trim();if(J==="")return;X((async()=>{const H=await u.suggestCron(J);N(!1),i(H)})())},t[4]=r,t[5]=u,t[6]=x):x=t[6];const p=x;let o;t[7]!==l?(o=()=>{const J="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(J===void 0||l===void 0)return;X((async()=>{try{await J.writeText(l),N(!0)}catch{N(!1)}})())},t[7]=l,t[8]=o):o=t[8];const c=o;let m;t[9]!==e?(m=e("Describe a schedule"),t[9]=e,t[10]=m):m=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=J=>{a(J.target.value)},t[11]=b):b=t[11];let y;t[12]!==p?(y=J=>{J.key==="Enter"&&(J.preventDefault(),p())},t[12]=p,t[13]=y):y=t[13];let I;t[14]!==e?(I=e("Describe a schedule"),t[14]=e,t[15]=I):I=t[15];let w;t[16]!==d||t[17]!==r||t[18]!==m||t[19]!==y||t[20]!==I?(w=s(ge,{"aria-label":m,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:d,onChange:b,onKeyDown:y,placeholder:I,value:r}),t[16]=d,t[17]=r,t[18]=m,t[19]=y,t[20]=I,t[21]=w):w=t[21];const A=d&&"opacity-60";let S;t[22]!==A?(S=be("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",A),t[22]=A,t[23]=S):S=t[23];let L;t[24]!==d||t[25]!==r?(L=d||r.trim()==="",t[24]=d,t[25]=r,t[26]=L):L=t[26];let T;t[27]!==d||t[28]!==e?(T=e(d?"Thinking…":"Suggest schedule"),t[27]=d,t[28]=e,t[29]=T):T=t[29];let k;t[30]!==p||t[31]!==S||t[32]!==L||t[33]!==T?(k=s("button",{className:S,"data-testid":"cron-assistant-generate",disabled:L,onClick:p,type:"button",children:T}),t[30]=p,t[31]=S,t[32]=L,t[33]=T,t[34]=k):k=t[34];let $;t[35]!==k||t[36]!==w?($=C("div",{className:"flex items-center gap-2",children:[w,k]}),t[35]=k,t[36]=w,t[37]=$):$=t[37];let h;t[38]!==n||t[39]!==c||t[40]!==l||t[41]!==e?(h=l!==void 0&&C("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:l}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:c,type:"button",children:e(n?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=n,t[39]=c,t[40]=l,t[41]=e,t[42]=h):h=t[42];let E;t[43]!==g||t[44]!==e?(E=g!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(g==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=g,t[44]=e,t[45]=E):E=t[45];let F;return t[46]!==$||t[47]!==h||t[48]!==E?(F=C("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[$,h,E]}),t[46]=$,t[47]=h,t[48]=E,t[49]=F):F=t[49],F},$e={kind:"idle"},Ie="SCHEDULER_NOT_CONFIGURED",ae={inFlight:[],runs:[]},Ae=(t,e,u)=>u!==void 0?u:e===void 0?r=>t.runCronJob(r):void 0,Le=({loadCronJobs:t,loadCronRuns:e,runCronJob:u}={})=>{const r=oe(),a=G(),[l,i]=W({}),n=ee(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>r.getCronJobs()))()),{data:N,error:v}=n,d=e??(t===void 0?()=>r.listCronRuns():void 0),f=ee(["lunora-cron-runs",e?"custom":"default"],async()=>d===void 0?ae:d().catch(o=>{if(xe(o)===Ie)return ae;throw o})),g=f.data??ae;ie(()=>f.poll(),d!==void 0);const x=Ae(r,t,u),p=async o=>{if(x!==void 0){i(c=>({...c,[o]:{kind:"running"}}));try{await x(o),i(c=>({...c,[o]:{kind:"ok"}})),n.refetch(),f.refetch()}catch(c){i(m=>({...m,[o]:{kind:"error",message:ue(c)}}))}}};return C("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Se,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),f.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:f.error}),N?.length===0&&s(ne,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:C("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),N!==void 0&&N.length>0&&s(Z,{className:"overflow-hidden py-0",children:s(j,{className:"px-0",children:C(se,{"data-testid":"cron-table",children:[s(le,{children:C(U,{children:[s(R,{children:a("name")}),s(R,{children:a("schedule")}),s(R,{children:a("target")}),s(R,{children:a("shard")}),s(R,{children:a("last run")}),x!==void 0&&s(R,{"aria-label":a("Actions")})]})}),s(re,{children:N.map(o=>{const c=l[o.name]??$e;return C(U,{"data-testid":`cron-row-${o.name}`,children:[s(D,{children:o.name}),s(D,{className:"font-mono text-xs tabular-nums",children:o.cron}),s(D,{children:C("span",{className:"flex items-center gap-2",children:[o.workflow===void 0?s(Y,{variant:"outline",children:a("function")}):s(Y,{variant:"secondary",children:a("workflow")}),s("span",{className:"font-mono text-xs",children:o.workflow??o.functionPath})]})}),s(D,{children:o.shardKey??""}),s(D,{"data-testid":`cron-last-run-${o.name}`,children:s(ke,{inFlight:g.inFlight.find(m=>m.name===o.name),last:g.runs.find(m=>m.name===o.name)})}),x!==void 0&&s(D,{className:"text-right",children:C("span",{className:"flex items-center justify-end gap-2",children:[c.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${o.name}`,children:a("ran")}),c.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${o.name}`,role:"alert",children:c.message}),s(he,{confirmLabel:a("Run now?"),disabled:c.kind==="running",onConfirm:()=>{X(p(o.name))},testId:`cron-run-${o.name}`,children:c.kind==="running"?a("Running…"):a("Run now")})]})})]},`${o.cron}:${o.name}`)})})]})})}),s(Ce,{runs:g.runs})]})},Re=t=>Number.isFinite(t)?te(t,"—"):"—",De=t=>{const e=z(34);let u;e[0]!==t?(u=t===void 0?{}:t,e[0]=t,e[1]=u):u=e[1];const{loadJobs:r,removeJob:a,retryJob:l}=u,i=oe(),n=G();let N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let v;e[3]!==i||e[4]!==r?(v=async()=>(await(r??(()=>i.listDeadJobs()))()).toSorted(Ee),e[3]=i,e[4]=r,e[5]=v):v=e[5];const d=ee(N,v),f=d.data,[g,x]=W(void 0),p=d.error??g,o=r===void 0;let c;e[6]!==i||e[7]!==o||e[8]!==l?(c=l??(o?h=>i.retryDeadJob(h):void 0),e[6]=i,e[7]=o,e[8]=l,e[9]=c):c=e[9];const m=c;let b;e[10]!==i||e[11]!==o||e[12]!==a?(b=a??(o?h=>i.removeDeadJob(h):void 0),e[10]=i,e[11]=o,e[12]=a,e[13]=b):b=e[13];const y=b;let I;e[14]!==d?(I=()=>d.poll(),e[14]=d,e[15]=I):I=e[15],ie(I,!0);let w;e[16]!==d?(w=async h=>{x(void 0);try{await h,d.refetch()}catch(E){x(ue(E))}},e[16]=d,e[17]=w):w=e[17];const A=w,S=m!==void 0||y!==void 0;let L;e[18]!==p?(L=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=L):L=e[19];let T;e[20]!==f?.length||e[21]!==n?(T=f?.length===0&&s(ne,{description:n("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:n("No dead-letter jobs.")}),e[20]=f?.length,e[21]=n,e[22]=T):T=e[22];let k;e[23]!==A||e[24]!==S||e[25]!==f||e[26]!==y||e[27]!==m||e[28]!==n?(k=f!==void 0&&f.length>0&&s(Z,{className:"overflow-hidden py-0",children:s(j,{className:"px-0",children:C(se,{"data-testid":"dlq-table",children:[s(le,{children:C(U,{children:[s(R,{children:n("function")}),s(R,{children:n("attempts")}),s(R,{children:n("last tried")}),s(R,{children:n("pool")}),s(R,{children:n("shard")}),s(R,{children:n("id")}),S&&s(R,{"aria-label":n("Actions")})]})}),s(re,{children:f.map(h=>C(U,{"data-testid":`dlq-row-${h.id}`,children:[s(D,{className:"font-mono text-xs",children:h.workflow??h.functionPath}),s(D,{className:"tabular-nums",children:h.attempts??0}),s(D,{className:"text-muted-foreground tabular-nums",children:Re(h.scheduledFor)}),s(D,{className:"font-mono text-xs",children:h.pool??""}),s(D,{children:h.shardKey??""}),s(D,{className:"font-mono text-xs",children:h.id}),S&&s(D,{className:"text-right",children:C("div",{className:"flex justify-end gap-1.5",children:[m!==void 0&&s(ce,{"data-testid":`dlq-retry-${h.id}`,onClick:()=>{X(A(m(h.id)))},size:"sm",type:"button",variant:"outline",children:n("Retry")}),y!==void 0&&s(he,{confirmLabel:n("Drop job?"),onConfirm:()=>{X(A(y(h.id)))},testId:`dlq-remove-${h.id}`,children:n("Drop")})]})})]},h.id))})]})})}),e[23]=A,e[24]=S,e[25]=f,e[26]=y,e[27]=m,e[28]=n,e[29]=k):k=e[29];let $;return e[30]!==k||e[31]!==L||e[32]!==T?($=C("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[L,T,k]}),e[30]=k,e[31]=L,e[32]=T,e[33]=$):$=e[33],$};function Ee(t,e){return(e.attempts??0)-(t.attempts??0)}const _e={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Je=t=>{const e=z(47);let u;e[0]!==t?(u=t===void 0?{}:t,e[0]=t,e[1]=u):u=e[1];const{loadJobs:r}=u,a=oe(),l=G();let i;e[2]!==a||e[3]!==r?(i=r??(async _=>a.listScheduledHistory(_===void 0?{}:{cursor:_})),e[2]=a,e[3]=r,e[4]=i):i=e[4];const n=i,N=r?"custom":"default";let v;e[5]!==N?(v=["lunora-job-history",N],e[5]=N,e[6]=v):v=e[6];let d;e[7]!==n?(d=async()=>n(),e[7]=n,e[8]=d):d=e[8];const f=ee(v,d),[g,x]=W(void 0),[p,o]=W(!1),[c,m]=W(void 0),b=f.data?.records;let y;e[9]!==b?(y=new Set(b?.map(Fe)),e[9]=b,e[10]=y):y=e[10];const I=y,w=b===void 0?void 0:[...b,...(g?.records??[]).filter(_=>!I.has(_.id))],A=g===void 0?f.data?.cursor:g.cursor;let S;e[11]!==n||e[12]!==A?(S=async()=>{o(!0),m(void 0);try{const _=await n(A);x(fe=>({cursor:_.cursor,records:[...fe?.records??[],..._.records]})),o(!1)}catch(_){m(ue(_)),o(!1)}},e[11]=n,e[12]=A,e[13]=S):S=e[13];const L=S;let T;e[14]!==l?(T=l("canceled"),e[14]=l,e[15]=T):T=e[15];let k;e[16]!==l?(k=l("failed"),e[16]=l,e[17]=k):k=e[17];let $;e[18]!==l?($=l("pending"),e[18]=l,e[19]=$):$=e[19];let h;e[20]!==l?(h=l("running"),e[20]=l,e[21]=h):h=e[21];let E;e[22]!==l?(E=l("succeeded"),e[22]=l,e[23]=E):E=e[23];let F;e[24]!==$||e[25]!==h||e[26]!==E||e[27]!==T||e[28]!==k?(F={canceled:T,failed:k,pending:$,running:h,succeeded:E},e[24]=$,e[25]=h,e[26]=E,e[27]=T,e[28]=k,e[29]=F):F=e[29];const J=F;let P;e[30]!==f?(P=()=>f.poll(),e[30]=f,e[31]=P):P=e[31],ie(P,g===void 0);const H="flex flex-col gap-3",K="lunora-job-history";let q;e[32]!==f.error?(q=f.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:f.error}),e[32]=f.error,e[33]=q):q=e[33];const V=w?.length===0&&s(ne,{description:l("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:l("No finished jobs.")}),Q=w!==void 0&&w.length>0&&s(Z,{className:"overflow-hidden py-0",children:s(j,{className:"px-0",children:C(se,{"data-testid":"job-history-table",children:[s(le,{children:C(U,{children:[s(R,{children:l("function")}),s(R,{children:l("state")}),s(R,{children:l("finished")}),s(R,{children:l("error")}),s(R,{children:l("id")})]})}),s(re,{children:w.map(_=>C(U,{"data-testid":`job-history-row-${_.id}`,children:[s(D,{className:"font-mono text-xs",children:_.workflow??_.functionPath}),s(D,{children:s(Y,{"data-testid":`job-history-state-${_.id}`,variant:_e[_.state],children:J[_.state]})}),s(D,{className:"text-muted-foreground tabular-nums",children:te(_.completedAt,"—")}),s(D,{className:"text-xs text-destructive",children:_.error??""}),s(D,{className:"font-mono text-xs",children:_.id})]},_.id))})]})})});let M;e[34]!==c?(M=c!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:c}),e[34]=c,e[35]=M):M=e[35];let B;e[36]!==p||e[37]!==A||e[38]!==L||e[39]!==l?(B=A!==void 0&&s("div",{children:s(ce,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{X(L())},variant:"outline",children:l(p?"Loading…":"Load more")})}),e[36]=p,e[37]=A,e[38]=L,e[39]=l,e[40]=B):B=e[40];let O;return e[41]!==q||e[42]!==V||e[43]!==Q||e[44]!==M||e[45]!==B?(O=C("div",{className:H,"data-testid":K,children:[q,V,Q,M,B]}),e[41]=q,e[42]=V,e[43]=Q,e[44]=M,e[45]=B,e[46]=O):O=e[46],O};function Fe(t){return t.id}const de=t=>{const e=z(8),{label:u,testId:r,value:a}=t;let l;e[0]!==u?(l=s("span",{className:"text-xs text-muted-foreground",children:u}),e[0]=u,e[1]=l):l=e[1];let i;e[2]!==r||e[3]!==a?(i=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":r,children:a}),e[2]=r,e[3]=a,e[4]=i):i=e[4];let n;return e[5]!==l||e[6]!==i?(n=s(Z,{className:"flex-1 py-0",children:C(j,{className:"flex flex-col gap-1 p-4",children:[l,i]})}),e[5]=l,e[6]=i,e[7]=n):n=e[7],n},Oe=t=>{const e=z(25);let u;e[0]!==t?(u=t===void 0?{}:t,e[0]=t,e[1]=u):u=e[1];const{loadStatus:r}=u,a=oe(),l=G(),i=r===void 0;let n;e[2]!==i?(n=["lunora-scheduler-status",i],e[2]=i,e[3]=n):n=e[3];let N;e[4]!==a||e[5]!==r?(N=async()=>{const b=await(r??(()=>a.schedulerStatus()))();return{...b,pools:b.pools.toSorted(Pe)}},e[4]=a,e[5]=r,e[6]=N):N=e[6];const v=ee(n,N),{data:d,error:f}=v;let g;e[7]!==v?(g=()=>v.poll(),e[7]=v,e[8]=g):g=e[8],ie(g,!0);let x;e[9]!==f?(x=f!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:f}),e[9]=f,e[10]=x):x=e[10];let p;e[11]!==d||e[12]!==l?(p=d!==void 0&&C("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(de,{label:l("backlog"),testId:"pools-backlog",value:d.backlog}),s(de,{label:l("in flight"),testId:"pools-inflight",value:d.inFlight}),s(de,{label:l("pools"),testId:"pools-count",value:d.pools.length})]}),e[11]=d,e[12]=l,e[13]=p):p=e[13];let o;e[14]!==d?.pools.length||e[15]!==l?(o=d?.pools.length===0&&s(ne,{description:l("Pools created with createWorkpool appear here once they have activity."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:l("No workpools.")}),e[14]=d?.pools.length,e[15]=l,e[16]=o):o=e[16];let c;e[17]!==d||e[18]!==l?(c=d!==void 0&&d.pools.length>0&&s(Z,{className:"overflow-hidden py-0",children:s(j,{className:"px-0",children:C(se,{"data-testid":"pools-table",children:[s(le,{children:C(U,{children:[s(R,{children:l("pool")}),s(R,{children:l("queued")}),s(R,{children:l("in flight")}),s(R,{children:l("max concurrency")})]})}),s(re,{children:d.pools.map(qe)})]})})}),e[17]=d,e[18]=l,e[19]=c):c=e[19];let m;return e[20]!==x||e[21]!==p||e[22]!==o||e[23]!==c?(m=C("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[x,p,o,c]}),e[20]=x,e[21]=p,e[22]=o,e[23]=c,e[24]=m):m=e[24],m};function Pe(t,e){return e.queued-t.queued}function qe(t){return C(U,{"data-testid":`pools-row-${t.name}`,children:[s(D,{className:"font-mono text-xs",children:t.name}),s(D,{className:"tabular-nums",children:t.queued}),C(D,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(D,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const Me=["jobs","history","dead","pools","cron"],it=t=>{const e=z(48);let u;e[0]!==t?(u=t===void 0?{}:t,e[0]=t,e[1]=u):u=e[1];const{loadCronJobs:r,scheduledCancel:a,scheduledLoad:l}=u,i=G(),[n,N]=W("jobs");let v;e[2]!==i?(v=i("Cron triggers"),e[2]=i,e[3]=v):v=e[3];let d;e[4]!==i?(d=i("Dead letter"),e[4]=i,e[5]=d):d=e[5];let f;e[6]!==i?(f=i("History"),e[6]=i,e[7]=f):f=e[7];let g;e[8]!==i?(g=i("Scheduled jobs"),e[8]=i,e[9]=g):g=e[9];let x;e[10]!==i?(x=i("Pools"),e[10]=i,e[11]=x):x=e[11];let p;e[12]!==v||e[13]!==d||e[14]!==f||e[15]!==g||e[16]!==x?(p={cron:v,dead:d,history:f,jobs:g,pools:x},e[12]=v,e[13]=d,e[14]=f,e[15]=g,e[16]=x,e[17]=p):p=e[17];const o=p;let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{N(h.currentTarget.dataset.view)},e[18]=c):c=e[18];const m=c;let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=s(pe,{}),e[19]=b):b=e[19];let y;e[20]!==i?(y=i("Schedule view"),e[20]=i,e[21]=y):y=e[21];let I;e[22]!==n||e[23]!==o?(I=Me.map(h=>s(ce,{"aria-selected":n===h,"data-testid":`schedule-view-${h}`,"data-view":h,onClick:m,role:"tab",size:"sm",type:"button",variant:n===h?"default":"outline",children:o[h]},h)),e[22]=n,e[23]=o,e[24]=I):I=e[24];let w;e[25]!==y||e[26]!==I?(w=s("div",{"aria-label":y,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:I}),e[25]=y,e[26]=I,e[27]=w):w=e[27];let A;e[28]!==a||e[29]!==l||e[30]!==n?(A=n==="jobs"&&s(Ne,{cancelJob:a,loadJobs:l}),e[28]=a,e[29]=l,e[30]=n,e[31]=A):A=e[31];let S;e[32]!==n?(S=n==="history"&&s(Je,{}),e[32]=n,e[33]=S):S=e[33];let L;e[34]!==n?(L=n==="dead"&&s(De,{}),e[34]=n,e[35]=L):L=e[35];let T;e[36]!==n?(T=n==="pools"&&s(Oe,{}),e[36]=n,e[37]=T):T=e[37];let k;e[38]!==r||e[39]!==n?(k=n==="cron"&&s(Le,{loadCronJobs:r}),e[38]=r,e[39]=n,e[40]=k):k=e[40];let $;return e[41]!==w||e[42]!==A||e[43]!==S||e[44]!==L||e[45]!==T||e[46]!==k?($=C("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[b,w,A,S,L,T,k]}),e[41]=w,e[42]=A,e[43]=S,e[44]=L,e[45]=T,e[46]=k,e[47]=$):$=e[47],$};export{it as SchedulePanel};
1
+ import{c as V}from"react/compiler-runtime";import{useState as G}from"react";import{D as we}from"../packem_shared/studio-DE7i2--m.mjs";import{B as le}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as j,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as ee,c as O,a as te,b as Q,d as se,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ne,u as xe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as re}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as ie,f as Z,j as ge,b as de,c as ve,d as ke}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as R}from"react/jsx-runtime";import{I as Se}from"../packem_shared/input-CXhxesPC.mjs";import{u as Ce}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{c as Te}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ae}from"@lunora/react";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{u as ye}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{ScheduledJobs as $e}from"../packem_shared/ScheduledJobs-QCTRdugp.mjs";const Ne={failed:"destructive",skipped:"warning",succeeded:"success"},Ie=25,Ee=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,Re=t=>{const e=V(39),{inFlight:i,last:n}=t,l=z();if(i!==void 0){let h;e[0]!==l?(h=l("running"),e[0]=l,e[1]=h):h=e[1];let g;e[2]!==h?(g=s(Y,{variant:"info",children:h}),e[2]=h,e[3]=g):g=e[3];let b;e[4]!==i.startedAt?(b=ie(i.startedAt,"—"),e[4]=i.startedAt,e[5]=b):b=e[5];let w;e[6]!==b?(w=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=w):w=e[7];let S;e[8]!==i.skipped||e[9]!==l?(S=i.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:l("{count} ticks skipped",{count:i.skipped})}),e[8]=i.skipped,e[9]=l,e[10]=S):S=e[10];let N;return e[11]!==g||e[12]!==w||e[13]!==S?(N=R("span",{className:"flex items-center gap-2",children:[g,w,S]}),e[11]=g,e[12]=w,e[13]=S,e[14]=N):N=e[14],N}if(n===void 0){let h;e[15]!==l?(h=l("never"),e[15]=l,e[16]=h):h=e[16];let g;return e[17]!==h?(g=s("span",{className:"text-xs text-muted-foreground",children:h}),e[17]=h,e[18]=g):g=e[18],g}let a;e[19]!==l?(a=l("failed"),e[19]=l,e[20]=a):a=e[20];let r;e[21]!==l?(r=l("skipped"),e[21]=l,e[22]=r):r=e[22];let o;e[23]!==l?(o=l("succeeded"),e[23]=l,e[24]=o):o=e[24];let u;e[25]!==a||e[26]!==r||e[27]!==o?(u={failed:a,skipped:r,succeeded:o},e[25]=a,e[26]=r,e[27]=o,e[28]=u):u=e[28];const v=u,f=Ne[n.status],c=v[n.status];let m;e[29]!==f||e[30]!==c?(m=s(Y,{variant:f,children:c}),e[29]=f,e[30]=c,e[31]=m):m=e[31];let y;e[32]!==n.startedAt?(y=ie(n.startedAt,"—"),e[32]=n.startedAt,e[33]=y):y=e[33];let p;e[34]!==y?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:y}),e[34]=y,e[35]=p):p=e[35];let d;return e[36]!==m||e[37]!==p?(d=R("span",{className:"flex items-center gap-2",children:[m,p]}),e[36]=m,e[37]=p,e[38]=d):d=e[38],d},Le=t=>{const e=V(80),{runs:i}=t,n=z();if(i.length===0)return;let l,a,r,o,u,v,f,c,m,y,p;if(e[0]!==i||e[1]!==n){const S=i.toSorted(Oe).slice(0,Ie);let N;e[13]!==n?(N=n("failed"),e[13]=n,e[14]=N):N=e[14];let T;e[15]!==n?(T=n("skipped"),e[15]=n,e[16]=T):T=e[16];let L;e[17]!==n?(L=n("succeeded"),e[17]=n,e[18]=L):L=e[18];let $;e[19]!==L||e[20]!==N||e[21]!==T?($={failed:N,skipped:T,succeeded:L},e[19]=L,e[20]=N,e[21]=T,e[22]=$):$=e[22];const A=$;m="flex flex-col gap-2",y="cron-run-history";let C;e[23]!==n?(C=n("Recent runs"),e[23]=n,e[24]=C):C=e[24],e[25]!==C?(p=s("h3",{className:"text-sm font-medium",children:C}),e[25]=C,e[26]=p):p=e[26],o=j,c="overflow-hidden py-0",r=X,f="px-0",a=ee;let k;e[27]!==n?(k=n("name"),e[27]=n,e[28]=k):k=e[28];let x;e[29]!==k?(x=s(O,{children:k}),e[29]=k,e[30]=x):x=e[30];let I;e[31]!==n?(I=n("status"),e[31]=n,e[32]=I):I=e[32];let D;e[33]!==I?(D=s(O,{children:I}),e[33]=I,e[34]=D):D=e[34];let E;e[35]!==n?(E=n("started"),e[35]=n,e[36]=E):E=e[36];let _;e[37]!==E?(_=s(O,{children:E}),e[37]=E,e[38]=_):_=e[38];let F;e[39]!==n?(F=n("duration"),e[39]=n,e[40]=F):F=e[40];let B;e[41]!==F?(B=s(O,{children:F}),e[41]=F,e[42]=B):B=e[42];let J;e[43]!==n?(J=n("skipped"),e[43]=n,e[44]=J):J=e[44];let U;e[45]!==J?(U=s(O,{children:J}),e[45]=J,e[46]=U):U=e[46];let P;e[47]!==n?(P=n("error"),e[47]=n,e[48]=P):P=e[48];let M;e[49]!==P?(M=s(O,{children:P}),e[49]=P,e[50]=M):M=e[50],e[51]!==x||e[52]!==D||e[53]!==_||e[54]!==B||e[55]!==U||e[56]!==M?(v=s(te,{children:R(Q,{children:[x,D,_,B,U,M]})}),e[51]=x,e[52]=D,e[53]=_,e[54]=B,e[55]=U,e[56]=M,e[57]=v):v=e[57],l=se;let W;e[58]!==A?(W=H=>R(Q,{"data-testid":`cron-run-row-${H.runId}`,children:[s(K,{children:H.name}),s(K,{children:s(Y,{variant:Ne[H.status],children:A[H.status]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(H.startedAt,"—")}),s(K,{className:"tabular-nums",children:H.status==="skipped"?"":Ee(H.durationMs)}),s(K,{className:"tabular-nums",children:H.skipped>0?H.skipped:""}),s(K,{className:"text-xs text-destructive",children:H.error??""})]},H.runId),e[58]=A,e[59]=W):W=e[59],u=S.map(W),e[0]=i,e[1]=n,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=v,e[8]=f,e[9]=c,e[10]=m,e[11]=y,e[12]=p}else l=e[2],a=e[3],r=e[4],o=e[5],u=e[6],v=e[7],f=e[8],c=e[9],m=e[10],y=e[11],p=e[12];let d;e[60]!==l||e[61]!==u?(d=s(l,{children:u}),e[60]=l,e[61]=u,e[62]=d):d=e[62];let h;e[63]!==a||e[64]!==v||e[65]!==d?(h=R(a,{children:[v,d]}),e[63]=a,e[64]=v,e[65]=d,e[66]=h):h=e[66];let g;e[67]!==r||e[68]!==f||e[69]!==h?(g=s(r,{className:f,children:h}),e[67]=r,e[68]=f,e[69]=h,e[70]=g):g=e[70];let b;e[71]!==o||e[72]!==g||e[73]!==c?(b=s(o,{className:c,children:g}),e[71]=o,e[72]=g,e[73]=c,e[74]=b):b=e[74];let w;return e[75]!==b||e[76]!==m||e[77]!==y||e[78]!==p?(w=R("div",{className:m,"data-testid":y,children:[p,b]}),e[75]=b,e[76]=m,e[77]=y,e[78]=p,e[79]=w):w=e[79],w};function Oe(t,e){return e.startedAt-t.startedAt}const Ke=()=>{const t=V(50),e=z(),i=Ce(""),[n,l]=G(""),[a,r]=G(void 0),[o,u]=G(!1);if(i.unavailable)return null;let v;t[0]!==i?(v=i.pending("cron"),t[0]=i,t[1]=v):v=t[1];const f=v;let c;t[2]!==i?(c=i.reason("cron"),t[2]=i,t[3]=c):c=t[3];const m=c;let y;t[4]!==n||t[5]!==i?(y=()=>{const E=n.trim();if(E==="")return;Z((async()=>{const F=await i.suggestCron(E);u(!1),r(F)})())},t[4]=n,t[5]=i,t[6]=y):y=t[6];const p=y;let d;t[7]!==a?(d=()=>{const E="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(E===void 0||a===void 0)return;Z((async()=>{try{await E.writeText(a),u(!0)}catch{u(!1)}})())},t[7]=a,t[8]=d):d=t[8];const h=d;let g;t[9]!==e?(g=e("Describe a schedule"),t[9]=e,t[10]=g):g=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{l(E.target.value)},t[11]=b):b=t[11];let w;t[12]!==p?(w=E=>{E.key==="Enter"&&(E.preventDefault(),p())},t[12]=p,t[13]=w):w=t[13];let S;t[14]!==e?(S=e("Describe a schedule"),t[14]=e,t[15]=S):S=t[15];let N;t[16]!==f||t[17]!==n||t[18]!==g||t[19]!==w||t[20]!==S?(N=s(Se,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:f,onChange:b,onKeyDown:w,placeholder:S,value:n}),t[16]=f,t[17]=n,t[18]=g,t[19]=w,t[20]=S,t[21]=N):N=t[21];const T=f&&"opacity-60";let L;t[22]!==T?(L=Te("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",T),t[22]=T,t[23]=L):L=t[23];let $;t[24]!==f||t[25]!==n?($=f||n.trim()==="",t[24]=f,t[25]=n,t[26]=$):$=t[26];let A;t[27]!==f||t[28]!==e?(A=e(f?"Thinking…":"Suggest schedule"),t[27]=f,t[28]=e,t[29]=A):A=t[29];let C;t[30]!==p||t[31]!==L||t[32]!==$||t[33]!==A?(C=s("button",{className:L,"data-testid":"cron-assistant-generate",disabled:$,onClick:p,type:"button",children:A}),t[30]=p,t[31]=L,t[32]=$,t[33]=A,t[34]=C):C=t[34];let k;t[35]!==C||t[36]!==N?(k=R("div",{className:"flex items-center gap-2",children:[N,C]}),t[35]=C,t[36]=N,t[37]=k):k=t[37];let x;t[38]!==o||t[39]!==h||t[40]!==a||t[41]!==e?(x=a!==void 0&&R("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:a}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:h,type:"button",children:e(o?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=o,t[39]=h,t[40]=a,t[41]=e,t[42]=x):x=t[42];let I;t[43]!==m||t[44]!==e?(I=m!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(m==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=m,t[44]=e,t[45]=I):I=t[45];let D;return t[46]!==k||t[47]!==x||t[48]!==I?(D=R("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[k,x,I]}),t[46]=k,t[47]=x,t[48]=I,t[49]=D):D=t[49],D},De={kind:"idle"},_e="SCHEDULER_NOT_CONFIGURED",ue={inFlight:[],runs:[]},Fe=(t,e,i)=>i!==void 0?i:e===void 0?n=>t.runCronJob(n):void 0,Je=({loadCronJobs:t,loadCronRuns:e,runCronJob:i}={})=>{const n=ae(),l=z(),[a,r]=G({}),o=ne(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>n.getCronJobs()))()),{data:u,error:v}=o,f=e??(t===void 0?()=>n.listCronRuns():void 0),c=ne(["lunora-cron-runs",e?"custom":"default"],async()=>f===void 0?ue:f().catch(d=>{if(ge(d)===_e)return ue;throw d})),m=c.data??ue;re(()=>c.poll(),f!==void 0);const y=Fe(n,t,i),p=async d=>{if(y!==void 0){r(h=>({...h,[d]:{kind:"running"}}));try{await y(d),r(h=>({...h,[d]:{kind:"ok"}})),o.refetch(),c.refetch()}catch(h){r(g=>({...g,[d]:{kind:"error",message:de(h)}}))}}};return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Ke,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:c.error}),u?.length===0&&s(oe,{description:l("Triggers declared with the cronJobs() builder appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:l("No cron triggers.")}),u!==void 0&&u.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"cron-table",children:[s(te,{children:R(Q,{children:[s(O,{children:l("name")}),s(O,{children:l("schedule")}),s(O,{children:l("target")}),s(O,{children:l("shard")}),s(O,{children:l("last run")}),y!==void 0&&s(O,{"aria-label":l("Actions")})]})}),s(se,{children:u.map(d=>{const h=a[d.name]??De;return R(Q,{"data-testid":`cron-row-${d.name}`,children:[s(K,{children:d.name}),s(K,{className:"font-mono text-xs tabular-nums",children:d.cron}),s(K,{children:R("span",{className:"flex items-center gap-2",children:[d.workflow===void 0?s(Y,{variant:"outline",children:l("function")}):s(Y,{variant:"secondary",children:l("workflow")}),s("span",{className:"font-mono text-xs",children:d.workflow??d.functionPath})]})}),s(K,{children:d.shardKey??""}),s(K,{"data-testid":`cron-last-run-${d.name}`,children:s(Re,{inFlight:m.inFlight.find(g=>g.name===d.name),last:m.runs.find(g=>g.name===d.name)})}),y!==void 0&&s(K,{className:"text-right",children:R("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${d.name}`,children:l("ran")}),h.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${d.name}`,role:"alert",children:h.message}),s(me,{confirmLabel:l("Run now?"),disabled:h.kind==="running",onConfirm:()=>{Z(p(d.name))},testId:`cron-run-${d.name}`,children:h.kind==="running"?l("Running…"):l("Run now")})]})})]},`${d.cron}:${d.name}`)})})]})})}),s(Le,{runs:m.runs})]})},Me=t=>Number.isFinite(t)?ie(t,"—"):"—",Pe=t=>{const e=V(34);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n,removeJob:l,retryJob:a}=i,r=ae(),o=z();let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-dead-jobs"],e[2]=u):u=e[2];let v;e[3]!==r||e[4]!==n?(v=async()=>(await(n??(()=>r.listDeadJobs()))()).toSorted(qe),e[3]=r,e[4]=n,e[5]=v):v=e[5];const f=ne(u,v),c=f.data,[m,y]=G(void 0),p=f.error??m,d=n===void 0;let h;e[6]!==r||e[7]!==d||e[8]!==a?(h=a??(d?x=>r.retryDeadJob(x):void 0),e[6]=r,e[7]=d,e[8]=a,e[9]=h):h=e[9];const g=h;let b;e[10]!==r||e[11]!==d||e[12]!==l?(b=l??(d?x=>r.removeDeadJob(x):void 0),e[10]=r,e[11]=d,e[12]=l,e[13]=b):b=e[13];const w=b;let S;e[14]!==f?(S=()=>f.poll(),e[14]=f,e[15]=S):S=e[15],re(S,!0);let N;e[16]!==f?(N=async x=>{y(void 0);try{await x,f.refetch()}catch(I){y(de(I))}},e[16]=f,e[17]=N):N=e[17];const T=N,L=g!==void 0||w!==void 0;let $;e[18]!==p?($=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=$):$=e[19];let A;e[20]!==c?.length||e[21]!==o?(A=c?.length===0&&s(oe,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=c?.length,e[21]=o,e[22]=A):A=e[22];let C;e[23]!==T||e[24]!==L||e[25]!==c||e[26]!==w||e[27]!==g||e[28]!==o?(C=c!==void 0&&c.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"dlq-table",children:[s(te,{children:R(Q,{children:[s(O,{children:o("function")}),s(O,{children:o("attempts")}),s(O,{children:o("last tried")}),s(O,{children:o("pool")}),s(O,{children:o("shard")}),s(O,{children:o("id")}),L&&s(O,{"aria-label":o("Actions")})]})}),s(se,{children:c.map(x=>R(Q,{"data-testid":`dlq-row-${x.id}`,children:[s(K,{className:"font-mono text-xs",children:x.workflow??x.functionPath}),s(K,{className:"tabular-nums",children:x.attempts??0}),s(K,{className:"text-muted-foreground tabular-nums",children:Me(x.scheduledFor)}),s(K,{className:"font-mono text-xs",children:x.pool??""}),s(K,{children:x.shardKey??""}),s(K,{className:"font-mono text-xs",children:x.id}),L&&s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&s(le,{"data-testid":`dlq-retry-${x.id}`,onClick:()=>{Z(T(g(x.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),w!==void 0&&s(me,{confirmLabel:o("Drop job?"),onConfirm:()=>{Z(T(w(x.id)))},testId:`dlq-remove-${x.id}`,children:o("Drop")})]})})]},x.id))})]})})}),e[23]=T,e[24]=L,e[25]=c,e[26]=w,e[27]=g,e[28]=o,e[29]=C):C=e[29];let k;return e[30]!==C||e[31]!==$||e[32]!==A?(k=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,A,C]}),e[30]=C,e[31]=$,e[32]=A,e[33]=k):k=e[33],k};function qe(t,e){return(e.attempts??0)-(t.attempts??0)}const Ue={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Be=t=>{const e=V(47);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n}=i,l=ae(),a=z();let r;e[2]!==l||e[3]!==n?(r=n??(async q=>l.listScheduledHistory(q===void 0?{}:{cursor:q})),e[2]=l,e[3]=n,e[4]=r):r=e[4];const o=r,u=n?"custom":"default";let v;e[5]!==u?(v=["lunora-job-history",u],e[5]=u,e[6]=v):v=e[6];let f;e[7]!==o?(f=async()=>o(),e[7]=o,e[8]=f):f=e[8];const c=ne(v,f),[m,y]=G(void 0),[p,d]=G(!1),[h,g]=G(void 0),b=c.data?.records;let w;e[9]!==b?(w=new Set(b?.map(He)),e[9]=b,e[10]=w):w=e[10];const S=w,N=b===void 0?void 0:[...b,...(m?.records??[]).filter(q=>!S.has(q.id))],T=m===void 0?c.data?.cursor:m.cursor;let L;e[11]!==o||e[12]!==T?(L=async()=>{d(!0),g(void 0);try{const q=await o(T);y(pe=>({cursor:q.cursor,records:[...pe?.records??[],...q.records]})),d(!1)}catch(q){g(de(q)),d(!1)}},e[11]=o,e[12]=T,e[13]=L):L=e[13];const $=L;let A;e[14]!==a?(A=a("canceled"),e[14]=a,e[15]=A):A=e[15];let C;e[16]!==a?(C=a("failed"),e[16]=a,e[17]=C):C=e[17];let k;e[18]!==a?(k=a("pending"),e[18]=a,e[19]=k):k=e[19];let x;e[20]!==a?(x=a("running"),e[20]=a,e[21]=x):x=e[21];let I;e[22]!==a?(I=a("succeeded"),e[22]=a,e[23]=I):I=e[23];let D;e[24]!==k||e[25]!==x||e[26]!==I||e[27]!==A||e[28]!==C?(D={canceled:A,failed:C,pending:k,running:x,succeeded:I},e[24]=k,e[25]=x,e[26]=I,e[27]=A,e[28]=C,e[29]=D):D=e[29];const E=D;let _;e[30]!==c?(_=()=>c.poll(),e[30]=c,e[31]=_):_=e[31],re(_,m===void 0);const F="flex flex-col gap-3",B="lunora-job-history";let J;e[32]!==c.error?(J=c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:c.error}),e[32]=c.error,e[33]=J):J=e[33];const U=N?.length===0&&s(oe,{description:a("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:a("No finished jobs.")}),P=N!==void 0&&N.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"job-history-table",children:[s(te,{children:R(Q,{children:[s(O,{children:a("function")}),s(O,{children:a("state")}),s(O,{children:a("finished")}),s(O,{children:a("error")}),s(O,{children:a("id")})]})}),s(se,{children:N.map(q=>R(Q,{"data-testid":`job-history-row-${q.id}`,children:[s(K,{className:"font-mono text-xs",children:q.workflow??q.functionPath}),s(K,{children:s(Y,{"data-testid":`job-history-state-${q.id}`,variant:Ue[q.state],children:E[q.state]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(q.completedAt,"—")}),s(K,{className:"text-xs text-destructive",children:q.error??""}),s(K,{className:"font-mono text-xs",children:q.id})]},q.id))})]})})});let M;e[34]!==h?(M=h!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:h}),e[34]=h,e[35]=M):M=e[35];let W;e[36]!==p||e[37]!==T||e[38]!==$||e[39]!==a?(W=T!==void 0&&s("div",{children:s(le,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{Z($())},variant:"outline",children:a(p?"Loading…":"Load more")})}),e[36]=p,e[37]=T,e[38]=$,e[39]=a,e[40]=W):W=e[40];let H;return e[41]!==J||e[42]!==U||e[43]!==P||e[44]!==M||e[45]!==W?(H=R("div",{className:F,"data-testid":B,children:[J,U,P,M,W]}),e[41]=J,e[42]=U,e[43]=P,e[44]=M,e[45]=W,e[46]=H):H=e[46],H};function He(t){return t.id}const Qe=ve(ce.dropOutboxEntry),Ve=ve(ce.retryOutboxEntry),ze=()=>{const t=V(8),e=z();let i;t[0]!==e?(i=e("Jobs whose mutation committed but that the scheduler has not accepted yet wait here."),t[0]=e,t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 4h16v12H4zM4 16l4 4h8l4-4"})}),t[2]=n):n=t[2];let l;t[3]!==e?(l=e("Nothing is waiting for the scheduler."),t[3]=e,t[4]=l):l=t[4];let a;return t[5]!==i||t[6]!==l?(a=s(oe,{description:i,icon:n,testId:"outbox-empty",title:l}),t[5]=i,t[6]=l,t[7]=a):a=t[7],a},We=t=>{const e=V(58),{entry:i,onAct:n}=t,l=z(),a=`outbox-row-${i.id}`;let r;e[0]!==i.target||e[1]!==l?(r=i.target??l("unreadable"),e[0]=i.target,e[1]=l,e[2]=r):r=e[2];let o;e[3]!==r?(o=s(K,{className:"font-mono text-xs",children:r}),e[3]=r,e[4]=o):o=e[4];const u=i.parked?"destructive":"secondary";let v;e[5]!==i.parked||e[6]!==l?(v=i.parked?l("parked"):l("retrying"),e[5]=i.parked,e[6]=l,e[7]=v):v=e[7];let f;e[8]!==u||e[9]!==v?(f=s(Y,{variant:u,children:v}),e[8]=u,e[9]=v,e[10]=f):f=e[10];let c;e[11]!==i.forever||e[12]!==l?(c=i.forever&&s(Y,{variant:"outline",children:l("forever")}),e[11]=i.forever,e[12]=l,e[13]=c):c=e[13];let m;e[14]!==f||e[15]!==c?(m=s(K,{children:R("div",{className:"flex gap-1",children:[f,c]})}),e[14]=f,e[15]=c,e[16]=m):m=e[16];let y;e[17]!==i.attempts?(y=s(K,{className:"tabular-nums",children:i.attempts}),e[17]=i.attempts,e[18]=y):y=e[18];let p;e[19]!==i.nextAttemptAt||e[20]!==i.parked?(p=i.parked?"—":ie(i.nextAttemptAt,"—"),e[19]=i.nextAttemptAt,e[20]=i.parked,e[21]=p):p=e[21];let d;e[22]!==p?(d=s(K,{className:"text-muted-foreground tabular-nums",children:p}),e[22]=p,e[23]=d):d=e[23];let h;e[24]!==i.id?(h=s(K,{className:"font-mono text-xs",children:i.id}),e[24]=i.id,e[25]=h):h=e[25];const g=`outbox-retry-${i.id}`;let b;e[26]!==i.id||e[27]!==n?(b=()=>{Z(n(Ve,i.id))},e[26]=i.id,e[27]=n,e[28]=b):b=e[28];let w;e[29]!==l?(w=l("Retry now"),e[29]=l,e[30]=w):w=e[30];let S;e[31]!==g||e[32]!==b||e[33]!==w?(S=s(le,{"data-testid":g,onClick:b,size:"sm",type:"button",variant:"outline",children:w}),e[31]=g,e[32]=b,e[33]=w,e[34]=S):S=e[34];let N;e[35]!==l?(N=l("Drop job?"),e[35]=l,e[36]=N):N=e[36];let T;e[37]!==i.id||e[38]!==n?(T=()=>{Z(n(Qe,i.id))},e[37]=i.id,e[38]=n,e[39]=T):T=e[39];const L=`outbox-drop-${i.id}`;let $;e[40]!==l?($=l("Drop"),e[40]=l,e[41]=$):$=e[41];let A;e[42]!==N||e[43]!==T||e[44]!==L||e[45]!==$?(A=s(me,{confirmLabel:N,onConfirm:T,testId:L,children:$}),e[42]=N,e[43]=T,e[44]=L,e[45]=$,e[46]=A):A=e[46];let C;e[47]!==S||e[48]!==A?(C=s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[S,A]})}),e[47]=S,e[48]=A,e[49]=C):C=e[49];let k;return e[50]!==a||e[51]!==d||e[52]!==h||e[53]!==C||e[54]!==o||e[55]!==m||e[56]!==y?(k=R(Q,{"data-testid":a,children:[o,m,y,d,h,C]}),e[50]=a,e[51]=d,e[52]=h,e[53]=C,e[54]=o,e[55]=m,e[56]=y,e[57]=k):k=e[57],k},Ge=t=>{const e=V(41),{entries:i,onAct:n}=t,l=z();let a;e[0]!==l?(a=l("function"),e[0]=l,e[1]=a):a=e[1];let r;e[2]!==a?(r=s(O,{children:a}),e[2]=a,e[3]=r):r=e[3];let o;e[4]!==l?(o=l("state"),e[4]=l,e[5]=o):o=e[5];let u;e[6]!==o?(u=s(O,{children:o}),e[6]=o,e[7]=u):u=e[7];let v;e[8]!==l?(v=l("attempts"),e[8]=l,e[9]=v):v=e[9];let f;e[10]!==v?(f=s(O,{children:v}),e[10]=v,e[11]=f):f=e[11];let c;e[12]!==l?(c=l("next attempt"),e[12]=l,e[13]=c):c=e[13];let m;e[14]!==c?(m=s(O,{children:c}),e[14]=c,e[15]=m):m=e[15];let y;e[16]!==l?(y=l("id"),e[16]=l,e[17]=y):y=e[17];let p;e[18]!==y?(p=s(O,{children:y}),e[18]=y,e[19]=p):p=e[19];let d;e[20]!==l?(d=l("Actions"),e[20]=l,e[21]=d):d=e[21];let h;e[22]!==d?(h=s(O,{"aria-label":d}),e[22]=d,e[23]=h):h=e[23];let g;e[24]!==p||e[25]!==h||e[26]!==r||e[27]!==u||e[28]!==f||e[29]!==m?(g=s(te,{children:R(Q,{children:[r,u,f,m,p,h]})}),e[24]=p,e[25]=h,e[26]=r,e[27]=u,e[28]=f,e[29]=m,e[30]=g):g=e[30];let b;if(e[31]!==i||e[32]!==n){let N;e[34]!==n?(N=T=>s(We,{entry:T,onAct:n},T.id),e[34]=n,e[35]=N):N=e[35],b=i.map(N),e[31]=i,e[32]=n,e[33]=b}else b=e[33];let w;e[36]!==b?(w=s(se,{children:b}),e[36]=b,e[37]=w):w=e[37];let S;return e[38]!==g||e[39]!==w?(S=s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"outbox-table",children:[g,w]})})}),e[38]=g,e[39]=w,e[40]=S):S=e[40],S},Ye=t=>{const e=V(11),{cursor:i,nextCursor:n,onFirst:l,onNext:a}=t,r=z();if(i===void 0&&n===void 0)return;let o;e[0]!==i||e[1]!==l||e[2]!==r?(o=i!==void 0&&s(le,{"data-testid":"outbox-first-page",onClick:l,size:"sm",type:"button",variant:"outline",children:r("First page")}),e[0]=i,e[1]=l,e[2]=r,e[3]=o):o=e[3];let u;e[4]!==n||e[5]!==a||e[6]!==r?(u=n!==void 0&&s(le,{"data-testid":"outbox-next-page",onClick:()=>{a(n)},size:"sm",type:"button",variant:"outline",children:r("Next page")}),e[4]=n,e[5]=a,e[6]=r,e[7]=u):u=e[7];let v;return e[8]!==o||e[9]!==u?(v=R("div",{className:"flex justify-end gap-1.5",children:[o,u]}),e[8]=o,e[9]=u,e[10]=v):v=e[10],v},je=t=>{const e=V(38);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n}=i,l=Ae(),a=z(),{queryShardKey:r,setShardKey:o,shardKey:u}=ye(n);let v;e[2]!==r?(v={cursor:void 0,shardKey:r},e[2]=r,e[3]=v):v=e[3];const[f,c]=G(v);f.shardKey!==r&&c({cursor:void 0,shardKey:r});const m=f.shardKey===r?f.cursor:void 0,y=u.trim()!==r;let p;e[4]!==m?(p=m===void 0?{}:{cursor:m},e[4]=m,e[5]=p):p=e[5];let d;e[6]!==r?(d={shardKey:r},e[6]=r,e[7]=d):d=e[7];const{data:h,error:g,poll:b,refetch:w}=xe(ce.getScheduleOutbox,p,d),S=y?void 0:h?.entries,N=y?void 0:h?.nextCursor,[T,L]=G(void 0),$=g??(T?.shardKey===r?T.message:void 0);re(b,!0);let A;e[8]!==l||e[9]!==r||e[10]!==w||e[11]!==a?(A=async(J,U)=>{L(void 0);try{(await l.query(J,{id:U},ke(r))).retried===!1&&L({message:a("That job is no longer in the outbox."),shardKey:r}),w()}catch(P){L({message:de(P),shardKey:r})}},e[8]=l,e[9]=r,e[10]=w,e[11]=a,e[12]=A):A=e[12];const C=A;let k;e[13]!==o||e[14]!==u?(k=s(be,{onChange:o,testId:"outbox-shard-input",value:u}),e[13]=o,e[14]=u,e[15]=k):k=e[15];let x;e[16]!==$?(x=$!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"outbox-error",role:"alert",children:$}),e[16]=$,e[17]=x):x=e[17];let I;e[18]!==m||e[19]!==S?.length?(I=S?.length===0&&m===void 0&&s(ze,{}),e[18]=m,e[19]=S?.length,e[20]=I):I=e[20];let D;e[21]!==C||e[22]!==S?(D=S!==void 0&&S.length>0&&s(Ge,{entries:S,onAct:C}),e[21]=C,e[22]=S,e[23]=D):D=e[23];let E,_;e[24]!==r?(E=()=>{c({cursor:void 0,shardKey:r})},_=J=>{c({cursor:J,shardKey:r})},e[24]=r,e[25]=E,e[26]=_):(E=e[25],_=e[26]);let F;e[27]!==m||e[28]!==N||e[29]!==E||e[30]!==_?(F=s(Ye,{cursor:m,nextCursor:N,onFirst:E,onNext:_}),e[27]=m,e[28]=N,e[29]=E,e[30]=_,e[31]=F):F=e[31];let B;return e[32]!==F||e[33]!==k||e[34]!==x||e[35]!==I||e[36]!==D?(B=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-schedule-outbox",children:[k,x,I,D,F]}),e[32]=F,e[33]=k,e[34]=x,e[35]=I,e[36]=D,e[37]=B):B=e[37],B},Xe="scheduler.lag_ms",he=t=>{const e=t.attributes?.function;return typeof e=="string"?e:t.functionPath},fe=t=>{const e=V(8),{label:i,testId:n,value:l}=t;let a;e[0]!==i?(a=s("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=a):a=e[1];let r;e[2]!==n||e[3]!==l?(r=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:l}),e[2]=n,e[3]=l,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=s(j,{className:"flex-1 py-0",children:R(X,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},Ze=t=>{const e=V(65);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadStatus:l}=i,a=ae(),r=z(),o=l===void 0;let u;e[2]!==o?(u=["lunora-scheduler-status",o],e[2]=o,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==l?(v=async()=>{const J=await(l??(()=>a.schedulerStatus()))();return{...J,pools:J.pools.toSorted(et)}},e[4]=a,e[5]=l,e[6]=v):v=e[6];const f=ne(u,v),{data:c,error:m}=f,{queryShardKey:y,setShardKey:p,shardKey:d}=ye(n);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h={},e[7]=h):h=e[7];let g;e[8]!==y?(g={shardKey:y},e[8]=y,e[9]=g):g=e[9];const b=xe(ce.getMetricSeries,h,g),{data:w,errorSource:S}=b;let N;e[10]!==S||e[11]!==b.error?(N=ge(S)==="FUNCTION_NOT_FOUND"?null:b.error,e[10]=S,e[11]=b.error,e[12]=N):N=e[12];const T=N;let L;e[13]!==f?(L=()=>f.poll(),e[13]=f,e[14]=L):L=e[14],re(L,!0);let $;e[15]!==b?($=()=>b.poll(),e[15]=b,e[16]=$):$=e[16],re($,!0);let A,C,k,x,I,D,E,_;if(e[17]!==m||e[18]!==w||e[19]!==T||e[20]!==p||e[21]!==d||e[22]!==c||e[23]!==r){const J=(Array.isArray(w?.series)?w.series:[]).filter(tt).toSorted(st);A="flex flex-col gap-3",C="lunora-scheduler-pools",e[32]!==m?(k=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:m}),e[32]=m,e[33]=k):k=e[33],e[34]!==c||e[35]!==r?(x=c!==void 0&&R("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(fe,{label:r("backlog"),testId:"pools-backlog",value:c.backlog}),s(fe,{label:r("in flight"),testId:"pools-inflight",value:c.inFlight}),s(fe,{label:r("pools"),testId:"pools-count",value:c.pools.length})]}),e[34]=c,e[35]=r,e[36]=x):x=e[36],e[37]!==c?.pools.length||e[38]!==r?(I=c?.pools.length===0&&s(oe,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[37]=c?.pools.length,e[38]=r,e[39]=I):I=e[39];let U;e[40]!==p||e[41]!==d?(U=s(be,{onChange:p,testId:"lag-shard-input",value:d}),e[40]=p,e[41]=d,e[42]=U):U=e[42];let P;e[43]!==r?(P=r("Start lag per job on this shard since it last woke; the series reset when the shard hibernates."),e[43]=r,e[44]=P):P=e[44];let M;e[45]!==P?(M=s("p",{className:"text-xs text-muted-foreground","data-testid":"lag-scope",children:P}),e[45]=P,e[46]=M):M=e[46],e[47]!==U||e[48]!==M?(D=R("div",{className:"flex flex-wrap items-center gap-3",children:[U,M]}),e[47]=U,e[48]=M,e[49]=D):D=e[49],e[50]!==T?(E=T!==null&&s("p",{className:"text-sm text-destructive","data-testid":"lag-error",role:"alert",children:T}),e[50]=T,e[51]=E):E=e[51],_=T===null&&J.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"lag-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("function")}),s(O,{children:r("runs")}),s(O,{children:r("mean lag (ms)")}),s(O,{children:r("max lag (ms)")}),s(O,{children:r("last lag (ms)")})]})}),s(se,{children:J.map(lt)})]})})}),e[17]=m,e[18]=w,e[19]=T,e[20]=p,e[21]=d,e[22]=c,e[23]=r,e[24]=A,e[25]=C,e[26]=k,e[27]=x,e[28]=I,e[29]=D,e[30]=E,e[31]=_}else A=e[24],C=e[25],k=e[26],x=e[27],I=e[28],D=e[29],E=e[30],_=e[31];let F;e[52]!==c||e[53]!==r?(F=c!==void 0&&c.pools.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"pools-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("pool")}),s(O,{children:r("queued")}),s(O,{children:r("in flight")}),s(O,{children:r("max concurrency")})]})}),s(se,{children:c.pools.map(rt)})]})})}),e[52]=c,e[53]=r,e[54]=F):F=e[54];let B;return e[55]!==A||e[56]!==C||e[57]!==k||e[58]!==x||e[59]!==I||e[60]!==D||e[61]!==E||e[62]!==_||e[63]!==F?(B=R("div",{className:A,"data-testid":C,children:[k,x,I,D,E,_,F]}),e[55]=A,e[56]=C,e[57]=k,e[58]=x,e[59]=I,e[60]=D,e[61]=E,e[62]=_,e[63]=F,e[64]=B):B=e[64],B};function et(t,e){return e.queued-t.queued}function tt(t){return t.name===Xe&&t.kind==="histogram"&&t.count>0}function st(t,e){return e.max-t.max}function lt(t){return R(Q,{"data-testid":`lag-row-${he(t)}`,children:[s(K,{className:"font-mono text-xs",children:he(t)}),s(K,{className:"tabular-nums",children:t.count}),s(K,{className:"tabular-nums",children:Math.round(t.sum/t.count)}),s(K,{className:"tabular-nums",children:t.max}),s(K,{className:"tabular-nums",children:t.last})]},he(t))}function rt(t){return R(Q,{"data-testid":`pools-row-${t.name}`,children:[s(K,{className:"font-mono text-xs",children:t.name}),s(K,{className:"tabular-nums",children:t.queued}),R(K,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(K,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const it=["jobs","outbox","history","dead","pools","cron"],It=t=>{const e=V(55);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadCronJobs:l,scheduledCancel:a,scheduledLoad:r}=i,o=z(),[u,v]=G("jobs");let f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let c;e[4]!==o?(c=o("Dead letter"),e[4]=o,e[5]=c):c=e[5];let m;e[6]!==o?(m=o("History"),e[6]=o,e[7]=m):m=e[7];let y;e[8]!==o?(y=o("Scheduled jobs"),e[8]=o,e[9]=y):y=e[9];let p;e[10]!==o?(p=o("Outbox"),e[10]=o,e[11]=p):p=e[11];let d;e[12]!==o?(d=o("Pools"),e[12]=o,e[13]=d):d=e[13];let h;e[14]!==f||e[15]!==c||e[16]!==m||e[17]!==y||e[18]!==p||e[19]!==d?(h={cron:f,dead:c,history:m,jobs:y,outbox:p,pools:d},e[14]=f,e[15]=c,e[16]=m,e[17]=y,e[18]=p,e[19]=d,e[20]=h):h=e[20];const g=h;let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{v(E.currentTarget.dataset.view)},e[21]=b):b=e[21];const w=b;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=s(we,{}),e[22]=S):S=e[22];let N;e[23]!==o?(N=o("Schedule view"),e[23]=o,e[24]=N):N=e[24];let T;e[25]!==u||e[26]!==g?(T=it.map(E=>s(le,{"aria-selected":u===E,"data-testid":`schedule-view-${E}`,"data-view":E,onClick:w,role:"tab",size:"sm",type:"button",variant:u===E?"default":"outline",children:g[E]},E)),e[25]=u,e[26]=g,e[27]=T):T=e[27];let L;e[28]!==N||e[29]!==T?(L=s("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:T}),e[28]=N,e[29]=T,e[30]=L):L=e[30];let $;e[31]!==a||e[32]!==r||e[33]!==u?($=u==="jobs"&&s($e,{cancelJob:a,loadJobs:r}),e[31]=a,e[32]=r,e[33]=u,e[34]=$):$=e[34];let A;e[35]!==u?(A=u==="outbox"&&s(je,{}),e[35]=u,e[36]=A):A=e[36];let C;e[37]!==u?(C=u==="history"&&s(Be,{}),e[37]=u,e[38]=C):C=e[38];let k;e[39]!==u?(k=u==="dead"&&s(Pe,{}),e[39]=u,e[40]=k):k=e[40];let x;e[41]!==n||e[42]!==u?(x=u==="pools"&&s(Ze,{initialShardKey:n}),e[41]=n,e[42]=u,e[43]=x):x=e[43];let I;e[44]!==l||e[45]!==u?(I=u==="cron"&&s(Je,{loadCronJobs:l}),e[44]=l,e[45]=u,e[46]=I):I=e[46];let D;return e[47]!==L||e[48]!==$||e[49]!==A||e[50]!==C||e[51]!==k||e[52]!==x||e[53]!==I?(D=R("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,L,$,A,C,k,x,I]}),e[47]=L,e[48]=$,e[49]=A,e[50]=C,e[51]=k,e[52]=x,e[53]=I,e[54]=D):D=e[54],D};export{It as SchedulePanel};
@@ -1 +1 @@
1
- import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
1
+ import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-DKXm5h19.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as v,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as c,jsx as t}from"react/jsx-runtime";const w=80,G=l=>{if(l===void 0)return"";const e=JSON.stringify(l,q);return e.length>w?`${e.slice(0,w)}…`:e},J=l=>{const e=[];for(const r of l){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((s,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:s})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=l=>{const e=R(24),{initialShardKey:r}=l,n=O(),{queryShardKey:s,setShardKey:i,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==s?(f={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=f):f=e[2];const{data:o,error:a,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==a||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==i||e[8]!==m||e[9]!==n){const N=o===void 0?[]:J(o.connections);let d;e[11]!==i||e[12]!==m?(d=t(E,{onChange:i,testId:"subs-shard-input",value:m}),e[11]=i,e[12]=m,e[13]=d):d=e[13];let u;e[14]!==o||e[15]!==n?(u=o!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:o.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:o.totalSubscriptions})})]}),e[14]=o,e[15]=n,e[16]=u):u=e[16];let g;e[17]!==d||e[18]!==u?(g=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,u]}),e[17]=d,e[18]=u,e[19]=g):g=e[19];let x;e[20]!==a||e[21]!==h||e[22]!==s?(x=a!==null&&t(j,{error:h,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=h,e[22]=s,e[23]=x):x=e[23],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,a===null&&o!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),a===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:c(_,{"data-testid":"subs-table",children:[t(D,{children:c(T,{children:[t(v,{children:n("Connection")}),t(v,{children:n("Function path")}),t(v,{children:n("Table")}),t(v,{children:n("Arguments")})]})}),t(H,{children:N.map(y=>{const{subscription:k}=y,I=G(k?.args);return c(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},y.key)})})]})})})]}),e[3]=a,e[4]=h,e[5]=s,e[6]=o,e[7]=i,e[8]=m,e[9]=n,e[10]=b}else b=e[10];return b};export{ae as default};
1
+ import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as v,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as c,jsx as t}from"react/jsx-runtime";const w=80,G=l=>{if(l===void 0)return"";const e=JSON.stringify(l,q);return e.length>w?`${e.slice(0,w)}…`:e},J=l=>{const e=[];for(const r of l){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((s,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:s})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=l=>{const e=R(24),{initialShardKey:r}=l,n=O(),{queryShardKey:s,setShardKey:i,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==s?(f={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=f):f=e[2];const{data:o,error:a,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==a||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==i||e[8]!==m||e[9]!==n){const N=o===void 0?[]:J(o.connections);let d;e[11]!==i||e[12]!==m?(d=t(E,{onChange:i,testId:"subs-shard-input",value:m}),e[11]=i,e[12]=m,e[13]=d):d=e[13];let u;e[14]!==o||e[15]!==n?(u=o!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:o.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:o.totalSubscriptions})})]}),e[14]=o,e[15]=n,e[16]=u):u=e[16];let g;e[17]!==d||e[18]!==u?(g=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,u]}),e[17]=d,e[18]=u,e[19]=g):g=e[19];let x;e[20]!==a||e[21]!==h||e[22]!==s?(x=a!==null&&t(j,{error:h,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=h,e[22]=s,e[23]=x):x=e[23],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,a===null&&o!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),a===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:c(_,{"data-testid":"subs-table",children:[t(D,{children:c(T,{children:[t(v,{children:n("Connection")}),t(v,{children:n("Function path")}),t(v,{children:n("Table")}),t(v,{children:n("Arguments")})]})}),t(H,{children:N.map(y=>{const{subscription:k}=y,I=G(k?.args);return c(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},y.key)})})]})})})]}),e[3]=a,e[4]=h,e[5]=s,e[6]=o,e[7]=i,e[8]=m,e[9]=n,e[10]=b}else b=e[10];return b};export{ae 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-DKXm5h19.mjs";import{L as be}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{h as me,k as Se}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BH0iWiBv.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Ke=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(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 Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let K;e[33]!==j?(K=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=K):K=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==K||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,K,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=K,e[50]=C,e[51]=E,e[52]=W):W=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Ke,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==F?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,F]}),e[56]=t.depth,e[57]=W,e[58]=F,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(60),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==r||e[21]!==d||e[22]!==o||e[23]!==i||e[24]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,K=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[26]=C):C=e[26];const O=C;let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[27]=E):E=e[27];const W=E,F=u===null&&K.length===0&&!T;let P;e[28]!==o||e[29]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[28]=o,e[29]=i,e[30]=P):P=e[30];let z;e[31]!==s?(z=s("Search traces"),e[31]=s,e[32]=z):z=e[32];let G;e[33]!==s?(G=s("search trace, span, or function"),e[33]=s,e[34]=G):G=e[34];let H;e[35]!==d||e[36]!==z||e[37]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[35]=d,e[36]=z,e[37]=G,e[38]=H):H=e[38];let J;e[39]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[39]=c,e[40]=J):J=e[40];let Q;e[41]!==s?(Q=s("Errors only"),e[41]=s,e[42]=Q):Q=e[42];let V;e[43]!==J||e[44]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[43]=J,e[44]=Q,e[45]=V):V=e[45];let X;e[46]!==_?(X=n(be,{message:_,prefix:"tr"}),e[46]=_,e[47]=X):X=e[47];let te;e[48]!==P||e[49]!==H||e[50]!==V||e[51]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[48]=P,e[49]=H,e[50]=V,e[51]=X,e[52]=te):te=e[52];let re;e[53]!==u||e[54]!==h||e[55]!==r?(re=u!==null&&n(ge,{error:h,shardKey:r,testId:"tr-error"}),e[53]=u,e[54]=h,e[55]=r,e[56]=re):re=e[56];let se;e[57]!==F||e[58]!==s?(se=F&&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[57]=F,e[58]=s,e[59]=se):se=e[59],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:A})}),u===null&&K.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:K.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=r,e[21]=d,e[22]=o,e[23]=i,e[24]=s,e[25]=D}else D=e[25];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};
1
+ import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{L as be}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as me,k as Se}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BH0iWiBv.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Ke=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(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 Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let K;e[33]!==j?(K=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=K):K=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==K||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,K,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=K,e[50]=C,e[51]=E,e[52]=W):W=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Ke,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==F?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,F]}),e[56]=t.depth,e[57]=W,e[58]=F,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(60),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==r||e[21]!==d||e[22]!==o||e[23]!==i||e[24]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,K=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[26]=C):C=e[26];const O=C;let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[27]=E):E=e[27];const W=E,F=u===null&&K.length===0&&!T;let P;e[28]!==o||e[29]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[28]=o,e[29]=i,e[30]=P):P=e[30];let z;e[31]!==s?(z=s("Search traces"),e[31]=s,e[32]=z):z=e[32];let G;e[33]!==s?(G=s("search trace, span, or function"),e[33]=s,e[34]=G):G=e[34];let H;e[35]!==d||e[36]!==z||e[37]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[35]=d,e[36]=z,e[37]=G,e[38]=H):H=e[38];let J;e[39]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[39]=c,e[40]=J):J=e[40];let Q;e[41]!==s?(Q=s("Errors only"),e[41]=s,e[42]=Q):Q=e[42];let V;e[43]!==J||e[44]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[43]=J,e[44]=Q,e[45]=V):V=e[45];let X;e[46]!==_?(X=n(be,{message:_,prefix:"tr"}),e[46]=_,e[47]=X):X=e[47];let te;e[48]!==P||e[49]!==H||e[50]!==V||e[51]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[48]=P,e[49]=H,e[50]=V,e[51]=X,e[52]=te):te=e[52];let re;e[53]!==u||e[54]!==h||e[55]!==r?(re=u!==null&&n(ge,{error:h,shardKey:r,testId:"tr-error"}),e[53]=u,e[54]=h,e[55]=r,e[56]=re):re=e[56];let se;e[57]!==F||e[58]!==s?(se=F&&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[57]=F,e[58]=s,e[59]=se):se=e[59],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:A})}),u===null&&K.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:K.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=r,e[21]=d,e[22]=o,e[23]=i,e[24]=s,e[25]=D}else D=e[25];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};
@@ -1 +1 @@
1
- import{c as xe}from"react/compiler-runtime";import{useState as f,useRef as ce,useEffect as ge}from"react";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as te,a as re}from"../packem_shared/card-By2O8ULa.mjs";import{E as de}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ue}from"../packem_shared/input-CXhxesPC.mjs";import{T as se,a as ne,b as q,c as u,d as ae,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{T as we}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ye}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{f as V,b as U,k as Ne,d as me,c as pe}from"../packem_shared/internal-hIuTpSbx.mjs";import{ConfirmButton as be}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsxs as i,jsx as t,Fragment as ke}from"react/jsx-runtime";const Se=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Ie=["pause","resume","restart","terminate"],Ce=l=>{const e=xe(7),{busy:p,id:h,onAct:x}=l,y=le();let s;e[0]!==p||e[1]!==h||e[2]!==x||e[3]!==y?(s=Ie.map(d=>d==="restart"?t(be,{confirmLabel:y("Restart?"),disabled:p,onConfirm:()=>{x(d)},testId:`workflow-instance-${d}-${h}`,children:y(d)},d):t(X,{"data-testid":`workflow-instance-${d}-${h}`,disabled:p,onClick:()=>{x(d)},size:"sm",type:"button",variant:"ghost",children:y(d)},d)),e[0]=p,e[1]=h,e[2]=x,e[3]=y,e[4]=s):s=e[4];let c;return e[5]!==s?(c=t(ke,{children:s}),e[5]=s,e[6]=c):c=e[6],c},Te="WORKFLOWS_NOT_CONFIGURED",Oe=l=>typeof l=="object"&&l!==null&&l.code===Te,Ee=l=>{const e=l.error??l.output;if(e===void 0)return"—";try{return JSON.stringify(e,Ne)}catch{return"(unserializable)"}},_e=({loadDetail:l,loadInstances:e,readOnly:p,runAction:h,workflowName:x})=>{const y=fe(),s=le(),[c,d]=f(null),[w,D]=f(null),[b,j]=f(""),[k,S]=f(null),[$,C]=f(!1),[_,J]=f(null),N=ce(0),v=ce(0),g=ce(0),T=l??(n=>y.getWorkflowInstance(n)),O=p?void 0:h??(e===void 0?n=>y.setWorkflowInstanceStatus(n):void 0),E=async()=>{v.current+=1;const n=v.current;S(null),C(!1);const r=b===""?void 0:b;try{if(e===void 0){const o=await y.listWorkflowInstances({name:x,status:r});if(n!==v.current)return;if(o.configured===!1){d(null),C(!0);return}d(o.instances);return}const a=await e({name:x,status:r});n===v.current&&d(a)}catch(a){if(n!==v.current)return;d(null),Oe(a)?C(!0):S(U(a))}};ge(()=>{N.current+=1,g.current+=1,D(null),V(E())},[x,b]);const W=async n=>{g.current+=1;const r=g.current;S(null);try{const a=await T({id:n,name:x});r===g.current&&D(a)}catch(a){r===g.current&&S(U(a))}},A=()=>{g.current+=1,D(null)},L=async(n,r)=>{if(O===void 0)return;const a=N.current;J(n),S(null);try{await O({action:r,id:n,name:x}),a===N.current&&await E()}catch(o){S(U(o))}J(null)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[i("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),i("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n=>{j(n.target.value)},value:b,children:[t("option",{value:"",children:s("All statuses")}),Se.map(n=>t("option",{value:n,children:n},n))]})]}),k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:k}),$&&t(de,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&c!==null&&c.length===0&&t(de,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),c!==null&&c.length>0&&t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflow-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Instance id")}),t(u,{children:s("Status")}),t(u,{children:s("Created")}),t(u,{children:s("Ended")}),t(u,{"aria-label":s("Actions")})]})}),t(ae,{children:c.map(n=>i(q,{"data-testid":`workflow-instance-${n.id}`,children:[t(m,{className:"font-mono text-xs",children:n.id}),t(m,{className:"font-mono text-xs",children:n.status}),t(m,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"—"}),t(m,{className:"text-right",children:i("div",{className:"flex justify-end gap-1.5",children:[t(X,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:()=>{V(W(n.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),O!==void 0&&t(Ce,{busy:_===n.id,id:n.id,onAct:r=>{V(L(n.id,r))}},x)]})})]},n.id))})]})})}),w!==null&&t(te,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:i(re,{className:"flex flex-col gap-2 px-4 py-3",children:[i("div",{className:"flex items-center justify-between",children:[i("span",{className:"font-mono text-xs",children:[s("Steps")," · ",w.id]}),t(X,{"data-testid":"workflow-instance-detail-close",onClick:A,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),w.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):i(se,{"data-testid":"workflow-instance-steps",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Step")}),t(u,{children:s("Type")}),t(u,{children:s("Attempts")}),t(u,{children:s("Started")}),t(u,{children:s("Output")})]})}),t(ae,{children:w.steps.map((n,r)=>i(q,{"data-testid":`workflow-step-${String(r)}`,children:[t(m,{className:"font-mono text-xs",children:n.name}),t(m,{className:"text-xs text-muted-foreground",children:n.type??"—"}),t(m,{className:"tabular-nums",children:n.attempts??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.start??"—"}),t(m,{className:"font-mono text-xs text-muted-foreground",children:Ee(n)})]},`${n.name}:${String(r)}`))})]})]})})]})},We=pe(oe.createWorkflowInstance),Ae=pe(oe.getWorkflowInstanceStatus),Re=pe(oe.sendWorkflowEvent),$e=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,Ne)}catch{return"(unserializable)"}},ve=l=>{const e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},Fe=(l,e)=>l.some(p=>p.exportName===e)?e:l[0]?.exportName??"",Pe=l=>{const e=xe(72),{eventTypes:p,exportName:h,onSent:x}=l,y=fe(),s=le(),[c,d]=f(""),[w,D]=f(""),[b,j]=f(""),[k,S]=f(!1),[$,C]=f(null);let _;e[0]!==y||e[1]!==h||e[2]!==x||e[3]!==s||e[4]!==w?(_=async(R,ee)=>{try{await y.query(Re,{exportName:h,id:R,payload:ee,type:w},me(""))}catch(ie){C(U(ie));return}try{await x(h,R)}catch(ie){const he=ie;C(`${s("Event sent, but refreshing the instance failed")}: ${U(he)}`)}},e[0]=y,e[1]=h,e[2]=x,e[3]=s,e[4]=w,e[5]=_):_=e[5];const J=_;let N;e[6]!==J||e[7]!==c||e[8]!==b||e[9]!==s?(N=async()=>{const R=c.trim(),ee=ve(b);if(ee===null){C(s("Payload must be valid JSON"));return}S(!0),C(null),await J(R,ee.value).finally(()=>{S(!1)})},e[6]=J,e[7]=c,e[8]=b,e[9]=s,e[10]=N):N=e[10];const v=N;let g;e[11]!==s?(g=s("Send event"),e[11]=s,e[12]=g):g=e[12];let T;e[13]!==g?(T=t("h3",{className:"text-sm font-medium",children:g}),e[13]=g,e[14]=T):T=e[14];let F;e[15]!==$?(F=$!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:$}),e[15]=$,e[16]=F):F=e[16];let P;e[17]!==s?(P=s("Instance id"),e[17]=s,e[18]=P):P=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=R=>{d(R.target.value)},e[19]=O):O=e[19];let E;e[20]!==s?(E=s("Instance id"),e[20]=s,e[21]=E):E=e[21];let W;e[22]!==c||e[23]!==P||e[24]!==E?(W=t(ue,{"aria-label":P,className:"max-w-48","data-testid":"workflows-event-id",onChange:O,placeholder:E,value:c}),e[22]=c,e[23]=P,e[24]=E,e[25]=W):W=e[25];let A;e[26]!==s?(A=s("Event type"),e[26]=s,e[27]=A):A=e[27];let L;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=R=>{D(R.target.value)},e[28]=L):L=e[28];let n;e[29]!==s?(n=s("Event type"),e[29]=s,e[30]=n):n=e[30];let r;e[31]!==A||e[32]!==n||e[33]!==w?(r=t(ue,{"aria-label":A,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:L,placeholder:n,value:w}),e[31]=A,e[32]=n,e[33]=w,e[34]=r):r=e[34];let a;e[35]!==p?(a=p.map(De),e[35]=p,e[36]=a):a=e[36];let o;e[37]!==a?(o=t("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:a}),e[37]=a,e[38]=o):o=e[38];let I;e[39]!==h||e[40]!==c||e[41]!==k||e[42]!==w?(I=k||h===""||c.trim()===""||w.trim()==="",e[39]=h,e[40]=c,e[41]=k,e[42]=w,e[43]=I):I=e[43];let z;e[44]!==v?(z=()=>{V(v())},e[44]=v,e[45]=z):z=e[45];let B;e[46]!==k||e[47]!==s?(B=s(k?"Sending…":"Send event"),e[46]=k,e[47]=s,e[48]=B):B=e[48];let K;e[49]!==I||e[50]!==z||e[51]!==B?(K=t(X,{"data-testid":"workflows-event-button",disabled:I,onClick:z,children:B}),e[49]=I,e[50]=z,e[51]=B,e[52]=K):K=e[52];let G;e[53]!==r||e[54]!==o||e[55]!==K||e[56]!==W?(G=i("div",{className:"flex flex-wrap items-center gap-2",children:[W,r,o,K]}),e[53]=r,e[54]=o,e[55]=K,e[56]=W,e[57]=G):G=e[57];let H;e[58]!==s?(H=s("Payload (JSON)"),e[58]=s,e[59]=H):H=e[59];let Y;e[60]===Symbol.for("react.memo_cache_sentinel")?(Y=R=>{j(R.target.value)},e[60]=Y):Y=e[60];let M;e[61]!==s?(M=s("Payload (JSON, optional)"),e[61]=s,e[62]=M):M=e[62];let Q;e[63]!==b||e[64]!==H||e[65]!==M?(Q=t(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:Y,placeholder:M,value:b}),e[63]=b,e[64]=H,e[65]=M,e[66]=Q):Q=e[66];let Z;return e[67]!==G||e[68]!==Q||e[69]!==T||e[70]!==F?(Z=i("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[T,F,G,Q]}),e[67]=G,e[68]=Q,e[69]=T,e[70]=F,e[71]=Z):Z=e[71],Z},Ze=()=>{const l=fe(),e=le(),{data:p,error:h}=ye(oe.listWorkflows,{}),[x,y]=f(""),[s,c]=f(""),[d,w]=f(""),[D,b]=f(!1),[j,k]=f(null),[S,$]=f([]),[C,_]=f(null),J=p!==void 0,N=Array.isArray(p?.workflows)?[...p.workflows].toSorted((r,a)=>r.exportName.localeCompare(a.exportName)):[],v=Fe(N,x),g=N.find(r=>r.exportName===v),T=r=>{$(a=>{const o=a.filter(I=>!(I.exportName===r.exportName&&I.id===r.id));return[r,...o]})},F=async()=>{const r=v;if(r==="")return;const a=ve(d);if(a===null){k(e("Params must be valid JSON"));return}b(!0),k(null);try{const o=s.trim(),I=await l.query(We,{exportName:r,id:o===""?void 0:o,params:a.value},me(""));T({exportName:r,id:I.id,status:I.status}),c("")}catch(o){k(U(o))}b(!1)},P=()=>{V(F())},O=async(r,a)=>{_(a);try{const o=await l.query(Ae,{exportName:r,id:a},me(""));T({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},E=async(r,a)=>{try{await O(r,a)}catch(o){k(U(o))}},W=r=>{y(r.target.value)},A=r=>{c(r.target.value)},L=r=>{w(r.target.value)},n=r=>{const{export:a,id:o}=r.currentTarget.dataset;a!==void 0&&o!==void 0&&V(E(a,o))};return i("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[h!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:h}),t("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),J&&N.length===0?t(de,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Export")}),t(u,{children:e("Name")}),t(u,{children:e("Class")})]})}),t(ae,{children:N.map(r=>i(q,{"data-testid":`workflows-row-${r.exportName}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.name}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),N.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:e("Start instance")}),j!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),i("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":e("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:W,value:v,children:N.map(r=>t("option",{value:r.exportName,children:r.exportName},r.exportName))}),t(ue,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:A,placeholder:e("Instance id (optional)"),value:s}),t(X,{"data-testid":"workflows-start-button",disabled:D||v==="",onClick:P,children:e(D?"Starting…":"Start instance")})]}),t(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:L,placeholder:e("Params (JSON, optional)"),value:d})]}),N.length>0&&t(Pe,{eventTypes:p?.eventTypes??[],exportName:v,onSent:O},v),S.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:e("Instances")}),t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Workflow")}),t(u,{children:e("Instance id")}),t(u,{children:e("Status")}),t(u,{children:e("Output")}),t(u,{})]})}),t(ae,{children:S.map(r=>i(q,{"data-testid":`workflows-instance-${r.id}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.id}),t(m,{className:"font-mono text-xs",children:r.status}),t(m,{className:"font-mono text-xs text-muted-foreground",children:$e(r)}),t(m,{children:t(X,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:C===r.id,onClick:n,size:"xs",variant:"outline",children:C===r.id?e("Refreshing…"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),g!==void 0&&t(_e,{workflowName:g.name})]})};function De(l){return t("option",{value:l,children:l},l)}export{Ze as default};
1
+ import{c as xe}from"react/compiler-runtime";import{useState as f,useRef as ce,useEffect as ge}from"react";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as te,a as re}from"../packem_shared/card-By2O8ULa.mjs";import{E as de}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ue}from"../packem_shared/input-CXhxesPC.mjs";import{T as se,a as ne,b as q,c as u,d as ae,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{T as we}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ye}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{f as V,b as U,k as Ne,d as me,c as pe}from"../packem_shared/internal-hIuTpSbx.mjs";import{ConfirmButton as be}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsxs as i,jsx as t,Fragment as ke}from"react/jsx-runtime";const Se=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Ie=["pause","resume","restart","terminate"],Ce=l=>{const e=xe(7),{busy:p,id:h,onAct:x}=l,y=le();let s;e[0]!==p||e[1]!==h||e[2]!==x||e[3]!==y?(s=Ie.map(d=>d==="restart"?t(be,{confirmLabel:y("Restart?"),disabled:p,onConfirm:()=>{x(d)},testId:`workflow-instance-${d}-${h}`,children:y(d)},d):t(X,{"data-testid":`workflow-instance-${d}-${h}`,disabled:p,onClick:()=>{x(d)},size:"sm",type:"button",variant:"ghost",children:y(d)},d)),e[0]=p,e[1]=h,e[2]=x,e[3]=y,e[4]=s):s=e[4];let c;return e[5]!==s?(c=t(ke,{children:s}),e[5]=s,e[6]=c):c=e[6],c},Te="WORKFLOWS_NOT_CONFIGURED",Oe=l=>typeof l=="object"&&l!==null&&l.code===Te,Ee=l=>{const e=l.error??l.output;if(e===void 0)return"—";try{return JSON.stringify(e,Ne)}catch{return"(unserializable)"}},_e=({loadDetail:l,loadInstances:e,readOnly:p,runAction:h,workflowName:x})=>{const y=fe(),s=le(),[c,d]=f(null),[w,D]=f(null),[b,j]=f(""),[k,S]=f(null),[$,C]=f(!1),[_,J]=f(null),N=ce(0),v=ce(0),g=ce(0),T=l??(n=>y.getWorkflowInstance(n)),O=p?void 0:h??(e===void 0?n=>y.setWorkflowInstanceStatus(n):void 0),E=async()=>{v.current+=1;const n=v.current;S(null),C(!1);const r=b===""?void 0:b;try{if(e===void 0){const o=await y.listWorkflowInstances({name:x,status:r});if(n!==v.current)return;if(o.configured===!1){d(null),C(!0);return}d(o.instances);return}const a=await e({name:x,status:r});n===v.current&&d(a)}catch(a){if(n!==v.current)return;d(null),Oe(a)?C(!0):S(U(a))}};ge(()=>{N.current+=1,g.current+=1,D(null),V(E())},[x,b]);const W=async n=>{g.current+=1;const r=g.current;S(null);try{const a=await T({id:n,name:x});r===g.current&&D(a)}catch(a){r===g.current&&S(U(a))}},A=()=>{g.current+=1,D(null)},L=async(n,r)=>{if(O===void 0)return;const a=N.current;J(n),S(null);try{await O({action:r,id:n,name:x}),a===N.current&&await E()}catch(o){S(U(o))}J(null)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[i("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),i("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n=>{j(n.target.value)},value:b,children:[t("option",{value:"",children:s("All statuses")}),Se.map(n=>t("option",{value:n,children:n},n))]})]}),k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:k}),$&&t(de,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&c!==null&&c.length===0&&t(de,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),c!==null&&c.length>0&&t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflow-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Instance id")}),t(u,{children:s("Status")}),t(u,{children:s("Created")}),t(u,{children:s("Ended")}),t(u,{"aria-label":s("Actions")})]})}),t(ae,{children:c.map(n=>i(q,{"data-testid":`workflow-instance-${n.id}`,children:[t(m,{className:"font-mono text-xs",children:n.id}),t(m,{className:"font-mono text-xs",children:n.status}),t(m,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"—"}),t(m,{className:"text-right",children:i("div",{className:"flex justify-end gap-1.5",children:[t(X,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:()=>{V(W(n.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),O!==void 0&&t(Ce,{busy:_===n.id,id:n.id,onAct:r=>{V(L(n.id,r))}},x)]})})]},n.id))})]})})}),w!==null&&t(te,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:i(re,{className:"flex flex-col gap-2 px-4 py-3",children:[i("div",{className:"flex items-center justify-between",children:[i("span",{className:"font-mono text-xs",children:[s("Steps")," · ",w.id]}),t(X,{"data-testid":"workflow-instance-detail-close",onClick:A,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),w.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):i(se,{"data-testid":"workflow-instance-steps",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Step")}),t(u,{children:s("Type")}),t(u,{children:s("Attempts")}),t(u,{children:s("Started")}),t(u,{children:s("Output")})]})}),t(ae,{children:w.steps.map((n,r)=>i(q,{"data-testid":`workflow-step-${String(r)}`,children:[t(m,{className:"font-mono text-xs",children:n.name}),t(m,{className:"text-xs text-muted-foreground",children:n.type??"—"}),t(m,{className:"tabular-nums",children:n.attempts??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.start??"—"}),t(m,{className:"font-mono text-xs text-muted-foreground",children:Ee(n)})]},`${n.name}:${String(r)}`))})]})]})})]})},We=pe(oe.createWorkflowInstance),Ae=pe(oe.getWorkflowInstanceStatus),Re=pe(oe.sendWorkflowEvent),$e=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,Ne)}catch{return"(unserializable)"}},ve=l=>{const e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},Fe=(l,e)=>l.some(p=>p.exportName===e)?e:l[0]?.exportName??"",Pe=l=>{const e=xe(72),{eventTypes:p,exportName:h,onSent:x}=l,y=fe(),s=le(),[c,d]=f(""),[w,D]=f(""),[b,j]=f(""),[k,S]=f(!1),[$,C]=f(null);let _;e[0]!==y||e[1]!==h||e[2]!==x||e[3]!==s||e[4]!==w?(_=async(R,ee)=>{try{await y.query(Re,{exportName:h,id:R,payload:ee,type:w},me(""))}catch(ie){C(U(ie));return}try{await x(h,R)}catch(ie){const he=ie;C(`${s("Event sent, but refreshing the instance failed")}: ${U(he)}`)}},e[0]=y,e[1]=h,e[2]=x,e[3]=s,e[4]=w,e[5]=_):_=e[5];const J=_;let N;e[6]!==J||e[7]!==c||e[8]!==b||e[9]!==s?(N=async()=>{const R=c.trim(),ee=ve(b);if(ee===null){C(s("Payload must be valid JSON"));return}S(!0),C(null),await J(R,ee.value).finally(()=>{S(!1)})},e[6]=J,e[7]=c,e[8]=b,e[9]=s,e[10]=N):N=e[10];const v=N;let g;e[11]!==s?(g=s("Send event"),e[11]=s,e[12]=g):g=e[12];let T;e[13]!==g?(T=t("h3",{className:"text-sm font-medium",children:g}),e[13]=g,e[14]=T):T=e[14];let F;e[15]!==$?(F=$!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:$}),e[15]=$,e[16]=F):F=e[16];let P;e[17]!==s?(P=s("Instance id"),e[17]=s,e[18]=P):P=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=R=>{d(R.target.value)},e[19]=O):O=e[19];let E;e[20]!==s?(E=s("Instance id"),e[20]=s,e[21]=E):E=e[21];let W;e[22]!==c||e[23]!==P||e[24]!==E?(W=t(ue,{"aria-label":P,className:"max-w-48","data-testid":"workflows-event-id",onChange:O,placeholder:E,value:c}),e[22]=c,e[23]=P,e[24]=E,e[25]=W):W=e[25];let A;e[26]!==s?(A=s("Event type"),e[26]=s,e[27]=A):A=e[27];let L;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=R=>{D(R.target.value)},e[28]=L):L=e[28];let n;e[29]!==s?(n=s("Event type"),e[29]=s,e[30]=n):n=e[30];let r;e[31]!==A||e[32]!==n||e[33]!==w?(r=t(ue,{"aria-label":A,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:L,placeholder:n,value:w}),e[31]=A,e[32]=n,e[33]=w,e[34]=r):r=e[34];let a;e[35]!==p?(a=p.map(De),e[35]=p,e[36]=a):a=e[36];let o;e[37]!==a?(o=t("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:a}),e[37]=a,e[38]=o):o=e[38];let I;e[39]!==h||e[40]!==c||e[41]!==k||e[42]!==w?(I=k||h===""||c.trim()===""||w.trim()==="",e[39]=h,e[40]=c,e[41]=k,e[42]=w,e[43]=I):I=e[43];let z;e[44]!==v?(z=()=>{V(v())},e[44]=v,e[45]=z):z=e[45];let B;e[46]!==k||e[47]!==s?(B=s(k?"Sending…":"Send event"),e[46]=k,e[47]=s,e[48]=B):B=e[48];let K;e[49]!==I||e[50]!==z||e[51]!==B?(K=t(X,{"data-testid":"workflows-event-button",disabled:I,onClick:z,children:B}),e[49]=I,e[50]=z,e[51]=B,e[52]=K):K=e[52];let G;e[53]!==r||e[54]!==o||e[55]!==K||e[56]!==W?(G=i("div",{className:"flex flex-wrap items-center gap-2",children:[W,r,o,K]}),e[53]=r,e[54]=o,e[55]=K,e[56]=W,e[57]=G):G=e[57];let H;e[58]!==s?(H=s("Payload (JSON)"),e[58]=s,e[59]=H):H=e[59];let Y;e[60]===Symbol.for("react.memo_cache_sentinel")?(Y=R=>{j(R.target.value)},e[60]=Y):Y=e[60];let M;e[61]!==s?(M=s("Payload (JSON, optional)"),e[61]=s,e[62]=M):M=e[62];let Q;e[63]!==b||e[64]!==H||e[65]!==M?(Q=t(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:Y,placeholder:M,value:b}),e[63]=b,e[64]=H,e[65]=M,e[66]=Q):Q=e[66];let Z;return e[67]!==G||e[68]!==Q||e[69]!==T||e[70]!==F?(Z=i("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[T,F,G,Q]}),e[67]=G,e[68]=Q,e[69]=T,e[70]=F,e[71]=Z):Z=e[71],Z},Ze=()=>{const l=fe(),e=le(),{data:p,error:h}=ye(oe.listWorkflows,{}),[x,y]=f(""),[s,c]=f(""),[d,w]=f(""),[D,b]=f(!1),[j,k]=f(null),[S,$]=f([]),[C,_]=f(null),J=p!==void 0,N=Array.isArray(p?.workflows)?[...p.workflows].toSorted((r,a)=>r.exportName.localeCompare(a.exportName)):[],v=Fe(N,x),g=N.find(r=>r.exportName===v),T=r=>{$(a=>{const o=a.filter(I=>!(I.exportName===r.exportName&&I.id===r.id));return[r,...o]})},F=async()=>{const r=v;if(r==="")return;const a=ve(d);if(a===null){k(e("Params must be valid JSON"));return}b(!0),k(null);try{const o=s.trim(),I=await l.query(We,{exportName:r,id:o===""?void 0:o,params:a.value},me(""));T({exportName:r,id:I.id,status:I.status}),c("")}catch(o){k(U(o))}b(!1)},P=()=>{V(F())},O=async(r,a)=>{_(a);try{const o=await l.query(Ae,{exportName:r,id:a},me(""));T({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},E=async(r,a)=>{try{await O(r,a)}catch(o){k(U(o))}},W=r=>{y(r.target.value)},A=r=>{c(r.target.value)},L=r=>{w(r.target.value)},n=r=>{const{export:a,id:o}=r.currentTarget.dataset;a!==void 0&&o!==void 0&&V(E(a,o))};return i("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[h!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:h}),t("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),J&&N.length===0?t(de,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Export")}),t(u,{children:e("Name")}),t(u,{children:e("Class")})]})}),t(ae,{children:N.map(r=>i(q,{"data-testid":`workflows-row-${r.exportName}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.name}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),N.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:e("Start instance")}),j!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),i("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":e("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:W,value:v,children:N.map(r=>t("option",{value:r.exportName,children:r.exportName},r.exportName))}),t(ue,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:A,placeholder:e("Instance id (optional)"),value:s}),t(X,{"data-testid":"workflows-start-button",disabled:D||v==="",onClick:P,children:e(D?"Starting…":"Start instance")})]}),t(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:L,placeholder:e("Params (JSON, optional)"),value:d})]}),N.length>0&&t(Pe,{eventTypes:p?.eventTypes??[],exportName:v,onSent:O},v),S.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:e("Instances")}),t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Workflow")}),t(u,{children:e("Instance id")}),t(u,{children:e("Status")}),t(u,{children:e("Output")}),t(u,{})]})}),t(ae,{children:S.map(r=>i(q,{"data-testid":`workflows-instance-${r.id}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.id}),t(m,{className:"font-mono text-xs",children:r.status}),t(m,{className:"font-mono text-xs text-muted-foreground",children:$e(r)}),t(m,{children:t(X,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:C===r.id,onClick:n,size:"xs",variant:"outline",children:C===r.id?e("Refreshing…"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),g!==void 0&&t(_e,{workflowName:g.name})]})};function De(l){return t("option",{value:l,children:l},l)}export{Ze as default};