d1s 0.3.10 → 0.3.11

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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/.next/BUILD_ID +1 -1
  3. package/dist/.next/app-build-manifest.json +50 -50
  4. package/dist/.next/app-path-routes-manifest.json +5 -5
  5. package/dist/.next/build-manifest.json +5 -5
  6. package/dist/.next/prerender-manifest.json +7 -7
  7. package/dist/.next/react-loadable-manifest.json +1 -1
  8. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/dist/.next/server/app/_not-found.html +1 -1
  10. package/dist/.next/server/app/_not-found.rsc +4 -4
  11. package/dist/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
  12. package/dist/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
  13. package/dist/.next/server/app/api/migrations/list/route_client-reference-manifest.js +1 -1
  14. package/dist/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
  15. package/dist/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
  16. package/dist/.next/server/app/api/pro/route_client-reference-manifest.js +1 -1
  17. package/dist/.next/server/app/api/pull-data/confirm/route_client-reference-manifest.js +1 -1
  18. package/dist/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
  19. package/dist/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
  20. package/dist/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
  21. package/dist/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
  22. package/dist/.next/server/app/api/query/route.js +8 -8
  23. package/dist/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
  24. package/dist/.next/server/app/api/schema/route.js +1 -1
  25. package/dist/.next/server/app/api/schema/route_client-reference-manifest.js +1 -1
  26. package/dist/.next/server/app/api/tables/[name]/import/route_client-reference-manifest.js +1 -1
  27. package/dist/.next/server/app/api/tables/[name]/route.js +5 -5
  28. package/dist/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
  29. package/dist/.next/server/app/api/tables/route.js +2 -2
  30. package/dist/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
  31. package/dist/.next/server/app/api/time-travel/preview/route_client-reference-manifest.js +1 -1
  32. package/dist/.next/server/app/api/time-travel/restore/route_client-reference-manifest.js +1 -1
  33. package/dist/.next/server/app/api/update/route.js +1 -1
  34. package/dist/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  35. package/dist/.next/server/app/index.html +2 -2
  36. package/dist/.next/server/app/index.rsc +5 -5
  37. package/dist/.next/server/app/page.js +9 -9
  38. package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
  39. package/dist/.next/server/app-paths-manifest.json +5 -5
  40. package/dist/.next/server/chunks/839.js +1 -1
  41. package/dist/.next/server/middleware-build-manifest.js +1 -1
  42. package/dist/.next/server/middleware-react-loadable-manifest.js +1 -1
  43. package/dist/.next/server/pages/404.html +1 -1
  44. package/dist/.next/server/pages/500.html +1 -1
  45. package/dist/.next/static/chunks/823-77b9a2d152da81dd.js +1 -0
  46. package/dist/.next/static/chunks/{950.01ba9ad634bd1f43.js → 950.edd33691c78c1807.js} +1 -1
  47. package/dist/.next/static/chunks/app/page-4170252891367dde.js +1 -0
  48. package/dist/.next/static/chunks/{webpack-c7b9f95656aa8fe9.js → webpack-d5e8b5757f0fec83.js} +1 -1
  49. package/dist/.next/static/css/262ae258bbcfd289.css +3 -0
  50. package/dist/.next/trace +3 -3
  51. package/dist/app/api/query/route.js +35 -16
  52. package/dist/app/api/schema/route.js +16 -6
  53. package/dist/app/api/tables/[name]/route.js +23 -12
  54. package/dist/app/api/tables/route.js +21 -6
  55. package/dist/d1-studio.js +1 -0
  56. package/package.json +5 -1
  57. package/dist/.next/static/chunks/823-5f8f96173644e0cc.js +0 -1
  58. package/dist/.next/static/chunks/app/page-5f0b0b876d1c4c1c.js +0 -1
  59. package/dist/.next/static/css/b69f03bff92613ce.css +0 -3
  60. /package/dist/.next/static/{TDqrfll63o1FXL7rpt5E_ → kGRfd0CDzKPsrYHw9rLTQ}/_buildManifest.js +0 -0
  61. /package/dist/.next/static/{TDqrfll63o1FXL7rpt5E_ → kGRfd0CDzKPsrYHw9rLTQ}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/page"]={"moduleLoading":{"prefix":"/_next/"},"ssrModuleMapping":{"622":{"*":{"id":"82146","name":"*","chunks":[],"async":false}},"930":{"*":{"id":"32122","name":"*","chunks":[],"async":false}},"1959":{"*":{"id":"31603","name":"*","chunks":[],"async":false}},"3190":{"*":{"id":"60122","name":"*","chunks":[],"async":false}},"3886":{"*":{"id":"75170","name":"*","chunks":[],"async":false}},"4431":{"*":{"id":"12263","name":"*","chunks":[],"async":false}},"5278":{"*":{"id":"78922","name":"*","chunks":[],"async":false}},"7150":{"*":{"id":"54160","name":"*","chunks":[],"async":false}},"7747":{"*":{"id":"60673","name":"*","chunks":[],"async":false}},"7989":{"*":{"id":"68495","name":"*","chunks":[],"async":false}},"8924":{"*":{"id":"29234","name":"*","chunks":[],"async":false}},"9766":{"*":{"id":"77526","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/builtin/global-error.js":{"id":7150,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/builtin/global-error.js":{"id":7150,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/client-page.js":{"id":1959,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/client-page.js":{"id":1959,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/client-segment.js":{"id":7989,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/client-segment.js":{"id":7989,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/http-access-fallback/error-boundary.js":{"id":3886,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":3886,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/layout-router.js":{"id":9766,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/layout-router.js":{"id":9766,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/metadata/async-metadata.js":{"id":5278,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/metadata/async-metadata.js":{"id":5278,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/render-from-template-context.js":{"id":8924,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":8924,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/lib/framework/boundary-components.js":{"id":4431,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":4431,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/lib/metadata/generate/icon-mark.js":{"id":622,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":622,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/font/google/target.css?{\"path\":\"src/app/layout.jsx\",\"import\":\"Geist\",\"arguments\":[{\"variable\":\"--font-geist-sans\",\"subsets\":[\"latin\"]}],\"variableName\":\"geistSans\"}":{"id":5706,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-5f8f96173644e0cc.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/font/google/target.css?{\"path\":\"src/app/layout.jsx\",\"import\":\"Geist_Mono\",\"arguments\":[{\"variable\":\"--font-geist-mono\",\"subsets\":[\"latin\"]}],\"variableName\":\"geistMono\"}":{"id":134,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-5f8f96173644e0cc.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/app/globals.css":{"id":3673,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-5f8f96173644e0cc.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/components/ui/toaster.jsx":{"id":7747,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-5f8f96173644e0cc.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js":{"id":3190,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-5f8f96173644e0cc.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/app/page.jsx":{"id":930,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","69","static/chunks/69-00a70b2df83ed9ee.js","823","static/chunks/823-5f8f96173644e0cc.js","974","static/chunks/app/page-5f0b0b876d1c4c1c.js"],"async":false}},"entryCSSFiles":{"/Volumes/ProjectSpace/_wip/d1studio/src/":[],"/Volumes/ProjectSpace/_wip/d1studio/src/app/layout":[{"inlined":false,"path":"static/css/b69f03bff92613ce.css"}],"/Volumes/ProjectSpace/_wip/d1studio/src/app/page":[]},"rscModuleMapping":{"622":{"*":{"id":"51384","name":"*","chunks":[],"async":false}},"930":{"*":{"id":"1905","name":"*","chunks":[],"async":false}},"1959":{"*":{"id":"23597","name":"*","chunks":[],"async":false}},"3190":{"*":{"id":"46254","name":"*","chunks":[],"async":false}},"3673":{"*":{"id":"61135","name":"*","chunks":[],"async":false}},"3886":{"*":{"id":"89748","name":"*","chunks":[],"async":false}},"4431":{"*":{"id":"73041","name":"*","chunks":[],"async":false}},"5278":{"*":{"id":"7184","name":"*","chunks":[],"async":false}},"7150":{"*":{"id":"81170","name":"*","chunks":[],"async":false}},"7747":{"*":{"id":"44158","name":"*","chunks":[],"async":false}},"7989":{"*":{"id":"36893","name":"*","chunks":[],"async":false}},"8924":{"*":{"id":"69576","name":"*","chunks":[],"async":false}},"9766":{"*":{"id":"6060","name":"*","chunks":[],"async":false}}},"edgeRscModuleMapping":{}}
1
+ globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/page"]={"moduleLoading":{"prefix":"/_next/"},"ssrModuleMapping":{"622":{"*":{"id":"82146","name":"*","chunks":[],"async":false}},"930":{"*":{"id":"32122","name":"*","chunks":[],"async":false}},"1959":{"*":{"id":"31603","name":"*","chunks":[],"async":false}},"3190":{"*":{"id":"60122","name":"*","chunks":[],"async":false}},"3886":{"*":{"id":"75170","name":"*","chunks":[],"async":false}},"4431":{"*":{"id":"12263","name":"*","chunks":[],"async":false}},"5278":{"*":{"id":"78922","name":"*","chunks":[],"async":false}},"7150":{"*":{"id":"54160","name":"*","chunks":[],"async":false}},"7747":{"*":{"id":"60673","name":"*","chunks":[],"async":false}},"7989":{"*":{"id":"68495","name":"*","chunks":[],"async":false}},"8924":{"*":{"id":"29234","name":"*","chunks":[],"async":false}},"9766":{"*":{"id":"77526","name":"*","chunks":[],"async":false}}},"edgeSSRModuleMapping":{},"clientModules":{"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/builtin/global-error.js":{"id":7150,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/builtin/global-error.js":{"id":7150,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/client-page.js":{"id":1959,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/client-page.js":{"id":1959,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/client-segment.js":{"id":7989,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/client-segment.js":{"id":7989,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/http-access-fallback/error-boundary.js":{"id":3886,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":3886,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/layout-router.js":{"id":9766,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/layout-router.js":{"id":9766,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/metadata/async-metadata.js":{"id":5278,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/metadata/async-metadata.js":{"id":5278,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/client/components/render-from-template-context.js":{"id":8924,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":8924,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/lib/framework/boundary-components.js":{"id":4431,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":4431,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/lib/metadata/generate/icon-mark.js":{"id":622,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":622,"name":"*","chunks":[],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/font/google/target.css?{\"path\":\"src/app/layout.jsx\",\"import\":\"Geist\",\"arguments\":[{\"variable\":\"--font-geist-sans\",\"subsets\":[\"latin\"]}],\"variableName\":\"geistSans\"}":{"id":5706,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-77b9a2d152da81dd.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/node_modules/next/font/google/target.css?{\"path\":\"src/app/layout.jsx\",\"import\":\"Geist_Mono\",\"arguments\":[{\"variable\":\"--font-geist-mono\",\"subsets\":[\"latin\"]}],\"variableName\":\"geistMono\"}":{"id":134,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-77b9a2d152da81dd.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/app/globals.css":{"id":3673,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-77b9a2d152da81dd.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/components/ui/toaster.jsx":{"id":7747,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-77b9a2d152da81dd.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js":{"id":3190,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","654","static/chunks/654-f2f8931465d44ae7.js","823","static/chunks/823-77b9a2d152da81dd.js","177","static/chunks/app/layout-a5219438265f0b6c.js"],"async":false},"/Volumes/ProjectSpace/_wip/d1studio/src/app/page.jsx":{"id":930,"name":"*","chunks":["421","static/chunks/421-55f8ce492f5bd9c3.js","69","static/chunks/69-00a70b2df83ed9ee.js","823","static/chunks/823-77b9a2d152da81dd.js","974","static/chunks/app/page-4170252891367dde.js"],"async":false}},"entryCSSFiles":{"/Volumes/ProjectSpace/_wip/d1studio/src/":[],"/Volumes/ProjectSpace/_wip/d1studio/src/app/layout":[{"inlined":false,"path":"static/css/262ae258bbcfd289.css"}],"/Volumes/ProjectSpace/_wip/d1studio/src/app/page":[]},"rscModuleMapping":{"622":{"*":{"id":"51384","name":"*","chunks":[],"async":false}},"930":{"*":{"id":"1905","name":"*","chunks":[],"async":false}},"1959":{"*":{"id":"23597","name":"*","chunks":[],"async":false}},"3190":{"*":{"id":"46254","name":"*","chunks":[],"async":false}},"3673":{"*":{"id":"61135","name":"*","chunks":[],"async":false}},"3886":{"*":{"id":"89748","name":"*","chunks":[],"async":false}},"4431":{"*":{"id":"73041","name":"*","chunks":[],"async":false}},"5278":{"*":{"id":"7184","name":"*","chunks":[],"async":false}},"7150":{"*":{"id":"81170","name":"*","chunks":[],"async":false}},"7747":{"*":{"id":"44158","name":"*","chunks":[],"async":false}},"7989":{"*":{"id":"36893","name":"*","chunks":[],"async":false}},"8924":{"*":{"id":"69576","name":"*","chunks":[],"async":false}},"9766":{"*":{"id":"6060","name":"*","chunks":[],"async":false}}},"edgeRscModuleMapping":{}}
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "/api/cloudflare/route": "app/api/cloudflare/route.js",
3
3
  "/api/databases/route": "app/api/databases/route.js",
4
- "/api/migrations/list/route": "app/api/migrations/list/route.js",
5
4
  "/api/migrations/sync-files/route": "app/api/migrations/sync-files/route.js",
6
5
  "/api/migrations/sync/route": "app/api/migrations/sync/route.js",
6
+ "/api/migrations/list/route": "app/api/migrations/list/route.js",
7
7
  "/api/pro/route": "app/api/pro/route.js",
8
+ "/api/pull-data/confirm/route": "app/api/pull-data/confirm/route.js",
8
9
  "/api/pull-remote/preview/route": "app/api/pull-remote/preview/route.js",
9
10
  "/api/push-remote/preview/route": "app/api/push-remote/preview/route.js",
10
- "/api/query/route": "app/api/query/route.js",
11
11
  "/api/schema/route": "app/api/schema/route.js",
12
- "/api/pull-data/confirm/route": "app/api/pull-data/confirm/route.js",
13
- "/api/tables/[name]/import/route": "app/api/tables/[name]/import/route.js",
14
12
  "/api/push-remote/confirm/route": "app/api/push-remote/confirm/route.js",
15
- "/_not-found/page": "app/_not-found/page.js",
13
+ "/api/tables/[name]/import/route": "app/api/tables/[name]/import/route.js",
14
+ "/api/query/route": "app/api/query/route.js",
16
15
  "/api/tables/route": "app/api/tables/route.js",
17
16
  "/api/time-travel/preview/route": "app/api/time-travel/preview/route.js",
18
17
  "/api/update/route": "app/api/update/route.js",
19
18
  "/api/time-travel/restore/route": "app/api/time-travel/restore/route.js",
20
19
  "/api/pull-remote/confirm/route": "app/api/pull-remote/confirm/route.js",
20
+ "/_not-found/page": "app/_not-found/page.js",
21
21
  "/api/tables/[name]/route": "app/api/tables/[name]/route.js",
22
22
  "/page": "app/page.js"
23
23
  }
@@ -1 +1 @@
1
- exports.id=839,exports.ids=[839],exports.modules={15988:(a,b,c)=>{Promise.resolve().then(c.bind(c,44158)),Promise.resolve().then(c.bind(c,46254))},41062:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,54160,23)),Promise.resolve().then(c.t.bind(c,31603,23)),Promise.resolve().then(c.t.bind(c,68495,23)),Promise.resolve().then(c.t.bind(c,75170,23)),Promise.resolve().then(c.t.bind(c,77526,23)),Promise.resolve().then(c.t.bind(c,78922,23)),Promise.resolve().then(c.t.bind(c,29234,23)),Promise.resolve().then(c.t.bind(c,12263,23)),Promise.resolve().then(c.bind(c,82146))},44158:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d});let d=(0,c(97954).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/components/ui/toaster.jsx","Toaster")},46254:(a,b,c)=>{"use strict";c.d(b,{DatabaseProvider:()=>e});var d=c(97954);let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call DatabaseProvider() from the server but DatabaseProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js","DatabaseProvider");(0,d.registerClientReference)(function(){throw Error("Attempted to call useDatabase() from the server but useDatabase is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js","useDatabase")},52603:(a,b,c)=>{"use strict";c.d(b,{cn:()=>f});var d=c(43249),e=c(58829);function f(...a){return(0,e.QP)((0,d.$)(a))}},60122:(a,b,c)=>{"use strict";c.d(b,{DatabaseProvider:()=>k,t:()=>l});var d=c(21124),e=c(38301);let f=new Map;function g(a,b,c=2e3){let d=f.get(a);if(d&&Date.now()-d.timestamp<c)return d.promise;let e=b();return f.set(a,{promise:e,timestamp:Date.now()}),e.finally(()=>{setTimeout(()=>{f.delete(a)},c)}),e}let h=(0,e.createContext)(void 0);class i{constructor(){this.cache=new Map}get(a){let b=this.cache.get(a);return b||null}set(a,b,c,d){this.cache.set(a,{data:b,schema:c,meta:d,timestamp:Date.now()})}update(a,b,c,d){let e=this.cache.get(a);e&&this.cache.set(a,{data:b||e.data,schema:c||e.schema,meta:d||e.meta,timestamp:Date.now()})}invalidate(a){this.cache.delete(a)}clear(){this.cache.clear()}}class j{constructor(){this.queue=[],this.processing=!1}async add(a){return new Promise((b,c)=>{this.queue.push({operation:a,resolve:b,reject:c}),this.process()})}async process(){if(this.processing||0===this.queue.length)return;this.processing=!0;let{operation:a,resolve:b,reject:c}=this.queue.shift();try{let c=await a();b(c)}catch(a){c(a)}finally{this.processing=!1,this.process()}}}function k({children:a}){let[b,c]=(0,e.useState)([]),[f,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(null);(0,e.useRef)(new j);let[r,s]=(0,e.useState)(null),t=(0,e.useRef)(new i).current,u=(0,e.useRef)(null),[v,w]=(0,e.useState)(null),x=(0,e.useCallback)((a,b,c=null)=>{w({type:a,message:b,detail:c,ts:new Date})},[]),[y,z]=(0,e.useState)(()=>null),A=(0,e.useCallback)(a=>{let b=a instanceof Date?a.toISOString():new Date().toISOString();localStorage.setItem("d1_last_sync",b),z(b)},[]),B=(0,e.useCallback)((a,b=1,c=50)=>{let d=`table-${a}-${b}-${c}`;return t.get(d)},[]),C=(0,e.useCallback)(a=>{t.cache.forEach((b,c)=>{c.startsWith(`table-${a}-`)&&t.invalidate(c)})},[]),D=(0,e.useCallback)((a,b,c,d,e=1,f=50)=>{let g=`table-${a}-${e}-${f}`;t.update(g,b,c,d)},[]),E=(0,e.useCallback)(async a=>{let b=/^\s*(SELECT|PRAGMA|EXPLAIN)/i.test(a),c=`query-${a}`,d=async()=>{x("loading","Executing query…");try{let b=u.current?.database_name,c=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,...b&&{db:b}})});if(!c.ok){let a="Failed to execute query";try{let b=await c.json();a=b?.error?.message||a}catch(a){}throw Error(a)}let d=await c.json();if(!d.success)throw Error(d.error||"Query execution failed");return x("success","Query executed"),d}catch(a){throw x("error",a.message||"Query failed"),a||Error("An unknown error occurred")}};return b?g(c,d,1e3):d()},[x]),F=(0,e.useCallback)(async a=>{try{let b=await fetch(`/api/tables/${a}`),c=await b.json();if(!b.ok||!c.success)throw Error(c.error||"Failed to fetch table schema");return c.schema||[]}catch(a){throw console.error("Schema fetch error:",a),a}},[]),G=(0,e.useCallback)(async(a,b={})=>{let{forceFetch:c=!1,page:d=1,limit:e=50}=b,f=`table-${a}-${d}-${e}`;if(!c){let a=t.get(f);if(a)return a}return g(`table-${a}-${d}-${e}`,async()=>{x("loading",`Loading ${a}…`);try{let b=u.current?.database_name,c=b?`&db=${encodeURIComponent(b)}`:"",g=await fetch(`/api/tables/${a}?page=${d}&limit=${e}${c}`,{headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!g.ok)throw Error("Failed to fetch table data");let h=await g.json();if(!h.success)throw Error(h.error||"Failed to fetch table data");t.set(f,h.data,h.schema,h.meta);let i=h.data?.length||0;return x("success",`Loaded ${i} row${1!==i?"s":""} \xb7 ${a}`),h}catch(b){throw console.error("Error fetching table data:",b),x("error",b.message,`Failed loading ${a}`),b}},1e3)},[x]),H=(0,e.useCallback)(async a=>{x("loading",`Refreshing ${a}…`);try{return t.cache.forEach((b,c)=>{c.startsWith(`table-${a}-`)&&t.invalidate(c)}),await G(a,{forceFetch:!0})}catch(b){throw console.error("Error updating table data:",b),x("error",b.message,`Failed refreshing ${a}`),b}},[G,x]),I=(0,e.useCallback)(async(a,b={})=>(s(a),await G(a,b)),[G]),J=(0,e.useCallback)(async()=>{let a=u.current?.database_name||"default";return g(`refresh-tables-${a}`,async()=>{x("loading","Loading tables…"),k(!0),m(null);try{let a=u.current?.database_name,b=a?`?db=${encodeURIComponent(a)}`:"",d=await fetch(`/api/tables${b}`);if(!d.ok)throw Error("Failed to fetch tables");let e=await d.json();if(e.error)throw Error(e.error);let f=e.tables||[];return c(f),x("success",`${f.length} table${1!==f.length?"s":""} loaded`),f}catch(a){throw m(a.message),x("error",a.message,"Failed loading tables"),a}finally{k(!1)}},2e3)},[x]),K=(0,e.useCallback)(async a=>{x("loading","Creating table…");try{await E(a),t.clear(),await J(),x("success","Table created")}catch(a){throw x("error",a.message,"Create table failed"),Error(`Failed to create table: ${a.message}`)}},[E,J,x]),L=(0,e.useCallback)(async a=>{x("loading",`Dropping "${a}"…`);try{await E(`DROP TABLE ${a};`),t.invalidate(a),await J(),x("success",`Table "${a}" dropped`)}catch(b){throw x("error",b.message,`Drop "${a}" failed`),Error(`Failed to drop table: ${b.message}`)}},[E,J,x]),M=(0,e.useCallback)(async a=>{x("loading","Syncing migrations…");try{let b=await fetch("/api/migrations/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok){let a=await b.json();throw Error(a.error?.message||"Failed to sync migrations")}let c=await b.json();return x("success","Migrations synced"),c}catch(a){throw console.error("Error syncing migrations:",a),x("error",a.message,"Migration sync failed"),a}},[x]),N=(0,e.useCallback)(async()=>{x("loading","Pulling from remote…");try{let a=localStorage.getItem("cf_credentials");if(!a)throw Error("No Cloudflare credentials found. Please connect to Cloudflare first.");let b=JSON.parse(a);if(!b.accountId||!b.apiToken)throw Error("Invalid credentials stored. Please reconnect to Cloudflare.");let c=await fetch("/api/pull-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:b.accountId,apiToken:b.apiToken})}),d=await c.json();if(!c.ok||!d.success)throw Error(d.error?.message||"Failed to pull from remote");t.clear(),await J();let e=d.details?.appliedMigrations?.length??0;return x("success",`Pull complete — ${e} migration${1!==e?"s":""} applied`),d}catch(a){throw console.error("Error pulling from remote:",a),x("error",a.message,"Pull from remote failed"),a}},[J,x]),O=(0,e.useCallback)(async a=>{x("loading","Pushing to remote…");try{let b=await fetch("/api/push-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok)throw Error(c.error?.message||"Failed to push to remote");let d=c.applied??0;return x("success",`Push complete — ${d} migration${1!==d?"s":""} applied`),c}catch(a){throw console.error("Error pushing to remote:",a),x("error",a.message,"Push to remote failed"),a}},[x]),P=(0,e.useCallback)(async a=>{let b=n.find(b=>b.database_name===a);b&&(u.current=b,q(b),t.clear(),c([]),s(null),await J())},[n,J]),Q=(0,e.useMemo)(()=>({tables:b,databases:n,currentDatabase:p,switchDatabase:P,isLoading:f,error:l,activeTable:r,lastStatus:v,setOperationStatus:x,lastSyncTime:y,setLastSyncTime:A,refreshTables:J,executeQuery:E,fetchTableSchema:F,fetchTableData:G,updateTableData:H,createTable:K,dropTable:L,syncMigrations:M,pullFromRemote:N,pushToRemote:O,getCachedTable:B,updateTableCache:D,invalidateTable:C,switchTable:I}),[b,n,p,P,f,l,r,v,x,y,A,J,E,F,G,H,K,L,M,N,O,B,D,C,I]);return(0,d.jsx)(h.Provider,{value:Q,children:a})}function l(){let a=(0,e.useContext)(h);if(!a)throw Error("useDatabase must be used within a DatabaseProvider");return a}},60673:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>r});var d=c(21124),e=c(99728),f=c(38301),g=c(76608),h=c(26691),i=c(90447),j=c(52603);let k=g.Kq,l=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.LM,{ref:c,className:(0,j.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...b}));l.displayName=g.LM.displayName;let m=(0,h.F)("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),n=f.forwardRef(({className:a,variant:b,...c},e)=>(0,d.jsx)(g.bL,{ref:e,className:(0,j.cn)(m({variant:b}),a),...c}));n.displayName=g.bL.displayName,f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.rc,{ref:c,className:(0,j.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...b})).displayName=g.rc.displayName;let o=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.bm,{ref:c,className:(0,j.cn)("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...b,children:(0,d.jsx)(i.A,{className:"h-4 w-4"})}));o.displayName=g.bm.displayName;let p=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.hE,{ref:c,className:(0,j.cn)("text-sm font-semibold [&+div]:text-xs",a),...b}));p.displayName=g.hE.displayName;let q=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.VY,{ref:c,className:(0,j.cn)("text-sm opacity-90",a),...b}));function r(){let{toasts:a}=(0,e.dj)();return(0,d.jsxs)(k,{children:[a.map(function({id:a,title:b,description:c,action:e,...f}){return(0,d.jsxs)(n,{...f,children:[(0,d.jsxs)("div",{className:"grid gap-1",children:[b&&(0,d.jsx)(p,{children:b}),c&&(0,d.jsx)(q,{children:c})]}),e,(0,d.jsx)(o,{})]},a)}),(0,d.jsx)(l,{})]})}q.displayName=g.VY.displayName},61135:()=>{},61662:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>l,metadata:()=>k});var d=c(75338),e=c(66914),f=c.n(e),g=c(4580),h=c.n(g);c(61135);var i=c(46254),j=c(44158);let k={title:"d1-studio",description:"Native D1 database studio."};function l({children:a}){return(0,d.jsx)("html",{lang:"en",children:(0,d.jsx)("body",{className:`${f().variable} ${h().variable} antialiased`,children:(0,d.jsxs)(i.DatabaseProvider,{children:[a,(0,d.jsx)(j.Toaster,{})," "]})})})}},72606:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81170,23)),Promise.resolve().then(c.t.bind(c,23597,23)),Promise.resolve().then(c.t.bind(c,36893,23)),Promise.resolve().then(c.t.bind(c,89748,23)),Promise.resolve().then(c.t.bind(c,6060,23)),Promise.resolve().then(c.t.bind(c,7184,23)),Promise.resolve().then(c.t.bind(c,69576,23)),Promise.resolve().then(c.t.bind(c,73041,23)),Promise.resolve().then(c.t.bind(c,51384,23))},92020:(a,b,c)=>{Promise.resolve().then(c.bind(c,60673)),Promise.resolve().then(c.bind(c,60122))},99728:(a,b,c)=>{"use strict";c.d(b,{dj:()=>l});var d=c(38301);let e=0,f=new Map,g=a=>{if(f.has(a))return;let b=setTimeout(()=>{f.delete(a),j({type:"REMOVE_TOAST",toastId:a})},1e6);f.set(a,b)},h=[],i={toasts:[]};function j(a){i=((a,b)=>{switch(b.type){case"ADD_TOAST":return{...a,toasts:[b.toast,...a.toasts].slice(0,1)};case"UPDATE_TOAST":return{...a,toasts:a.toasts.map(a=>a.id===b.toast.id?{...a,...b.toast}:a)};case"DISMISS_TOAST":{let{toastId:c}=b;return c?g(c):a.toasts.forEach(a=>{g(a.id)}),{...a,toasts:a.toasts.map(a=>a.id===c||void 0===c?{...a,open:!1}:a)}}case"REMOVE_TOAST":if(void 0===b.toastId)return{...a,toasts:[]};return{...a,toasts:a.toasts.filter(a=>a.id!==b.toastId)}}})(i,a),h.forEach(a=>{a(i)})}function k({...a}){let b=(e=(e+1)%Number.MAX_SAFE_INTEGER).toString(),c=()=>j({type:"DISMISS_TOAST",toastId:b});return j({type:"ADD_TOAST",toast:{...a,id:b,open:!0,onOpenChange:a=>{a||c()}}}),{id:b,dismiss:c,update:a=>j({type:"UPDATE_TOAST",toast:{...a,id:b}})}}function l(){let[a,b]=d.useState(i);return d.useEffect(()=>(h.push(b),()=>{let a=h.indexOf(b);a>-1&&h.splice(a,1)}),[a]),{...a,toast:k,dismiss:a=>j({type:"DISMISS_TOAST",toastId:a})}}}};
1
+ exports.id=839,exports.ids=[839],exports.modules={15988:(a,b,c)=>{Promise.resolve().then(c.bind(c,44158)),Promise.resolve().then(c.bind(c,46254))},41062:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,54160,23)),Promise.resolve().then(c.t.bind(c,31603,23)),Promise.resolve().then(c.t.bind(c,68495,23)),Promise.resolve().then(c.t.bind(c,75170,23)),Promise.resolve().then(c.t.bind(c,77526,23)),Promise.resolve().then(c.t.bind(c,78922,23)),Promise.resolve().then(c.t.bind(c,29234,23)),Promise.resolve().then(c.t.bind(c,12263,23)),Promise.resolve().then(c.bind(c,82146))},44158:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d});let d=(0,c(97954).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/components/ui/toaster.jsx","Toaster")},46254:(a,b,c)=>{"use strict";c.d(b,{DatabaseProvider:()=>e});var d=c(97954);let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call DatabaseProvider() from the server but DatabaseProvider is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js","DatabaseProvider");(0,d.registerClientReference)(function(){throw Error("Attempted to call useDatabase() from the server but useDatabase is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Volumes/ProjectSpace/_wip/d1studio/src/context/database-context.js","useDatabase")},52603:(a,b,c)=>{"use strict";c.d(b,{cn:()=>f});var d=c(43249),e=c(58829);function f(...a){return(0,e.QP)((0,d.$)(a))}},60122:(a,b,c)=>{"use strict";c.d(b,{DatabaseProvider:()=>k,t:()=>l});var d=c(21124),e=c(38301);let f=new Map;function g(a,b,c=2e3){let d=f.get(a);if(d&&Date.now()-d.timestamp<c)return d.promise;let e=b();return f.set(a,{promise:e,timestamp:Date.now()}),e.finally(()=>{setTimeout(()=>{f.delete(a)},c)}),e}let h=(0,e.createContext)(void 0);class i{constructor(){this.cache=new Map}get(a){let b=this.cache.get(a);return b||null}set(a,b,c,d){this.cache.set(a,{data:b,schema:c,meta:d,timestamp:Date.now()})}update(a,b,c,d){let e=this.cache.get(a);e&&this.cache.set(a,{data:b||e.data,schema:c||e.schema,meta:d||e.meta,timestamp:Date.now()})}invalidate(a){this.cache.delete(a)}clear(){this.cache.clear()}}class j{constructor(){this.queue=[],this.processing=!1}async add(a){return new Promise((b,c)=>{this.queue.push({operation:a,resolve:b,reject:c}),this.process()})}async process(){if(this.processing||0===this.queue.length)return;this.processing=!0;let{operation:a,resolve:b,reject:c}=this.queue.shift();try{let c=await a();b(c)}catch(a){c(a)}finally{this.processing=!1,this.process()}}}function k({children:a}){let[b,c]=(0,e.useState)([]),[f,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(()=>"local");(0,e.useRef)(new j);let[t,u]=(0,e.useState)(null),v=(0,e.useRef)(new i).current,w=(0,e.useRef)(null),x=(0,e.useRef)(r),[y,z]=(0,e.useState)(null),A=(0,e.useCallback)((a,b,c=null)=>{z({type:a,message:b,detail:c,ts:new Date})},[]),[B,C]=(0,e.useState)(()=>null),D=(0,e.useCallback)(a=>{let b=a instanceof Date?a.toISOString():new Date().toISOString();localStorage.setItem("d1_last_sync",b),C(b)},[]),E=(0,e.useCallback)((a,b=1,c=50,d=x.current)=>{let e=`table-${d}-${a}-${b}-${c}`;return v.get(e)},[]),F=(0,e.useCallback)(a=>{v.cache.forEach((b,c)=>{c.startsWith("table-")&&c.includes(`-${a}-`)&&v.invalidate(c)})},[]),G=(0,e.useCallback)((a,b,c,d,e=1,f=50,g=x.current)=>{let h=`table-${g}-${a}-${e}-${f}`;v.update(h,b,c,d)},[]),H=(0,e.useCallback)(async(a,b={})=>{let c=b?.target==="remote"||b?.target==="local"?b.target:x.current,d=/^\s*(SELECT|PRAGMA|EXPLAIN)/i.test(a),e=`query-${c}-${a}`,f=async()=>{A("loading",`Executing ${c} query…`);try{let b=w.current?.database_name,d=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,target:c,...b&&{db:b}})});if(!d.ok){let a="Failed to execute query";try{let b=await d.json();a=b?.error?.message||a}catch(a){}throw Error(a)}let e=await d.json();if(!e.success)throw Error(e.error||"Query execution failed");return A("success",`${"remote"===c?"Remote":"Local"} query executed`),e}catch(a){throw A("error",a.message||"Query failed"),a||Error("An unknown error occurred")}};return d?g(e,f,1e3):f()},[A]),I=(0,e.useCallback)(async(a,b={})=>{try{let c=b?.source==="remote"||b?.source==="local"?b.source:x.current,d=`source=${encodeURIComponent(c)}`,e=await fetch(`/api/tables/${a}?${d}`),f=await e.json();if(!e.ok||!f.success)throw Error(f.error||"Failed to fetch table schema");return f.schema||[]}catch(a){throw console.error("Schema fetch error:",a),a}},[]),J=(0,e.useCallback)(async(a,b={})=>{let{forceFetch:c=!1,page:d=1,limit:e=50}=b,f=b?.source==="remote"||b?.source==="local"?b.source:x.current,h=`table-${f}-${a}-${d}-${e}`;if(!c){let a=v.get(h);if(a)return a}return g(`table-${f}-${a}-${d}-${e}`,async()=>{A("loading",`Loading ${a} (${f})…`);try{let b=w.current?.database_name,c=b?`&db=${encodeURIComponent(b)}`:"",g=`source=${encodeURIComponent(f)}`,i=await fetch(`/api/tables/${a}?page=${d}&limit=${e}&${g}${c}`,{headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!i.ok)throw Error("Failed to fetch table data");let j=await i.json();if(!j.success)throw Error(j.error||"Failed to fetch table data");v.set(h,j.data,j.schema,j.meta);let k=j.data?.length||0;return A("success",`Loaded ${k} row${1!==k?"s":""} \xb7 ${a} (${f})`),j}catch(b){throw console.error("Error fetching table data:",b),A("error",b.message,`Failed loading ${a}`),b}},1e3)},[A]),K=(0,e.useCallback)(async a=>{let b=x.current;A("loading",`Refreshing ${a}…`);try{return v.cache.forEach((b,c)=>{c.startsWith("table-")&&c.includes(`-${a}-`)&&v.invalidate(c)}),await J(a,{forceFetch:!0,source:b})}catch(b){throw console.error("Error updating table data:",b),A("error",b.message,`Failed refreshing ${a}`),b}},[J,A]),L=(0,e.useCallback)(async(a,b={})=>(u(a),await J(a,b)),[J]),M=(0,e.useCallback)(async()=>{let a=w.current?.database_name||"default",b=x.current;return g(`refresh-tables-${a}-${b}`,async()=>{A("loading",`Loading tables (${b})…`),k(!0),m(null);try{let a=w.current?.database_name,d=new URLSearchParams;d.set("source",b),a&&d.set("db",a);let e=await fetch(`/api/tables?${d.toString()}`);if(!e.ok)throw Error("Failed to fetch tables");let f=await e.json();if(f.error)throw Error(f.error);let g=f.tables||[];return c(g),A("success",`${g.length} table${1!==g.length?"s":""} loaded (${b})`),g}catch(a){throw m(a.message),A("error",a.message,"Failed loading tables"),a}finally{k(!1)}},2e3)},[A]),N=(0,e.useCallback)(async a=>{let b="remote"===a?"remote":"local";if(b===x.current)return;let d=x.current;x.current=b,s(b),v.clear(),c([]),u(null),m(null);try{await M(),A("success",`Source switched to ${b}`)}catch(a){throw x.current=d,s(d),a}},[M,A]),O=(0,e.useCallback)(async a=>{A("loading","Creating table…");try{await H(a),v.clear(),await M(),A("success","Table created")}catch(a){throw A("error",a.message,"Create table failed"),Error(`Failed to create table: ${a.message}`)}},[H,M,A]),P=(0,e.useCallback)(async a=>{A("loading",`Dropping "${a}"…`);try{await H(`DROP TABLE ${a};`),v.invalidate(a),await M(),A("success",`Table "${a}" dropped`)}catch(b){throw A("error",b.message,`Drop "${a}" failed`),Error(`Failed to drop table: ${b.message}`)}},[H,M,A]),Q=(0,e.useCallback)(async a=>{A("loading","Syncing migrations…");try{let b=await fetch("/api/migrations/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok){let a=await b.json();throw Error(a.error?.message||"Failed to sync migrations")}let c=await b.json();return A("success","Migrations synced"),c}catch(a){throw console.error("Error syncing migrations:",a),A("error",a.message,"Migration sync failed"),a}},[A]),R=(0,e.useCallback)(async()=>{A("loading","Pulling from remote…");try{let a=localStorage.getItem("cf_credentials");if(!a)throw Error("No Cloudflare credentials found. Please connect to Cloudflare first.");let b=JSON.parse(a);if(!b.accountId||!b.apiToken)throw Error("Invalid credentials stored. Please reconnect to Cloudflare.");let c=await fetch("/api/pull-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:b.accountId,apiToken:b.apiToken})}),d=await c.json();if(!c.ok||!d.success)throw Error(d.error?.message||"Failed to pull from remote");v.clear(),await M();let e=d.details?.appliedMigrations?.length??0;return A("success",`Pull complete — ${e} migration${1!==e?"s":""} applied`),d}catch(a){throw console.error("Error pulling from remote:",a),A("error",a.message,"Pull from remote failed"),a}},[M,A]),S=(0,e.useCallback)(async a=>{A("loading","Pushing to remote…");try{let b=await fetch("/api/push-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok)throw Error(c.error?.message||"Failed to push to remote");let d=c.applied??0;return A("success",`Push complete — ${d} migration${1!==d?"s":""} applied`),c}catch(a){throw console.error("Error pushing to remote:",a),A("error",a.message,"Push to remote failed"),a}},[A]),T=(0,e.useCallback)(async a=>{let b=n.find(b=>b.database_name===a);b&&(w.current=b,q(b),v.clear(),c([]),u(null),await M())},[n,M]),U=(0,e.useMemo)(()=>({tables:b,databases:n,currentDatabase:p,sourceMode:r,setSourceMode:N,switchDatabase:T,isLoading:f,error:l,activeTable:t,lastStatus:y,setOperationStatus:A,lastSyncTime:B,setLastSyncTime:D,refreshTables:M,executeQuery:H,fetchTableSchema:I,fetchTableData:J,updateTableData:K,createTable:O,dropTable:P,syncMigrations:Q,pullFromRemote:R,pushToRemote:S,getCachedTable:E,updateTableCache:G,invalidateTable:F,switchTable:L}),[b,n,p,r,N,T,f,l,t,y,A,B,D,M,H,I,J,K,O,P,Q,R,S,E,G,F,L]);return(0,d.jsx)(h.Provider,{value:U,children:a})}function l(){let a=(0,e.useContext)(h);if(!a)throw Error("useDatabase must be used within a DatabaseProvider");return a}},60673:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>r});var d=c(21124),e=c(99728),f=c(38301),g=c(76608),h=c(26691),i=c(90447),j=c(52603);let k=g.Kq,l=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.LM,{ref:c,className:(0,j.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...b}));l.displayName=g.LM.displayName;let m=(0,h.F)("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),n=f.forwardRef(({className:a,variant:b,...c},e)=>(0,d.jsx)(g.bL,{ref:e,className:(0,j.cn)(m({variant:b}),a),...c}));n.displayName=g.bL.displayName,f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.rc,{ref:c,className:(0,j.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...b})).displayName=g.rc.displayName;let o=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.bm,{ref:c,className:(0,j.cn)("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...b,children:(0,d.jsx)(i.A,{className:"h-4 w-4"})}));o.displayName=g.bm.displayName;let p=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.hE,{ref:c,className:(0,j.cn)("text-sm font-semibold [&+div]:text-xs",a),...b}));p.displayName=g.hE.displayName;let q=f.forwardRef(({className:a,...b},c)=>(0,d.jsx)(g.VY,{ref:c,className:(0,j.cn)("text-sm opacity-90",a),...b}));function r(){let{toasts:a}=(0,e.dj)();return(0,d.jsxs)(k,{children:[a.map(function({id:a,title:b,description:c,action:e,...f}){return(0,d.jsxs)(n,{...f,children:[(0,d.jsxs)("div",{className:"grid gap-1",children:[b&&(0,d.jsx)(p,{children:b}),c&&(0,d.jsx)(q,{children:c})]}),e,(0,d.jsx)(o,{})]},a)}),(0,d.jsx)(l,{})]})}q.displayName=g.VY.displayName},61135:()=>{},61662:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>l,metadata:()=>k});var d=c(75338),e=c(66914),f=c.n(e),g=c(4580),h=c.n(g);c(61135);var i=c(46254),j=c(44158);let k={title:"d1-studio",description:"Native D1 database studio."};function l({children:a}){return(0,d.jsx)("html",{lang:"en",children:(0,d.jsx)("body",{className:`${f().variable} ${h().variable} antialiased`,children:(0,d.jsxs)(i.DatabaseProvider,{children:[a,(0,d.jsx)(j.Toaster,{})," "]})})})}},72606:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81170,23)),Promise.resolve().then(c.t.bind(c,23597,23)),Promise.resolve().then(c.t.bind(c,36893,23)),Promise.resolve().then(c.t.bind(c,89748,23)),Promise.resolve().then(c.t.bind(c,6060,23)),Promise.resolve().then(c.t.bind(c,7184,23)),Promise.resolve().then(c.t.bind(c,69576,23)),Promise.resolve().then(c.t.bind(c,73041,23)),Promise.resolve().then(c.t.bind(c,51384,23))},92020:(a,b,c)=>{Promise.resolve().then(c.bind(c,60673)),Promise.resolve().then(c.bind(c,60122))},99728:(a,b,c)=>{"use strict";c.d(b,{dj:()=>l});var d=c(38301);let e=0,f=new Map,g=a=>{if(f.has(a))return;let b=setTimeout(()=>{f.delete(a),j({type:"REMOVE_TOAST",toastId:a})},1e6);f.set(a,b)},h=[],i={toasts:[]};function j(a){i=((a,b)=>{switch(b.type){case"ADD_TOAST":return{...a,toasts:[b.toast,...a.toasts].slice(0,1)};case"UPDATE_TOAST":return{...a,toasts:a.toasts.map(a=>a.id===b.toast.id?{...a,...b.toast}:a)};case"DISMISS_TOAST":{let{toastId:c}=b;return c?g(c):a.toasts.forEach(a=>{g(a.id)}),{...a,toasts:a.toasts.map(a=>a.id===c||void 0===c?{...a,open:!1}:a)}}case"REMOVE_TOAST":if(void 0===b.toastId)return{...a,toasts:[]};return{...a,toasts:a.toasts.filter(a=>a.id!==b.toastId)}}})(i,a),h.forEach(a=>{a(i)})}function k({...a}){let b=(e=(e+1)%Number.MAX_SAFE_INTEGER).toString(),c=()=>j({type:"DISMISS_TOAST",toastId:b});return j({type:"ADD_TOAST",toast:{...a,id:b,open:!0,onOpenChange:a=>{a||c()}}}),{id:b,dismiss:c,update:a=>j({type:"UPDATE_TOAST",toast:{...a,id:b}})}}function l(){let[a,b]=d.useState(i);return d.useEffect(()=>(h.push(b),()=>{let a=h.indexOf(b);a>-1&&h.splice(a,1)}),[a]),{...a,toast:k,dismiss:a=>j({type:"DISMISS_TOAST",toastId:a})}}}};
@@ -1 +1 @@
1
- globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],ampDevFiles:[],lowPriorityFiles:[],rootMainFiles:["static/chunks/webpack-c7b9f95656aa8fe9.js","static/chunks/4bd1b696-c023c6e3521b1417.js","static/chunks/255-4f212684648fcab9.js","static/chunks/main-app-d20e9d5e211da7c8.js"],rootMainFilesTree:{},pages:{"/_app":["static/chunks/webpack-c7b9f95656aa8fe9.js","static/chunks/framework-a6e0b7e30f98059a.js","static/chunks/main-0bd218f776705cbf.js","static/chunks/pages/_app-7d307437aca18ad4.js"],"/_error":["static/chunks/webpack-c7b9f95656aa8fe9.js","static/chunks/framework-a6e0b7e30f98059a.js","static/chunks/main-0bd218f776705cbf.js","static/chunks/pages/_error-cb2a52f75f2162e2.js"]},ampFirstPages:[]},globalThis.__BUILD_MANIFEST.lowPriorityFiles=["/static/"+process.env.__NEXT_BUILD_ID+"/_buildManifest.js",,"/static/"+process.env.__NEXT_BUILD_ID+"/_ssgManifest.js"];
1
+ globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],ampDevFiles:[],lowPriorityFiles:[],rootMainFiles:["static/chunks/webpack-d5e8b5757f0fec83.js","static/chunks/4bd1b696-c023c6e3521b1417.js","static/chunks/255-4f212684648fcab9.js","static/chunks/main-app-d20e9d5e211da7c8.js"],rootMainFilesTree:{},pages:{"/_app":["static/chunks/webpack-d5e8b5757f0fec83.js","static/chunks/framework-a6e0b7e30f98059a.js","static/chunks/main-0bd218f776705cbf.js","static/chunks/pages/_app-7d307437aca18ad4.js"],"/_error":["static/chunks/webpack-d5e8b5757f0fec83.js","static/chunks/framework-a6e0b7e30f98059a.js","static/chunks/main-0bd218f776705cbf.js","static/chunks/pages/_error-cb2a52f75f2162e2.js"]},ampFirstPages:[]},globalThis.__BUILD_MANIFEST.lowPriorityFiles=["/static/"+process.env.__NEXT_BUILD_ID+"/_buildManifest.js",,"/static/"+process.env.__NEXT_BUILD_ID+"/_ssgManifest.js"];
@@ -1 +1 @@
1
- self.__REACT_LOADABLE_MANIFEST='{"components/schema-view.jsx -> ./schema-erd":{"id":7950,"files":["static/css/599369d853c61df7.css","static/chunks/1a258343.234dd786cf6c097e.js","static/chunks/95.8b08bca2768cb67c.js","static/chunks/950.01ba9ad634bd1f43.js"]}}';
1
+ self.__REACT_LOADABLE_MANIFEST='{"components/schema-view.jsx -> ./schema-erd":{"id":7950,"files":["static/css/599369d853c61df7.css","static/chunks/1a258343.234dd786cf6c097e.js","static/chunks/95.8b08bca2768cb67c.js","static/chunks/950.edd33691c78c1807.js"]}}';
@@ -1 +1 @@
1
- <!DOCTYPE html><!--TDqrfll63o1FXL7rpt5E_--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/4cf2300e9c8272f7-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/93f479601ee12b01-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/b69f03bff92613ce.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c7b9f95656aa8fe9.js"/><script src="/_next/static/chunks/4bd1b696-c023c6e3521b1417.js" async=""></script><script src="/_next/static/chunks/255-4f212684648fcab9.js" async=""></script><script src="/_next/static/chunks/main-app-d20e9d5e211da7c8.js" async=""></script><script src="/_next/static/chunks/421-55f8ce492f5bd9c3.js" async=""></script><script src="/_next/static/chunks/654-f2f8931465d44ae7.js" async=""></script><script src="/_next/static/chunks/823-5f8f96173644e0cc.js" async=""></script><script src="/_next/static/chunks/app/layout-a5219438265f0b6c.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>404: This page could not be found.</title><title>d1-studio</title><meta name="description" content="Native D1 database studio."/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="__variable_188709 __variable_9a8899 antialiased"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><div role="region" aria-label="Notifications (F8)" tabindex="-1" style="pointer-events:none"><ol tabindex="-1" class="fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]"></ol></div> <script src="/_next/static/chunks/webpack-c7b9f95656aa8fe9.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[3190,[\"421\",\"static/chunks/421-55f8ce492f5bd9c3.js\",\"654\",\"static/chunks/654-f2f8931465d44ae7.js\",\"823\",\"static/chunks/823-5f8f96173644e0cc.js\",\"177\",\"static/chunks/app/layout-a5219438265f0b6c.js\"],\"DatabaseProvider\"]\n3:I[9766,[],\"\"]\n4:I[8924,[],\"\"]\n5:I[7747,[\"421\",\"static/chunks/421-55f8ce492f5bd9c3.js\",\"654\",\"static/chunks/654-f2f8931465d44ae7.js\",\"823\",\"static/chunks/823-5f8f96173644e0cc.js\",\"177\",\"static/chunks/app/layout-a5219438265f0b6c.js\"],\"Toaster\"]\n6:I[4431,[],\"OutletBoundary\"]\n8:I[5278,[],\"AsyncMetadataOutlet\"]\na:I[4431,[],\"ViewportBoundary\"]\nc:I[4431,[],\"MetadataBoundary\"]\nd:\"$Sreact.suspense\"\nf:I[7150,[],\"\"]\n:HL[\"/_next/static/media/4cf2300e9c8272f7-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/93f479601ee12b01-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/b69f03bff92613ce.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"TDqrfll63o1FXL7rpt5E_\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/b69f03bff92613ce.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__variable_188709 __variable_9a8899 antialiased\",\"children\":[\"$\",\"$L2\",null,{\"children\":[[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}],[\"$\",\"$L5\",null,{}],\" \"]}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L6\",null,{\"children\":[\"$L7\",[\"$\",\"$L8\",null,{\"promise\":\"$@9\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$La\",null,{\"children\":\"$Lb\"}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]],[\"$\",\"$Lc\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$d\",null,{\"fallback\":null,\"children\":\"$Le\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$f\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n7:null\n"])</script><script>self.__next_f.push([1,"9:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"d1-studio\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Native D1 database studio.\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"e:\"$9:metadata\"\n"])</script></body></html>
1
+ <!DOCTYPE html><!--kGRfd0CDzKPsrYHw9rLTQ--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/4cf2300e9c8272f7-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="preload" href="/_next/static/media/93f479601ee12b01-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/262ae258bbcfd289.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-d5e8b5757f0fec83.js"/><script src="/_next/static/chunks/4bd1b696-c023c6e3521b1417.js" async=""></script><script src="/_next/static/chunks/255-4f212684648fcab9.js" async=""></script><script src="/_next/static/chunks/main-app-d20e9d5e211da7c8.js" async=""></script><script src="/_next/static/chunks/421-55f8ce492f5bd9c3.js" async=""></script><script src="/_next/static/chunks/654-f2f8931465d44ae7.js" async=""></script><script src="/_next/static/chunks/823-77b9a2d152da81dd.js" async=""></script><script src="/_next/static/chunks/app/layout-a5219438265f0b6c.js" async=""></script><meta name="robots" content="noindex"/><meta name="next-size-adjust" content=""/><title>404: This page could not be found.</title><title>d1-studio</title><meta name="description" content="Native D1 database studio."/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="__variable_188709 __variable_9a8899 antialiased"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><div role="region" aria-label="Notifications (F8)" tabindex="-1" style="pointer-events:none"><ol tabindex="-1" class="fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]"></ol></div> <script src="/_next/static/chunks/webpack-d5e8b5757f0fec83.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[3190,[\"421\",\"static/chunks/421-55f8ce492f5bd9c3.js\",\"654\",\"static/chunks/654-f2f8931465d44ae7.js\",\"823\",\"static/chunks/823-77b9a2d152da81dd.js\",\"177\",\"static/chunks/app/layout-a5219438265f0b6c.js\"],\"DatabaseProvider\"]\n3:I[9766,[],\"\"]\n4:I[8924,[],\"\"]\n5:I[7747,[\"421\",\"static/chunks/421-55f8ce492f5bd9c3.js\",\"654\",\"static/chunks/654-f2f8931465d44ae7.js\",\"823\",\"static/chunks/823-77b9a2d152da81dd.js\",\"177\",\"static/chunks/app/layout-a5219438265f0b6c.js\"],\"Toaster\"]\n6:I[4431,[],\"OutletBoundary\"]\n8:I[5278,[],\"AsyncMetadataOutlet\"]\na:I[4431,[],\"ViewportBoundary\"]\nc:I[4431,[],\"MetadataBoundary\"]\nd:\"$Sreact.suspense\"\nf:I[7150,[],\"\"]\n:HL[\"/_next/static/media/4cf2300e9c8272f7-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/media/93f479601ee12b01-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n:HL[\"/_next/static/css/262ae258bbcfd289.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"kGRfd0CDzKPsrYHw9rLTQ\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/262ae258bbcfd289.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__variable_188709 __variable_9a8899 antialiased\",\"children\":[\"$\",\"$L2\",null,{\"children\":[[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}],[\"$\",\"$L5\",null,{}],\" \"]}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L6\",null,{\"children\":[\"$L7\",[\"$\",\"$L8\",null,{\"promise\":\"$@9\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$La\",null,{\"children\":\"$Lb\"}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]],[\"$\",\"$Lc\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$d\",null,{\"fallback\":null,\"children\":\"$Le\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$f\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n7:null\n"])</script><script>self.__next_f.push([1,"9:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"d1-studio\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Native D1 database studio.\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"e:\"$9:metadata\"\n"])</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-c7b9f95656aa8fe9.js" defer=""></script><script src="/_next/static/chunks/framework-a6e0b7e30f98059a.js" defer=""></script><script src="/_next/static/chunks/main-0bd218f776705cbf.js" defer=""></script><script src="/_next/static/chunks/pages/_app-7d307437aca18ad4.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cb2a52f75f2162e2.js" defer=""></script><script src="/_next/static/TDqrfll63o1FXL7rpt5E_/_buildManifest.js" defer=""></script><script src="/_next/static/TDqrfll63o1FXL7rpt5E_/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"TDqrfll63o1FXL7rpt5E_","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-d5e8b5757f0fec83.js" defer=""></script><script src="/_next/static/chunks/framework-a6e0b7e30f98059a.js" defer=""></script><script src="/_next/static/chunks/main-0bd218f776705cbf.js" defer=""></script><script src="/_next/static/chunks/pages/_app-7d307437aca18ad4.js" defer=""></script><script src="/_next/static/chunks/pages/_error-cb2a52f75f2162e2.js" defer=""></script><script src="/_next/static/kGRfd0CDzKPsrYHw9rLTQ/_buildManifest.js" defer=""></script><script src="/_next/static/kGRfd0CDzKPsrYHw9rLTQ/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"kGRfd0CDzKPsrYHw9rLTQ","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[823],{1374:(e,t,a)=>{a.d(t,{dj:()=>d});var r=a(2115);let o=0,c=new Map,n=e=>{if(c.has(e))return;let t=setTimeout(()=>{c.delete(e),i({type:"REMOVE_TOAST",toastId:e})},1e6);c.set(e,t)},s=[],l={toasts:[]};function i(e){l=((e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?n(a):e.toasts.forEach(e=>{n(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(l,e),s.forEach(e=>{e(l)})}function u(e){let{...t}=e,a=(o=(o+1)%Number.MAX_SAFE_INTEGER).toString(),r=()=>i({type:"DISMISS_TOAST",toastId:a});return i({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||r()}}}),{id:a,dismiss:r,update:e=>i({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function d(){let[e,t]=r.useState(l);return r.useEffect(()=>(s.push(t),()=>{let e=s.indexOf(t);e>-1&&s.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>i({type:"DISMISS_TOAST",toastId:e})}}},3190:(e,t,a)=>{a.d(t,{DatabaseProvider:()=>u,t:()=>d});var r=a(5155),o=a(2115);let c=new Map;function n(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2e3,r=c.get(e);if(r&&Date.now()-r.timestamp<a)return r.promise;let o=t();return c.set(e,{promise:o,timestamp:Date.now()}),o.finally(()=>{setTimeout(()=>{c.delete(e)},a)}),o}let s=(0,o.createContext)(void 0);class l{get(e){let t=this.cache.get(e);return t||null}set(e,t,a,r){this.cache.set(e,{data:t,schema:a,meta:r,timestamp:Date.now()})}update(e,t,a,r){let o=this.cache.get(e);o&&this.cache.set(e,{data:t||o.data,schema:a||o.schema,meta:r||o.meta,timestamp:Date.now()})}invalidate(e){this.cache.delete(e)}clear(){this.cache.clear()}constructor(){this.cache=new Map}}class i{async add(e){return new Promise((t,a)=>{this.queue.push({operation:e,resolve:t,reject:a}),this.process()})}async process(){if(this.processing||0===this.queue.length)return;this.processing=!0;let{operation:e,resolve:t,reject:a}=this.queue.shift();try{let a=await e();t(a)}catch(e){a(e)}finally{this.processing=!1,this.process()}}constructor(){this.queue=[],this.processing=!1}}function u(e){let{children:t}=e,[a,c]=(0,o.useState)([]),[u,d]=(0,o.useState)(!0),[h,f]=(0,o.useState)(null),[g,m]=(0,o.useState)([]),[p,w]=(0,o.useState)(null),[y,b]=(0,o.useState)(()=>"remote"===localStorage.getItem("d1_source_mode")?"remote":"local");(0,o.useRef)(new i);let[S,v]=(0,o.useState)(null),E=(0,o.useRef)(new l).current,C=(0,o.useRef)(null),T=(0,o.useRef)(y),[k,_]=(0,o.useState)(null),I=(0,o.useCallback)(function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;_({type:e,message:t,detail:a,ts:new Date})},[]),[O,P]=(0,o.useState)(()=>localStorage.getItem("d1_last_sync")||null),D=(0,o.useCallback)(e=>{let t=e instanceof Date?e.toISOString():new Date().toISOString();localStorage.setItem("d1_last_sync",t),P(t)},[]);(0,o.useEffect)(()=>{T.current=y,localStorage.setItem("d1_source_mode",y)},[y]);let A=(0,o.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T.current,o="table-".concat(r,"-").concat(e,"-").concat(t,"-").concat(a);return E.get(o)},[]),j=(0,o.useCallback)(e=>{E.cache.forEach((t,a)=>{a.startsWith("table-")&&a.includes("-".concat(e,"-"))&&E.invalidate(a)})},[]),F=(0,o.useCallback)(function(e,t,a,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:50,n=arguments.length>6&&void 0!==arguments[6]?arguments[6]:T.current,s="table-".concat(n,"-").concat(e,"-").concat(o,"-").concat(c);E.update(s,t,a,r)},[]),R=(0,o.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=(null==t?void 0:t.target)==="remote"||(null==t?void 0:t.target)==="local"?t.target:T.current,r=/^\s*(SELECT|PRAGMA|EXPLAIN)/i.test(e),o="query-".concat(a,"-").concat(e),c=async()=>{I("loading","Executing ".concat(a," query…"));try{var t,r;let o=null==(t=C.current)?void 0:t.database_name,c=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e,target:a,...o&&{db:o}})});if(!c.ok){let e="Failed to execute query";try{let t=await c.json();e=(null==t||null==(r=t.error)?void 0:r.message)||e}catch(e){}throw Error(e)}let n=await c.json();if(!n.success)throw Error(n.error||"Query execution failed");return I("success","".concat("remote"===a?"Remote":"Local"," query executed")),n}catch(e){throw I("error",e.message||"Query failed"),e||Error("An unknown error occurred")}};return r?n(o,c,1e3):c()},[I]),M=(0,o.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let a=(null==t?void 0:t.source)==="remote"||(null==t?void 0:t.source)==="local"?t.source:T.current,r="source=".concat(encodeURIComponent(a)),o=await fetch("/api/tables/".concat(e,"?").concat(r)),c=await o.json();if(!o.ok||!c.success)throw Error(c.error||"Failed to fetch table schema");return c.schema||[]}catch(e){throw console.error("Schema fetch error:",e),e}},[]),N=(0,o.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{forceFetch:a=!1,page:r=1,limit:o=50}=t,c=(null==t?void 0:t.source)==="remote"||(null==t?void 0:t.source)==="local"?t.source:T.current,s="table-".concat(c,"-").concat(e,"-").concat(r,"-").concat(o);if(!a){let e=E.get(s);if(e)return e}return n("table-".concat(c,"-").concat(e,"-").concat(r,"-").concat(o),async()=>{I("loading","Loading ".concat(e," (").concat(c,")…"));try{var t,a;let n=null==(t=C.current)?void 0:t.database_name,l=n?"&db=".concat(encodeURIComponent(n)):"",i="source=".concat(encodeURIComponent(c)),u=await fetch("/api/tables/".concat(e,"?page=").concat(r,"&limit=").concat(o,"&").concat(i).concat(l),{headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!u.ok)throw Error("Failed to fetch table data");let d=await u.json();if(!d.success)throw Error(d.error||"Failed to fetch table data");E.set(s,d.data,d.schema,d.meta);let h=(null==(a=d.data)?void 0:a.length)||0;return I("success","Loaded ".concat(h," row").concat(1!==h?"s":""," \xb7 ").concat(e," (").concat(c,")")),d}catch(t){throw console.error("Error fetching table data:",t),I("error",t.message,"Failed loading ".concat(e)),t}},1e3)},[I]),q=(0,o.useCallback)(async e=>{let t=T.current;I("loading","Refreshing ".concat(e,"…"));try{return E.cache.forEach((t,a)=>{a.startsWith("table-")&&a.includes("-".concat(e,"-"))&&E.invalidate(a)}),await N(e,{forceFetch:!0,source:t})}catch(t){throw console.error("Error updating table data:",t),I("error",t.message,"Failed refreshing ".concat(e)),t}},[N,I]),x=(0,o.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v(e),await N(e,t)},[N]),L=(0,o.useCallback)(async()=>{var e;let t=(null==(e=C.current)?void 0:e.database_name)||"default",a=T.current;return n("refresh-tables-".concat(t,"-").concat(a),async()=>{I("loading","Loading tables (".concat(a,")…")),d(!0),f(null);try{var e;let t=null==(e=C.current)?void 0:e.database_name,r=new URLSearchParams;r.set("source",a),t&&r.set("db",t);let o=await fetch("/api/tables?".concat(r.toString()));if(!o.ok)throw Error("Failed to fetch tables");let n=await o.json();if(n.error)throw Error(n.error);let s=n.tables||[];return c(s),I("success","".concat(s.length," table").concat(1!==s.length?"s":""," loaded (").concat(a,")")),s}catch(e){throw f(e.message),I("error",e.message,"Failed loading tables"),e}finally{d(!1)}},2e3)},[I]),U=(0,o.useCallback)(async e=>{let t="remote"===e?"remote":"local";if(t===T.current)return;let a=T.current;T.current=t,b(t),E.clear(),c([]),v(null),f(null);try{await L(),I("success","Source switched to ".concat(t))}catch(e){throw T.current=a,b(a),e}},[L,I]),J=(0,o.useCallback)(async e=>{I("loading","Creating table…");try{await R(e),E.clear(),await L(),I("success","Table created")}catch(e){throw I("error",e.message,"Create table failed"),Error("Failed to create table: ".concat(e.message))}},[R,L,I]),Q=(0,o.useCallback)(async e=>{I("loading",'Dropping "'.concat(e,'"…'));try{await R("DROP TABLE ".concat(e,";")),E.invalidate(e),await L(),I("success",'Table "'.concat(e,'" dropped'))}catch(t){throw I("error",t.message,'Drop "'.concat(e,'" failed')),Error("Failed to drop table: ".concat(t.message))}},[R,L,I]),G=(0,o.useCallback)(async e=>{I("loading","Syncing migrations…");try{let a=await fetch("/api/migrations/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){var t;let e=await a.json();throw Error((null==(t=e.error)?void 0:t.message)||"Failed to sync migrations")}let r=await a.json();return I("success","Migrations synced"),r}catch(e){throw console.error("Error syncing migrations:",e),I("error",e.message,"Migration sync failed"),e}},[I]),V=(0,o.useCallback)(async()=>{I("loading","Pulling from remote…");try{var e,t,a,r;let o=localStorage.getItem("cf_credentials");if(!o)throw Error("No Cloudflare credentials found. Please connect to Cloudflare first.");let c=JSON.parse(o);if(!c.accountId||!c.apiToken)throw Error("Invalid credentials stored. Please reconnect to Cloudflare.");let n=await fetch("/api/pull-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:c.accountId,apiToken:c.apiToken})}),s=await n.json();if(!n.ok||!s.success)throw Error((null==(a=s.error)?void 0:a.message)||"Failed to pull from remote");E.clear(),await L();let l=null!=(r=null==(t=s.details)||null==(e=t.appliedMigrations)?void 0:e.length)?r:0;return I("success","Pull complete — ".concat(l," migration").concat(1!==l?"s":""," applied")),s}catch(e){throw console.error("Error pulling from remote:",e),I("error",e.message,"Pull from remote failed"),e}},[L,I]),W=(0,o.useCallback)(async e=>{I("loading","Pushing to remote…");try{var t,a;let r=await fetch("/api/push-remote/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await r.json();if(!r.ok)throw Error((null==(t=o.error)?void 0:t.message)||"Failed to push to remote");let c=null!=(a=o.applied)?a:0;return I("success","Push complete — ".concat(c," migration").concat(1!==c?"s":""," applied")),o}catch(e){throw console.error("Error pushing to remote:",e),I("error",e.message,"Push to remote failed"),e}},[I]),X=(0,o.useCallback)(async e=>{let t=g.find(t=>t.database_name===e);t&&(C.current=t,w(t),E.clear(),c([]),v(null),await L())},[g,L]);(0,o.useEffect)(()=>((async()=>{try{let e=await fetch("/api/databases");if(e.ok){let t=(await e.json()).databases||[];m(t),t.length>0&&!C.current&&(C.current=t[0],w(t[0]))}}catch(e){}L()})(),()=>{E.clear()}),[L]);let B=(0,o.useMemo)(()=>({tables:a,databases:g,currentDatabase:p,sourceMode:y,setSourceMode:U,switchDatabase:X,isLoading:u,error:h,activeTable:S,lastStatus:k,setOperationStatus:I,lastSyncTime:O,setLastSyncTime:D,refreshTables:L,executeQuery:R,fetchTableSchema:M,fetchTableData:N,updateTableData:q,createTable:J,dropTable:Q,syncMigrations:G,pullFromRemote:V,pushToRemote:W,getCachedTable:A,updateTableCache:F,invalidateTable:j,switchTable:x}),[a,g,p,y,U,X,u,h,S,k,I,O,D,L,R,M,N,q,J,Q,G,V,W,A,F,j,x]);return(0,r.jsx)(s.Provider,{value:B,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useDatabase must be used within a DatabaseProvider");return e}},3537:(e,t,a)=>{a.d(t,{cn:()=>c});var r=a(2821),o=a(5889);function c(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,o.QP)((0,r.$)(t))}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[950],{7950:(e,t,n)=>{n.r(t),n.d(t,{SchemaERD:()=>k});var o=n(5155),r=n(2115),l=n(2539),s=n(6122);n(682);var i=n(8288),a=n(5958),d=n(8822),c=n(944),h=n(3381),f=n(2033);let p={canvas:"#f8fafc",dot:"#cbd5e1",cardBg:"#ffffff",cardBorder:"#e2e8f0",headerBg:"#f8fafc",headerBorder:"#e2e8f0",rowBorder:"#f1f5f9",tableName:"#0f172a",colName:"#1e293b",type:"#64748b",typePillBg:"#f1f5f9",typePillBdr:"#e2e8f0",typeNull:"#94a3b8",pkFkIcon:"#0f172a",diamondFill:"#334155",diamondNull:"#94a3b8",handle:"#334155",handleBorder:"#ffffff",edge:"#334155",shadow:"0 2px 8px rgba(0,0,0,0.08)",btnBg:"#ffffff",btnBorder:"#e2e8f0",btnText:"#374151",btnHover:"#f1f5f9",legendBg:"#ffffff",legendBdr:"#e2e8f0",legendText:"#64748b"};function x(e){let{filled:t}=e;return(0,o.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",children:t?(0,o.jsx)("polygon",{points:"5,0 10,5 5,10 0,5",fill:"currentColor"}):(0,o.jsx)("polygon",{points:"5,0 10,5 5,10 0,5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}function u(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[(0,o.jsx)("rect",{x:"1",y:"1",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"9",y:"1",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"1",y:"9",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"})]})}function g(e){let{type:t,nullable:n}=e,r=(t||"text").toLowerCase(),l="uuid"===r||r.startsWith("timestamp");return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[l?(0,o.jsx)("span",{style:{fontSize:10,fontFamily:"monospace",padding:"1px 6px",borderRadius:9999,border:"1px solid ".concat(p.typePillBdr),background:p.typePillBg,color:p.type},children:r}):(0,o.jsx)("span",{style:{fontSize:11,fontFamily:"monospace",color:p.type},children:r}),n&&(0,o.jsx)("span",{style:{fontSize:10,color:p.typeNull},children:"| null"})]})}let y={table:function(e){let{data:t}=e,{name:n,columns:r,fkSet:d}=t;return(0,o.jsxs)("div",{style:{position:"relative",width:280},children:[(0,o.jsxs)("div",{style:{overflow:"hidden",borderRadius:8,border:"1px solid ".concat(p.cardBorder),boxShadow:p.shadow},children:[(0,o.jsxs)("div",{style:{height:44,background:p.headerBg,borderBottom:"1px solid ".concat(p.headerBorder),display:"flex",alignItems:"center",gap:8,padding:"0 12px"},children:[(0,o.jsx)(u,{}),(0,o.jsx)("span",{style:{color:p.tableName,fontFamily:"monospace",fontWeight:600,fontSize:13},children:n})]}),r.map((e,t)=>{let n=e.pk>0,l=d.has(e.name),s=1===e.notnull||n;return(0,o.jsxs)("div",{style:{height:32,display:"flex",alignItems:"center",gap:8,padding:"0 12px",background:p.cardBg,borderBottom:t<r.length-1?"1px solid ".concat(p.rowBorder):"none"},children:[(0,o.jsx)("div",{style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n?(0,o.jsx)(i.A,{size:12,color:p.pkFkIcon}):l?(0,o.jsx)(a.A,{size:12,color:p.pkFkIcon}):s?(0,o.jsx)("span",{style:{color:p.diamondFill},children:(0,o.jsx)(x,{filled:!0})}):(0,o.jsx)("span",{style:{color:p.diamondNull},children:(0,o.jsx)(x,{filled:!1})})}),(0,o.jsx)("span",{style:{flex:1,fontSize:12,fontFamily:"monospace",color:p.colName,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,o.jsx)(g,{type:e.type,nullable:!s})]},e.cid)})]}),r.map((e,t)=>{let n=e.pk>0,r=d.has(e.name);if(!n&&!r)return null;let i=44+32*t+16;return(0,o.jsxs)("span",{children:[n&&(0,o.jsx)(l.h7,{id:"".concat(e.name,"-target"),type:"target",position:s.yX.Left,style:{top:i,background:p.handle,width:7,height:7,border:"1.5px solid ".concat(p.handleBorder)}}),r&&(0,o.jsx)(l.h7,{id:"".concat(e.name,"-source"),type:"source",position:s.yX.Right,style:{top:i,background:p.handle,width:7,height:7,border:"1.5px solid ".concat(p.handleBorder)}})]},e.cid)})]})}};function b(e){let{icon:t,label:n}=e;return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5},children:[t,(0,o.jsx)("span",{style:{fontSize:11,color:p.legendText},children:n})]})}function m(e){let{children:t,onClick:n,disabled:r,title:l}=e;return(0,o.jsx)("button",{onClick:n,disabled:r,title:l,style:{width:32,height:32,borderRadius:6,background:p.btnBg,color:p.btnText,border:"1px solid ".concat(p.btnBorder),cursor:r?"not-allowed":"pointer",opacity:r?.5:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:p.shadow},onMouseOver:e=>{r||(e.currentTarget.style.background=p.btnHover)},onMouseOut:e=>{e.currentTarget.style.background=p.btnBg},children:t})}function j(e){let{tables:t,onRefresh:n,isLoading:f}=e,[u,g,j]=(0,l.ck)([]),[k,w,v]=(0,l.fM)([]),{fitView:B}=(0,l.VH)(),S=(0,r.useCallback)(()=>{if(!t.length)return;let e=function(e){let t=new Map(e.map(e=>[e.name,new Set]));e.forEach(e=>e.foreignKeys.forEach(n=>{var o;return null==(o=t.get(e.name))?void 0:o.add(n.table)}));let n=new Map;e.forEach(e=>(function e(o){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(n.has(o))return n.get(o);if(r.has(o))return n.set(o,0),0;r.add(o);let l=t.get(o)||new Set,s=0===l.size?0:Math.max(...[...l].map(t=>e(t,r)+1));return n.set(o,s),s})(e.name));let o=new Map;e.forEach(e=>{var t;let r=null!=(t=n.get(e.name))?t:0;o.has(r)||o.set(r,[]),o.get(r).push(e.name)});let r=[...o.entries()].sort((e,t)=>t[0]-e[0]),l={};return r.forEach((t,n)=>{let[,o]=t,r=-o.reduce((t,n)=>{var o;let r=e.find(e=>e.name===n);return t+44+32*((null==r||null==(o=r.columns)?void 0:o.length)||0)+44},0)/2;o.forEach(t=>{var o;let s=e.find(e=>e.name===t),i=44+32*((null==s||null==(o=s.columns)?void 0:o.length)||0);l[t]={x:390*n,y:r},r+=i+44})}),l}(t),n=t.map(t=>({id:t.name,type:"table",position:e[t.name]||{x:0,y:0},data:{name:t.name,columns:t.columns,fkSet:new Set(t.foreignKeys.map(e=>e.from))}})),o=[];t.forEach(e=>{e.foreignKeys.forEach(n=>{let r=t.find(e=>e.name===n.table),l=null==r?void 0:r.columns.find(e=>1===e.pk);o.push({id:"".concat(e.name,".").concat(n.from,"->").concat(n.table,".").concat(n.to),source:e.name,sourceHandle:"".concat(n.from,"-source"),target:n.table,targetHandle:l?"".concat(l.name,"-target"):"".concat(n.to,"-target"),type:"smoothstep",style:{stroke:p.edge,strokeWidth:1.5,opacity:.6},markerEnd:{type:s.TG.ArrowClosed,color:p.edge,width:10,height:10}})})}),g(n),w(o),setTimeout(()=>B({padding:.15}),80)},[t,g,w,B]);return(0,r.useEffect)(()=>{S()},[S]),(0,o.jsxs)(l.Gc,{nodes:u,edges:k,onNodesChange:j,onEdgesChange:v,nodeTypes:y,fitView:!0,minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},style:{background:p.canvas},children:[(0,o.jsx)(l.VS,{variant:l._5.Dots,color:p.dot,gap:20,size:1}),(0,o.jsx)(l.H2,{showInteractive:!1,style:{background:p.btnBg,border:"1px solid ".concat(p.btnBorder),borderRadius:8,boxShadow:p.shadow}}),(0,o.jsx)(l.Zk,{position:"top-right",children:(0,o.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,o.jsxs)("button",{onClick:S,style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,fontSize:12,fontWeight:600,background:p.btnBg,color:p.btnText,border:"1px solid ".concat(p.btnBorder),cursor:"pointer",boxShadow:p.shadow},onMouseOver:e=>e.currentTarget.style.background=p.btnHover,onMouseOut:e=>e.currentTarget.style.background=p.btnBg,children:[(0,o.jsx)(d.A,{size:13}),"Auto layout"]}),(0,o.jsx)(m,{onClick:()=>B({padding:.15}),title:"Fit view",children:(0,o.jsx)(c.A,{size:13})}),(0,o.jsx)(m,{onClick:n,disabled:f,title:"Refresh",children:(0,o.jsx)(h.A,{size:13,style:{animation:f?"spin 1s linear infinite":"none"}})})]})}),(0,o.jsx)(l.Zk,{position:"bottom-center",children:(0,o.jsxs)("div",{style:{display:"flex",gap:20,padding:"8px 16px",background:p.legendBg,border:"1px solid ".concat(p.legendBdr),borderRadius:8,boxShadow:p.shadow},children:[(0,o.jsx)(b,{icon:(0,o.jsx)(i.A,{size:12,color:p.pkFkIcon}),label:"Primary key"}),(0,o.jsx)(b,{icon:(0,o.jsx)(a.A,{size:12,color:p.pkFkIcon}),label:"Foreign key"}),(0,o.jsx)(b,{icon:(0,o.jsx)("span",{style:{color:p.diamondFill},children:(0,o.jsx)(x,{filled:!0})}),label:"Non-null"}),(0,o.jsx)(b,{icon:(0,o.jsx)("span",{style:{color:p.diamondNull},children:(0,o.jsx)(x,{filled:!1})}),label:"Nullable"})]})})]})}function k(e){let{db:t}=e,[n,s]=(0,r.useState)([]),[i,a]=(0,r.useState)(!0),[d,c]=(0,r.useState)(null),h=(0,r.useCallback)(async()=>{a(!0),c(null);try{let e=t?"?db=".concat(encodeURIComponent(t)):"",n=await fetch("/api/schema".concat(e)),o=await n.json();if(!o.success)throw Error(o.error||"Failed to load schema");s(o.tables)}catch(e){c(e.message)}finally{a(!1)}},[t]);return((0,r.useEffect)(()=>{h()},[h]),i)?(0,o.jsxs)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas,color:p.type,gap:8},children:[(0,o.jsx)(f.A,{size:18,style:{animation:"spin 1s linear infinite"}}),(0,o.jsx)("span",{style:{fontSize:14},children:"Loading schema…"})]}):d?(0,o.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas},children:(0,o.jsxs)("div",{style:{textAlign:"center",color:p.type},children:[(0,o.jsx)("p",{style:{fontSize:14,marginBottom:8},children:d}),(0,o.jsx)("button",{onClick:h,style:{fontSize:12,color:p.tableName,textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}):n.length?(0,o.jsx)("div",{style:{height:"100%",background:p.canvas},children:(0,o.jsx)(l.Ln,{children:(0,o.jsx)(j,{tables:n,onRefresh:h,isLoading:i})})}):(0,o.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas,color:p.type},children:(0,o.jsx)("p",{style:{fontSize:14},children:"No tables found"})})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[950],{7950:(e,t,n)=>{n.r(t),n.d(t,{SchemaERD:()=>k});var o=n(5155),r=n(2115),l=n(2539),s=n(6122);n(682);var i=n(8288),a=n(5958),d=n(8822),c=n(944),h=n(3381),f=n(2033);let p={canvas:"#f8fafc",dot:"#cbd5e1",cardBg:"#ffffff",cardBorder:"#e2e8f0",headerBg:"#f8fafc",headerBorder:"#e2e8f0",rowBorder:"#f1f5f9",tableName:"#0f172a",colName:"#1e293b",type:"#64748b",typePillBg:"#f1f5f9",typePillBdr:"#e2e8f0",typeNull:"#94a3b8",pkFkIcon:"#0f172a",diamondFill:"#334155",diamondNull:"#94a3b8",handle:"#334155",handleBorder:"#ffffff",edge:"#334155",shadow:"0 2px 8px rgba(0,0,0,0.08)",btnBg:"#ffffff",btnBorder:"#e2e8f0",btnText:"#374151",btnHover:"#f1f5f9",legendBg:"#ffffff",legendBdr:"#e2e8f0",legendText:"#64748b"};function u(e){let{filled:t}=e;return(0,o.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",children:t?(0,o.jsx)("polygon",{points:"5,0 10,5 5,10 0,5",fill:"currentColor"}):(0,o.jsx)("polygon",{points:"5,0 10,5 5,10 0,5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}function x(){return(0,o.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[(0,o.jsx)("rect",{x:"1",y:"1",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"9",y:"1",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"1",y:"9",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"}),(0,o.jsx)("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",stroke:p.type,strokeWidth:"1.5"})]})}function g(e){let{type:t,nullable:n}=e,r=(t||"text").toLowerCase(),l="uuid"===r||r.startsWith("timestamp");return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[l?(0,o.jsx)("span",{style:{fontSize:10,fontFamily:"monospace",padding:"1px 6px",borderRadius:9999,border:"1px solid ".concat(p.typePillBdr),background:p.typePillBg,color:p.type},children:r}):(0,o.jsx)("span",{style:{fontSize:11,fontFamily:"monospace",color:p.type},children:r}),n&&(0,o.jsx)("span",{style:{fontSize:10,color:p.typeNull},children:"| null"})]})}let y={table:function(e){let{data:t}=e,{name:n,columns:r,fkSet:d}=t;return(0,o.jsxs)("div",{style:{position:"relative",width:280},children:[(0,o.jsxs)("div",{style:{overflow:"hidden",borderRadius:8,border:"1px solid ".concat(p.cardBorder),boxShadow:p.shadow},children:[(0,o.jsxs)("div",{style:{height:44,background:p.headerBg,borderBottom:"1px solid ".concat(p.headerBorder),display:"flex",alignItems:"center",gap:8,padding:"0 12px"},children:[(0,o.jsx)(x,{}),(0,o.jsx)("span",{style:{color:p.tableName,fontFamily:"monospace",fontWeight:600,fontSize:13},children:n})]}),r.map((e,t)=>{let n=e.pk>0,l=d.has(e.name),s=1===e.notnull||n;return(0,o.jsxs)("div",{style:{height:32,display:"flex",alignItems:"center",gap:8,padding:"0 12px",background:p.cardBg,borderBottom:t<r.length-1?"1px solid ".concat(p.rowBorder):"none"},children:[(0,o.jsx)("div",{style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n?(0,o.jsx)(i.A,{size:12,color:p.pkFkIcon}):l?(0,o.jsx)(a.A,{size:12,color:p.pkFkIcon}):s?(0,o.jsx)("span",{style:{color:p.diamondFill},children:(0,o.jsx)(u,{filled:!0})}):(0,o.jsx)("span",{style:{color:p.diamondNull},children:(0,o.jsx)(u,{filled:!1})})}),(0,o.jsx)("span",{style:{flex:1,fontSize:12,fontFamily:"monospace",color:p.colName,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,o.jsx)(g,{type:e.type,nullable:!s})]},e.cid)})]}),r.map((e,t)=>{let n=e.pk>0,r=d.has(e.name);if(!n&&!r)return null;let i=44+32*t+16;return(0,o.jsxs)("span",{children:[n&&(0,o.jsx)(l.h7,{id:"".concat(e.name,"-target"),type:"target",position:s.yX.Left,style:{top:i,background:p.handle,width:7,height:7,border:"1.5px solid ".concat(p.handleBorder)}}),r&&(0,o.jsx)(l.h7,{id:"".concat(e.name,"-source"),type:"source",position:s.yX.Right,style:{top:i,background:p.handle,width:7,height:7,border:"1.5px solid ".concat(p.handleBorder)}})]},e.cid)})]})}};function b(e){let{icon:t,label:n}=e;return(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5},children:[t,(0,o.jsx)("span",{style:{fontSize:11,color:p.legendText},children:n})]})}function m(e){let{children:t,onClick:n,disabled:r,title:l}=e;return(0,o.jsx)("button",{onClick:n,disabled:r,title:l,style:{width:32,height:32,borderRadius:6,background:p.btnBg,color:p.btnText,border:"1px solid ".concat(p.btnBorder),cursor:r?"not-allowed":"pointer",opacity:r?.5:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:p.shadow},onMouseOver:e=>{r||(e.currentTarget.style.background=p.btnHover)},onMouseOut:e=>{e.currentTarget.style.background=p.btnBg},children:t})}function j(e){let{tables:t,onRefresh:n,isLoading:f}=e,[x,g,j]=(0,l.ck)([]),[k,w,v]=(0,l.fM)([]),{fitView:B}=(0,l.VH)(),S=(0,r.useCallback)(()=>{if(!t.length)return;let e=function(e){let t=new Map(e.map(e=>[e.name,new Set]));e.forEach(e=>e.foreignKeys.forEach(n=>{var o;return null==(o=t.get(e.name))?void 0:o.add(n.table)}));let n=new Map;e.forEach(e=>(function e(o){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(n.has(o))return n.get(o);if(r.has(o))return n.set(o,0),0;r.add(o);let l=t.get(o)||new Set,s=0===l.size?0:Math.max(...[...l].map(t=>e(t,r)+1));return n.set(o,s),s})(e.name));let o=new Map;e.forEach(e=>{var t;let r=null!=(t=n.get(e.name))?t:0;o.has(r)||o.set(r,[]),o.get(r).push(e.name)});let r=[...o.entries()].sort((e,t)=>t[0]-e[0]),l={};return r.forEach((t,n)=>{let[,o]=t,r=-o.reduce((t,n)=>{var o;let r=e.find(e=>e.name===n);return t+44+32*((null==r||null==(o=r.columns)?void 0:o.length)||0)+44},0)/2;o.forEach(t=>{var o;let s=e.find(e=>e.name===t),i=44+32*((null==s||null==(o=s.columns)?void 0:o.length)||0);l[t]={x:390*n,y:r},r+=i+44})}),l}(t),n=t.map(t=>({id:t.name,type:"table",position:e[t.name]||{x:0,y:0},data:{name:t.name,columns:t.columns,fkSet:new Set(t.foreignKeys.map(e=>e.from))}})),o=[];t.forEach(e=>{e.foreignKeys.forEach(n=>{let r=t.find(e=>e.name===n.table),l=null==r?void 0:r.columns.find(e=>1===e.pk);o.push({id:"".concat(e.name,".").concat(n.from,"->").concat(n.table,".").concat(n.to),source:e.name,sourceHandle:"".concat(n.from,"-source"),target:n.table,targetHandle:l?"".concat(l.name,"-target"):"".concat(n.to,"-target"),type:"smoothstep",style:{stroke:p.edge,strokeWidth:1.5,opacity:.6},markerEnd:{type:s.TG.ArrowClosed,color:p.edge,width:10,height:10}})})}),g(n),w(o),setTimeout(()=>B({padding:.15}),80)},[t,g,w,B]);return(0,r.useEffect)(()=>{S()},[S]),(0,o.jsxs)(l.Gc,{nodes:x,edges:k,onNodesChange:j,onEdgesChange:v,nodeTypes:y,fitView:!0,minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},style:{background:p.canvas},children:[(0,o.jsx)(l.VS,{variant:l._5.Dots,color:p.dot,gap:20,size:1}),(0,o.jsx)(l.H2,{showInteractive:!1,style:{background:p.btnBg,border:"1px solid ".concat(p.btnBorder),borderRadius:8,boxShadow:p.shadow}}),(0,o.jsx)(l.Zk,{position:"top-right",children:(0,o.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,o.jsxs)("button",{onClick:S,style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:6,fontSize:12,fontWeight:600,background:p.btnBg,color:p.btnText,border:"1px solid ".concat(p.btnBorder),cursor:"pointer",boxShadow:p.shadow},onMouseOver:e=>e.currentTarget.style.background=p.btnHover,onMouseOut:e=>e.currentTarget.style.background=p.btnBg,children:[(0,o.jsx)(d.A,{size:13}),"Auto layout"]}),(0,o.jsx)(m,{onClick:()=>B({padding:.15}),title:"Fit view",children:(0,o.jsx)(c.A,{size:13})}),(0,o.jsx)(m,{onClick:n,disabled:f,title:"Refresh",children:(0,o.jsx)(h.A,{size:13,style:{animation:f?"spin 1s linear infinite":"none"}})})]})}),(0,o.jsx)(l.Zk,{position:"bottom-center",children:(0,o.jsxs)("div",{style:{display:"flex",gap:20,padding:"8px 16px",background:p.legendBg,border:"1px solid ".concat(p.legendBdr),borderRadius:8,boxShadow:p.shadow},children:[(0,o.jsx)(b,{icon:(0,o.jsx)(i.A,{size:12,color:p.pkFkIcon}),label:"Primary key"}),(0,o.jsx)(b,{icon:(0,o.jsx)(a.A,{size:12,color:p.pkFkIcon}),label:"Foreign key"}),(0,o.jsx)(b,{icon:(0,o.jsx)("span",{style:{color:p.diamondFill},children:(0,o.jsx)(u,{filled:!0})}),label:"Non-null"}),(0,o.jsx)(b,{icon:(0,o.jsx)("span",{style:{color:p.diamondNull},children:(0,o.jsx)(u,{filled:!1})}),label:"Nullable"})]})})]})}function k(e){let{db:t,source:n="local"}=e,[s,i]=(0,r.useState)([]),[a,d]=(0,r.useState)(!0),[c,h]=(0,r.useState)(null),u=(0,r.useCallback)(async()=>{d(!0),h(null);try{let e=new URLSearchParams;e.set("source",n),t&&e.set("db",t);let o="?".concat(e.toString()),r=await fetch("/api/schema".concat(o)),l=await r.json();if(!l.success)throw Error(l.error||"Failed to load schema");i(l.tables)}catch(e){h(e.message)}finally{d(!1)}},[t,n]);return((0,r.useEffect)(()=>{u()},[u]),a)?(0,o.jsxs)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas,color:p.type,gap:8},children:[(0,o.jsx)(f.A,{size:18,style:{animation:"spin 1s linear infinite"}}),(0,o.jsx)("span",{style:{fontSize:14},children:"Loading schema…"})]}):c?(0,o.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas},children:(0,o.jsxs)("div",{style:{textAlign:"center",color:p.type},children:[(0,o.jsx)("p",{style:{fontSize:14,marginBottom:8},children:c}),(0,o.jsx)("button",{onClick:u,style:{fontSize:12,color:p.tableName,textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}):s.length?(0,o.jsx)("div",{style:{height:"100%",background:p.canvas},children:(0,o.jsx)(l.Ln,{children:(0,o.jsx)(j,{tables:s,onRefresh:u,isLoading:a})})}):(0,o.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:p.canvas,color:p.type},children:(0,o.jsx)("p",{style:{fontSize:14},children:"No tables found"})})}}}]);