@theobourgeois/ytdb 0.2.20 → 0.3.0

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 (181) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -1
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/react-loadable-manifest.json +12 -1
  6. package/.next/routes-manifest.json +9 -0
  7. package/.next/server/app/[connectionId]/[schema]/[table]/page.js +1 -1
  8. package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/[connectionId]/diff/page.js +2 -2
  10. package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/[connectionId]/migrations/(index)/page.js +1 -1
  12. package/.next/server/app/[connectionId]/migrations/(index)/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/[connectionId]/migrations/(index)/timeline/page.js +1 -1
  14. package/.next/server/app/[connectionId]/migrations/(index)/timeline/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page.js +1 -0
  16. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page.js.nft.json +1 -0
  17. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page_client-reference-manifest.js +1 -0
  18. package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
  19. package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/[connectionId]/migrations/[setId]/schema/page.js +1 -1
  21. package/.next/server/app/[connectionId]/migrations/[setId]/schema/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page.js +1 -1
  23. package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/[connectionId]/page.js +1 -1
  25. package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/[connectionId]/query/page.js +1 -1
  27. package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/_global-error/page.js +2 -2
  29. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  30. package/.next/server/app/_global-error.html +1 -1
  31. package/.next/server/app/_global-error.rsc +1 -1
  32. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  33. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  34. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  35. package/.next/server/app/_not-found/page.js +1 -1
  36. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/_not-found.html +1 -1
  38. package/.next/server/app/_not-found.rsc +7 -7
  39. package/.next/server/app/_not-found.segments/_full.segment.rsc +7 -7
  40. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +7 -7
  41. package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -3
  42. package/.next/server/app/api/activity/route.js +2 -2
  43. package/.next/server/app/api/adopt/route.js +1 -1
  44. package/.next/server/app/api/cell/route.js +3 -3
  45. package/.next/server/app/api/definition/route.js +2 -2
  46. package/.next/server/app/api/delete-rows/route.js +1 -1
  47. package/.next/server/app/api/detect/route.js +1 -1
  48. package/.next/server/app/api/health/route.js +1 -1
  49. package/.next/server/app/api/insert-row/route.js +2 -2
  50. package/.next/server/app/api/ledger/route.js +1 -1
  51. package/.next/server/app/api/lookup/route.js +2 -2
  52. package/.next/server/app/api/migrate/route.js +1 -1
  53. package/.next/server/app/api/note/route.js +1 -1
  54. package/.next/server/app/api/query/route.js +2 -2
  55. package/.next/server/app/api/reconcile/route.js +2 -2
  56. package/.next/server/app/api/rehearse/route.js +1 -1
  57. package/.next/server/app/api/related/route.js +2 -2
  58. package/.next/server/app/api/repo/route.js +1 -1
  59. package/.next/server/app/api/rows/route.js +2 -2
  60. package/.next/server/app/api/schema/route.js +1 -1
  61. package/.next/server/app/api/tables/route.js +2 -2
  62. package/.next/server/app/api/timeline/route.js +1 -1
  63. package/.next/server/app/api/update-row/route.js +1 -1
  64. package/.next/server/app/favicon.ico/route.js +1 -1
  65. package/.next/server/app/icon.svg/route.js +1 -1
  66. package/.next/server/app/index.html +1 -1
  67. package/.next/server/app/index.rsc +8 -8
  68. package/.next/server/app/index.segments/__PAGE__.segment.rsc +8 -8
  69. package/.next/server/app/index.segments/_full.segment.rsc +8 -8
  70. package/.next/server/app/index.segments/_tree.segment.rsc +3 -3
  71. package/.next/server/app/page.js +2 -2
  72. package/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app-paths-manifest.json +2 -1
  74. package/.next/server/chunks/1421.js +1 -1
  75. package/.next/server/chunks/4809.js +1 -1
  76. package/.next/server/chunks/5816.js +1 -1
  77. package/.next/server/chunks/6729.js +1 -1
  78. package/.next/server/chunks/7928.js +1 -1
  79. package/.next/server/middleware-build-manifest.js +1 -1
  80. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  81. package/.next/server/middleware.js +1 -1
  82. package/.next/server/pages/404.html +1 -1
  83. package/.next/server/pages/500.html +1 -1
  84. package/.next/server/server-reference-manifest.json +1 -1
  85. package/.next/static/{XOKG1sVlYC-O8M7Qf5aWE → NB4JOC2i3ctixKpjpc7WH}/_buildManifest.js +1 -1
  86. package/.next/static/chunks/1a258343.4407cfad5d6b3688.js +1 -0
  87. package/.next/static/chunks/{223-a4fca67d979d899d.js → 223-ae41c085e76173d8.js} +1 -1
  88. package/.next/static/chunks/228-332e8b6e327f10da.js +1 -0
  89. package/.next/static/chunks/{544-9e1c454c8313699f.js → 544-624e05bf7e7a38d4.js} +1 -1
  90. package/.next/static/chunks/6090-97474bba31339e8e.js +1 -0
  91. package/.next/static/chunks/9146.9656b5ec316de71a.js +1 -0
  92. package/.next/static/chunks/91dbc596.26f4ecb79a1f7c01.js +1 -0
  93. package/.next/static/chunks/9406.9203511499c8bf43.js +1 -0
  94. package/.next/static/chunks/app/[connectionId]/migrations/(index)/page-e85d6ff71aeabe8d.js +1 -0
  95. package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-e85d6ff71aeabe8d.js +1 -0
  96. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/diagram/page-e85d6ff71aeabe8d.js +1 -0
  97. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/layout-31e703f1a9beebf7.js +1 -0
  98. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-e85d6ff71aeabe8d.js +1 -0
  99. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/schema/page-e85d6ff71aeabe8d.js +1 -0
  100. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/timeline/page-e85d6ff71aeabe8d.js +1 -0
  101. package/.next/static/chunks/app/[connectionId]/page-78a06e32a2658d3b.js +1 -0
  102. package/.next/static/chunks/app/[connectionId]/query/page-53c2d6f97a05d957.js +1 -0
  103. package/.next/static/chunks/app/_global-error/page-e85d6ff71aeabe8d.js +1 -0
  104. package/.next/static/chunks/app/api/activity/route-e85d6ff71aeabe8d.js +1 -0
  105. package/.next/static/chunks/app/api/adopt/route-e85d6ff71aeabe8d.js +1 -0
  106. package/.next/static/chunks/app/api/cell/route-e85d6ff71aeabe8d.js +1 -0
  107. package/.next/static/chunks/app/api/definition/route-e85d6ff71aeabe8d.js +1 -0
  108. package/.next/static/chunks/app/api/delete-rows/route-e85d6ff71aeabe8d.js +1 -0
  109. package/.next/static/chunks/app/api/detect/route-e85d6ff71aeabe8d.js +1 -0
  110. package/.next/static/chunks/app/api/health/route-e85d6ff71aeabe8d.js +1 -0
  111. package/.next/static/chunks/app/api/insert-row/route-e85d6ff71aeabe8d.js +1 -0
  112. package/.next/static/chunks/app/api/ledger/route-e85d6ff71aeabe8d.js +1 -0
  113. package/.next/static/chunks/app/api/lookup/route-e85d6ff71aeabe8d.js +1 -0
  114. package/.next/static/chunks/app/api/migrate/route-e85d6ff71aeabe8d.js +1 -0
  115. package/.next/static/chunks/app/api/note/route-e85d6ff71aeabe8d.js +1 -0
  116. package/.next/static/chunks/app/api/query/route-e85d6ff71aeabe8d.js +1 -0
  117. package/.next/static/chunks/app/api/reconcile/route-e85d6ff71aeabe8d.js +1 -0
  118. package/.next/static/chunks/app/api/rehearse/route-e85d6ff71aeabe8d.js +1 -0
  119. package/.next/static/chunks/app/api/related/route-e85d6ff71aeabe8d.js +1 -0
  120. package/.next/static/chunks/app/api/repo/route-e85d6ff71aeabe8d.js +1 -0
  121. package/.next/static/chunks/app/api/rows/route-e85d6ff71aeabe8d.js +1 -0
  122. package/.next/static/chunks/app/api/schema/route-e85d6ff71aeabe8d.js +1 -0
  123. package/.next/static/chunks/app/api/tables/route-e85d6ff71aeabe8d.js +1 -0
  124. package/.next/static/chunks/app/api/timeline/route-e85d6ff71aeabe8d.js +1 -0
  125. package/.next/static/chunks/app/api/update-row/route-e85d6ff71aeabe8d.js +1 -0
  126. package/.next/static/chunks/app/layout-2ed8b1f837adb32a.js +1 -0
  127. package/.next/static/chunks/next/dist/client/components/builtin/app-error-e85d6ff71aeabe8d.js +1 -0
  128. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-e85d6ff71aeabe8d.js +1 -0
  129. package/.next/static/chunks/next/dist/client/components/builtin/not-found-e85d6ff71aeabe8d.js +1 -0
  130. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-e85d6ff71aeabe8d.js +1 -0
  131. package/.next/static/chunks/webpack-6451386e3f1b2ec9.js +1 -0
  132. package/.next/static/css/0e3fe8b2c0252430.css +1 -0
  133. package/.next/static/css/{e02ab5db9ff2dca2.css → 5df9ea52964d1443.css} +1 -1
  134. package/.next/static/css/6ada1421df91d770.css +21 -0
  135. package/README.md +5 -351
  136. package/bin/ytdb.mjs +4 -9
  137. package/package.json +3 -1
  138. package/.next/static/chunks/228-e9e3a928efbebb89.js +0 -1
  139. package/.next/static/chunks/6090-6764126dba5d4d96.js +0 -1
  140. package/.next/static/chunks/app/[connectionId]/migrations/(index)/page-34cb852b3259a90b.js +0 -1
  141. package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-34cb852b3259a90b.js +0 -1
  142. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/layout-cdb8e5d125828828.js +0 -1
  143. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-34cb852b3259a90b.js +0 -1
  144. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/schema/page-34cb852b3259a90b.js +0 -1
  145. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/timeline/page-34cb852b3259a90b.js +0 -1
  146. package/.next/static/chunks/app/[connectionId]/page-188bdfaba4f04923.js +0 -1
  147. package/.next/static/chunks/app/[connectionId]/query/page-ef40d6213057d671.js +0 -1
  148. package/.next/static/chunks/app/_global-error/page-34cb852b3259a90b.js +0 -1
  149. package/.next/static/chunks/app/api/activity/route-34cb852b3259a90b.js +0 -1
  150. package/.next/static/chunks/app/api/adopt/route-34cb852b3259a90b.js +0 -1
  151. package/.next/static/chunks/app/api/cell/route-34cb852b3259a90b.js +0 -1
  152. package/.next/static/chunks/app/api/definition/route-34cb852b3259a90b.js +0 -1
  153. package/.next/static/chunks/app/api/delete-rows/route-34cb852b3259a90b.js +0 -1
  154. package/.next/static/chunks/app/api/detect/route-34cb852b3259a90b.js +0 -1
  155. package/.next/static/chunks/app/api/health/route-34cb852b3259a90b.js +0 -1
  156. package/.next/static/chunks/app/api/insert-row/route-34cb852b3259a90b.js +0 -1
  157. package/.next/static/chunks/app/api/ledger/route-34cb852b3259a90b.js +0 -1
  158. package/.next/static/chunks/app/api/lookup/route-34cb852b3259a90b.js +0 -1
  159. package/.next/static/chunks/app/api/migrate/route-34cb852b3259a90b.js +0 -1
  160. package/.next/static/chunks/app/api/note/route-34cb852b3259a90b.js +0 -1
  161. package/.next/static/chunks/app/api/query/route-34cb852b3259a90b.js +0 -1
  162. package/.next/static/chunks/app/api/reconcile/route-34cb852b3259a90b.js +0 -1
  163. package/.next/static/chunks/app/api/rehearse/route-34cb852b3259a90b.js +0 -1
  164. package/.next/static/chunks/app/api/related/route-34cb852b3259a90b.js +0 -1
  165. package/.next/static/chunks/app/api/repo/route-34cb852b3259a90b.js +0 -1
  166. package/.next/static/chunks/app/api/rows/route-34cb852b3259a90b.js +0 -1
  167. package/.next/static/chunks/app/api/schema/route-34cb852b3259a90b.js +0 -1
  168. package/.next/static/chunks/app/api/tables/route-34cb852b3259a90b.js +0 -1
  169. package/.next/static/chunks/app/api/timeline/route-34cb852b3259a90b.js +0 -1
  170. package/.next/static/chunks/app/api/update-row/route-34cb852b3259a90b.js +0 -1
  171. package/.next/static/chunks/app/layout-e3fdecae5544dc60.js +0 -1
  172. package/.next/static/chunks/next/dist/client/components/builtin/app-error-34cb852b3259a90b.js +0 -1
  173. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-34cb852b3259a90b.js +0 -1
  174. package/.next/static/chunks/next/dist/client/components/builtin/not-found-34cb852b3259a90b.js +0 -1
  175. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-34cb852b3259a90b.js +0 -1
  176. package/.next/static/chunks/webpack-34eb118f56295776.js +0 -1
  177. package/.next/static/css/ab9c0ea2c2569929.css +0 -1
  178. package/public/screenshots/ytdb-command-palette.png +0 -0
  179. package/public/screenshots/ytdb-connection.png +0 -0
  180. package/public/screenshots/ytdb-explorer.png +0 -0
  181. /package/.next/static/{XOKG1sVlYC-O8M7Qf5aWE → NB4JOC2i3ctixKpjpc7WH}/_ssgManifest.js +0 -0
package/README.md CHANGED
@@ -1,357 +1,11 @@
1
1
  # YTDB
2
2
 
3
- A fast, local-first PostgreSQL browser for exploring and editing databases without leaving the keyboard.
3
+ YTDB is a fast, local-first PostgreSQL browser and migration tool. Run `npx @theobourgeois/ytdb` and it opens in your browser, with every query going through a small process on your own machine, so connection strings and data never leave it. Point it at your repo's migrations folder and it shows where dev, staging and prod each stand on every migration, lets you apply or revert them one step at a time with notes for whoever runs them next, and keeps a timeline of every run in the database itself. Each environment gets its own color, so you always know whether you're about to touch prod. It also browses and edits tables, follows foreign keys, runs read-only SQL, and diffs two databases' schemas into migration SQL.
4
4
 
5
- ![YTDB browsing a fictional products table](public/screenshots/ytdb-explorer.png)
5
+ ![The migrations list showing which migrations dev, staging and prod have applied](docs/images/migrations.png)
6
6
 
7
- ## What it does
7
+ ![A migration's page on staging with its note and a per-environment checklist](docs/images/migration-detail.png)
8
8
 
9
- - Browse tables and views across multiple PostgreSQL schemas
10
- - Run read-only SQL queries with capped results and searchable local history
11
- - Search, filter, sort, and paginate rows
12
- - Edit cells inline, insert new rows, and delete selected rows
13
- - Follow foreign keys, inspect related records, and peek at complete rows
14
- - Pin, hide, reorder, and resize columns
15
- - Export the current result set as CSV or JSON
16
- - View table and view definitions
17
- - Switch between multiple saved connections and share layouts between them
18
- - Compare two connections' schemas and generate the migration SQL that closes the gap
19
- - Import a folder of migrations and apply or revert them one at a time or all at once, with each
20
- environment's history recorded in the database itself
21
- - Import or export your workspace configuration
22
- - Choose from six built-in themes
9
+ ![The timeline of migration runs across all three environments](docs/images/timeline.png)
23
10
 
24
- ![YTDB's new connection dialog](public/screenshots/ytdb-connection.png)
25
-
26
- ## Jump to any table
27
-
28
- Press <kbd>⌘</kbd>+<kbd>P</kbd> on macOS or <kbd>Ctrl</kbd>+<kbd>P</kbd> elsewhere to search across tables and saved connections. Type a table name to filter, then press <kbd>Enter</kbd> to open it.
29
-
30
- ![YTDB's Command P table palette filtering to products](public/screenshots/ytdb-command-palette.png)
31
-
32
- The screenshots use a disposable local database with fictional product and company names. No production data or credentials are included in this repository.
33
-
34
- ## Compare two databases
35
-
36
- Open **Compare schema** in a connection's sidebar (<kbd>⌘</kbd>+<kbd>⇧</kbd>+<kbd>D</kbd>) to diff it
37
- against another saved connection — dev against prod, say. Connections that already share a layout are
38
- offered first, since those are the same database in another environment.
39
-
40
- The **Changes** pane lists every table, column, index, constraint, trigger, view, enum, function,
41
- extension, and schema that differs, and the **Migration SQL** pane writes the DDL that would bring the
42
- other database in line. Nothing is ever executed from here: copy the script into whatever migration
43
- tool the project already uses. DROP statements are withheld until you ask for them.
44
-
45
- ## Run a folder of migrations
46
-
47
- **Migrations** in a connection's sidebar (<kbd>⌘</kbd>+<kbd>⇧</kbd>+<kbd>M</kbd>) lists the
48
- migrations you have. Each one is a folder of SQL and a page of its own: open it to apply it to an
49
- environment, see where every environment stands on it, or revert it. The list shows that standing at
50
- a glance — `dev 8/8`, `prod 0/8` — so a migration that has been through dev but not prod is obvious
51
- without opening anything.
52
-
53
- ### Read straight from your repo
54
-
55
- Choose **Read from a folder** and give it the path to your project's migrations directory, say
56
- `~/code/app/src/lib/supabase/migrations`. Every folder inside it that holds `.sql` files is one
57
- migration, named after the folder — `key-claims/apply/0001_create_keys.sql` is version 0001 of
58
- `key-claims`, with `key-claims/revert/0001_create_keys.sql` as its undo. A flat folder of `.sql`
59
- files is one migration named after the folder itself.
60
-
61
- Nothing is imported or remembered. The folder is read off the disk by the YTDB running on your
62
- machine every time the page opens, so the list is whatever is on the branch you have checked out,
63
- and the header says which branch that is. Switch branches and the list follows. The path is kept per
64
- set of linked connections, so dev and prod of one project read the same folder and another project
65
- reads its own.
66
-
67
- ### Leaving a note on how to run it
68
-
69
- **Add note** in a migration's `⋯` menu leaves word for whoever runs it next — *apply 0001–0007,
70
- deploy the app, then apply 0008*. It sits above the files on the migration's page, and again in the
71
- confirmation before anything runs. For a migration read from a folder the note is the `README.md`
72
- (or `NOTES.md`) beside its SQL, so it is committed with it and follows the branch; a README already
73
- there is picked up as the note. An imported migration keeps its note in the browser. Emptying the
74
- note removes it.
75
-
76
- ### The ledger
77
-
78
- Applying a migration records it in a small table the database keeps for itself,
79
- `maintenance.ytdb_migrations`, created on the first apply. A row is keyed by the migration's set and
80
- its version together, since every folder numbers its files from 0001. The SQL that ran — and its
81
- revert SQL — is stored in the row alongside it, so a migration belongs to the databases and not to
82
- the browser that happened to have the folder. Open YTDB somewhere else and the ones your databases
83
- have run are listed with how far each environment got; **Open** rebuilds one from the ledger, ready
84
- to apply to the environment that is behind, or revert.
85
-
86
- A ledger written by an earlier YTDB, keyed on version alone, is moved onto the new key the next time
87
- anything is written to it. Rows written before YTDB stored SQL are still listed, but can only be
88
- rebuilt from the folder.
89
-
90
- ### Adopting a database that was migrated by hand
91
-
92
- A database that has been running for a while has already had most of the folder applied to it,
93
- just not through YTDB, so its ledger is empty and everything shows as pending. **Mark everything as
94
- applied** in the list's menu reads the database's schema first and sorts the migrations by what it
95
- finds: the ones whose tables, columns, indexes, types, functions, policies, and triggers are all
96
- there; the ones only partly there; the ones that leave no trace in the schema (data backfills,
97
- seeds, grants); and the ones not there at all. The first group is ticked for you; open any group to
98
- see what is missing for each migration and tick or untick as you know better. Marking writes one
99
- ledger row per ticked migration, in one transaction, without running any SQL, and never touches a
100
- row that is already there. Do it once per environment from a checkout of your main branch, and from
101
- then on only what is genuinely new shows as pending.
102
-
103
- ### Finding what to work on
104
-
105
- The list has a search box and a status filter — not fully applied, not started anywhere, applied
106
- everywhere, or pending on one environment in particular. Both are remembered per set of linked
107
- connections, so the view you left is the view you come back to.
108
-
109
- Drop in whatever you have to start one. A flat folder of migrations is enough:
110
-
111
- ```text
112
- migrations/
113
- 0001_create_customers.sql
114
- 0002_create_orders.sql
115
- ```
116
-
117
- If you keep reverts, put them in a sibling folder and they pair up by the version each name starts
118
- with, whatever the rest of the name says:
119
-
120
- ```text
121
- shop-migrations/
122
- apply/ 0001_create_customers.sql 0002_create_orders.sql
123
- revert/ 0001_create_customers.sql 0002_create_orders.sql
124
- ```
125
-
126
- `up/` and `down/` work as folder names too, as do `0002_create_orders.up.sql` / `.down.sql` suffixes
127
- in a flat folder. **Reverts are optional** — a migration without one applies like any other, and only
128
- Revert is unavailable for it.
129
-
130
- Files do not have to arrive together. Dropping files onto an open migration folds them in: new
131
- versions are added, versions already there have their SQL refreshed, and a revert file finds the
132
- version it belongs to. So you can start one from a folder, add a stray file later, and attach a
133
- revert from a row's `⋯` menu whenever you write one. **New migration** starts an empty one.
134
-
135
- Nothing is appended into one script. Each migration runs on its own, in a transaction, together with
136
- the row that records it — so a migration that fails halfway leaves the database and the ledger exactly
137
- as they were.
138
-
139
- One database at a time is the target, named in the header and in every button: **Running against dev**,
140
- **Apply 6 to dev**. Its column in the list is the tinted one. Switching target is one click on another
141
- environment's column, which opens that connection. **Apply** on a row runs everything still pending up
142
- to and including it, so a target can never end up with a gap in the middle; the `⋯` menu has
143
- *apply only this one* for the rare out-of-order case, and *revert back through here* going the other way.
144
-
145
- To run a handful, tick them — the box in the column header selects them all, and shift-click ticks
146
- everything between. While anything is ticked, the header's Apply, *Mark as already applied*, and
147
- *Revert* cover only the ticked ones, in order, and the selection clears once they have all run.
148
-
149
- A file edited after a database ran it is flagged as drifted, and opening its row shows **Changes**: a
150
- git-style diff of the SQL that database actually ran — kept in its ledger — against the file as it
151
- is now.
152
-
153
- ### Which environments have which migrations
154
-
155
- Each database keeps its own ledger in `maintenance.ytdb_migrations`, written as part of the same
156
- transaction as the migration. Dev is not asked what prod has run — prod is. Connections
157
- [sharing a layout](#compare-two-databases) are the same database in another environment, so their
158
- ledgers are read side by side: every migration shows where it has landed and where it has not, and
159
- the environment strip totals up how far behind each one is. A file edited after it was applied is
160
- flagged as drifted rather than quietly counted as done, and rows in a database that have no file in
161
- the folder are listed separately.
162
-
163
- The ledger is only ever created by the first apply — schema included, so the connection needs
164
- permission to create it. Reading the status of a production connection never writes to it.
165
-
166
- **Ledger table** in the header menu moves it to another schema. The setting covers every connection,
167
- since dev and prod comparing ledgers in different places would mean nothing. A database that already
168
- keeps its ledger somewhere else goes on using it rather than being stranded by the change, and the
169
- status line says where. Schema names must be plain identifiers.
170
-
171
- ### Adopting a database that was migrated by hand
172
-
173
- A database whose schema is already up to date has no ledger, so every migration reads as pending and
174
- applying them would fail on tables that already exist. **Mark as already applied** — on one row from
175
- its `⋯` menu, or on everything pending from the header menu — writes the ledger rows without running
176
- any SQL, which is how you baseline an existing dev or prod. **Mark as not applied** takes a row back
177
- out of the ledger, again without touching the schema. Both say plainly in the confirmation that
178
- nothing will run.
179
-
180
- **History** is both records at once, newest first. Each database's ledger says what it has applied,
181
- when, and under which role — including runs made from someone else's machine, since that record lives
182
- in the database rather than in a browser. This browser's own log adds what a ledger cannot keep:
183
- reverts, failures with their error, and rows written without running anything. A run in both is one
184
- event, not two. Every run is also appended to the [activity log](#activity-log).
185
-
186
- A file that already wraps itself in a single `BEGIN` … `COMMIT` — how most migration folders are
187
- written — needs no changes. YTDB takes that transaction over so its own ledger write joins it, and
188
- says nothing about it. A `BEGIN` inside a PL/pgSQL function body is left alone, as it should be.
189
-
190
- Migrations that PostgreSQL refuses to run inside a transaction — `CREATE INDEX CONCURRENTLY`, say —
191
- opt out with a directive on the first line:
192
-
193
- ```sql
194
- -- ytdb:no-transaction
195
- CREATE INDEX CONCURRENTLY orders_placed_at_idx ON orders (placed_at);
196
- ```
197
-
198
- Those run unwrapped and are recorded straight after, so a failure partway through leaves work behind.
199
- A file that commits more than once is treated the same way, since YTDB cannot join a transaction it
200
- does not control. Both are labelled in the list and named in the confirmation before anything runs.
201
-
202
- ## Run YTDB
203
-
204
- ### Requirements
205
-
206
- - Node.js 20.9 or newer
207
- - npm
208
- - A PostgreSQL database you can reach from your machine
209
-
210
- Start YTDB without cloning the repository:
211
-
212
- ```bash
213
- npx @theobourgeois/ytdb
214
- ```
215
-
216
- Run that command outside a YTDB source checkout. Inside this repository, npm treats the local
217
- package as already installed; use `npx --yes --package=@theobourgeois/ytdb@latest -- ytdb`
218
- when you specifically want to test the published package from here.
219
-
220
- The command starts an authenticated database bridge bound to `127.0.0.1` and opens
221
- [ytdb.theobourgeois.com](https://ytdb.theobourgeois.com). Select **New**, then enter a
222
- name and PostgreSQL connection URL:
223
-
224
- ```text
225
- postgresql://user:password@host:5432/database
226
- ```
227
-
228
- The hosted UI talks directly to that loopback-only bridge. The fragment in the URL contains
229
- a random, per-process session token; URL fragments are not sent to the hosted server. Closing
230
- the command stops database access and restarting it creates a new token.
231
-
232
- To run the entire UI locally or work on YTDB itself:
233
-
234
- ```bash
235
- git clone https://github.com/theobourgeois/YTDB.git
236
- cd YTDB
237
- npm install
238
- npm run dev
239
- ```
240
-
241
- Open [http://127.0.0.1:4371](http://127.0.0.1:4371). No environment variables or
242
- administrator-level hostname setup are required. The Convex scaffold is optional and the UI
243
- still runs when `NEXT_PUBLIC_CONVEX_URL` is unset.
244
-
245
- ## Activity log
246
-
247
- Every action taken in YTDB is appended to a local JSONL log, so you can retrace what
248
- happened while debugging, or mine the history later. Logs are written to
249
- `.ytdb/activity/YYYY-MM-DD.jsonl` (one file per day, ignored by Git).
250
-
251
- ```bash
252
- npm run log # last 50 actions
253
- npm run log -- --follow # stream actions as they happen
254
- npm run log -- --errors # only failures
255
- npm run log -- --action query # only SQL console runs
256
- npm run log -- --slow 500 # only actions taking 500ms or more
257
- npm run log -- --limit all --json # the raw entries, for analysis
258
- npm run log -- --help # all options
259
- ```
260
-
261
- Each line is one self-describing JSON object:
262
-
263
- ```json
264
- {
265
- "v": 1,
266
- "id": "914c2716-d586-4f1b-bae3-d3785969e252",
267
- "ts": "2026-09-03T12:44:41.302Z",
268
- "source": "api",
269
- "action": "rows",
270
- "connection": "postgres://appuser@127.0.0.1:5432/shopdb",
271
- "status": "ok",
272
- "durationMs": 5,
273
- "params": { "query": { "table": { "schema": "public", "name": "widgets" } } },
274
- "result": { "rows": 3, "columns": 3, "total": 3 }
275
- }
276
- ```
277
-
278
- - `action` is one of `tables`, `rows`, `query`, `cell.update`, `rows.insert`, `rows.delete`,
279
- `related`, `lookup`, `definition`, `schema`, `ledger`, `migrate`, or a browser-only action
280
- (`connection.add`, `connection.update`, `connection.remove`, `config.export`, `config.import`,
281
- `migrations.import`, `migrations.remove`).
282
- - `connection` keeps the user, host, and database so entries are attributable, but the
283
- password is always stripped before anything is written.
284
- - `params` records the request that was made; `result` records counts, never row data, so
285
- the log never becomes a copy of your database.
286
- - Payloads over 20 KB are stored as a truncated preview.
287
-
288
- Set `YTDB_LOG=off` to disable logging, or `YTDB_LOG_DIR` to write elsewhere.
289
- Logging is fire-and-forget: a failed write is reported once on the server console and never
290
- fails the action it was recording.
291
-
292
- ## Useful commands
293
-
294
- ```bash
295
- npm run dev # development server on 127.0.0.1:4371
296
- npm run build # production build
297
- npm start # serve the production build
298
- npm run lint # ESLint
299
- npm run log # local activity log
300
- npm pack --dry-run # inspect the publishable npx package
301
- npm run dev:convex # optional Convex development process
302
- ```
303
-
304
- ## Security model
305
-
306
- The UI is hosted, but all PostgreSQL access is performed by the loopback-only process started
307
- by `npx @theobourgeois/ytdb`.
308
-
309
- - Connection URLs are stored in your browser's `localStorage` for the
310
- `ytdb.theobourgeois.com` origin.
311
- - SQL query drafts and history are also stored locally and are never sent to Convex.
312
- - Each database request goes from the hosted UI to `127.0.0.1`, where the local bridge connects
313
- to PostgreSQL. The Vercel deployment refuses all database API requests.
314
- - The bridge accepts only the official UI origin and requests bearing its random session token.
315
- - The hosted page has no analytics or third-party scripts, and its Content Security Policy
316
- blocks scripts and network requests from unapproved origins.
317
- - The query console runs one statement at a time inside a read-only transaction and returns at most 500 rows.
318
- - The migration runner is not read-only: it runs whatever SQL the imported files contain, with the
319
- privileges of the connection you run it from, and creates the `maintenance` schema and its
320
- `ytdb_migrations` table on first use.
321
- Imported migration files are held in your browser and never leave your machine.
322
- - Exported YTDB configuration files include connection URLs. Treat those files like passwords and never commit them.
323
- - The app supports writes, row insertion, and row deletion. Use a read-only or least-privilege PostgreSQL role when you do not need editing.
324
- - The activity log records the SQL you run and the parameters you send. It stays on your
325
- machine in `.ytdb/`, which Git ignores; treat it as sensitive and delete the directory
326
- to clear the history.
327
- - `.env*` files remain ignored by Git, with only the blank `.env.example` template allowed into the repository.
328
-
329
- ## Project structure
330
-
331
- ```text
332
- src/
333
- app/
334
- api/ PostgreSQL route handlers
335
- [connectionId]/ database explorer routes
336
- components/
337
- connections/ connection and config management
338
- diff/ schema comparison between two connections
339
- explorer/ schemas, tables, and navigation
340
- migrations/ importing, running, and reverting migration folders
341
- table/ grid, filters, editors, and pagination
342
- lib/
343
- activity/ local action log
344
- db/ server-only PostgreSQL access
345
- migrations/ folder parsing, ledger comparison, run plans
346
- store/ persisted browser state
347
- schema-diff.ts structural comparison of two snapshots
348
- schema-migration.ts DDL that brings one database in line with another
349
- hooks/ shared React hooks
350
- scripts/ local activity-log reader
351
- bin/ `npx @theobourgeois/ytdb` launcher
352
- convex/ optional Convex scaffold
353
- ```
354
-
355
- ## Tech stack
356
-
357
- [Next.js 16](https://nextjs.org/) · [React 19](https://react.dev/) · [PostgreSQL](https://www.postgresql.org/) · [Tailwind CSS 4](https://tailwindcss.com/) · [Base UI](https://base-ui.com/) · [Zustand](https://zustand.docs.pmnd.rs/) · [Convex](https://www.convex.dev/)
11
+ ![Browsing the products table on prod](docs/images/table.png)
package/bin/ytdb.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawn } from "node:child_process";
4
- import { randomBytes } from "node:crypto";
5
4
  import { existsSync, readFileSync } from "node:fs";
6
5
  import { homedir, platform } from "node:os";
7
6
  import { dirname, join } from "node:path";
@@ -67,12 +66,11 @@ if (!existsSync(nextBin) || !existsSync(buildId)) {
67
66
  process.exit(1);
68
67
  }
69
68
 
70
- const token = randomBytes(32).toString("base64url");
71
- const fragment = `token=${encodeURIComponent(token)}&port=${port}`;
72
69
  const localOrigin = `http://127.0.0.1:${port}`;
70
+ // The hosted UI remembers this port, so later visits to the bare origin find the bridge.
73
71
  const browserUrl = process.argv.includes("--local")
74
- ? `${localOrigin}/#${fragment}`
75
- : `${hostedOrigin}/#${fragment}`;
72
+ ? `${localOrigin}/`
73
+ : `${hostedOrigin}/#port=${port}`;
76
74
 
77
75
  const child = spawn(
78
76
  process.execPath,
@@ -84,7 +82,6 @@ const child = spawn(
84
82
  NEXT_TELEMETRY_DISABLED: "1",
85
83
  // The bridge trusts whichever origin this process actually opened.
86
84
  YTDB_HOSTED_ORIGIN: hostedOrigin,
87
- YTDB_BRIDGE_TOKEN: token,
88
85
  YTDB_LOG_DIR: join(homedir(), ".ytdb", "activity"),
89
86
  },
90
87
  stdio: "inherit",
@@ -105,9 +102,7 @@ for (const signal of ["SIGINT", "SIGTERM"]) {
105
102
  async function waitUntilReady() {
106
103
  for (let attempt = 0; attempt < 100 && !stopped; attempt += 1) {
107
104
  try {
108
- const response = await fetch(`${localOrigin}/api/health`, {
109
- headers: { Authorization: `Bearer ${token}` },
110
- });
105
+ const response = await fetch(`${localOrigin}/api/health`);
111
106
  if (response.ok) return;
112
107
  } catch {
113
108
  // The server is still starting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theobourgeois/ytdb",
3
- "version": "0.2.20",
3
+ "version": "0.3.0",
4
4
  "description": "A fast, local-first PostgreSQL browser.",
5
5
  "homepage": "https://ytdb.theobourgeois.com",
6
6
  "repository": {
@@ -46,9 +46,11 @@
46
46
  "@codemirror/view": "^6.43.10",
47
47
  "@lezer/highlight": "^1.2.3",
48
48
  "@uiw/react-codemirror": "^4.25.11",
49
+ "@xyflow/react": "^12.12.0",
49
50
  "class-variance-authority": "^0.7.1",
50
51
  "clsx": "^2.1.1",
51
52
  "convex": "^1.45.0",
53
+ "elkjs": "^0.12.0",
52
54
  "next": "16.3.0",
53
55
  "pg": "^8.23.0",
54
56
  "react": "19.2.8",
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[228],{7412:(e,t,n)=>{n.d(t,{L:()=>i});var r=n(95155),s=n(13267),a=n(40980);function i({trailing:e,className:t,...n}){return(0,r.jsxs)("div",{className:(0,a.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,r.jsx)(s.TfF,{className:"size-3.5 shrink-0"}),(0,r.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},9385:(e,t,n)=>{function r(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function s(e,t){let n=new Map(e.map(e=>[e.connection.id,e])),s=t.filter(e=>n.has(e.connectionId)).map(e=>({id:e.id,runId:e.runId,connectionId:e.connectionId,connectionName:e.connectionName,version:e.version,name:e.name,at:e.ranAt,kind:"failed"===e.status?"failed":e.recorded?"apply"===e.direction?"marked":"unmarked":"apply"===e.direction?"applied":"reverted",durationMs:e.durationMs,error:e.error,setName:e.setName,fromLedger:!1})),a=new Map;for(let e of s){let t=`${e.connectionId}:${e.setName??""}:${e.version}`,n=a.get(t);(!n||e.at>n.at)&&a.set(t,e)}let i=[...s];for(let t of e)for(let e of t.ledger?.entries??[]){let n=`${t.connection.id}:${e.setName}:${e.version}`,s=a.get(n);if(s&&("applied"===s.kind||"marked"===s.kind)&&2e3>Math.abs(s.at-(r(e.appliedAt)+(e.durationMs??0)))){s.appliedBy=e.appliedBy;continue}i.push({id:`ledger:${t.connection.id}:${e.setName}:${e.version}`,connectionId:t.connection.id,connectionName:t.connection.name,version:e.version,name:e.name||e.version,at:r(e.appliedAt),kind:"applied",durationMs:e.durationMs,setName:e.setName,appliedBy:e.appliedBy,fromLedger:!0})}return i.sort((e,t)=>t.at-e.at)}n.d(t,{x:()=>s})},17021:(e,t,n)=>{n.d(t,{H:()=>N});var r=n(95155),s=n(12115),a=n(13267),i=n(72194),l=n(40891),o=n(89239),d=n(72264),c=n(30374),u=n(7412),m=n(87364),p=n(27529);let h=["applied","reverted","marked","unmarked","failed","uncertain","legacy"];var x=n(79668),f=n(40980),g=n(28335);function v({connection:e,ledgerSchema:t,event:n,step:i,onResolved:l,onRetry:d}){let c,u,h=(0,m.Y)(`reconcile:${e.id}:${t}:${n.id}`,r=>p.F.reconcile(e.url,t,n.id,r)),[x,g]=(0,s.useState)(null),[b,j]=(0,s.useState)(null);async function k(r,s=!1){g(r),j(null);try{await p.F.resolve(e.url,t,{eventId:n.id,outcome:r,checksum:i?.checksum}),l(r),s&&d?.()}catch(e){j(e instanceof Error?e.message:String(e))}finally{g(null)}}if(h.error)return(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b p-3 text-xs text-destructive",role:"alert",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 break-words",children:h.error}),(0,r.jsx)(o.$,{size:"xs",variant:"ghost",onClick:h.reload,children:"Retry"})]});if(!h.data)return(0,r.jsxs)("p",{className:"flex items-center gap-2 border-b p-3 text-xs text-muted-foreground",children:[(0,r.jsx)(a.gnh,{className:"size-3.5 animate-spin"}),"Checking ",e.name,"…"]});let{running:y,detection:N}=h.data,w="revert"===n.direction,$=N?.evidence??[],C=$.filter(e=>e.satisfied).length;return y?(c=`Still running on ${e.name}${y.since?` since ${new Date(y.since).toLocaleTimeString()}`:""}. Leave it be; the timeline updates when it finishes.`,u=null):n.atomic?(c=`This ran in one transaction that never committed, so nothing from it is on ${e.name}.`,u="lost"):N&&"unknown"!==N.verdict?"applied"===N.verdict?(c=`Everything it ${w?"removes is gone from":"creates or changes is on"} ${e.name}.`,u="landed"):"pending"===N.verdict?(c=`Nothing it ${w?"removes is gone from":"creates or changes is on"} ${e.name}.`,u="lost"):(c=`Some of what it does is on ${e.name} and some is not. Finish or undo the rest by hand in the query editor before settling it.`,u=null):(c=`This SQL leaves no trace in the schema — data changes, seeds, grants — so ${e.name} cannot say whether it ran. Check by hand before settling it.`,u=null),(0,r.jsxs)("div",{className:"border-b",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2",children:[(0,r.jsx)("p",{className:"min-w-0 flex-1 text-xs",children:c}),(0,r.jsx)(o.$,{size:"icon-xs",variant:"ghost","aria-label":"Check again",title:"Check again",disabled:h.loading,onClick:h.reload,children:(0,r.jsx)(a.oS8,{className:(0,f.cn)("size-3.5",h.loading&&"animate-spin")})})]}),$.length>0&&(0,r.jsxs)("div",{className:"mx-3 mb-2 max-h-40 overflow-y-auto rounded-md border bg-muted/25",children:[(0,r.jsxs)("p",{className:"border-b px-2 py-1 text-[11px] text-muted-foreground",children:[C," of ",$.length," ",1===$.length?"thing":"things"," it would leave behind ",1===C?"is":"are"," there"]}),$.map(e=>(0,r.jsxs)("p",{className:"flex items-center gap-1.5 px-2 py-0.5 font-mono text-[11px]",children:[e.satisfied?(0,r.jsx)(a.wiW,{className:"size-3 shrink-0 text-emerald-600 dark:text-emerald-400"}):(0,r.jsx)(a.yBK,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,r.jsx)("span",{className:"min-w-0 truncate",title:e.note?`${e.description} — ${e.note}`:e.description,children:e.description})]},e.description))]}),b&&(0,r.jsx)("p",{className:"mx-3 mb-2 rounded-md border border-destructive/25 bg-destructive/5 px-2 py-1 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:b}),!y&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2",children:[(0,r.jsx)(o.$,{size:"xs",variant:"landed"===u?"default":"outline",disabled:null!==x,title:"Writes the ledger row this run would have written. No SQL runs.",onClick:()=>void k("landed"),children:"landed"===x?"Marking…":w?"Mark as reverted":"Mark as applied"}),(0,r.jsx)(o.$,{size:"xs",variant:"lost"===u?"default":"outline",disabled:null!==x,title:"Closes this run as failed. The ledger is left as it is.",onClick:()=>void k("lost"),children:"lost"===x?"Marking…":"Mark as failed"}),d&&!w&&(0,r.jsx)(o.$,{size:"xs",variant:"ghost",disabled:null!==x,title:"Closes this run as failed and runs the migration again.",onClick:()=>void k("lost",!0),children:"Retry"})]})]})}let b={applied:"Applied",reverted:"Reverted",marked:"Marked as applied",unmarked:"Marked as not applied",failed:"Failed",uncertain:"Unconfirmed",legacy:"Previously recorded"};function j({kind:e}){let t="size-3.5 shrink-0";switch(e){case"failed":return(0,r.jsx)(a.yBK,{className:(0,f.cn)(t,"text-destructive")});case"uncertain":return(0,r.jsx)(a.e5t,{className:(0,f.cn)(t,"text-amber-600 dark:text-amber-400")});case"reverted":return(0,r.jsx)(a.ij9,{className:(0,f.cn)(t,"text-amber-600 dark:text-amber-400")});case"marked":return(0,r.jsx)(a.nXx,{className:(0,f.cn)(t,"text-muted-foreground")});case"unmarked":return(0,r.jsx)(a.fJ4,{className:(0,f.cn)(t,"text-muted-foreground")});case"legacy":return(0,r.jsx)(a.A01,{className:(0,f.cn)(t,"text-muted-foreground")});default:return(0,r.jsx)(a.wiW,{className:(0,f.cn)(t,"text-emerald-600 dark:text-emerald-400")})}}function k({event:e,schema:t}){let[n,i]=(0,s.useState)("sql"),d=(0,m.Y)(`timeline:${e.connection.id}:${t}:${e.shared.id}`,n=>p.F.timelineDetail(e.connection.url,t,e.shared.id,n));if(d.error)return(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-destructive",role:"alert",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 break-words",children:d.error}),(0,r.jsx)(o.$,{size:"xs",variant:"ghost",onClick:d.reload,children:"Retry"})]});if(!d.data)return(0,r.jsxs)("p",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,r.jsx)(a.gnh,{className:"size-3.5 animate-spin"}),"Loading…"]});let u=d.data,h="revert"===n?u.revertSql:u.sql,x=[{value:"sql",label:"SQL"}];return null!==u.previousSql&&null!==u.sql&&x.push({value:"changes",label:"Changes"}),null!==u.revertSql&&x.push({value:"revert",label:"Rollback"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b px-3 py-1.5",children:[(0,r.jsx)(c.x,{label:"Saved migration SQL",value:n,options:x,onChange:i}),"changes"===n&&u.previousAt&&(0,r.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Since ",new Date(u.previousAt).toLocaleString()]})]}),"changes"===n?u.previousSql===u.sql?(0,r.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:"Unchanged since the last successful run."}):(0,r.jsx)(g.u,{before:u.previousSql??"",after:u.sql??"",className:"max-h-96 py-2"}):h?(0,r.jsx)("div",{className:"flex max-h-96 min-h-0 flex-col",children:(0,r.jsx)(l.iX,{sql:h,loading:!1,error:null})}):(0,r.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:"No SQL saved."})]})}function y({event:e,settling:t}){var n;let l,[o,d]=(0,s.useState)(!1),c=`timeline-${e.connection.id}-${e.id}`,u=t.ledgerSchema,m=t.findStep?.(e.setName??"",e.version)??null,p="failed"===e.kind||"uncertain"===e.kind?"bg-destructive/5 text-destructive":"bg-muted/30 text-muted-foreground";return(0,r.jsxs)("div",{className:"relative pl-9 before:absolute before:top-0 before:bottom-0 before:left-[11px] before:border-l last:before:bottom-6",children:[(0,r.jsx)("span",{className:"absolute top-3 left-0 flex size-6 items-center justify-center rounded-full border bg-background",children:(0,r.jsx)(j,{kind:e.kind})}),(0,r.jsxs)("button",{type:"button","aria-expanded":o,"aria-controls":c,onClick:()=>d(!o),className:"group flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-lg px-2 py-3 text-left transition-colors hover:bg-muted/50 focus-visible:outline-2 focus-visible:outline-ring",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[(0,r.jsx)("span",{title:(l=[],("marked"===e.kind||"unmarked"===e.kind)&&l.push("No SQL ran. Only the migration record changed."),"legacy"===e.kind&&l.push("Preserved from the earlier ledger, which did not distinguish running from marking."),"uncertain"===e.kind&&l.push("No confirmed outcome: it may still be running, or it was interrupted. Open it to see what the database says."),"failed"===e.kind&&e.shared?.atomic&&l.push("The transaction was rolled back."),e.shared&&!e.shared.atomic&&"legacy"!==e.kind&&l.push("This SQL manages its own transactions, so a failure can leave changes applied."),"browser"===e.source&&l.push("Stored in this browser only."),l.join(" ")||void 0),className:(0,f.cn)("font-medium","failed"===e.kind&&"text-destructive","uncertain"===e.kind&&"text-amber-600 dark:text-amber-400"),children:b[e.kind]}),(0,r.jsx)("span",{className:"font-mono text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 truncate font-medium",title:e.name,children:e.name})]}),(0,r.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)(i.F,{connection:e.connection,className:"size-1.5"}),e.connection.name]}),e.setName&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{className:"max-w-48 truncate",children:e.setName})]}),e.appliedBy&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{title:"PostgreSQL role",children:e.appliedBy})]}),null!==e.durationMs&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{children:null===(n=e.durationMs)?null:n<1e3?`${n} ms`:`${(n/1e3).toFixed(1)} s`})]}),"browser"===e.source&&(0,r.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5",children:"This browser"})]})]}),(0,r.jsx)("time",{dateTime:new Date(e.at).toISOString(),title:new Date(e.at).toLocaleString(),className:"shrink-0 text-[11px] text-muted-foreground tabular-nums",children:new Date(e.at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),(0,r.jsx)(a.nNJ,{className:(0,f.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",o&&"rotate-90")})]}),o&&(0,r.jsxs)("div",{id:c,className:"mb-3 overflow-hidden rounded-lg border bg-background",children:["uncertain"===e.kind&&e.shared&&(0,r.jsx)(v,{connection:e.connection,ledgerSchema:u,event:e.shared,step:m,onResolved:t.onResolved,onRetry:t.onRetry&&m&&"apply"===e.shared.direction?()=>t.onRetry?.(m):void 0}),e.error&&(0,r.jsx)("pre",{className:(0,f.cn)("max-h-48 overflow-auto border-b p-3 font-mono text-[11px] whitespace-pre-wrap break-words",p),children:e.error}),e.shared?(0,r.jsx)(k,{event:e,schema:u}):(0,r.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:"No saved SQL."})]})]})}function N({events:e,connections:t,loading:n,ledgerSchema:l,setName:c,findStep:m,onLedgerChange:g,onRetry:v}){let j=(0,x.jV)(e=>e.clearHistory),[k,w]=(0,s.useState)(""),[$,C]=(0,s.useState)("all"),[S,z]=(0,s.useState)("all"),M=(0,s.useMemo)(()=>t.filter(e=>"all"===$||e.id===$),[t,$]),L=(0,s.useMemo)(()=>({setName:c,query:k.trim(),kind:"all"===S?void 0:S}),[c,k,S]),R=function(e,t,n){let[r,a]=(0,s.useState)({}),[i,l]=(0,s.useState)(!0),o=(0,s.useRef)(r),d=(0,s.useRef)(!1),c=(0,s.useRef)(null),u=JSON.stringify([e.map(e=>[e.id,e.url]),t,n]),m=(0,s.useRef)(u),h=(0,s.useCallback)(async(r=!1)=>{if(d.current)return;d.current=!0,l(!0);let s=new AbortController;c.current=s;let i={...o.current};await Promise.all(e.map(async e=>{let a=o.current[e.id]?.page;if(!r||a?.nextCursor)try{let l=await p.F.timeline(e.url,t,{...n,before:r?a?.nextCursor??void 0:void 0},s.signal);if(a&&l.initialized){let e=new Set(l.events.map(e=>e.id)),t=l.events.some(e=>a.events.some(t=>t.id===e.id));(r||t)&&(l.events=[...l.events,...a.events.filter(t=>!e.has(t.id))].sort((e,t)=>BigInt(e.sequence)>BigInt(t.sequence)?-1:1),r||(l.nextCursor=a.nextCursor))}i[e.id]={page:l}}catch(t){i[e.id]={page:a,error:t instanceof Error?t.message:String(t)}}})),s.signal.aborted||(o.current=i,a(i),l(!1),d.current=!1)},[e,t,n]);return(0,s.useEffect)(()=>{d.current=!1,m.current!==u&&(m.current=u,o.current={});let e=()=>{"visible"===document.visibilityState&&h()},t=window.setTimeout(()=>void h(),200),n=window.setInterval(e,1e4);return window.addEventListener("focus",e),()=>{window.clearTimeout(t),window.clearInterval(n),window.removeEventListener("focus",e),c.current?.abort()}},[h,u]),{reads:r,loading:i,refresh:()=>void h(),loadMore:()=>void h(!0),hasMore:Object.values(r).some(e=>!!e.page?.nextCursor)}}(M,l,L),D={ledgerSchema:l,findStep:m,onRetry:v,onResolved:e=>{R.refresh(),"landed"===e&&g?.()}},q=[];for(let t of M){let n=R.reads[t.id]?.page,r=n?.events??[];for(let e of r)q.push({id:`${t.id}:${e.id}`,connection:t,name:e.name,version:e.version,setName:e.setName,at:Date.parse(e.startedAt),kind:e.kind,durationMs:e.durationMs,appliedBy:e.appliedBy,error:e.error,shared:e,source:"shared"});for(let s of e.filter(e=>e.connectionId===t.id)){if(n?.initialized&&s.fromLedger||r.some(e=>e.id===s.runId||!s.runId&&"legacy"===e.kind&&e.setName===s.setName&&e.version===s.version&&("applied"===s.kind||"marked"===s.kind)&&2e3>Math.abs(Date.parse(e.startedAt)+(e.durationMs??0)-s.at)))continue;let e=s.fromLedger?"legacy":s.kind;(!L.kind||L.kind===e)&&(!L.query||[s.name,s.version,s.setName,s.appliedBy].join(" ").toLowerCase().includes(L.query.toLowerCase()))&&q.push({...s,kind:e,connection:t,source:s.fromLedger?"ledger":"browser"})}}q.sort((e,t)=>t.at-e.at||e.id.localeCompare(t.id));let B=new Map;for(let e of q){let t=function(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?"Today":(n.setDate(n.getDate()-1),t.toDateString()===n.toDateString())?"Yesterday":t.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}(e.at);B.set(t,[...B.get(t)??[],e])}let F=M.filter(e=>R.reads[e.id]?.error),I=e.some(e=>!e.fromLedger),A="all"!==$||"all"!==S,T=A?[t.find(e=>e.id===$)?.name,"all"===S?void 0:b[S]].filter(Boolean).join(" \xb7 "):"All";return(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center gap-1 border-b bg-background px-2 py-1",children:[(0,r.jsx)(u.L,{"aria-label":"Search timeline",placeholder:"Search timeline",value:k,maxLength:200,onChange:e=>w(e.target.value),className:"min-w-0 flex-1",trailing:k?(0,r.jsx)("button",{type:"button","aria-label":"Clear search",className:"cursor-pointer rounded p-0.5 hover:text-foreground",onClick:()=>w(""),children:(0,r.jsx)(a.yBK,{className:"size-3.5"})}):null}),(0,r.jsxs)(d.rI,{children:[(0,r.jsxs)(d.ty,{render:(0,r.jsx)(o.$,{size:"sm",variant:A?"outline":"ghost"}),className:"max-w-56 cursor-pointer",children:[(0,r.jsx)("span",{className:"truncate",children:T}),(0,r.jsx)(a.RQe,{"data-icon":"inline-end"})]}),(0,r.jsxs)(d.SQ,{align:"end",className:"min-w-48",children:[t.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(d.I,{children:[(0,r.jsx)(d.lp,{children:"Environment"}),(0,r.jsxs)(d.Hr,{value:$,onValueChange:e=>C(e),children:[(0,r.jsx)(d.Ht,{value:"all",children:"All environments"}),t.map(e=>(0,r.jsxs)(d.Ht,{value:e.id,children:[(0,r.jsx)(i.F,{connection:e,className:"size-1.5"}),e.name]},e.id))]})]}),(0,r.jsx)(d.mB,{})]}),(0,r.jsxs)(d.I,{children:[(0,r.jsx)(d.lp,{children:"Outcome"}),(0,r.jsxs)(d.Hr,{value:S,onValueChange:e=>z(e),children:[(0,r.jsx)(d.Ht,{value:"all",children:"All outcomes"}),h.map(e=>(0,r.jsx)(d.Ht,{value:e,children:b[e]},e))]})]})]})]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm",onClick:R.refresh,disabled:R.loading,"aria-label":"Refresh timeline",title:"Refresh timeline",children:(0,r.jsx)(a.oS8,{className:(0,f.cn)("size-3.5",R.loading&&"animate-spin")})}),I&&(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm",onClick:()=>j(),"aria-label":"Clear local log",title:"Clears this browser's log. The databases' ledgers and timelines are untouched.",children:(0,r.jsx)(a.GVO,{className:"size-3.5"})})]}),F.map(e=>(0,r.jsxs)("p",{role:"alert",title:R.reads[e.id].error,className:"truncate px-4 pt-2 text-[11px] text-destructive",children:[e.name,": ",R.reads[e.id].error]},e.id)),0===q.length?(0,r.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:R.loading||n?"Reading timeline…":k.trim()||A?"No matching events.":"Nothing has run yet."}):(0,r.jsxs)("div",{className:"px-4 pb-4",children:[[...B].map(([e,t])=>(0,r.jsxs)("section",{"aria-label":e,children:[(0,r.jsx)("h3",{className:"pt-4 pb-2 text-[11px] font-medium text-muted-foreground",children:e}),t.map(e=>(0,r.jsx)(y,{event:e,settling:D},e.id))]},e)),R.hasMore&&(0,r.jsx)("div",{className:"flex justify-center pt-4",children:(0,r.jsx)(o.$,{variant:"ghost",size:"sm",onClick:R.loadMore,disabled:R.loading,children:R.loading?"Loading…":"Load older"})})]})]})}},18349:(e,t,n)=>{n.d(t,{T:()=>a});var r=n(95155);n(12115);var s=n(40980);function a({className:e,...t}){return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,s.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}},27013:(e,t,n)=>{n.d(t,{K:()=>o});var r=n(95155),s=n(12115),a=n(89239),i=n(42763),l=n(60529);function o(e){return(0,r.jsx)(i.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,r.jsx)(i.Cf,{className:"sm:max-w-sm",showCloseButton:!1,children:e.open&&(0,r.jsx)(d,{...e})})})}function d({title:e,initial:t="",submitLabel:n,onOpenChange:o,onSubmit:c}){let[u,m]=(0,s.useState)(t),p=u.trim();return(0,r.jsxs)("form",{onSubmit:function(e){e.preventDefault(),p&&(c(p),o(!1))},className:"flex flex-col gap-4",children:[(0,r.jsx)(i.c7,{children:(0,r.jsx)(i.L3,{children:e})}),(0,r.jsx)(l.p,{autoFocus:!0,"aria-label":"Migration name",value:u,placeholder:"add_users_table",onChange:e=>m(e.target.value),onFocus:e=>e.currentTarget.select()}),(0,r.jsxs)(i.Es,{children:[(0,r.jsx)(a.$,{type:"button",variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),(0,r.jsx)(a.$,{type:"submit",disabled:!p,children:n})]})]})}},28335:(e,t,n)=>{n.d(t,{u:()=>o});var r=n(95155),s=n(12115);function a(e){let t=e.replace(/\r\n?/g,"\n").replace(/\s+$/,"");return t?t.split("\n"):[]}var i=n(40980);let l={same:" ",add:"+",remove:"-"};function o({before:e,after:t,className:n}){let c=(0,s.useMemo)(()=>(function(e,t=3){let n=[];e.forEach((r,s)=>{if("same"===r.kind)return;let a=Math.max(0,s-t),i=Math.min(e.length-1,s+t),l=n.at(-1);l&&a<=l[1]+1?l[1]=Math.max(l[1],i):n.push([a,i])});let r=[],s=[],a=0,i=0;for(let t of e)r.push(a),s.push(i),"add"!==t.kind&&(a+=1),"remove"!==t.kind&&(i+=1);return n.map(([t,n])=>{let a=e.slice(t,n+1),i=a.filter(e=>"add"!==e.kind).length,l=a.filter(e=>"remove"!==e.kind).length,o=r[t]+ +(0!==i),d=s[t]+ +(0!==l);return{header:`@@ -${o},${i} +${d},${l} @@`,lines:a}})})(function(e,t){let n=a(e),r=a(t),s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;let i=0;for(;i<n.length-s&&i<r.length-s&&n[n.length-1-i]===r[r.length-1-i];)i+=1;let l=n.slice(s,n.length-i),o=r.slice(s,r.length-i),d=function(e,t){let n=e.length,r=t.length,s=n+r,a=s+1,i=new Int32Array(2*s+3),l=[],o=!1;for(let d=0;d<=s&&!o;d+=1){if((l.length+1)*i.length>2e7)return null;l.push(i.slice());for(let s=-d;s<=d;s+=2){let l=s===-d||s!==d&&i[a+s-1]<i[a+s+1]?i[a+s+1]:i[a+s-1]+1,c=l-s;for(;l<n&&c<r&&e[l]===t[c];)l+=1,c+=1;if(i[a+s]=l,l>=n&&c>=r){o=!0;break}}}let d=[],c=n,u=r;for(let n=l.length-1;n>=0;n-=1){let r=l[n],s=c-u,i=s===-n||s!==n&&r[a+s-1]<r[a+s+1]?s+1:s-1,o=r[a+i],m=o-i;for(;c>o&&u>m;)d.push({kind:"same",text:e[c-1]}),c-=1,u-=1;n>0&&(c===o?d.push({kind:"add",text:t[u-1]}):d.push({kind:"remove",text:e[c-1]})),c=o,u=m}return d.reverse()}(l,o)??[...l.map(e=>({kind:"remove",text:e})),...o.map(e=>({kind:"add",text:e}))],c=[...n.slice(0,s).map(e=>({kind:"same",text:e})),...d,...n.slice(n.length-i).map(e=>({kind:"same",text:e}))],u=0,m=0;return c.map(e=>"same"===e.kind?(u+=1,m+=1,{...e,oldNo:u,newNo:m}):"remove"===e.kind?(u+=1,{...e,oldNo:u,newNo:null}):(m+=1,{...e,oldNo:null,newNo:m}))}(e,t)),[e,t]);return 0===c.length?(0,r.jsx)("p",{className:(0,i.cn)("text-xs text-muted-foreground",n),children:"Only whitespace at the end of the file differs."}):(0,r.jsx)("div",{className:(0,i.cn)("overflow-auto font-mono text-[11px] leading-5",n),children:(0,r.jsx)("table",{className:"w-full border-collapse",children:c.map(e=>(0,r.jsxs)("tbody",{children:[(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:3,className:"bg-muted/60 px-3 text-muted-foreground select-none",children:e.header})}),e.lines.map((e,t)=>(0,r.jsxs)("tr",{className:(0,i.cn)("add"===e.kind&&"bg-emerald-500/12","remove"===e.kind&&"bg-red-500/12"),children:[(0,r.jsx)(d,{value:e.oldNo}),(0,r.jsx)(d,{value:e.newNo}),(0,r.jsxs)("td",{className:"pr-3 whitespace-pre",children:[(0,r.jsx)("span",{className:(0,i.cn)("inline-block w-4 pl-1 select-none","add"===e.kind&&"text-emerald-600 dark:text-emerald-400","remove"===e.kind&&"text-red-600 dark:text-red-400"),children:l[e.kind]}),e.text]})]},t))]},e.header))})})}function d({value:e}){return(0,r.jsx)("td",{className:"w-10 min-w-10 pr-2 text-right text-muted-foreground/50 tabular-nums select-none",children:e??""})}},33807:(e,t,n)=>{n.d(t,{J:()=>a});var r=n(95155);n(12115);var s=n(40980);function a({className:e,...t}){return(0,r.jsx)("label",{"data-slot":"label",className:(0,s.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},35942:(e,t,n)=>{n.d(t,{F:()=>c});var r=n(95155);n(12115);var s=n(76166),a=n(90839),i=n(84588),l=n(66784),o=n(64084),d=n(40980);function c({className:e,children:t,...n}){return(0,r.jsxs)(s.V,{"data-slot":"scroll-area",className:(0,d.cn)("relative",e),...n,children:[(0,r.jsx)(a.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,r.jsx)(u,{}),(0,r.jsx)(i.I,{})]})}function u({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,d.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...n,children:(0,r.jsx)(o.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},41069:(e,t,n)=>{n.d(t,{hX:()=>a,lj:()=>l,z2:()=>i});var r=n(95155),s=n(30374);function a(e){return"schema"===e?"schema":"timeline"===e?"history":"migrations"}function i(e){return"schema"===e?"schema":"history"===e?"timeline":void 0}function l({caption:e,pane:t,onPaneChange:n,migrationsLabel:a="Migrations",showSchema:i=!1}){return(0,r.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:e}),(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)(s.x,{label:"Migrations pane",value:t,onChange:n,options:[{value:"migrations",label:a},...i?[{value:"schema",label:"Schema"}]:[],{value:"history",label:"Timeline"}]})})]})}},42763:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>b,L3:()=>j,c7:()=>v,lG:()=>h,rr:()=>k});var r=n(95155);n(12115);var s=n(98408),a=n(32949),i=n(45477),l=n(88593),o=n(52579),d=n(11975),c=n(31799),u=n(40980),m=n(89239),p=n(13267);function h({...e}){return(0,r.jsx)(s.D,{"data-slot":"dialog",...e})}function x({...e}){return(0,r.jsx)(a.Z,{"data-slot":"dialog-portal",...e})}function f({className:e,...t}){return(0,r.jsx)(i.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...s}){return(0,r.jsxs)(x,{children:[(0,r.jsx)(f,{}),(0,r.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s,children:[t,n&&(0,r.jsxs)(o.H,{"data-slot":"dialog-close",render:(0,r.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,r.jsx)(p.yBK,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function v({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function b({className:e,showCloseButton:t=!1,children:n,...s}){return(0,r.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...s,children:[n,t&&(0,r.jsx)(o.H,{render:(0,r.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,r.jsx)(d.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function k({className:e,...t}){return(0,r.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},59221:(e,t,n)=>{n.d(t,{o:()=>j});var r=n(95155),s=n(12115),a=n(40980);let i=/^ {0,3}(`{3,}|~{3,})/,l=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,o=/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/,d=/^( {0,3})([-*+])(\s+|$)/,c=/^( {0,3})(\d{1,9})[.)](\s+|$)/,u=/^ {0,3}>\s?/,m=/^\[([ xX])\]\s+/;function p(e){return""===e.trim()}function h(e){return i.test(e)||l.test(e)||o.test(e)||d.test(e)||c.test(e)||u.test(e)}function x(e){return e.length-e.trimStart().length}let f=/\\([\\`*_[\]()#>~-])|(`+)([\s\S]*?[^`])\2(?!`)|\*\*(.+?)\*\*|(?<!\w)__(.+?)__(?!\w)|\*(?=\S)(.+?)(?<=\S)\*|(?<!\w)_(?=\S)(.+?)(?<=\S)_(?!\w)|~~(.+?)~~|\[([^\]]+)\]\(([^)\s]+)\)|(https?:\/\/[^\s<]+[^\s<.,:;"')\]!?])|\n/g;function g(e){let t=[],n=0,s=0;for(let a of e.matchAll(f)){let i=a.index??0;i>n&&t.push(e.slice(n,i)),n=i+a[0].length;let[l,o,,d,c,u,m,p,h,x,f,j]=a;void 0!==o?t.push(o):void 0!==d?t.push((0,r.jsx)(v,{children:d.trim()},s++)):void 0!==c||void 0!==u?t.push((0,r.jsx)("strong",{className:"font-medium text-foreground",children:g(c??u)},s++)):void 0!==m||void 0!==p?t.push((0,r.jsx)("em",{children:g(m??p)},s++)):void 0!==h?t.push((0,r.jsx)("s",{children:g(h)},s++)):void 0!==x?t.push((0,r.jsx)(b,{href:f,children:g(x)},s++)):void 0!==j?t.push((0,r.jsx)(b,{href:j,children:j},s++)):"\n"===l&&t.push((0,r.jsx)("br",{},s++))}return n<e.length&&t.push(e.slice(n)),t}function v({children:e}){return(0,r.jsx)("code",{className:"rounded bg-muted px-1 py-px font-mono text-[0.92em]",children:e})}function b({href:e,children:t}){let n=/^(https?:|mailto:)/i.test(e);return(0,r.jsx)("a",{href:n?e:void 0,target:"_blank",rel:"noreferrer",className:"underline decoration-muted-foreground/50 underline-offset-2 hover:decoration-foreground",children:t})}function j({text:e,className:t}){let n=function e(t){let n=[],r=0;for(;r<t.length;){let s=t[r];if(p(s)){r+=1;continue}let a=i.exec(s);if(a){let e=RegExp(`^ {0,3}${a[1][0]}{${a[1].length},}\\s*$`),s=[];for(r+=1;r<t.length&&!e.test(t[r]);)s.push(t[r]),r+=1;r+=1,n.push({type:"code",code:s.join("\n")});continue}let f=l.exec(s);if(f){n.push({type:"heading",level:f[1].length,text:f[2]}),r+=1;continue}if(o.test(s)){n.push({type:"rule"}),r+=1;continue}if(u.test(s)){let s=[];for(;r<t.length&&u.test(t[r]);)s.push(t[r].replace(u,"")),r+=1;n.push({type:"quote",blocks:e(s)});continue}let g=d.exec(s)??c.exec(s);if(g){let a=c.test(s),i=a?Number(g[2]):1,l=[];for(;r<t.length;){let n=(a?c:d).exec(t[r]);if(!n)break;let s=n[0].length,i=[t[r].slice(s)];for(r+=1;r<t.length;){let e=t[r];if(p(e)){let e=t[r+1];if(void 0!==e&&x(e)>=2){i.push(""),r+=1;continue}break}if(x(e)>=2){i.push(e.slice(Math.min(s,x(e)))),r+=1;continue}if(!h(e)&&""!==i[i.length-1]){i.push(e),r+=1;continue}break}let o=m.exec(i[0]);for(o&&(i[0]=i[0].replace(m,"")),l.push({checked:o?" "!==o[1]:null,blocks:e(i)});r<t.length&&p(t[r])&&void 0!==t[r+1];)if((a?c:d).test(t[r+1]))r+=1;else break}n.push({type:"list",ordered:a,start:i,items:l});continue}let v=[s];for(r+=1;r<t.length&&!p(t[r])&&!h(t[r]);)v.push(t[r]),r+=1;n.push({type:"paragraph",text:v.join("\n")})}return n}(e.replace(/\r\n?/g,"\n").split("\n"));return(0,r.jsx)("div",{className:(0,a.cn)("space-y-2 break-words",t),children:function e(t,n){return t.map((t,i)=>{switch(t.type){case"heading":return(0,r.jsx)("p",{className:(0,a.cn)("font-medium text-foreground",t.level<=2?"text-[1.1em]":""),children:g(t.text)},i);case"paragraph":return n?(0,r.jsx)(s.Fragment,{children:g(t.text)},i):(0,r.jsx)("p",{children:g(t.text)},i);case"quote":return(0,r.jsx)("blockquote",{className:"space-y-2 border-l-2 pl-3 text-muted-foreground",children:e(t.blocks,!1)},i);case"code":return(0,r.jsx)("pre",{className:"overflow-x-auto rounded-md border bg-muted/40 px-2.5 py-2 font-mono text-[0.92em] leading-relaxed",children:t.code},i);case"rule":return(0,r.jsx)("hr",{className:"border-border"},i);case"list":{let n=t.ordered?"ol":"ul",s=t.items.some(e=>null!==e.checked);return(0,r.jsx)(n,{start:t.ordered?t.start:void 0,className:(0,a.cn)("space-y-0.5",s?"list-none pl-0":t.ordered?"list-decimal pl-5":"list-disc pl-5"),children:t.items.map((t,n)=>{let s=1===t.blocks.length&&"paragraph"===t.blocks[0].type;return(0,r.jsxs)("li",{className:(0,a.cn)(null!==t.checked&&"flex items-start gap-2"),children:[null!==t.checked&&(0,r.jsx)("span",{"aria-hidden":!0,className:(0,a.cn)("mt-[0.3em] inline-flex size-[0.85em] shrink-0 items-center justify-center rounded-[3px] border",t.checked?"border-foreground bg-foreground text-background":"border-muted-foreground/60"),children:t.checked&&(0,r.jsx)("svg",{viewBox:"0 0 12 12",className:"size-[0.7em]",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M2.5 6.5 5 9l4.5-6",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,r.jsx)("span",{className:(0,a.cn)("min-w-0",!s&&"block space-y-1.5",t.checked&&"text-muted-foreground line-through"),children:e(t.blocks,s)})]},n)})},i)}}})}(n,!1)})}},60529:(e,t,n)=>{n.d(t,{p:()=>i});var r=n(95155);n(12115);var s=n(64878),a=n(40980);function i({className:e,type:t,...n}){return(0,r.jsx)(s.p,{type:t,"data-slot":"input",className:(0,a.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...n})}},62417:(e,t,n)=>{n.d(t,{DM:()=>p,FY:()=>o,Gf:()=>a,ay:()=>l,e:()=>m,eh:()=>d,gj:()=>u,kB:()=>x,lF:()=>g,n9:()=>h,nb:()=>c,nj:()=>f,yy:()=>v});var r=n(20642);let s={steps:[],blockedBy:null};function a(e,t){return e?{...e,entries:e.entries.filter(e=>e.setName===t)}:null}function i(e){let t=new Map;for(let n of e?.entries??[])t.set(n.version,n);return t}function l(e,t){return t?t.entries.find(t=>t.version===e.version)??null:null}function o(e,t){if(!t)return"unknown";let n=l(e,t);return n?n.checksum&&n.checksum!==e.checksum?"drifted":"applied":"pending"}function d(e,t){let n={total:e?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!e)return n;let r=a(t,e.name);for(let t of e.steps){let e=o(t,r);"applied"===e?n.applied+=1:"drifted"===e?n.drifted+=1:"pending"===e&&(n.pending+=1)}return n.foreign=c(e,r).length,n}function c(e,t){if(!t)return[];let n=new Set((e?.steps??[]).map(e=>e.version));return t.entries.filter(e=>!n.has(e.version)).sort((e,t)=>(0,r.Zy)(e.version,t.version))}function u(e,t,n){if(!e||!t)return s;let r=[];for(let s of e.steps)if("pending"===o(s,t)&&r.push(s),void 0!==n&&s.version===n)break;return{steps:r,blockedBy:null}}function m(e,t,n){if(!e||!t)return s;let a=i(t),l=[];for(let t of[...e.steps].reverse()){if(void 0!==n&&0>(0,r.Zy)(t.version,n))break;if(a.has(t.version)){if(!t.revertSql)return{steps:l,blockedBy:t};l.push(t)}}return{steps:l,blockedBy:null}}function p(e,t,n){return e&&t?{steps:e.steps.filter(e=>n.has(e.version)&&"pending"===o(e,t)),blockedBy:null}:s}function h(e,t,n){if(!e||!t)return s;let r=i(t),a=[];for(let t of[...e.steps].reverse())if(n.has(t.version)&&r.has(t.version)){if(!t.revertSql)return{steps:a,blockedBy:t};a.push(t)}return{steps:a,blockedBy:null}}function x(e,t){if(!e||!t)return null;let n=i(t);for(let t of[...e.steps].reverse())if(n.has(t.version))return t;return null}function f(e,t){if(!e||0===e.entries.length)return null;let n=e.entries[0].version;for(let t of e.entries)(0,r.Zy)(t.version,n)>0&&(n=t.version);let s=t.filter(e=>0>(0,r.Zy)(e.version,n));return s.length>0?{steps:s,after:n}:null}function g(e,t){let n=new Set(t.map(e=>e.toLowerCase())),s=new Map;for(let t of e)for(let e of t.ledger?.entries??[]){let r=e.setName.trim();if(!r||n.has(r.toLowerCase()))continue;let a=s.get(r)??new Map,i=a.get(t.connection.id)??new Set;i.add(e.version),a.set(t.connection.id,i),s.set(r,a)}return[...s.entries()].map(([t,n])=>{let s=new Set;for(let e of n.values())for(let t of e)s.add(t);return{name:t,versions:[...s].sort(r.Zy),total:s.size,applied:e.map(e=>({connectionId:e.connection.id,connectionName:e.connection.name,count:n.get(e.connection.id)?.size??0}))}}).sort((e,t)=>e.name.localeCompare(t.name))}function v(e,t,n){let r=n.query.trim().toLowerCase();if(r&&![e.name,...e.steps.flatMap(e=>[e.version,e.name])].join("\n").toLowerCase().includes(r))return!1;let{status:s}=n;if("all"===s)return!0;if(s.startsWith("pending:")){let e=t.find(e=>e.connectionId===s.slice(8));return!e||!e.read||e.summary.pending>0||e.summary.drifted>0}return"pending"===s?t.some(e=>!e.read||e.summary.pending>0||e.summary.drifted>0):"untouched"===s?t.every(e=>!e.read||0===e.summary.applied&&0===e.summary.drifted):"complete"!==s||e.steps.length>0&&t.every(e=>e.read&&0===e.summary.pending&&0===e.summary.drifted)}},71612:(e,t,n)=>{n.d(t,{y:()=>a});var r=n(87364),s=n(27529);function a(e,t){return(0,r.Y)(`repo:${e??""}:${t??""}`,async n=>e?s.F.repo(e,t,n):null)}},72194:(e,t,n)=>{n.d(t,{F:()=>i});var r=n(95155),s=n(40980),a=n(32538);function i({connection:e,className:t}){return(0,r.jsx)("span",{"aria-hidden":!0,className:(0,s.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,a.Mq)(e)}})}},77649:(e,t,n)=>{n.d(t,{k:()=>p,$:()=>m});var r=n(95155),s=n(12115),a=n(13267),i=n(89239);function l(e){let t=e.createReader?.();return t?new Promise((e,n)=>{let r=[],s=()=>{t.readEntries(t=>{0===t.length||r.length>=2e3?e(r):(r.push(...t),s())},n)};s()}):Promise.resolve([])}async function o(e,t,n,r){if(r.length>=2e3||n>6||e.name.startsWith("."))return;let s=t?`${t}/${e.name}`:e.name;if(e.isFile){if(!/\.sql$/i.test(e.name))return;let t=await new Promise((t,n)=>{e.file?e.file(t,n):n(Error(`Could not read ${e.name}`))});r.push({path:s,text:await t.text()});return}if(e.isDirectory)for(let t of(await l(e)))await o(t,s,n+1,r)}async function d(e){let t=[];for(let n of Array.from(e.items)){if("file"!==n.kind)continue;let e=n.webkitGetAsEntry?.();e&&t.push(e)}if(0===t.length){let t=Array.from(e.files).filter(e=>/\.sql$/i.test(e.name));return 0===t.length?null:{name:"Migrations",files:await Promise.all(t.map(async e=>({path:e.name,text:await e.text()})))}}let n=1===t.length&&t[0].isDirectory?t[0]:null,r=[];if(n){for(let e of(await l(n)))await o(e,"",1,r);return{name:n.name,files:r}}for(let e of t)await o(e,"",0,r);return r.length>0?{name:"Migrations",files:r}:null}async function c(e){let t,n=Array.from(e).filter(e=>/\.sql$/i.test(e.name));if(0===n.length)return null;let r=new Set(n.map(e=>(e.webkitRelativePath||e.name).split("/")[0])),s=1===r.size&&((t=n[0]).webkitRelativePath||t.name).includes("/")?[...r][0]:null;return{name:s??"Migrations",files:await Promise.all(n.slice(0,2e3).map(async e=>{let t=e.webkitRelativePath||e.name;return{path:s?t.slice(s.length+1):t,text:await e.text()}}))}}var u=n(40980);function m(e){let[t,n]=(0,s.useState)(!1),[r,a]=(0,s.useState)(null);return{importFrom:(0,s.useCallback)(async t=>{n(!0),a(null);try{let n=t instanceof FileList?await c(t):await d(t);if(!n||0===n.files.length)return void a("No .sql files in there.");e(n)}catch(e){a(e instanceof Error?e.message:"Couldn’t read that folder.")}finally{n(!1)}},[e]),busy:t,error:r,clearError:()=>a(null)}}function p({onFiles:e,className:t,compact:n=!1}){let{importFrom:l,busy:o,error:d}=m(e),[c,h]=(0,s.useState)(!1),x=(0,s.useRef)(null),f=(0,s.useRef)(null);return(0,s.useEffect)(()=>{x.current?.setAttribute("webkitdirectory",""),x.current?.setAttribute("directory","")},[]),(0,r.jsxs)("div",{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:e=>{e.preventDefault(),h(!1),l(e.dataTransfer)},className:(0,u.cn)("flex items-center justify-center rounded-lg border border-dashed text-center transition-colors",n?"flex-wrap gap-x-3 gap-y-2 px-4 py-3":"flex-col gap-4 px-6 py-10",c?"border-primary bg-primary/5":"border-border",t),children:[o?(0,r.jsx)(a.gnh,{className:"size-4 shrink-0 animate-spin text-muted-foreground"}):(0,r.jsx)(a.FeY,{className:(0,u.cn)("shrink-0 text-muted-foreground",n?"size-4":"size-5")}),n?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Drop a folder of .sql files"}):(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Drop a migration folder"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:".sql files, optionally split into apply/ and revert/"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)(i.$,{size:n?"xs":"sm",variant:n?"ghost":"outline",disabled:o,onClick:()=>x.current?.click(),children:[(0,r.jsx)(a.WzY,{"data-icon":"inline-start"}),"Choose folder"]}),(0,r.jsx)(i.$,{size:n?"xs":"sm",variant:"ghost",disabled:o,onClick:()=>f.current?.click(),children:"Choose files"})]}),d&&(0,r.jsx)("p",{className:"w-full text-xs text-destructive",children:d}),(0,r.jsx)("input",{ref:x,type:"file",multiple:!0,className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}}),(0,r.jsx)("input",{ref:f,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}})]})}},83504:(e,t,n)=>{n.d(t,{I:()=>u,p:()=>d});var r=n(95155),s=n(13267),a=n(59221),i=n(72194),l=n(89239),o=n(42763);function d(e){try{let t=new URL(e),n=t.username?`${decodeURIComponent(t.username)}@`:"",r=t.port?`:${t.port}`:"";return`${n}${t.hostname}${r}${t.pathname}`}catch{return"this connection"}}function c({status:e}){switch(e){case"running":return(0,r.jsx)(s.gnh,{className:"size-3.5 shrink-0 animate-spin text-primary"});case"ok":return(0,r.jsx)(s.wiW,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"});case"failed":return(0,r.jsx)(s.yBK,{className:"size-3.5 shrink-0 text-destructive"});case"skipped":return(0,r.jsx)(s.uPM,{className:"size-3.5 shrink-0 text-muted-foreground/60"});default:return(0,r.jsx)(s.Rzr,{className:"size-3.5 shrink-0 text-muted-foreground/60"})}}function u({open:e,direction:t,connection:n,steps:m,blockedBy:p,progress:h,running:x,recordOnly:f,note:g,outOfOrder:v,rehearsal:b,onRun:j,onRehearse:k,onStop:y,onClose:N}){let w=f?"apply"===t?"Mark as applied":"Mark as not applied":"apply"===t?"Apply":"Revert",$=f?"Marked":"apply"===t?"Applied":"Reverted",C=m.length,S=m.filter(e=>{var t;return"wrapped-by-ytdb"!==(t=e.transaction)&&"self-wrapped"!==t}),z=h?.find(e=>"failed"===e.status)??null,M=null!==h&&!x,L=h?.filter(e=>"ok"===e.status).length??0,R=!h||b&&M,D=v?.steps??[],q=h??m.map(e=>({version:e.version,name:e.name,status:"waiting"}));return(0,r.jsx)(o.lG,{open:e,onOpenChange:e=>!e&&!x&&N(),children:(0,r.jsxs)(o.Cf,{className:"sm:max-w-lg",children:[(0,r.jsxs)(o.c7,{children:[(0,r.jsx)(o.L3,{children:0===C&&p?"Nothing here can be reverted":b&&h?x?`Dry run of ${C} migration${1===C?"":"s"}…`:z?`Dry run failed at ${L+1} of ${C}`:`Dry run passed: ${C} migration${1===C?"":"s"}`:M?z?`${w} stopped after ${L} of ${C}`:`${$} ${L} migration${1===L?"":"s"}`:f?`${"Mark as applied"===w?"Mark":"Unmark"} ${C} migration${1===C?"":"s"} on ${n.name}?`:`${w} ${C} migration${1===C?"":"s"}?`}),(0,r.jsx)(o.rr,{children:(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{children:f?M?"Recorded on":"Records on":b&&h?"Tried against, without keeping anything on":M?"Ran against":"Runs against"}),(0,r.jsx)(i.F,{connection:n}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:n.name}),(0,r.jsx)("span",{className:"font-mono text-[11px]",children:d(n.url)})]})})]}),R&&g&&(0,r.jsxs)("div",{className:"flex max-h-40 gap-2 overflow-y-auto rounded-md border bg-muted/30 px-3 py-2 text-xs",children:[(0,r.jsx)(s.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(a.o,{text:g,className:"min-w-0 flex-1"})]}),q.length>0&&(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:q.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-1.5 text-xs last:border-b-0",children:[(0,r.jsx)(c,{status:e.status}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),void 0!==e.durationMs&&(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.durationMs," ms"]})]},e.version))}),z?.error&&(0,r.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:z.error}),R&&p&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(s.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:0===C?`${p.version} ${p.name} is the newest one applied and has no revert file, so nothing below it can be reached.`:`Stops at ${p.version} ${p.name}, which has no revert file.`})]}),R&&f&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on ",n.name," ","changes."]}),R&&!f&&"apply"===t&&D.length>0&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(s.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsxs)("span",{children:[1===D.length?`${D[0].version} is older than ${v?.after}, which is already applied here.`:`${D.map(e=>e.version).join(", ")} are older than ${v?.after}, which is already applied here.`," ",1===D.length?"It was":"They were"," probably merged after it ran, so check"," ",1===D.length?"it does":"they do"," not depend on going first."]})]}),R&&!f&&S.length>0&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(s.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:1===S.length?`${S[0].version} runs outside a transaction, so a failure partway leaves it half applied.`:`${S.length} of these run outside a transaction, so a failure partway leaves them half applied.`})]}),R&&!f&&"revert"===t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reverting runs newest first and can drop data the migrations created."}),(0,r.jsx)(o.Es,{children:x?b?(0,r.jsx)(l.$,{variant:"outline",disabled:!0,children:"Trying…"}):(0,r.jsx)(l.$,{variant:"outline",onClick:y,children:"Stop after this one"}):M&&!b?(0,r.jsx)(l.$,{onClick:N,children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.$,{variant:"outline",onClick:N,children:0===C?"Close":"Cancel"}),C>0&&k&&!f&&(0,r.jsxs)(l.$,{variant:"outline",onClick:k,title:"Runs every step in one transaction and rolls it back, so you see whether it would go through without changing anything.",children:[(0,r.jsx)(s.DPG,{"data-icon":"inline-start"}),b&&M?"Dry run again":"Dry run"]}),C>0&&(0,r.jsx)(l.$,{variant:f||"revert"!==t?"default":"destructive",onClick:j,children:f?`${w} (${C})`:`${w} ${1===C?"migration":`${C} migrations`}`})]})})]})})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6090],{25:(e,t,r)=>{r.d(t,{Ol:()=>l,TA:()=>d,qb:()=>u});let n=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,i=new Set(["begin","start"]),a=new Set(["commit","end"]),o=new Set(["rollback"]);function s(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)||void 0!==e&&e>="0"&&e<="9"}function l(e){if(n.test(e))return{mode:"unwrapped",sql:e,atomic:!1};let t=function(e){let t=[],r=0,n=0,i=n=>{let i=function(e,t){let r=t;for(;r<e.length;){let t=e[r];if(" "===t||" "===t||"\n"===t||"\r"===t){r+=1;continue}if("-"===t&&"-"===e[r+1]){for(;r<e.length&&"\n"!==e[r];)r+=1;continue}if("/"===t&&"*"===e[r+1]){let t=e.indexOf("*/",r+2);r=-1===t?e.length:t+2;continue}break}return r}(e,r);if(i>=n)return;let a=i;for(;a<e.length&&s(e[a]);)a+=1;t.push({at:i,end:n,keyword:e.slice(i,a).toLowerCase()})};for(;n<e.length;){let t=e[n];if("-"===t&&"-"===e[n+1]){for(;n<e.length&&"\n"!==e[n];)n+=1;continue}if("/"===t&&"*"===e[n+1]){let t=e.indexOf("*/",n+2);n=-1===t?e.length:t+2;continue}if("'"===t||'"'===t){n=function(e,t,r){let n=t+1;for(;n<e.length;){if(e[n]===r){if(e[n+1]===r){n+=2;continue}return n+1}n+=1}return n}(e,n,t);continue}if("$"===t){let t=function(e,t){if("$"!==e[t])return null;let r=t+1;for(;r<e.length&&s(e[r]);)r+=1;return"$"!==e[r]?null:e.slice(t,r+1)}(e,n);if(t){let r=e.indexOf(t,n+t.length);n=-1===r?e.length:r+t.length;continue}}if(";"===t){i(n+1),n+=1,r=n;continue}n+=1}return i(e.length),t}(e),r=t.filter(e=>i.has(e.keyword)||a.has(e.keyword)||o.has(e.keyword));if(0===r.length)return{mode:"wrapped-by-ytdb",sql:e,atomic:!0};let l=t[0],d=t[t.length-1];return 2===r.length&&r[0]===l&&r[1]===d&&i.has(l.keyword)&&a.has(d.keyword)?{mode:"self-wrapped",sql:e.slice(0,l.at)+e.slice(l.end,d.at)+e.slice(d.end),atomic:!0}:{mode:"self-managed",sql:e,atomic:!1}}function d(e){switch(e){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function u(e){return"unwrapped"===e?"no transaction":"self-managed"===e?"self-managed":null}},20185:(e,t,r)=>{function n(e){let t=e.split("/").filter(Boolean).map(decodeURIComponent);if(0===t.length)return{kind:"home"};let[r,n,i,a]=t;if(1===t.length)return{kind:"connection",connectionId:r};if(2===t.length){if("query"===n)return{kind:"query",connectionId:r};if("diff"===n)return{kind:"diff",connectionId:r};if("migrations"===n)return{kind:"migrations",connectionId:r}}if(3===t.length)return"migrations"===n?"timeline"===i?{kind:"migrations",connectionId:r,view:"timeline"}:{kind:"migration",connectionId:r,setId:i}:{kind:"table",connectionId:r,table:{schema:n,name:i}};return 4===t.length&&"migrations"===n&&("schema"===a||"timeline"===a)?{kind:"migration",connectionId:r,setId:i,view:a}:{kind:"connection",connectionId:r}}function i(e){let t=encodeURIComponent;switch(e.kind){case"home":return"/";case"connection":return`/${t(e.connectionId)}`;case"query":case"diff":return`/${t(e.connectionId)}/${e.kind}`;case"migrations":return`/${t(e.connectionId)}/migrations${e.view?`/${e.view}`:""}`;case"migration":return`/${t(e.connectionId)}/migrations/${t(e.setId)}${e.view?`/${e.view}`:""}`;case"table":return`/${t(e.connectionId)}/${t(e.table.schema)}/${t(e.table.name)}`}}function a(e,t,{tableExists:r=!0}={}){let o=n(e);return"home"!==o.kind&&("table"!==o.kind||r)?i({...o,connectionId:t}):i({kind:"connection",connectionId:t})}r.d(t,{Jn:()=>i,ZG:()=>n,gZ:()=>a})},20642:(e,t,r)=>{r.d(t,{Ai:()=>m,Nz:()=>h,Zy:()=>p,mj:()=>g,wQ:()=>y});var n=r(40980),i=r(25);let a=new Set(["apply","up","forward"]),o=new Set(["revert","down","rollback","undo"]),s=[".up",".apply",".forward","_up","_apply","-up","-apply"],l=[".down",".revert",".rollback",".undo","_down","_revert","_rollback","_undo","-down","-revert","-rollback","-undo"];function d(e){return e.split("/").filter(e=>e.length>0)}function u(e){let t=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(e);if(t)return{version:t[1].replace(/_/g,"."),name:c(t[2])};let r=/^(\d+(?:[-.]\d+)*)(?:[-_.\s]+(.*))?$/.exec(e);return r?{version:r[1],name:c(r[2]??"")}:{version:e,name:c(e)}}function c(e){return e.replace(/[-_]+/g," ").trim()}function p(e,t){let r=/(\d+)|(\D+)/g,n=e.match(r)??[],i=t.match(r)??[],a=Math.min(n.length,i.length);for(let e=0;e<a;e+=1){let t=n[e],r=i[e],a=/^\d+$/.test(t)&&/^\d+$/.test(r)?Number(t)-Number(r):t.localeCompare(r);if(0!==a)return a}return n.length-i.length}function f(e){let t=e.replace(/\r\n/g,"\n").trim(),r=0x811c9dc5,n=0x1000193;for(let e=0;e<t.length;e+=1){let i=t.charCodeAt(e);r=Math.imul(r^i,0x1000193)>>>0,n=Math.imul(n+i,0x85ebca6b)>>>0}return`${r.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}function h(e){let t={applies:new Map,reverts:new Map,skipped:[],errors:[]},r=e.filter(e=>{var t;let r=d(t=e.path).at(-1)??t;return!r.startsWith(".")&&/\.sql$/i.test(r)});if(0===r.length)return t.errors.push("No .sql files in there."),t;let n=r.reduce((e,t)=>e+t.text.length,0);if(n>4e6)return t.errors.push(`That is ${b(n)} of SQL, over the ${b(4e6)} limit.`),t;let i=[];for(let e of r){if(e.text.length>5e5){t.skipped.push(`${e.path} — over ${b(5e5)}`);continue}if(e.text.includes("\0")){t.skipped.push(`${e.path} — not text`);continue}if(!e.text.trim()){t.skipped.push(`${e.path} — empty`);continue}i.push({file:e,...function(e){let t=d(e),r=(t.at(-1)??e).replace(/\.sql$/i,"");for(let e of t.slice(0,-1)){let t=e.toLowerCase();if(o.has(t))return{direction:"revert",stem:r};if(a.has(t))return{direction:"apply",stem:r}}let n=r.toLowerCase();for(let e of l)if(n.endsWith(e))return{direction:"revert",stem:r.slice(0,-e.length)};for(let e of s)if(n.endsWith(e))return{direction:"apply",stem:r.slice(0,-e.length)};return{direction:"apply",stem:r}}(e.path)})}let p=new Set,f=!1;for(let{direction:e,stem:t}of i){if("apply"!==e)continue;let{version:r}=u(t);p.has(r)&&(f=!0),p.add(r)}for(let{file:e,direction:r,stem:n}of i){let{version:i,name:a}=f?{version:n,name:c(n)}:u(n),o=("apply"===r?t.applies:t.reverts).get(i);if(o){t.skipped.push(`${e.path} — ${o.path} is already version ${i}`);continue}"apply"===r?t.applies.set(i,{path:e.path,sql:e.text,name:a}):t.reverts.set(i,{path:e.path,sql:e.text})}return 0===t.applies.size&&0===t.reverts.size&&t.errors.push("None of those .sql files could be read as a migration."),t}function m(e,t){let r=new Map(e.map(e=>[e.version,{...e}])),n=[...t.skipped],a=0,o=0,s=0;for(let[e,s]of t.applies){let t=r.get(e);if(t){t.applySql!==s.sql&&(o+=1),t.name=s.name||t.name,t.applyPath=s.path,t.applySql=s.sql,t.checksum=f(s.sql),t.transaction=(0,i.Ol)(s.sql).mode;continue}if(r.size>=500){n.push(`${s.path} — over 500 migrations`);continue}r.set(e,{version:e,name:s.name||e,applyPath:s.path,applySql:s.sql,checksum:f(s.sql),transaction:(0,i.Ol)(s.sql).mode}),a+=1}for(let[e,i]of t.reverts){let t=r.get(e);if(!t){n.push(`${i.path} — no migration ${e} to revert`);continue}t.revertPath=i.path,t.revertSql=i.sql,s+=1}return{steps:[...r.values()].sort((e,t)=>p(e.version,t.version)),added:a,updated:o,reverts:s,skipped:n}}function g(e){return{id:(0,n.z)(),name:v(e),importedAt:Date.now(),steps:[],skipped:[]}}function v(e){return e.trim().replace(/\s+/g," ").slice(0,80)||"Migrations"}function b(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function y(e,t){let r=[],a=[];for(let e of[...t].sort((e,t)=>p(e.version,t.version))){if(!e.applySql){r.push(e.version);continue}a.push({version:e.version,name:e.name||e.version,applyPath:`${e.version} (from the ledger)`,applySql:e.applySql,checksum:f(e.applySql),revertPath:e.revertSql?`${e.version} revert (from the ledger)`:void 0,revertSql:e.revertSql,transaction:(0,i.Ol)(e.applySql).mode})}return{set:{id:(0,n.z)(),name:v(e),importedAt:Date.now(),steps:a,skipped:[]},missing:r}}},27529:(e,t,r)=>{r.d(t,{F:()=>a});var n=r(72914);async function i(e,t,r){let i,a=await (0,n.Qv)(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r}),o=await a.text();if(!o)throw Error(`YTDB bridge returned an empty response (HTTP ${a.status}). Restart YTDB to update the local bridge.`);try{i=JSON.parse(o)}catch{if(404===a.status)throw Error("The YTDB running on your machine is older than this page and does not know this request. Restart it with `npx @theobourgeois/ytdb@latest`.");throw Error(`YTDB bridge returned an invalid response (HTTP ${a.status}).`)}if(!a.ok)throw Error((i&&"object"==typeof i&&"error"in i&&"string"==typeof i.error?i.error:a.statusText)||`YTDB bridge request failed with HTTP ${a.status}.`);return i}let a={timeline:(e,t,r,n)=>i("/api/timeline",{connectionUrl:e,ledgerSchema:t,query:r},n),timelineDetail:(e,t,r,n)=>i("/api/timeline",{connectionUrl:e,ledgerSchema:t,eventId:r},n),tables:(e,t)=>i("/api/tables",{connectionUrl:e},t),rows:(e,t,r)=>i("/api/rows",{connectionUrl:e,query:t},r),query:(e,t,r)=>i("/api/query",{connectionUrl:e,sql:t},r),updateCell:(e,t,r)=>i("/api/cell",{connectionUrl:e,update:t},r),insertRow:(e,t,r)=>i("/api/insert-row",{connectionUrl:e,insertion:t},r),updateRow:(e,t,r)=>i("/api/update-row",{connectionUrl:e,update:t},r),deleteRows:(e,t,r)=>i("/api/delete-rows",{connectionUrl:e,deletion:t},r),related:(e,t,r)=>i("/api/related",{connectionUrl:e,lookups:t},r),lookup:(e,t,r)=>i("/api/lookup",{connectionUrl:e,query:t},r),definition:(e,t,r)=>i("/api/definition",{connectionUrl:e,table:t},r),schema:(e,t)=>i("/api/schema",{connectionUrl:e},t),ledger:(e,t,r,n=!1)=>i("/api/ledger",{connectionUrl:e,ledgerSchema:t,withSql:n},r),migrate:(e,t,r)=>i("/api/migrate",{connectionUrl:e,migration:t},r),adopt:(e,t,r)=>i("/api/adopt",{connectionUrl:e,adopt:t},r),rehearse:(e,t,r)=>i("/api/rehearse",{connectionUrl:e,rehearsal:t},r),reconcile:(e,t,r,n)=>i("/api/reconcile",{connectionUrl:e,ledgerSchema:t,eventId:r},n),resolve:(e,t,r,n)=>i("/api/reconcile",{connectionUrl:e,ledgerSchema:t,...r},n),detect:(e,t,r)=>i("/api/detect",{connectionUrl:e,migrations:t},r),repo:(e,t,r)=>i("/api/repo",{root:e,checkout:t},r),note:(e,t,r,n)=>i("/api/note",{root:e,path:t,note:r},n)}},36331:(e,t,r)=>{r.d(t,{Z:()=>l,k:()=>d});var n=r(95155),i=r(12115),a=r(27529),o=r(87364);let s=(0,i.createContext)(null);function l({connection:e,children:t}){let r=(0,o.Y)(e.url,t=>a.F.tables(e.url,t));return(0,n.jsx)(s.Provider,{value:{connection:e,tables:r},children:t})}function d(){let e=(0,i.useContext)(s);if(!e)throw Error("useExplorerContext must be used inside ExplorerProvider");return e}},43262:(e,t,r)=>{r.d(t,{Ar:()=>n,US:()=>s,s5:()=>d,tT:()=>u,vI:()=>l});let n={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M",back:"⌘[",forward:"⌘]"};function i(){let e=new Set;return{register:t=>(e.add(t),()=>{e.delete(t)}),open(){for(let t of e)t()}}}let a=i(),o=i(),s=a.register,l=a.open,d=o.register,u=o.open},48861:(e,t,r)=>{r.d(t,{Q:()=>d});var n=r(73321),i=r(12115),a=r(69586),o=r(79668),s=r(88263),l=r(20185);function d(e){let t,r,d=(0,n.useRouter)(),u=(0,s.c)(e=>e.entries),c=(0,s.c)(e=>e.index),p=(t=(0,a.Z)(e=>e.connections),r=(0,o.jV)(e=>e.sets),(0,i.useCallback)((e,n)=>{let i=e=>t.find(t=>t.id===e)?.name??e,a="connectionId"in e&&e.connectionId!==n?` \xb7 ${i(e.connectionId)}`:"";switch(e.kind){case"home":return"Connections";case"connection":return i(e.connectionId);case"query":return`SQL query${a}`;case"diff":return`Compare schema${a}`;case"migrations":return`Migrations${"timeline"===e.view?" \xb7 Timeline":""}${a}`;case"migration":{let t=r.find(t=>t.id===e.setId)?.name??"Migration",n="schema"===e.view?" \xb7 Schema":"timeline"===e.view?" \xb7 Timeline":"";return`${t}${n}${a}`}case"table":return`${e.table.name}${a}`}},[t,r]));return(0,i.useMemo)(()=>{let t=t=>{let r=u[t];if(void 0===r)return null;let n=(0,l.ZG)(r);return{href:r,route:n,label:p(n,e)}},r=t(c-1),n=t(c+1);return{back:r,forward:n,goBack:()=>{r&&d.back()},goForward:()=>{n&&d.forward()}}},[u,c,p,e,d])}},56012:(e,t,r)=>{r.d(t,{R9:()=>i,XG:()=>o,aC:()=>n,hD:()=>a,km:()=>s});let n="maintenance",i="ytdb_migrations";function a(e){return"string"==typeof e&&e.length>0&&e.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(e)}let o=2e4;function s(e){return e.startsWith("repo:")}},79668:(e,t,r)=>{r.d(t,{Ss:()=>f,ec:()=>m,jV:()=>p,kG:()=>h,ox:()=>g});var n=r(12115),i=r(1934),a=r(31692),o=r(42256),s=r(20642),l=r(56012),d=r(40980),u=r(69586);let c={query:"",status:"all"},p=(0,i.v)()((0,a.Zr)((e,t)=>({sets:[],history:[],ledgerSchema:l.aC,setLedgerSchema:t=>{(0,l.hD)(t)&&e({ledgerSchema:t})},listFilters:{},setListFilter:(t,r)=>e(e=>({listFilters:{...e.listFilters,[t]:{...e.listFilters[t]??c,...r}}})),repoRoots:{},setRepoRoot:(t,r)=>e(e=>{let n={...e.repoRoots},i=r?.trim();i?n[t]=i:delete n[t],(0,o.L)("migrations.folder",{set:!!i});let a={...e.repoCheckouts};return delete a[t],{repoRoots:n,repoCheckouts:a}}),repoCheckouts:{},setRepoCheckout:(t,r)=>e(e=>{let n={...e.repoCheckouts};return r?n[t]=r:delete n[t],(0,o.L)("migrations.checkout",{set:!!r}),{repoCheckouts:n}}),createSet:t=>{let r=(0,s.mj)(t);return e(e=>({sets:[...e.sets,r]})),r.id},addFiles:(r,n)=>{let i=t().sets.find(e=>e.id===r),a=(0,s.Nz)(n),l=(0,s.Ai)(i?.steps??[],a);return i&&e(e=>({sets:e.sets.map(e=>e.id===r?{...e,steps:l.steps,skipped:l.skipped,importedAt:Date.now()}:e)})),(0,o.L)("migrations.import",{name:i?.name,added:l.added,updated:l.updated,reverts:l.reverts,skipped:l.skipped.length}),l},adoptSet:t=>(e(e=>({sets:[...e.sets,t]})),(0,o.L)("migrations.import",{name:t.name,migrations:t.steps.length,source:"ledger"}),t.id),renameSet:(t,r)=>{let n=r.trim().replace(/\s+/g," ").slice(0,80);n&&e(e=>({sets:e.sets.map(e=>e.id===t?{...e,name:n}:e)}))},setNote:(t,r)=>{let n=r.trim().slice(0,l.XG)||void 0;e(e=>({sets:e.sets.map(e=>e.id===t?{...e,note:n}:e)}))},removeStep:(t,r)=>e(e=>({sets:e.sets.map(e=>e.id===t?{...e,steps:e.steps.filter(e=>e.version!==r)}:e)})),removeSet:r=>{let n=t().sets.find(e=>e.id===r);e(e=>({sets:e.sets.filter(e=>e.id!==r)})),(0,o.L)("migrations.remove",{name:n?.name})},record:t=>e(e=>({history:[{...t,id:(0,d.z)(),ranAt:Date.now()},...e.history].slice(0,300)})),clearHistory:t=>e(e=>({history:t?e.history.filter(e=>e.setId!==t):[]}))}),{name:"ytdb:migrations"}));function f(e){return p(t=>t.sets.find(t=>t.id===e)??null)}function h(e){return p(t=>t.listFilters[e]??c)}function m(){return(0,n.useSyncExternalStore)(e=>p.persist.onFinishHydration(e),()=>p.persist.hasHydrated(),()=>!1)}function g(e){let t=(0,u.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),r=p(e=>e.repoRoots[t]??null),n=p(e=>e.repoCheckouts[t]??null);return{scope:t,root:r,checkout:n}}},87364:(e,t,r)=>{r.d(t,{Y:()=>i});var n=r(12115);function i(e,t){let[r,i]=(0,n.useState)(0),[a,o]=(0,n.useState)({key:"",error:null}),s=`${r}:${e}`;(0,n.useEffect)(()=>{let e=new AbortController;return t(e.signal).then(e=>o({key:s,data:e,error:null})).catch(t=>{if(e.signal.aborted)return;let r=t instanceof Error?t.message:String(t);o(e=>({key:s,data:e.data,error:r}))}),()=>e.abort()},[s]);let l=(0,n.useCallback)(()=>i(e=>e+1),[]),d=a.key!==s;return{data:a.data,error:d?null:a.error,loading:d,reload:l}}},88263:(e,t,r)=>{r.d(t,{c:()=>s});var n=r(1934),i=r(31692);let a="ytdbNav";function o(e){let t=window.history.state;t&&"object"==typeof t&&t[a]===e||window.history.replaceState({...t??{},[a]:e},"")}let s=(0,n.v)()((0,i.Zr)((e,t)=>({entries:[],index:-1,traversing:!1,replaceNext:!1,markTraversal:()=>e({traversing:!0}),markReplace:()=>e({replaceNext:!0}),arrive:r=>{let n,{entries:i,index:s,traversing:l,replaceNext:d}=t(),u=function(){let e=window.history.state;if(!e||"object"!=typeof e)return;let t=e[a];return"number"==typeof t?t:void 0}();if(i[s]===r&&!d){e({traversing:!1}),o(s);return}let c=i;void 0!==u&&i[u]===r?n=u:l&&i[s-1]===r?n=s-1:l&&i[s+1]===r?n=s+1:d&&s>=0?(c=i.map((e,t)=>t===s?r:e),n=s):n=(c=[...i.slice(0,s+1),r]).length-1,e({entries:c,index:n,traversing:!1,replaceNext:!1}),o(n)}}),{name:"ytdb:navigation",storage:(0,i.KU)(()=>sessionStorage),partialize:e=>({entries:e.entries,index:e.index})}))},89239:(e,t,r)=>{r.d(t,{$:()=>l,r:()=>s});var n=r(95155),i=r(35684),a=r(18460),o=r(40980);let s=(0,a.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:r="default",...a}){return(0,n.jsx)(i.$,{"data-slot":"button",className:(0,o.cn)(s({variant:t,size:r,className:e})),...a})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);