@lunora/studio 1.0.0-alpha.361 → 1.0.0-alpha.363

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 (327) hide show
  1. package/dist/index.d.mts +4 -1
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  9. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  10. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  11. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  12. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  13. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  14. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  15. package/dist/packem_chunks/MailPanel.mjs +1 -1
  16. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  17. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  18. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  19. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  20. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  21. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  22. package/dist/packem_chunks/SqlEditorPanel.mjs +24 -9
  23. package/dist/packem_chunks/TableEditor.mjs +1 -1
  24. package/dist/packem_chunks/agents-panel.mjs +1 -1
  25. package/dist/packem_chunks/ai-knowledge.mjs +1 -0
  26. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  27. package/dist/packem_chunks/assistant-panel.mjs +3 -0
  28. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  29. package/dist/packem_chunks/containers-panel.mjs +1 -1
  30. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  31. package/dist/packem_chunks/evals-panel.mjs +1 -1
  32. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  33. package/dist/packem_chunks/flags-panel.mjs +1 -1
  34. package/dist/packem_chunks/issues-panel.mjs +1 -1
  35. package/dist/packem_chunks/kv-browser.mjs +1 -1
  36. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  37. package/dist/packem_chunks/migrations-route.mjs +1 -1
  38. package/dist/packem_chunks/payments-panel.mjs +1 -1
  39. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  40. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  41. package/dist/packem_chunks/queues-panel.mjs +1 -1
  42. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  43. package/dist/packem_chunks/rls-panel.mjs +1 -1
  44. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  45. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  46. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  47. package/dist/packem_chunks/traces-panel.mjs +1 -1
  48. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  49. package/dist/packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs +1 -0
  50. package/dist/packem_shared/{ApiDocsPanel-DD2Uns6b.mjs → ApiDocsPanel-B9S9l1Ce.mjs} +1 -1
  51. package/dist/packem_shared/{DataBrowser-CVRWnNWu.mjs → DataBrowser-Dm-jhIUP.mjs} +2 -2
  52. package/dist/packem_shared/{GlobalDataBrowser-DC47T6Zl.mjs → GlobalDataBrowser-C1Y8GUhe.mjs} +1 -1
  53. package/dist/packem_shared/{HomePanel-D12HxHQo.mjs → HomePanel-B5ytwPIo.mjs} +1 -1
  54. package/dist/packem_shared/{MigrationsPanel-DMkxSXNl.mjs → MigrationsPanel-CwLikxDT.mjs} +1 -1
  55. package/dist/packem_shared/Studio-B89ZNMOD.mjs +1 -0
  56. package/dist/packem_shared/{StudioApp-isdWpF9P.mjs → StudioApp-C9l1a3A8.mjs} +1 -1
  57. package/dist/packem_shared/advisor-view-CzieqKMe.mjs +5 -0
  58. package/dist/packem_shared/assistant-provider-Bp72uWsq.mjs +1 -0
  59. package/dist/packem_shared/assistant-reason-D6EwMCxT.mjs +1 -0
  60. package/dist/packem_shared/{cf-links-CBJ5SywP.mjs → cf-links-C4DVTr8A.mjs} +1 -1
  61. package/dist/packem_shared/error-alert-DKXm5h19.mjs +6 -0
  62. package/dist/packem_shared/{home-panel-CDVTuTF8.mjs → home-panel-5fGktYeD.mjs} +1 -1
  63. package/dist/packem_shared/recording-client-z4CBi0y8.mjs +1 -0
  64. package/dist/packem_shared/studio-gZfpz1wC.mjs +2 -0
  65. package/dist/packem_shared/{table-list-sidebar-CNadcIgG.mjs → table-list-sidebar-kpHaDWjy.mjs} +1 -1
  66. package/dist/packem_shared/use-assistant-rpc-GCUK2zPa.mjs +1 -0
  67. package/dist/standalone/chunk-2DT3QG6Q.js +1 -0
  68. package/dist/standalone/chunk-2EB7FN5S.js +1 -0
  69. package/dist/standalone/chunk-2H6VLY2M.js +1 -0
  70. package/dist/standalone/chunk-2NGKUO32.js +1 -0
  71. package/dist/standalone/chunk-2SNHKJXK.js +1 -0
  72. package/dist/standalone/chunk-2W4UO5BC.js +1 -0
  73. package/dist/standalone/chunk-32V7XGNC.js +1 -0
  74. package/dist/standalone/{chunk-SLIDAWNX.js → chunk-3D67ZJRW.js} +1 -1
  75. package/dist/standalone/chunk-3X3NXJBR.js +1 -0
  76. package/dist/standalone/chunk-4EPW63HS.js +1 -0
  77. package/dist/standalone/chunk-4L55URI5.js +2 -0
  78. package/dist/standalone/chunk-4N76XUNG.js +1 -0
  79. package/dist/standalone/{chunk-WS36BO4R.js → chunk-4NKJV7YX.js} +1 -1
  80. package/dist/standalone/chunk-4PI2OSSP.js +1 -0
  81. package/dist/standalone/chunk-53XKGQEE.js +1 -0
  82. package/dist/standalone/chunk-5GYHGDIF.js +8 -0
  83. package/dist/standalone/chunk-5PEAXTYQ.js +1 -0
  84. package/dist/standalone/chunk-5QUTVSHM.js +1 -0
  85. package/dist/standalone/{chunk-BYOGQ2IV.js → chunk-5RX5CQSU.js} +2 -2
  86. package/dist/standalone/{chunk-O2NMPIV2.js → chunk-5WNGRT7N.js} +1 -1
  87. package/dist/standalone/chunk-5Z2U4KBN.js +1 -0
  88. package/dist/standalone/chunk-66BMMNUR.js +1 -0
  89. package/dist/standalone/chunk-6FPV3EK2.js +1 -0
  90. package/dist/standalone/chunk-6G3E4PJ2.js +1 -0
  91. package/dist/standalone/chunk-75TRPM7O.js +1 -0
  92. package/dist/standalone/chunk-7MLX5CGD.js +1 -0
  93. package/dist/standalone/chunk-7QEZ2SFW.js +1 -0
  94. package/dist/standalone/chunk-7TQ7BZ67.js +1 -0
  95. package/dist/standalone/chunk-A2Q3TGIQ.js +1 -0
  96. package/dist/standalone/chunk-AD5J2ANS.js +1 -0
  97. package/dist/standalone/chunk-ALR4VAUE.js +1 -0
  98. package/dist/standalone/chunk-AXE2SDRU.js +1 -0
  99. package/dist/standalone/chunk-AZIKM5BA.js +1 -0
  100. package/dist/standalone/chunk-BAEIW3YS.js +1 -0
  101. package/dist/standalone/chunk-BBDTJG2K.js +1 -0
  102. package/dist/standalone/chunk-BCUOQNI2.js +1 -0
  103. package/dist/standalone/chunk-BG2CJOVS.js +1 -0
  104. package/dist/standalone/chunk-BI6MZHZJ.js +1 -0
  105. package/dist/standalone/chunk-BKI3JMXQ.js +1 -0
  106. package/dist/standalone/chunk-CKEQX655.js +1 -0
  107. package/dist/standalone/{chunk-DX55P3KZ.js → chunk-CL3JOU6F.js} +1 -1
  108. package/dist/standalone/chunk-CP7QNLR4.js +1 -0
  109. package/dist/standalone/chunk-CVSIFPI5.js +1 -0
  110. package/dist/standalone/chunk-D57B4MFK.js +1 -0
  111. package/dist/standalone/chunk-D65UVZIA.js +1 -0
  112. package/dist/standalone/{chunk-DBVJ5VLI.js → chunk-DA2CAFXI.js} +1 -1
  113. package/dist/standalone/chunk-DB6QX4X6.js +1 -0
  114. package/dist/standalone/chunk-DZFXH55R.js +1 -0
  115. package/dist/standalone/chunk-ELSQ4FVH.js +1 -0
  116. package/dist/standalone/chunk-EPWCW2DF.js +1 -0
  117. package/dist/standalone/chunk-FHLODLBC.js +1 -0
  118. package/dist/standalone/chunk-FJLRSFTE.js +1 -0
  119. package/dist/standalone/{chunk-3FS22LNI.js → chunk-FVCBNFQW.js} +3 -3
  120. package/dist/standalone/{chunk-VEWQWS3J.js → chunk-FWM5Z6CH.js} +1 -1
  121. package/dist/standalone/chunk-GJXCPZDN.js +1 -0
  122. package/dist/standalone/chunk-GNI37YCV.js +33 -0
  123. package/dist/standalone/chunk-GVQPNM3T.js +3 -0
  124. package/dist/standalone/chunk-GWNGVKLG.js +1 -0
  125. package/dist/standalone/chunk-GXTSE66Z.js +1 -0
  126. package/dist/standalone/chunk-H3EIPYRZ.js +1 -0
  127. package/dist/standalone/chunk-H5TMLWIS.js +1 -0
  128. package/dist/standalone/{chunk-XIRKBJPD.js → chunk-HBG6SSE2.js} +5 -5
  129. package/dist/standalone/chunk-HC2B7SXW.js +1 -0
  130. package/dist/standalone/chunk-HCOF7HOM.js +1 -0
  131. package/dist/standalone/chunk-HGCOTYPV.js +1 -0
  132. package/dist/standalone/chunk-HLHMHCXS.js +1 -0
  133. package/dist/standalone/chunk-HSF2DCJ2.js +30 -0
  134. package/dist/standalone/chunk-HZDLUAWS.js +1 -0
  135. package/dist/standalone/{chunk-3PAYDWHN.js → chunk-I3SSF2T6.js} +2 -2
  136. package/dist/standalone/chunk-I5QX75DE.js +1 -0
  137. package/dist/standalone/chunk-ICHZ2IBL.js +1 -0
  138. package/dist/standalone/{chunk-7ZIYHKLX.js → chunk-IG5VD7R7.js} +3 -3
  139. package/dist/standalone/{chunk-SU5DTRGK.js → chunk-IHGRWY3Y.js} +1 -1
  140. package/dist/standalone/chunk-J45HAKBU.js +1 -0
  141. package/dist/standalone/chunk-J4PQAVOF.js +1 -0
  142. package/dist/standalone/chunk-JD6PRRFO.js +1 -0
  143. package/dist/standalone/chunk-JOPNP4EO.js +1 -0
  144. package/dist/standalone/chunk-JVP3TR3A.js +1 -0
  145. package/dist/standalone/chunk-KGLIQIZU.js +1 -0
  146. package/dist/standalone/{chunk-ONWGX5Y4.js → chunk-KH6OXCG3.js} +1 -1
  147. package/dist/standalone/chunk-KKMQUBYH.js +1 -0
  148. package/dist/standalone/chunk-L2FYX4FN.js +1 -0
  149. package/dist/standalone/chunk-LDHJRHPZ.js +1 -0
  150. package/dist/standalone/chunk-LSEUUZN4.js +1 -0
  151. package/dist/standalone/chunk-MNYDT3RH.js +1 -0
  152. package/dist/standalone/chunk-MT4ICMXJ.js +1 -0
  153. package/dist/standalone/chunk-MXJTD2OX.js +1 -0
  154. package/dist/standalone/chunk-NGZNXNRD.js +1 -0
  155. package/dist/standalone/chunk-O3AZ7JKE.js +1 -0
  156. package/dist/standalone/chunk-OK2QU2EV.js +1 -0
  157. package/dist/standalone/{chunk-IH2CJZF2.js → chunk-ONTGYVAN.js} +1 -1
  158. package/dist/standalone/chunk-OWRKSQPE.js +1 -0
  159. package/dist/standalone/chunk-OZAOWE7T.js +1 -0
  160. package/dist/standalone/chunk-P5EVJEGC.js +1 -0
  161. package/dist/standalone/chunk-PDBW6GTJ.js +1 -0
  162. package/dist/standalone/chunk-PJUVJTDR.js +1 -0
  163. package/dist/standalone/chunk-Q3IA6HPX.js +1 -0
  164. package/dist/standalone/chunk-QAOZXPLU.js +1 -0
  165. package/dist/standalone/chunk-QKUVJIRX.js +1 -0
  166. package/dist/standalone/chunk-QNM2J7MG.js +1 -0
  167. package/dist/standalone/chunk-QRA7AKYO.js +1 -0
  168. package/dist/standalone/chunk-RBIVXSXT.js +1 -0
  169. package/dist/standalone/chunk-RCXNYW7P.js +1 -0
  170. package/dist/standalone/{chunk-TDVDZ7XQ.js → chunk-RIAOZECW.js} +1 -1
  171. package/dist/standalone/{chunk-LUHXNZI4.js → chunk-RTS5G3ET.js} +1 -1
  172. package/dist/standalone/chunk-S36FVTKK.js +1 -0
  173. package/dist/standalone/chunk-SDDEOSQB.js +1 -0
  174. package/dist/standalone/chunk-SHHGIT7M.js +7 -0
  175. package/dist/standalone/chunk-SR6CPTRT.js +1 -0
  176. package/dist/standalone/chunk-SVQWZPO4.js +1 -0
  177. package/dist/standalone/chunk-T3ZCW3RG.js +1 -0
  178. package/dist/standalone/chunk-TEMI7MVE.js +1 -0
  179. package/dist/standalone/chunk-TKBTZX4K.js +1 -0
  180. package/dist/standalone/chunk-TW4O2BA5.js +159 -0
  181. package/dist/standalone/chunk-U5MPNEM2.js +1 -0
  182. package/dist/standalone/chunk-UD5REVU2.js +1 -0
  183. package/dist/standalone/chunk-ULQNADMJ.js +1 -0
  184. package/dist/standalone/chunk-UPPNZ6MI.js +1 -0
  185. package/dist/standalone/{chunk-PQH2LSJX.js → chunk-UQA2AJGI.js} +1 -1
  186. package/dist/standalone/chunk-UTQLJKHH.js +1 -0
  187. package/dist/standalone/chunk-UVG3ZISC.js +1 -0
  188. package/dist/standalone/chunk-UXBNXITB.js +1 -0
  189. package/dist/standalone/chunk-UZ2ZXB74.js +1 -0
  190. package/dist/standalone/chunk-V3BE427M.js +1 -0
  191. package/dist/standalone/chunk-VQDTA4P6.js +1 -0
  192. package/dist/standalone/chunk-W4LJQYCI.js +1 -0
  193. package/dist/standalone/chunk-WLHQ4FKC.js +1 -0
  194. package/dist/standalone/chunk-XPFVUAPX.js +1 -0
  195. package/dist/standalone/{chunk-SYGCASPT.js → chunk-Y2YLTUMD.js} +1 -1
  196. package/dist/standalone/chunk-Y3IGTWUE.js +1 -0
  197. package/dist/standalone/chunk-Y64STA6O.js +1 -0
  198. package/dist/standalone/chunk-YEVTA35E.js +1 -0
  199. package/dist/standalone/chunk-YEXTJUKQ.js +6 -0
  200. package/dist/standalone/chunk-YFTPHGS2.js +1 -0
  201. package/dist/standalone/{chunk-R36QXQZX.js → chunk-YORPLSI5.js} +1 -1
  202. package/dist/standalone/chunk-Z64BZNPS.js +1 -0
  203. package/dist/standalone/chunk-Z6VILGGP.js +5 -0
  204. package/dist/standalone/chunk-ZBOB33BA.js +1 -0
  205. package/dist/standalone/{chunk-5R2YO7HF.js → chunk-ZOKSVUID.js} +4 -4
  206. package/dist/standalone/{chunk-H7HZ42JY.js → chunk-ZPQBVYNN.js} +1 -1
  207. package/dist/standalone/chunk-ZSWW2UGP.js +1 -0
  208. package/dist/standalone/studio.js +2 -2
  209. package/dist/styles.css +1 -1
  210. package/package.json +7 -6
  211. package/dist/packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs +0 -1
  212. package/dist/packem_shared/Studio-MA8kKZLu.mjs +0 -1
  213. package/dist/packem_shared/advisor-view-tBumWci_.mjs +0 -1
  214. package/dist/packem_shared/error-alert-C0R39DO1.mjs +0 -1
  215. package/dist/packem_shared/recording-client-DAipTA_n.mjs +0 -1
  216. package/dist/packem_shared/studio-UhUrPz5J.mjs +0 -2
  217. package/dist/packem_shared/use-sql-assistant-rZPs3LC3.mjs +0 -1
  218. package/dist/standalone/chunk-2AH4ABE5.js +0 -1
  219. package/dist/standalone/chunk-2G57ENH5.js +0 -1
  220. package/dist/standalone/chunk-3GXPALXG.js +0 -1
  221. package/dist/standalone/chunk-3GYLOE4V.js +0 -1
  222. package/dist/standalone/chunk-473JK2PQ.js +0 -1
  223. package/dist/standalone/chunk-4C4THJUD.js +0 -1
  224. package/dist/standalone/chunk-4DAKKAK7.js +0 -1
  225. package/dist/standalone/chunk-4M57OYFX.js +0 -1
  226. package/dist/standalone/chunk-4SQBAPY6.js +0 -1
  227. package/dist/standalone/chunk-5DNGK3NT.js +0 -1
  228. package/dist/standalone/chunk-5GIQ6C5N.js +0 -1
  229. package/dist/standalone/chunk-5WJG7FMH.js +0 -1
  230. package/dist/standalone/chunk-63KDHS3H.js +0 -1
  231. package/dist/standalone/chunk-6B6ARRMI.js +0 -1
  232. package/dist/standalone/chunk-6LMO2D54.js +0 -1
  233. package/dist/standalone/chunk-6M7FLLMT.js +0 -1
  234. package/dist/standalone/chunk-6QEXGYWH.js +0 -1
  235. package/dist/standalone/chunk-6UTZXEW3.js +0 -1
  236. package/dist/standalone/chunk-6VAY6L4J.js +0 -1
  237. package/dist/standalone/chunk-7PADVGQX.js +0 -1
  238. package/dist/standalone/chunk-7RGYCU6F.js +0 -1
  239. package/dist/standalone/chunk-7UM5ROG6.js +0 -1
  240. package/dist/standalone/chunk-A566HCBX.js +0 -1
  241. package/dist/standalone/chunk-A5JISKHE.js +0 -1
  242. package/dist/standalone/chunk-ADNRFCMZ.js +0 -1
  243. package/dist/standalone/chunk-AP4PC2M4.js +0 -1
  244. package/dist/standalone/chunk-BFE2DRP6.js +0 -33
  245. package/dist/standalone/chunk-BPEB4KFE.js +0 -1
  246. package/dist/standalone/chunk-BVX45MU5.js +0 -7
  247. package/dist/standalone/chunk-C6GN7ZXJ.js +0 -1
  248. package/dist/standalone/chunk-CL2VZNDI.js +0 -1
  249. package/dist/standalone/chunk-CNA3TVUK.js +0 -1
  250. package/dist/standalone/chunk-CZ6HBDIL.js +0 -1
  251. package/dist/standalone/chunk-D6S7MXW4.js +0 -1
  252. package/dist/standalone/chunk-E26OT26O.js +0 -1
  253. package/dist/standalone/chunk-FCAXVYAX.js +0 -1
  254. package/dist/standalone/chunk-FXPAJDES.js +0 -1
  255. package/dist/standalone/chunk-HHRYM6UW.js +0 -1
  256. package/dist/standalone/chunk-HPRF5LMA.js +0 -1
  257. package/dist/standalone/chunk-IB22LETR.js +0 -1
  258. package/dist/standalone/chunk-IBJVVHV5.js +0 -1
  259. package/dist/standalone/chunk-IENQRRQT.js +0 -1
  260. package/dist/standalone/chunk-IQ4TTHQT.js +0 -1
  261. package/dist/standalone/chunk-ITH5LRWM.js +0 -1
  262. package/dist/standalone/chunk-J6VFG6M5.js +0 -1
  263. package/dist/standalone/chunk-JSDKOE4U.js +0 -1
  264. package/dist/standalone/chunk-JTGGWF7R.js +0 -1
  265. package/dist/standalone/chunk-JZD7ZN3F.js +0 -1
  266. package/dist/standalone/chunk-K3CWB3AM.js +0 -1
  267. package/dist/standalone/chunk-KNFB3FGW.js +0 -1
  268. package/dist/standalone/chunk-KNXWDE4N.js +0 -1
  269. package/dist/standalone/chunk-KRPXOSBL.js +0 -1
  270. package/dist/standalone/chunk-KRY7BYHT.js +0 -1
  271. package/dist/standalone/chunk-KYAG2YMF.js +0 -1
  272. package/dist/standalone/chunk-KZCEJFZF.js +0 -1
  273. package/dist/standalone/chunk-KZILJQX3.js +0 -8
  274. package/dist/standalone/chunk-LEYUH5TS.js +0 -1
  275. package/dist/standalone/chunk-LFM672WN.js +0 -1
  276. package/dist/standalone/chunk-LIGOLZND.js +0 -1
  277. package/dist/standalone/chunk-LPU6YTSU.js +0 -1
  278. package/dist/standalone/chunk-MWJC3S62.js +0 -1
  279. package/dist/standalone/chunk-NP2AQOLE.js +0 -1
  280. package/dist/standalone/chunk-NVKLYDOH.js +0 -1
  281. package/dist/standalone/chunk-O2X2XYCM.js +0 -1
  282. package/dist/standalone/chunk-O3MDWYXF.js +0 -1
  283. package/dist/standalone/chunk-ONG4JEZD.js +0 -1
  284. package/dist/standalone/chunk-OS26JXYA.js +0 -1
  285. package/dist/standalone/chunk-OXFKZ4BM.js +0 -1
  286. package/dist/standalone/chunk-PGTEGUAB.js +0 -1
  287. package/dist/standalone/chunk-PTBUWRBY.js +0 -1
  288. package/dist/standalone/chunk-Q6HA3L2H.js +0 -1
  289. package/dist/standalone/chunk-QGV5ARD2.js +0 -1
  290. package/dist/standalone/chunk-QWRK4ESB.js +0 -1
  291. package/dist/standalone/chunk-RL2ITK2N.js +0 -1
  292. package/dist/standalone/chunk-RTJO3AR4.js +0 -1
  293. package/dist/standalone/chunk-SFY646MC.js +0 -1
  294. package/dist/standalone/chunk-T5UMHPAB.js +0 -1
  295. package/dist/standalone/chunk-T6HV2FQP.js +0 -2
  296. package/dist/standalone/chunk-T7ZKNNGX.js +0 -1
  297. package/dist/standalone/chunk-TCYPNSTV.js +0 -1
  298. package/dist/standalone/chunk-TQM6XHBA.js +0 -1
  299. package/dist/standalone/chunk-TRMWBRRU.js +0 -1
  300. package/dist/standalone/chunk-TW7KJSMR.js +0 -15
  301. package/dist/standalone/chunk-TYD3V4NB.js +0 -1
  302. package/dist/standalone/chunk-TZKLK52W.js +0 -1
  303. package/dist/standalone/chunk-U4RXQSQ7.js +0 -1
  304. package/dist/standalone/chunk-UNZ2UBVL.js +0 -1
  305. package/dist/standalone/chunk-VJRNOSRY.js +0 -1
  306. package/dist/standalone/chunk-W2BCSK5S.js +0 -1
  307. package/dist/standalone/chunk-W7MRISE3.js +0 -1
  308. package/dist/standalone/chunk-WM72PRE3.js +0 -1
  309. package/dist/standalone/chunk-X4WHMCOZ.js +0 -1
  310. package/dist/standalone/chunk-X74GEPSG.js +0 -1
  311. package/dist/standalone/chunk-XKPD4SFN.js +0 -1
  312. package/dist/standalone/chunk-XMSNLMWU.js +0 -1
  313. package/dist/standalone/chunk-XOPFDWXX.js +0 -1
  314. package/dist/standalone/chunk-XQLOVFPP.js +0 -1
  315. package/dist/standalone/chunk-XSHYZPGF.js +0 -1
  316. package/dist/standalone/chunk-XST3UEHU.js +0 -1
  317. package/dist/standalone/chunk-XYR5NST4.js +0 -1
  318. package/dist/standalone/chunk-Y74LIFSL.js +0 -1
  319. package/dist/standalone/chunk-YHTHRYP5.js +0 -1
  320. package/dist/standalone/chunk-YMEKCV27.js +0 -1
  321. package/dist/standalone/chunk-Z5EV64KS.js +0 -1
  322. package/dist/standalone/chunk-ZBON5T5A.js +0 -1
  323. package/dist/standalone/chunk-ZGSL4DPP.js +0 -1
  324. package/dist/standalone/chunk-ZOQTXWPK.js +0 -1
  325. package/dist/standalone/chunk-ZTOREMGH.js +0 -1
  326. package/dist/standalone/chunk-ZZ5GICTF.js +0 -1
  327. /package/dist/standalone/{chunk-UYEZR3BI.js → chunk-P6VNMPWR.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{c as B}from"react/compiler-runtime";import{useState as $,useEffect as ze,useMemo as $t,useRef as Ke,useCallback as ct}from"react";import{ShardInput as Gn}from"./ShardInput-CoySruKZ.mjs";import{u as Ze}from"./use-admin-query-CaOm4JS3.mjs";import{u as Xe}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ut}from"./use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as he}from"./ADMIN_FUNCTIONS-4aGsMs95.mjs";import{b as nn}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,l as Me,k as on,b as zt,c as $e,d as Re,o as Jn,h as Wn}from"./internal-hIuTpSbx.mjs";import{m as Hn,b as sn,c as Nt,u as Un,a as Qn,T as Yn,D as Xn}from"./table-list-sidebar-CNadcIgG.mjs";import{u as Zn}from"./use-sql-assistant-rZPs3LC3.mjs";import{decodeWire as Pt,isPlainObject as ln,encodeWire as rn,decodeDocument as eo}from"@lunora/wire";import{B as kt}from"./button-q0UYSmrn.mjs";import{I as to}from"./input-CXhxesPC.mjs";import{L as qt}from"./label-DKFzyHq6.mjs";import{M as ft}from"./modal-shell-CDztwLnv.mjs";import{useT as ve}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as d,jsxs as E,Fragment as et}from"react/jsx-runtime";import{ConfirmButton as Kt}from"./ConfirmButton-CIXYF6Mg.mjs";import{E as no}from"./empty-state-D7jEML_T.mjs";import{C as Dt,a as Pe}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as oo,sortFn_text as so,sortFn_datetime as lo,sortFn_basic as ro,sortFn_alphanumeric as ao,rowSortingFeature as io,rowSelectionFeature as co,columnVisibilityFeature as uo,columnSizingFeature as fo,columnResizingFeature as mo,columnOrderingFeature as go,createSortedRowModel as po,useTable as bo,flexRender as ho}from"@tanstack/react-table";import{useVirtualizer as xo}from"@tanstack/react-virtual";import{C as It}from"./checkbox-CnS9cyCz.mjs";import{c as dt}from"./utils-bhneXptQ.mjs";import{f as vo}from"./virtual-rect-D_j7aLxX.mjs";import{C as Tt,G as wo,T as yo}from"./data-grid-B5m1OosL.mjs";import{DataFilters as Co,toFilterClauses as Fe}from"./DataFilters--ocFTVT2.mjs";import{G as So,C as No}from"./grid-features-Drvfswwy.mjs";import{G as ko}from"./grid-pagination-DY2erU65.mjs";import Gt from"./useDebounced-DVeQ5-oW.mjs";import{r as To,l as Eo}from"./shard-history-CaO3C4KQ.mjs";const _o=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),Ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},$o=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Jt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Ot=s=>`${s.table}.${s.column}`,Do=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=ve(),[u,m]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=re=>{m(re.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=re=>{b(re.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let S,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=Pt(JSON.parse(p))}catch(re){S=i("Invalid JSON: {message}",{message:re.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=S,e[8]=C}else S=e[7],C=e[8];let k;e[9]!==u||e[10]!==r||e[11]!==a?(k=a.has(u)&&r>1,e[9]=u,e[10]=r,e[11]=a,e[12]=k):k=e[12];const N=k,w=u!==""&&!y&&S===void 0&&!N;let T;e[13]!==w||e[14]!==u||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[u]:C}),t())},e[13]=w,e[14]=u,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const F=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let O;e[25]!==i||e[26]!==l||e[27]!==r?(O=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=O):O=e[28];let V;e[29]!==O?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:O}),e[29]=O,e[30]=V):V=e[30];let A;e[31]!==c||e[32]!==i?(A=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=A):A=e[33];let L;e[34]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=L):L=e[35];let G;e[36]!==V||e[37]!==L||e[38]!==D?(G=E("div",{className:"flex flex-col gap-0.5",children:[D,V,L]}),e[36]=V,e[37]=L,e[38]=D,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let P;e[42]!==t||e[43]!==q?(P=d(kt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=P):P=e[44];let J;e[45]!==G||e[46]!==P?(J=E("div",{className:"flex items-start justify-between",children:[G,P]}),e[45]=G,e[46]=P,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let H;e[50]!==K?(H=d(qt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=H):H=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let U;e[54]!==n?(U=n.map(Ao),e[54]=n,e[55]=U):U=e[55];let ne;e[56]!==u||e[57]!==Y||e[58]!==U?(ne=d("select",{"aria-label":Y,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:u,children:U}),e[56]=u,e[57]=Y,e[58]=U,e[59]=ne):ne=e[59];let le;e[60]!==i?(le=i("Value"),e[60]=i,e[61]=le):le=e[61];let ae;e[62]!==le?(ae=d(qt,{htmlFor:"bulk-patch-value",children:le}),e[62]=le,e[63]=ae):ae=e[63];let ge;e[64]!==p?(ge=d(to,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=ge):ge=e[65];let fe;e[66]!==H||e[67]!==ne||e[68]!==ae||e[69]!==ge?(fe=E("div",{className:"flex items-center gap-2",children:[H,ne,ae,ge]}),e[66]=H,e[67]=ne,e[68]=ae,e[69]=ge,e[70]=fe):fe=e[70];let me;e[71]!==S?(me=S!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:S}),e[71]=S,e[72]=me):me=e[72];let pe;e[73]!==u||e[74]!==i||e[75]!==r||e[76]!==N?(pe=N&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:u,total:r.toString()})}),e[73]=u,e[74]=i,e[75]=r,e[76]=N,e[77]=pe):pe=e[77];let ie;e[78]!==y||e[79]!==i||e[80]!==N?(ie=y&&!N&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=N,e[81]=ie):ie=e[81];let Q;e[82]!==w||e[83]!==u||e[84]!==p?(Q=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${u} = ${p.trim()}`}),e[82]=w,e[83]=u,e[84]=p,e[85]=Q):Q=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let ce;e[88]!==t||e[89]!==be?(ce=d(kt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=ce):ce=e[90];const Se=!w;let oe;e[91]!==i||e[92]!==r?(oe=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=oe):oe=e[93];let se;e[94]!==F||e[95]!==Se||e[96]!==oe?(se=d(kt,{"data-testid":"bulk-patch-apply",disabled:Se,onClick:F,size:"xs",children:oe}),e[94]=F,e[95]=Se,e[96]=oe,e[97]=se):se=e[97];let W;e[98]!==ce||e[99]!==se?(W=E("div",{className:"flex justify-end gap-2",children:[ce,se]}),e[98]=ce,e[99]=se,e[100]=W):W=e[100];let j;return e[101]!==t||e[102]!==J||e[103]!==fe||e[104]!==me||e[105]!==pe||e[106]!==ie||e[107]!==Q||e[108]!==W||e[109]!==R?(j=E(ft,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,fe,me,pe,ie,Q,W]}),e[101]=t,e[102]=J,e[103]=fe,e[104]=me,e[105]=pe,e[106]=ie,e[107]=Q,e[108]=W,e[109]=R,e[110]=j):j=e[110],j};function Ao(s){return d("option",{value:s,children:s},s)}const Wt=6,at=100,Po=s=>({paddingLeft:s*16}),Io=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},Oo=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Fo=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Mo=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(Oo,{table:s.table}):s.isRestrict?d(Io,{table:s.table}):d(Fo,{table:s.table}),an=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=Po(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let u;e[11]!==i?(u=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=u):u=e[12];let m;e[13]!==o?(m=Mo(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==u||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,u,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=u,e[24]=m,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(an,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(et,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},Vo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Lo=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Vo(a)||[]).slice(0,at),l=t.total??0;return{capNote:l>at?`showing first ${at.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},cn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Lo(s,n.field,e,l),u=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Wt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await cn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Wt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:m,isRestrict:u,relation:n,rowCount:a,rowIds:i,table:s}},Bo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=ve(),[r,a]=$(!0),[i,u]=$(null),[m,p]=$(null);ze(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=Ro(t);if(!((x.get(c)??[]).length>0)){g||(u({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await cn(c,o,void 0,x,new Set,0,n);g||(u(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&$o(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(ft,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(an,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},jo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,u=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),f=a+p>c&&a<l;b||f?r.add(m.id):a<c?i+=p:u+=p,a+=p}return{ids:r,leadPx:i,tailPx:u}},zo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},qo=oo({columnOrderingFeature:go,columnResizingFeature:mo,columnSizingFeature:fo,columnVisibilityFeature:uo,rowSelectionFeature:co,rowSortingFeature:io,sortedRowModel:po(),sortFns:{alphanumeric:ao,basic:ro,datetime:lo,text:so}}),Ko=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(S=>{const[C,k]=S;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(S=>{const[C]=S;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let u;s[4]!==n?(u=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=u):u=s[5];const m=u;let p;s[6]!==n?(p=Object.values(n).reduce(Jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==m?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=f):f=s[11],f},dn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Go=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=ve();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let u;e[8]!==o||e[9]!==t||e[10]!==i?(u=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=u):u=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==u||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,u,p]}),e[18]=a,e[19]=u,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Wo),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function Jo(s,e){return s+Object.keys(e).length}function Wo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Me(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Me(s.newValue)})]},`${s.rowId}:${s.column}`)}const Ht=400,Ho=36,Uo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Qo={width:"100%"},Yo=/\n$/u,Xo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Zo={display:"flex",width:"100%"},Ut={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},es="2.5rem",un={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Ft=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),fn=(s,e)=>({...Ft(s),left:`calc(${es} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Et="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ts=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,At="__back__:",ns=s=>`${At}${s.table}.${s.column}`,os=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ie=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},ss=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},ls=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return ss(s,n);const o=dn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},rs=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
1
+ import{c as B}from"react/compiler-runtime";import{useState as $,useEffect as ze,useMemo as $t,useRef as Ke,useCallback as ct}from"react";import{ShardInput as Gn}from"./ShardInput-CoySruKZ.mjs";import{u as Ze}from"./use-admin-query-CaOm4JS3.mjs";import{u as Jn}from"./use-assistant-rpc-GCUK2zPa.mjs";import{u as Xe}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ut}from"./use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as he}from"./ADMIN_FUNCTIONS-DUXsXId1.mjs";import{b as nn}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,l as Me,k as on,b as zt,c as $e,d as Re,o as Wn,h as Hn}from"./internal-hIuTpSbx.mjs";import{m as Un,b as sn,c as Nt,u as Qn,a as Yn,T as Xn,D as Zn}from"./table-list-sidebar-kpHaDWjy.mjs";import{decodeWire as Pt,isPlainObject as ln,encodeWire as rn,decodeDocument as eo}from"@lunora/wire";import{B as kt}from"./button-q0UYSmrn.mjs";import{I as to}from"./input-CXhxesPC.mjs";import{L as qt}from"./label-DKFzyHq6.mjs";import{M as ft}from"./modal-shell-CDztwLnv.mjs";import{useT as ve}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as d,jsxs as E,Fragment as et}from"react/jsx-runtime";import{ConfirmButton as Kt}from"./ConfirmButton-CIXYF6Mg.mjs";import{E as no}from"./empty-state-D7jEML_T.mjs";import{C as Dt,a as Pe}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as oo,sortFn_text as so,sortFn_datetime as lo,sortFn_basic as ro,sortFn_alphanumeric as ao,rowSortingFeature as io,rowSelectionFeature as co,columnVisibilityFeature as uo,columnSizingFeature as fo,columnResizingFeature as mo,columnOrderingFeature as go,createSortedRowModel as po,useTable as bo,flexRender as ho}from"@tanstack/react-table";import{useVirtualizer as xo}from"@tanstack/react-virtual";import{C as It}from"./checkbox-CnS9cyCz.mjs";import{c as dt}from"./utils-bhneXptQ.mjs";import{f as vo}from"./virtual-rect-D_j7aLxX.mjs";import{C as Tt,G as wo,T as yo}from"./data-grid-B5m1OosL.mjs";import{DataFilters as Co,toFilterClauses as Fe}from"./DataFilters--ocFTVT2.mjs";import{G as So,C as No}from"./grid-features-Drvfswwy.mjs";import{G as ko}from"./grid-pagination-DY2erU65.mjs";import Gt from"./useDebounced-DVeQ5-oW.mjs";import{r as To,l as Eo}from"./shard-history-CaO3C4KQ.mjs";const _o=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),Ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},$o=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Jt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Ot=s=>`${s.table}.${s.column}`,Do=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=ve(),[u,m]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=re=>{m(re.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=re=>{b(re.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let S,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=Pt(JSON.parse(p))}catch(re){S=i("Invalid JSON: {message}",{message:re.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=S,e[8]=C}else S=e[7],C=e[8];let k;e[9]!==u||e[10]!==r||e[11]!==a?(k=a.has(u)&&r>1,e[9]=u,e[10]=r,e[11]=a,e[12]=k):k=e[12];const N=k,w=u!==""&&!y&&S===void 0&&!N;let T;e[13]!==w||e[14]!==u||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[u]:C}),t())},e[13]=w,e[14]=u,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const F=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let O;e[25]!==i||e[26]!==l||e[27]!==r?(O=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=O):O=e[28];let V;e[29]!==O?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:O}),e[29]=O,e[30]=V):V=e[30];let A;e[31]!==c||e[32]!==i?(A=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=A):A=e[33];let L;e[34]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=L):L=e[35];let G;e[36]!==V||e[37]!==L||e[38]!==D?(G=E("div",{className:"flex flex-col gap-0.5",children:[D,V,L]}),e[36]=V,e[37]=L,e[38]=D,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let P;e[42]!==t||e[43]!==q?(P=d(kt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=P):P=e[44];let J;e[45]!==G||e[46]!==P?(J=E("div",{className:"flex items-start justify-between",children:[G,P]}),e[45]=G,e[46]=P,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let H;e[50]!==K?(H=d(qt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=H):H=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let U;e[54]!==n?(U=n.map(Ao),e[54]=n,e[55]=U):U=e[55];let ne;e[56]!==u||e[57]!==Y||e[58]!==U?(ne=d("select",{"aria-label":Y,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:u,children:U}),e[56]=u,e[57]=Y,e[58]=U,e[59]=ne):ne=e[59];let le;e[60]!==i?(le=i("Value"),e[60]=i,e[61]=le):le=e[61];let ae;e[62]!==le?(ae=d(qt,{htmlFor:"bulk-patch-value",children:le}),e[62]=le,e[63]=ae):ae=e[63];let ge;e[64]!==p?(ge=d(to,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=ge):ge=e[65];let fe;e[66]!==H||e[67]!==ne||e[68]!==ae||e[69]!==ge?(fe=E("div",{className:"flex items-center gap-2",children:[H,ne,ae,ge]}),e[66]=H,e[67]=ne,e[68]=ae,e[69]=ge,e[70]=fe):fe=e[70];let me;e[71]!==S?(me=S!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:S}),e[71]=S,e[72]=me):me=e[72];let pe;e[73]!==u||e[74]!==i||e[75]!==r||e[76]!==N?(pe=N&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:u,total:r.toString()})}),e[73]=u,e[74]=i,e[75]=r,e[76]=N,e[77]=pe):pe=e[77];let ie;e[78]!==y||e[79]!==i||e[80]!==N?(ie=y&&!N&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=N,e[81]=ie):ie=e[81];let Q;e[82]!==w||e[83]!==u||e[84]!==p?(Q=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${u} = ${p.trim()}`}),e[82]=w,e[83]=u,e[84]=p,e[85]=Q):Q=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let ce;e[88]!==t||e[89]!==be?(ce=d(kt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=ce):ce=e[90];const Se=!w;let oe;e[91]!==i||e[92]!==r?(oe=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=oe):oe=e[93];let se;e[94]!==F||e[95]!==Se||e[96]!==oe?(se=d(kt,{"data-testid":"bulk-patch-apply",disabled:Se,onClick:F,size:"xs",children:oe}),e[94]=F,e[95]=Se,e[96]=oe,e[97]=se):se=e[97];let W;e[98]!==ce||e[99]!==se?(W=E("div",{className:"flex justify-end gap-2",children:[ce,se]}),e[98]=ce,e[99]=se,e[100]=W):W=e[100];let j;return e[101]!==t||e[102]!==J||e[103]!==fe||e[104]!==me||e[105]!==pe||e[106]!==ie||e[107]!==Q||e[108]!==W||e[109]!==R?(j=E(ft,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,fe,me,pe,ie,Q,W]}),e[101]=t,e[102]=J,e[103]=fe,e[104]=me,e[105]=pe,e[106]=ie,e[107]=Q,e[108]=W,e[109]=R,e[110]=j):j=e[110],j};function Ao(s){return d("option",{value:s,children:s},s)}const Wt=6,at=100,Po=s=>({paddingLeft:s*16}),Io=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},Oo=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Fo=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Mo=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(Oo,{table:s.table}):s.isRestrict?d(Io,{table:s.table}):d(Fo,{table:s.table}),an=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=Po(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let u;e[11]!==i?(u=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=u):u=e[12];let m;e[13]!==o?(m=Mo(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==u||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,u,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=u,e[24]=m,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(an,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(et,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},Vo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Lo=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Vo(a)||[]).slice(0,at),l=t.total??0;return{capNote:l>at?`showing first ${at.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},cn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Lo(s,n.field,e,l),u=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Wt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await cn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Wt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:m,isRestrict:u,relation:n,rowCount:a,rowIds:i,table:s}},Bo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=ve(),[r,a]=$(!0),[i,u]=$(null),[m,p]=$(null);ze(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=Ro(t);if(!((x.get(c)??[]).length>0)){g||(u({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await cn(c,o,void 0,x,new Set,0,n);g||(u(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&$o(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(ft,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(an,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},jo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,u=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),f=a+p>c&&a<l;b||f?r.add(m.id):a<c?i+=p:u+=p,a+=p}return{ids:r,leadPx:i,tailPx:u}},zo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},qo=oo({columnOrderingFeature:go,columnResizingFeature:mo,columnSizingFeature:fo,columnVisibilityFeature:uo,rowSelectionFeature:co,rowSortingFeature:io,sortedRowModel:po(),sortFns:{alphanumeric:ao,basic:ro,datetime:lo,text:so}}),Ko=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(S=>{const[C,k]=S;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(S=>{const[C]=S;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let u;s[4]!==n?(u=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=u):u=s[5];const m=u;let p;s[6]!==n?(p=Object.values(n).reduce(Jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==m?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=f):f=s[11],f},dn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Go=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=ve();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let u;e[8]!==o||e[9]!==t||e[10]!==i?(u=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=u):u=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==u||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,u,p]}),e[18]=a,e[19]=u,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Wo),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function Jo(s,e){return s+Object.keys(e).length}function Wo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Me(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Me(s.newValue)})]},`${s.rowId}:${s.column}`)}const Ht=400,Ho=36,Uo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Qo={width:"100%"},Yo=/\n$/u,Xo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Zo={display:"flex",width:"100%"},Ut={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},es="2.5rem",un={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Ft=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),fn=(s,e)=>({...Ft(s),left:`calc(${es} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Et="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ts=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,At="__back__:",ns=s=>`${At}${s.table}.${s.column}`,os=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ie=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},ss=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},ls=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return ss(s,n);const o=dn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},rs=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
2
2
  `,`
3
3
  `).replace(Yo,"").split(`
4
- `),r=[];let a=0;for(const[i,u]of l.entries()){const m=t[s.row+i],p=m===void 0?null:Ie(m),b=u.split(" ");if(m===void 0||p===null){a+=b.length;continue}for(const[f,g]of b.entries()){const h=e[s.col+f],x=h===void 0||!o(h)?void 0:ls(g,m[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},mn=(s,e)=>Ie(s)??`row-${e.toString()}`,as=8,is=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=ve();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let u;e[3]!==c?(u=c("Loading…"),e[3]=c,e[4]=u):u=e[4];let m;e[5]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[5]=u,e[6]=m):m=e[6],a=m}else if(t.row===null){let u;e[7]!==c?(u=c("No matching row."),e[7]=c,e[8]=u):u=e[8];let m;e[9]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10],a=m}else{let u;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(sn(t.row,o)).slice(0,as);u=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(ws)}),e[11]=o,e[12]=t.row,e[13]=u}else u=e[13];a=u}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},cs=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=$(null),[u,m]=$("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let f;e[4]!==o||e[5]!==l||e[6]!==u||e[7]!==r?(f=N=>{const w=N.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),u!=="idle")return;m("loading"),Ce((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=u,e[7]=r,e[8]=f):f=e[8];const g=f;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let S;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(S=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=S):S=e[15];let C;e[16]!==a||e[17]!==t||e[18]!==u||e[19]!==r?(C=a!==null&&u!=="idle"&&d(is,{anchor:a,mask:t(r,u==="loading"||u.row===null?[]:Object.keys(u.row)),state:u}),e[16]=a,e[17]=t,e[18]=u,e[19]=r,e[20]=C):C=e[20];let k;return e[21]!==S||e[22]!==C?(k=E(et,{children:[S,C]}),e[21]=S,e[22]=C,e[23]=k):k=e[23],k},ds=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",us="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",Qt=s=>{const e=B(9),{column:n,onExpand:o,storedValue:t,value:c}=s;let l;e[0]!==n||e[1]!==o||e[2]!==t||e[3]!==c?(l=()=>{o(n,c,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c,e[4]=l):l=e[4];const r=l,a=`db-expand-${n}`;let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[5]=i):i=e[5];let u;return e[6]!==r||e[7]!==a?(u=d("button",{"aria-label":"Expand cell",className:us,"data-testid":a,onClick:r,type:"button",children:i}),e[6]=r,e[7]=a,e[8]=u):u=e[8],u},fs=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Ke(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),ze(a,i);let u;e[2]!==t||e[3]!==c?(u=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=u):u=e[4];const m=u;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,f=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=Me(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==f||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":f,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=f,e[13]=g,e[14]=h):h=e[14],h},ms=s=>{const e=B(71),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,u,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Ie(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,D=d(Tt,{value:Hn(i,r,c)});let O;e[12]!==_||e[13]!==D?(O=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:D}),e[12]=_,e[13]=D,e[14]=O):O=e[14],m=O;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),D=`${R}:${String(i)}`;let O;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==D||e[21]!==R?(O=d(cs,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},D),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=D,e[21]=R,e[22]=O):O=e[22],m=O;break e}if(a===null){let _;e[23]!==i?(_=d(Tt,{value:i}),e[23]=i,e[24]=_):_=e[24];let D;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?(D=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=D):D=e[28];let O;e[29]!==_||e[30]!==D?(O=E(et,{children:[_,D]}),e[29]=_,e[30]=D,e[31]=O):O=e[31],m=O;break e}u=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=u,e[11]=m}else a=e[8],i=e[9],u=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=u,b=p===void 0?i:p.value;let f;e[32]!==r||e[33]!==o?(f=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=f):f=e[34];const g=f;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=D=>{o.stage(a,r,dn(D,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(fs,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const y=v,S=x,C=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=ts(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=k):k=e[54];let N;e[55]!==b||e[56]!==k?(N=d(Tt,{highlight:k,value:b}),e[55]=b,e[56]=k,e[57]=N):N=e[57];let w;e[58]!==x||e[59]!==y||e[60]!==C||e[61]!==N?(w=d("span",{className:S,"data-testid":C,onDoubleClick:y,children:N}),e[58]=x,e[59]=y,e[60]=C,e[61]=N,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell||e[66]!==i?(T=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=i,e[67]=T):T=e[67];let F;return e[68]!==T||e[69]!==w?(F=E(et,{children:[w,T]}),e[68]=T,e[69]=w,e[70]=F):F=e[70],F},gs=s=>{s.preventDefault()},Yt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},ps=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,u=n.column.id;if(e.current=null,i===null||i===u)return;const m=l.atoms.columnOrder.get(),b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),f=b.indexOf(u);b.splice(f===-1?b.length:f,0,i),l.setColumnOrder(b)};return E("th",{className:dt("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),"data-testid":`db-head-${n.column.id}`,draggable:!0,onDragOver:gs,onDragStart:r,onDrop:a,style:c===void 0?Ft(n.getSize()):fn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[ho(n.column.columnDef.header,n.getContext()),ds(n.column.getIsSorted())]}),s!==void 0&&Yt[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Yt[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:dt("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},bs=s=>{const e=B(13),{table:n}=s,o=ve();let t;e[0]!==n?(t=u=>{n.toggleAllRowsSelected(u)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:un,children:d(It,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},hs=s=>{const e=B(17),{row:n}=s,o=ve();let t;e[0]!==n.original?(t=Ie(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=f=>{n.toggleSelected(f)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let u;e[8]!==n.index||e[9]!==n.original?(u=mn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=u):u=e[10];const m=`db-select-${u}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:un,children:d(It,{"aria-label":a,checked:i,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},xs=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:u,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:f}=s,g=ve(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:S,tbodyStyle:C,viewportWidth:k,virtualRows:N}=f,w=Ke(null),[T,F]=$(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,D]=$(R);let O;e[1]!==y?(O=y.getVisibleLeafColumns(),e[1]=y,e[2]=O):O=e[2];const V=O.length;let A;e[3]!==T||e[4]!==V||e[5]!==o||e[6]!==y||e[7]!==S?(A=re=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(re.key))return;re.preventDefault();const X=T??{col:0,row:0};if(re.key==="Enter"){const xe=S[X.row],de=y.getVisibleLeafColumns()[X.col];if(xe!==void 0&&de!==void 0){const te=Ie(xe.original);te!==null&&o.editableColumn(de.id)&&o.startEdit(te,de.id)}F(X);return}let{col:ee,row:we}=X;e:switch(re.key){case"ArrowDown":{we=Math.min(we+1,S.length-1);break e}case"ArrowRight":{ee=Math.min(ee+1,V-1);break e}case"ArrowUp":{we=Math.max(we-1,0);break e}default:ee=Math.max(ee-1,0)}F({col:ee,row:we})},e[3]=T,e[4]=V,e[5]=o,e[6]=y,e[7]=S,e[8]=A):A=e[8];const L=A;let G;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==S?(G=re=>{const X=o.editable?re.clipboardData.getData("text/plain"):"";if(X==="")return;re.preventDefault();const ee=y.getVisibleLeafColumns().map(ys),we=rs({anchor:T??{col:0,row:0},columnIds:ee,columnMeta:n,editableColumn:o.editableColumn,rows:S.map(Cs),text:X});for(const xe of we.edits)o.stage(xe.rowId,xe.column,xe.value);D({columns:ee.join("\0"),count:we.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=S,e[14]=G):G=e[14];const q=G;let P,J;e[15]!==T||e[16]!==v?(P=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=P,e[18]=J):(P=e[17],J=e[18]),ze(P,J);let K,H,Y,U,ne,le,ae,ge,fe,me,pe,ie,Q,be,ce,Se;if(e[19]!==T||e[20]!==h||e[21]!==u||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==L||e[30]!==q||e[31]!==a||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==S||e[41]!==C||e[42]!==k||e[43]!==N){const re=y.getVisibleLeafColumns().map(Ss),X=jo(re,p,x,k),ee=zo(y.getVisibleLeafColumns().map(Ns),p),we=te=>{const De=S[te.index],{original:Ve}=De,Le=Ie(Ve),Ne=mn(Ve,te.index),ue={...Xo,height:`${te.size.toString()}px`,transform:`translateY(${te.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ue,children:[d(hs,{row:De}),X.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),De.getVisibleCells().map((ke,Ge)=>{if(!X.ids.has(ke.column.id))return null;const qe=ee.get(ke.column.id),He=T!==null&&T.row===te.index&&T.col===Ge?" ring-1 ring-ring ring-inset":"";return d("td",{className:dt("group/cell truncate font-mono text-muted-foreground",qe!==void 0&&"border-e border-border bg-background",He),onPointerDown:()=>{F({col:Ge,row:te.index})},style:qe===void 0?Ft(ke.column.getSize()):fn(ke.column.getSize(),qe),children:ke.column.id.startsWith(At)?d(os,{counts:u[ke.column.id.slice(At.length)],rowId:Ne}):d(ms,{cell:ke,edit:o,highlight:i,mask:c,refs:b})},ke.id)}),X.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:Ut,children:[d("button",{className:Et,"data-testid":`db-inspect-${Ne}`,onClick:()=>{a(Ve)},type:"button",children:"Details"}),t&&E(et,{children:[d("button",{className:Et,"data-testid":`db-edit-${Ne}`,disabled:Le===null,onClick:()=>{r(Le,Ve)},type:"button",children:"Edit"}),d("button",{className:Et,"data-testid":`db-delete-${Ne}`,disabled:Le===null,onClick:()=>{l(Le)},type:"button",children:"Delete"})]})]})]},De.id)};K=wo,ie="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Q=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ks).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Q):Q=e[64],ne="db-scroll",le=L,ae=q,ge=h,fe="grid",me=Uo,pe=0,Se="w-full text-xs",H="db-rows",Y=Qo;let xe;e[65]!==y?(xe=d(bs,{table:y}),e[65]=y,e[66]=xe):xe=e[66];let de;e[67]===Symbol.for("react.memo_cache_sentinel")?(de=d("th",{"aria-label":"Row actions",style:Ut}),e[67]=de):de=e[67],U=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Zo,children:[xe,X.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),y.getFlatHeaders().map(te=>X.ids.has(te.column.id)?d(ps,{declaredType:n?.[te.column.id]?.type,draggedRef:w,header:te,masked:c.columns.has(te.column.id),onTogglePin:m,pinnedOffset:ee.get(te.column.id),table:y},te.id):null),X.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),de]})}),be=C,ce=N.map(te=>we(te)),e[19]=T,e[20]=h,e[21]=u,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=L,e[30]=q,e[31]=a,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=S,e[41]=C,e[42]=k,e[43]=N,e[44]=K,e[45]=H,e[46]=Y,e[47]=U,e[48]=ne,e[49]=le,e[50]=ae,e[51]=ge,e[52]=fe,e[53]=me,e[54]=pe,e[55]=ie,e[56]=Q,e[57]=be,e[58]=ce,e[59]=Se}else K=e[44],H=e[45],Y=e[46],U=e[47],ne=e[48],le=e[49],ae=e[50],ge=e[51],fe=e[52],me=e[53],pe=e[54],ie=e[55],Q=e[56],be=e[57],ce=e[58],Se=e[59];let oe;e[68]!==be||e[69]!==ce?(oe=d("tbody",{style:be,children:ce}),e[68]=be,e[69]=ce,e[70]=oe):oe=e[70];let se;e[71]!==H||e[72]!==Y||e[73]!==U||e[74]!==oe||e[75]!==Se?(se=E("table",{className:Se,"data-testid":H,style:Y,children:[U,oe]}),e[71]=H,e[72]=Y,e[73]=U,e[74]=oe,e[75]=Se,e[76]=se):se=e[76];let W;e[77]!==ne||e[78]!==le||e[79]!==ae||e[80]!==ge||e[81]!==fe||e[82]!==me||e[83]!==pe||e[84]!==se?(W=d("div",{"data-testid":ne,onKeyDown:le,onPaste:ae,ref:ge,role:fe,style:me,tabIndex:pe,children:se}),e[77]=ne,e[78]=le,e[79]=ae,e[80]=ge,e[81]=fe,e[82]=me,e[83]=pe,e[84]=se,e[85]=W):W=e[85];let j;return e[86]!==K||e[87]!==ie||e[88]!==Q||e[89]!==W?(j=E(K,{layout:ie,children:[Q,W]}),e[86]=K,e[87]=ie,e[88]=Q,e[89]=W,e[90]=j):j=e[90],j},vs=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=$t(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:F=>F[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:ns(T)});return w},[o,t,l]),a=$t(()=>c??[],[c]),[i,u]=$({}),[m,p]=$({}),b=bo({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Ie(w.original)!==null,features:qo,getRowId:(w,T)=>Ie(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:u,onSortingChange:n,state:{columnVisibility:m,rowSelection:i,sorting:e}}),f=b.getRowModel().rows,g=Ke(null),h=xo({count:f.length,estimateSize:()=>Ho,getScrollElement:()=>g.current,initialRect:{height:Ht,width:0},observeElementRect:(w,T)=>vo(w,T,Ht),overscan:8}),x=ct(w=>{h.scrollToIndex(w)},[h]),[v,y]=$({left:0,width:0}),S=ct(w=>{if(g.current=w,w===null)return;const T=()=>{y(R=>R.left===w.scrollLeft&&R.width===w.clientWidth?R:{left:w.scrollLeft,width:w.clientWidth})};w.addEventListener("scroll",T,{passive:!0});const F=new ResizeObserver(T);return F.observe(w),()=>{w.removeEventListener("scroll",T),F.disconnect(),g.current=null}},[]),C=h.getVirtualItems(),N={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:S,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:N,viewportWidth:v.width,virtualRows:C}};function ws(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Me(n),children:Me(n)})]},e)}function ys(s){return s.id}function Cs(s){return s.original}function Ss(s){return{getSize:()=>s.getSize(),id:s.id}}function Ns(s){return{getSize:()=>s.getSize(),id:s.id}}function ks(s){return s.id}const Ts=s=>{const e=B(22),{onCommit:n}=s,o=ve(),[t,c]=$(""),l=Ke(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),ze(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=y=>{c(y.target.value)},e[2]=i):i=e[2];const u=i;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Query name"),e[8]=o,e[9]=f):f=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==f?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:u,placeholder:f,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=f,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:Dt,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},Es=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=ve(),[a,i]=$(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{i(!0)},e[0]=u):u=e[0];const m=u;let p;e[1]!==c?(p=N=>{c(N),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let f;e[3]!==n||e[4]!==l?(f=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=f):f=e[5];const g=f;let h;e[6]!==t||e[7]!==l?(h=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&t(w.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:Dt,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let S;e[14]!==b||e[15]!==a||e[16]!==r?(S=a?d(Ts,{onCommit:b}):d("button",{className:Dt,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=S):S=e[17];let C;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(C=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((N,w)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":w,"data-testid":`db-saved-query-${N.name}`,onClick:g,type:"button",children:N.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:N.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":w,"data-testid":`db-saved-query-delete-${N.name}`,onClick:x,type:"button",children:"✕"})]},N.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=C):C=e[22];let k;return e[23]!==y||e[24]!==S||e[25]!==C?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,S,C]}),e[23]=y,e[24]=S,e[25]=C,e[26]=k):k=e[26],k},We="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",gn=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Xt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?gn.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",_s=(s,e,n)=>n===void 0?Xt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?gn.test(s)?"date":"number":Xt(s,e),Rs=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},$s=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Je="\0clear",Ds=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=ve();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Je?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const u=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let S;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(S=d(It,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=S):S=e[10],S}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Je;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let f;e[13]!==b?(f=d("option",{value:Je,children:b}),e[13]=b,e[14]=f):f=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==f?(x=E("select",{"aria-label":n,className:We,"data-testid":m,onChange:u,value:p,children:[f,g,h]}),e[17]=n,e[18]=u,e[19]=m,e[20]=p,e[21]=f,e[22]=x):x=e[22],x},As=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=ve(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const u=i;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Je?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,f=a??Je;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Je,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==u?(h=u&&d("option",{value:a,children:a}),e[10]=a,e[11]=u,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(Ls),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==f||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:We,"data-testid":b,onChange:p,value:f,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=f,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},Ps=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=Number(u.target.value);u.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Is=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=new Date(u.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?$s(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},Os=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{o(n,u.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Fs=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=ve();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=$(l),[i,u]=$(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const S=y.target.value;a(S);try{o(n,JSON.parse(S)),u(!1)}catch{u(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=i&&"border-destructive";let f;e[5]!==b?(f=dt(We,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==f||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:f,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=f,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},Ms=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=_s(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let u;e[4]!==n?(u=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==u||e[12]!==m||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[u,m,p]}),e[11]=u,e[12]=m,e[13]=p,e[14]=b):b=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(f=a==="boolean"&&d(Ds,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=f):f=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(As,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(Ps,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(Is,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(Fs,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(y=a==="text"&&d(Os,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=y):y=e[46];let S;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==f||e[53]!==g||e[54]!==h?(S=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,f,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=f,e[53]=g,e[54]=h,e[55]=S):S=e[55],S},Vs=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=ve();let i;e[0]!==o?(i=Rs(o),e[0]=o,e[1]=i):i=e[1];const u=i,[m,p]=$(!1),b=!m&&u!==null;let f;e[2]!==u||e[3]!==c?(f=(P,J)=>{c(JSON.stringify({...u,[P]:J},null,2))},e[2]=u,e[3]=c,e[4]=f):f=e[4];const g=f;let h;e[5]!==c?(h=P=>{c(P.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p(!0)},e[8]=S):S=e[8];const C=S,k=u===null;let N;e[9]!==a?(N=a("Form"),e[9]=a,e[10]=N):N=e[10];let w;e[11]!==b||e[12]!==k||e[13]!==N?(w=d("button",{"aria-pressed":b,className:Pe,"data-testid":"db-editor-form",disabled:k,onClick:y,type:"button",children:N}),e[11]=b,e[12]=k,e[13]=N,e[14]=w):w=e[14];const T=!b;let F;e[15]!==a?(F=a("JSON"),e[15]=a,e[16]=F):F=e[16];let R;e[17]!==F||e[18]!==T?(R=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-editor-json",onClick:C,type:"button",children:F}),e[17]=F,e[18]=T,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==w?(_=E("div",{className:"flex items-center gap-1.5",children:[w,R]}),e[20]=R,e[21]=w,e[22]=_):_=e[22];let D;e[23]!==n||e[24]!==o||e[25]!==u||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?(D=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(u).map(P=>{const[J,K]=P;return d(Ms,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:K},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=u,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=D):D=e[31];let O;e[32]!==a?(O=a("Save"),e[32]=a,e[33]=O):O=e[33];let V;e[34]!==l||e[35]!==O?(V=d("button",{className:Pe,"data-testid":"db-editor-save",onClick:l,type:"button",children:O}),e[34]=l,e[35]=O,e[36]=V):V=e[36];let A;e[37]!==a?(A=a("Cancel"),e[37]=a,e[38]=A):A=e[38];let L;e[39]!==t||e[40]!==A?(L=d("button",{className:Pe,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:A}),e[39]=t,e[40]=A,e[41]=L):L=e[41];let G;e[42]!==V||e[43]!==L?(G=E("div",{className:"flex items-center gap-1.5",children:[V,L]}),e[42]=V,e[43]=L,e[44]=G):G=e[44];let q;return e[45]!==_||e[46]!==D||e[47]!==G?(q=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,D,G]}),e[45]=_,e[46]=D,e[47]=G,e[48]=q):q=e[48],q};function Ls(s){return d("option",{value:s,children:s},s)}const Bs=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:u,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:f,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:S,total:C,totalKnown:k,viewMode:N}=s,w=ve(),T=N==="table";let F;e[0]!==y||e[1]!==T?(F=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=T,e[2]=F):F=e[2];const R=N==="json";let _;e[3]!==v||e[4]!==R?(_=d("button",{"aria-pressed":R,className:Pe,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=R,e[5]=_):_=e[5];let D;e[6]!==a||e[7]!==w?(D=a===void 0?w("Live — changes stream in automatically"):w("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=w,e[8]=D):D=e[8];const O=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let V;e[9]!==O?(V=d("span",{"aria-hidden":"true",className:O}),e[9]=O,e[10]=V):V=e[10];let A;e[11]!==a||e[12]!==w?(A=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=A):A=e[13];let L;e[14]!==D||e[15]!==V||e[16]!==A?(L=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:D,children:[V,A]}),e[14]=D,e[15]=V,e[16]=A,e[17]=L):L=e[17];let G;e[18]!==l||e[19]!==i||e[20]!==S||e[21]!==w?(G=l&&d("button",{"aria-pressed":i,className:Pe,"data-testid":"db-mask-toggle",onClick:S,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=S,e[21]=w,e[22]=G):G=e[22];let q;e[23]!==o||e[24]!==u?(q=o&&d("button",{className:Pe,"data-testid":"db-add-row",onClick:u,type:"button",children:"Add row"}),e[23]=o,e[24]=u,e[25]=q):q=e[25];let P;e[26]!==o||e[27]!==x||e[28]!==w?(P=o&&x!==void 0&&d("button",{className:Pe,"data-testid":"db-generate-rows",onClick:x,type:"button",children:w("Generate rows")}),e[26]=o,e[27]=x,e[28]=w,e[29]=P):P=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==w||e[34]!==C||e[35]!==k?(J=o&&C>0&&r&&d(Kt,{confirmLabel:k?w("Permanently delete {total} matching rows and everything that cascades?",{total:C.toString()}):w("Permanently delete all matching rows and everything that cascades?"),onConfirm:m,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:C.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=m,e[33]=w,e[34]=C,e[35]=k,e[36]=J):J=e[36];let K;e[37]!==o||e[38]!==r||e[39]!==p||e[40]!==w||e[41]!==C||e[42]!==k?(K=o&&k&&C>0&&r&&d("button",{className:Pe,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:C.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=C,e[42]=k,e[43]=K):K=e[43];let H;e[44]!==o||e[45]!==r||e[46]!==f||e[47]!==w||e[48]!==C||e[49]!==k?(H=o&&C>0&&!r&&d(Kt,{confirmLabel:k?w("Permanently clear all {total} rows and everything that cascades?",{total:C.toString()}):w("Permanently clear every row and everything that cascades?"),onConfirm:f,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:C.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=f,e[47]=w,e[48]=C,e[49]=k,e[50]=H):H=e[50];let Y;e[51]!==G||e[52]!==q||e[53]!==P||e[54]!==J||e[55]!==K||e[56]!==H||e[57]!==F||e[58]!==_||e[59]!==L?(Y=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[F,_,L,G,q,P,J,K,H]}),e[51]=G,e[52]=q,e[53]=P,e[54]=J,e[55]=K,e[56]=H,e[57]=F,e[58]=_,e[59]=L,e[60]=Y):Y=e[60];let U;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(U=d(Co,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[61]=n,e[62]=t,e[63]=c,e[64]=b,e[65]=g,e[66]=h,e[67]=U):U=e[67];let ne;return e[68]!==Y||e[69]!==U?(ne=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[Y,U]}),e[68]=Y,e[69]=U,e[70]=ne):ne=e[70],ne},js=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:u,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:f,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let S;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.totalKnown||e[14]!==t.viewMode||e[15]!==r||e[16]!==u||e[17]!==m||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(S=d(Bs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:u,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,totalKnown:t.totalKnown,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.totalKnown,e[14]=t.viewMode,e[15]=r,e[16]=u,e[17]=m,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=S):S=e[22];let C;e[23]!==b||e[24]!==h?(C=h!==void 0&&d(Es,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=C):C=e[25];let k;e[26]!==o||e[27]!==t.onBulkDeleteSelected||e[28]!==t.selectedTable||e[29]!==t.table||e[30]!==t.viewMode||e[31]!==r||e[32]!==f||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&f.rows.length>0&&d(So,{backRelations:o.available,columns:f.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:Nt(f.rows,g.maskView),sqlColumns:f.sqlColumns,table:t.table.table,transposed:g.transposed}),e[26]=o,e[27]=t.onBulkDeleteSelected,e[28]=t.selectedTable,e[29]=t.table,e[30]=t.viewMode,e[31]=r,e[32]=f,e[33]=g.maskView,e[34]=g.onToggleTranspose,e[35]=g.transposed,e[36]=k):k=e[36];let N;e[37]!==t.cancelEdit||e[38]!==t.editing||e[39]!==t.saveEdit||e[40]!==t.setEditorDocumentText||e[41]!==c||e[42]!==r||e[43]!==f?(N=r&&t.editing!==null&&d(Vs,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:f.refs}),e[37]=t.cancelEdit,e[38]=t.editing,e[39]=t.saveEdit,e[40]=t.setEditorDocumentText,e[41]=c,e[42]=r,e[43]=f,e[44]=N):N=e[44];let w;e[45]!==t.committing||e[46]!==t.discardStaged||e[47]!==t.onCommitStaged||e[48]!==t.stagedChanges||e[49]!==r?(w=r&&t.stagedChanges.length>0&&d(Go,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[45]=t.committing,e[46]=t.discardStaged,e[47]=t.onCommitStaged,e[48]=t.stagedChanges,e[49]=r,e[50]=w):w=e[50];let T;e[51]!==t.writeError?(T=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[51]=t.writeError,e[52]=T):T=e[52];let F;e[53]!==t.writeNotice?(F=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[53]=t.writeNotice,e[54]=F):F=e[54];let R;e[55]!==S||e[56]!==C||e[57]!==k||e[58]!==N||e[59]!==w||e[60]!==T||e[61]!==F?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[S,C,k,N,w,T,F]}),e[55]=S,e[56]=C,e[57]=k,e[58]=N,e[59]=w,e[60]=T,e[61]=F,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==f?(_=t.viewMode==="table"&&f.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(no,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[63]=t.viewMode,e[64]=f,e[65]=_):_=e[65];let D;e[66]!==t.viewMode||e[67]!==f||e[68]!==g.maskView||e[69]!==g.transposed?(D=t.viewMode==="table"&&f.rows.length>0&&g.transposed&&d(yo,{columns:f.columns,rows:Nt(f.rows,g.maskView)}),e[66]=t.viewMode,e[67]=f,e[68]=g.maskView,e[69]=g.transposed,e[70]=D):D=e[70];let O;e[71]!==o||e[72]!==t.filter||e[73]!==t.onRowEdit||e[74]!==t.table||e[75]!==t.viewMode||e[76]!==c||e[77]!==l||e[78]!==r||e[79]!==i||e[80]!==p||e[81]!==f||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(O=t.viewMode==="table"&&f.rows.length>0&&!g.transposed&&d(xs,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[71]=o,e[72]=t.filter,e[73]=t.onRowEdit,e[74]=t.table,e[75]=t.viewMode,e[76]=c,e[77]=l,e[78]=r,e[79]=i,e[80]=p,e[81]=f,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=O):O=e[87];let V;e[88]!==t.viewMode||e[89]!==f||e[90]!==g.maskView?(V=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(Nt(f.rows,g.maskView),on,2)}),e[88]=t.viewMode,e[89]=f,e[90]=g.maskView,e[91]=V):V=e[91];let A;e[92]!==t.changePageSize||e[93]!==t.goNext||e[94]!==t.goPrevious||e[95]!==t.hasNext||e[96]!==t.hasPrevious||e[97]!==t.jumpToPage||e[98]!==t.pageSize||e[99]!==t.rangeEnd||e[100]!==t.rangeStart||e[101]!==t.total?(A=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(ko,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[92]=t.changePageSize,e[93]=t.goNext,e[94]=t.goPrevious,e[95]=t.hasNext,e[96]=t.hasPrevious,e[97]=t.jumpToPage,e[98]=t.pageSize,e[99]=t.rangeEnd,e[100]=t.rangeStart,e[101]=t.total,e[102]=A):A=e[102];let L;return e[103]!==R||e[104]!==_||e[105]!==D||e[106]!==O||e[107]!==V||e[108]!==A?(L=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,D,O,V,A]}),e[103]=R,e[104]=_,e[105]=D,e[106]=O,e[107]=V,e[108]=A,e[109]=L):L=e[109],L},zs="/__lunora/seed",_t=200,qs=50,Ks=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Gs=s=>Array.isArray(s)&&s.every(e=>ln(e)),Js=async s=>{let e;try{e=await fetch(zs,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${zt(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=Pt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${zt(t)}`}}return Gs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:n.error==="seed-refused"&&typeof n.message=="string"?{kind:"error",message:n.message}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},Ws="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Hs="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Us=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=ve(),[l,r]=$(10),[a,i]=$(!1),[u,m]=$(void 0),[p,b]=$(void 0),[f,g]=$(0),h=C=>{const k=Number(C.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,_t))},x=async()=>{m(void 0),b(void 0),g(0),i(!0);try{const C=await Js({count:l,existingIds:e,seed:Date.now(),table:t});if(C.kind==="error"){m(C.message);return}const{rows:k}=C;if(k.length===0){m(c("No rows generated — all columns were skipped."));return}const N=await o(k);if(N.error!==void 0){m(N.error);return}b(N.inserted),g(N.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},y=s.filter(C=>C.pk!==!0),S=Ks(s,e);return E(ft,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:_t,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:_t.toString()})})]}),y.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(C=>{const k=C.ref!==void 0&&C.type==="id",N=k&&(e[C.ref??""]??[]).length===0,w=N?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",T=N?`gen-rows-fk-empty-${C.name}`:`gen-rows-fk-ok-${C.name}`,F=N?c("FK: no rows in {ref} — seed it first",{ref:C.ref??""}):c("→ {ref}",{ref:C.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:C.name}),E("span",{className:"text-muted-foreground",children:["(",C.type,")"]}),C.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),k&&d("span",{className:w,"data-testid":T,children:F})]},C.name)})})]}),S.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:S.join(", ")})}),u!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:u}),p!==void 0&&u===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:p.toString(),total:(p+f).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:Ws,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:Hs,"data-testid":"gen-rows-generate",disabled:a||S.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Qs=$e(he.backRelationCounts),Ys=(s,e,n,o)=>{const t=B(16),c=ut();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=$(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Ot(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const u=i;let m;t[6]!==n||t[7]!==u?(m=JSON.stringify([u,n]),t[6]=n,t[7]=u,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){x.cancelled||a({});return}try{const S=await c.query(Qs,{ids:y,relations:v},Re(o));x.cancelled||a(Object.fromEntries(S.relations.map(Xs)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const f=b;let g,h;return t[13]!==f?(g=()=>{const x={cancelled:!1};return Ce(f(x)),()=>{x.cancelled=!0}},h=[f],t[13]=f,t[14]=g,t[15]=h):(g=t[14],h=t[15]),ze(g,h),r};function Xs(s){return[Ot(s),s.counts]}const Zs=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},it=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},pn=s=>Me(s),Zt=s=>s.map(e=>({column:e.column,path:(e.path??[]).join("."),...e.path===void 0||e.path.length===0?{}:{pathSegments:e.path},...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":pn(e.value)})),en=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],el=s=>[s.column,s.operator,s.value,s.path??[]],rt=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>el(t)),o===void 0?null:[o.column,o.direction]]),Mt=200,tl=20,nl=$e(he.readTablePage),ol=$e(he.facetColumn),Rt=$e(he.writeRow),sl=$e(he.deleteRows),ll=$e(he.clearTable),rl=$e(he.patchRows),al={},Vt=new Set(["__doc__","__id__","_creationTime","_id","id"]),il=s=>{const e=s.__doc__;if(typeof e=="string"){const o=eo(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Vt.has(o)||(n[o]=t);return n},cl=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,rn(e)]),dl=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Fe(s),limit:n,offset:e,orderBy:it(t),search:o,skipCount:!0,table:c}),ul=({filters:s,search:e,table:n})=>({filters:Fe(s),limit:1,search:e,table:n}),fl=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ie(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},ml=s=>!Vt.has(s),gl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to remove the rest.`,pl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to set the rest.`,tn={resumable:!1,truncated:gl,verb:"deleted"},bl={resumable:!0,truncated:pl,verb:"written"},hl=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=ut(),[u,m]=$(l),[p,b]=$(o??""),f=a===void 0||a===""?null:a,[g,h]=$(0),[x,v]=$("table"),[y,S]=$(()=>en(e)),[C,k]=$(n??""),[N,w]=$(()=>Zt(s??[])),{clearFacets:T,facets:F,refetchFacets:R,toggleFacet:_}=Un(),[D,O]=$(null),[V,A]=$(null),[L,G]=$(null),q=Ke(null),P=Ko(),[J,K]=$(null),[H,Y]=$(!1),[U,ne]=$(a),[le,ae]=$(()=>rt(o,n,s,e)),[ge,fe]=$(0),[me,pe]=$(()=>rt(o,n,s,e)),ie=a!==U,Q=rt(o,n,s,e),ce=ie||!ie&&Q!==le&&Q!==me;if(ce){ne(a),ae(Q),fe(z=>z+1),S(en(e)),k(n??"");const I=Zt(s??[]);w(I),b(o??""),T(),P.clear(),K(null),O(null),h(0),A(null),G(null),q.current=null}else Q!==le&&ae(Q);const Se=ce?n??"":C,oe=ce?o??"":p,se=`${a??""}:${ge.toString()}`,W=Gt(Se.trim(),300,se),j=Gt(oe.trim(),400,se),re=Xe(se),X=Ke(0),[ee,we]=$(j);ee!==j&&(we(j),P.clear(),K(null),O(null));const xe=rt(j,W,Fe(N),it(y));xe!==me&&pe(xe);const de=Ze(he.listTables,al,{live:!0,shardKey:j}),te=de.data??null,De=de.error,Ve=dl({filters:N,offset:g,pageSize:u,search:W,sorting:y,table:f??""}),Le=ul({filters:N,search:W,table:f??""}),Ne=Ze(he.readTablePage,Ve,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:j}),ue=Ne.data??null,ke=Ne.error,{liveError:Ge}=Ne,qe=Ze(he.readTablePage,Le,{enabled:f!==null,live:!0,shardKey:j});ze(()=>{de.data!==void 0&&To(j)},[de.data,j]);const He=I=>{t?.(I)},mt=(I,z)=>{t?.(I,{search:z})},gt=async(I,z)=>{try{return(await i.query(nl,{filters:[],limit:tl,offset:0,search:z,table:I},Re(j))).rows.find(Ae=>Ie(Ae)===z)??null}catch{return null}},tt=(I,z,Te,Ae)=>ye=>i.query(ol,{column:ye,filters:Fe(Te),search:Ae,table:z},Re(I)),pt=I=>{_(I,f===null?null:tt(j,f,N,W))},nt=(I,z)=>{const Te={column:I,literal:[Jn(z)],operator:"eq",value:pn(z)},Ae=ye=>ye.column===I&&ye.operator!=="has"&&ye.pathSegments===void 0&&(ye.path??"").trim()==="";w(ye=>[...ye.filter(_e=>!Ae(_e)),Te]),h(0)},bt=Xe(tt),ht=Xe(R),Ue=Xe(c);ze(()=>{f!==null&&Ce(ht.current(bt.current(j,f,N,W)))},[j,f,N,W]),ze(()=>{f===null||Ue.current===void 0||U!==a||le!==Q||Ue.current({filters:Fe(N),orderBy:it(y),search:W,shard:j})},[f,a,U,le,Q,N,y,W,j]);const Qe=I=>{f!==null&&h(Math.max(0,I))},xt=(I,z)=>{K({column:z,rowId:I})},vt=()=>{K(null)},wt=async()=>{if(f!==null){A(null),Y(!0);try{for(const[I,z]of Object.entries(P.staged))await i.query(Rt,{doc:z,id:I,op:"patch",table:f},Re(j)),P.drop(I,z)}catch(I){A(I.message)}K(null),Ne.refetch(),Y(!1)}},yt=()=>{P.clear(),K(null)},Ct=I=>{X.current+=1,b(I),P.clear(),K(null),O(null),h(0),q.current=null},St=fl(ue,P.staged),M=async(I,z,Te)=>{if(f===null)return;A(null);let Ae;if(I!=="delete"){let ye;try{ye=Te===void 0||Te.trim()===""?{}:JSON.parse(Te)}catch(_e){A(`Invalid JSON: ${_e.message}`);return}try{const _e=Pt(ye);if(!ln(_e)){A("The document must be a JSON object.");return}Ae=_e}catch(_e){A(`Invalid document: ${_e.message}`);return}}try{await i.query(Rt,{doc:Ae,id:z??void 0,op:I,table:f},Re(j)),O(null),Ne.refetch()}catch(ye){A(ye.message)}},Z=async(I,z,Te)=>{if(f===null)return 0;const Ae=se,ye=X.current,_e=()=>re.current===Ae&&X.current===ye;A(null),G(null);const Bt=cl(I,z,j),zn=q.current?.key===Bt?q.current.after:void 0,qn=Te.resumable?zn??"":void 0;let je=0;try{const Ye=await Zs({args:z,maxBatches:Mt,openCursor:qn,query:async Kn=>{const jt=await i.query(I,Kn,Re(j));return je+=jt.count,jt}});return _e()&&(q.current=Ye.cursor===void 0?null:{after:Ye.cursor,key:Bt},Ye.outcome==="cap-hit"&&A(Te.truncated),G(`${je.toString()} ${je===1?"row":"rows"} ${Te.verb}.`)),je}catch(Ye){return _e()&&(A(`${Ye.message} (at least ${je.toString()} rows were already ${Te.verb})`),q.current=null),je}finally{_e()&&(h(0),Ne.refetch())}},Oe=I=>{S(I),h(0)},Be=$t(()=>f===null?[]:r?.(f)??[],[r,f]),Ee=vs(ue,y,Oe,Be),ot={filters:Fe(N),orderBy:it(y),search:W,shard:p,table:f??void 0},st=qe.data?.total,lt=st!==void 0,Lt=st??(ue===null?0:g+ue.rows.length),bn=g>0,hn=W!==""||Fe(N).length>0,xn=ue!==null&&(lt?g+ue.rows.length<Lt:ue.rows.length===u),vn=ue===null||ue.rows.length===0?0:g+1,wn=ue===null?0:g+ue.rows.length,yn=()=>{de.refetch()},Cn=()=>{v("table")},Sn=()=>{v("json")},Nn=()=>{Ce(Z(sl,{filters:Fe(N),search:W,table:f},tn))},kn=()=>{Ce(Z(ll,{table:f},tn))},Tn=I=>{Ce(Z(rl,{doc:I,filters:Fe(N),search:W,table:f},bl))},En=I=>{k(I.target.value),h(0)},_n=I=>{w(I),h(0)},Rn=()=>{A(null);const I={};for(const z of ue?.columns??[])Vt.has(z)||(I[z]="");O({docText:JSON.stringify(I,null,2),id:""})},$n=I=>{O(z=>z===null?z:{docText:I,id:z.id})},Dn=()=>{D!==null&&Ce(M(D.id===""?"insert":"patch",D.id===""?null:D.id,D.docText))},An=()=>{O(null),A(null)},Pn=()=>{Qe(g-u)},In=()=>{Qe(g+u)},On=I=>{Qe(Math.max(0,(I-1)*u))},Fn=I=>{m(I),h(0)},Mn=(I,z)=>{A(null),O({docText:JSON.stringify(rn(il(z)),null,2),id:I})},Vn=I=>{Ce(M("delete",I))},Ln=async I=>{if(!(f===null||I.length===0)){A(null);try{for(const z of I)await i.query(Rt,{id:z,op:"delete",table:f},Re(j));Ne.refetch()}catch(z){A(z.message)}}},Bn=I=>{Ce(Ln(I))},jn=()=>{Ce(wt())};return{addRow:Rn,bulkDelete:Nn,bulkPatch:Tn,cancelCellEdit:vt,cancelEdit:An,changePageSize:Fn,clearTable:kn,columns:ue?.columns??[],committing:H,currentView:ot,discardStaged:yt,editableColumn:ml,editing:D,editingCell:J,facetFilter:nt,facets:F,filter:C,filters:N,goNext:In,goPrevious:Pn,hasNext:xn,hasPredicate:hn,hasPrevious:bn,jumpToPage:On,liveError:Ge,loadTables:yn,navigateToRef:mt,onBulkDeleteSelected:Bn,onCommitStaged:jn,onFilterChange:En,onFiltersChange:_n,onRowDelete:Vn,onRowEdit:Mn,page:ue,previewRef:gt,pageError:ke,pageSize:u,rangeEnd:wn,rangeStart:vn,queryShardKey:j,saveEdit:Dn,selectedTable:f,selectTable:He,setEditorDocumentText:$n,setShardKey:Ct,shardKey:p,showJson:Sn,showTable:Cn,stage:P.stage,stagedChanges:St,stagedValue:P.stagedValue,startCellEdit:xt,table:Ee,tables:te,tablesError:De,toggleFacet:pt,total:Lt,totalKnown:lt,viewMode:x,writeError:V,writeNotice:L}},xl="lunora-studio-pinned-columns",vl=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=nn(xl,c),a=t??"",i=l[a];let u;e[1]!==o||e[2]!==i?(u=i===void 0?new Set((o??"").split(",").filter(wl)):new Set(i),e[1]=o,e[2]=i,e[3]=u):u=e[3];const m=u;let p;e[4]!==a||e[5]!==m||e[6]!==r?(p=T=>{r(F=>{const R=F[a]??[...m],_=R.includes(T)?R.filter(D=>D!==T):[...R,T];return{...F,[a]:_}})},e[4]=a,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[f,g]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(yl)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N}=Qn(v);let w;return e[12]!==y||e[13]!==S||e[14]!==C||e[15]!==k||e[16]!==N||e[17]!==b||e[18]!==m||e[19]!==f?(w={maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N,onTogglePin:b,onToggleTranspose:x,pinnedColumns:m,transposed:f},e[12]=y,e[13]=S,e[14]=C,e[15]=k,e[16]=N,e[17]=b,e[18]=m,e[19]=f,e[20]=w):w=e[20],w};function wl(s){return s!==""}function yl(s){return!s}const Cl=$e(he.describeTable),Sl=$e(he.readTablePage),Nl=$e(he.importShard),kl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},Tl=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},El=s=>{const e=ut(),[n,o]=$(!1),[t,c]=$(void 0),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$({}),[p,b]=$(!1),[f,g]=$(void 0),h=async(S,C)=>{o(!0),c(S),r(C),i(void 0),m({}),g(void 0),b(!0);try{const k=await e.query(Cl,{table:S},Re(C)),{columns:N}=k;i(N);const w={},T=N.filter(F=>F.ref!==void 0&&F.type==="id"&&F.pk!==!0);for(const F of T){if(F.ref===void 0)continue;const{ref:R}=F;if(w[R]===void 0)try{const _=await e.query(Sl,{filters:[],limit:qs,offset:0,search:"",table:R},Re(C));w[R]=_.rows.flatMap(D=>kl(D)||[])}catch{w[R]=[]}}m(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),m({}),g(void 0)},columnMeta:a,error:f,fkPools:u,insertBatch:async(S,C)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(Nl,{rows:S.map(w=>({doc:w,table:t}))},Re(l)),N=Tl(k);return N.error!==void 0||(C(),s()),N}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(S,C)=>{Ce(h(S,C))},shardKey:l,table:t}},_l=s=>{const e=B(6),[n,o]=$(null);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{o(null)},e[0]=t):t=e[0];const c=t,[l,r]=$(null);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h,x)=>{r({column:g,storedValue:x,value:h})},e[1]=a):a=e[1];const i=a;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{r(null)},e[2]=u):u=e[2];const m=u,[p,b]=$(s);p!==s&&(b(s),o(null),r(null));let f;return e[3]!==l||e[4]!==n?(f={closeExpandedCell:m,closeInspect:c,expandedCell:l,inspecting:n,onExpandCell:i,onInspect:o},e[3]=l,e[4]=n,e[5]=f):f=e[5],f},Rl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,$l=(s,e)=>typeof e=="number"&&Rl.test(s),Dl=s=>{const e=B(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=Me(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let f;return e[10]!==a||e[11]!==m||e[12]!==p||e[13]!==b?(f=E("button",{"data-testid":m,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=m,e[12]=p,e[13]=b,e[14]=f):f=e[14],f}if($l(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=Wn(l),e[17]=l,e[18]=b):b=e[18];let f;return e[19]!==m||e[20]!==p||e[21]!==b?(f=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=f):f=e[22],f}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const m=`rd-bytes-${n}`;let p;e[23]!==l?(p=Me(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==m||e[26]!==p?(b=d("span",{"data-testid":m,children:p}),e[25]=m,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let m;e[28]!==l?(m=JSON.stringify(l,on,2),e[28]=l,e[29]=m):m=e[29];let p;return e[30]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[30]=m,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=Me(l),e[32]=l,e[33]=i):i=e[33];let u;return e[34]!==i?(u=d("span",{children:i}),e[34]=i,e[35]=u):u=e[35],u},Al=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=u):u=e[3];let m;e[4]!==t?(m=E("div",{className:"mb-3 flex items-center justify-between",children:[u,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(Dl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let f;return e[19]!==t||e[20]!==m||e[21]!==b?(f=E(ft,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=f):f=e[22],f},Pl=50,Il=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Ol=({onFetchTables:s,onSelect:e})=>{const n=ve(),[o]=$(()=>Eo()),[t,c]=$(!1),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$(!1),[p,b]=$(void 0),f=Ke(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),m(!0),f.current+=1;const y=f.current;try{const S=await s(v);f.current===y&&i(S?.slice(0,Pl))}catch(S){f.current===y&&b(S.message)}f.current===y&&m(!1)},x=v=>{Ce(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(Il,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),u&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!u&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!u&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},Fl="lunora-studio-back-relations",Ml=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Vl=(s,e)=>s==null||typeof s=="string"||typeof s=="number"&&Number.isFinite(s)||typeof s=="boolean"||typeof s=="bigint"&&e==="bigint",Ll=(s,e)=>e===null&&(s==="eq"||s==="ne")?{literal:[null],value:"null"}:typeof e!="string"&&typeof e!="number"&&typeof e!="boolean"?{value:""}:typeof e=="string"&&(s==="eq"||s==="ne")?{literal:[e],value:e}:s!=="has"&&typeof e!="boolean"?{value:String(e)}:{literal:[e],value:typeof e=="string"?`"${e}"`:String(e)},Bl={},jl=50,zl=[],ql=$e(he.listTables),Kl=$e(he.readTablePage),Gl=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Gn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d(Ol,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},Nr=({canGenerateRows:s=!1,editable:e=!1,globalTableNames:n,initialFilters:o,initialOrderBy:t,initialPins:c,initialSearch:l,initialShardKey:r,onNavigateToGlobal:a,onSelectTable:i,onViewChange:u,pageSize:m=jl,queryBar:p,schemaSwitch:b,tableParam:f})=>{const g=Ze(he.describeTables,{},{shardKey:r??""}),h=Ze(he.listTablesIndexes,{},{shardKey:r??""}),x=g.data?.columnsByTable??Bl,[v,y]=nn(Fl,{}),S=ct(M=>{const Z=new Set(v[M]);return Jt(M,x).filter(Oe=>Z.has(Ot(Oe)))},[v,x]),C=hl({initialFilters:o,initialOrderBy:t,initialSearch:l,initialShardKey:r,onSelectTable:i,onViewChange:u,pageSize:m,resolveBackRelations:S,tableParam:f}),{cancelCellEdit:k,columns:N,currentView:w,editableColumn:T,editingCell:F,facetFilter:R,facets:_,loadTables:D,navigateToRef:O,onFiltersChange:V,page:A,pageError:L,previewRef:G,queryShardKey:q,selectedTable:P,selectTable:J,setShardKey:K,shardKey:H,stage:Y,stagedValue:U,startCellEdit:ne,tables:le,tablesError:ae,toggleFacet:ge}=C,fe=Zn(H),me=Xe(P),pe=M=>{const Z=P;Ce((async()=>{const Be=await fe.suggestFilter(M,Z??"");Be!==void 0&&me.current===Z&&V(Be.map(Ee=>{const{literal:ot,value:st}=Ll(Ee.operator,Ee.value),lt=Ee.path===void 0||Ee.path.length===0?{}:{path:Ee.path.join("."),pathSegments:Ee.path};return{column:Ee.column,operator:Ee.operator,...lt,...ot===void 0?{}:{literal:ot},value:st}}))})())},ie=P===null?[]:Jt(P,x),Q=new Set(v[P??""]),be=[];for(const M of A?.rows??[]){const Z=M._id??M.id;typeof Z=="string"&&Z!==""&&be.push(Z)}const ce=Ys(Q,ie,be,q),Se=M=>{y(Z=>{const Oe=P??"",Be=Z[Oe]??[];return{...Z,[Oe]:Be.includes(M)?Be.filter(Ee=>Ee!==M):[...Be,M]}})},oe=vl({columns:N,initialPins:c,selectedTable:P}),se=_l(JSON.stringify([P,q])),[W,j]=$(null),{closeExpandedCell:re,closeInspect:X,expandedCell:ee,inspecting:we,onExpandCell:xe}=se,de=ut(),te=Object.fromEntries((x[P??""]??[]).map(M=>[M.name,M])),De=new Map;for(const M of x[P??""]??[])M.isStorage===!0&&De.set(M.name,M.bucket);const Ve=ct(async(M,Z)=>de.signedStorageUrl(M,Z===void 0?{}:{bucket:Z}),[de]),Le=async M=>await de.query(ql,{},Re(M)),Ne=()=>{P!==null&&J(P)},{closeDialog:ue,columnMeta:ke,fkPools:Ge,insertBatch:qe,open:He,openDialog:mt}=El(Ne),gt=()=>{P!==null&&mt(P,H)},tt=M=>qe(M,ue),[pt,nt]=$(!1),bt=()=>{nt(!0)},ht=()=>{nt(!1)},Ue=(M,Z)=>{if(a!==void 0&&n?.has(M)===!0){a(M,Z);return}O(M,Z)},Qe=p?.onSaveQuery,xt=M=>{Qe?.(M,w)},vt={cancelEdit:k,editable:e,editableColumn:T,editingCell:F,onExpandCell:xe,stage:Y,stagedValue:U,startEdit:ne},wt=M=>{M!==null&&j(M)},yt=()=>{C.onRowDelete(W)},Ct=async(M,Z,Oe)=>await de.query(Kl,{filters:[{column:Z,operator:"eq",value:Oe}],limit:at,offset:0,orderBy:[],table:M},Re(q)),St={columns:A?.refs,maskViewFor:oe.maskViewFor,onNavigate:Ue,onPreview:G};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Yn,{header:d(Gl,{onFetchShardTables:Le,onShardChange:K,schemaSwitch:b,shardKey:H}),onReload:D,onSelect:J,prefix:"db",selected:P,tables:le??zl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ae!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ae}),A===null&&L===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),L!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:L}),A!==null&&d(js,{assistant:fe,backRelations:{available:ie,counts:ce,enabled:Q,onToggle:Se},browser:C,columnMeta:te,edit:vt,editable:e,onAskAiFilter:pe,onInspect:se.onInspect,onOpenBulkPatch:bt,onOpenGenerateRows:s?gt:void 0,onRowDelete:wt,onSaveQuery:xt,page:A,preferences:oe,queryBar:p,references:St})]}),A!==null&&d(Xn,{columns:N,facets:_,mask:oe.maskView,onFacetFilter:R,onToggleFacet:ge}),we!==null&&A!==null&&d(Al,{columns:A.columns,mask:oe.maskView,onClose:X,onNavigate:Ue,refs:A.refs,row:sn(we,oe.maskView)}),W!==null&&P!==null&&d(Bo,{onClose:()=>{j(null)},onConfirm:yt,readPage:Ct,rowId:W,schema:_o(x),table:P}),ee!==null&&d(No,{bucket:De.get(ee.column),column:ee.column,onClose:re,onFilter:Vl(ee.storedValue,te[ee.column]?.type)?()=>{R(ee.column,ee.storedValue??null),re()}:void 0,resolveUrl:De.has(ee.column)?Ve:void 0,value:ee.value}),pt&&P!==null&&d(Do,{columns:C.columns.filter(M=>C.editableColumn(M)),onApply:C.bulkPatch,onClose:ht,shardKey:C.queryShardKey,table:P,total:C.total,uniqueColumns:Ml(h.data?.indexesByTable[P])}),He&&P!==null&&ke!==void 0&&d(Us,{columns:ke,fkPools:Ge,onClose:ue,onInsertRows:tt,table:P})]})};export{Nr as DataBrowser};
4
+ `),r=[];let a=0;for(const[i,u]of l.entries()){const m=t[s.row+i],p=m===void 0?null:Ie(m),b=u.split(" ");if(m===void 0||p===null){a+=b.length;continue}for(const[f,g]of b.entries()){const h=e[s.col+f],x=h===void 0||!o(h)?void 0:ls(g,m[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},mn=(s,e)=>Ie(s)??`row-${e.toString()}`,as=8,is=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=ve();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let u;e[3]!==c?(u=c("Loading…"),e[3]=c,e[4]=u):u=e[4];let m;e[5]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[5]=u,e[6]=m):m=e[6],a=m}else if(t.row===null){let u;e[7]!==c?(u=c("No matching row."),e[7]=c,e[8]=u):u=e[8];let m;e[9]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10],a=m}else{let u;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(sn(t.row,o)).slice(0,as);u=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(ws)}),e[11]=o,e[12]=t.row,e[13]=u}else u=e[13];a=u}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},cs=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=$(null),[u,m]=$("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let f;e[4]!==o||e[5]!==l||e[6]!==u||e[7]!==r?(f=N=>{const w=N.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),u!=="idle")return;m("loading"),Ce((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=u,e[7]=r,e[8]=f):f=e[8];const g=f;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let S;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(S=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=S):S=e[15];let C;e[16]!==a||e[17]!==t||e[18]!==u||e[19]!==r?(C=a!==null&&u!=="idle"&&d(is,{anchor:a,mask:t(r,u==="loading"||u.row===null?[]:Object.keys(u.row)),state:u}),e[16]=a,e[17]=t,e[18]=u,e[19]=r,e[20]=C):C=e[20];let k;return e[21]!==S||e[22]!==C?(k=E(et,{children:[S,C]}),e[21]=S,e[22]=C,e[23]=k):k=e[23],k},ds=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",us="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",Qt=s=>{const e=B(9),{column:n,onExpand:o,storedValue:t,value:c}=s;let l;e[0]!==n||e[1]!==o||e[2]!==t||e[3]!==c?(l=()=>{o(n,c,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c,e[4]=l):l=e[4];const r=l,a=`db-expand-${n}`;let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[5]=i):i=e[5];let u;return e[6]!==r||e[7]!==a?(u=d("button",{"aria-label":"Expand cell",className:us,"data-testid":a,onClick:r,type:"button",children:i}),e[6]=r,e[7]=a,e[8]=u):u=e[8],u},fs=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Ke(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),ze(a,i);let u;e[2]!==t||e[3]!==c?(u=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=u):u=e[4];const m=u;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,f=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=Me(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==f||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":f,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=f,e[13]=g,e[14]=h):h=e[14],h},ms=s=>{const e=B(71),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,u,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Ie(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,D=d(Tt,{value:Un(i,r,c)});let O;e[12]!==_||e[13]!==D?(O=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:D}),e[12]=_,e[13]=D,e[14]=O):O=e[14],m=O;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),D=`${R}:${String(i)}`;let O;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==D||e[21]!==R?(O=d(cs,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},D),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=D,e[21]=R,e[22]=O):O=e[22],m=O;break e}if(a===null){let _;e[23]!==i?(_=d(Tt,{value:i}),e[23]=i,e[24]=_):_=e[24];let D;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?(D=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=D):D=e[28];let O;e[29]!==_||e[30]!==D?(O=E(et,{children:[_,D]}),e[29]=_,e[30]=D,e[31]=O):O=e[31],m=O;break e}u=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=u,e[11]=m}else a=e[8],i=e[9],u=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=u,b=p===void 0?i:p.value;let f;e[32]!==r||e[33]!==o?(f=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=f):f=e[34];const g=f;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=D=>{o.stage(a,r,dn(D,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(fs,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const y=v,S=x,C=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=ts(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=k):k=e[54];let N;e[55]!==b||e[56]!==k?(N=d(Tt,{highlight:k,value:b}),e[55]=b,e[56]=k,e[57]=N):N=e[57];let w;e[58]!==x||e[59]!==y||e[60]!==C||e[61]!==N?(w=d("span",{className:S,"data-testid":C,onDoubleClick:y,children:N}),e[58]=x,e[59]=y,e[60]=C,e[61]=N,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell||e[66]!==i?(T=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=i,e[67]=T):T=e[67];let F;return e[68]!==T||e[69]!==w?(F=E(et,{children:[w,T]}),e[68]=T,e[69]=w,e[70]=F):F=e[70],F},gs=s=>{s.preventDefault()},Yt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},ps=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,u=n.column.id;if(e.current=null,i===null||i===u)return;const m=l.atoms.columnOrder.get(),b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),f=b.indexOf(u);b.splice(f===-1?b.length:f,0,i),l.setColumnOrder(b)};return E("th",{className:dt("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),"data-testid":`db-head-${n.column.id}`,draggable:!0,onDragOver:gs,onDragStart:r,onDrop:a,style:c===void 0?Ft(n.getSize()):fn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[ho(n.column.columnDef.header,n.getContext()),ds(n.column.getIsSorted())]}),s!==void 0&&Yt[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Yt[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:dt("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},bs=s=>{const e=B(13),{table:n}=s,o=ve();let t;e[0]!==n?(t=u=>{n.toggleAllRowsSelected(u)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:un,children:d(It,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},hs=s=>{const e=B(17),{row:n}=s,o=ve();let t;e[0]!==n.original?(t=Ie(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=f=>{n.toggleSelected(f)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let u;e[8]!==n.index||e[9]!==n.original?(u=mn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=u):u=e[10];const m=`db-select-${u}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:un,children:d(It,{"aria-label":a,checked:i,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},xs=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:u,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:f}=s,g=ve(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:S,tbodyStyle:C,viewportWidth:k,virtualRows:N}=f,w=Ke(null),[T,F]=$(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,D]=$(R);let O;e[1]!==y?(O=y.getVisibleLeafColumns(),e[1]=y,e[2]=O):O=e[2];const V=O.length;let A;e[3]!==T||e[4]!==V||e[5]!==o||e[6]!==y||e[7]!==S?(A=re=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(re.key))return;re.preventDefault();const X=T??{col:0,row:0};if(re.key==="Enter"){const xe=S[X.row],de=y.getVisibleLeafColumns()[X.col];if(xe!==void 0&&de!==void 0){const te=Ie(xe.original);te!==null&&o.editableColumn(de.id)&&o.startEdit(te,de.id)}F(X);return}let{col:ee,row:we}=X;e:switch(re.key){case"ArrowDown":{we=Math.min(we+1,S.length-1);break e}case"ArrowRight":{ee=Math.min(ee+1,V-1);break e}case"ArrowUp":{we=Math.max(we-1,0);break e}default:ee=Math.max(ee-1,0)}F({col:ee,row:we})},e[3]=T,e[4]=V,e[5]=o,e[6]=y,e[7]=S,e[8]=A):A=e[8];const L=A;let G;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==S?(G=re=>{const X=o.editable?re.clipboardData.getData("text/plain"):"";if(X==="")return;re.preventDefault();const ee=y.getVisibleLeafColumns().map(ys),we=rs({anchor:T??{col:0,row:0},columnIds:ee,columnMeta:n,editableColumn:o.editableColumn,rows:S.map(Cs),text:X});for(const xe of we.edits)o.stage(xe.rowId,xe.column,xe.value);D({columns:ee.join("\0"),count:we.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=S,e[14]=G):G=e[14];const q=G;let P,J;e[15]!==T||e[16]!==v?(P=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=P,e[18]=J):(P=e[17],J=e[18]),ze(P,J);let K,H,Y,U,ne,le,ae,ge,fe,me,pe,ie,Q,be,ce,Se;if(e[19]!==T||e[20]!==h||e[21]!==u||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==L||e[30]!==q||e[31]!==a||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==S||e[41]!==C||e[42]!==k||e[43]!==N){const re=y.getVisibleLeafColumns().map(Ss),X=jo(re,p,x,k),ee=zo(y.getVisibleLeafColumns().map(Ns),p),we=te=>{const De=S[te.index],{original:Ve}=De,Le=Ie(Ve),Ne=mn(Ve,te.index),ue={...Xo,height:`${te.size.toString()}px`,transform:`translateY(${te.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ue,children:[d(hs,{row:De}),X.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),De.getVisibleCells().map((ke,Ge)=>{if(!X.ids.has(ke.column.id))return null;const qe=ee.get(ke.column.id),He=T!==null&&T.row===te.index&&T.col===Ge?" ring-1 ring-ring ring-inset":"";return d("td",{className:dt("group/cell truncate font-mono text-muted-foreground",qe!==void 0&&"border-e border-border bg-background",He),onPointerDown:()=>{F({col:Ge,row:te.index})},style:qe===void 0?Ft(ke.column.getSize()):fn(ke.column.getSize(),qe),children:ke.column.id.startsWith(At)?d(os,{counts:u[ke.column.id.slice(At.length)],rowId:Ne}):d(ms,{cell:ke,edit:o,highlight:i,mask:c,refs:b})},ke.id)}),X.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:Ut,children:[d("button",{className:Et,"data-testid":`db-inspect-${Ne}`,onClick:()=>{a(Ve)},type:"button",children:"Details"}),t&&E(et,{children:[d("button",{className:Et,"data-testid":`db-edit-${Ne}`,disabled:Le===null,onClick:()=>{r(Le,Ve)},type:"button",children:"Edit"}),d("button",{className:Et,"data-testid":`db-delete-${Ne}`,disabled:Le===null,onClick:()=>{l(Le)},type:"button",children:"Delete"})]})]})]},De.id)};K=wo,ie="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Q=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ks).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Q):Q=e[64],ne="db-scroll",le=L,ae=q,ge=h,fe="grid",me=Uo,pe=0,Se="w-full text-xs",H="db-rows",Y=Qo;let xe;e[65]!==y?(xe=d(bs,{table:y}),e[65]=y,e[66]=xe):xe=e[66];let de;e[67]===Symbol.for("react.memo_cache_sentinel")?(de=d("th",{"aria-label":"Row actions",style:Ut}),e[67]=de):de=e[67],U=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Zo,children:[xe,X.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),y.getFlatHeaders().map(te=>X.ids.has(te.column.id)?d(ps,{declaredType:n?.[te.column.id]?.type,draggedRef:w,header:te,masked:c.columns.has(te.column.id),onTogglePin:m,pinnedOffset:ee.get(te.column.id),table:y},te.id):null),X.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),de]})}),be=C,ce=N.map(te=>we(te)),e[19]=T,e[20]=h,e[21]=u,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=L,e[30]=q,e[31]=a,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=S,e[41]=C,e[42]=k,e[43]=N,e[44]=K,e[45]=H,e[46]=Y,e[47]=U,e[48]=ne,e[49]=le,e[50]=ae,e[51]=ge,e[52]=fe,e[53]=me,e[54]=pe,e[55]=ie,e[56]=Q,e[57]=be,e[58]=ce,e[59]=Se}else K=e[44],H=e[45],Y=e[46],U=e[47],ne=e[48],le=e[49],ae=e[50],ge=e[51],fe=e[52],me=e[53],pe=e[54],ie=e[55],Q=e[56],be=e[57],ce=e[58],Se=e[59];let oe;e[68]!==be||e[69]!==ce?(oe=d("tbody",{style:be,children:ce}),e[68]=be,e[69]=ce,e[70]=oe):oe=e[70];let se;e[71]!==H||e[72]!==Y||e[73]!==U||e[74]!==oe||e[75]!==Se?(se=E("table",{className:Se,"data-testid":H,style:Y,children:[U,oe]}),e[71]=H,e[72]=Y,e[73]=U,e[74]=oe,e[75]=Se,e[76]=se):se=e[76];let W;e[77]!==ne||e[78]!==le||e[79]!==ae||e[80]!==ge||e[81]!==fe||e[82]!==me||e[83]!==pe||e[84]!==se?(W=d("div",{"data-testid":ne,onKeyDown:le,onPaste:ae,ref:ge,role:fe,style:me,tabIndex:pe,children:se}),e[77]=ne,e[78]=le,e[79]=ae,e[80]=ge,e[81]=fe,e[82]=me,e[83]=pe,e[84]=se,e[85]=W):W=e[85];let j;return e[86]!==K||e[87]!==ie||e[88]!==Q||e[89]!==W?(j=E(K,{layout:ie,children:[Q,W]}),e[86]=K,e[87]=ie,e[88]=Q,e[89]=W,e[90]=j):j=e[90],j},vs=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=$t(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:F=>F[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:ns(T)});return w},[o,t,l]),a=$t(()=>c??[],[c]),[i,u]=$({}),[m,p]=$({}),b=bo({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Ie(w.original)!==null,features:qo,getRowId:(w,T)=>Ie(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:u,onSortingChange:n,state:{columnVisibility:m,rowSelection:i,sorting:e}}),f=b.getRowModel().rows,g=Ke(null),h=xo({count:f.length,estimateSize:()=>Ho,getScrollElement:()=>g.current,initialRect:{height:Ht,width:0},observeElementRect:(w,T)=>vo(w,T,Ht),overscan:8}),x=ct(w=>{h.scrollToIndex(w)},[h]),[v,y]=$({left:0,width:0}),S=ct(w=>{if(g.current=w,w===null)return;const T=()=>{y(R=>R.left===w.scrollLeft&&R.width===w.clientWidth?R:{left:w.scrollLeft,width:w.clientWidth})};w.addEventListener("scroll",T,{passive:!0});const F=new ResizeObserver(T);return F.observe(w),()=>{w.removeEventListener("scroll",T),F.disconnect(),g.current=null}},[]),C=h.getVirtualItems(),N={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:S,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:N,viewportWidth:v.width,virtualRows:C}};function ws(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Me(n),children:Me(n)})]},e)}function ys(s){return s.id}function Cs(s){return s.original}function Ss(s){return{getSize:()=>s.getSize(),id:s.id}}function Ns(s){return{getSize:()=>s.getSize(),id:s.id}}function ks(s){return s.id}const Ts=s=>{const e=B(22),{onCommit:n}=s,o=ve(),[t,c]=$(""),l=Ke(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),ze(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=y=>{c(y.target.value)},e[2]=i):i=e[2];const u=i;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Query name"),e[8]=o,e[9]=f):f=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==f?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:u,placeholder:f,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=f,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:Dt,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},Es=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=ve(),[a,i]=$(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{i(!0)},e[0]=u):u=e[0];const m=u;let p;e[1]!==c?(p=N=>{c(N),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let f;e[3]!==n||e[4]!==l?(f=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=f):f=e[5];const g=f;let h;e[6]!==t||e[7]!==l?(h=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&t(w.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:Dt,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let S;e[14]!==b||e[15]!==a||e[16]!==r?(S=a?d(Ts,{onCommit:b}):d("button",{className:Dt,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=S):S=e[17];let C;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(C=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((N,w)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":w,"data-testid":`db-saved-query-${N.name}`,onClick:g,type:"button",children:N.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:N.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":w,"data-testid":`db-saved-query-delete-${N.name}`,onClick:x,type:"button",children:"✕"})]},N.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=C):C=e[22];let k;return e[23]!==y||e[24]!==S||e[25]!==C?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,S,C]}),e[23]=y,e[24]=S,e[25]=C,e[26]=k):k=e[26],k},We="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",gn=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Xt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?gn.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",_s=(s,e,n)=>n===void 0?Xt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?gn.test(s)?"date":"number":Xt(s,e),Rs=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},$s=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Je="\0clear",Ds=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=ve();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Je?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const u=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let S;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(S=d(It,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=S):S=e[10],S}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Je;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let f;e[13]!==b?(f=d("option",{value:Je,children:b}),e[13]=b,e[14]=f):f=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==f?(x=E("select",{"aria-label":n,className:We,"data-testid":m,onChange:u,value:p,children:[f,g,h]}),e[17]=n,e[18]=u,e[19]=m,e[20]=p,e[21]=f,e[22]=x):x=e[22],x},As=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=ve(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const u=i;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Je?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,f=a??Je;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Je,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==u?(h=u&&d("option",{value:a,children:a}),e[10]=a,e[11]=u,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(Ls),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==f||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:We,"data-testid":b,onChange:p,value:f,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=f,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},Ps=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=Number(u.target.value);u.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Is=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=new Date(u.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?$s(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},Os=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{o(n,u.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Fs=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=ve();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=$(l),[i,u]=$(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const S=y.target.value;a(S);try{o(n,JSON.parse(S)),u(!1)}catch{u(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=i&&"border-destructive";let f;e[5]!==b?(f=dt(We,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==f||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:f,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=f,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},Ms=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=_s(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let u;e[4]!==n?(u=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==u||e[12]!==m||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[u,m,p]}),e[11]=u,e[12]=m,e[13]=p,e[14]=b):b=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(f=a==="boolean"&&d(Ds,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=f):f=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(As,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(Ps,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(Is,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(Fs,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(y=a==="text"&&d(Os,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=y):y=e[46];let S;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==f||e[53]!==g||e[54]!==h?(S=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,f,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=f,e[53]=g,e[54]=h,e[55]=S):S=e[55],S},Vs=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=ve();let i;e[0]!==o?(i=Rs(o),e[0]=o,e[1]=i):i=e[1];const u=i,[m,p]=$(!1),b=!m&&u!==null;let f;e[2]!==u||e[3]!==c?(f=(P,J)=>{c(JSON.stringify({...u,[P]:J},null,2))},e[2]=u,e[3]=c,e[4]=f):f=e[4];const g=f;let h;e[5]!==c?(h=P=>{c(P.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p(!0)},e[8]=S):S=e[8];const C=S,k=u===null;let N;e[9]!==a?(N=a("Form"),e[9]=a,e[10]=N):N=e[10];let w;e[11]!==b||e[12]!==k||e[13]!==N?(w=d("button",{"aria-pressed":b,className:Pe,"data-testid":"db-editor-form",disabled:k,onClick:y,type:"button",children:N}),e[11]=b,e[12]=k,e[13]=N,e[14]=w):w=e[14];const T=!b;let F;e[15]!==a?(F=a("JSON"),e[15]=a,e[16]=F):F=e[16];let R;e[17]!==F||e[18]!==T?(R=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-editor-json",onClick:C,type:"button",children:F}),e[17]=F,e[18]=T,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==w?(_=E("div",{className:"flex items-center gap-1.5",children:[w,R]}),e[20]=R,e[21]=w,e[22]=_):_=e[22];let D;e[23]!==n||e[24]!==o||e[25]!==u||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?(D=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(u).map(P=>{const[J,K]=P;return d(Ms,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:K},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=u,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=D):D=e[31];let O;e[32]!==a?(O=a("Save"),e[32]=a,e[33]=O):O=e[33];let V;e[34]!==l||e[35]!==O?(V=d("button",{className:Pe,"data-testid":"db-editor-save",onClick:l,type:"button",children:O}),e[34]=l,e[35]=O,e[36]=V):V=e[36];let A;e[37]!==a?(A=a("Cancel"),e[37]=a,e[38]=A):A=e[38];let L;e[39]!==t||e[40]!==A?(L=d("button",{className:Pe,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:A}),e[39]=t,e[40]=A,e[41]=L):L=e[41];let G;e[42]!==V||e[43]!==L?(G=E("div",{className:"flex items-center gap-1.5",children:[V,L]}),e[42]=V,e[43]=L,e[44]=G):G=e[44];let q;return e[45]!==_||e[46]!==D||e[47]!==G?(q=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,D,G]}),e[45]=_,e[46]=D,e[47]=G,e[48]=q):q=e[48],q};function Ls(s){return d("option",{value:s,children:s},s)}const Bs=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:u,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:f,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:S,total:C,totalKnown:k,viewMode:N}=s,w=ve(),T=N==="table";let F;e[0]!==y||e[1]!==T?(F=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=T,e[2]=F):F=e[2];const R=N==="json";let _;e[3]!==v||e[4]!==R?(_=d("button",{"aria-pressed":R,className:Pe,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=R,e[5]=_):_=e[5];let D;e[6]!==a||e[7]!==w?(D=a===void 0?w("Live — changes stream in automatically"):w("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=w,e[8]=D):D=e[8];const O=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let V;e[9]!==O?(V=d("span",{"aria-hidden":"true",className:O}),e[9]=O,e[10]=V):V=e[10];let A;e[11]!==a||e[12]!==w?(A=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=A):A=e[13];let L;e[14]!==D||e[15]!==V||e[16]!==A?(L=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:D,children:[V,A]}),e[14]=D,e[15]=V,e[16]=A,e[17]=L):L=e[17];let G;e[18]!==l||e[19]!==i||e[20]!==S||e[21]!==w?(G=l&&d("button",{"aria-pressed":i,className:Pe,"data-testid":"db-mask-toggle",onClick:S,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=S,e[21]=w,e[22]=G):G=e[22];let q;e[23]!==o||e[24]!==u?(q=o&&d("button",{className:Pe,"data-testid":"db-add-row",onClick:u,type:"button",children:"Add row"}),e[23]=o,e[24]=u,e[25]=q):q=e[25];let P;e[26]!==o||e[27]!==x||e[28]!==w?(P=o&&x!==void 0&&d("button",{className:Pe,"data-testid":"db-generate-rows",onClick:x,type:"button",children:w("Generate rows")}),e[26]=o,e[27]=x,e[28]=w,e[29]=P):P=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==w||e[34]!==C||e[35]!==k?(J=o&&C>0&&r&&d(Kt,{confirmLabel:k?w("Permanently delete {total} matching rows and everything that cascades?",{total:C.toString()}):w("Permanently delete all matching rows and everything that cascades?"),onConfirm:m,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:C.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=m,e[33]=w,e[34]=C,e[35]=k,e[36]=J):J=e[36];let K;e[37]!==o||e[38]!==r||e[39]!==p||e[40]!==w||e[41]!==C||e[42]!==k?(K=o&&k&&C>0&&r&&d("button",{className:Pe,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:C.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=C,e[42]=k,e[43]=K):K=e[43];let H;e[44]!==o||e[45]!==r||e[46]!==f||e[47]!==w||e[48]!==C||e[49]!==k?(H=o&&C>0&&!r&&d(Kt,{confirmLabel:k?w("Permanently clear all {total} rows and everything that cascades?",{total:C.toString()}):w("Permanently clear every row and everything that cascades?"),onConfirm:f,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:C.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=f,e[47]=w,e[48]=C,e[49]=k,e[50]=H):H=e[50];let Y;e[51]!==G||e[52]!==q||e[53]!==P||e[54]!==J||e[55]!==K||e[56]!==H||e[57]!==F||e[58]!==_||e[59]!==L?(Y=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[F,_,L,G,q,P,J,K,H]}),e[51]=G,e[52]=q,e[53]=P,e[54]=J,e[55]=K,e[56]=H,e[57]=F,e[58]=_,e[59]=L,e[60]=Y):Y=e[60];let U;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(U=d(Co,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[61]=n,e[62]=t,e[63]=c,e[64]=b,e[65]=g,e[66]=h,e[67]=U):U=e[67];let ne;return e[68]!==Y||e[69]!==U?(ne=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[Y,U]}),e[68]=Y,e[69]=U,e[70]=ne):ne=e[70],ne},js=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:u,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:f,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let S;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.totalKnown||e[14]!==t.viewMode||e[15]!==r||e[16]!==u||e[17]!==m||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(S=d(Bs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:u,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,totalKnown:t.totalKnown,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.totalKnown,e[14]=t.viewMode,e[15]=r,e[16]=u,e[17]=m,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=S):S=e[22];let C;e[23]!==b||e[24]!==h?(C=h!==void 0&&d(Es,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=C):C=e[25];let k;e[26]!==o||e[27]!==t.onBulkDeleteSelected||e[28]!==t.selectedTable||e[29]!==t.table||e[30]!==t.viewMode||e[31]!==r||e[32]!==f||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&f.rows.length>0&&d(So,{backRelations:o.available,columns:f.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:Nt(f.rows,g.maskView),sqlColumns:f.sqlColumns,table:t.table.table,transposed:g.transposed}),e[26]=o,e[27]=t.onBulkDeleteSelected,e[28]=t.selectedTable,e[29]=t.table,e[30]=t.viewMode,e[31]=r,e[32]=f,e[33]=g.maskView,e[34]=g.onToggleTranspose,e[35]=g.transposed,e[36]=k):k=e[36];let N;e[37]!==t.cancelEdit||e[38]!==t.editing||e[39]!==t.saveEdit||e[40]!==t.setEditorDocumentText||e[41]!==c||e[42]!==r||e[43]!==f?(N=r&&t.editing!==null&&d(Vs,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:f.refs}),e[37]=t.cancelEdit,e[38]=t.editing,e[39]=t.saveEdit,e[40]=t.setEditorDocumentText,e[41]=c,e[42]=r,e[43]=f,e[44]=N):N=e[44];let w;e[45]!==t.committing||e[46]!==t.discardStaged||e[47]!==t.onCommitStaged||e[48]!==t.stagedChanges||e[49]!==r?(w=r&&t.stagedChanges.length>0&&d(Go,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[45]=t.committing,e[46]=t.discardStaged,e[47]=t.onCommitStaged,e[48]=t.stagedChanges,e[49]=r,e[50]=w):w=e[50];let T;e[51]!==t.writeError?(T=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[51]=t.writeError,e[52]=T):T=e[52];let F;e[53]!==t.writeNotice?(F=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[53]=t.writeNotice,e[54]=F):F=e[54];let R;e[55]!==S||e[56]!==C||e[57]!==k||e[58]!==N||e[59]!==w||e[60]!==T||e[61]!==F?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[S,C,k,N,w,T,F]}),e[55]=S,e[56]=C,e[57]=k,e[58]=N,e[59]=w,e[60]=T,e[61]=F,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==f?(_=t.viewMode==="table"&&f.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(no,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[63]=t.viewMode,e[64]=f,e[65]=_):_=e[65];let D;e[66]!==t.viewMode||e[67]!==f||e[68]!==g.maskView||e[69]!==g.transposed?(D=t.viewMode==="table"&&f.rows.length>0&&g.transposed&&d(yo,{columns:f.columns,rows:Nt(f.rows,g.maskView)}),e[66]=t.viewMode,e[67]=f,e[68]=g.maskView,e[69]=g.transposed,e[70]=D):D=e[70];let O;e[71]!==o||e[72]!==t.filter||e[73]!==t.onRowEdit||e[74]!==t.table||e[75]!==t.viewMode||e[76]!==c||e[77]!==l||e[78]!==r||e[79]!==i||e[80]!==p||e[81]!==f||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(O=t.viewMode==="table"&&f.rows.length>0&&!g.transposed&&d(xs,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[71]=o,e[72]=t.filter,e[73]=t.onRowEdit,e[74]=t.table,e[75]=t.viewMode,e[76]=c,e[77]=l,e[78]=r,e[79]=i,e[80]=p,e[81]=f,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=O):O=e[87];let V;e[88]!==t.viewMode||e[89]!==f||e[90]!==g.maskView?(V=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(Nt(f.rows,g.maskView),on,2)}),e[88]=t.viewMode,e[89]=f,e[90]=g.maskView,e[91]=V):V=e[91];let A;e[92]!==t.changePageSize||e[93]!==t.goNext||e[94]!==t.goPrevious||e[95]!==t.hasNext||e[96]!==t.hasPrevious||e[97]!==t.jumpToPage||e[98]!==t.pageSize||e[99]!==t.rangeEnd||e[100]!==t.rangeStart||e[101]!==t.total?(A=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(ko,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[92]=t.changePageSize,e[93]=t.goNext,e[94]=t.goPrevious,e[95]=t.hasNext,e[96]=t.hasPrevious,e[97]=t.jumpToPage,e[98]=t.pageSize,e[99]=t.rangeEnd,e[100]=t.rangeStart,e[101]=t.total,e[102]=A):A=e[102];let L;return e[103]!==R||e[104]!==_||e[105]!==D||e[106]!==O||e[107]!==V||e[108]!==A?(L=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,D,O,V,A]}),e[103]=R,e[104]=_,e[105]=D,e[106]=O,e[107]=V,e[108]=A,e[109]=L):L=e[109],L},zs="/__lunora/seed",_t=200,qs=50,Ks=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Gs=s=>Array.isArray(s)&&s.every(e=>ln(e)),Js=async s=>{let e;try{e=await fetch(zs,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${zt(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=Pt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${zt(t)}`}}return Gs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:n.error==="seed-refused"&&typeof n.message=="string"?{kind:"error",message:n.message}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},Ws="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Hs="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Us=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=ve(),[l,r]=$(10),[a,i]=$(!1),[u,m]=$(void 0),[p,b]=$(void 0),[f,g]=$(0),h=C=>{const k=Number(C.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,_t))},x=async()=>{m(void 0),b(void 0),g(0),i(!0);try{const C=await Js({count:l,existingIds:e,seed:Date.now(),table:t});if(C.kind==="error"){m(C.message);return}const{rows:k}=C;if(k.length===0){m(c("No rows generated — all columns were skipped."));return}const N=await o(k);if(N.error!==void 0){m(N.error);return}b(N.inserted),g(N.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},y=s.filter(C=>C.pk!==!0),S=Ks(s,e);return E(ft,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:_t,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:_t.toString()})})]}),y.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(C=>{const k=C.ref!==void 0&&C.type==="id",N=k&&(e[C.ref??""]??[]).length===0,w=N?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",T=N?`gen-rows-fk-empty-${C.name}`:`gen-rows-fk-ok-${C.name}`,F=N?c("FK: no rows in {ref} — seed it first",{ref:C.ref??""}):c("→ {ref}",{ref:C.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:C.name}),E("span",{className:"text-muted-foreground",children:["(",C.type,")"]}),C.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),k&&d("span",{className:w,"data-testid":T,children:F})]},C.name)})})]}),S.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:S.join(", ")})}),u!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:u}),p!==void 0&&u===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:p.toString(),total:(p+f).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:Ws,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:Hs,"data-testid":"gen-rows-generate",disabled:a||S.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Qs=$e(he.backRelationCounts),Ys=(s,e,n,o)=>{const t=B(16),c=ut();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=$(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Ot(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const u=i;let m;t[6]!==n||t[7]!==u?(m=JSON.stringify([u,n]),t[6]=n,t[7]=u,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){x.cancelled||a({});return}try{const S=await c.query(Qs,{ids:y,relations:v},Re(o));x.cancelled||a(Object.fromEntries(S.relations.map(Xs)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const f=b;let g,h;return t[13]!==f?(g=()=>{const x={cancelled:!1};return Ce(f(x)),()=>{x.cancelled=!0}},h=[f],t[13]=f,t[14]=g,t[15]=h):(g=t[14],h=t[15]),ze(g,h),r};function Xs(s){return[Ot(s),s.counts]}const Zs=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},it=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},pn=s=>Me(s),Zt=s=>s.map(e=>({column:e.column,path:(e.path??[]).join("."),...e.path===void 0||e.path.length===0?{}:{pathSegments:e.path},...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":pn(e.value)})),en=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],el=s=>[s.column,s.operator,s.value,s.path??[]],rt=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>el(t)),o===void 0?null:[o.column,o.direction]]),Mt=200,tl=20,nl=$e(he.readTablePage),ol=$e(he.facetColumn),Rt=$e(he.writeRow),sl=$e(he.deleteRows),ll=$e(he.clearTable),rl=$e(he.patchRows),al={},Vt=new Set(["__doc__","__id__","_creationTime","_id","id"]),il=s=>{const e=s.__doc__;if(typeof e=="string"){const o=eo(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Vt.has(o)||(n[o]=t);return n},cl=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,rn(e)]),dl=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Fe(s),limit:n,offset:e,orderBy:it(t),search:o,skipCount:!0,table:c}),ul=({filters:s,search:e,table:n})=>({filters:Fe(s),limit:1,search:e,table:n}),fl=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ie(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},ml=s=>!Vt.has(s),gl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to remove the rest.`,pl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to set the rest.`,tn={resumable:!1,truncated:gl,verb:"deleted"},bl={resumable:!0,truncated:pl,verb:"written"},hl=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=ut(),[u,m]=$(l),[p,b]=$(o??""),f=a===void 0||a===""?null:a,[g,h]=$(0),[x,v]=$("table"),[y,S]=$(()=>en(e)),[C,k]=$(n??""),[N,w]=$(()=>Zt(s??[])),{clearFacets:T,facets:F,refetchFacets:R,toggleFacet:_}=Qn(),[D,O]=$(null),[V,A]=$(null),[L,G]=$(null),q=Ke(null),P=Ko(),[J,K]=$(null),[H,Y]=$(!1),[U,ne]=$(a),[le,ae]=$(()=>rt(o,n,s,e)),[ge,fe]=$(0),[me,pe]=$(()=>rt(o,n,s,e)),ie=a!==U,Q=rt(o,n,s,e),ce=ie||!ie&&Q!==le&&Q!==me;if(ce){ne(a),ae(Q),fe(z=>z+1),S(en(e)),k(n??"");const I=Zt(s??[]);w(I),b(o??""),T(),P.clear(),K(null),O(null),h(0),A(null),G(null),q.current=null}else Q!==le&&ae(Q);const Se=ce?n??"":C,oe=ce?o??"":p,se=`${a??""}:${ge.toString()}`,W=Gt(Se.trim(),300,se),j=Gt(oe.trim(),400,se),re=Xe(se),X=Ke(0),[ee,we]=$(j);ee!==j&&(we(j),P.clear(),K(null),O(null));const xe=rt(j,W,Fe(N),it(y));xe!==me&&pe(xe);const de=Ze(he.listTables,al,{live:!0,shardKey:j}),te=de.data??null,De=de.error,Ve=dl({filters:N,offset:g,pageSize:u,search:W,sorting:y,table:f??""}),Le=ul({filters:N,search:W,table:f??""}),Ne=Ze(he.readTablePage,Ve,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:j}),ue=Ne.data??null,ke=Ne.error,{liveError:Ge}=Ne,qe=Ze(he.readTablePage,Le,{enabled:f!==null,live:!0,shardKey:j});ze(()=>{de.data!==void 0&&To(j)},[de.data,j]);const He=I=>{t?.(I)},mt=(I,z)=>{t?.(I,{search:z})},gt=async(I,z)=>{try{return(await i.query(nl,{filters:[],limit:tl,offset:0,search:z,table:I},Re(j))).rows.find(Ae=>Ie(Ae)===z)??null}catch{return null}},tt=(I,z,Te,Ae)=>ye=>i.query(ol,{column:ye,filters:Fe(Te),search:Ae,table:z},Re(I)),pt=I=>{_(I,f===null?null:tt(j,f,N,W))},nt=(I,z)=>{const Te={column:I,literal:[Wn(z)],operator:"eq",value:pn(z)},Ae=ye=>ye.column===I&&ye.operator!=="has"&&ye.pathSegments===void 0&&(ye.path??"").trim()==="";w(ye=>[...ye.filter(_e=>!Ae(_e)),Te]),h(0)},bt=Xe(tt),ht=Xe(R),Ue=Xe(c);ze(()=>{f!==null&&Ce(ht.current(bt.current(j,f,N,W)))},[j,f,N,W]),ze(()=>{f===null||Ue.current===void 0||U!==a||le!==Q||Ue.current({filters:Fe(N),orderBy:it(y),search:W,shard:j})},[f,a,U,le,Q,N,y,W,j]);const Qe=I=>{f!==null&&h(Math.max(0,I))},xt=(I,z)=>{K({column:z,rowId:I})},vt=()=>{K(null)},wt=async()=>{if(f!==null){A(null),Y(!0);try{for(const[I,z]of Object.entries(P.staged))await i.query(Rt,{doc:z,id:I,op:"patch",table:f},Re(j)),P.drop(I,z)}catch(I){A(I.message)}K(null),Ne.refetch(),Y(!1)}},yt=()=>{P.clear(),K(null)},Ct=I=>{X.current+=1,b(I),P.clear(),K(null),O(null),h(0),q.current=null},St=fl(ue,P.staged),M=async(I,z,Te)=>{if(f===null)return;A(null);let Ae;if(I!=="delete"){let ye;try{ye=Te===void 0||Te.trim()===""?{}:JSON.parse(Te)}catch(_e){A(`Invalid JSON: ${_e.message}`);return}try{const _e=Pt(ye);if(!ln(_e)){A("The document must be a JSON object.");return}Ae=_e}catch(_e){A(`Invalid document: ${_e.message}`);return}}try{await i.query(Rt,{doc:Ae,id:z??void 0,op:I,table:f},Re(j)),O(null),Ne.refetch()}catch(ye){A(ye.message)}},Z=async(I,z,Te)=>{if(f===null)return 0;const Ae=se,ye=X.current,_e=()=>re.current===Ae&&X.current===ye;A(null),G(null);const Bt=cl(I,z,j),zn=q.current?.key===Bt?q.current.after:void 0,qn=Te.resumable?zn??"":void 0;let je=0;try{const Ye=await Zs({args:z,maxBatches:Mt,openCursor:qn,query:async Kn=>{const jt=await i.query(I,Kn,Re(j));return je+=jt.count,jt}});return _e()&&(q.current=Ye.cursor===void 0?null:{after:Ye.cursor,key:Bt},Ye.outcome==="cap-hit"&&A(Te.truncated),G(`${je.toString()} ${je===1?"row":"rows"} ${Te.verb}.`)),je}catch(Ye){return _e()&&(A(`${Ye.message} (at least ${je.toString()} rows were already ${Te.verb})`),q.current=null),je}finally{_e()&&(h(0),Ne.refetch())}},Oe=I=>{S(I),h(0)},Be=$t(()=>f===null?[]:r?.(f)??[],[r,f]),Ee=vs(ue,y,Oe,Be),ot={filters:Fe(N),orderBy:it(y),search:W,shard:p,table:f??void 0},st=qe.data?.total,lt=st!==void 0,Lt=st??(ue===null?0:g+ue.rows.length),bn=g>0,hn=W!==""||Fe(N).length>0,xn=ue!==null&&(lt?g+ue.rows.length<Lt:ue.rows.length===u),vn=ue===null||ue.rows.length===0?0:g+1,wn=ue===null?0:g+ue.rows.length,yn=()=>{de.refetch()},Cn=()=>{v("table")},Sn=()=>{v("json")},Nn=()=>{Ce(Z(sl,{filters:Fe(N),search:W,table:f},tn))},kn=()=>{Ce(Z(ll,{table:f},tn))},Tn=I=>{Ce(Z(rl,{doc:I,filters:Fe(N),search:W,table:f},bl))},En=I=>{k(I.target.value),h(0)},_n=I=>{w(I),h(0)},Rn=()=>{A(null);const I={};for(const z of ue?.columns??[])Vt.has(z)||(I[z]="");O({docText:JSON.stringify(I,null,2),id:""})},$n=I=>{O(z=>z===null?z:{docText:I,id:z.id})},Dn=()=>{D!==null&&Ce(M(D.id===""?"insert":"patch",D.id===""?null:D.id,D.docText))},An=()=>{O(null),A(null)},Pn=()=>{Qe(g-u)},In=()=>{Qe(g+u)},On=I=>{Qe(Math.max(0,(I-1)*u))},Fn=I=>{m(I),h(0)},Mn=(I,z)=>{A(null),O({docText:JSON.stringify(rn(il(z)),null,2),id:I})},Vn=I=>{Ce(M("delete",I))},Ln=async I=>{if(!(f===null||I.length===0)){A(null);try{for(const z of I)await i.query(Rt,{id:z,op:"delete",table:f},Re(j));Ne.refetch()}catch(z){A(z.message)}}},Bn=I=>{Ce(Ln(I))},jn=()=>{Ce(wt())};return{addRow:Rn,bulkDelete:Nn,bulkPatch:Tn,cancelCellEdit:vt,cancelEdit:An,changePageSize:Fn,clearTable:kn,columns:ue?.columns??[],committing:H,currentView:ot,discardStaged:yt,editableColumn:ml,editing:D,editingCell:J,facetFilter:nt,facets:F,filter:C,filters:N,goNext:In,goPrevious:Pn,hasNext:xn,hasPredicate:hn,hasPrevious:bn,jumpToPage:On,liveError:Ge,loadTables:yn,navigateToRef:mt,onBulkDeleteSelected:Bn,onCommitStaged:jn,onFilterChange:En,onFiltersChange:_n,onRowDelete:Vn,onRowEdit:Mn,page:ue,previewRef:gt,pageError:ke,pageSize:u,rangeEnd:wn,rangeStart:vn,queryShardKey:j,saveEdit:Dn,selectedTable:f,selectTable:He,setEditorDocumentText:$n,setShardKey:Ct,shardKey:p,showJson:Sn,showTable:Cn,stage:P.stage,stagedChanges:St,stagedValue:P.stagedValue,startCellEdit:xt,table:Ee,tables:te,tablesError:De,toggleFacet:pt,total:Lt,totalKnown:lt,viewMode:x,writeError:V,writeNotice:L}},xl="lunora-studio-pinned-columns",vl=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=nn(xl,c),a=t??"",i=l[a];let u;e[1]!==o||e[2]!==i?(u=i===void 0?new Set((o??"").split(",").filter(wl)):new Set(i),e[1]=o,e[2]=i,e[3]=u):u=e[3];const m=u;let p;e[4]!==a||e[5]!==m||e[6]!==r?(p=T=>{r(F=>{const R=F[a]??[...m],_=R.includes(T)?R.filter(D=>D!==T):[...R,T];return{...F,[a]:_}})},e[4]=a,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[f,g]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(yl)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N}=Yn(v);let w;return e[12]!==y||e[13]!==S||e[14]!==C||e[15]!==k||e[16]!==N||e[17]!==b||e[18]!==m||e[19]!==f?(w={maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N,onTogglePin:b,onToggleTranspose:x,pinnedColumns:m,transposed:f},e[12]=y,e[13]=S,e[14]=C,e[15]=k,e[16]=N,e[17]=b,e[18]=m,e[19]=f,e[20]=w):w=e[20],w};function wl(s){return s!==""}function yl(s){return!s}const Cl=$e(he.describeTable),Sl=$e(he.readTablePage),Nl=$e(he.importShard),kl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},Tl=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},El=s=>{const e=ut(),[n,o]=$(!1),[t,c]=$(void 0),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$({}),[p,b]=$(!1),[f,g]=$(void 0),h=async(S,C)=>{o(!0),c(S),r(C),i(void 0),m({}),g(void 0),b(!0);try{const k=await e.query(Cl,{table:S},Re(C)),{columns:N}=k;i(N);const w={},T=N.filter(F=>F.ref!==void 0&&F.type==="id"&&F.pk!==!0);for(const F of T){if(F.ref===void 0)continue;const{ref:R}=F;if(w[R]===void 0)try{const _=await e.query(Sl,{filters:[],limit:qs,offset:0,search:"",table:R},Re(C));w[R]=_.rows.flatMap(D=>kl(D)||[])}catch{w[R]=[]}}m(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),m({}),g(void 0)},columnMeta:a,error:f,fkPools:u,insertBatch:async(S,C)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(Nl,{rows:S.map(w=>({doc:w,table:t}))},Re(l)),N=Tl(k);return N.error!==void 0||(C(),s()),N}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(S,C)=>{Ce(h(S,C))},shardKey:l,table:t}},_l=s=>{const e=B(6),[n,o]=$(null);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{o(null)},e[0]=t):t=e[0];const c=t,[l,r]=$(null);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h,x)=>{r({column:g,storedValue:x,value:h})},e[1]=a):a=e[1];const i=a;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{r(null)},e[2]=u):u=e[2];const m=u,[p,b]=$(s);p!==s&&(b(s),o(null),r(null));let f;return e[3]!==l||e[4]!==n?(f={closeExpandedCell:m,closeInspect:c,expandedCell:l,inspecting:n,onExpandCell:i,onInspect:o},e[3]=l,e[4]=n,e[5]=f):f=e[5],f},Rl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,$l=(s,e)=>typeof e=="number"&&Rl.test(s),Dl=s=>{const e=B(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=Me(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let f;return e[10]!==a||e[11]!==m||e[12]!==p||e[13]!==b?(f=E("button",{"data-testid":m,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=m,e[12]=p,e[13]=b,e[14]=f):f=e[14],f}if($l(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=Hn(l),e[17]=l,e[18]=b):b=e[18];let f;return e[19]!==m||e[20]!==p||e[21]!==b?(f=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=f):f=e[22],f}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const m=`rd-bytes-${n}`;let p;e[23]!==l?(p=Me(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==m||e[26]!==p?(b=d("span",{"data-testid":m,children:p}),e[25]=m,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let m;e[28]!==l?(m=JSON.stringify(l,on,2),e[28]=l,e[29]=m):m=e[29];let p;return e[30]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[30]=m,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=Me(l),e[32]=l,e[33]=i):i=e[33];let u;return e[34]!==i?(u=d("span",{children:i}),e[34]=i,e[35]=u):u=e[35],u},Al=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=u):u=e[3];let m;e[4]!==t?(m=E("div",{className:"mb-3 flex items-center justify-between",children:[u,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(Dl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let f;return e[19]!==t||e[20]!==m||e[21]!==b?(f=E(ft,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=f):f=e[22],f},Pl=50,Il=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Ol=({onFetchTables:s,onSelect:e})=>{const n=ve(),[o]=$(()=>Eo()),[t,c]=$(!1),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$(!1),[p,b]=$(void 0),f=Ke(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),m(!0),f.current+=1;const y=f.current;try{const S=await s(v);f.current===y&&i(S?.slice(0,Pl))}catch(S){f.current===y&&b(S.message)}f.current===y&&m(!1)},x=v=>{Ce(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(Il,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),u&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!u&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!u&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},Fl="lunora-studio-back-relations",Ml=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Vl=(s,e)=>s==null||typeof s=="string"||typeof s=="number"&&Number.isFinite(s)||typeof s=="boolean"||typeof s=="bigint"&&e==="bigint",Ll=(s,e)=>e===null&&(s==="eq"||s==="ne")?{literal:[null],value:"null"}:typeof e!="string"&&typeof e!="number"&&typeof e!="boolean"?{value:""}:typeof e=="string"&&(s==="eq"||s==="ne")?{literal:[e],value:e}:s!=="has"&&typeof e!="boolean"?{value:String(e)}:{literal:[e],value:typeof e=="string"?`"${e}"`:String(e)},Bl={},jl=50,zl=[],ql=$e(he.listTables),Kl=$e(he.readTablePage),Gl=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Gn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d(Ol,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},Nr=({canGenerateRows:s=!1,editable:e=!1,globalTableNames:n,initialFilters:o,initialOrderBy:t,initialPins:c,initialSearch:l,initialShardKey:r,onNavigateToGlobal:a,onSelectTable:i,onViewChange:u,pageSize:m=jl,queryBar:p,schemaSwitch:b,tableParam:f})=>{const g=Ze(he.describeTables,{},{shardKey:r??""}),h=Ze(he.listTablesIndexes,{},{shardKey:r??""}),x=g.data?.columnsByTable??Bl,[v,y]=nn(Fl,{}),S=ct(M=>{const Z=new Set(v[M]);return Jt(M,x).filter(Oe=>Z.has(Ot(Oe)))},[v,x]),C=hl({initialFilters:o,initialOrderBy:t,initialSearch:l,initialShardKey:r,onSelectTable:i,onViewChange:u,pageSize:m,resolveBackRelations:S,tableParam:f}),{cancelCellEdit:k,columns:N,currentView:w,editableColumn:T,editingCell:F,facetFilter:R,facets:_,loadTables:D,navigateToRef:O,onFiltersChange:V,page:A,pageError:L,previewRef:G,queryShardKey:q,selectedTable:P,selectTable:J,setShardKey:K,shardKey:H,stage:Y,stagedValue:U,startCellEdit:ne,tables:le,tablesError:ae,toggleFacet:ge}=C,fe=Jn(H),me=Xe(P),pe=M=>{const Z=P;Ce((async()=>{const Be=await fe.suggestFilter(M,Z??"");Be!==void 0&&me.current===Z&&V(Be.map(Ee=>{const{literal:ot,value:st}=Ll(Ee.operator,Ee.value),lt=Ee.path===void 0||Ee.path.length===0?{}:{path:Ee.path.join("."),pathSegments:Ee.path};return{column:Ee.column,operator:Ee.operator,...lt,...ot===void 0?{}:{literal:ot},value:st}}))})())},ie=P===null?[]:Jt(P,x),Q=new Set(v[P??""]),be=[];for(const M of A?.rows??[]){const Z=M._id??M.id;typeof Z=="string"&&Z!==""&&be.push(Z)}const ce=Ys(Q,ie,be,q),Se=M=>{y(Z=>{const Oe=P??"",Be=Z[Oe]??[];return{...Z,[Oe]:Be.includes(M)?Be.filter(Ee=>Ee!==M):[...Be,M]}})},oe=vl({columns:N,initialPins:c,selectedTable:P}),se=_l(JSON.stringify([P,q])),[W,j]=$(null),{closeExpandedCell:re,closeInspect:X,expandedCell:ee,inspecting:we,onExpandCell:xe}=se,de=ut(),te=Object.fromEntries((x[P??""]??[]).map(M=>[M.name,M])),De=new Map;for(const M of x[P??""]??[])M.isStorage===!0&&De.set(M.name,M.bucket);const Ve=ct(async(M,Z)=>de.signedStorageUrl(M,Z===void 0?{}:{bucket:Z}),[de]),Le=async M=>await de.query(ql,{},Re(M)),Ne=()=>{P!==null&&J(P)},{closeDialog:ue,columnMeta:ke,fkPools:Ge,insertBatch:qe,open:He,openDialog:mt}=El(Ne),gt=()=>{P!==null&&mt(P,H)},tt=M=>qe(M,ue),[pt,nt]=$(!1),bt=()=>{nt(!0)},ht=()=>{nt(!1)},Ue=(M,Z)=>{if(a!==void 0&&n?.has(M)===!0){a(M,Z);return}O(M,Z)},Qe=p?.onSaveQuery,xt=M=>{Qe?.(M,w)},vt={cancelEdit:k,editable:e,editableColumn:T,editingCell:F,onExpandCell:xe,stage:Y,stagedValue:U,startEdit:ne},wt=M=>{M!==null&&j(M)},yt=()=>{C.onRowDelete(W)},Ct=async(M,Z,Oe)=>await de.query(Kl,{filters:[{column:Z,operator:"eq",value:Oe}],limit:at,offset:0,orderBy:[],table:M},Re(q)),St={columns:A?.refs,maskViewFor:oe.maskViewFor,onNavigate:Ue,onPreview:G};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Xn,{header:d(Gl,{onFetchShardTables:Le,onShardChange:K,schemaSwitch:b,shardKey:H}),onReload:D,onSelect:J,prefix:"db",selected:P,tables:le??zl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ae!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ae}),A===null&&L===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),L!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:L}),A!==null&&d(js,{assistant:fe,backRelations:{available:ie,counts:ce,enabled:Q,onToggle:Se},browser:C,columnMeta:te,edit:vt,editable:e,onAskAiFilter:pe,onInspect:se.onInspect,onOpenBulkPatch:bt,onOpenGenerateRows:s?gt:void 0,onRowDelete:wt,onSaveQuery:xt,page:A,preferences:oe,queryBar:p,references:St})]}),A!==null&&d(Zn,{columns:N,facets:_,mask:oe.maskView,onFacetFilter:R,onToggleFacet:ge}),we!==null&&A!==null&&d(Al,{columns:A.columns,mask:oe.maskView,onClose:X,onNavigate:Ue,refs:A.refs,row:sn(we,oe.maskView)}),W!==null&&P!==null&&d(Bo,{onClose:()=>{j(null)},onConfirm:yt,readPage:Ct,rowId:W,schema:_o(x),table:P}),ee!==null&&d(No,{bucket:De.get(ee.column),column:ee.column,onClose:re,onFilter:Vl(ee.storedValue,te[ee.column]?.type)?()=>{R(ee.column,ee.storedValue??null),re()}:void 0,resolveUrl:De.has(ee.column)?Ve:void 0,value:ee.value}),pt&&P!==null&&d(Do,{columns:C.columns.filter(M=>C.editableColumn(M)),onApply:C.bulkPatch,onClose:ht,shardKey:C.queryShardKey,table:P,total:C.total,uniqueColumns:Ml(h.data?.indexesByTable[P])}),He&&P!==null&&ke!==void 0&&d(Us,{columns:ke,fkPools:Ge,onClose:ue,onInsertRows:tt,table:P})]})};export{Nr as DataBrowser};
@@ -1 +1 @@
1
- import{useState as A,useRef as I,useEffect as J}from"react";import{a as Q}from"./use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as B}from"./DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as me}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ue}from"./use-studio-client-DCA50tF2.mjs";import{useT as _}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{b as fe}from"./cf-links-CBJ5SywP.mjs";import{l as pe,o as ge,f as be}from"./internal-hIuTpSbx.mjs";import{m as Z,u as he,a as xe,T as ke,D as ve}from"./table-list-sidebar-CNadcIgG.mjs";import{c as X}from"react/compiler-runtime";import{c as Ne,a as ye,b as q,e as we,d as Te,T as Se}from"./table-D0SBiDu-.mjs";import{a as Ce}from"./control-button-BOZ5K-FC.mjs";import{C as K,G as Fe}from"./data-grid-B5m1OosL.mjs";import{G as Pe}from"./grid-pagination-DY2erU65.mjs";import{jsx as r,jsxs as P}from"react/jsx-runtime";import{E as Ee}from"./empty-state-D7jEML_T.mjs";const Me=(t,e)=>{const n=t._id;return typeof n=="string"||typeof n=="number"?String(n):`row-${e.toString()}`},Ge=t=>t==null?"∅":t===""?"(empty)":pe(t),Re=t=>{const e=X(45),{filters:n,hasMaskedColumns:f,mask:s,maskOn:u,onChangePageSize:o,onJumpToPage:O,onNext:d,onPrevious:T,onRemoveFilter:p,onToggleMask:L,page:c,pageSize:E,pagination:S}=t,C=_(),{hasNext:z,hasPrevious:D,rangeEnd:$,rangeStart:F,total:k}=S;let v;e[0]!==f||e[1]!==u||e[2]!==L||e[3]!==C?(v=f&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2",children:r("button",{"aria-pressed":u,className:Ce,"data-testid":"gdb-mask-toggle",onClick:L,type:"button",children:C("Mask sensitive columns")})}),e[0]=f,e[1]=u,e[2]=L,e[3]=C,e[4]=v):v=e[4];let g;e[5]!==n||e[6]!==s||e[7]!==p||e[8]!==C?(g=n.length>0&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2 text-xs","data-testid":"gdb-filters",children:n.map((i,m)=>{const G=Ge(Z(i.value,i.column,s));return P("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted px-1.5 py-0.5","data-testid":"gdb-filter-chip",children:[r("span",{className:"font-medium text-foreground",children:i.column}),r("span",{className:"text-muted-foreground",children:"="}),r("span",{className:"font-mono text-foreground",children:G}),r("button",{"aria-label":C("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:()=>{p(m)},type:"button",children:"✕"})]},`${i.column}:${G}`)})}),e[5]=n,e[6]=s,e[7]=p,e[8]=C,e[9]=g):g=e[9];let a;if(e[10]!==s||e[11]!==c.columns){let i;e[13]!==s?(i=m=>P(Ne,{children:[m,s.columns.has(m)&&r("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`gdb-mask-chip-${m}`,title:"This column is masked by a mask() policy",children:"masked"})]},m),e[13]=s,e[14]=i):i=e[14],a=c.columns.map(i),e[10]=s,e[11]=c.columns,e[12]=a}else a=e[12];let b;e[15]!==a?(b=r(ye,{children:r(q,{children:a})}),e[15]=a,e[16]=b):b=e[16];let N;if(e[17]!==s||e[18]!==c.columns||e[19]!==c.rows){let i;e[21]!==s||e[22]!==c.columns?(i=(m,G)=>r(q,{"data-testid":"gdb-row",children:c.columns.map(w=>r(we,{className:"max-w-xs truncate font-mono text-xs",children:s.enabled&&s.columns.has(w)?r("span",{className:"text-muted-foreground italic","data-testid":`gdb-masked-${w}`,title:"Masked (preview)",children:r(K,{value:Z(m[w],w,s)})}):r(K,{value:m[w]})},w))},Me(m,G)),e[21]=s,e[22]=c.columns,e[23]=i):i=e[23],N=c.rows.map(i),e[17]=s,e[18]=c.columns,e[19]=c.rows,e[20]=N}else N=e[20];let y;e[24]!==N?(y=r(Te,{children:N}),e[24]=N,e[25]=y):y=e[25];let h;e[26]!==b||e[27]!==y?(h=r(Fe,{layout:"fill",children:r("div",{className:"min-h-0 flex-1 overflow-auto",children:P(Se,{"data-testid":"gdb-rows",children:[b,y]})})}),e[26]=b,e[27]=y,e[28]=h):h=e[28];let x;e[29]!==z||e[30]!==D||e[31]!==o||e[32]!==O||e[33]!==d||e[34]!==T||e[35]!==E||e[36]!==$||e[37]!==F||e[38]!==k?(x=r("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:r(Pe,{hasNext:z,hasPrevious:D,onJumpToPage:O,onNext:d,onPageSizeChange:o,onPrevious:T,pageSize:E,prefix:"gdb",rangeEnd:$,rangeStart:F,total:k})}),e[29]=z,e[30]=D,e[31]=o,e[32]=O,e[33]=d,e[34]=T,e[35]=E,e[36]=$,e[37]=F,e[38]=k,e[39]=x):x=e[39];let M;return e[40]!==v||e[41]!==g||e[42]!==h||e[43]!==x?(M=P("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[v,g,h,x]}),e[40]=v,e[41]=g,e[42]=h,e[43]=x,e[44]=M):M=e[44],M},Oe=()=>{const t=X(8),e=_();let n;t[0]!==e?(n=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=n):n=t[1];let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=P("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z"})]}),t[2]=f):f=t[2];let s;t[3]!==e?(s=e("No global tables."),t[3]=e,t[4]=s):s=t[4];let u;return t[5]!==n||t[6]!==s?(u=r("div",{className:"flex flex-1 items-center justify-center p-6",children:r(Ee,{description:n,icon:f,testId:"gdb-empty",title:s})}),t[5]=n,t[6]=s,t[7]=u):u=t[7],u},Le=50,ze=[],W=[],Xe=({initialTable:t,onSelectTable:e,pageSize:n=Le,schemaSwitch:f}={})=>{const s=ue(),u=_(),[o,O]=A(t??null),[d,T]=A(0),[p,L]=A(n),[c,E]=A([]),S=me(c),{clearFacets:C,facets:z,refetchFacets:D,toggleFacet:$}=he(),F=Q(["lunora-global-tables"],()=>s.listGlobalTables()),k=F.data??null,v=F.error,g=Q(["lunora-global-page",o??"",d,p,JSON.stringify(c)],()=>s.readGlobalTablePage({filters:c,limit:p,offset:d,table:o??""}),{enabled:o!==null,keepPreviousData:!1}),a=g.data??null,b=g.error,N=(l,R)=>j=>s.facetGlobalColumn({column:j,filters:R,table:l}),y=(l,R)=>D(N(l,R));B(()=>F.poll(),!0),B(()=>g.poll(),o!==null),B(()=>o===null?void 0:y(o,S.current),o!==null);const h=I(void 0),x=l=>{O(l),h.current=l,E([]),S.current=[],C(),T(0),e?.(l)},M=l=>{$(l,o===null?null:N(o,S.current))},i=l=>{E(l),S.current=l,T(0),o!==null&&be(y(o,l))},m=(l,R)=>{i([...S.current.filter(j=>j.column!==l),{column:l,value:ge(R)}])},G=l=>{i(S.current.filter((R,j)=>j!==l))},w=I(x);J(()=>{w.current=x}),J(()=>{if(t===void 0||t===""||h.current===t)return;h.current=t;const l=t;queueMicrotask(()=>{w.current(l)})},[t]);const V=l=>{o!==null&&T(Math.max(0,l))},{maskColumns:Y,maskOn:ee,maskView:U,onToggleMask:te}=xe({columns:a?.columns??W,selectedTable:o}),H=a?.total??0,re=d>0,se=a!==null&&d+a.rows.length<H,le=a===null||a.rows.length===0?0:d+1,ae=a===null?0:d+a.rows.length,oe=()=>{F.refetch()},ne=()=>{V(d-p)},ie=()=>{V(d+p)},ce=l=>{V(Math.max(0,(l-1)*p))},de=l=>{L(l),T(0)};return P("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[r(ke,{header:P("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[f,r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"gdb-cf-link",href:fe,rel:"noreferrer",target:"_blank",children:u("Open in Cloudflare")})]}),onReload:oe,onSelect:x,prefix:"gdb",selected:o,tables:k??ze}),P("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[v!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-tables-error",role:"alert",children:v}),k!==null&&k.length===0&&r(Oe,{}),b!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-page-error",role:"alert",children:b}),k!==null&&k.length>0&&a===null&&b===null&&r("div",{className:"flex flex-1 items-center justify-center p-6",children:r("p",{className:"text-sm text-muted-foreground",children:u("Select a table to browse its rows.")})}),a!==null&&r(Re,{filters:c,hasMaskedColumns:Y.size>0,mask:U,maskOn:ee,onChangePageSize:de,onJumpToPage:ce,onNext:ie,onPrevious:ne,onRemoveFilter:G,onToggleMask:te,page:a,pageSize:p,pagination:{hasNext:se,hasPrevious:re,rangeEnd:ae,rangeStart:le,total:H}})]}),r(ve,{columns:a?.columns??W,facets:z,mask:U,onFacetFilter:m,onToggleFacet:M})]})};export{Xe as GlobalDataBrowser};
1
+ import{useState as A,useRef as I,useEffect as J}from"react";import{a as Q}from"./use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as B}from"./DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as me}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ue}from"./use-studio-client-DCA50tF2.mjs";import{useT as _}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{b as fe}from"./cf-links-C4DVTr8A.mjs";import{l as pe,o as ge,f as be}from"./internal-hIuTpSbx.mjs";import{m as Z,u as he,a as xe,T as ke,D as ve}from"./table-list-sidebar-kpHaDWjy.mjs";import{c as X}from"react/compiler-runtime";import{c as Ne,a as ye,b as q,e as we,d as Te,T as Se}from"./table-D0SBiDu-.mjs";import{a as Ce}from"./control-button-BOZ5K-FC.mjs";import{C as K,G as Fe}from"./data-grid-B5m1OosL.mjs";import{G as Pe}from"./grid-pagination-DY2erU65.mjs";import{jsx as r,jsxs as P}from"react/jsx-runtime";import{E as Ee}from"./empty-state-D7jEML_T.mjs";const Me=(t,e)=>{const n=t._id;return typeof n=="string"||typeof n=="number"?String(n):`row-${e.toString()}`},Ge=t=>t==null?"∅":t===""?"(empty)":pe(t),Re=t=>{const e=X(45),{filters:n,hasMaskedColumns:f,mask:s,maskOn:u,onChangePageSize:o,onJumpToPage:O,onNext:d,onPrevious:T,onRemoveFilter:p,onToggleMask:L,page:c,pageSize:E,pagination:S}=t,C=_(),{hasNext:z,hasPrevious:D,rangeEnd:$,rangeStart:F,total:k}=S;let v;e[0]!==f||e[1]!==u||e[2]!==L||e[3]!==C?(v=f&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2",children:r("button",{"aria-pressed":u,className:Ce,"data-testid":"gdb-mask-toggle",onClick:L,type:"button",children:C("Mask sensitive columns")})}),e[0]=f,e[1]=u,e[2]=L,e[3]=C,e[4]=v):v=e[4];let g;e[5]!==n||e[6]!==s||e[7]!==p||e[8]!==C?(g=n.length>0&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2 text-xs","data-testid":"gdb-filters",children:n.map((i,m)=>{const G=Ge(Z(i.value,i.column,s));return P("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted px-1.5 py-0.5","data-testid":"gdb-filter-chip",children:[r("span",{className:"font-medium text-foreground",children:i.column}),r("span",{className:"text-muted-foreground",children:"="}),r("span",{className:"font-mono text-foreground",children:G}),r("button",{"aria-label":C("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:()=>{p(m)},type:"button",children:"✕"})]},`${i.column}:${G}`)})}),e[5]=n,e[6]=s,e[7]=p,e[8]=C,e[9]=g):g=e[9];let a;if(e[10]!==s||e[11]!==c.columns){let i;e[13]!==s?(i=m=>P(Ne,{children:[m,s.columns.has(m)&&r("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`gdb-mask-chip-${m}`,title:"This column is masked by a mask() policy",children:"masked"})]},m),e[13]=s,e[14]=i):i=e[14],a=c.columns.map(i),e[10]=s,e[11]=c.columns,e[12]=a}else a=e[12];let b;e[15]!==a?(b=r(ye,{children:r(q,{children:a})}),e[15]=a,e[16]=b):b=e[16];let N;if(e[17]!==s||e[18]!==c.columns||e[19]!==c.rows){let i;e[21]!==s||e[22]!==c.columns?(i=(m,G)=>r(q,{"data-testid":"gdb-row",children:c.columns.map(w=>r(we,{className:"max-w-xs truncate font-mono text-xs",children:s.enabled&&s.columns.has(w)?r("span",{className:"text-muted-foreground italic","data-testid":`gdb-masked-${w}`,title:"Masked (preview)",children:r(K,{value:Z(m[w],w,s)})}):r(K,{value:m[w]})},w))},Me(m,G)),e[21]=s,e[22]=c.columns,e[23]=i):i=e[23],N=c.rows.map(i),e[17]=s,e[18]=c.columns,e[19]=c.rows,e[20]=N}else N=e[20];let y;e[24]!==N?(y=r(Te,{children:N}),e[24]=N,e[25]=y):y=e[25];let h;e[26]!==b||e[27]!==y?(h=r(Fe,{layout:"fill",children:r("div",{className:"min-h-0 flex-1 overflow-auto",children:P(Se,{"data-testid":"gdb-rows",children:[b,y]})})}),e[26]=b,e[27]=y,e[28]=h):h=e[28];let x;e[29]!==z||e[30]!==D||e[31]!==o||e[32]!==O||e[33]!==d||e[34]!==T||e[35]!==E||e[36]!==$||e[37]!==F||e[38]!==k?(x=r("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:r(Pe,{hasNext:z,hasPrevious:D,onJumpToPage:O,onNext:d,onPageSizeChange:o,onPrevious:T,pageSize:E,prefix:"gdb",rangeEnd:$,rangeStart:F,total:k})}),e[29]=z,e[30]=D,e[31]=o,e[32]=O,e[33]=d,e[34]=T,e[35]=E,e[36]=$,e[37]=F,e[38]=k,e[39]=x):x=e[39];let M;return e[40]!==v||e[41]!==g||e[42]!==h||e[43]!==x?(M=P("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[v,g,h,x]}),e[40]=v,e[41]=g,e[42]=h,e[43]=x,e[44]=M):M=e[44],M},Oe=()=>{const t=X(8),e=_();let n;t[0]!==e?(n=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=n):n=t[1];let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=P("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z"})]}),t[2]=f):f=t[2];let s;t[3]!==e?(s=e("No global tables."),t[3]=e,t[4]=s):s=t[4];let u;return t[5]!==n||t[6]!==s?(u=r("div",{className:"flex flex-1 items-center justify-center p-6",children:r(Ee,{description:n,icon:f,testId:"gdb-empty",title:s})}),t[5]=n,t[6]=s,t[7]=u):u=t[7],u},Le=50,ze=[],W=[],Xe=({initialTable:t,onSelectTable:e,pageSize:n=Le,schemaSwitch:f}={})=>{const s=ue(),u=_(),[o,O]=A(t??null),[d,T]=A(0),[p,L]=A(n),[c,E]=A([]),S=me(c),{clearFacets:C,facets:z,refetchFacets:D,toggleFacet:$}=he(),F=Q(["lunora-global-tables"],()=>s.listGlobalTables()),k=F.data??null,v=F.error,g=Q(["lunora-global-page",o??"",d,p,JSON.stringify(c)],()=>s.readGlobalTablePage({filters:c,limit:p,offset:d,table:o??""}),{enabled:o!==null,keepPreviousData:!1}),a=g.data??null,b=g.error,N=(l,R)=>j=>s.facetGlobalColumn({column:j,filters:R,table:l}),y=(l,R)=>D(N(l,R));B(()=>F.poll(),!0),B(()=>g.poll(),o!==null),B(()=>o===null?void 0:y(o,S.current),o!==null);const h=I(void 0),x=l=>{O(l),h.current=l,E([]),S.current=[],C(),T(0),e?.(l)},M=l=>{$(l,o===null?null:N(o,S.current))},i=l=>{E(l),S.current=l,T(0),o!==null&&be(y(o,l))},m=(l,R)=>{i([...S.current.filter(j=>j.column!==l),{column:l,value:ge(R)}])},G=l=>{i(S.current.filter((R,j)=>j!==l))},w=I(x);J(()=>{w.current=x}),J(()=>{if(t===void 0||t===""||h.current===t)return;h.current=t;const l=t;queueMicrotask(()=>{w.current(l)})},[t]);const V=l=>{o!==null&&T(Math.max(0,l))},{maskColumns:Y,maskOn:ee,maskView:U,onToggleMask:te}=xe({columns:a?.columns??W,selectedTable:o}),H=a?.total??0,re=d>0,se=a!==null&&d+a.rows.length<H,le=a===null||a.rows.length===0?0:d+1,ae=a===null?0:d+a.rows.length,oe=()=>{F.refetch()},ne=()=>{V(d-p)},ie=()=>{V(d+p)},ce=l=>{V(Math.max(0,(l-1)*p))},de=l=>{L(l),T(0)};return P("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[r(ke,{header:P("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[f,r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"gdb-cf-link",href:fe,rel:"noreferrer",target:"_blank",children:u("Open in Cloudflare")})]}),onReload:oe,onSelect:x,prefix:"gdb",selected:o,tables:k??ze}),P("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[v!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-tables-error",role:"alert",children:v}),k!==null&&k.length===0&&r(Oe,{}),b!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-page-error",role:"alert",children:b}),k!==null&&k.length>0&&a===null&&b===null&&r("div",{className:"flex flex-1 items-center justify-center p-6",children:r("p",{className:"text-sm text-muted-foreground",children:u("Select a table to browse its rows.")})}),a!==null&&r(Re,{filters:c,hasMaskedColumns:Y.size>0,mask:U,maskOn:ee,onChangePageSize:de,onJumpToPage:ce,onNext:ie,onPrevious:ne,onRemoveFilter:G,onToggleMask:te,page:a,pageSize:p,pagination:{hasNext:se,hasPrevious:re,rangeEnd:ae,rangeStart:le,total:H}})]}),r(ve,{columns:a?.columns??W,facets:z,mask:U,onFacetFilter:m,onToggleFacet:M})]})};export{Xe as GlobalDataBrowser};
@@ -1 +1 @@
1
- import"./badge-r_5B4LHP.mjs";import"./card-By2O8ULa.mjs";import"./empty-state-D7jEML_T.mjs";import"./use-admin-query-CaOm4JS3.mjs";import"./DEFAULT_LOCALE-BQ3jRT74.mjs";import"./ADMIN_FUNCTIONS-4aGsMs95.mjs";import"./internal-hIuTpSbx.mjs";import"./utils-bhneXptQ.mjs";import"./DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{H,c as f}from"./home-panel-CDVTuTF8.mjs";export{H as HomePanel,f as cacheFooterText};
1
+ import"./badge-r_5B4LHP.mjs";import"./card-By2O8ULa.mjs";import"./empty-state-D7jEML_T.mjs";import"./use-admin-query-CaOm4JS3.mjs";import"./DEFAULT_LOCALE-BQ3jRT74.mjs";import"./ADMIN_FUNCTIONS-DUXsXId1.mjs";import"./internal-hIuTpSbx.mjs";import"./utils-bhneXptQ.mjs";import"./DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{H,c as f}from"./home-panel-5fGktYeD.mjs";export{H as HomePanel,f as cacheFooterText};