@lunora/studio 1.0.0-alpha.10 → 1.0.0-alpha.101

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 (316) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.ts +824 -781
  3. package/dist/index.js +1 -41
  4. package/dist/mount.d.ts +10 -10
  5. package/dist/mount.js +1 -26
  6. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -0
  7. package/dist/packem_chunks/ApiTab.js +1 -0
  8. package/dist/packem_chunks/AuditPanel.js +1 -0
  9. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
  10. package/dist/packem_chunks/ExportImportPanel.js +3 -0
  11. package/dist/packem_chunks/FileBrowser.js +4 -0
  12. package/dist/packem_chunks/FunctionRunner.js +1 -0
  13. package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
  14. package/dist/packem_chunks/HealthPanel.js +1 -0
  15. package/dist/packem_chunks/InsightsPanel.js +1 -0
  16. package/dist/packem_chunks/LogsPanel.js +1 -0
  17. package/dist/packem_chunks/MailPanel.js +2 -0
  18. package/dist/packem_chunks/MetricsPanel.js +1 -0
  19. package/dist/packem_chunks/NotificationsPanel.js +1 -0
  20. package/dist/packem_chunks/PitrPanel.js +1 -0
  21. package/dist/packem_chunks/SchemaViewer.js +1 -0
  22. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -0
  23. package/dist/packem_chunks/SettingsPanel.js +1 -0
  24. package/dist/packem_chunks/SqlEditorPanel.js +6 -0
  25. package/dist/packem_chunks/TableEditor.js +1 -0
  26. package/dist/packem_chunks/agents-panel.js +1 -0
  27. package/dist/packem_chunks/analytics-panel.js +1 -0
  28. package/dist/packem_chunks/auth-audit-panel.js +1 -0
  29. package/dist/packem_chunks/auth-config-panel.js +1 -0
  30. package/dist/packem_chunks/auth-sessions-panel.js +1 -0
  31. package/dist/packem_chunks/containers-panel.js +1 -0
  32. package/dist/packem_chunks/dashboards-panel.js +1 -0
  33. package/dist/packem_chunks/fanout-panel.js +1 -0
  34. package/dist/packem_chunks/flags-panel.js +1 -0
  35. package/dist/packem_chunks/issues-panel.js +1 -0
  36. package/dist/packem_chunks/kv-browser.js +1 -0
  37. package/dist/packem_chunks/log-drains-panel.js +4 -0
  38. package/dist/packem_chunks/migrations-route.js +1 -0
  39. package/dist/packem_chunks/organizations-panel.js +1 -0
  40. package/dist/packem_chunks/payments-panel.js +1 -0
  41. package/dist/packem_chunks/permissions-panel.js +1 -0
  42. package/dist/packem_chunks/queues-panel.js +1 -0
  43. package/dist/packem_chunks/rls-panel.js +1 -0
  44. package/dist/packem_chunks/schedule-panel.js +1 -0
  45. package/dist/packem_chunks/sparkline.js +1 -0
  46. package/dist/packem_chunks/storage-rules-panel.js +1 -0
  47. package/dist/packem_chunks/subscriptions-panel.js +1 -0
  48. package/dist/packem_chunks/sync-client-panel.js +1 -0
  49. package/dist/packem_chunks/traces-panel.js +1 -0
  50. package/dist/packem_chunks/users-panel.js +1 -0
  51. package/dist/packem_chunks/vector-browser.js +1 -0
  52. package/dist/packem_chunks/workflows-panel.js +1 -0
  53. package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
  54. package/dist/packem_shared/ApiDocsPanel-Cu_QmzO0.js +2 -0
  55. package/dist/packem_shared/ApiReferencePanel-DuIU1P8B.js +1 -0
  56. package/dist/packem_shared/CommandPalette-mPR8-vIm.js +1 -0
  57. package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
  58. package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
  59. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
  60. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
  61. package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
  62. package/dist/packem_shared/DataBrowser-CPNKM0KZ.js +1 -0
  63. package/dist/packem_shared/DataFilters-B26ZeqBZ.js +1 -0
  64. package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
  65. package/dist/packem_shared/GlobalDataBrowser-BSmyOO0n.js +1 -0
  66. package/dist/packem_shared/HomePanel-BUO6BcYQ.js +1 -0
  67. package/dist/packem_shared/MigrationsPanel-BAnvY79E.js +1 -0
  68. package/dist/packem_shared/OpenRpcReferencePanel-DXeffPFr.js +1 -0
  69. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
  70. package/dist/packem_shared/ScheduledJobs-pHVlh2xU.js +1 -0
  71. package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
  72. package/dist/packem_shared/Studio-DG_n-8Pc.js +1 -0
  73. package/dist/packem_shared/StudioApp-bavavhpe.js +1 -0
  74. package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
  75. package/dist/packem_shared/advisor-view-CGcwvlMo.js +1 -0
  76. package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
  77. package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
  78. package/dist/packem_shared/app.d-D1bPR8FO.d.ts +252 -0
  79. package/dist/packem_shared/badge-BbuuAio7.js +1 -0
  80. package/dist/packem_shared/bar-chart-B8oDHgnw.js +6 -0
  81. package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
  82. package/dist/packem_shared/button-BkCrNcAs.js +1 -0
  83. package/dist/packem_shared/card-BMKx5UdA.js +1 -0
  84. package/dist/packem_shared/cf-links-Dmg86v1D.js +1 -0
  85. package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
  86. package/dist/packem_shared/data-grid-Ci4-tZkk.js +1 -0
  87. package/dist/packem_shared/data-view-params-ClrV7XgF.js +1 -0
  88. package/dist/packem_shared/dropdown-menu-BgS2zw1i.js +2 -0
  89. package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
  90. package/dist/packem_shared/error-alert-_2q2VtVG.js +1 -0
  91. package/dist/packem_shared/grid-features-Y2YSjhCf.js +6 -0
  92. package/dist/packem_shared/home-panel-Ir3YHReO.js +3 -0
  93. package/dist/packem_shared/input-JHu63lTv.js +1 -0
  94. package/dist/packem_shared/internal-zkEvTqy8.js +2 -0
  95. package/dist/packem_shared/label-6uP1obNF.js +1 -0
  96. package/dist/packem_shared/live-status-CmuRLFKf.js +1 -0
  97. package/dist/packem_shared/log-line-CmtmbZNE.js +1 -0
  98. package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
  99. package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +1 -0
  100. package/dist/packem_shared/recording-client-DtUxwVNY.js +1 -0
  101. package/dist/packem_shared/reference-view-DncEStdm.js +12 -0
  102. package/dist/packem_shared/result-chart-0VgP_3FP.js +1 -0
  103. package/dist/packem_shared/schema-diagram-GVgnLWTf.js +2 -0
  104. package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
  105. package/dist/packem_shared/select-BssZMiFY.js +2 -0
  106. package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
  107. package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
  108. package/dist/packem_shared/sparkline-BNvxiJj_.js +1 -0
  109. package/dist/packem_shared/stat-card-BGJdhfm6.js +1 -0
  110. package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
  111. package/dist/packem_shared/studio-C9Qvg13j.js +2 -0
  112. package/dist/packem_shared/table-DZAB8cs3.js +2 -0
  113. package/dist/packem_shared/table-list-sidebar-fz0m_4I4.js +1 -0
  114. package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
  115. package/dist/packem_shared/trace-handoff-D7j9TjUT.js +1 -0
  116. package/dist/packem_shared/use-admin-query-CnnyWJXM.js +1 -0
  117. package/dist/packem_shared/use-async-submit-B32whHJO.js +1 -0
  118. package/dist/packem_shared/use-auth-config-0EnNCdLu.js +1 -0
  119. package/dist/packem_shared/use-open-trace-D9XDDHHS.js +1 -0
  120. package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
  121. package/dist/packem_shared/use-sql-assistant-Dtw55kKM.js +1 -0
  122. package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
  123. package/dist/packem_shared/utils-bhneXptQ.js +1 -0
  124. package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
  125. package/dist/packem_shared/wire-codec-DkrdsFXO.js +1 -0
  126. package/dist/standalone/chunk-2LU3W7JY.js +3 -0
  127. package/dist/standalone/chunk-2OUPA2WJ.js +1 -0
  128. package/dist/standalone/chunk-2PJNAWB3.js +1 -0
  129. package/dist/standalone/chunk-2QSHLBCO.js +1 -0
  130. package/dist/standalone/chunk-322ZP3GW.js +1 -0
  131. package/dist/standalone/chunk-34SDRCH2.js +1 -0
  132. package/dist/standalone/chunk-3C3CG7ZK.js +1 -0
  133. package/dist/standalone/chunk-3CWGJYBB.js +1 -0
  134. package/dist/standalone/chunk-3DH35OZ5.js +1 -0
  135. package/dist/standalone/chunk-3SCGCJYS.js +1 -0
  136. package/dist/standalone/chunk-3XIESWL4.js +1 -0
  137. package/dist/standalone/chunk-4HNNNIDW.js +1 -0
  138. package/dist/standalone/chunk-4UOFSGUS.js +1 -0
  139. package/dist/standalone/chunk-546EVK7X.js +1 -0
  140. package/dist/standalone/chunk-54MMVNPT.js +1 -0
  141. package/dist/standalone/chunk-55PVLIN3.js +1 -0
  142. package/dist/standalone/chunk-5Y3QLNWX.js +1 -0
  143. package/dist/standalone/chunk-6JBWLC63.js +4 -0
  144. package/dist/standalone/chunk-6MUFUH3T.js +13 -0
  145. package/dist/standalone/chunk-6ST5ECQA.js +1 -0
  146. package/dist/standalone/chunk-6UPCJAAI.js +1 -0
  147. package/dist/standalone/chunk-7QIFDWQV.js +1 -0
  148. package/dist/standalone/chunk-7T7UOTYK.js +1 -0
  149. package/dist/standalone/chunk-A6ZHBJ76.js +1 -0
  150. package/dist/standalone/chunk-AVAC26HJ.js +1 -0
  151. package/dist/standalone/chunk-AYZUNJKK.js +1 -0
  152. package/dist/standalone/chunk-B2QO6Q52.js +1 -0
  153. package/dist/standalone/chunk-BCAPWLLU.js +8 -0
  154. package/dist/standalone/chunk-BGBLQ563.js +1 -0
  155. package/dist/standalone/chunk-BQNVN2OD.js +1 -0
  156. package/dist/standalone/chunk-BUVIRYQM.js +1 -0
  157. package/dist/standalone/chunk-C2OHUG2J.js +1 -0
  158. package/dist/standalone/chunk-CFPZYHPY.js +2 -0
  159. package/dist/standalone/chunk-CKPKUMYJ.js +1 -0
  160. package/dist/standalone/chunk-CZZWYUTR.js +1 -0
  161. package/dist/standalone/chunk-DBYTTQBC.js +1 -0
  162. package/dist/standalone/chunk-DGRAPESO.js +1 -0
  163. package/dist/standalone/chunk-DJZYD5I5.js +1 -0
  164. package/dist/standalone/chunk-DRDGV6G3.js +1 -0
  165. package/dist/standalone/chunk-ESVP44Y3.js +1 -0
  166. package/dist/standalone/chunk-F2O4CDVZ.js +1 -0
  167. package/dist/standalone/chunk-F7IRBXWY.js +1 -0
  168. package/dist/standalone/chunk-FBQNAZHM.js +1 -0
  169. package/dist/standalone/chunk-FKAUVTSS.js +1 -0
  170. package/dist/standalone/chunk-FSXERBWP.js +1 -0
  171. package/dist/standalone/chunk-FURI47Z2.js +1 -0
  172. package/dist/standalone/chunk-GG6PIGQO.js +1 -0
  173. package/dist/standalone/chunk-GGADAESO.js +1 -0
  174. package/dist/standalone/chunk-GMR677FL.js +1 -0
  175. package/dist/standalone/chunk-GR62EIAU.js +4 -0
  176. package/dist/standalone/chunk-GRL5MG3Z.js +1 -0
  177. package/dist/standalone/chunk-GVSKCIJR.js +1 -0
  178. package/dist/standalone/chunk-H23VFWFW.js +6 -0
  179. package/dist/standalone/chunk-HGSIVV32.js +59 -0
  180. package/dist/standalone/chunk-HPFLBYRI.js +1 -0
  181. package/dist/standalone/chunk-I6A5C46N.js +1 -0
  182. package/dist/standalone/chunk-IC4L6G56.js +1 -0
  183. package/dist/standalone/chunk-IGCNMZSB.js +1 -0
  184. package/dist/standalone/chunk-IUYFXK4X.js +19 -0
  185. package/dist/standalone/chunk-IVFHIQOT.js +1 -0
  186. package/dist/standalone/chunk-JNYM5V6I.js +2 -0
  187. package/dist/standalone/chunk-K2E4OECF.js +1 -0
  188. package/dist/standalone/chunk-K3PSOZXH.js +1 -0
  189. package/dist/standalone/chunk-KFQXMD7C.js +1 -0
  190. package/dist/standalone/chunk-KG6FVK5P.js +1 -0
  191. package/dist/standalone/chunk-LEDWUPXM.js +1 -0
  192. package/dist/standalone/chunk-LEJV3YKH.js +1 -0
  193. package/dist/standalone/chunk-LZFOZFYW.js +1 -0
  194. package/dist/standalone/chunk-M3NGYXDR.js +11 -0
  195. package/dist/standalone/chunk-M43KO276.js +1 -0
  196. package/dist/standalone/chunk-MLT5MMMY.js +1 -0
  197. package/dist/standalone/chunk-MWIKAR7F.js +1 -0
  198. package/dist/standalone/chunk-MZ2JNVMR.js +1 -0
  199. package/dist/standalone/chunk-N6DBTBBZ.js +1 -0
  200. package/dist/standalone/chunk-NBZH4PVA.js +1 -0
  201. package/dist/standalone/chunk-NE4N6I57.js +1 -0
  202. package/dist/standalone/chunk-NZZB7PPI.js +1 -0
  203. package/dist/standalone/chunk-O6XSMU4X.js +1 -0
  204. package/dist/standalone/chunk-OZ4CUX5O.js +1 -0
  205. package/dist/standalone/chunk-P4BOVBMR.js +1 -0
  206. package/dist/standalone/chunk-PLFTCTMX.js +1 -0
  207. package/dist/standalone/chunk-PVF5J5UD.js +1 -0
  208. package/dist/standalone/chunk-QBWRC5YX.js +1 -0
  209. package/dist/standalone/chunk-QJQWXV2E.js +1 -0
  210. package/dist/standalone/chunk-QLQADHFE.js +1 -0
  211. package/dist/standalone/chunk-RA5DW5MU.js +1 -0
  212. package/dist/standalone/chunk-RMN2JN4S.js +1 -0
  213. package/dist/standalone/chunk-RTMMB3OY.js +1 -0
  214. package/dist/standalone/chunk-RX5D4SLS.js +1 -0
  215. package/dist/standalone/chunk-SBZXUGZ7.js +4 -0
  216. package/dist/standalone/chunk-SD4BERSA.js +1 -0
  217. package/dist/standalone/chunk-SDVDPAD2.js +3 -0
  218. package/dist/standalone/chunk-SFDOII3B.js +1 -0
  219. package/dist/standalone/chunk-SMIESS7P.js +1 -0
  220. package/dist/standalone/chunk-SO52T6RL.js +1 -0
  221. package/dist/standalone/chunk-T6VMSOBB.js +1 -0
  222. package/dist/standalone/chunk-THIXMMZD.js +1 -0
  223. package/dist/standalone/chunk-TMGHRD6W.js +1 -0
  224. package/dist/standalone/chunk-UF6XZKV3.js +1 -0
  225. package/dist/standalone/chunk-V53KNYRN.js +1 -0
  226. package/dist/standalone/chunk-V76WCOMM.js +1 -0
  227. package/dist/standalone/chunk-VDW32UET.js +1 -0
  228. package/dist/standalone/chunk-VITTPKH5.js +1 -0
  229. package/dist/standalone/chunk-WJQLNYGX.js +1 -0
  230. package/dist/standalone/chunk-WMLKVJUX.js +1 -0
  231. package/dist/standalone/chunk-WPK2Q33V.js +6 -0
  232. package/dist/standalone/chunk-WQH3LT2P.js +1 -0
  233. package/dist/standalone/chunk-XAEG372C.js +1 -0
  234. package/dist/standalone/chunk-XBDKZZ67.js +1 -0
  235. package/dist/standalone/chunk-XF2B7P5A.js +1 -0
  236. package/dist/standalone/chunk-XQCVZAGU.js +1 -0
  237. package/dist/standalone/chunk-XXQUMVWH.js +1 -0
  238. package/dist/standalone/chunk-Y32QIKBS.js +1 -0
  239. package/dist/standalone/chunk-Y7XGNPT6.js +1 -0
  240. package/dist/standalone/chunk-YC52XCPK.js +14 -0
  241. package/dist/standalone/chunk-Z4EWPIMU.js +1 -0
  242. package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
  243. package/dist/standalone/chunk-ZKPKUHTX.js +1 -0
  244. package/dist/standalone/chunk-ZMYRKEA6.js +1 -0
  245. package/dist/standalone/studio.js +9 -378
  246. package/dist/styles.css +2 -2
  247. package/package.json +15 -14
  248. package/dist/packem_shared/ADMIN_FUNCTIONS-DjXgvJb6.js +0 -46
  249. package/dist/packem_shared/ApiDocsPanel-yVSGHK3H.js +0 -842
  250. package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
  251. package/dist/packem_shared/ApiTab-rwttyQ1-.js +0 -251
  252. package/dist/packem_shared/AuditPanel-D9Eh7j7E.js +0 -200
  253. package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
  254. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  255. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  256. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  257. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  258. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  259. package/dist/packem_shared/DataBrowser-CyckZRwj.js +0 -4480
  260. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  261. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  262. package/dist/packem_shared/ExportImportPanel-BGJqFK9X.js +0 -197
  263. package/dist/packem_shared/FileBrowser-0pCpdKPE.js +0 -2932
  264. package/dist/packem_shared/FunctionRunner-7NH3KcTg.js +0 -343
  265. package/dist/packem_shared/FunctionStatsPanel-CXynSuqT.js +0 -375
  266. package/dist/packem_shared/GlobalDataBrowser-DAxzB-Br.js +0 -289
  267. package/dist/packem_shared/HealthPanel-CyLs7qZm.js +0 -648
  268. package/dist/packem_shared/HomePanel-BOkFRbuj.js +0 -1334
  269. package/dist/packem_shared/InsightsPanel-CvXMoZuv.js +0 -461
  270. package/dist/packem_shared/LogsPanel-BrUstOk6.js +0 -827
  271. package/dist/packem_shared/MailPanel-GnnrNqL6.js +0 -440
  272. package/dist/packem_shared/MetricsPanel-BN_uUU-_.js +0 -1611
  273. package/dist/packem_shared/MigrationsPanel-DaZuUHje.js +0 -239
  274. package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
  275. package/dist/packem_shared/PitrPanel-LJGNP_IX.js +0 -252
  276. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  277. package/dist/packem_shared/ScheduledJobs-UmVaMbJy.js +0 -262
  278. package/dist/packem_shared/SchemaViewer-Bam6ylvw.js +0 -2512
  279. package/dist/packem_shared/SecurityAdvisorPanel-DTmjUNqt.js +0 -92
  280. package/dist/packem_shared/SettingsPanel-C2wDK-8F.js +0 -390
  281. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  282. package/dist/packem_shared/SqlEditorPanel-D5wMIxcg.js +0 -13
  283. package/dist/packem_shared/Studio-DpgYe4qt.js +0 -33
  284. package/dist/packem_shared/StudioApp-C7aaizqc.js +0 -657
  285. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  286. package/dist/packem_shared/TableEditor-DzK3Z6rL.js +0 -371
  287. package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
  288. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  289. package/dist/packem_shared/app.d-Nbhpihxv.d.ts +0 -300
  290. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  291. package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
  292. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  293. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  294. package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
  295. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  296. package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
  297. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  298. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  299. package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
  300. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  301. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  302. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  303. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  304. package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
  305. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  306. package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
  307. package/dist/packem_shared/sql-editor-panel-Smfl_FDF.js +0 -2562
  308. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  309. package/dist/packem_shared/studio-9Mq0PdMi.js +0 -10831
  310. package/dist/packem_shared/table-_RzNvy3R.js +0 -246
  311. package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
  312. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  313. package/dist/packem_shared/use-admin-query-4JQW2rr1.js +0 -88
  314. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  315. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  316. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
@@ -0,0 +1,4 @@
1
+ import{c as te}from"react/compiler-runtime";import{useState as X}from"react";import{u as se}from"../packem_shared/button-BkCrNcAs.js";import{c as re,f as oe}from"../packem_shared/card-BMKx5UdA.js";import{u as ce}from"../packem_shared/input-JHu63lTv.js";import{useT as ae}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{a as me}from"../packem_shared/cf-links-Dmg86v1D.js";import{c as pe,f as ue,b as fe}from"../packem_shared/internal-zkEvTqy8.js";import{jsx as r,jsxs as h}from"react/jsx-runtime";const he=e=>{const t=te(23),{destination:s}=e,f=ae();let g;t[0]!==s.snippet?(g=()=>{pe(s.snippet)},t[0]=s.snippet,t[1]=g):g=t[1];const m=g;let o;t[2]!==s.title?(o=r("h4",{className:"text-sm font-semibold",children:s.title}),t[2]=s.title,t[3]=o):o=t[3];let a;t[4]!==s.description?(a=r("p",{className:"text-sm text-muted-foreground",children:s.description}),t[4]=s.description,t[5]=a):a=t[5];let d;t[6]!==o||t[7]!==a?(d=h("div",{children:[o,a]}),t[6]=o,t[7]=a,t[8]=d):d=t[8];const F=`drain-copy-${s.id}`;let l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==F||t[13]!==l?(n=r(se,{"data-testid":F,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=F,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=h("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==s.snippet?(c=r("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:s.snippet}),t[18]=s.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=r(re,{className:"py-0","data-testid":"drain-card",children:h(oe,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},_e=()=>{const e=te(88),t=ae();let s;e[0]!==t?(s=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=s):s=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];const g=f.join(`
2
+ `);let m;e[3]!==t?(m=t("Logpush"),e[3]=t,e[4]=m):m=e[4];let o;e[5]!==s||e[6]!==m?(o={description:s,id:"logpush",snippet:g,title:m},e[5]=s,e[6]=m,e[7]=o):o=e[7];let a;e[8]!==t?(a=t("Send logs programmatically to a Worker for custom capture and forwarding."),e[8]=t,e[9]=a):a=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"],e[10]=d):d=e[10];const F=d.join(`
3
+ `);let l;e[11]!==t?(l=t("Tail Workers"),e[11]=t,e[12]=l):l=e[12];let n;e[13]!==a||e[14]!==l?(n={description:a,id:"tail-worker",snippet:F,title:l},e[13]=a,e[14]=l,e[15]=n):n=e[15];let i;e[16]!==t?(i=t("Retain and query recent request logs directly in Cloudflare's dashboard."),e[16]=t,e[17]=i):i=e[17];let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=["{",' "observability": { "enabled": true }',"}"],e[18]=c):c=e[18];const x=c.join(`
4
+ `);let y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let P;e[24]!==b||e[25]!==o||e[26]!==n?(P=[o,n,b],e[24]=b,e[25]=o,e[26]=n,e[27]=P):P=e[27];const V=P,[p,le]=X(""),[k,Z]=X(!1),[u,U]=X(null);let z;if(e[28]!==t||e[29]!==p){const G=async()=>{const Q=p.trim();if(Q==="")return;const ee="fetch"in globalThis?globalThis.fetch:void 0;if(ee===void 0){U({kind:"error",message:t("fetch is unavailable in this environment.")});return}const ie={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};Z(!0),U(null);const de=performance.now();try{const H=await ee(Q,{body:JSON.stringify(ie),headers:{"Content-Type":"application/json"},method:"POST"});U({kind:"success",latencyMs:Math.round(performance.now()-de),status:H.status})}catch(H){U({kind:"error",message:fe(H)})}Z(!1)};z=()=>{ue(G())},e[28]=t,e[29]=p,e[30]=z}else z=e[30];const Y=z;let J;e[31]===Symbol.for("react.memo_cache_sentinel")?(J=G=>{le(G.target.value)},e[31]=J):J=e[31];const ne=J;let v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself — forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=r("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let C;e[40]!==t?(C=t("Cloudflare destinations"),e[40]=t,e[41]=C):C=e[41];let _;e[42]!==C?(_=r("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C}),e[42]=C,e[43]=_):_=e[43];let T;e[44]!==V?(T=V.map(ge),e[44]=V,e[45]=T):T=e[45];let $;e[46]!==_||e[47]!==T?($=h("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[_,T]}),e[46]=_,e[47]=T,e[48]=$):$=e[48];let L;e[49]!==t?(L=t("Webhook test"),e[49]=t,e[50]=L):L=e[50];let j;e[51]!==L?(j=r("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:L}),e[51]=L,e[52]=j):j=e[52];let O;e[53]!==t?(O=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=O):O=e[54];let M;e[55]!==O?(M=r("p",{className:"mb-2 text-sm text-muted-foreground",children:O}),e[55]=O,e[56]=M):M=e[56];let R;e[57]!==t?(R=t("https://example.com/logs"),e[57]=t,e[58]=R):R=e[58];let q;e[59]!==R||e[60]!==p?(q=r(ce,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ne,placeholder:R,type:"url",value:p}),e[59]=R,e[60]=p,e[61]=q):q=e[61];let W;e[62]!==k||e[63]!==p?(W=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=W):W=e[64];let I;e[65]!==k||e[66]!==t?(I=t(k?"Sending…":"Send test event"),e[65]=k,e[66]=t,e[67]=I):I=e[67];let A;e[68]!==Y||e[69]!==W||e[70]!==I?(A=r(se,{"data-testid":"drain-webhook-test",disabled:W,onClick:Y,children:I}),e[68]=Y,e[69]=W,e[70]=I,e[71]=A):A=e[71];let B;e[72]!==q||e[73]!==A?(B=h("div",{className:"flex flex-wrap items-center gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=B):B=e[74];let D;e[75]!==u||e[76]!==t?(D=u!==null&&r("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered — status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=D):D=e[77];let E;e[78]!==j||e[79]!==M||e[80]!==B||e[81]!==D?(E=r(re,{className:"py-0",children:r(oe,{className:"p-3",children:h("section",{"data-testid":"drain-webhook",children:[j,M,B,D]})})}),e[78]=j,e[79]=M,e[80]=B,e[81]=D,e[82]=E):E=e[82];let K;return e[83]!==w||e[84]!==S||e[85]!==$||e[86]!==E?(K=h("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,$,E]}),e[83]=w,e[84]=S,e[85]=$,e[86]=E,e[87]=K):K=e[87],K};function ge(e){return r(he,{destination:e},e.id)}export{_e as default};
@@ -0,0 +1 @@
1
+ import{c as w}from"react/compiler-runtime";import{useMemo as O,useState as D}from"react";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as N}from"../packem_shared/utils-bhneXptQ.js";import{MigrationsPanel as J}from"../packem_shared/MigrationsPanel-BAnvY79E.js";import{useNavigate as E,useSearch as U}from"@tanstack/react-router";import{U as H}from"../packem_shared/error-alert-_2q2VtVG.js";import{E as P}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as S}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as V,f as W}from"../packem_shared/internal-zkEvTqy8.js";import{S as _}from"../packem_shared/schema-diagram-GVgnLWTf.js";import{jsx as l,jsxs as g}from"react/jsx-runtime";const k=t=>typeof t=="object"&&t!==null,z=t=>k(t)&&k(t.fields)&&k(t.indexes)&&k(t.relations)&&typeof t.shardMode=="string",B=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(a){return{error:`baseline is not valid JSON: ${a instanceof Error?a.message:String(a)}`,status:"invalid"}}if(!k(e)||e.version!==1||!k(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(const[a,n]of Object.entries(e.tables))if(!z(n))return{error:`baseline table "${a}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},L=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((a,n)=>a===e.fields[n]),Q=(t,e,a,n)=>{const s=[];return a.kind!==n.kind&&s.push({severity:"breaking",summary:`field ${t}.${e} changed type: ${a.kind} → ${n.kind} — add a data migration to convert existing values`,table:t,scope:"table",type:"changedFieldKind"}),a.optional&&!n.optional?s.push({severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!a.optional&&n.optional&&s.push({scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},G=(t,e,a)=>a.optional?{scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},X=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.fields)){const i=e.fields[s];i===void 0?n.push(G(t,s,o)):n.push(...Q(t,s,i,o))}for(const s of Object.keys(e.fields))a.fields[s]===void 0&&n.push({severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},Y=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.indexes)){const i=e.indexes[s];if(i===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}L(i,o)||n.push({severity:"breaking",summary:`index ${s} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const s of Object.keys(e.indexes))a.indexes[s]===void 0&&n.push({severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},Z=(t,e,a,n)=>{for(const s of Object.keys(a.relations))e.relations[s]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))a.relations[s]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},ee=(t,e,a,n)=>{e.shardMode!==a.shardMode&&n.push({severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${a.shardMode} — its physical storage moves; add a data migration / re-shard plan`,table:t,scope:"table",type:"changedShardMode"}),X(t,e,a,n),Y(t,e,a,n),Z(t,e,a,n)},te=(t,e)=>{const a=[],n=t?.tables??{};for(const[s,o]of Object.entries(e.tables)){const i=n[s];if(i===void 0){a.push({scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}ee(s,i,o,a)}for(const s of Object.keys(n))e.tables[s]===void 0&&a.push({scope:"table",severity:"breaking",summary:`removed table ${s} — add a data migration if its data must be archived/cleaned up`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";a.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:a}},T=t=>Object.entries(t.fields).map(([e,a])=>({name:e,optional:a.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:a.kind})),F=(t,e)=>{const a={},n=t?.fields??{},s=e?.fields??{};for(const[o,i]of Object.entries(s)){const r=n[o];r===void 0?a[o]=t===void 0?"unchanged":"added":a[o]=r.kind===i.kind&&r.optional===i.optional?"unchanged":"changed"}for(const o of Object.keys(n))s[o]===void 0&&(a[o]="removed");return a},ae=(t,e)=>{const{changes:a}=te(t,e),n=new Set(a.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),s=[],o=(i,r)=>i?"added":n.has(r)?"changed":"context";for(const[i,r]of Object.entries(e.tables)){const c=t?.tables[i],u=o(c===void 0,i);s.push({columns:T(r),fieldStatus:F(c,r),name:i,shardMode:r.shardMode,status:u})}for(const[i,r]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&s.push({columns:T(r),fieldStatus:F(r,void 0),name:i,shardMode:r.shardMode,status:"removed"});return s.sort((i,r)=>i.name.localeCompare(r.name)),{breakingCount:a.filter(i=>i.severity==="breaking").length,changes:a,tables:s}},K=t=>{const e=B(t);return e.status==="ok"?e.snapshot:void 0},ne={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},se=t=>t==="global"?"global":"shard",ie=t=>{const e=w(24),{appliedAt:a,hash:n,onSelect:s,selected:o,seq:i}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let c;e[0]!==r?(c=N("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=c):c=e[1];const u=`sh-version-${n}`;let m;e[2]!==n||e[3]!==s?(m=()=>{s(n)},e[2]=n,e[3]=s,e[4]=m):m=e[4];let p;e[5]!==i?(p=g("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==n?(b=n.slice(0,7),e[7]=n,e[8]=b):b=e[8];let h;e[9]!==b?(h=l("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:b}),e[9]=b,e[10]=h):h=e[10];let f;e[11]!==p||e[12]!==h?(f=g("span",{className:"flex w-full items-baseline gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=f):f=e[13];let v;e[14]!==a?(v=V(a),e[14]=a,e[15]=v):v=e[15];let x;e[16]!==v?(x=l("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:v}),e[16]=v,e[17]=x):x=e[17];let d;return e[18]!==x||e[19]!==c||e[20]!==u||e[21]!==m||e[22]!==f?(d=l("li",{children:g("button",{className:c,"data-testid":u,onClick:m,type:"button",children:[f,x]})}),e[18]=x,e[19]=c,e[20]=u,e[21]=m,e[22]=f,e[23]=d):d=e[23],d},re=t=>{const e=w(26),{breaking:a,count:n,first:s}=t,o=q();if(s){let h;e[0]!==n?(h=l("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=h):h=e[1];let f;e[2]!==o?(f=o("tables"),e[2]=o,e[3]=f):f=e[3];let v;e[4]!==f?(v=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=v):v=e[5];let x;return e[6]!==h||e[7]!==v?(x=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[h,v]}),e[6]=h,e[7]=v,e[8]=x):x=e[8],x}const i=a>0&&"text-destructive";let r;e[9]!==i?(r=N("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=r):r=e[10];let c;e[11]!==n||e[12]!==r?(c=l("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=c):c=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let m;e[17]!==u?(m=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=m):m=e[18];let p;e[19]!==a||e[20]!==o?(p=a>0&&g("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:a})]}),e[19]=a,e[20]=o,e[21]=p):p=e[21];let b;return e[22]!==c||e[23]!==m||e[24]!==p?(b=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[c,m,p]}),e[22]=c,e[23]=m,e[24]=p,e[25]=b):b=e[25],b},A={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},oe=(t,e)=>{const a=`${A[t.type].action} ${e} `;return t.summary.startsWith(a)?t.summary.slice(a.length):t.summary},de=t=>{const e=new Map;for(const n of t){const s=n.table??"",o=e.get(s);o===void 0?e.set(s,[n]):o.push(n)}const a=[...e].map(([n,s])=>({changes:s,table:n}));return[...a.filter(n=>n.table!==""),...a.filter(n=>n.table==="")]},le=t=>{const e=w(2),{children:a}=t;let n;return e[0]!==a?(n=l("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:a}),e[0]=a,e[1]=n):n=e[1],n},ce=({pane:t,shardKey:e=""})=>{const a=q(),n=E(),s=U({strict:!1}).version,o=d=>{W(n({search:{version:d},to:"/migrations"}))},i=S(I.schemaHistory,{},{shardKey:e}),r=i.data?.versions??[],c=s!==void 0&&r.some(d=>d.hash===s)?s:r[0]?.hash,u=r.findIndex(d=>d.hash===c),m=u===-1?void 0:r[u+1]?.hash,p=S(I.schemaVersion,{hash:c??""},{enabled:c!==void 0,shardKey:e}),b=S(I.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),h=O(()=>{const d=K(p.data?.version?.snapshotJson);if(d!==void 0)return ae(K(b.data?.version?.snapshotJson),d)},[p.data,b.data]),f=O(()=>(h?.tables??[]).map(d=>({columns:d.columns,name:d.name,tier:se(d.shardMode)})),[h]),v=O(()=>{const d={};for(const $ of h?.tables??[])d[$.name]=ne[$.status];return d},[h]);if(i.error!==null)return l(H,{error:i.errorSource,testId:"sh-error"});if(r.length===0)return l(P,{description:a("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:a("No schema versions recorded yet.")});const x=h?.changes??[];return g("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[g("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[l(le,{children:a("Schema versions")}),l("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:r.map(d=>l(ie,{appliedAt:d.appliedAt,hash:d.hash,onSelect:o,selected:d.hash===c,seq:d.seq},d.hash))})]}),g("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[l(re,{breaking:h?.breakingCount??0,count:m===void 0?f.length:x.length,first:m===void 0}),t==="diagram"?l("div",{className:"flex min-h-0 flex-1 flex-col",children:l(_,{fill:!0,nodeClasses:v,tables:f,testIdPrefix:"sh"})}):l("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:de(x).map(d=>{const $=(h?.tables??[]).find(y=>y.name===d.table);return g("section",{className:"mb-6",children:[g("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[l("span",{className:"font-mono text-[13px] text-foreground",children:d.table===""?a("schema"):d.table}),$!==void 0&&l("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:a("{count} columns",{count:$.columns.length})}),d.changes.length>1&&l("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:d.changes.length})]}),l("ul",{children:d.changes.map(y=>{const{action:C,kind:M}=A[y.type],j=y.severity==="breaking",R=oe(y,M);return g("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[l("span",{"aria-hidden":"true",className:N("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),g("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[a(C)," ",M]}),R!==d.table&&l("span",{className:N("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:R}),j&&l("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:a("breaking")})]},`${y.type}-${y.summary}`)})})]},d.table)})})]})]})},me=t=>N("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),je=t=>{const e=w(11),{initialShardKey:a}=t,n=q(),[s,o]=D("diagram");let i;e[0]!==s?(i=(p,b,h,f)=>g("button",{"aria-selected":s===p,className:me(s===p),"data-testid":h,onClick:()=>{o(p)},role:"tab",type:"button",children:[b,f!==void 0&&l("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),e[0]=s,e[1]=i):i=e[1];const r=i;let c;e[2]!==n||e[3]!==r?(c=g("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=c):c=e[4];let u;e[5]!==a||e[6]!==s?(u=l("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?l("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:l(J,{initialShardKey:a})}):l(ce,{pane:s,shardKey:a})}),e[5]=a,e[6]=s,e[7]=u):u=e[7];let m;return e[8]!==c||e[9]!==u?(m=g("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[c,u]}),e[8]=c,e[9]=u,e[10]=m):m=e[10],m};export{je as default};
@@ -0,0 +1 @@
1
+ import{c as U}from"react/compiler-runtime";import{useLunora as ae}from"@lunora/react";import{useState as L}from"react";import{u as j}from"../packem_shared/button-BkCrNcAs.js";import{f as vt,c as yt}from"../packem_shared/card-BMKx5UdA.js";import{E as Qe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{m as me,n as Ct,f as lt,b as $t,d as It,p as de}from"../packem_shared/table-DZAB8cs3.js";import{O as Ge}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{u as At}from"../packem_shared/use-auth-config-0EnNCdLu.js";import{useAutoRefresh as wt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{h as S,f as Nt,b as Dt,i as Ot}from"../packem_shared/internal-zkEvTqy8.js";import{u as X}from"../packem_shared/input-JHu63lTv.js";import{p as _t}from"../packem_shared/label-6uP1obNF.js";import{M as Rt}from"../packem_shared/modal-shell-CUwwWC2o.js";import{l as xt}from"../packem_shared/textarea-Bu2-jKAs.js";import{_ as ie}from"../packem_shared/use-async-submit-B32whHJO.js";import{jsx as l,jsxs as M,Fragment as it}from"react/jsx-runtime";const zt=t=>{const e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},Tt=t=>{const e=zt(t),r={};for(const[d,g]of Object.entries(e)){if(!Array.isArray(g)||g.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=g}return r},St=t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),G=t=>{const e=U(6),{children:r,htmlFor:d,label:g}=t;let i;e[0]!==d||e[1]!==g?(i=l(_t,{htmlFor:d,children:g}),e[0]=d,e[1]=g,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=M("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},se=({busy:t,canSubmit:e,children:r,destructive:d=!1,error:g,onClose:i,onSubmit:o,submitLabel:n,testId:a,title:s})=>{const m=K();return M(Rt,{label:s,onClose:i,panelTestId:`${a}-panel`,testId:`${a}-overlay`,variant:"dialog",children:[l("h2",{className:"text-sm font-semibold text-foreground",children:s}),r,g!==null&&l("p",{className:"text-sm text-destructive","data-testid":`${a}-error`,role:"alert",children:g}),M("div",{className:"flex justify-end gap-2 pt-1",children:[l(j,{"data-testid":`${a}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:m("Cancel")}),l(j,{"data-testid":`${a}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?m("Saving…"):n})]})]})},bt=t=>{const e=U(79),{mode:r,onClose:d,onDone:g,org:i}=t,o=ae(),n=K(),{busy:a,error:s,run:m}=ie();let h;e[0]!==i?(h=i?S(i.name):"",e[0]=i,e[1]=h):h=e[1];const[c,u]=L(h);let f;e[2]!==i?(f=i?S(i.slug):"",e[2]=i,e[3]=f):f=e[3];const[b,v]=L(f);let w;e[4]!==i?(w=i?S(i.logo):"",e[4]=i,e[5]=w):w=e[5];const[p,C]=L(w),[y,x]=L("");let $;e[6]!==r||e[7]!==i?.metadata?($=r==="edit"?St(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=$):$=e[8];const[I,z]=L($);let D;e[9]!==o||e[10]!==p||e[11]!==I||e[12]!==r||e[13]!==c||e[14]!==d||e[15]!==g||e[16]!==i?.id||e[17]!==y||e[18]!==m||e[19]!==b?(D=()=>{m(async()=>{const F=I.trim()===""?void 0:zt(I);r==="create"?await o.createAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:F,name:c.trim(),ownerId:y.trim()===""?void 0:y.trim(),slug:b.trim()===""?void 0:b.trim()}):await o.updateAuthOrganization({logo:p.trim()===""?void 0:p.trim(),metadata:F,name:c.trim()===""?void 0:c.trim(),organizationId:S(i?.id),slug:b.trim()===""?void 0:b.trim()}),g(),d()})},e[9]=o,e[10]=p,e[11]=I,e[12]=r,e[13]=c,e[14]=d,e[15]=g,e[16]=i?.id,e[17]=y,e[18]=m,e[19]=b,e[20]=D):D=e[20];const A=D;let k;e[21]!==r||e[22]!==c?(k=c.trim()!==""||r==="edit",e[21]=r,e[22]=c,e[23]=k):k=e[23];let O;e[24]!==r||e[25]!==n?(O=n(r==="create"?"Create":"Save"),e[24]=r,e[25]=n,e[26]=O):O=e[26];let _;e[27]!==r||e[28]!==n?(_=n(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=n,e[29]=_):_=e[29];let P;e[30]!==n?(P=n("name"),e[30]=n,e[31]=P):P=e[31];let q;e[32]===Symbol.for("react.memo_cache_sentinel")?(q=F=>{u(F.target.value)},e[32]=q):q=e[32];let B;e[33]!==c?(B=l(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:q,value:c}),e[33]=c,e[34]=B):B=e[34];let E;e[35]!==B||e[36]!==P?(E=l(G,{htmlFor:"org-form-name",label:P,children:B}),e[35]=B,e[36]=P,e[37]=E):E=e[37];let J;e[38]!==n?(J=n("Slug (optional — derived from name)"),e[38]=n,e[39]=J):J=e[39];let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=F=>{v(F.target.value)},e[40]=Q):Q=e[40];let R;e[41]!==b?(R=l(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:Q,value:b}),e[41]=b,e[42]=R):R=e[42];let T;e[43]!==J||e[44]!==R?(T=l(G,{htmlFor:"org-form-slug",label:J,children:R}),e[43]=J,e[44]=R,e[45]=T):T=e[45];let H;e[46]!==n?(H=n("Logo URL (optional)"),e[46]=n,e[47]=H):H=e[47];let le;e[48]===Symbol.for("react.memo_cache_sentinel")?(le=F=>{C(F.target.value)},e[48]=le):le=e[48];let Y;e[49]!==p?(Y=l(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:le,value:p}),e[49]=p,e[50]=Y):Y=e[50];let ee;e[51]!==H||e[52]!==Y?(ee=l(G,{htmlFor:"org-form-logo",label:H,children:Y}),e[51]=H,e[52]=Y,e[53]=ee):ee=e[53];let Z;e[54]!==r||e[55]!==y||e[56]!==n?(Z=r==="create"&&l(G,{htmlFor:"org-form-owner",label:n("Owner user id (optional)"),children:l(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:F=>{x(F.target.value)},value:y})}),e[54]=r,e[55]=y,e[56]=n,e[57]=Z):Z=e[57];let te;e[58]!==n?(te=n("Metadata (JSON, optional)"),e[58]=n,e[59]=te):te=e[59];let re;e[60]===Symbol.for("react.memo_cache_sentinel")?(re=F=>{z(F.target.value)},e[60]=re):re=e[60];let W;e[61]!==I?(W=l(xt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:re,value:I}),e[61]=I,e[62]=W):W=e[62];let N;e[63]!==te||e[64]!==W?(N=l(G,{htmlFor:"org-form-metadata",label:te,children:W}),e[63]=te,e[64]=W,e[65]=N):N=e[65];let oe;return e[66]!==a||e[67]!==s||e[68]!==d||e[69]!==A||e[70]!==E||e[71]!==T||e[72]!==ee||e[73]!==Z||e[74]!==N||e[75]!==k||e[76]!==O||e[77]!==_?(oe=M(se,{busy:a,canSubmit:k,error:s,onClose:d,onSubmit:A,submitLabel:O,testId:"org-form",title:_,children:[E,T,ee,Z,N]}),e[66]=a,e[67]=s,e[68]=d,e[69]=A,e[70]=E,e[71]=T,e[72]=ee,e[73]=Z,e[74]=N,e[75]=k,e[76]=O,e[77]=_,e[78]=oe):oe=e[78],oe},Mt=t=>{const e=U(40),{onClose:r,onDone:d,organizationId:g}=t,i=ae(),o=K(),{busy:n,error:a,run:s}=ie(),[m,h]=L(""),[c,u]=L("");let f;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==g||e[4]!==c||e[5]!==s||e[6]!==m?(f=()=>{s(async()=>{await i.addAuthOrgMember({organizationId:g,role:c.trim()===""?void 0:c.trim(),userId:m.trim()}),d(),r()})},e[0]=i,e[1]=r,e[2]=d,e[3]=g,e[4]=c,e[5]=s,e[6]=m,e[7]=f):f=e[7];const b=f;let v;e[8]!==m?(v=m.trim(),e[8]=m,e[9]=v):v=e[9];const w=v!=="";let p;e[10]!==o?(p=o("Add member"),e[10]=o,e[11]=p):p=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let y;e[14]!==o?(y=o("User id"),e[14]=o,e[15]=y):y=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=_=>{h(_.target.value)},e[16]=x):x=e[16];let $;e[17]!==m?($=l(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:x,value:m}),e[17]=m,e[18]=$):$=e[18];let I;e[19]!==y||e[20]!==$?(I=l(G,{htmlFor:"org-add-member-user",label:y,children:$}),e[19]=y,e[20]=$,e[21]=I):I=e[21];let z;e[22]!==o?(z=o("Role (optional)"),e[22]=o,e[23]=z):z=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=_=>{u(_.target.value)},e[24]=D):D=e[24];let A;e[25]!==c?(A=l(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:D,value:c}),e[25]=c,e[26]=A):A=e[26];let k;e[27]!==z||e[28]!==A?(k=l(G,{htmlFor:"org-add-member-role",label:z,children:A}),e[27]=z,e[28]=A,e[29]=k):k=e[29];let O;return e[30]!==n||e[31]!==a||e[32]!==r||e[33]!==b||e[34]!==k||e[35]!==w||e[36]!==p||e[37]!==C||e[38]!==I?(O=M(se,{busy:n,canSubmit:w,error:a,onClose:r,onSubmit:b,submitLabel:p,testId:"org-add-member",title:C,children:[I,k]}),e[30]=n,e[31]=a,e[32]=r,e[33]=b,e[34]=k,e[35]=w,e[36]=p,e[37]=C,e[38]=I,e[39]=O):O=e[39],O},Ft=t=>{const e=U(40),{onClose:r,onDone:d,organizationId:g}=t,i=ae(),o=K(),{busy:n,error:a,run:s}=ie(),[m,h]=L(""),[c,u]=L("");let f;e[0]!==i||e[1]!==m||e[2]!==r||e[3]!==d||e[4]!==g||e[5]!==c||e[6]!==s?(f=()=>{s(async()=>{await i.inviteAuthOrgMember({email:m.trim(),organizationId:g,role:c.trim()===""?void 0:c.trim()}),d(),r()})},e[0]=i,e[1]=m,e[2]=r,e[3]=d,e[4]=g,e[5]=c,e[6]=s,e[7]=f):f=e[7];const b=f;let v;e[8]!==m?(v=m.trim(),e[8]=m,e[9]=v):v=e[9];const w=v!=="";let p;e[10]!==o?(p=o("Send invitation"),e[10]=o,e[11]=p):p=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let y;e[14]!==o?(y=o("email"),e[14]=o,e[15]=y):y=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=_=>{h(_.target.value)},e[16]=x):x=e[16];let $;e[17]!==m?($=l(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:x,type:"email",value:m}),e[17]=m,e[18]=$):$=e[18];let I;e[19]!==y||e[20]!==$?(I=l(G,{htmlFor:"org-invite-member-email",label:y,children:$}),e[19]=y,e[20]=$,e[21]=I):I=e[21];let z;e[22]!==o?(z=o("Role (optional)"),e[22]=o,e[23]=z):z=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=_=>{u(_.target.value)},e[24]=D):D=e[24];let A;e[25]!==c?(A=l(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:D,value:c}),e[25]=c,e[26]=A):A=e[26];let k;e[27]!==z||e[28]!==A?(k=l(G,{htmlFor:"org-invite-member-role",label:z,children:A}),e[27]=z,e[28]=A,e[29]=k):k=e[29];let O;return e[30]!==n||e[31]!==a||e[32]!==r||e[33]!==b||e[34]!==k||e[35]!==w||e[36]!==p||e[37]!==C||e[38]!==I?(O=M(se,{busy:n,canSubmit:w,error:a,onClose:r,onSubmit:b,submitLabel:p,testId:"org-invite-member",title:C,children:[I,k]}),e[30]=n,e[31]=a,e[32]=r,e[33]=b,e[34]=k,e[35]=w,e[36]=p,e[37]=C,e[38]=I,e[39]=O):O=e[39],O},Et=t=>{const e=U(32),{member:r,onClose:d,onDone:g}=t,i=ae(),o=K(),{busy:n,error:a,run:s}=ie();let m;e[0]!==r.role?(m=()=>S(r.role),e[0]=r.role,e[1]=m):m=e[1];const[h,c]=L(m);let u;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==g||e[6]!==h||e[7]!==s?(u=()=>{s(async()=>{await i.setAuthOrgMemberRole({memberId:S(r.id),role:h.trim()}),g(),d()})},e[2]=i,e[3]=r.id,e[4]=d,e[5]=g,e[6]=h,e[7]=s,e[8]=u):u=e[8];const f=u;let b;e[9]!==h?(b=h.trim(),e[9]=h,e[10]=b):b=e[10];const v=b!=="";let w;e[11]!==o?(w=o("Save"),e[11]=o,e[12]=w):w=e[12];let p;e[13]!==o?(p=o("Change member role"),e[13]=o,e[14]=p):p=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=z=>{c(z.target.value)},e[17]=y):y=e[17];let x;e[18]!==h?(x=l(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:y,value:h}),e[18]=h,e[19]=x):x=e[19];let $;e[20]!==C||e[21]!==x?($=l(G,{htmlFor:"org-member-role-value",label:C,children:x}),e[20]=C,e[21]=x,e[22]=$):$=e[22];let I;return e[23]!==n||e[24]!==a||e[25]!==d||e[26]!==f||e[27]!==$||e[28]!==v||e[29]!==w||e[30]!==p?(I=l(se,{busy:n,canSubmit:v,error:a,onClose:d,onSubmit:f,submitLabel:w,testId:"org-member-role",title:p,children:$}),e[23]=n,e[24]=a,e[25]=d,e[26]=f,e[27]=$,e[28]=v,e[29]=w,e[30]=p,e[31]=I):I=e[31],I},ft=t=>{const e=U(36),{mode:r,onClose:d,onDone:g,organizationId:i,team:o}=t,n=ae(),a=K(),{busy:s,error:m,run:h}=ie();let c;e[0]!==o?(c=o?S(o.name):"",e[0]=o,e[1]=c):c=e[1];const[u,f]=L(c);let b;e[2]!==n||e[3]!==r||e[4]!==u||e[5]!==d||e[6]!==g||e[7]!==i||e[8]!==h||e[9]!==o?.id?(b=()=>{h(async()=>{await(r==="create"?n.createAuthOrgTeam({name:u.trim(),organizationId:i}):n.updateAuthOrgTeam({name:u.trim(),teamId:S(o?.id)})),g(),d()})},e[2]=n,e[3]=r,e[4]=u,e[5]=d,e[6]=g,e[7]=i,e[8]=h,e[9]=o?.id,e[10]=b):b=e[10];const v=b;let w;e[11]!==u?(w=u.trim(),e[11]=u,e[12]=w):w=e[12];const p=w!=="";let C;e[13]!==r||e[14]!==a?(C=a(r==="create"?"Create":"Save"),e[13]=r,e[14]=a,e[15]=C):C=e[15];let y;e[16]!==r||e[17]!==a?(y=a(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=a,e[18]=y):y=e[18];let x;e[19]!==a?(x=a("name"),e[19]=a,e[20]=x):x=e[20];let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=A=>{f(A.target.value)},e[21]=$):$=e[21];let I;e[22]!==u?(I=l(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:$,value:u}),e[22]=u,e[23]=I):I=e[23];let z;e[24]!==x||e[25]!==I?(z=l(G,{htmlFor:"org-team-form-name",label:x,children:I}),e[24]=x,e[25]=I,e[26]=z):z=e[26];let D;return e[27]!==s||e[28]!==m||e[29]!==d||e[30]!==v||e[31]!==z||e[32]!==p||e[33]!==C||e[34]!==y?(D=l(se,{busy:s,canSubmit:p,error:m,onClose:d,onSubmit:v,submitLabel:C,testId:"org-team-form",title:y,children:z}),e[27]=s,e[28]=m,e[29]=d,e[30]=v,e[31]=z,e[32]=p,e[33]=C,e[34]=y,e[35]=D):D=e[35],D},Lt=t=>{const e=U(30),{onClose:r,onDone:d,teamId:g}=t,i=ae(),o=K(),{busy:n,error:a,run:s}=ie(),[m,h]=L("");let c;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==s||e[4]!==g||e[5]!==m?(c=()=>{s(async()=>{await i.addAuthOrgTeamMember({teamId:g,userId:m.trim()}),d(),r()})},e[0]=i,e[1]=r,e[2]=d,e[3]=s,e[4]=g,e[5]=m,e[6]=c):c=e[6];const u=c;let f;e[7]!==m?(f=m.trim(),e[7]=m,e[8]=f):f=e[8];const b=f!=="";let v;e[9]!==o?(v=o("Add member"),e[9]=o,e[10]=v):v=e[10];let w;e[11]!==o?(w=o("Add team member"),e[11]=o,e[12]=w):w=e[12];let p;e[13]!==o?(p=o("User id"),e[13]=o,e[14]=p):p=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=I=>{h(I.target.value)},e[15]=C):C=e[15];let y;e[16]!==m?(y=l(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:m}),e[16]=m,e[17]=y):y=e[17];let x;e[18]!==p||e[19]!==y?(x=l(G,{htmlFor:"org-team-add-member-user",label:p,children:y}),e[18]=p,e[19]=y,e[20]=x):x=e[20];let $;return e[21]!==n||e[22]!==a||e[23]!==r||e[24]!==u||e[25]!==b||e[26]!==v||e[27]!==w||e[28]!==x?($=l(se,{busy:n,canSubmit:b,error:a,onClose:r,onSubmit:u,submitLabel:v,testId:"org-team-add-member",title:w,children:x}),e[21]=n,e[22]=a,e[23]=r,e[24]=u,e[25]=b,e[26]=v,e[27]=w,e[28]=x,e[29]=$):$=e[29],$},pt=t=>{const e=U(47),{mode:r,onClose:d,onDone:g,organizationId:i,role:o}=t,n=ae(),a=K(),{busy:s,error:m,run:h}=ie();let c;e[0]!==o?(c=o?S(o.role):"",e[0]=o,e[1]=c):c=e[1];const[u,f]=L(c);let b;e[2]!==r||e[3]!==o?.permission?(b=r==="edit"?St(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=b):b=e[4];const[v,w]=L(b);let p;e[5]!==n||e[6]!==r||e[7]!==u||e[8]!==d||e[9]!==g||e[10]!==i||e[11]!==v||e[12]!==o?.id||e[13]!==h?(p=()=>{h(async()=>{const _=Tt(v);await(r==="create"?n.createAuthOrgRole({organizationId:i,permission:_,role:u.trim()}):n.updateAuthOrgRole({permission:_,roleId:S(o?.id)})),g(),d()})},e[5]=n,e[6]=r,e[7]=u,e[8]=d,e[9]=g,e[10]=i,e[11]=v,e[12]=o?.id,e[13]=h,e[14]=p):p=e[14];const C=p;let y;e[15]!==r||e[16]!==u||e[17]!==v?(y=v.trim()!==""&&(r==="edit"||u.trim()!==""),e[15]=r,e[16]=u,e[17]=v,e[18]=y):y=e[18];let x;e[19]!==r||e[20]!==a?(x=a(r==="create"?"Create":"Save"),e[19]=r,e[20]=a,e[21]=x):x=e[21];let $;e[22]!==r||e[23]!==a?($=a(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=a,e[24]=$):$=e[24];let I;e[25]!==r||e[26]!==u||e[27]!==a?(I=r==="create"&&l(G,{htmlFor:"org-role-form-name",label:a("Role name"),children:l(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:_=>{f(_.target.value)},value:u})}),e[25]=r,e[26]=u,e[27]=a,e[28]=I):I=e[28];let z;e[29]!==a?(z=a('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=a,e[30]=z):z=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=_=>{w(_.target.value)},e[31]=D):D=e[31];let A;e[32]!==v?(A=l(xt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:D,value:v}),e[32]=v,e[33]=A):A=e[33];let k;e[34]!==A||e[35]!==z?(k=l(G,{htmlFor:"org-role-form-permission",label:z,children:A}),e[34]=A,e[35]=z,e[36]=k):k=e[36];let O;return e[37]!==s||e[38]!==m||e[39]!==d||e[40]!==C||e[41]!==k||e[42]!==y||e[43]!==x||e[44]!==$||e[45]!==I?(O=M(se,{busy:s,canSubmit:y,error:m,onClose:d,onSubmit:C,submitLabel:x,testId:"org-role-form",title:$,children:[I,k]}),e[37]=s,e[38]=m,e[39]=d,e[40]=C,e[41]=k,e[42]=y,e[43]=x,e[44]=$,e[45]=I,e[46]=O):O=e[46],O},kt=t=>{const e=U(18),{action:r,message:d,onClose:g,onDone:i,testId:o,title:n}=t,a=K(),{busy:s,error:m,run:h}=ie();let c;e[0]!==r||e[1]!==g||e[2]!==i||e[3]!==h?(c=()=>{h(async()=>{await r(),i(),g()})},e[0]=r,e[1]=g,e[2]=i,e[3]=h,e[4]=c):c=e[4];const u=c;let f;e[5]!==a?(f=a("Delete"),e[5]=a,e[6]=f):f=e[6];let b;e[7]!==d?(b=l("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=b):b=e[8];let v;return e[9]!==s||e[10]!==m||e[11]!==g||e[12]!==u||e[13]!==f||e[14]!==b||e[15]!==o||e[16]!==n?(v=l(se,{busy:s,canSubmit:!0,destructive:!0,error:m,onClose:g,onSubmit:u,submitLabel:f,testId:o,title:n,children:b}),e[9]=s,e[10]=m,e[11]=g,e[12]=u,e[13]=f,e[14]=b,e[15]=o,e[16]=n,e[17]=v):v=e[17],v},Ve=t=>{const e=U(13),{action:r,children:d,heading:g,testId:i}=t;let o;e[0]!==g?(o=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g}),e[0]=g,e[1]=o):o=e[1];let n;e[2]!==r?(n=r!==void 0&&l("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=n):n=e[3];let a;e[4]!==o||e[5]!==n?(a=M("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,n]}),e[4]=o,e[5]=n,e[6]=a):a=e[6];let s;e[7]!==d?(s=l(vt,{className:"px-0",children:d}),e[7]=d,e[8]=s):s=e[8];let m;return e[9]!==a||e[10]!==s||e[11]!==i?(m=M(yt,{className:"overflow-hidden py-0","data-testid":i,children:[a,s]}),e[9]=a,e[10]=s,e[11]=i,e[12]=m):m=e[12],m},Xe=t=>{const e=U(23),{columns:r,rowActions:d,rowPrefix:g,rows:i}=t,o=K();let n;e[0]!==r?(n=r.map(jt),e[0]=r,e[1]=n):n=e[1];let a;e[2]!==o?(a=o("Actions"),e[2]=o,e[3]=a):a=e[3];let s;e[4]!==a?(s=l(me,{"aria-label":a}),e[4]=a,e[5]=s):s=e[5];let m;e[6]!==n||e[7]!==s?(m=l(Ct,{children:M(lt,{children:[n,s]})}),e[6]=n,e[7]=s,e[8]=m):m=e[8];let h;if(e[9]!==r||e[10]!==d||e[11]!==g||e[12]!==i){let f;e[14]!==r||e[15]!==d||e[16]!==g?(f=(b,v)=>{const w=S(b.id),p=w===""?`index-${v.toString()}`:w;return M(lt,{"data-testid":`${g}-${p}`,children:[r.map(C=>l(de,{className:C.className,children:C.render(b)},C.head)),l(de,{children:l("div",{className:"flex justify-end gap-1",children:d(b)})})]},p)},e[14]=r,e[15]=d,e[16]=g,e[17]=f):f=e[17],h=i.map(f),e[9]=r,e[10]=d,e[11]=g,e[12]=i,e[13]=h}else h=e[13];let c;e[18]!==h?(c=l($t,{children:h}),e[18]=h,e[19]=c):c=e[19];let u;return e[20]!==m||e[21]!==c?(u=M(It,{children:[m,c]}),e[20]=m,e[21]=c,e[22]=u):u=e[22],u};function jt(t){return l(me,{children:t.head},t.head)}const Pt=t=>{const e=U(30),{actionBusy:r,onRemoveMember:d,memberColumns:g,members:i,onDialog:o}=t,n=K();let a;e[0]!==o?(a=()=>{o({kind:"add-member"})},e[0]=o,e[1]=a):a=e[1];let s;e[2]!==n?(s=n("Add member"),e[2]=n,e[3]=s):s=e[3];let m;e[4]!==a||e[5]!==s?(m=l(j,{"data-testid":"org-open-add-member",onClick:a,size:"xs",type:"button",variant:"outline",children:s}),e[4]=a,e[5]=s,e[6]=m):m=e[6];let h;e[7]!==o?(h=()=>{o({kind:"invite-member"})},e[7]=o,e[8]=h):h=e[8];let c;e[9]!==n?(c=n("Invite member"),e[9]=n,e[10]=c):c=e[10];let u;e[11]!==h||e[12]!==c?(u=l(j,{"data-testid":"org-open-invite-member",onClick:h,size:"xs",type:"button",variant:"outline",children:c}),e[11]=h,e[12]=c,e[13]=u):u=e[13];let f;e[14]!==m||e[15]!==u?(f=M(it,{children:[m,u]}),e[14]=m,e[15]=u,e[16]=f):f=e[16];let b;e[17]!==n?(b=n("Members"),e[17]=n,e[18]=b):b=e[18];let v;e[19]!==r||e[20]!==g||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==n?(v=i.length===0?l("div",{className:"p-3",children:l(Qe,{testId:"org-members-empty",title:n("No members.")})}):l(Xe,{columns:g,rowActions:p=>M(it,{children:[l(j,{"data-testid":`org-member-role-${S(p.id)}`,onClick:()=>{o({kind:"member-role",member:p})},size:"xs",type:"button",variant:"ghost",children:n("Change role")}),l(j,{"data-testid":`org-remove-member-${S(p.id)}`,disabled:r,onClick:()=>{d(S(p.id))},size:"xs",type:"button",variant:"ghost",children:n("Remove")})]}),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=g,e[21]=i,e[22]=o,e[23]=d,e[24]=n,e[25]=v):v=e[25];let w;return e[26]!==f||e[27]!==b||e[28]!==v?(w=l(Ve,{action:f,heading:b,testId:"org-members",children:v}),e[26]=f,e[27]=b,e[28]=v,e[29]=w):w=e[29],w},Bt=t=>{const e=U(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:g,selectedTeam:i,teamColumns:o,teams:n}=t,a=K();let s;e[0]!==d?(s=()=>{d({kind:"team-create"})},e[0]=d,e[1]=s):s=e[1];let m;e[2]!==a?(m=a("New team"),e[2]=a,e[3]=m):m=e[3];let h;e[4]!==s||e[5]!==m?(h=l(j,{"data-testid":"org-open-create-team",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[4]=s,e[5]=m,e[6]=h):h=e[6];let c;e[7]!==a?(c=a("Teams"),e[7]=a,e[8]=c):c=e[8];let u;e[9]!==r||e[10]!==d||e[11]!==g||e[12]!==i||e[13]!==a||e[14]!==o||e[15]!==n?(u=n.length===0?l("div",{className:"p-3",children:l(Qe,{testId:"org-teams-empty",title:a("No teams.")})}):l(Xe,{columns:o,rowActions:b=>M(it,{children:[l(j,{"aria-pressed":i===S(b.id),"data-testid":`org-team-select-${S(b.id)}`,onClick:()=>{g(S(b.id))},size:"xs",type:"button",variant:"ghost",children:a("Members")}),l(j,{"data-testid":`org-team-rename-${S(b.id)}`,onClick:()=>{d({kind:"team-rename",team:b})},size:"xs",type:"button",variant:"ghost",children:a("Rename")}),l(j,{"data-testid":`org-team-delete-${S(b.id)}`,onClick:()=>{r(b)},size:"xs",type:"button",variant:"ghost",children:a("Delete")})]}),rowPrefix:"org-team",rows:n}),e[9]=r,e[10]=d,e[11]=g,e[12]=i,e[13]=a,e[14]=o,e[15]=n,e[16]=u):u=e[16];let f;return e[17]!==h||e[18]!==c||e[19]!==u?(f=l(Ve,{action:h,heading:c,testId:"org-teams",children:u}),e[17]=h,e[18]=c,e[19]=u,e[20]=f):f=e[20],f},Jt=t=>{const e=U(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:g,selectedTeam:i,teamMemberColumns:o,teamMembers:n}=t,a=K();let s;e[0]!==g||e[1]!==i?(s=()=>{g({kind:"team-add-member",teamId:i})},e[0]=g,e[1]=i,e[2]=s):s=e[2];let m;e[3]!==a?(m=a("Add member"),e[3]=a,e[4]=m):m=e[4];let h;e[5]!==s||e[6]!==m?(h=l(j,{"data-testid":"org-open-add-team-member",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[5]=s,e[6]=m,e[7]=h):h=e[7];let c;e[8]!==a?(c=a("Team members"),e[8]=a,e[9]=c):c=e[9];let u;e[10]!==r||e[11]!==d||e[12]!==a||e[13]!==o||e[14]!==n?(u=n.length===0?l("div",{className:"p-3",children:l(Qe,{testId:"org-team-members-empty",title:a("No team members.")})}):l(Xe,{columns:o,rowActions:b=>l(j,{"data-testid":`org-team-remove-member-${S(b.id)}`,disabled:r,onClick:()=>{d(S(b.id))},size:"xs",type:"button",variant:"ghost",children:a("Remove")}),rowPrefix:"org-team-member",rows:n}),e[10]=r,e[11]=d,e[12]=a,e[13]=o,e[14]=n,e[15]=u):u=e[15];let f;return e[16]!==h||e[17]!==c||e[18]!==u?(f=l(Ve,{action:h,heading:c,testId:"org-team-members",children:u}),e[16]=h,e[17]=c,e[18]=u,e[19]=f):f=e[19],f},Ut=t=>{const e=U(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:g,roles:i}=t,o=K();let n;e[0]!==d?(n=()=>{d({kind:"role-create"})},e[0]=d,e[1]=n):n=e[1];let a;e[2]!==o?(a=o("New role"),e[2]=o,e[3]=a):a=e[3];let s;e[4]!==n||e[5]!==a?(s=l(j,{"data-testid":"org-open-create-role",onClick:n,size:"xs",type:"button",variant:"outline",children:a}),e[4]=n,e[5]=a,e[6]=s):s=e[6];let m;e[7]!==o?(m=o("Roles"),e[7]=o,e[8]=m):m=e[8];let h;e[9]!==r||e[10]!==d||e[11]!==g||e[12]!==i||e[13]!==o?(h=i.length===0?l("div",{className:"p-3",children:l(Qe,{testId:"org-roles-empty",title:o("No custom roles.")})}):l(Xe,{columns:g,rowActions:u=>M(it,{children:[l(j,{"data-testid":`org-role-edit-${S(u.id)}`,onClick:()=>{d({kind:"role-edit",role:u})},size:"xs",type:"button",variant:"ghost",children:o("Edit")}),l(j,{"data-testid":`org-role-delete-${S(u.id)}`,onClick:()=>{r(S(u.id))},size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=g,e[12]=i,e[13]=o,e[14]=h):h=e[14];let c;return e[15]!==s||e[16]!==m||e[17]!==h?(c=l(Ve,{action:s,heading:m,testId:"org-roles",children:h}),e[15]=s,e[16]=m,e[17]=h,e[18]=c):c=e[18],c},Ht=t=>{const e=U(199),{organizationId:r,rolesEnabled:d,teamsEnabled:g}=t,i=ae(),o=K(),[n,a]=L(null),[s,m]=L(null),[h,c]=L(!1),[u,f]=L(null);let b;e[0]!==r?(b=["lunora-auth-org-members",r],e[0]=r,e[1]=b):b=e[1];let v;e[2]!==i||e[3]!==r?(v=()=>i.listAuthOrgMembers({limit:200,organizationId:r}),e[2]=i,e[3]=r,e[4]=v):v=e[4];const w=Ge(b,v);let p;e[5]!==r?(p=["lunora-auth-org-invitations",r],e[5]=r,e[6]=p):p=e[6];let C;e[7]!==i||e[8]!==r?(C=()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),e[7]=i,e[8]=r,e[9]=C):C=e[9];const y=Ge(p,C);let x;e[10]!==r?(x=["lunora-auth-org-teams",r],e[10]=r,e[11]=x):x=e[11];let $;e[12]!==i||e[13]!==r?($=()=>i.listAuthOrgTeams({limit:200,organizationId:r}),e[12]=i,e[13]=r,e[14]=$):$=e[14];let I;e[15]!==g?(I={enabled:g},e[15]=g,e[16]=I):I=e[16];const z=Ge(x,$,I);let D;e[17]!==r?(D=["lunora-auth-org-roles",r],e[17]=r,e[18]=D):D=e[18];let A;e[19]!==i||e[20]!==r?(A=()=>i.listAuthOrgRoles({limit:200,organizationId:r}),e[19]=i,e[20]=r,e[21]=A):A=e[21];let k;e[22]!==d?(k={enabled:d},e[22]=d,e[23]=k):k=e[23];const O=Ge(D,A,k);let _;e[24]!==s?(_=["lunora-auth-org-team-members",s],e[24]=s,e[25]=_):_=e[25];let P;e[26]!==i||e[27]!==s?(P=()=>i.listAuthOrgTeamMembers({limit:200,teamId:s??""}),e[26]=i,e[27]=s,e[28]=P):P=e[28];const q=s!==null;let B;e[29]!==q?(B={enabled:q},e[29]=q,e[30]=B):B=e[30];const E=Ge(_,P,B);let J;e[31]!==w.data?.rows?(J=w.data?.rows??[],e[31]=w.data?.rows,e[32]=J):J=e[32];const Q=J;let R;e[33]!==y.data?.rows?(R=y.data?.rows??[],e[33]=y.data?.rows,e[34]=R):R=e[34];const T=R;let H;e[35]!==z.data?.rows?(H=z.data?.rows??[],e[35]=z.data?.rows,e[36]=H):H=e[36];const le=H;let Y;e[37]!==O.data?.rows?(Y=O.data?.rows??[],e[37]=O.data?.rows,e[38]=Y):Y=e[38];const ee=Y;let Z;e[39]!==s||e[40]!==E?(Z=s===null?[]:E.data?.rows??[],e[39]=s,e[40]=E,e[41]=Z):Z=e[41];const te=Z,re=w.error??y.error??z.error??O.error??E.error;let W;e[42]!==y||e[43]!==w||e[44]!==d||e[45]!==O||e[46]!==s||e[47]!==E||e[48]!==g||e[49]!==z?(W=()=>{w.refetch(),y.refetch(),g&&z.refetch(),d&&O.refetch(),s!==null&&E.refetch()},e[42]=y,e[43]=w,e[44]=d,e[45]=O,e[46]=s,e[47]=E,e[48]=g,e[49]=z,e[50]=W):W=e[50];const N=W;wt(N,!0);let oe;e[51]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{a(null)},e[51]=oe):oe=e[51];const F=oe;let Ye;e[52]!==N?(Ye=V=>{Nt((async()=>{c(!0),f(null);try{await V(),N(),c(!1)}catch(at){f(Dt(at)),c(!1)}})())},e[52]=N,e[53]=Ye):Ye=e[53];const ne=Ye;let Ze;e[54]!==i||e[55]!==o?(Ze=V=>{const at=S(V.id);a({action:async()=>{await i.removeAuthOrgTeam({teamId:at}),m(ht=>ht===at?null:ht)},kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},e[54]=i,e[55]=o,e[56]=Ze):Ze=e[56];const st=Ze;let ce;e[57]!==o?(ce=o("userId"),e[57]=o,e[58]=ce):ce=e[58];let ue;e[59]!==ce?(ue={head:ce,render:Kt},e[59]=ce,e[60]=ue):ue=e[60];let ge;e[61]!==o?(ge=o("role"),e[61]=o,e[62]=ge):ge=e[62];let he;e[63]!==ge?(he={head:ge,render:qt},e[63]=ge,e[64]=he):he=e[64];let We;e[65]!==ue||e[66]!==he?(We=[ue,he],e[65]=ue,e[66]=he,e[67]=We):We=e[67];const mt=We;let be;e[68]!==o?(be=o("email"),e[68]=o,e[69]=be):be=e[69];let fe;e[70]!==be?(fe={head:be,render:Gt},e[70]=be,e[71]=fe):fe=e[71];let pe;e[72]!==o?(pe=o("role"),e[72]=o,e[73]=pe):pe=e[73];let ve;e[74]!==pe?(ve={head:pe,render:Qt},e[74]=pe,e[75]=ve):ve=e[75];let ye;e[76]!==o?(ye=o("status"),e[76]=o,e[77]=ye):ye=e[77];let Ce;e[78]!==ye?(Ce={head:ye,render:Vt},e[78]=ye,e[79]=Ce):Ce=e[79];let et;e[80]!==fe||e[81]!==ve||e[82]!==Ce?(et=[fe,ve,Ce],e[80]=fe,e[81]=ve,e[82]=Ce,e[83]=et):et=e[83];const dt=et;let $e;e[84]!==o?($e=o("id"),e[84]=o,e[85]=$e):$e=e[85];let Ie;e[86]!==$e?(Ie={className:"font-mono text-xs",head:$e,render:Xt},e[86]=$e,e[87]=Ie):Ie=e[87];let we;e[88]!==o?(we=o("name"),e[88]=o,e[89]=we):we=e[89];let xe;e[90]!==we?(xe={head:we,render:Yt},e[90]=we,e[91]=xe):xe=e[91];let tt;e[92]!==Ie||e[93]!==xe?(tt=[Ie,xe],e[92]=Ie,e[93]=xe,e[94]=tt):tt=e[94];const ct=tt;let ze;e[95]!==o?(ze=o("userId"),e[95]=o,e[96]=ze):ze=e[96];let rt;e[97]!==ze?(rt=[{head:ze,render:Zt}],e[97]=ze,e[98]=rt):rt=e[98];const ut=rt;let Se;e[99]!==o?(Se=o("role"),e[99]=o,e[100]=Se):Se=e[100];let ke;e[101]!==Se?(ke={head:Se,render:Wt},e[101]=Se,e[102]=ke):ke=e[102];let Ae;e[103]!==o?(Ae=o("Permission"),e[103]=o,e[104]=Ae):Ae=e[104];let Ne;e[105]!==Ae?(Ne={className:"font-mono text-xs whitespace-pre-wrap",head:Ae,render:er},e[105]=Ae,e[106]=Ne):Ne=e[106];let ot;e[107]!==ke||e[108]!==Ne?(ot=[ke,Ne],e[107]=ke,e[108]=Ne,e[109]=ot):ot=e[109];const gt=ot;let De;e[110]!==re?(De=re!==null&&l("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:re}),e[110]=re,e[111]=De):De=e[111];let Oe;e[112]!==u?(Oe=u!==null&&l("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:u}),e[112]=u,e[113]=Oe):Oe=e[113];let _e;e[114]!==i||e[115]!==ne?(_e=V=>{ne(()=>i.removeAuthOrgMember({memberId:V}))},e[114]=i,e[115]=ne,e[116]=_e):_e=e[116];let Re;e[117]!==h||e[118]!==mt||e[119]!==Q||e[120]!==_e?(Re=l(Pt,{actionBusy:h,memberColumns:mt,members:Q,onDialog:a,onRemoveMember:_e}),e[117]=h,e[118]=mt,e[119]=Q,e[120]=_e,e[121]=Re):Re=e[121];let Te;e[122]!==h||e[123]!==i||e[124]!==dt||e[125]!==T||e[126]!==ne||e[127]!==o?(Te=T.length>0&&l(Ve,{heading:o("Invitations"),testId:"org-invitations",children:l(Xe,{columns:dt,rowActions:V=>l(j,{"data-testid":`org-cancel-invitation-${S(V.id)}`,disabled:h,onClick:()=>{ne(()=>i.cancelAuthOrgInvitation({invitationId:S(V.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),rowPrefix:"org-invitation",rows:T})}),e[122]=h,e[123]=i,e[124]=dt,e[125]=T,e[126]=ne,e[127]=o,e[128]=Te):Te=e[128];let Me;e[129]!==st||e[130]!==s||e[131]!==ct||e[132]!==le||e[133]!==g?(Me=g&&l(Bt,{onConfirmDeleteTeam:st,onDialog:a,onSelectTeam:m,selectedTeam:s,teamColumns:ct,teams:le}),e[129]=st,e[130]=s,e[131]=ct,e[132]=le,e[133]=g,e[134]=Me):Me=e[134];let Fe;e[135]!==h||e[136]!==i||e[137]!==ne||e[138]!==s||e[139]!==ut||e[140]!==te||e[141]!==g?(Fe=g&&s!==null&&l(Jt,{actionBusy:h,onDialog:a,onRemoveTeamMember:V=>{ne(()=>i.removeAuthOrgTeamMember({teamMemberId:V}))},selectedTeam:s,teamMemberColumns:ut,teamMembers:te}),e[135]=h,e[136]=i,e[137]=ne,e[138]=s,e[139]=ut,e[140]=te,e[141]=g,e[142]=Fe):Fe=e[142];let Ee;e[143]!==i||e[144]!==gt||e[145]!==ee||e[146]!==d||e[147]!==o?(Ee=d&&l(Ut,{onConfirmDeleteRole:V=>{a({action:()=>i.deleteAuthOrgRole({roleId:V}),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},onDialog:a,roleColumns:gt,roles:ee}),e[143]=i,e[144]=gt,e[145]=ee,e[146]=d,e[147]=o,e[148]=Ee):Ee=e[148];let Le;e[149]!==n?.kind||e[150]!==r||e[151]!==N?(Le=n?.kind==="add-member"&&l(Mt,{onClose:F,onDone:N,organizationId:r}),e[149]=n?.kind,e[150]=r,e[151]=N,e[152]=Le):Le=e[152];let je;e[153]!==n?.kind||e[154]!==r||e[155]!==N?(je=n?.kind==="invite-member"&&l(Ft,{onClose:F,onDone:N,organizationId:r}),e[153]=n?.kind,e[154]=r,e[155]=N,e[156]=je):je=e[156];let Pe;e[157]!==n||e[158]!==N?(Pe=n?.kind==="member-role"&&l(Et,{member:n.member,onClose:F,onDone:N}),e[157]=n,e[158]=N,e[159]=Pe):Pe=e[159];let Be;e[160]!==n?.kind||e[161]!==r||e[162]!==N?(Be=n?.kind==="team-create"&&l(ft,{mode:"create",onClose:F,onDone:N,organizationId:r}),e[160]=n?.kind,e[161]=r,e[162]=N,e[163]=Be):Be=e[163];let Je;e[164]!==n||e[165]!==r||e[166]!==N?(Je=n?.kind==="team-rename"&&l(ft,{mode:"edit",onClose:F,onDone:N,organizationId:r,team:n.team}),e[164]=n,e[165]=r,e[166]=N,e[167]=Je):Je=e[167];let Ue;e[168]!==n||e[169]!==N?(Ue=n?.kind==="team-add-member"&&l(Lt,{onClose:F,onDone:N,teamId:n.teamId}),e[168]=n,e[169]=N,e[170]=Ue):Ue=e[170];let He;e[171]!==n?.kind||e[172]!==r||e[173]!==N?(He=n?.kind==="role-create"&&l(pt,{mode:"create",onClose:F,onDone:N,organizationId:r}),e[171]=n?.kind,e[172]=r,e[173]=N,e[174]=He):He=e[174];let Ke;e[175]!==n||e[176]!==r||e[177]!==N?(Ke=n?.kind==="role-edit"&&l(pt,{mode:"edit",onClose:F,onDone:N,organizationId:r,role:n.role}),e[175]=n,e[176]=r,e[177]=N,e[178]=Ke):Ke=e[178];let qe;e[179]!==n||e[180]!==N?(qe=n?.kind==="confirm"&&l(kt,{action:n.action,message:n.message,onClose:F,onDone:N,testId:n.testId,title:n.title}),e[179]=n,e[180]=N,e[181]=qe):qe=e[181];let nt;return e[182]!==De||e[183]!==Oe||e[184]!==Re||e[185]!==Te||e[186]!==Me||e[187]!==Fe||e[188]!==Ee||e[189]!==Le||e[190]!==je||e[191]!==Pe||e[192]!==Be||e[193]!==Je||e[194]!==Ue||e[195]!==He||e[196]!==Ke||e[197]!==qe?(nt=M("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[De,Oe,Re,Te,Me,Fe,Ee,Le,je,Pe,Be,Je,Ue,He,Ke,qe]}),e[182]=De,e[183]=Oe,e[184]=Re,e[185]=Te,e[186]=Me,e[187]=Fe,e[188]=Ee,e[189]=Le,e[190]=je,e[191]=Pe,e[192]=Be,e[193]=Je,e[194]=Ue,e[195]=He,e[196]=Ke,e[197]=qe,e[198]=nt):nt=e[198],nt};function Kt(t){return l("span",{className:"font-mono text-xs",children:S(t.userId)})}function qt(t){return S(t.role)}function Gt(t){return S(t.email)}function Qt(t){return S(t.role)}function Vt(t){return S(t.status)}function Xt(t){return S(t.id)}function Yt(t){return S(t.name)}function Zt(t){return l("span",{className:"font-mono text-xs",children:S(t.userId)})}function Wt(t){return S(t.role)}function er(t){return S(t.permission)}const yr=()=>{const t=U(62),e=ae(),r=K(),{config:d,ready:g}=At(),i=d.capabilities.organization,[o,n]=L(null),[a,s]=L(null);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=["lunora-auth-orgs"],t[0]=m):m=t[0];let h;t[1]!==e?(h=()=>e.listAuthOrganizations({limit:100}),t[1]=e,t[2]=h):h=t[2];let c;t[3]!==i?(c={enabled:i},t[3]=i,t[4]=c):c=t[4];const u=Ge(m,h,c),f=u.data?.rows??null;let b;t[5]!==u?(b=()=>{u.refetch()},t[5]=u,t[6]=b):b=t[6],wt(b,i);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{s(null)},t[7]=v):v=t[7];const w=v;let p;t[8]!==u?(p=()=>{u.refetch()},t[8]=u,t[9]=p):p=t[9];const C=p;let y;t[10]===Symbol.for("react.memo_cache_sentinel")?(y=R=>{n(R)},t[10]=y):y=t[10];const x=y;if(g&&!i){let R;t[11]!==r?(R=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=R):R=t[12];let T;t[13]!==r?(T=r("Organizations are not enabled."),t[13]=r,t[14]=T):T=t[14];let H;return t[15]!==R||t[16]!==T?(H=l(Qe,{description:R,testId:"org-disabled",title:T}),t[15]=R,t[16]=T,t[17]=H):H=t[17],H}let $;t[18]!==r?($=r("Organizations"),t[18]=r,t[19]=$):$=t[19];let I;t[20]!==$?(I=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),t[20]=$,t[21]=I):I=t[21];let z;t[22]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{s({kind:"create"})},t[22]=z):z=t[22];let D;t[23]!==r?(D=r("New organization"),t[23]=r,t[24]=D):D=t[24];let A;t[25]!==D?(A=l(j,{"data-testid":"org-new",onClick:z,size:"sm",type:"button",children:D}),t[25]=D,t[26]=A):A=t[26];let k;t[27]!==A||t[28]!==I?(k=M("div",{className:"flex items-center justify-between",children:[I,A]}),t[27]=A,t[28]=I,t[29]=k):k=t[29];let O;t[30]!==u.error?(O=u.error!==null&&l("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:u.error}),t[30]=u.error,t[31]=O):O=t[31];let _;t[32]!==f||t[33]!==r?(_=f!==null&&f.length===0&&l(Qe,{testId:"org-empty",title:r("No organizations.")}),t[32]=f,t[33]=r,t[34]=_):_=t[34];let P;t[35]!==f||t[36]!==o||t[37]!==r?(P=f!==null&&f.length>0&&l(yt,{className:"overflow-hidden py-0",children:l(vt,{className:"px-0",children:M(It,{"data-testid":"org-table",children:[l(Ct,{children:M(lt,{children:[l(me,{children:r("id")}),l(me,{children:r("name")}),l(me,{children:r("slug")}),l(me,{children:r("created")}),l(me,{"aria-label":r("Actions")})]})}),l($t,{children:f.map(R=>{const T=S(R.id);return M(lt,{"data-testid":`org-row-${T}`,children:[l(de,{className:"font-mono text-xs",children:T}),l(de,{children:S(R.name)}),l(de,{children:S(R.slug)}),l(de,{className:"text-muted-foreground tabular-nums",children:Ot(R.createdAt)}),l(de,{children:M("div",{className:"flex justify-end gap-1",children:[l(j,{"aria-pressed":o===T,"data-testid":`org-select-${T}`,onClick:()=>{x(T)},size:"xs",type:"button",variant:"ghost",children:r("Manage")}),l(j,{"data-testid":`org-edit-${T}`,onClick:()=>{s({kind:"edit",org:R})},size:"xs",type:"button",variant:"ghost",children:r("Edit")}),l(j,{"data-testid":`org-delete-${T}`,onClick:()=>{s({kind:"delete",org:R})},size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},T)})})]})})}),t[35]=f,t[36]=o,t[37]=r,t[38]=P):P=t[38];let q;t[39]!==d.organization||t[40]!==o?(q=o!==null&&l(Ht,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=q):q=t[41];let B;t[42]!==a?.kind||t[43]!==C?(B=a?.kind==="create"&&l(bt,{mode:"create",onClose:w,onDone:C}),t[42]=a?.kind,t[43]=C,t[44]=B):B=t[44];let E;t[45]!==a||t[46]!==C?(E=a?.kind==="edit"&&l(bt,{mode:"edit",onClose:w,onDone:C,org:a.org}),t[45]=a,t[46]=C,t[47]=E):E=t[47];let J;t[48]!==e||t[49]!==a||t[50]!==C||t[51]!==r?(J=a?.kind==="delete"&&l(kt,{action:async()=>{const R=S(a.org.id);await e.deleteAuthOrganization({organizationId:R}),n(T=>T===R?null:T)},message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:w,onDone:C,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=a,t[50]=C,t[51]=r,t[52]=J):J=t[52];let Q;return t[53]!==k||t[54]!==O||t[55]!==_||t[56]!==P||t[57]!==q||t[58]!==B||t[59]!==E||t[60]!==J?(Q=M("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[k,O,_,P,q,B,E,J]}),t[53]=k,t[54]=O,t[55]=_,t[56]=P,t[57]=q,t[58]=B,t[59]=E,t[60]=J,t[61]=Q):Q=t[61],Q};export{yr as default};
@@ -0,0 +1 @@
1
+ import{O as U}from"../packem_shared/wire-codec-DkrdsFXO.js";import{U as B}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as b,f as w}from"../packem_shared/card-BMKx5UdA.js";import{E as S}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as I,n as D,f as y,m as c,b as A,p as n}from"../packem_shared/table-DZAB8cs3.js";import{N as v}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as C}from"../packem_shared/home-panel-Ir3YHReO.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as g}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as P}from"../packem_shared/internal-zkEvTqy8.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";const F=["subscriptions","events"],G={},$=new Set(["active","trialing"]),H=new Set(["past_due","unpaid"]),i=(a,t)=>{if(a[t]!==void 0)return a[t];const m=a.__doc__;return typeof m=="string"?U(m)?.[t]:void 0},s=a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"",L=a=>$.has(a)?"default":H.has(a)?"destructive":"outline",ae=({limit:a=100})=>{const t=M(),m=C(),{data:u}=v(g.listTables,G,{live:!0}),T=u!==void 0,_=Array.isArray(u)&&F.every(r=>u.some(l=>l.name===r)),p=m.payments&&_,d=v(g.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=v(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});O(()=>{p&&(d.refetch(),f.refetch())},!0);const h=d.data?.rows??[],E=f.data?.rows??[],R=d.error??f.error,j=d.error===null?f.errorSource:d.errorSource,x=h.filter(r=>$.has(s(i(r,"state")))).length,k=E.toSorted((r,l)=>Number(i(l,"processedAt")??0)-Number(i(r,"processedAt")??0));return T&&!p?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(S,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):o("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:o(b,{className:"justify-between gap-0 py-0",children:[o("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),o("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:x}),e(N,{variant:"default",children:t("{count} active",{count:x})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),R===null?void 0:e(B,{error:j}),h.length===0&&!d.isLoading?e(S,{testId:"payments-empty",title:t("No subscriptions yet")}):e(b,{className:"overflow-hidden py-0",children:e(w,{className:"px-0",children:o(I,{children:[e(D,{children:o(y,{children:[e(c,{children:t("Provider")}),e(c,{children:t("Reference")}),e(c,{children:t("Plan")}),e(c,{children:t("State")}),e(c,{children:t("Renews")})]})}),e(A,{children:h.map(r=>{const l=s(i(r,"state"));return o(y,{"data-testid":"payment-subscription-row",children:[e(n,{children:s(i(r,"provider"))}),e(n,{children:s(i(r,"referenceId"))}),e(n,{children:s(i(r,"priceId"))}),e(n,{children:e(N,{variant:L(l),children:l})}),e(n,{children:P(i(r,"currentPeriodEnd"))})]},s(i(r,"providerSubscriptionId")))})})]})})}),o(b,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),e(w,{className:"px-0",children:e(I,{children:e(A,{children:k.map(r=>o(y,{"data-testid":"payment-event-row",children:[e(n,{children:s(i(r,"provider"))}),e(n,{className:"font-medium",children:s(i(r,"type"))}),e(n,{className:"text-muted-foreground",children:s(i(r,"providerEventId"))}),e(n,{children:P(i(r,"processedAt"))})]},s(i(r,"providerEventId"))))})})})]})]})};export{ae as PaymentsPanel};
@@ -0,0 +1 @@
1
+ import{useState as h,useRef as he,useEffect as ie}from"react";import{m as xe,p as ye,n as ge,f as de,c as ce}from"../packem_shared/card-BMKx5UdA.js";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as me}from"react/compiler-runtime";import{U as be}from"../packem_shared/error-alert-_2q2VtVG.js";import{L as Ne}from"../packem_shared/live-status-CmuRLFKf.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as ve,n as we,f as oe,m as te,b as ke,p as ae}from"../packem_shared/table-DZAB8cs3.js";import{N as re}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useLunora as fe}from"@lunora/react";import{ShardInput as Pe}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{p as M}from"../packem_shared/label-6uP1obNF.js";import{l as Se}from"../packem_shared/textarea-Bu2-jKAs.js";import{d as Ce,g as $e,b as Ie,f as le}from"../packem_shared/internal-zkEvTqy8.js";const se=["read","insert","update","delete"],_e=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Ae=e=>{const t=new Set;for(const i of e?.advisories??[])if(i.name==="rls_uncovered_table"){const{table:n}=i.metadata;typeof n=="string"&&n!==""&&t.add(n)}return t},Fe=(e,t,i)=>{const n=new Map,r=d=>{const o=n.get(d);if(o!==void 0)return o;const p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:d,uncovered:i.has(d)};return n.set(d,p),p};for(const d of e)r(d.table).cells[d.on]={procedure:d.procedure};for(const d of t)r(d.table).maskedColumns.add(d.column);for(const d of i)r(d);return[...n.values()].toSorted((d,o)=>d.table.localeCompare(o.table))},Te=e=>{const t=me(17);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const{onProbe:n}=i,r=ee();let d,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={},o={live:!0},t[2]=d,t[3]=o):(d=t[2],o=t[3]);const p=re(Z.rlsPolicies,d,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const g=re(Z.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const b=re(Z.getAdvisories,u);let N;if(t[6]!==b.data||t[7]!==g.data||t[8]!==n||t[9]!==p||t[10]!==r){let v=null;p.data!==void 0&&(v=Array.isArray(p.data.policies)?p.data.policies:[]);const A=Array.isArray(g.data?.columns)?g.data.columns:[],O=b.data??null,{error:S,errorSource:w,liveError:C}=p,I=v===null?[]:Fe(v,A,Ae(O));let k;t[12]!==C?(k=a("div",{className:"flex items-center justify-end",children:a(Ne,{message:C,prefix:"pm"})}),t[12]=C,t[13]=k):k=t[13];let x;t[14]!==S||t[15]!==w?(x=S!==null&&a(be,{error:w,testId:"pm-error"}),t[14]=S,t[15]=w,t[16]=x):x=t[16],N=s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&I.length===0?a(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):s(ve,{"data-testid":"pm-table",children:[a(we,{children:s(oe,{children:[a(te,{children:r("Table")}),se.map(c=>a(te,{children:_e(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(ke,{children:I.map(c=>s(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:s("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(Y,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),se.map($=>{const y=c.cells[$];return a(ae,{"data-testid":`pm-cell-${c.table}-${$}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):s("span",{className:"flex flex-col gap-1",children:[a(Y,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),n!==void 0&&a(R,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${$}`,onClick:()=>{n(c.table,$,y.procedure??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},$)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Ee)})})]},c.table))})]})]}),t[6]=b.data,t[7]=g.data,t[8]=n,t[9]=p,t[10]=r,t[11]=N}else N=t[11];return N};function Ee(e){return a(Y,{variant:"outline",children:e},e)}const Le=$e(Z.runAs),Re=()=>{const e=fe();return async({args:t,functionPath:i,shardKey:n="",userId:r})=>{const d=Le;try{return{kind:"allowed",value:await e.query(d,{args:t,functionPath:i,userId:r},Ce(n))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},Me=e=>e===void 0?"undefined":JSON.stringify(e,null,2),Oe=({functions:e,prefill:t,runAsIdentity:i=!1}={})=>{const n=fe(),r=ee(),d=Re(),[o,p]=h(null),[l,g]=h(null),u=e??o??[],[b,N]=h(""),[v,A]=h("{}"),[O,S]=h(""),[w,C]=h(""),[I,k]=h(!1),[x,c]=h(null),[$,y]=h(null),_=he(-1);ie(()=>{if(e!==void 0)return;let m=!1;return n.listFunctions().then(f=>(m||p(f),f)).catch(f=>{m||g(Ie(f))}),()=>{m=!0}},[n,e]),ie(()=>{if(t===void 0||_.current===t.nonce)return;_.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{N(m),c(null)})},[t]);const P=b===""?u[0]?.path??"":b,F=async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(f){y(r("Invalid JSON args: {message}",{message:f.message})),c(null);return}y(null),k(!0);try{const f=await d({args:m,functionPath:P,shardKey:O.trim(),userId:w.trim()});c(f)}finally{k(!1)}},T=()=>{le(F())},B=m=>{N(m.target.value)},E=m=>{A(m.target.value)},L=m=>{C(m.target.value)};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&a(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),s("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:B,value:P,children:u.map(m=>s("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-args",children:r("Arguments")}),a(Se,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:E,value:v})]}),a(Pe,{onChange:S,testId:"pp-shard",value:O}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(G,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:r("Leave empty to run as admin"),value:w})]}),s("div",{className:"flex items-center gap-2",children:[a(R,{"data-testid":"pp-run",disabled:!i||I||P==="",onClick:T,type:"button",children:r(I?"Probing…":"Run probe")}),w.trim()!==""&&a(Y,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:w.trim()})})]})]}),$!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:$}),x!==null&&x.kind==="allowed"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(Y,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Me(x.value)})]}),x!==null&&x.kind==="denied"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(Y,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},ze="/__lunora/policy-scaffold",je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},qe=async e=>{const t=await fetch(ze,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await t.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(t.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};const n=i.error;return{kind:"error",message:n===void 0?`policy scaffold failed (${String(t.status)})`:je[n]??n}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=()=>{const e=me(69),t=ee(),[i,n]=h(null),[r,d]=h(!1),[o,p]=h(null),[l,g]=h(ne);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=X=>{const K=X.target.name,{value:Q}=X.target;g(ue=>({...ue,[K]:Q}))},e[0]=u):u=e[0];const b=u;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{n(null),g(ne)},e[1]=N):N=e[1];const v=N;let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=async X=>{d(!0),p(null);try{const K=await qe(X);p(K),K.kind==="ok"&&v()}catch(K){const Q=K;p({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}d(!1)},e[2]=A):A=e[2];const O=A;let S;e[3]!==l.policyName||e[4]!==l.tableName?(S=()=>{le(O({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=S):S=e[5];const w=S;let C;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(C=()=>{le(O({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=C):C=e[9];const I=C;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p(null),n("scaffold")},e[10]=k):k=e[10];const x=k;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{p(null),n("wire")},e[11]=c):c=e[11];const $=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let _;e[14]!==y?(_=a(xe,{children:y}),e[14]=y,e[15]=_):_=e[15];let P;e[16]!==t?(P=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=P):P=e[17];let F;e[18]!==P?(F=a(ye,{children:P}),e[18]=P,e[19]=F):F=e[19];let T;e[20]!==F||e[21]!==_?(T=s(ge,{children:[_,F]}),e[20]=F,e[21]=_,e[22]=T):T=e[22];const B=i==="scaffold"?"default":"outline";let E;e[23]!==t?(E=t("New policy file"),e[23]=t,e[24]=E):E=e[24];let L;e[25]!==B||e[26]!==E?(L=a(R,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:B,children:E}),e[25]=B,e[26]=E,e[27]=L):L=e[27];const m=i==="wire"?"default":"outline";let f;e[28]!==t?(f=t("Wire into a procedure"),e[28]=t,e[29]=f):f=e[29];let z;e[30]!==m||e[31]!==f?(z=a(R,{"data-testid":"policy-scaffolder-wire",onClick:$,size:"xs",type:"button",variant:m,children:f}),e[30]=m,e[31]=f,e[32]=z):z=e[32];let j;e[33]!==L||e[34]!==z?(j=s("div",{className:"flex flex-wrap gap-2",children:[L,z]}),e[33]=L,e[34]=z,e[35]=j):j=e[35];let q;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==w||e[41]!==t?(q=i==="scaffold"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(G,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(G,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),a(R,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=w,e[41]=t,e[42]=q):q=e[42];let J;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==I||e[49]!==t?(J=i==="wire"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(G,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(G,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(G,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),a(R,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:I,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=I,e[49]=t,e[50]=J):J=e[50];let D;e[51]!==o?(D=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=D):D=e[52];let U;e[53]!==o?.kind||e[54]!==t?(U=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=U):U=e[55];let W;e[56]!==o||e[57]!==t?(W=o?.kind==="ok"&&s("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(De)})]}),e[56]=o,e[57]=t,e[58]=W):W=e[58];let H;e[59]!==j||e[60]!==q||e[61]!==J||e[62]!==D||e[63]!==U||e[64]!==W?(H=s(de,{children:[j,q,J,D,U,W]}),e[59]=j,e[60]=q,e[61]=J,e[62]=D,e[63]=U,e[64]=W,e[65]=H):H=e[65];let V;return e[66]!==T||e[67]!==H?(V=s(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[T,H]}),e[66]=T,e[67]=H,e[68]=V):V=e[68],V};function De(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const nt=({functions:e,runAsIdentity:t=!1,schemaEditable:i=!1}={})=>{const n=ee(),[r,d]=h(void 0),o=(p,l,g)=>{g!==""&&d(u=>({functionPath:g,nonce:(u?.nonce??0)+1}))};return s("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[s("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Permissions")})}),a(Te,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:s(ce,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Probe")})}),s(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:n("Pick a function and an identity, then run it to see the access outcome.")}),a(Oe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),i&&a("section",{className:"flex flex-col gap-2",children:a(Je,{})})]})};export{nt as PermissionsPanel};
@@ -0,0 +1 @@
1
+ import{c as P}from"react/compiler-runtime";import{useLunora as Ke}from"@lunora/react";import{useState as _}from"react";import{ConfirmButton as Ve}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{U as Xe}from"../packem_shared/error-alert-_2q2VtVG.js";import{A as Ye}from"../packem_shared/alert-CVcOFuDR.js";import{g as Ce}from"../packem_shared/badge-BbuuAio7.js";import{u as Ie}from"../packem_shared/button-BkCrNcAs.js";import{c as Oe,f as ke}from"../packem_shared/card-BMKx5UdA.js";import{E as Qe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ze}from"../packem_shared/input-JHu63lTv.js";import{p as et}from"../packem_shared/scroll-area-DTEq6Jec.js";import{d as Be,n as Je,f as oe,m as $,b as Fe,p as w}from"../packem_shared/table-DZAB8cs3.js";import{l as tt}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Te}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as at}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as Se,b as $e,g as Ae,i as st,f as we}from"../packem_shared/internal-zkEvTqy8.js";import{jsx as a,jsxs as q,Fragment as We}from"react/jsx-runtime";const rt=(n,e)=>{const t=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),l=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:l,showReliabilityWarning:l.length>0||d>0}},nt=200,ot=Ae(j.sendQueueMessage),dt=Ae(j.replayQueueMessage),lt=Ae(j.clearQueueMessages),Re=96,it=n=>{if(n===void 0)return"—";try{return JSON.stringify(n)}catch{return"[unserializable]"}},ut=n=>n.length>Re?`${n.slice(0,Re)}…`:n,ct=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",mt=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ht=n=>{const e=P(11),{loaded:t,queues:l}=n,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==l||e[6]!==d?(r=t&&l.length===0?a(Qe,{description:d("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:d("No queues defined")}):a(Oe,{className:"overflow-hidden py-0",children:a(ke,{className:"px-0",children:q(Be,{"data-testid":"queues-table",children:[a(Je,{children:q(oe,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:l.map(xt)})]})})}),e[4]=t,e[5]=l,e[6]=d,e[7]=r):r=e[7];let h;return e[8]!==o||e[9]!==r?(h=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=h):h=e[10],h},pt=n=>{const e=P(67),{message:t,onReplay:l,replayingId:d}=n,s=U();let o,r,h,c,f,y,x,i,m,g;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]!==s){const J=it(t.body);r=oe,y=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(i=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=i):i=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const L=`queues-outcome-${t.id}`;let M;e[25]!==t.outcome?(M=ct(t.outcome),e[25]=t.outcome,e[26]=M):M=e[26];let C;e[27]!==t.outcome||e[28]!==L||e[29]!==M?(C=a(Ce,{"data-testid":L,variant:M,children:t.outcome}),e[27]=t.outcome,e[28]=L,e[29]=M,e[30]=C):C=e[30];let E;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(E=t.deadLettered&&a(Ce,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=E):E=e[34],e[35]!==C||e[36]!==E?(g=a(w,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,E]})}),e[35]=C,e[36]=E,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=J,f=ut(J),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]=s,e[9]=o,e[10]=r,e[11]=h,e[12]=c,e[13]=f,e[14]=y,e[15]=x,e[16]=i,e[17]=m,e[18]=g}else o=e[9],r=e[10],h=e[11],c=e[12],f=e[13],y=e[14],x=e[15],i=e[16],m=e[17],g=e[18];let p;e[38]!==o||e[39]!==h||e[40]!==c||e[41]!==f?(p=a(o,{className:h,title:c,children:f}),e[38]=o,e[39]=h,e[40]=c,e[41]=f,e[42]=p):p=e[42];let b;e[43]!==t.capturedAt?(b=st(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=b):b=e[44];let N;e[45]!==b?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let I;e[47]!==t.id||e[48]!==d||e[49]!==s?(I=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=I):I=e[50];let Q;e[51]!==t.id||e[52]!==l||e[53]!==S||e[54]!==A||e[55]!==I?(Q=a(w,{children:a(Ie,{"data-id":t.id,"data-testid":S,disabled:A,onClick:l,size:"xs",type:"button",variant:"outline",children:I})}),e[51]=t.id,e[52]=l,e[53]=S,e[54]=A,e[55]=I,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==N||e[59]!==Q||e[60]!==y||e[61]!==x||e[62]!==i||e[63]!==m||e[64]!==g||e[65]!==p?(D=q(r,{"data-testid":y,children:[x,i,m,g,p,N,Q]}),e[57]=r,e[58]=N,e[59]=Q,e[60]=y,e[61]=x,e[62]=i,e[63]=m,e[64]=g,e[65]=p,e[66]=D):D=e[66],D},gt=n=>{const e=P(30),{hasError:t,messages:l,onClear:d,onReplay:s,replayingId:o}=n,r=U();let h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=h):h=e[1];let c;e[2]!==h?(c=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=c):c=e[3];let f;e[4]!==l.length||e[5]!==r?(f=r("Clear {count} messages?",{count:l.length}),e[4]=l.length,e[5]=r,e[6]=f):f=e[6];const y=l.length===0;let x;e[7]!==r?(x=r("Clear log"),e[7]=r,e[8]=x):x=e[8];let i;e[9]!==d||e[10]!==f||e[11]!==y||e[12]!==x?(i=a("div",{className:"ml-auto",children:a(Ve,{confirmLabel:f,disabled:y,onConfirm:d,testId:"queues-clear",children:x})}),e[9]=d,e[10]=f,e[11]=y,e[12]=x,e[13]=i):i=e[13];let m;e[14]!==l.length||e[15]!==r?(m=l.length>0&&a(Ce,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:l.length})}),e[14]=l.length,e[15]=r,e[16]=m):m=e[16];let g;e[17]!==c||e[18]!==i||e[19]!==m?(g=q("div",{className:"flex flex-wrap items-center gap-2",children:[c,i,m]}),e[17]=c,e[18]=i,e[19]=m,e[20]=g):g=e[20];let p;e[21]!==t||e[22]!==l||e[23]!==s||e[24]!==o||e[25]!==r?(p=!t&&l.length===0?a(Qe,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):a(Oe,{className:"overflow-hidden py-0",children:a(ke,{className:"px-0",children:a(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:q(oe,{children:[a($,{children:r("Export")}),a($,{children:r("Message")}),a($,{children:r("Attempts")}),a($,{children:r("Outcome")}),a($,{children:r("Body")}),a($,{children:r("Captured")}),a($,{})]})}),a(Fe,{children:l.map(N=>a(pt,{message:N,onReplay:s,replayingId:o},N.id))})]})})})}),e[21]=t,e[22]=l,e[23]=s,e[24]=o,e[25]=r,e[26]=p):p=e[26];let b;return e[27]!==g||e[28]!==p?(b=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[g,p]}),e[27]=g,e[28]=p,e[29]=b):b=e[29],b},ft=n=>{const e=P(20),{batchMode:t,bodyText:l,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:r,onSelectExport:h,onSend:c,queues:f,selectedExportName:y,sending:x}=n,i=U();let m;e[0]!==i?(m=i("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=i,e[1]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let p;e[4]!==t||e[5]!==l||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==r||e[10]!==h||e[11]!==c||e[12]!==f||e[13]!==y||e[14]!==x||e[15]!==i?(p=f.length===0?a(Qe,{description:i("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:i("No queues to send to")}):q(We,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[a("select",{"aria-label":i("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:y,children:f.map(yt)}),a(Ze,{"aria-label":i("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:i("Delay (s)"),type:"number",value:d}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),i("Send as batch (JSON array)")]}),a(Ie,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:c,type:"button",children:i(x?"Sending…":"Send message")})]}),a(tt,{"aria-label":i("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:l})]}),e[4]=t,e[5]=l,e[6]=d,e[7]=s,e[8]=o,e[9]=r,e[10]=h,e[11]=c,e[12]=f,e[13]=y,e[14]=x,e[15]=i,e[16]=p):p=e[16];let b;return e[17]!==g||e[18]!==p?(b=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,p]}),e[17]=g,e[18]=p,e[19]=b):b=e[19],b},Ft=n=>{const e=P(59),{limit:t}=n,l=t??nt,d=Ke(),s=U(),[o,r]=_("declared"),[h,c]=_(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];const{data:y,error:x,errorSource:i}=Te(j.listQueues,f);let m;e[1]!==l?(m={limit:l},e[1]=l,e[2]=m):m=e[2];const{data:g,error:p,errorSource:b,refetch:N}=Te(j.getQueueMessages,m),S=Array.isArray(y?.queues)?[...y.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:I,queuesWithoutDlq:Q,showReliabilityWarning:D}=rt(S,A),[J,F]=_(""),[L,M]=_(""),[C,E]=_(""),[W,ze]=_(!1),[de,Le]=_(!1),[le,Me]=_(null),G=S.some(u=>u.exportName===J)?J:S[0]?.exportName??"",Ee=o==="messages"?p:x,je=o==="messages"?b:i,ie=Ee??h,ue=Ee===null?h:je;let H;e[3]!==N?(H=()=>{N()},e[3]=N,e[4]=H):H=e[4],at(H,o==="messages");const ce=async()=>{c(null);const u=G;if(u==="")return;let v=null;const _e=L.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{c(s("Body must be valid JSON."));return}let ve;const De=C.trim();if(De!==""){const z=Number(De);if(!Number.isFinite(z)||z<0){c(s("Delay must be a non-negative number of seconds."));return}ve=z}if(W&&!Array.isArray(v)){c(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Le(!0);const He=W?{batch:v,delaySeconds:ve,exportName:u}:{body:v,delaySeconds:ve,exportName:u};try{await d.query(ot,He,Se("")),N()}catch(z){c($e(z))}Le(!1)};let K;e[5]!==d||e[6]!==N?(K=async u=>{c(null),Me(u);try{await d.query(dt,{id:u},Se("")),N()}catch(v){c($e(v))}Me(null)},e[5]=d,e[6]=N,e[7]=K):K=e[7];const me=K;let V;e[8]!==d||e[9]!==N?(V=async()=>{c(null);try{await d.query(lt,{},Se("")),N()}catch(u){c($e(u))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const he=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=u=>{const v=u.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&r(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=u=>{F(u.currentTarget.value)},e[12]=Y):Y=e[12];const pe=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=u=>{M(u.currentTarget.value)},e[13]=Z):Z=e[13];const ge=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=u=>{E(u.currentTarget.value)},e[14]=ee):ee=e[14];const fe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=u=>{ze(u.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let ae;e[16]!==ce?(ae=()=>{we(ce())},e[16]=ce,e[17]=ae):ae=e[17];const ye=ae;let se;e[18]!==me?(se=u=>{const{id:v}=u.currentTarget.dataset;v!==void 0&&we(me(v))},e[18]=me,e[19]=se):se=e[19];const Ne=se;let re;e[20]!==he?(re=()=>{we(he())},e[20]=he,e[21]=re):re=e[21];const be=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let T;e[22]!==s||e[23]!==o?(T=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(u=>a(Ie,{"aria-selected":o===u,"data-tab":u,"data-testid":`queues-tab-${u}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===u?"secondary":"ghost",children:mt(u,s)},u))}),e[22]=s,e[23]=o,e[24]=T):T=e[24];let R;e[25]!==ie||e[26]!==ue?(R=ie!==null&&a(Xe,{error:ue,testId:"queues-error"}),e[25]=ie,e[26]=ue,e[27]=R):R=e[27];const qe=D&&a(Ye,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[Q.length>0&&q(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:Q.map(bt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),I>0&&a("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:I===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:I})})]})});let O;e[28]!==S||e[29]!==y||e[30]!==o?(O=o==="declared"&&a(ht,{loaded:y!==void 0,queues:S}),e[28]=S,e[29]=y,e[30]=o,e[31]=O):O=e[31];let k;e[32]!==A||e[33]!==p||e[34]!==be||e[35]!==Ne||e[36]!==le||e[37]!==o?(k=o==="messages"&&a(gt,{hasError:p!==null,messages:A,onClear:be,onReplay:Ne,replayingId:le}),e[32]=A,e[33]=p,e[34]=be,e[35]=Ne,e[36]=le,e[37]=o,e[38]=k):k=e[38];let B;e[39]!==W||e[40]!==L||e[41]!==C||e[42]!==xe||e[43]!==ge||e[44]!==fe||e[45]!==pe||e[46]!==ye||e[47]!==S||e[48]!==G||e[49]!==de||e[50]!==o?(B=o==="send"&&a(ft,{batchMode:W,bodyText:L,delayText:C,onBatchModeChange:xe,onBodyChange:ge,onDelayChange:fe,onSelectExport:pe,onSend:ye,queues:S,selectedExportName:G,sending:de}),e[39]=W,e[40]=L,e[41]=C,e[42]=xe,e[43]=ge,e[44]=fe,e[45]=pe,e[46]=ye,e[47]=S,e[48]=G,e[49]=de,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==T||e[53]!==R||e[54]!==qe||e[55]!==O||e[56]!==k||e[57]!==B?(ne=q("div",{className:Ue,"data-testid":Ge,children:[T,R,qe,O,k,B]}),e[52]=T,e[53]=R,e[54]=qe,e[55]=O,e[56]=k,e[57]=B,e[58]=ne):ne=e[58],ne};function xt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[a(w,{className:"font-mono text-xs",children:n.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function yt(n){return a("option",{value:n.exportName,children:n.exportName},n.exportName)}function Nt(n,e){return n.exportName.localeCompare(e.exportName)}function bt(n){return n.name}export{Ft as default};
@@ -0,0 +1 @@
1
+ import{c as F}from"react/compiler-runtime";import{U as J}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{f as D,c as U}from"../packem_shared/card-BMKx5UdA.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as E,n as G,f as T,m as S,b as M,p as A}from"../packem_shared/table-DZAB8cs3.js";import{N as K}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";const O=["read","insert","update","delete"],q=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],B=e=>{const t=new Map;for(const s of e){const l=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),t.set(s.table,l)}return[...t.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},ae=()=>{const e=F(49),t=V();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:I,errorSource:R}=K(W.rlsPolicies,s),c=l!==void 0;let p,n,m,a,h,f,u,x,i;if(e[1]!==l||e[2]!==I||e[3]!==R||e[4]!==c||e[5]!==t){const _=B(Array.isArray(l?.policies)?l.policies:[]);let k;e[15]!==l?(k=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=k):k=e[16],n=k,u="flex flex-col gap-6",x="lunora-rls-panel",e[17]!==I||e[18]!==R?(i=I!==null&&r(J,{error:R,testId:"rls-error"}),e[17]=I,e[18]=R,e[19]=i):i=e[19],f="flex flex-col gap-2",p=U,m="overflow-hidden py-0";let v;e[20]!==t?(v=t("Policies"),e[20]=t,e[21]=v):v=e[21],e[22]!==v?(a=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[22]=v,e[23]=a):a=e[23],h=c&&_.length===0?r(j,{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")}):r(D,{className:"px-0",children:o(E,{"data-testid":"rls-policies-table",children:[r(G,{children:o(T,{children:[r(S,{children:t("Table")}),O.map(d=>r(S,{children:q(t,d)},d)),r(S,{children:t("Guarded by")})]})}),r(M,{children:_.map(d=>o(T,{"data-testid":`rls-table-${d.table}`,children:[r(A,{className:"font-mono text-xs",children:d.table}),O.map(C=>r(A,{children:d.operations.has(C)?r(z,{variant:"secondary",children:t("Guarded")}):r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},C)),r(A,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=I,e[3]=R,e[4]=c,e[5]=t,e[6]=p,e[7]=n,e[8]=m,e[9]=a,e[10]=h,e[11]=f,e[12]=u,e[13]=x,e[14]=i}else p=e[6],n=e[7],m=e[8],a=e[9],h=e[10],f=e[11],u=e[12],x=e[13],i=e[14];let b;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==h?(b=o(p,{className:m,children:[a,h]}),e[24]=p,e[25]=m,e[26]=a,e[27]=h,e[28]=b):b=e[28];let N;e[29]!==f||e[30]!==b?(N=r("section",{className:f,children:b}),e[29]=f,e[30]=b,e[31]=N):N=e[31];let g;e[32]!==t?(g=t("Roles"),e[32]=t,e[33]=g):g=e[33];let y;e[34]!==g?(y=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[34]=g,e[35]=y):y=e[35];let $;e[36]!==c||e[37]!==n||e[38]!==t?($=c&&n.length===0?r(j,{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")}):r(D,{className:"px-0",children:o(E,{"data-testid":"rls-roles-table",children:[r(G,{children:o(T,{children:[r(S,{children:t("Role")}),r(S,{children:t("Description")}),r(S,{children:t("Permissions")})]})}),r(M,{children:n.map(L)})]})}),e[36]=c,e[37]=n,e[38]=t,e[39]=$):$=e[39];let w;e[40]!==y||e[41]!==$?(w=r("section",{className:"flex flex-col gap-2",children:o(U,{className:"overflow-hidden py-0",children:[y,$]})}),e[40]=y,e[41]=$,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==x||e[46]!==i||e[47]!==N?(P=o("div",{className:u,"data-testid":x,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=x,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function H(e){return r(z,{variant:"outline",children:e},e)}function L(e){return o(T,{"data-testid":`rls-role-${e.name}`,children:[r(A,{className:"font-mono text-xs",children:e.name}),r(A,{className:"text-muted-foreground",children:e.description??""}),r(A,{children:e.permissions.length===0?r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):r("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(H)})})]},e.name)}export{ae as default};
@@ -0,0 +1 @@
1
+ import{c as M}from"react/compiler-runtime";import{useState as _}from"react";import{u as Z}from"../packem_shared/button-BkCrNcAs.js";import{useT as B}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{useLunora as E}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{c as T,f as A}from"../packem_shared/card-BMKx5UdA.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as z,n as K,f as I,m as x,b as V,p as b}from"../packem_shared/table-DZAB8cs3.js";import{O}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{f as R,b as H,i as X}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-pHVlh2xU.js";const te={kind:"idle"},oe=(n,e,c)=>c!==void 0?c:e===void 0?d=>n.runCronJob(d):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=E(),d=B(),[f,a]=_({}),r=O(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:o,error:k}=r,h=oe(c,n,e),i=async l=>{if(h!==void 0){a(s=>({...s,[l]:{kind:"running"}}));try{await h(l),a(s=>({...s,[l]:{kind:"ok"}})),r.refetch()}catch(s){a(v=>({...v,[l]:{kind:"error",message:H(s)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:k}),o?.length===0&&t(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"cron-table",children:[t(K,{children:m(I,{children:[t(x,{children:d("name")}),t(x,{children:d("schedule")}),t(x,{children:d("target")}),t(x,{children:d("shard")}),h!==void 0&&t(x,{"aria-label":d("Actions")})]})}),t(V,{children:o.map(l=>{const s=f[l.name]??te;return m(I,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(Y,{variant:"outline",children:d("function")}):t(Y,{variant:"secondary",children:d("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[s.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:d("ran")}),s.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:s.message}),t(G,{confirmLabel:d("Run now?"),disabled:s.kind==="running",onConfirm:()=>{R(i(l.name))},testId:`cron-run-${l.name}`,children:s.kind==="running"?d("Running…"):d("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},re=n=>Number.isFinite(n)?X(n,"—"):"—",ne=n=>{const e=M(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:d,removeJob:f,retryJob:a}=c,r=E(),o=B();let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=["lunora-dead-jobs"],e[2]=k):k=e[2];let h;e[3]!==r||e[4]!==d?(h=async()=>(await(d??(()=>r.listDeadJobs()))()).toSorted(ae),e[3]=r,e[4]=d,e[5]=h):h=e[5];const i=O(k,h),l=i.data,[s,v]=_(void 0),N=i.error??s,u=d===void 0;let $;e[6]!==r||e[7]!==u||e[8]!==a?($=a??(u?p=>r.retryDeadJob(p):void 0),e[6]=r,e[7]=u,e[8]=a,e[9]=$):$=e[9];const g=$;let w;e[10]!==r||e[11]!==u||e[12]!==f?(w=f??(u?p=>r.removeDeadJob(p):void 0),e[10]=r,e[11]=u,e[12]=f,e[13]=w):w=e[13];const C=w;let J;e[14]!==i?(J=()=>{i.refetch()},e[14]=i,e[15]=J):J=e[15],Q(J,!0);let j;e[16]!==i?(j=async p=>{v(void 0);try{await p,i.refetch()}catch(U){v(H(U))}},e[16]=i,e[17]=j):j=e[17];const S=j,L=g!==void 0||C!==void 0;let q;e[18]!==N?(q=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=q):q=e[19];let y;e[20]!==l?.length||e[21]!==o?(y=l?.length===0&&t(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=l?.length,e[21]=o,e[22]=y):y=e[22];let P;e[23]!==S||e[24]!==L||e[25]!==l||e[26]!==C||e[27]!==g||e[28]!==o?(P=l!==void 0&&l.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"dlq-table",children:[t(K,{children:m(I,{children:[t(x,{children:o("function")}),t(x,{children:o("attempts")}),t(x,{children:o("last tried")}),t(x,{children:o("pool")}),t(x,{children:o("shard")}),t(x,{children:o("id")}),L&&t(x,{"aria-label":o("Actions")})]})}),t(V,{children:l.map(p=>m(I,{"data-testid":`dlq-row-${p.id}`,children:[t(b,{className:"font-mono text-xs",children:p.functionPath}),t(b,{className:"tabular-nums",children:p.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:re(p.scheduledFor)}),t(b,{className:"font-mono text-xs",children:p.pool??""}),t(b,{children:p.shardKey??""}),t(b,{className:"font-mono text-xs",children:p.id}),L&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&t(Z,{"data-testid":`dlq-retry-${p.id}`,onClick:()=>{R(S(g(p.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),C!==void 0&&t(G,{confirmLabel:o("Drop job?"),onConfirm:()=>{R(S(C(p.id)))},testId:`dlq-remove-${p.id}`,children:o("Drop")})]})})]},p.id))})]})})}),e[23]=S,e[24]=L,e[25]=l,e[26]=C,e[27]=g,e[28]=o,e[29]=P):P=e[29];let D;return e[30]!==P||e[31]!==q||e[32]!==y?(D=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[q,y,P]}),e[30]=P,e[31]=q,e[32]=y,e[33]=D):D=e[33],D};function ae(n,e){return(e.attempts??0)-(n.attempts??0)}const F=n=>{const e=M(8),{label:c,testId:d,value:f}=n;let a;e[0]!==c?(a=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=a):a=e[1];let r;e[2]!==d||e[3]!==f?(r=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=t(T,{className:"flex-1 py-0",children:m(A,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},de=n=>{const e=M(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:d}=c,f=E(),a=B(),r=d===void 0;let o;e[2]!==r?(o=["lunora-scheduler-status",r],e[2]=r,e[3]=o):o=e[3];let k;e[4]!==f||e[5]!==d?(k=async()=>{const w=await(d??(()=>f.schedulerStatus()))();return{...w,pools:w.pools.toSorted(ie)}},e[4]=f,e[5]=d,e[6]=k):k=e[6];const h=O(o,k),{data:i,error:l}=h;let s;e[7]!==h?(s=()=>{h.refetch()},e[7]=h,e[8]=s):s=e[8],Q(s,!0);let v;e[9]!==l?(v=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=v):v=e[10];let N;e[11]!==i||e[12]!==a?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(F,{label:a("backlog"),testId:"pools-backlog",value:i.backlog}),t(F,{label:a("in flight"),testId:"pools-inflight",value:i.inFlight}),t(F,{label:a("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=a,e[13]=N):N=e[13];let u;e[14]!==i?.pools.length||e[15]!==a?(u=i?.pools.length===0&&t(W,{description:a("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:a("No workpools.")}),e[14]=i?.pools.length,e[15]=a,e[16]=u):u=e[16];let $;e[17]!==i||e[18]!==a?($=i!==void 0&&i.pools.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"pools-table",children:[t(K,{children:m(I,{children:[t(x,{children:a("pool")}),t(x,{children:a("queued")}),t(x,{children:a("in flight")}),t(x,{children:a("max concurrency")})]})}),t(V,{children:i.pools.map(se)})]})})}),e[17]=i,e[18]=a,e[19]=$):$=e[19];let g;return e[20]!==v||e[21]!==N||e[22]!==u||e[23]!==$?(g=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[v,N,u,$]}),e[20]=v,e[21]=N,e[22]=u,e[23]=$,e[24]=g):g=e[24],g};function ie(n,e){return e.queued-n.queued}function se(n){return m(I,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Je=n=>{const e=M(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:d,scheduledCancel:f,scheduledLoad:a}=c,r=B(),[o,k]=_("jobs");let h;e[2]!==r?(h=r("Cron triggers"),e[2]=r,e[3]=h):h=e[3];let i;e[4]!==r?(i=r("Dead letter"),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r?(l=r("Scheduled jobs"),e[6]=r,e[7]=l):l=e[7];let s;e[8]!==r?(s=r("Pools"),e[8]=r,e[9]=s):s=e[9];let v;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==s?(v={cron:h,dead:i,jobs:l,pools:s},e[10]=h,e[11]=i,e[12]=l,e[13]=s,e[14]=v):v=e[14];const N=v;let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=y=>{k(y.currentTarget.dataset.view)},e[15]=u):u=e[15];const $=u;let g;e[16]!==r?(g=r("Schedule view"),e[16]=r,e[17]=g):g=e[17];let w;e[18]!==o||e[19]!==N?(w=ce.map(y=>t(Z,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:$,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:N[y]},y)),e[18]=o,e[19]=N,e[20]=w):w=e[20];let C;e[21]!==g||e[22]!==w?(C=t("div",{"aria-label":g,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:w}),e[21]=g,e[22]=w,e[23]=C):C=e[23];let J;e[24]!==f||e[25]!==a||e[26]!==o?(J=o==="jobs"&&t(ee,{cancelJob:f,loadJobs:a}),e[24]=f,e[25]=a,e[26]=o,e[27]=J):J=e[27];let j;e[28]!==o?(j=o==="dead"&&t(ne,{}),e[28]=o,e[29]=j):j=e[29];let S;e[30]!==o?(S=o==="pools"&&t(de,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&t(le,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let q;return e[35]!==C||e[36]!==J||e[37]!==j||e[38]!==S||e[39]!==L?(q=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[C,J,j,S,L]}),e[35]=C,e[36]=J,e[37]=j,e[38]=S,e[39]=L,e[40]=q):q=e[40],q};export{Je as SchedulePanel};
@@ -0,0 +1 @@
1
+ import{c as f}from"react/compiler-runtime";import{B as m,E as u}from"../packem_shared/bar-chart-B8oDHgnw.js";import{jsx as c}from"react/jsx-runtime";const d={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},b=n=>{const e=f(6),{data:o}=n;let a,r;if(e[0]!==o){r=Symbol.for("react.early_return_sentinel");e:{const s=o.slice(-16);if(s.length<3){r=null;break e}a=s.map(h)}e[0]=o,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;const i=a;let t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=c(m,{dataKey:"value"}),e[3]=t):t=e[3];let l;return e[4]!==i?(l=c("div",{"aria-hidden":"true",className:"h-8 w-28",children:c(u,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:d,data:i,children:t})}),e[4]=i,e[5]=l):l=e[5],l};function h(n,e){return{index:e,value:n}}export{b as default};
@@ -0,0 +1 @@
1
+ import{c as $}from"react/compiler-runtime";import{U as N}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as y}from"../packem_shared/badge-BbuuAio7.js";import{c as k,f as S}from"../packem_shared/card-BMKx5UdA.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as v,n as I,f as g,m as u,b as R,p as f}from"../packem_shared/table-DZAB8cs3.js";import{N as j}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as A}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as p}from"react/jsx-runtime";const E=(e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],b={delete:2,list:3,read:0,write:1},T=e=>[...e].toSorted((r,s)=>r.bucket.localeCompare(s.bucket)||b[r.on]-b[s.on]||(r.prefix??"").localeCompare(s.prefix??"")),W=()=>{const e=$(14),r=A();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:i,errorSource:d}=j(C.storageRules,s),h=l!==void 0;let c;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==r){const x=T(Array.isArray(l?.rules)?l.rules:[]);let n;e[7]!==i||e[8]!==d?(n=i!==null&&t(N,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=n):n=e[9];let a;e[10]!==r?(a=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=a):a=e[11];let m;e[12]!==a?(m=t("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:a}),e[12]=a,e[13]=m):m=e[13],c=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[n,m,h&&x.length===0?t(w,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")}):t(k,{className:"overflow-hidden py-0",children:t(S,{className:"px-0",children:p(v,{"data-testid":"storage-rules-table",children:[t(I,{children:p(g,{children:[t(u,{children:r("Bucket")}),t(u,{children:r("Operation")}),t(u,{children:r("Key prefix")}),t(u,{children:r("Guarded by")})]})}),t(R,{children:x.map(o=>p(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[t(f,{className:"font-mono text-xs",children:o.bucket}),t(f,{children:t(y,{variant:"secondary",children:E(r,o.on)})}),t(f,{className:"font-mono text-xs",children:o.prefix??t("span",{className:"text-muted-foreground",children:r("(whole bucket)")})}),t(f,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=r,e[6]=c}else c=e[6];return c};export{W as default};
@@ -0,0 +1 @@
1
+ import{c as M}from"react/compiler-runtime";import{U as T}from"../packem_shared/error-alert-_2q2VtVG.js";import{ShardInput as j}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as $}from"../packem_shared/badge-BbuuAio7.js";import{c as E,f as _}from"../packem_shared/card-BMKx5UdA.js";import{E as q}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as D,n as F,f as C,m as g,b as J,p as N}from"../packem_shared/table-DZAB8cs3.js";import{N as L}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as P}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as U}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";const K=80,W=a=>{if(a===void 0)return"";const e=JSON.stringify(a);return e.length>K?`${e.slice(0,K)}…`:e},B=a=>{const e=[];for(const i of a){const n=i.id.toString();if(i.subscriptions.length===0){e.push({admin:i.admin,connectionId:i.id,key:`c${n}`,subscription:null});continue}i.subscriptions.forEach((m,o)=>{e.push({admin:i.admin,connectionId:i.id,key:`c${n}-s${o.toString()}`,subscription:m})})}return e},k=t("span",{className:"text-muted-foreground",children:"—"}),oe=a=>{const e=M(22),{initialShardKey:i}=a,n=R(),{queryShardKey:m,setShardKey:o,shardKey:u}=P(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==m?(f={keepPreviousData:!0,shardKey:m},e[1]=m,e[2]=f):f=e[2];const{data:r,error:s,errorSource:h,refetch:A}=L(U.listSubscriptions,p,f);O(A,!0);let b;if(e[3]!==s||e[4]!==h||e[5]!==r||e[6]!==o||e[7]!==u||e[8]!==n){const S=r===void 0?[]:B(r.connections);let d;e[10]!==o||e[11]!==u?(d=t(j,{onChange:o,testId:"subs-shard-input",value:u}),e[10]=o,e[11]=u,e[12]=d):d=e[12];let l;e[13]!==r||e[14]!==n?(l=r!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t($,{variant:"secondary",children:n("{count} connections",{count:r.totalConnections})}),t($,{variant:"secondary",children:n("{count} subscriptions",{count:r.totalSubscriptions})})]}),e[13]=r,e[14]=n,e[15]=l):l=e[15];let v;e[16]!==d||e[17]!==l?(v=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,l]}),e[16]=d,e[17]=l,e[18]=v):v=e[18];let x;e[19]!==s||e[20]!==h?(x=s!==null&&t(T,{error:h,testId:"subs-error"}),e[19]=s,e[20]=h,e[21]=x):x=e[21],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[v,x,s===null&&r!==void 0&&S.length===0&&t(q,{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.")}),s===null&&S.length>0&&t(E,{className:"overflow-hidden py-0",children:t(_,{className:"px-0",children:c(D,{"data-testid":"subs-table",children:[t(F,{children:c(C,{children:[t(g,{children:n("Connection")}),t(g,{children:n("Function path")}),t(g,{children:n("Table")}),t(g,{children:n("Arguments")})]})}),t(J,{children:S.map(y=>{const{subscription:I}=y,w=W(I?.args);return c(C,{"data-testid":"subs-row",children:[t(N,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t($,{variant:"outline",children:n("admin")})]})}),t(N,{className:"font-mono text-xs",children:I?.functionPath??k}),t(N,{children:I?.table??k}),t(N,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:w||void 0,children:w||k})]},y.key)})})]})})})]}),e[3]=s,e[4]=h,e[5]=r,e[6]=o,e[7]=u,e[8]=n,e[9]=b}else b=e[9];return b};export{oe as default};
@@ -0,0 +1 @@
1
+ import{c as z}from"react/compiler-runtime";import{useLunora as D}from"@lunora/react";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as K,f as L}from"../packem_shared/card-BMKx5UdA.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as A,n as E,f as _,m as i,b as M,p as c}from"../packem_shared/table-DZAB8cs3.js";import{O as Y}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as F}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";const G=2e3,H=new Set(["open"]),re=O=>{const e=z(41),{read:x}=O,n=F(),P=D();let S;e[0]!==P||e[1]!==x?(S=()=>Promise.resolve(x?x():P.debug()),e[0]=P,e[1]=x,e[2]=S):S=e[2];const W=S,R=x?"injected":"live";let v;e[3]!==R?(v=["lunora-studio","sync-client-debug",R],e[3]=R,e[4]=v):v=e[4];const{data:l,refetch:q}=Y(v,W);if(B(q,!0,G),!l){let r;e[5]!==n?(r=n("Reading the sync client's state…"),e[5]=n,e[6]=r):r=e[6];let y;e[7]!==n?(y=n("Sync client"),e[7]=n,e[8]=y):y=e[8];let w;return e[9]!==r||e[10]!==y?(w=t(K,{children:t(L,{children:t(j,{description:r,title:y})})}),e[9]=r,e[10]=y,e[11]=w):w=e[11],w}const{pendingWrites:b,shards:$,subscriptions:N}=l;let o;e[12]!==n?(o=n("This Studio session's sync client"),e[12]=n,e[13]=o):o=e[13];let d;e[14]!==o?(d=t("span",{className:"text-sm font-medium",children:o}),e[14]=o,e[15]=d):d=e[15];const T=l.connectionStatus==="connected"?"default":"secondary";let a;e[16]!==l.connectionStatus||e[17]!==T?(a=t(C,{variant:T,children:l.connectionStatus}),e[16]=l.connectionStatus,e[17]=T,e[18]=a):a=e[18];let h;e[19]!==b||e[20]!==n?(h=b>0?t(C,{variant:"secondary",children:n("{count} pending writes",{count:b})}):null,e[19]=b,e[20]=n,e[21]=h):h=e[21];let u;e[22]!==d||e[23]!==a||e[24]!==h?(u=s("div",{className:"flex flex-wrap items-center gap-2",children:[d,a,h]}),e[22]=d,e[23]=a,e[24]=h,e[25]=u):u=e[25];let m;e[26]!==n?(m=n("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=n,e[27]=m):m=e[27];let p;e[28]!==m?(p=t("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=p):p=e[29];let f;e[30]!==$||e[31]!==n?(f=$.length===0?t(j,{description:n("No shard connection has been opened yet."),title:n("No shards")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Shard")}),t(i,{children:n("Socket")}),t(i,{children:n("Confirmed watermark")})]})}),t(M,{children:$.map(r=>s(_,{children:[t(c,{children:r.shardKey??n("(default)")}),t(c,{children:t(C,{variant:H.has(r.wsState)?"default":"secondary",children:r.wsState})}),t(c,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=$,e[31]=n,e[32]=f):f=e[32];let g;e[33]!==N||e[34]!==n?(g=N.length===0?t(j,{description:n("This client holds no live queries or shapes."),title:n("No subscriptions")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Subscription")}),t(i,{children:n("Kind")}),t(i,{children:n("Acked")}),t(i,{children:n("Cursor")}),t(i,{children:n("Pending overlays")})]})}),t(M,{children:N.map(r=>s(_,{children:[t(c,{className:"font-mono text-xs",children:r.functionPath}),t(c,{children:r.kind}),t(c,{children:t(C,{variant:r.acked?"default":"secondary",children:r.acked?n("yes"):n("no")})}),t(c,{children:r.serverCursor??"—"}),t(c,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=N,e[34]=n,e[35]=g):g=e[35];let k;return e[36]!==p||e[37]!==f||e[38]!==g||e[39]!==u?(k=t(K,{children:s(L,{className:"flex flex-col gap-4",children:[u,p,f,g]})}),e[36]=p,e[37]=f,e[38]=g,e[39]=u,e[40]=k):k=e[40],k};export{re as default};
@@ -0,0 +1 @@
1
+ import{c as z}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{U as he}from"../packem_shared/error-alert-_2q2VtVG.js";import{L as ge}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as be}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ce}from"../packem_shared/badge-BbuuAio7.js";import{f as xe}from"../packem_shared/checkbox-StT4Gob6.js";import{E as ve}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ye}from"../packem_shared/input-JHu63lTv.js";import{N as oe}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Ne}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as de}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as me}from"../packem_shared/internal-zkEvTqy8.js";import{r as we}from"../packem_shared/shard-history-DMEW5VBE.js";import{f as Me,p as Se,c as Ie}from"../packem_shared/trace-handoff-D7j9TjUT.js";import{E as ke}from"../packem_shared/log-line-CmtmbZNE.js";import{c as se}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as k,Fragment as $e}from"react/jsx-runtime";const ie=n=>Math.min(100,Math.max(0,n)),_e=(n,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ie(n.offsetMs/e*100),a=n.durationMs/e*100,l=Math.max(.5,Math.min(ie(a),100-t));return{leftPercent:t,widthPercent:l}},Te=(n,e,t=!1)=>{const a=e.trim().toLowerCase(),l=t?n.filter(r=>!r.ok):n;return a===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(a)||r.functionPath.toLowerCase().includes(a)||r.traceId.toLowerCase().includes(a)||r.spans.some(o=>o.name.toLowerCase().includes(a)||o.spanId.toLowerCase().includes(a)))},U=n=>Number.isFinite(n)?n>0&&n<1?`${n.toFixed(2)}ms`:`${String(Math.round(n))}ms`:"—",Le=n=>!Number.isFinite(n)||n<=0?[]:Array.from({length:4},(e,t)=>{const a=(t+1)/4;return{label:U(n*a),percent:a*100}}),ue=n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}},V=n=>{const e=z(7),{label:t,value:a}=n;let l;e[0]!==t?(l=s("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==a?(r=s("dd",{className:"min-w-0 break-all",children:a}),e[2]=a,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Pe=n=>{const e=z(68),{span:t}=n,a=X();let l,r,o,d,i,m;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]!==a){const _=Object.entries(t.attributes??{});let $;e[15]!==t.events?($=t.events??[],e[15]=t.events,e[16]=$):$=e[16],l=$,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let y;e[17]!==a?(y=a("Span ID"),e[17]=a,e[18]=y):y=e[18];let N;e[19]!==t.spanId||e[20]!==y?(N=s(V,{label:y,value:t.spanId}),e[19]=t.spanId,e[20]=y,e[21]=N):N=e[21];let w;e[22]!==a?(w=a("Parent span ID"),e[22]=a,e[23]=w):w=e[23];let u;e[24]!==t.parentSpanId||e[25]!==a?(u=t.parentSpanId===""?a("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=a,e[26]=u):u=e[26];let f;e[27]!==u||e[28]!==w?(f=s(V,{label:w,value:u}),e[27]=u,e[28]=w,e[29]=f):f=e[29];let h;e[30]!==a?(h=a("Kind"),e[30]=a,e[31]=h):h=e[31];const T=t.kind??"internal";let S;e[32]!==h||e[33]!==T?(S=s(V,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=S):S=e[34];let M;e[35]!==a?(M=a("Started at"),e[35]=a,e[36]=M):M=e[36];let g;e[37]!==t.offsetMs||e[38]!==a?(g=a("+{offset}",{offset:U(t.offsetMs)}),e[37]=t.offsetMs,e[38]=a,e[39]=g):g=e[39];let b;e[40]!==M||e[41]!==g?(b=s(V,{label:M,value:g}),e[40]=M,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==a?(I=a("Duration"),e[43]=a,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=U(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=s(V,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==f||e[51]!==S||e[52]!==b||e[53]!==x||e[54]!==N?(d=k("dl",{className:"flex flex-col gap-1",children:[N,f,S,b,x]}),e[50]=f,e[51]=S,e[52]=b,e[53]=x,e[54]=N,e[55]=d):d=e[55],e[56]!==t.error?(i=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:[s("span",{className:"font-semibold text-destructive",children:t.error.type}),s("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=i):i=e[57],m=_.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[s("p",{className:"mb-1 text-muted-foreground",children:a("Attributes")}),s("dl",{className:"flex flex-col gap-1",children:_.map(Ce)})]}),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]=a,e[9]=l,e[10]=r,e[11]=o,e[12]=d,e[13]=i,e[14]=m}else l=e[9],r=e[10],o=e[11],d=e[12],i=e[13],m=e[14];let c;e[58]!==l||e[59]!==a?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[s("p",{className:"mb-1 text-muted-foreground",children:a("Events")}),s("ul",{className:"flex flex-col gap-1",children:l.map(Ke)})]}),e[58]=l,e[59]=a,e[60]=c):c=e[60];let v;return e[61]!==r||e[62]!==o||e[63]!==d||e[64]!==i||e[65]!==m||e[66]!==c?(v=k("div",{className:r,"data-testid":o,children:[d,i,m,c]}),e[61]=r,e[62]=o,e[63]=d,e[64]=i,e[65]=m,e[66]=c,e[67]=v):v=e[67],v};function Ce(n){const[e,t]=n;return s(V,{label:e,value:ue(t)},e)}function Fe(n){const[e,t]=n;return`${e}=${ue(t)}`}function Ke(n){return k("li",{className:"flex gap-2",children:[s("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(n.ts)}),s(ce,{variant:"secondary",children:n.name}),s("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(n.attributes??{}).map(Fe).join(" ")})]},`${n.name}:${String(n.ts)}`)}const De=14,fe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=n=>{const e=z(17),{traceDurationMs:t}=n;let a,l,r,o,d,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const v=Le(t);if(v.length===0){i=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=se(fe,"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")?(d=s("span",{}),e[8]=d):d=e[8],a="relative h-3",l=v.map(Be)}e[0]=t,e[1]=a,e[2]=l,e[3]=r,e[4]=o,e[5]=d,e[6]=i}else a=e[1],l=e[2],r=e[3],o=e[4],d=e[5],i=e[6];if(i!==Symbol.for("react.early_return_sentinel"))return i;let m;e[9]!==a||e[10]!==l?(m=s("span",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=m):m=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==d||e[15]!==m?(c=k("div",{className:r,"data-testid":o,children:[d,m]}),e[12]=r,e[13]=o,e[14]=d,e[15]=m,e[16]=c):c=e[16],c},Ee=n=>{const e=z(60),{span:t,traceDurationMs:a}=n,l=X(),[r,o]=ee(!1);let d;e[0]!==t||e[1]!==a?(d=_e(t,a),e[0]=t,e[1]=a,e[2]=d):d=e[2];const{leftPercent:i,widthPercent:m}=d;let c;e[3]!==t.attributes?(c=Me(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const v=c,_=t.depth*De;let $;e[5]!==_?($={paddingLeft:_},e[5]=_,e[6]=$):$=e[6];const y=$,N=`${String(i)}%`,w=`${String(m)}%`;let u;e[7]!==N||e[8]!==w?(u={left:N,width:w},e[7]=N,e[8]=w,e[9]=u):u=e[9];const f=u;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Oe)},e[10]=h):h=e[10];const T=h,S=t.depth,M=`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:U(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:U(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=se(fe,"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:s("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]!==y||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:y,title:t.name,children:[p,t.name]}),e[20]=y,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const A=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==A?(L=se("absolute inset-y-0 rounded-sm",A),e[24]=A,e[25]=L):L=e[25];let E;e[26]!==f||e[27]!==i||e[28]!==L||e[29]!==m?(E=s("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:s("span",{className:L,"data-left":i,"data-testid":"tr-span-bar","data-width":m,style:f})}),e[26]=f,e[27]=i,e[28]=L,e[29]=m,e[30]=E):E=e[30];let B;e[31]!==t.durationMs?(B=U(t.durationMs),e[31]=t.durationMs,e[32]=B):B=e[32];let K;e[33]!==B?(K=s("span",{className:"text-right tabular-nums text-muted-foreground",children:B}),e[33]=B,e[34]=K):K=e[34];let O;e[35]!==t.error?(O=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=O):O=e[36];let P;e[37]!==O?(P=s("span",{className:"truncate text-muted-foreground",children:O}),e[37]=O,e[38]=P):P=e[38];let R;e[39]!==v?(R=v===""?null:s("span",{"data-testid":"tr-span-attributes",title:v,children:v}),e[39]=v,e[40]=R):R=e[40];let C;e[41]!==R?(C=s("span",{className:"truncate text-muted-foreground",children:R}),e[41]=R,e[42]=C):C=e[42];let J;e[43]!==r||e[44]!==M||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==E||e[49]!==K||e[50]!==P||e[51]!==C?(J=k("button",{"aria-controls":M,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,E,K,P,C]}),e[43]=r,e[44]=M,e[45]=g,e[46]=I,e[47]=x,e[48]=E,e[49]=K,e[50]=P,e[51]=C,e[52]=J):J=e[52];let D;e[53]!==r||e[54]!==t?(D=r&&s("div",{id:`tr-span-detail-${t.spanId}`,children:s(Pe,{span:t})}),e[53]=r,e[54]=t,e[55]=D):D=e[55];let F;return e[56]!==t.depth||e[57]!==J||e[58]!==D?(F=k("li",{"data-depth":S,"data-testid":"tr-span-row",children:[J,D]}),e[56]=t.depth,e[57]=J,e[58]=D,e[59]=F):F=e[59],F},Ae=n=>{const e=z(15),{durationMs:t,spans:a}=n,l=X();let r;e[0]!==t?(r=s(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 d;if(e[4]!==t||e[5]!==a){let c;e[7]!==t?(c=v=>s(Ee,{span:v,traceDurationMs:t},v.spanId),e[7]=t,e[8]=c):c=e[8],d=a.map(c),e[4]=t,e[5]=a,e[6]=d}else d=e[6];let i;e[9]!==o||e[10]!==d?(i=s("ul",{"aria-label":o,children:d}),e[9]=o,e[10]=d,e[11]=i):i=e[11];let m;return e[12]!==r||e[13]!==i?(m=k($e,{children:[r,i]}),e[12]=r,e[13]=i,e[14]=m):m=e[14],m};function Be(n){return s("span",{className:se("absolute inset-y-0 border-l border-border/70",n.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(n.percent)}%`},children:n.label},n.percent)}function Oe(n){return!n}const Re=n=>Array.isArray(n?.traces)?n.traces:[],Je=n=>{const e=z(12),{entries:t}=n,a=X();let l;e[0]!==t.length||e[1]!==a?(l=a("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=a,e[2]=l):l=e[2];let r;e[3]!==l?(r=s("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(Ue),e[5]=t,e[6]=o):o=e[6];let d;e[7]!==o?(d=s("div",{role:"grid",children:o}),e[7]=o,e[8]=d):d=e[8];let i;return e[9]!==r||e[10]!==d?(i=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,d]}),e[9]=r,e[10]=d,e[11]=i):i=e[11],i},ze=n=>{const e=z(50),{expanded:t,logs:a,onToggle:l,trace:r}=n,o=X();let d;e[0]!==l||e[1]!==r.traceId?(d=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=d):d=e[2];const i=d,m=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,v=`tr-toggle-${r.traceId}`,_=t?"▾":"▸";let $;e[3]!==_?($=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:_}),e[3]=_,e[4]=$):$=e[4];let y;e[5]!==r.rootName?(y=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=y):y=e[6];let N;e[7]!==r.functionPath?(N=s("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]=N):N=e[8];let w;e[9]!==r.durationMs?(w=U(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let u;e[11]!==w?(u=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=u):u=e[12];let f;e[13]!==o||e[14]!==r.spans.length?(f=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=f):f=e[15];let h;e[16]!==f?(h=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let S;e[18]!==o||e[19]!==r.ok?(S=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=S):S=e[20];let M;e[21]!==T||e[22]!==S?(M=s("span",{className:"shrink-0",children:s(ce,{variant:T,children:S})}),e[21]=T,e[22]=S,e[23]=M):M=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=s("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]!==i||e[30]!==u||e[31]!==h||e[32]!==M||e[33]!==b||e[34]!==c||e[35]!==v||e[36]!==$||e[37]!==y||e[38]!==N?(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":v,onClick:i,type:"button",children:[$,y,N,u,h,M,b]}),e[28]=t,e[29]=i,e[30]=u,e[31]=h,e[32]=M,e[33]=b,e[34]=c,e[35]=v,e[36]=$,e[37]=y,e[38]=N,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==a||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:[s(Ae,{durationMs:r.durationMs,spans:r.spans}),a.length>0&&s(Je,{entries:a})]}),e[40]=t,e[41]=a,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]!==m?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":m,children:[I,p]}),e[46]=I,e[47]=p,e[48]=m,e[49]=x):x=e[49],x},ft=n=>{const e=z(58),{initialShardKey:t}=n,a=X(),[l]=ee(Se),{queryShardKey:r,setShardKey:o,shardKey:d}=Ne(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[i,m]=ee(l?.traceId??""),[c,v]=ee(!1),[_,$]=ee(We);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],le(qe,y);let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N={},e[1]=N):N=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:u,error:f,errorSource:h,isLoading:T,liveError:S}=oe(de.getTraces,N,w);let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M={},e[4]=M):M=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(de.getLogs,M,b);let p,x;e[8]!==u||e[9]!==r?(p=()=>{u!==void 0&&we(r)},x=[u,r],e[8]=u,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let A;if(e[12]!==u||e[13]!==f||e[14]!==h||e[15]!==_||e[16]!==T||e[17]!==S||e[18]!==I?.entries||e[19]!==c||e[20]!==i||e[21]!==o||e[22]!==d||e[23]!==a){const L=Re(u),E=u?.total??L.length,B=E>L.length,K=Te(L,i,c),O=Map.groupBy((I?.entries??[]).toReversed(),He);let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=j=>{m(j.target.value)},e[25]=P):P=e[25];const R=P;let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=j=>{$(pe=>{const ne=new Set(pe);return ne.has(j)?ne.delete(j):ne.add(j),ne})},e[26]=C):C=e[26];const J=C,D=f===null&&K.length===0&&!T;let F;e[27]!==o||e[28]!==d?(F=s(be,{onChange:o,testId:"tr-shard-input",value:d}),e[27]=o,e[28]=d,e[29]=F):F=e[29];let W;e[30]!==a?(W=a("Search traces"),e[30]=a,e[31]=W):W=e[31];let q;e[32]!==a?(q=a("search trace, span, or function"),e[32]=a,e[33]=q):q=e[33];let H;e[34]!==i||e[35]!==W||e[36]!==q?(H=s(ye,{"aria-label":W,className:"h-8 w-56","data-testid":"tr-search",onChange:R,placeholder:q,value:i}),e[34]=i,e[35]=W,e[36]=q,e[37]=H):H=e[37];let Q;e[38]!==c?(Q=s(xe,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:v}),e[38]=c,e[39]=Q):Q=e[39];let Y;e[40]!==a?(Y=a("Errors only"),e[40]=a,e[41]=Y):Y=e[41];let Z;e[42]!==Q||e[43]!==Y?(Z=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[Q,Y]}),e[42]=Q,e[43]=Y,e[44]=Z):Z=e[44];let G;e[45]!==S?(G=s(ge,{message:S,prefix:"tr"}),e[45]=S,e[46]=G):G=e[46];let te;e[47]!==F||e[48]!==H||e[49]!==Z||e[50]!==G?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[F,H,Z,G]}),e[47]=F,e[48]=H,e[49]=Z,e[50]=G,e[51]=te):te=e[51];let re;e[52]!==f||e[53]!==h?(re=f!==null&&s(he,{error:h,testId:"tr-error"}),e[52]=f,e[53]=h,e[54]=re):re=e[54];let ae;e[55]!==D||e[56]!==a?(ae=D&&s(ve,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),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 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[55]=D,e[56]=a,e[57]=ae):ae=e[57],A=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,ae,f===null&&B&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:E})}),f===null&&K.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:K.map(j=>s(ze,{expanded:_.has(j.traceId),logs:O.get(j.traceId)??[],onToggle:J,trace:j},j.traceId))})]}),e[12]=u,e[13]=f,e[14]=h,e[15]=_,e[16]=T,e[17]=S,e[18]=I?.entries,e[19]=c,e[20]=i,e[21]=o,e[22]=d,e[23]=a,e[24]=A}else A=e[24];return A};function Ue(n,e){return s("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:s(ke,{entry:n})},`${String(e)}:${String(n.timestamp)}`)}function We(){return new Set}function qe(){Ie()}function He(n){return n.traceId}export{ft as default};
@@ -0,0 +1 @@
1
+ import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,f as Fe}from"../packem_shared/card-BMKx5UdA.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{d as Ue,n as _e,f as L,m as z,b as Pe,p as U}from"../packem_shared/table-DZAB8cs3.js";import{O as Ke}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-0EnNCdLu.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-CU-uftxO.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,b as Ee}from"../packem_shared/internal-zkEvTqy8.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{_ as Xe}from"../packem_shared/use-async-submit-B32whHJO.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=p=>{A(p.target.value)},e[3]=P):P=e[3];const De=P;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,_)=>{d(q=>({...q,[p]:_}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=_=>!_.required||at(_,R(_)),e[11]=R,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=R,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==R?(W=()=>{const p={};for(const _ of o.userFields){const q=lt(_,R(_));q!==void 0&&(p[_.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=R,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==R||e[75]!==a?(he=o.userFields.length>0&&n("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{const _=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=R(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:_,children:[t(Qe,{checked:Me,"data-testid":_,id:_,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=R(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:_,children:[p.name,q]}),t(j,{"data-testid":_,id:_,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=R,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(_e,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(Pe,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(_e,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(Pe,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&Re((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(_e,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(Pe,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),P=(N,D)=>{Re((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&P(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;P(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},R=()=>{P(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{P(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{P(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{P(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{P(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:R,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:P,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:P,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:P,userId:l.id,version:I}),n("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,Pt=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(_e,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(Pe,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{Pt as UsersPanel};
@@ -0,0 +1 @@
1
+ import{c as A}from"react/compiler-runtime";import{useLunora as H}from"@lunora/react";import{useState as h,useEffect as Q}from"react";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{c as V,f as j}from"../packem_shared/card-BMKx5UdA.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as D}from"../packem_shared/input-JHu63lTv.js";import{d as q,n as E,f as N,m as o,b as L,p as i}from"../packem_shared/table-DZAB8cs3.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as M,b as B,h as J}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const O=10,g=x=>{const r=A(7),{label:m,value:a}=x;let l;r[0]!==m?(l=e("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),r[0]=m,r[1]=l):l=r[1];const f=a??"—";let c;r[2]!==f?(c=e("span",{className:"font-mono text-sm",children:f}),r[2]=f,r[3]=c):c=r[3];let u;return r[4]!==l||r[5]!==c?(u=n("div",{className:"flex flex-col gap-0.5",children:[l,c]}),r[4]=l,r[5]=c,r[6]=u):u=r[6],u},ce=({loadIndexes:x,runQuery:r}={})=>{const m=H(),a=G(),[l,f]=h(null),[c,u]=h(null),[v,C]=h(null),[b,F]=h(""),[p,y]=h(null),[k,w]=h(null),[I,S]=h(!1);Q(()=>{const t={cancelled:!1};return M((async()=>{try{const d=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(f(d),u(null),C($=>$??d[0]?.name??null))}catch(d){t.cancelled||(f(null),u(B(d)))}})()),()=>{t.cancelled=!0}},[m,x]);const s=l?.find(t=>t.name===v)??null,K=t=>{C(t.currentTarget.dataset.index??null),y(null),w(null)},T=t=>{F(t.target.value)},Z=async()=>{const t=b.trim();if(!(v===null||t==="")){S(!0),w(null);try{const d=await(r??($=>m.queryVectorIndex($)))({name:v,text:t,topK:O});y(d)}catch(d){y(null),w(B(d))}S(!1)}},z=()=>{M(Z())};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[c!==null&&e("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:c}),l!==null&&l.length===0&&e(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),l!==null&&l.length>0&&e(V,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-table",children:[e(E,{children:n(N,{children:[e(o,{children:a("name")}),e(o,{children:a("table")}),e(o,{children:a("dimensions")}),e(o,{children:a("metric")}),e(o,{children:a("vectors")})]})}),e(L,{children:l.map(t=>n(N,{className:t.name===v?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:K,children:[e(i,{className:"font-mono text-xs",children:t.name}),e(i,{className:"font-mono text-xs",children:t.table}),e(i,{className:"tabular-nums",children:t.dimensions??"—"}),e(i,{children:t.metric??"—"}),e(i,{className:"tabular-nums",children:t.vectorsCount??"—"})]},t.name))})]})})}),s!==null&&n("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[n("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e(g,{label:a("field"),value:s.field}),e(g,{label:a("dimensions"),value:s.dimensions}),e(g,{label:a("metric"),value:s.metric}),e(g,{label:a("vectors"),value:s.vectorsCount})]}),s.metadata!==void 0&&s.metadata.length>0&&n("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",e("span",{className:"font-mono",children:s.metadata.join(", ")})]}),n("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e(D,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:T,placeholder:a("Search by similarity…"),value:b}),e(R,{"data-testid":"vector-search",disabled:I||b.trim()==="",onClick:z,children:a(I?"Searching…":"Search")})]}),k!==null&&e("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:k}),p!==null&&p.length===0&&e("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),p!==null&&p.length>0&&e(V,{className:"mt-3 overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-matches",children:[e(E,{children:n(N,{children:[e(o,{children:a("id")}),e(o,{children:a("score")}),e(o,{children:a("metadata")})]})}),e(L,{children:p.map(t=>n(N,{"data-testid":`vector-match-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.id}),e(i,{className:"tabular-nums",children:t.score.toFixed(4)}),e(i,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"—":J(t.metadata)})]},t.id))})]})})})]})]})};export{ce as VectorBrowser};
@@ -0,0 +1 @@
1
+ import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,f as L}from"../packem_shared/card-BMKx5UdA.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{d as U,n as _,f as x,m as i,b as q,p as d}from"../packem_shared/table-DZAB8cs3.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("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:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
@@ -0,0 +1 @@
1
+ const _="__lunora_admin__:",e={aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAdvisorProcedures:"__lunora_admin__:getAdvisorProcedures",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",lintSql:"__lunora_admin__:lintSql",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listTablesIndexes:"__lunora_admin__:listTablesIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{e as ADMIN_FUNCTIONS,_ as ADMIN_FUNCTION_PREFIX};
@@ -0,0 +1,2 @@
1
+ import{c as E}from"react/compiler-runtime";import{useLunora as Y}from"@lunora/react";import{useState as M,useEffect as Z}from"react";import{u as Q}from"./button-BkCrNcAs.js";import{E as z}from"./empty-state-Cg7t_8qu.js";import{useT as L}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"./ADMIN_FUNCTIONS-4aE59aDq.js";import{c as ee,d as te,g as ae}from"./internal-zkEvTqy8.js";import{jsxs as A,jsx as m}from"react/jsx-runtime";const ne=ae(B.listTables),ie=["react","client","cli"],le=!1,oe={action:"action",mutation:"mutation",query:"query"},J=i=>{const e=i.indexOf(":");return e===-1?{file:"",fn:i}:{file:i.slice(0,e),fn:i.slice(e+1)}},U=({file:i,fn:e,kind:l})=>`await client.${oe[l]}(api.${i}.${e}, { /* args */ });`,re=i=>{const e=`api.${i.file}.${i.fn}`;switch(i.kind){case"action":return U(i);case"mutation":return`const ${i.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},se=({file:i,fn:e})=>`lunora run ${i}:${e} --args '{ }'`,de=i=>["// Read rows",`const rows = await ctx.db.query("${i}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${i}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${i}">;`,`type RowId = Id<"${i}">;`].join(`
2
+ `),ce=(i,e)=>{switch(i){case"cli":return se(e);case"client":return U(e);default:return re(e)}},V=i=>{const e=E(19),{code:l,label:o,testId:a}=i,n=L();let s;e[0]!==l?(s=()=>{ee(l)},e[0]=l,e[1]=s):s=e[1];const u=s;let t;e[2]!==o?(t=m("span",{className:"text-xs font-medium text-muted-foreground",children:o}),e[2]=o,e[3]=t):t=e[3];const c=`${a}-copy`;let r;e[4]!==n?(r=n("Copy"),e[4]=n,e[5]=r):r=e[5];let p;e[6]!==u||e[7]!==c||e[8]!==r?(p=m(Q,{"data-testid":c,onClick:u,size:"xs",type:"button",variant:"ghost",children:r}),e[6]=u,e[7]=c,e[8]=r,e[9]=p):p=e[9];let f;e[10]!==t||e[11]!==p?(f=A("div",{className:"flex items-center justify-between gap-2",children:[t,p]}),e[10]=t,e[11]=p,e[12]=f):f=e[12];let d;e[13]!==l||e[14]!==a?(d=m("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":a,children:l}),e[13]=l,e[14]=a,e[15]=d):d=e[15];let h;return e[16]!==f||e[17]!==d?(h=A("div",{className:"flex flex-col gap-1.5",children:[f,d]}),e[16]=f,e[17]=d,e[18]=h):h=e[18],h},pe=i=>{const e=E(50),{file:l,fn:o,kind:a}=i,n=L(),[s,u]=M("react");let t,c,r;if(e[0]!==l||e[1]!==o||e[2]!==a||e[3]!==n||e[4]!==s){const x={file:l,fn:o,kind:a};let I;e[8]!==n?(I=n("CLI"),e[8]=n,e[9]=I):I=e[9];let C;e[10]!==n?(C=n("Client"),e[10]=n,e[11]=C):C=e[11];let T;e[12]!==n?(T=n("React"),e[12]=n,e[13]=T):T=e[13];let _;e[14]!==I||e[15]!==C||e[16]!==T?(_={cli:I,client:C,react:T},e[14]=I,e[15]=C,e[16]=T,e[17]=_):_=e[17],r=_;let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=P=>{u(P.currentTarget.dataset.tab)},e[18]=D):D=e[18],t=D,c=ce(s,x),e[0]=l,e[1]=o,e[2]=a,e[3]=n,e[4]=s,e[5]=t,e[6]=c,e[7]=r}else t=e[5],c=e[6],r=e[7];const p=c,f=a==="action"&&s==="react"&&!le,d=`api.${l}.${o}`;let h;e[19]!==d?(h=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:d}),e[19]=d,e[20]=h):h=e[20];let b;e[21]!==a||e[22]!==n?(b=n("Call this {kind} from your app.",{kind:a}),e[21]=a,e[22]=n,e[23]=b):b=e[23];let v;e[24]!==b?(v=m("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=v):v=e[25];let y;e[26]!==h||e[27]!==v?(y=A("div",{children:[h,v]}),e[26]=h,e[27]=v,e[28]=y):y=e[28];let k;e[29]!==n?(k=n("Snippet flavour"),e[29]=n,e[30]=k):k=e[30];let $;e[31]!==t||e[32]!==s||e[33]!==r?($=ie.map(x=>m(Q,{"aria-selected":s===x,"data-tab":x,"data-testid":`api-tab-${x}`,onClick:t,role:"tab",size:"xs",type:"button",variant:s===x?"default":"outline",children:r[x]},x)),e[31]=t,e[32]=s,e[33]=r,e[34]=$):$=e[34];let N;e[35]!==k||e[36]!==$?(N=m("div",{"aria-label":k,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:$}),e[35]=k,e[36]=$,e[37]=N):N=e[37];const O=r[s],j=`api-snippet-${s}`;let w;e[38]!==p||e[39]!==O||e[40]!==j?(w=m(V,{code:p,label:O,testId:j}),e[38]=p,e[39]=O,e[40]=j,e[41]=w):w=e[41];let S;e[42]!==f||e[43]!==n?(S=f&&m("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:n("Actions have no React hook — call them through the client.")}),e[42]=f,e[43]=n,e[44]=S):S=e[44];let R;return e[45]!==w||e[46]!==S||e[47]!==y||e[48]!==N?(R=A("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[y,N,w,S]}),e[45]=w,e[46]=S,e[47]=y,e[48]=N,e[49]=R):R=e[49],R},fe=i=>{const e=E(19),{name:l}=i,o=L();let a;e[0]!==l?(a=de(l),e[0]=l,e[1]=a):a=e[1];const n=a;let s;e[2]!==l?(s=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:l}),e[2]=l,e[3]=s):s=e[3];let u;e[4]!==o?(u=o("Read and write this table through the typed data model."),e[4]=o,e[5]=u):u=e[5];let t;e[6]!==u?(t=m("p",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=t):t=e[7];let c;e[8]!==s||e[9]!==t?(c=A("div",{children:[s,t]}),e[8]=s,e[9]=t,e[10]=c):c=e[10];let r;e[11]!==o?(r=o("Data model"),e[11]=o,e[12]=r):r=e[12];let p;e[13]!==n||e[14]!==r?(p=m(V,{code:n,label:r,testId:"api-snippet-table"}),e[13]=n,e[14]=r,e[15]=p):p=e[15];let f;return e[16]!==c||e[17]!==p?(f=A("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,p]}),e[16]=c,e[17]=p,e[18]=f):f=e[18],f},G=i=>{const e=E(8),{active:l,label:o,onSelect:a,testId:n,value:s}=i;let u;e[0]!==a||e[1]!==s?(u=()=>{a(s)},e[0]=a,e[1]=s,e[2]=u):u=e[2];const t=u,c=l?"page":void 0;let r;return e[3]!==o||e[4]!==t||e[5]!==c||e[6]!==n?(r=m("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":n,onClick:t,type:"button",children:o}),e[3]=o,e[4]=t,e[5]=c,e[6]=n,e[7]=r):r=e[7],r},me=i=>{const e=new Map;for(const l of i){const{file:o,fn:a}=J(l.path),n=e.get(o)??[];n.push({fn:a,kind:l.kind,path:l.path}),e.set(o,n)}return[...e.entries()].map(([l,o])=>({file:l,items:o.toSorted((a,n)=>a.fn.localeCompare(n.fn))})).toSorted((l,o)=>l.file.localeCompare(o.file))},Se=i=>{const e=E(58),{functions:l,initialShardKey:o}=i,a=L(),n=Y(),[s,u]=M(null),[t,c]=M(null);let r,p;e[0]!==n||e[1]!==o?(r=()=>{let _=!1;return n.query(ne,{},te(o??"")).then(D=>(_||u(D),D)).catch(()=>{_||u([])}),()=>{_=!0}},p=[n,o],e[0]=n,e[1]=o,e[2]=r,e[3]=p):(r=e[2],p=e[3]),Z(r,p);let f,d,h,b,v,y,k,$,N,O;if(e[4]!==l||e[5]!==t||e[6]!==a||e[7]!==s){const _=l??[],D=me(_),P=(s??[]).map(ue).toSorted(he);let F;e[18]===Symbol.for("react.memo_cache_sentinel")?(F=g=>{c({kind:"fn",path:g})},e[18]=F):F=e[18];const W=F;let H;e[19]===Symbol.for("react.memo_cache_sentinel")?(H=g=>{c({kind:"table",name:g})},e[19]=H):H=e[19];const X=H;d=t?.kind==="fn"?_.find(g=>g.path===t.path):void 0,f=_.length>0||P.length>0,h=d===void 0?void 0:J(d.path),N="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==a?(b=a("API resources"),e[20]=a,e[21]=b):b=e[21],v="flex flex-col gap-4 overflow-y-auto",y="api-rail";let K;e[22]!==t||e[23]!==a?(K=g=>A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g.file||a("(root)")}),g.items.map(q=>m(G,{active:t?.kind==="fn"&&t.path===q.path,label:q.fn,onSelect:W,testId:`api-rail-fn-${q.path}`,value:q.path},q.path))]},g.file),e[22]=t,e[23]=a,e[24]=K):K=e[24],k=D.map(K),$=P.length>0&&A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Tables")}),P.map(g=>m(G,{active:t?.kind==="table"&&t.name===g,label:g,onSelect:X,testId:`api-rail-table-${g}`,value:g},g))]}),e[4]=l,e[5]=t,e[6]=a,e[7]=s,e[8]=f,e[9]=d,e[10]=h,e[11]=b,e[12]=v,e[13]=y,e[14]=k,e[15]=$,e[16]=N,e[17]=O}else f=e[8],d=e[9],h=e[10],b=e[11],v=e[12],y=e[13],k=e[14],$=e[15],N=e[16],O=e[17];let j;e[25]!==f||e[26]!==a?(j=!f&&m("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:a("No functions or tables to document yet.")}),e[25]=f,e[26]=a,e[27]=j):j=e[27];let w;e[28]!==j||e[29]!==b||e[30]!==v||e[31]!==y||e[32]!==k||e[33]!==$?(w=A("nav",{"aria-label":b,className:v,"data-testid":y,children:[k,$,j]}),e[28]=j,e[29]=b,e[30]=v,e[31]=y,e[32]=k,e[33]=$,e[34]=w):w=e[34];let S;e[35]!==t||e[36]!==a?(S=t===null&&m(z,{description:a("Select a function or table to see how to call it from your app."),testId:"api-empty",title:a("API usage snippets")}),e[35]=t,e[36]=a,e[37]=S):S=e[37];let R;e[38]!==t?.kind||e[39]!==d||e[40]!==h?(R=t?.kind==="fn"&&d!==void 0&&h!==void 0&&m(pe,{file:h.file,fn:h.fn,kind:d.kind},d.path),e[38]=t?.kind,e[39]=d,e[40]=h,e[41]=R):R=e[41];let x;e[42]!==t?.kind||e[43]!==d||e[44]!==a?(x=t?.kind==="fn"&&d===void 0&&m(z,{testId:"api-empty",title:a("API usage snippets")}),e[42]=t?.kind,e[43]=d,e[44]=a,e[45]=x):x=e[45];let I;e[46]!==t?(I=t?.kind==="table"&&m(fe,{name:t.name}),e[46]=t,e[47]=I):I=e[47];let C;e[48]!==S||e[49]!==R||e[50]!==x||e[51]!==I?(C=A("div",{className:"min-w-0",children:[S,R,x,I]}),e[48]=S,e[49]=R,e[50]=x,e[51]=I,e[52]=C):C=e[52];let T;return e[53]!==w||e[54]!==C||e[55]!==N||e[56]!==O?(T=A("div",{className:N,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=N,e[56]=O,e[57]=T):T=e[57],T};function ue(i){return i.name}function he(i,e){return i.localeCompare(e)}export{le as REACT_HAS_ACTION_HOOK,se as buildCliSnippet,U as buildClientSnippet,re as buildReactSnippet,de as buildTableSnippet,Se as default,J as splitPath};