@lunora/studio 1.0.0-alpha.358 → 1.0.0-alpha.359

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 (191) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/mount.mjs +1 -1
  3. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  4. package/dist/packem_chunks/ApiTab.mjs +1 -1
  5. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  6. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  8. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  9. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  11. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  12. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  13. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  14. package/dist/packem_chunks/MailPanel.mjs +1 -1
  15. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  17. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  18. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  20. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  22. package/dist/packem_chunks/TableEditor.mjs +1 -1
  23. package/dist/packem_chunks/agents-panel.mjs +1 -1
  24. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  25. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  26. package/dist/packem_chunks/architecture-panel.mjs +1 -1
  27. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  28. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  30. package/dist/packem_chunks/containers-panel.mjs +1 -1
  31. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  32. package/dist/packem_chunks/evals-panel.mjs +1 -1
  33. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  34. package/dist/packem_chunks/flags-panel.mjs +1 -1
  35. package/dist/packem_chunks/issues-panel.mjs +1 -1
  36. package/dist/packem_chunks/kv-browser.mjs +1 -1
  37. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  38. package/dist/packem_chunks/migrations-route.mjs +1 -1
  39. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  40. package/dist/packem_chunks/payments-panel.mjs +1 -1
  41. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  42. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  43. package/dist/packem_chunks/queues-panel.mjs +1 -1
  44. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  45. package/dist/packem_chunks/rls-panel.mjs +1 -1
  46. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  47. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  48. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  49. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  50. package/dist/packem_chunks/traces-panel.mjs +1 -1
  51. package/dist/packem_chunks/users-panel.mjs +1 -1
  52. package/dist/packem_chunks/vector-browser.mjs +1 -1
  53. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  54. package/dist/packem_shared/{ApiDocsPanel-E4Vr-8zW.mjs → ApiDocsPanel-DD2Uns6b.mjs} +1 -1
  55. package/dist/packem_shared/{ApiReferencePanel-u9Rrljdf.mjs → ApiReferencePanel-CQxU1Ocx.mjs} +1 -1
  56. package/dist/packem_shared/{CommandPalette-5OsK8PNe.mjs → CommandPalette-BZCHLpst.mjs} +1 -1
  57. package/dist/packem_shared/{DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs → DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs} +1 -1
  58. package/dist/packem_shared/{DataBrowser-C5HbI4TH.mjs → DataBrowser-CVRWnNWu.mjs} +1 -1
  59. package/dist/packem_shared/{GlobalDataBrowser-D0H2yJSl.mjs → GlobalDataBrowser-DC47T6Zl.mjs} +1 -1
  60. package/dist/packem_shared/{HomePanel-CcYkDlR-.mjs → HomePanel-D12HxHQo.mjs} +1 -1
  61. package/dist/packem_shared/{MigrationsPanel-YyCO_T-3.mjs → MigrationsPanel-DMkxSXNl.mjs} +1 -1
  62. package/dist/packem_shared/{OpenRpcReferencePanel-E9cDfHRv.mjs → OpenRpcReferencePanel-BFDG91tn.mjs} +1 -1
  63. package/dist/packem_shared/{ScheduledJobs-D4CUj7aX.mjs → ScheduledJobs-QCTRdugp.mjs} +1 -1
  64. package/dist/packem_shared/{Studio-4vJzwwNa.mjs → Studio-MA8kKZLu.mjs} +1 -1
  65. package/dist/packem_shared/{StudioApp-px2FMPDS.mjs → StudioApp-isdWpF9P.mjs} +1 -1
  66. package/dist/packem_shared/{advisor-view-fNcNYW2Q.mjs → advisor-view-tBumWci_.mjs} +1 -1
  67. package/dist/packem_shared/{data-grid-r3isM8Nq.mjs → data-grid-B5m1OosL.mjs} +1 -1
  68. package/dist/packem_shared/{diagram-export-panel-aBDQdX4e.mjs → diagram-export-panel-Vdt-DZnO.mjs} +1 -1
  69. package/dist/packem_shared/{error-alert-54TiaMvZ.mjs → error-alert-C0R39DO1.mjs} +1 -1
  70. package/dist/packem_shared/{grid-features-2c5SaBtH.mjs → grid-features-Drvfswwy.mjs} +1 -1
  71. package/dist/packem_shared/{home-panel-DPiMVQZ2.mjs → home-panel-CDVTuTF8.mjs} +1 -1
  72. package/dist/packem_shared/internal-hIuTpSbx.mjs +2 -0
  73. package/dist/packem_shared/{log-line-BWDt_F56.mjs → log-line-BH0iWiBv.mjs} +1 -1
  74. package/dist/packem_shared/{recording-client-MbGZ28I0.mjs → recording-client-DAipTA_n.mjs} +1 -1
  75. package/dist/packem_shared/{reference-view-DCEC5kjY.mjs → reference-view-DENugPcj.mjs} +1 -1
  76. package/dist/packem_shared/{schema-diagram-k7cFl7Wp.mjs → schema-diagram-CtVPhOGj.mjs} +1 -1
  77. package/dist/packem_shared/{sql-result-table-CatgdmMh.mjs → sql-result-table-DCwooMGW.mjs} +1 -1
  78. package/dist/packem_shared/{studio-DIUgH7k0.mjs → studio-UhUrPz5J.mjs} +1 -1
  79. package/dist/packem_shared/{table-list-sidebar-CCRB_iYz.mjs → table-list-sidebar-CNadcIgG.mjs} +1 -1
  80. package/dist/packem_shared/{use-admin-query-BW9IuacC.mjs → use-admin-query-CaOm4JS3.mjs} +1 -1
  81. package/dist/packem_shared/{use-admin-spec-BdNLZbTO.mjs → use-admin-spec-CK7mk3Ui.mjs} +1 -1
  82. package/dist/packem_shared/{use-async-submit-2eBBD0-m.mjs → use-async-submit-D0r7-m2J.mjs} +1 -1
  83. package/dist/packem_shared/{use-auth-config-KO9tnI39.mjs → use-auth-config-CG7VvAvQ.mjs} +1 -1
  84. package/dist/packem_shared/{use-open-trace-B_0LbTD7.mjs → use-open-trace-BJKMJjeS.mjs} +1 -1
  85. package/dist/packem_shared/{use-sql-assistant-BMVlguKF.mjs → use-sql-assistant-rZPs3LC3.mjs} +1 -1
  86. package/dist/standalone/{chunk-UFPN44MP.js → chunk-2AH4ABE5.js} +1 -1
  87. package/dist/standalone/{chunk-FYWZRJCT.js → chunk-2G57ENH5.js} +1 -1
  88. package/dist/standalone/{chunk-CVUNFP54.js → chunk-3FS22LNI.js} +1 -1
  89. package/dist/standalone/{chunk-2CPBNLFU.js → chunk-3GYLOE4V.js} +1 -1
  90. package/dist/standalone/{chunk-XZKWGTLI.js → chunk-3PAYDWHN.js} +1 -1
  91. package/dist/standalone/{chunk-FACE2CFY.js → chunk-473JK2PQ.js} +1 -1
  92. package/dist/standalone/chunk-4DAKKAK7.js +1 -0
  93. package/dist/standalone/{chunk-FRN6D6MP.js → chunk-4M57OYFX.js} +1 -1
  94. package/dist/standalone/{chunk-KRDWV6YM.js → chunk-5GIQ6C5N.js} +1 -1
  95. package/dist/standalone/{chunk-MDAXV2XH.js → chunk-5R2YO7HF.js} +1 -1
  96. package/dist/standalone/{chunk-SUOVLXY6.js → chunk-5WJG7FMH.js} +1 -1
  97. package/dist/standalone/{chunk-4FZYH76L.js → chunk-63KDHS3H.js} +1 -1
  98. package/dist/standalone/{chunk-HGT4YHTI.js → chunk-6B6ARRMI.js} +1 -1
  99. package/dist/standalone/{chunk-NSUOMZWM.js → chunk-6LMO2D54.js} +1 -1
  100. package/dist/standalone/{chunk-2O6KKVH2.js → chunk-6VAY6L4J.js} +1 -1
  101. package/dist/standalone/{chunk-HKLF627N.js → chunk-7PADVGQX.js} +1 -1
  102. package/dist/standalone/{chunk-IIJXS3KP.js → chunk-7UM5ROG6.js} +1 -1
  103. package/dist/standalone/{chunk-XIVWJUD3.js → chunk-7ZIYHKLX.js} +1 -1
  104. package/dist/standalone/{chunk-NEZRBBPI.js → chunk-A5JISKHE.js} +1 -1
  105. package/dist/standalone/{chunk-MI7DM536.js → chunk-ADNRFCMZ.js} +1 -1
  106. package/dist/standalone/chunk-BFE2DRP6.js +33 -0
  107. package/dist/standalone/{chunk-OIBN6KMM.js → chunk-BPEB4KFE.js} +1 -1
  108. package/dist/standalone/chunk-BVX45MU5.js +7 -0
  109. package/dist/standalone/{chunk-5IGDDSST.js → chunk-BYOGQ2IV.js} +1 -1
  110. package/dist/standalone/{chunk-AKGGWCWW.js → chunk-C6GN7ZXJ.js} +1 -1
  111. package/dist/standalone/{chunk-ZD53YB3L.js → chunk-CL2VZNDI.js} +1 -1
  112. package/dist/standalone/{chunk-P6L6ABWO.js → chunk-CNA3TVUK.js} +1 -1
  113. package/dist/standalone/chunk-CZ6HBDIL.js +1 -0
  114. package/dist/standalone/{chunk-MY7ZGJOD.js → chunk-D6S7MXW4.js} +1 -1
  115. package/dist/standalone/{chunk-LKCO3E2B.js → chunk-FCAXVYAX.js} +1 -1
  116. package/dist/standalone/{chunk-ZWDORIZY.js → chunk-FXPAJDES.js} +1 -1
  117. package/dist/standalone/{chunk-WZTY3ZYI.js → chunk-H7HZ42JY.js} +1 -1
  118. package/dist/standalone/{chunk-CW57Q264.js → chunk-HHRYM6UW.js} +1 -1
  119. package/dist/standalone/{chunk-PMGNJZYE.js → chunk-HPRF5LMA.js} +1 -1
  120. package/dist/standalone/{chunk-PBKTGB7B.js → chunk-IB22LETR.js} +1 -1
  121. package/dist/standalone/chunk-IENQRRQT.js +1 -0
  122. package/dist/standalone/{chunk-LRXCL6IA.js → chunk-IQ4TTHQT.js} +1 -1
  123. package/dist/standalone/{chunk-TA3DCQUA.js → chunk-ITH5LRWM.js} +1 -1
  124. package/dist/standalone/{chunk-B4BK5Q5O.js → chunk-J6VFG6M5.js} +1 -1
  125. package/dist/standalone/{chunk-MD67S53Z.js → chunk-JSDKOE4U.js} +1 -1
  126. package/dist/standalone/{chunk-EAZXULX6.js → chunk-JZD7ZN3F.js} +1 -1
  127. package/dist/standalone/chunk-K3CWB3AM.js +1 -0
  128. package/dist/standalone/{chunk-FCRSF54M.js → chunk-KNFB3FGW.js} +1 -1
  129. package/dist/standalone/{chunk-WOGVVXGF.js → chunk-KNXWDE4N.js} +1 -1
  130. package/dist/standalone/{chunk-DPESH5MT.js → chunk-KRY7BYHT.js} +1 -1
  131. package/dist/standalone/chunk-KYAG2YMF.js +1 -0
  132. package/dist/standalone/{chunk-OUFWXYEF.js → chunk-KZCEJFZF.js} +1 -1
  133. package/dist/standalone/{chunk-F4VO76XV.js → chunk-KZILJQX3.js} +1 -1
  134. package/dist/standalone/{chunk-OSQYIZAV.js → chunk-LEYUH5TS.js} +1 -1
  135. package/dist/standalone/{chunk-AN2L3XHC.js → chunk-LFM672WN.js} +1 -1
  136. package/dist/standalone/{chunk-FHGTI6PR.js → chunk-LPU6YTSU.js} +1 -1
  137. package/dist/standalone/{chunk-TRZTGE4R.js → chunk-MWJC3S62.js} +1 -1
  138. package/dist/standalone/{chunk-OX7I5YHU.js → chunk-NP2AQOLE.js} +1 -1
  139. package/dist/standalone/{chunk-5SYMAYUA.js → chunk-NVKLYDOH.js} +1 -1
  140. package/dist/standalone/{chunk-ZFFZWSDJ.js → chunk-O2NMPIV2.js} +1 -1
  141. package/dist/standalone/{chunk-BCP3MEB3.js → chunk-O2X2XYCM.js} +1 -1
  142. package/dist/standalone/{chunk-XZ6B5XNN.js → chunk-O3MDWYXF.js} +1 -1
  143. package/dist/standalone/chunk-ONG4JEZD.js +1 -0
  144. package/dist/standalone/{chunk-DS7HZKZ2.js → chunk-ONWGX5Y4.js} +1 -1
  145. package/dist/standalone/{chunk-X5KWBDTF.js → chunk-OS26JXYA.js} +1 -1
  146. package/dist/standalone/{chunk-N4AWDORA.js → chunk-PGTEGUAB.js} +1 -1
  147. package/dist/standalone/{chunk-6I42AM75.js → chunk-PQH2LSJX.js} +1 -1
  148. package/dist/standalone/{chunk-7KPRMBD6.js → chunk-PTBUWRBY.js} +1 -1
  149. package/dist/standalone/{chunk-4IEMXFUB.js → chunk-Q6HA3L2H.js} +1 -1
  150. package/dist/standalone/{chunk-KRH6UDVU.js → chunk-QGV5ARD2.js} +1 -1
  151. package/dist/standalone/{chunk-YJWR6ZWC.js → chunk-QWRK4ESB.js} +1 -1
  152. package/dist/standalone/{chunk-WC5QFZYZ.js → chunk-RL2ITK2N.js} +1 -1
  153. package/dist/standalone/{chunk-ZQOPXQIT.js → chunk-RTJO3AR4.js} +1 -1
  154. package/dist/standalone/{chunk-SDQH4HR6.js → chunk-SU5DTRGK.js} +1 -1
  155. package/dist/standalone/{chunk-OSJ7HV7B.js → chunk-T5UMHPAB.js} +1 -1
  156. package/dist/standalone/{chunk-QXHMVPS3.js → chunk-T6HV2FQP.js} +1 -1
  157. package/dist/standalone/{chunk-FNUPPZKJ.js → chunk-T7ZKNNGX.js} +1 -1
  158. package/dist/standalone/{chunk-FLVDICZL.js → chunk-TCYPNSTV.js} +1 -1
  159. package/dist/standalone/{chunk-MHJNM7VT.js → chunk-TQM6XHBA.js} +1 -1
  160. package/dist/standalone/{chunk-IWG2D7QS.js → chunk-TRMWBRRU.js} +1 -1
  161. package/dist/standalone/{chunk-FSWWDMW2.js → chunk-TW7KJSMR.js} +1 -1
  162. package/dist/standalone/{chunk-NMVFSJM7.js → chunk-TYD3V4NB.js} +1 -1
  163. package/dist/standalone/{chunk-3HX723U6.js → chunk-TZKLK52W.js} +1 -1
  164. package/dist/standalone/{chunk-B6OTKSMY.js → chunk-U4RXQSQ7.js} +1 -1
  165. package/dist/standalone/{chunk-MC577GI5.js → chunk-UNZ2UBVL.js} +1 -1
  166. package/dist/standalone/{chunk-SJLEEYCR.js → chunk-VJRNOSRY.js} +1 -1
  167. package/dist/standalone/{chunk-HKPDPKXD.js → chunk-WM72PRE3.js} +1 -1
  168. package/dist/standalone/{chunk-HSLO46OW.js → chunk-X4WHMCOZ.js} +1 -1
  169. package/dist/standalone/{chunk-PCMV6S7K.js → chunk-XIRKBJPD.js} +1 -1
  170. package/dist/standalone/{chunk-WCWSMX3N.js → chunk-XKPD4SFN.js} +1 -1
  171. package/dist/standalone/chunk-XMSNLMWU.js +1 -0
  172. package/dist/standalone/{chunk-JYCRY3LM.js → chunk-XOPFDWXX.js} +1 -1
  173. package/dist/standalone/{chunk-V6SVNLUM.js → chunk-XQLOVFPP.js} +1 -1
  174. package/dist/standalone/{chunk-HONLEKH5.js → chunk-XSHYZPGF.js} +1 -1
  175. package/dist/standalone/{chunk-KYONGQQ4.js → chunk-XST3UEHU.js} +1 -1
  176. package/dist/standalone/{chunk-AOHKAKKL.js → chunk-Y74LIFSL.js} +1 -1
  177. package/dist/standalone/{chunk-CTE6RPXC.js → chunk-YMEKCV27.js} +1 -1
  178. package/dist/standalone/{chunk-CZACJYDC.js → chunk-ZOQTXWPK.js} +1 -1
  179. package/dist/standalone/{chunk-FMQ72AKG.js → chunk-ZZ5GICTF.js} +1 -1
  180. package/dist/standalone/studio.js +1 -1
  181. package/package.json +6 -6
  182. package/dist/packem_shared/internal-BXEjuLPN.mjs +0 -2
  183. package/dist/standalone/chunk-3Y5K3IQO.js +0 -1
  184. package/dist/standalone/chunk-GMO7IUXO.js +0 -1
  185. package/dist/standalone/chunk-LPINY2IJ.js +0 -19
  186. package/dist/standalone/chunk-LVNPLZDL.js +0 -1
  187. package/dist/standalone/chunk-PTCC45P7.js +0 -1
  188. package/dist/standalone/chunk-PZZWUL5U.js +0 -1
  189. package/dist/standalone/chunk-SDSQIQJG.js +0 -21
  190. package/dist/standalone/chunk-W37HRJGQ.js +0 -1
  191. package/dist/standalone/chunk-XBZUJDHD.js +0 -1
@@ -1 +1 @@
1
- import{a as dt}from"./chunk-MHJNM7VT.js";import"./chunk-7RGYCU6F.js";import"./chunk-F4VO76XV.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as De}from"./chunk-OUFWXYEF.js";import{a as st}from"./chunk-XBZUJDHD.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{a as at}from"./chunk-5DNGK3NT.js";import{a as ot}from"./chunk-ZWDORIZY.js";import{a as tt}from"./chunk-KYONGQQ4.js";import{b as et}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{h as Be,i as We}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import{i as ze}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as He}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ue}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Te}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as F}from"./chunk-6UTZXEW3.js";import{c as ce}from"./chunk-W37HRJGQ.js";import{p as Ye}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as Oe}from"./chunk-3Y5K3IQO.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-CW57Q264.js";import{a as Qe,e as Ve}from"./chunk-MD67S53Z.js";import{b as de,f as le,h as Ge,i as Ze,j as Xe,s as je,w as qe}from"./chunk-LPINY2IJ.js";import{a as s,d as se,e as Je,f as Ae,g as Pe}from"./chunk-OXFKZ4BM.js";var be=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1),S=se(Je(),1);var m=se(Pe(),1);var qt=Ge(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Ye(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ye,ve;e[5]!==o||e[6]!==$.data?(ye=s(()=>{$.data!==void 0&&et(o)},"W"),ve=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ye,e[8]=ve):(ye=e[7],ve=e[8]),(0,S.useEffect)(ye,ve);let xe;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ze(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Xe(jt))}x(!1)},"u");xe=s(()=>{je(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Nt=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let Ot=Ne,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Oe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Qe,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ve,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let Z;e[57]!==G?(Z=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=Z):Z=e[58];let X;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==Z?(X=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,Z]}),e[59]=h,e[60]=H,e[61]=V,e[62]=Z,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Y||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,ee]}),e[68]=Y,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(He,{"data-testid":"mg-run",disabled:y||!C,onClick:ke,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==X||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,X,te,ae]}),e[77]=z,e[78]=X,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Se;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Se=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Se):Se=e[97],Se},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(Ue,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:qe(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" 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:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),ge=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"q"),ut=s(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"F"),pe=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"T"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"Z"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>ge(ue(d))===ge(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(o.kind===n.kind&&(!a||ge(o)===ge(n)))return;if(a&&Rt(o,n))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`);if(o.kind!==n.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`);let d=Object.values(n.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&d.length>0&&d.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"N"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Ce="global",Pt=s((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"je"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&&gt(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"Fe"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 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:r}},"Te"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"X"),Vt={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"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Zt=s(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=qe(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Xt=s(t=>{let e=(0,be.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},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"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Yt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,be.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=We(),a=Be({strict:!1}).version,o=s(u=>{je(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(Te,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Oe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Xt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Yt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-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"),Ra=s(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Ze");export{Ra as default};
1
+ import{a as dt}from"./chunk-TQM6XHBA.js";import"./chunk-7RGYCU6F.js";import"./chunk-KZILJQX3.js";import"./chunk-SYGCASPT.js";import"./chunk-YMEKCV27.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as De}from"./chunk-KZCEJFZF.js";import{a as st}from"./chunk-KYAG2YMF.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{a as at}from"./chunk-5DNGK3NT.js";import{a as ot}from"./chunk-FXPAJDES.js";import{a as tt}from"./chunk-XST3UEHU.js";import{b as et}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{h as Be,i as We}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import{i as ze}from"./chunk-SU5DTRGK.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as He}from"./chunk-6VAY6L4J.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as Ue}from"./chunk-PQH2LSJX.js";import"./chunk-4C4THJUD.js";import{a as Te}from"./chunk-CZ6HBDIL.js";import"./chunk-T5UMHPAB.js";import"./chunk-NVKLYDOH.js";import"./chunk-E26OT26O.js";import{a as F}from"./chunk-6UTZXEW3.js";import{c as ce}from"./chunk-4DAKKAK7.js";import{m as Ye}from"./chunk-BVX45MU5.js";import"./chunk-H7HZ42JY.js";import{a as Oe}from"./chunk-XMSNLMWU.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-HHRYM6UW.js";import{a as Qe,e as Ve}from"./chunk-JSDKOE4U.js";import{C as qe,h as de,l as le,n as Ge,o as Ze,p as Xe,y as je}from"./chunk-BFE2DRP6.js";import{a as s,d as se,e as Je,f as Ae,g as Pe}from"./chunk-OXFKZ4BM.js";var be=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1),S=se(Je(),1);var m=se(Pe(),1);var qt=Ge(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Ye(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ye,ve;e[5]!==o||e[6]!==$.data?(ye=s(()=>{$.data!==void 0&&et(o)},"W"),ve=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ye,e[8]=ve):(ye=e[7],ve=e[8]),(0,S.useEffect)(ye,ve);let xe;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ze(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Xe(jt))}x(!1)},"u");xe=s(()=>{je(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Nt=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=s(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let Ot=Ne,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Oe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Qe,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ve,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let Z;e[57]!==G?(Z=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=Z):Z=e[58];let X;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==Z?(X=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,Z]}),e[59]=h,e[60]=H,e[61]=V,e[62]=Z,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Y||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,ee]}),e[68]=Y,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(He,{"data-testid":"mg-run",disabled:y||!C,onClick:ke,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==X||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,X,te,ae]}),e[77]=z,e[78]=X,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Se;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Se=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Se):Se=e[97],Se},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(Ue,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:qe(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" 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:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),ge=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"q"),ut=s(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"F"),pe=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"T"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"Z"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>ge(ue(d))===ge(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(o.kind===n.kind&&(!a||ge(o)===ge(n)))return;if(a&&Rt(o,n))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`);if(o.kind!==n.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`);let d=Object.values(n.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&d.length>0&&d.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"N"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Ce="global",Pt=s((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"je"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&&gt(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"Fe"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 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:r}},"Te"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"X"),Vt={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"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Zt=s(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=qe(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Xt=s(t=>{let e=(0,be.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},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"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Yt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,be.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=We(),a=Be({strict:!1}).version,o=s(u=>{je(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(Te,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Oe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Xt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Yt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-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"),Ra=s(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Ze");export{Ra as default};
@@ -1 +1 @@
1
- import{i as R}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as B}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as S}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as q}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as U}from"./chunk-6UTZXEW3.js";import{c as O}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as D}from"./chunk-3Y5K3IQO.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-CW57Q264.js";import{a as V,e as W}from"./chunk-MD67S53Z.js";import{f as P,w as H}from"./chunk-LPINY2IJ.js";import{a as n,d as j,e as re,f as ae,g as ie}from"./chunk-OXFKZ4BM.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=P(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=O(U.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(R,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(V,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};
1
+ import{i as R}from"./chunk-SU5DTRGK.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as B}from"./chunk-6VAY6L4J.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as S}from"./chunk-PQH2LSJX.js";import"./chunk-4C4THJUD.js";import{a as q}from"./chunk-CZ6HBDIL.js";import"./chunk-T5UMHPAB.js";import"./chunk-NVKLYDOH.js";import"./chunk-E26OT26O.js";import{a as U}from"./chunk-6UTZXEW3.js";import{c as O}from"./chunk-4DAKKAK7.js";import"./chunk-BVX45MU5.js";import"./chunk-H7HZ42JY.js";import{a as D}from"./chunk-XMSNLMWU.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-HHRYM6UW.js";import{a as V,e as W}from"./chunk-JSDKOE4U.js";import{C as H,l as P}from"./chunk-BFE2DRP6.js";import{a as n,d as j,e as re,f as ae,g as ie}from"./chunk-OXFKZ4BM.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=P(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=O(U.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(R,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(V,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};
@@ -1 +1 @@
1
- import{a as Se}from"./chunk-P6L6ABWO.js";import{a as _}from"./chunk-OUFWXYEF.js";import{a as Ie}from"./chunk-XBZUJDHD.js";import{a as Ce}from"./chunk-ZWDORIZY.js";import{a as ve}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as V}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as z}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as E}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Ne}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as X}from"./chunk-6UTZXEW3.js";import{c as re}from"./chunk-W37HRJGQ.js";import{g as pe,p as ce}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as de}from"./chunk-3Y5K3IQO.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-CW57Q264.js";import{a as se,b as ue,c as fe,d as he,e as ne}from"./chunk-MD67S53Z.js";import{f as K,h as xe,i as ge,j as ye,p as be,s as ae}from"./chunk-LPINY2IJ.js";import{a as f,d as oe,e as Fe,f as Te,g as Ee}from"./chunk-OXFKZ4BM.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(de,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=xe(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=ce();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},ge(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,be,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=ce(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(ye(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(de,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 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({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(fe,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(he,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ue,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(ne,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(se,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(ne,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
1
+ import{a as Se}from"./chunk-CNA3TVUK.js";import{a as _}from"./chunk-KZCEJFZF.js";import{a as Ie}from"./chunk-KYAG2YMF.js";import{a as Ce}from"./chunk-FXPAJDES.js";import{a as ve}from"./chunk-XST3UEHU.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as V}from"./chunk-SU5DTRGK.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as z}from"./chunk-6VAY6L4J.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as E}from"./chunk-PQH2LSJX.js";import"./chunk-4C4THJUD.js";import{a as Ne}from"./chunk-CZ6HBDIL.js";import"./chunk-T5UMHPAB.js";import"./chunk-NVKLYDOH.js";import"./chunk-E26OT26O.js";import{a as X}from"./chunk-6UTZXEW3.js";import{c as re}from"./chunk-4DAKKAK7.js";import{d as pe,m as ce}from"./chunk-BVX45MU5.js";import"./chunk-H7HZ42JY.js";import{a as de}from"./chunk-XMSNLMWU.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-HHRYM6UW.js";import{a as se,b as ue,c as fe,d as he,e as ne}from"./chunk-JSDKOE4U.js";import{l as K,n as xe,o as ge,p as ye,v as be,y as ae}from"./chunk-BFE2DRP6.js";import{a as f,d as oe,e as Fe,f as Te,g as Ee}from"./chunk-OXFKZ4BM.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(de,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=xe(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=ce();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},ge(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,be,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=ce(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(ye(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(de,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 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({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(fe,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(he,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ue,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(ne,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(se,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(ne,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
@@ -1 +1 @@
1
- import{a as le,d as ae,e as ke,i as Ne,j as we,l as Se}from"./chunk-F4VO76XV.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as ye}from"./chunk-SJLEEYCR.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import{a as ne}from"./chunk-HKLF627N.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{i as ue}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as oe}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{p as ge}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as re}from"./chunk-3Y5K3IQO.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-CW57Q264.js";import{a as fe,e as he}from"./chunk-MD67S53Z.js";import{b as me,f as Y,s as pe}from"./chunk-LPINY2IJ.js";import{a as c,d as te,e as Ae,f as qe,g as je}from"./chunk-OXFKZ4BM.js";var z=te(qe(),1);var E=te(Ae(),1);var o=te(je(),1);var Le=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let a of r.nodes)(e===void 0||H(a)===e)&&t.add(a.id);if(e===void 0)return t;let l=new Set(t);for(let a of r.edges)d.has(a.kind)&&(t.has(a.from)&&l.add(a.to),t.has(a.to)&&l.add(a.from));return l},"Pe"),Ee=c((r,e,d,t)=>{let l=`lane:${r}`;return[{data:{label:e},id:l,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((a,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${a.detail??a.kind} \xB7 ${a.name}`,link:Pe(a)},extent:"parent",id:a.id,parentId:l,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let n of r.nodes)d.has(n.id)&&t.set(H(n),[...t.get(H(n))??[],n]);let l=[...r.modules.map(n=>({label:n.installed===!0?`${n.name} \xB7 ${e.componentLabel}`:n.name,lane:n.name})),{label:e.appLaneLabel,lane:Q}],a=[],i=0;for(let{label:n,lane:f}of l){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(a.push(...Ee(f,n,i,m)),i+=1)}let u=[];for(let n of r.edges)e.kinds.has(n.kind)&&d.has(n.from)&&d.has(n.to)&&u.push({animated:Me.has(n.kind),id:`${n.from}|${n.kind}|${n.to}`,label:n.kind,labelBgStyle:Fe,labelStyle:De,source:n.from,style:Be,target:n.to,type:"smoothstep"});return{edges:u,nodes:a}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),l;return e[0]!==t?(l=(0,o.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1],l},"qe"),Ie={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=ue(),{label:l,link:a}=d,i;e[0]!==a||e[1]!==t?(i=c(()=>{pe(t(a))},"u"),e[0]=a,e[1]=t,e[2]=i):i=e[2];let u=i,n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(ae,{isConnectable:!1,position:le.Left,style:Ie,type:"target"}),e[3]=n):n=e[3];let f;e[4]!==l||e[5]!==u?(f=(0,o.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:l}),e[4]=l,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)(ae,{isConnectable:!1,position:le.Right,style:Ie,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,o.jsxs)(o.Fragment,{children:[n,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),l,a,i,u,n,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");n=j(Q),u=fe,p="overflow-hidden py-0",i=he,s="px-0",a=be,m="architecture-catalog";let I;e[13]!==t?(I=t("Module"),e[13]=t,e[14]=I):I=e[14];let L;e[15]!==I?(L=(0,o.jsx)(T,{children:I}),e[15]=I,e[16]=L):L=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,o.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,o.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,o.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==L||e[32]!==q?(h=(0,o.jsx)(xe,{children:(0,o.jsxs)(J,{children:[L,q,y,N]})}),e[29]=y,e[30]=N,e[31]=L,e[32]=q,e[33]=h):h=e[33],l=ve,f=d.modules.map(g=>(0,o.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,o.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,o.jsx)(oe,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,o.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,o.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=l,e[4]=a,e[5]=i,e[6]=u,e[7]=n,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else l=e[3],a=e[4],i=e[5],u=e[6],n=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==n||e[35]!==t?(b=n>0&&(0,o.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,o.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs",children:n})]}),e[34]=n,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==l||e[38]!==f||e[39]!==b?(x=(0,o.jsxs)(l,{children:[f,b]}),e[37]=l,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==a||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,o.jsxs)(a,{"data-testid":m,children:[h,x]}),e[41]=a,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,o.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,o.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[l,a]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),n;e[0]!==d.edges?(n=c(w=>d.edges.some(X=>X.kind===w),"s"),e[0]=d.edges,e[1]=n):n=e[1];let f=Le.filter(n),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==l||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...l===ce?{}:{lane:l}}),e[6]=h,e[7]=p,e[8]=i,e[9]=l,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{a(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let I=j,L="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,o.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,o.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==l||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,o.jsxs)("select",{"aria-label":v,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":"architecture-module-filter",onChange:P,value:l,children:[k,N,M]}),e[26]=l,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,o.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,o.jsx)("button",{"aria-pressed":i.has(w),className:me("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{I(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,o.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,o.jsx)(Ne,{}),G=(0,o.jsx)(we,{showInteractive:!1}),K=(0,o.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,o.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,o.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,o.jsxs)("section",{className:L,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),l=ge(),a;e[0]!==l?(a=c(()=>l.fetchArchitecture(),"r"),e[0]=l,e[1]=a):a=e[1];let i=ye(d,a,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,o.jsx)(ne,{className:"h-8 w-48"}),(0,o.jsx)(ne,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,n,f;e[18]!==u?(n=(0,o.jsx)(We,{manifest:u}),f=(0,o.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=n,e[20]=f):(n=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,o.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,o.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,o.jsx)(oe,{variant:"outline",children:u.unresolved.length})]}),(0,o.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==n||e[25]!==f||e[26]!==m?(h=(0,o.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[n,f,m]}),e[24]=n,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Le)}c(Je,"We");function Qe(r){return(0,o.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,o.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
1
+ import{a as le,d as ae,e as ke,i as Ne,j as we,l as Se}from"./chunk-KZILJQX3.js";import"./chunk-SYGCASPT.js";import"./chunk-YMEKCV27.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import{a as ye}from"./chunk-VJRNOSRY.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import{a as ne}from"./chunk-7PADVGQX.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{i as ue}from"./chunk-LUHXNZI4.js";import"./chunk-ZTOREMGH.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as oe}from"./chunk-PQH2LSJX.js";import"./chunk-4C4THJUD.js";import{m as ge}from"./chunk-BVX45MU5.js";import"./chunk-H7HZ42JY.js";import{a as re}from"./chunk-XMSNLMWU.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-HHRYM6UW.js";import{a as fe,e as he}from"./chunk-JSDKOE4U.js";import{h as me,l as Y,y as pe}from"./chunk-BFE2DRP6.js";import{a as c,d as te,e as Ae,f as qe,g as je}from"./chunk-OXFKZ4BM.js";var z=te(qe(),1);var E=te(Ae(),1);var o=te(je(),1);var Le=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let a of r.nodes)(e===void 0||H(a)===e)&&t.add(a.id);if(e===void 0)return t;let l=new Set(t);for(let a of r.edges)d.has(a.kind)&&(t.has(a.from)&&l.add(a.to),t.has(a.to)&&l.add(a.from));return l},"Pe"),Ee=c((r,e,d,t)=>{let l=`lane:${r}`;return[{data:{label:e},id:l,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((a,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${a.detail??a.kind} \xB7 ${a.name}`,link:Pe(a)},extent:"parent",id:a.id,parentId:l,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let n of r.nodes)d.has(n.id)&&t.set(H(n),[...t.get(H(n))??[],n]);let l=[...r.modules.map(n=>({label:n.installed===!0?`${n.name} \xB7 ${e.componentLabel}`:n.name,lane:n.name})),{label:e.appLaneLabel,lane:Q}],a=[],i=0;for(let{label:n,lane:f}of l){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(a.push(...Ee(f,n,i,m)),i+=1)}let u=[];for(let n of r.edges)e.kinds.has(n.kind)&&d.has(n.from)&&d.has(n.to)&&u.push({animated:Me.has(n.kind),id:`${n.from}|${n.kind}|${n.to}`,label:n.kind,labelBgStyle:Fe,labelStyle:De,source:n.from,style:Be,target:n.to,type:"smoothstep"});return{edges:u,nodes:a}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),l;return e[0]!==t?(l=(0,o.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1],l},"qe"),Ie={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=ue(),{label:l,link:a}=d,i;e[0]!==a||e[1]!==t?(i=c(()=>{pe(t(a))},"u"),e[0]=a,e[1]=t,e[2]=i):i=e[2];let u=i,n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(ae,{isConnectable:!1,position:le.Left,style:Ie,type:"target"}),e[3]=n):n=e[3];let f;e[4]!==l||e[5]!==u?(f=(0,o.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:l}),e[4]=l,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)(ae,{isConnectable:!1,position:le.Right,style:Ie,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,o.jsxs)(o.Fragment,{children:[n,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),l,a,i,u,n,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");n=j(Q),u=fe,p="overflow-hidden py-0",i=he,s="px-0",a=be,m="architecture-catalog";let I;e[13]!==t?(I=t("Module"),e[13]=t,e[14]=I):I=e[14];let L;e[15]!==I?(L=(0,o.jsx)(T,{children:I}),e[15]=I,e[16]=L):L=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,o.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,o.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,o.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==L||e[32]!==q?(h=(0,o.jsx)(xe,{children:(0,o.jsxs)(J,{children:[L,q,y,N]})}),e[29]=y,e[30]=N,e[31]=L,e[32]=q,e[33]=h):h=e[33],l=ve,f=d.modules.map(g=>(0,o.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,o.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,o.jsx)(oe,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,o.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,o.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=l,e[4]=a,e[5]=i,e[6]=u,e[7]=n,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else l=e[3],a=e[4],i=e[5],u=e[6],n=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==n||e[35]!==t?(b=n>0&&(0,o.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,o.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs",children:n})]}),e[34]=n,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==l||e[38]!==f||e[39]!==b?(x=(0,o.jsxs)(l,{children:[f,b]}),e[37]=l,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==a||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,o.jsxs)(a,{"data-testid":m,children:[h,x]}),e[41]=a,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,o.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,o.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[l,a]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),n;e[0]!==d.edges?(n=c(w=>d.edges.some(X=>X.kind===w),"s"),e[0]=d.edges,e[1]=n):n=e[1];let f=Le.filter(n),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==l||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...l===ce?{}:{lane:l}}),e[6]=h,e[7]=p,e[8]=i,e[9]=l,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{a(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let I=j,L="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,o.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,o.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==l||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,o.jsxs)("select",{"aria-label":v,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":"architecture-module-filter",onChange:P,value:l,children:[k,N,M]}),e[26]=l,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,o.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,o.jsx)("button",{"aria-pressed":i.has(w),className:me("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{I(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,o.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,o.jsx)(Ne,{}),G=(0,o.jsx)(we,{showInteractive:!1}),K=(0,o.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,o.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,o.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,o.jsxs)("section",{className:L,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),l=ge(),a;e[0]!==l?(a=c(()=>l.fetchArchitecture(),"r"),e[0]=l,e[1]=a):a=e[1];let i=ye(d,a,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,o.jsx)(ne,{className:"h-8 w-48"}),(0,o.jsx)(ne,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,n,f;e[18]!==u?(n=(0,o.jsx)(We,{manifest:u}),f=(0,o.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=n,e[20]=f):(n=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,o.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,o.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,o.jsx)(oe,{variant:"outline",children:u.unresolved.length})]}),(0,o.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==n||e[25]!==f||e[26]!==m?(h=(0,o.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[n,f,m]}),e[24]=n,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Le)}c(Je,"We");function Qe(r){return(0,o.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,o.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
@@ -1 +1 @@
1
- import{c as l}from"./chunk-JTGGWF7R.js";import{j as u}from"./chunk-4C4THJUD.js";import{a as c}from"./chunk-WZTY3ZYI.js";import{b as d}from"./chunk-LPINY2IJ.js";import{a as t,d as o,e as h,g as z}from"./chunk-OXFKZ4BM.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=l({disabled:s,focusableWhenDisabled:g,native:f});return u("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=c("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"v");export{W as a};
1
+ import{c as l}from"./chunk-JTGGWF7R.js";import{j as u}from"./chunk-4C4THJUD.js";import{a as c}from"./chunk-H7HZ42JY.js";import{h as d}from"./chunk-BFE2DRP6.js";import{a as t,d as o,e as h,g as z}from"./chunk-OXFKZ4BM.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=l({disabled:s,focusableWhenDisabled:g,native:f});return u("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=c("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"v");export{W as a};
@@ -1 +1 @@
1
- import{b as i}from"./chunk-LPINY2IJ.js";import{a as l,d as m,f as d,g as p}from"./chunk-OXFKZ4BM.js";var n=m(d(),1);var c=m(p(),1);function f(r){let t=(0,n.c)(8),e,s;t[0]!==r?({className:e,...s}=r,t[0]=r,t[1]=e,t[2]=s):(e=t[1],s=t[2]);let a;t[3]!==e?(a=i("animate-pulse rounded-md bg-muted",e),t[3]=e,t[4]=a):a=t[4];let o;return t[5]!==s||t[6]!==a?(o=(0,c.jsx)("div",{"data-slot":"skeleton",className:a,...s}),t[5]=s,t[6]=a,t[7]=o):o=t[7],o}l(f,"p");export{f as a};
1
+ import{h as i}from"./chunk-BFE2DRP6.js";import{a as l,d as m,f as d,g as p}from"./chunk-OXFKZ4BM.js";var n=m(d(),1);var c=m(p(),1);function f(r){let t=(0,n.c)(8),e,s;t[0]!==r?({className:e,...s}=r,t[0]=r,t[1]=e,t[2]=s):(e=t[1],s=t[2]);let a;t[3]!==e?(a=i("animate-pulse rounded-md bg-muted",e),t[3]=e,t[4]=a):a=t[4];let o;return t[5]!==s||t[6]!==a?(o=(0,c.jsx)("div",{"data-slot":"skeleton",className:a,...s}),t[5]=s,t[6]=a,t[7]=o):o=t[7],o}l(f,"p");export{f as a};
@@ -1 +1 @@
1
- import{a as v}from"./chunk-AOHKAKKL.js";import{a as Q}from"./chunk-FACE2CFY.js";import{a as L}from"./chunk-5DNGK3NT.js";import{a as G}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-ZBON5T5A.js";import{b as $}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as W}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as E}from"./chunk-6UTZXEW3.js";import{c as B}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as A}from"./chunk-3Y5K3IQO.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-CW57Q264.js";import{a as _}from"./chunk-MD67S53Z.js";import{f as j}from"./chunk-LPINY2IJ.js";import{a as S,d as F,f as J,g as V}from"./chunk-OXFKZ4BM.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
1
+ import{a as v}from"./chunk-Y74LIFSL.js";import{a as Q}from"./chunk-473JK2PQ.js";import{a as L}from"./chunk-5DNGK3NT.js";import{a as G}from"./chunk-XST3UEHU.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-SU5DTRGK.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-ZBON5T5A.js";import{b as $}from"./chunk-PQH2LSJX.js";import"./chunk-4C4THJUD.js";import{a as W}from"./chunk-CZ6HBDIL.js";import"./chunk-T5UMHPAB.js";import"./chunk-NVKLYDOH.js";import"./chunk-E26OT26O.js";import{a as E}from"./chunk-6UTZXEW3.js";import{c as B}from"./chunk-4DAKKAK7.js";import"./chunk-BVX45MU5.js";import"./chunk-H7HZ42JY.js";import{a as A}from"./chunk-XMSNLMWU.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-HHRYM6UW.js";import{a as _}from"./chunk-JSDKOE4U.js";import{l as j}from"./chunk-BFE2DRP6.js";import{a as S,d as F,f as J,g as V}from"./chunk-OXFKZ4BM.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};