@theobourgeois/ytdb 0.2.16 → 0.2.17
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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +8 -7
- package/.next/build-manifest.json +2 -2
- package/.next/routes-manifest.json +6 -0
- package/.next/server/app/[connectionId]/[schema]/[table]/page.js +1 -1
- package/.next/server/app/[connectionId]/[schema]/[table]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/diff/page.js +2 -2
- package/.next/server/app/[connectionId]/diff/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/page.js +1 -1
- package/.next/server/app/[connectionId]/migrations/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/migrations/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/page.js +1 -1
- package/.next/server/app/[connectionId]/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/query/page.js +1 -1
- package/.next/server/app/[connectionId]/query/page.js.nft.json +1 -1
- package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error/page.js +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/activity/route.js +2 -2
- package/.next/server/app/api/activity/route.js.nft.json +1 -1
- package/.next/server/app/api/adopt/route.js +1 -40
- package/.next/server/app/api/adopt/route.js.nft.json +1 -1
- package/.next/server/app/api/cell/route.js +1 -1
- package/.next/server/app/api/cell/route.js.nft.json +1 -1
- package/.next/server/app/api/definition/route.js +2 -2
- package/.next/server/app/api/definition/route.js.nft.json +1 -1
- package/.next/server/app/api/delete-rows/route.js +2 -2
- package/.next/server/app/api/delete-rows/route.js.nft.json +1 -1
- package/.next/server/app/api/detect/route.js +1 -1
- package/.next/server/app/api/detect/route.js.nft.json +1 -1
- package/.next/server/app/api/health/route.js +1 -1
- package/.next/server/app/api/insert-row/route.js +2 -2
- package/.next/server/app/api/insert-row/route.js.nft.json +1 -1
- package/.next/server/app/api/ledger/route.js +1 -40
- package/.next/server/app/api/ledger/route.js.nft.json +1 -1
- package/.next/server/app/api/lookup/route.js +2 -2
- package/.next/server/app/api/lookup/route.js.nft.json +1 -1
- package/.next/server/app/api/migrate/route.js +1 -40
- package/.next/server/app/api/migrate/route.js.nft.json +1 -1
- package/.next/server/app/api/note/route.js +1 -1
- package/.next/server/app/api/note/route.js.nft.json +1 -1
- package/.next/server/app/api/query/route.js +2 -2
- package/.next/server/app/api/query/route.js.nft.json +1 -1
- package/.next/server/app/api/related/route.js +2 -2
- package/.next/server/app/api/related/route.js.nft.json +1 -1
- package/.next/server/app/api/repo/route.js +1 -1
- package/.next/server/app/api/repo/route.js.nft.json +1 -1
- package/.next/server/app/api/rows/route.js +1 -1
- package/.next/server/app/api/rows/route.js.nft.json +1 -1
- package/.next/server/app/api/schema/route.js +1 -1
- package/.next/server/app/api/schema/route.js.nft.json +1 -1
- package/.next/server/app/api/tables/route.js +2 -2
- package/.next/server/app/api/tables/route.js.nft.json +1 -1
- package/.next/server/app/api/timeline/route.js +1 -0
- package/.next/server/app/api/timeline/route.js.nft.json +1 -0
- package/.next/server/app/api/timeline/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/update-row/route.js +2 -2
- package/.next/server/app/api/update-row/route.js.nft.json +1 -1
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +8 -7
- package/.next/server/chunks/125.js +86 -0
- package/.next/server/chunks/208.js +1 -0
- package/.next/server/chunks/593.js +1 -1
- package/.next/server/chunks/729.js +1 -1
- package/.next/server/chunks/{755.js → 842.js} +1 -1
- package/.next/server/chunks/875.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/Rs4wmCBhbkxl8S4ZIgteG/_buildManifest.js +1 -0
- package/.next/static/chunks/1520-1d9fc8b9ea29f3aa.js +1 -0
- package/.next/static/chunks/1981-f89f2873291b0dfe.js +1 -0
- package/.next/static/chunks/{4730-edc8f5e7a930e67c.js → 2435-240bc4349cace375.js} +1 -1
- package/.next/static/chunks/3960-1b1a9a0ae3f12118.js +1 -0
- package/.next/static/chunks/7709-b2eee040599bab79.js +1 -0
- package/.next/static/chunks/801-1b0c3a4022fc2254.js +1 -0
- package/.next/static/chunks/8098-f4a0693371faa888.js +1 -0
- package/.next/static/chunks/9243-9f0f2534090c6124.js +1 -0
- package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-7bed5765c93ce736.js +1 -0
- package/.next/static/chunks/app/[connectionId]/diff/{page-4fec354f34fb5566.js → page-e3e50546820ed5d5.js} +1 -1
- package/.next/static/chunks/app/[connectionId]/{layout-2920542266b3ced9.js → layout-06d736d4773bd4a8.js} +1 -1
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-696ad0a48678eac9.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/page-b731d6df40cedc5e.js +1 -0
- package/.next/static/chunks/app/[connectionId]/page-8f68a2646e2f3eaa.js +1 -0
- package/.next/static/chunks/app/[connectionId]/query/{page-1dc88ac208e95bfb.js → page-55618bbb32f70fee.js} +1 -1
- package/.next/static/chunks/app/_global-error/page-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/activity/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/adopt/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/cell/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/definition/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/delete-rows/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/detect/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/health/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/insert-row/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/ledger/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/lookup/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/migrate/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/note/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/query/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/related/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/repo/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/rows/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/schema/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/tables/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/timeline/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/api/update-row/route-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/app/{page-46e11b50fbcec559.js → page-957b7639b047ba08.js} +1 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-f8c12c454482851d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f8c12c454482851d.js +1 -0
- package/.next/static/css/5612558bae080ad4.css +1 -0
- package/package.json +1 -1
- package/.next/server/chunks/172.js +0 -1
- package/.next/static/OyIGZSorg5OrE1_BWj2Lr/_buildManifest.js +0 -1
- package/.next/static/chunks/3732-535d9f485cf90098.js +0 -1
- package/.next/static/chunks/478-36d0af53d0639a95.js +0 -1
- package/.next/static/chunks/6090-3a613287bf7c9e90.js +0 -1
- package/.next/static/chunks/7709-0c22d3fda039f7d3.js +0 -1
- package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-e20cadf8c3f008f7.js +0 -1
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-18158f23ccdab4cf.js +0 -1
- package/.next/static/chunks/app/[connectionId]/migrations/page-2ed07ba3810d1ee6.js +0 -1
- package/.next/static/chunks/app/[connectionId]/page-22bcfd48d84d7598.js +0 -1
- package/.next/static/chunks/app/_global-error/page-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/activity/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/adopt/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/cell/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/definition/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/delete-rows/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/detect/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/health/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/insert-row/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/ledger/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/lookup/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/migrate/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/note/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/query/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/related/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/repo/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/rows/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/schema/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/tables/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/app/api/update-row/route-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-ff89809b1108405d.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-ff89809b1108405d.js +0 -1
- package/.next/static/css/87a80461c6ff2903.css +0 -1
- /package/.next/static/{OyIGZSorg5OrE1_BWj2Lr → Rs4wmCBhbkxl8S4ZIgteG}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7123],{7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var r=n(95155),a=n(13267),l=n(40980);function s({trailing:e,className:t,...n}){return(0,r.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,r.jsx)(a.TfF,{className:"size-3.5 shrink-0"}),(0,r.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},12860:(e,t,n)=>{Promise.resolve().then(n.bind(n,37875))},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>a,r:()=>l});let r=new Set;function a(e){return r.add(e),()=>{r.delete(e)}}function l(){for(let e of r)e()}},19065:(e,t,n)=>{"use strict";function r(e,t){if(0===t)return!0;let n=e[t-1];return"_"===n||"-"===n||" "===n||"."===n}function a(e,t,n){return l(e,t,e=>[n(e)])}function l(e,t,n){if(!e.trim())return[];let a=[];for(let l of t){let t=n(l),s=null;for(let n of t){let t=function(e,t){let n=e.trim().toLocaleLowerCase(),a=t.toLocaleLowerCase();if(!n)return 0;if(0===a.length)return null;if(a===n)return 1e4;if(a.startsWith(n))return 5e3-a.length;let l=a.indexOf(n);if(-1!==l)return 2400+1200*!!r(t,l)-l-a.length;let s=0,o=0,i=0;for(let e=0;e<a.length&&s<n.length;e+=1){if(a[e]!==n[s]){i=0;continue}o+=12,(i+=1)>1&&(o+=18*i),r(t,e)&&(o+=40),s+=1}if(s<n.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(n)?o+=2200:c.includes(n)&&(o+=700),o-(a.length-n.length)}(e,n);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&a.push({item:l,score:s})}return a.sort((e,t)=>t.score!==e.score?t.score-e.score:n(e.item)[0]?.localeCompare(n(t.item)[0]??"")??0)}n.d(t,{R6:()=>a,UO:()=>l})},23716:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(95155),a=n(13267),l=n(72264),s=n(40980);function o({schemas:e,selected:t,onChange:n,compact:i=!1}){let c=null===t||t.length===e.length,u=null===t||t.length===e.length?"All schemas":0===t.length?"No schemas":1===t.length?t[0]:`${t.length} of ${e.length} schemas`;return(0,r.jsxs)(l.rI,{children:[i?(0,r.jsxs)(l.ty,{"aria-label":`Schemas: ${u}`,title:u,className:(0,s.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-1 text-[11px] tabular-nums outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-foreground/10 data-open:text-foreground",c?"text-muted-foreground":"text-foreground"),children:[(0,r.jsx)(a.olY,{className:"size-3.5"}),!c&&(0,r.jsx)("span",{children:t.length})]}):(0,r.jsxs)(l.ty,{className:"group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left text-[0.8rem] outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-muted/60",children:[(0,r.jsx)(a.olY,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:u}),(0,r.jsx)(a.RQe,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,r.jsx)(l.SQ,{align:i?"end":"start",sideOffset:6,className:(0,s.cn)("max-h-80 min-w-52",!i&&"w-(--anchor-width)"),children:(0,r.jsxs)(l.I,{children:[(0,r.jsx)(l.hO,{checked:c,onCheckedChange:e=>n(e?null:[]),children:"All schemas"}),(0,r.jsx)(l.mB,{}),e.map(a=>(0,r.jsx)(l.hO,{checked:c||(t?.includes(a)??!1),onCheckedChange:r=>{let l,s;return l=t??e,void n((s=r?[...new Set([...l,a])]:l.filter(e=>e!==a)).length===e.length?null:s)},children:(0,r.jsx)("span",{className:"truncate",children:a})},a))]})})]})}},35942:(e,t,n)=>{"use strict";n.d(t,{F:()=>u});var r=n(95155);n(12115);var a=n(76166),l=n(90839),s=n(84588),o=n(66784),i=n(64084),c=n(40980);function u({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,r.jsx)(l.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,r.jsx)(d,{}),(0,r.jsx)(s.I,{})]})}function d({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(o.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,c.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...n,children:(0,r.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},37875:(e,t,n)=>{"use strict";n.d(t,{ExplorerShell:()=>ea});var r=n(95155),a=n(98500),l=n.n(a),s=n(13267),o=n(89239),i=n(95377),c=n(69586),u=n(74590),d=n(32538),m=n(36331),f=n(73321),h=n(12115),p=n(35942),x=n(7412),g=n(86846),b=n(43262),w=n(95848),v=n(40980),y=n(72264),j=n(72194),k=n(79781);function N({current:e}){let t=(0,c.Z)(e=>e.connections),n=(0,k.$C)();return(0,r.jsxs)(y.rI,{children:[(0,r.jsxs)(y.ty,{className:"flex h-8 w-full items-center justify-between gap-2 rounded-lg px-2 text-left font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 data-open:bg-muted/60",children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(j.F,{connection:e}),(0,r.jsx)("span",{className:"truncate",children:e.name}),e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsx)(s.klM,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsxs)(y.SQ,{align:"start",className:"w-(--anchor-width)",children:[t.map(t=>(0,r.jsxs)(y._2,{onClick:()=>void n(t.id),className:t.id===e.id?"font-medium":void 0,children:[(0,r.jsx)(j.F,{connection:t}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.name}),t.layoutGroup&&t.layoutGroup===e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]},t.id)),(0,r.jsx)(y.mB,{}),(0,r.jsx)(y._2,{render:(0,r.jsx)(l(),{href:"/"}),children:"Manage connections"})]})]})}var C=n(23716);function S(e,t){let n=e.trim(),r=n.lastIndexOf(".");return -1===r?n:"schema"===t?n.slice(0,r):n.slice(r+1)}function T({text:e,query:t}){if(!t)return e;let n=[],a=e.toLocaleLowerCase(),l=t.toLocaleLowerCase(),s=0,o=a.indexOf(l);if(-1===o)return e;for(;-1!==o;)o>s&&n.push(e.slice(s,o)),n.push((0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(o,o+t.length)},o)),s=o+t.length,o=a.indexOf(l,s);return s<e.length&&n.push(e.slice(s)),n}function E({connectionId:e,table:t,search:n,pinned:a,showSchema:o,active:i,reorderable:c,dragging:u,dropEdge:d,onTogglePin:m,onDragStart:f,onDragOver:h,onDrop:p,onDragEnd:x,onMove:g}){return(0,r.jsxs)("li",{onDragOver:h,onDrop:p,className:(0,v.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",i&&"bg-muted text-foreground",!i&&"text-foreground/80",u&&"opacity-45","before"===d&&"before:absolute before:inset-x-1 before:top-0 before:z-10 before:h-0.5 before:-translate-y-1/2 before:rounded-full before:bg-primary","after"===d&&"after:absolute after:inset-x-1 after:bottom-0 after:z-10 after:h-0.5 after:translate-y-1/2 after:rounded-full after:bg-primary"),children:[c&&(0,r.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${t.schema}.${t.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:f,onDragEnd:x,onKeyDown:e=>{("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),g?.("ArrowUp"===e.key?-1:1))},className:"ml-1.5 flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground opacity-50 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 active:cursor-grabbing",children:(0,r.jsx)(s.Mvf,{className:"size-3.5"})}),(0,r.jsxs)(l(),{href:`/${e}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`,className:(0,v.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/60",c?"pl-1":"pl-6"),children:[(0,r.jsx)("span",{className:"truncate",children:(0,r.jsx)(T,{text:t.name,query:S(n,"table")})}),o?(0,r.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:t.schema}):"view"===t.kind&&(0,r.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,r.jsx)("button",{type:"button","aria-label":`${a?"Unpin":"Pin"} ${t.schema}.${t.name}`,"aria-pressed":a,title:a?"Unpin table":"Pin table",onClick:()=>m(t),className:(0,v.cn)("mr-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-row:opacity-100",a&&"text-foreground"),children:a?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})}function $({label:e,count:t,collapsed:n,pinned:a,search:l,onToggle:o}){return(0,r.jsxs)("button",{type:"button","aria-expanded":!n,onClick:o,className:"flex h-7 w-full cursor-pointer items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,r.jsx)(s.nNJ,{className:(0,v.cn)("size-3.5 transition-transform",!n&&"rotate-90")}),a&&(0,r.jsx)(s.M0d,{className:"mr-0.5 size-3"}),(0,r.jsx)("span",{className:"truncate",children:a?e:(0,r.jsx)(T,{text:e,query:S(l,"schema")})}),(0,r.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:t})]})}function L({connectionId:e,tables:t,search:n,collapsedSchemas:a,pinnedTables:l,onToggleSchema:s,onTogglePin:o,onReorderPinned:i}){let c=(0,f.useParams)(),[u,d]=(0,h.useState)(!1),[m,p]=(0,h.useState)(null),[x,g]=(0,h.useState)(null),b=new Map(t.map(e=>[(0,w.i)(e),e])),v=l.flatMap(e=>{let t=b.get(e);return t?[t]:[]});function y(){p(null),g(null)}return 0===t.length?(0,r.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:n.trim()?"No tables match your search":"No tables in these schemas"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[v.length>0&&(0,r.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,r.jsx)($,{label:"Pinned tables",count:v.length,collapsed:u,pinned:!0,search:n,onToggle:()=>d(e=>!e)}),!u&&(0,r.jsx)("ul",{children:v.map(t=>{let a=(0,w.i)(t);return(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:!0,showSchema:!0,active:c.schema===t.schema&&c.table===t.name,reorderable:!0,dragging:m===a,dropEdge:x?.key===a?x.edge:null,onTogglePin:o,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",a),p(a),g(null)},onDragOver:e=>(function(e,t){if(!m||m===t)return;e.preventDefault(),e.dataTransfer.dropEffect="move";let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?"before":"after";g(e=>e?.key===t&&e.edge===r?e:{key:t,edge:r})})(e,a),onDrop:e=>{let t,n;return e.preventDefault(),t=m??e.dataTransfer.getData("text/plain"),n=x?.key===a?x.edge:"before",void(t&&i(t,a,n),y())},onDragEnd:y,onMove:e=>{let t,n;return t=v.findIndex(e=>(0,w.i)(e)===a),void((n=v[t+e])&&i(a,(0,w.i)(n),-1===e?"before":"after"))}},a)})})]}),(function(e){let t=new Map;for(let n of e)t.set(n.schema,[...t.get(n.schema)??[],n]);return[...t.entries()].sort(([e],[t])=>{let n;return((n=new Map([["public",0],["auth",1]])).get(e)??2)-(n.get(t)??2)||e.localeCompare(t)})})(t).map(([t,i])=>{let u=a.includes(t);return(0,r.jsxs)("div",{children:[(0,r.jsx)($,{label:t,count:i.length,collapsed:u,search:n,onToggle:()=>s(t)}),!u&&(0,r.jsx)("ul",{children:i.map(t=>(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:l.includes((0,w.i)(t)),active:c.schema===t.schema&&c.table===t.name,onTogglePin:o},(0,w.i)(t)))})]},t)})]})}function z(e){return Math.min(480,Math.max(180,Math.round(e)))}function D(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e)??2)-(n.get(t)??2)||e.localeCompare(t)}function R(e,t,n){let r=t.trim().toLocaleLowerCase();return e.filter(e=>(null===n||!!n.includes(e.schema))&&(!r||e.name.toLocaleLowerCase().includes(r)||`${e.schema}.${e.name}`.toLocaleLowerCase().includes(r)))}function I({href:e,active:t,shortcut:n,children:a}){return(0,r.jsxs)(l(),{href:e,"aria-current":t?"page":void 0,className:(0,v.cn)((0,o.r)({variant:t?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[a,(0,r.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:n})]})}function A({width:e,onWidthChange:t,onCollapse:n}){let a=(0,f.usePathname)(),{connection:l,tables:i}=(0,m.k)(),[d,v]=(0,u.DE)(l.id),y=(0,c.Z)(e=>e.connections.length>1),[j,k]=(0,h.useState)(()=>z(e)),S=(0,h.useRef)(null),T=(0,h.useMemo)(()=>[...new Set((i.data??[]).map(e=>e.schema))].sort(D),[i.data]),E=(0,h.useMemo)(()=>null===d.selectedSchemas?null:d.selectedSchemas.filter(e=>T.includes(e)),[d.selectedSchemas,T]),$=(0,h.useMemo)(()=>R(i.data??[],d.search,E),[i.data,d.search,E]),M=`/${encodeURIComponent(l.id)}`,U=`${M}/query`,P=`${M}/diff`,F=`${M}/migrations`;function q(e,t){let n=new Set(R(i.data??[],e,t).map(e=>e.schema));return d.collapsedSchemas.filter(e=>!n.has(e))}return(0,r.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:j},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 border-b border-sidebar-border/60 p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsx)(N,{current:l})}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:n,children:(0,r.jsx)(s.cFu,{})})]}),(0,r.jsxs)(I,{href:U,active:a===U,shortcut:b.Ar.sqlEditor,children:[(0,r.jsx)(s.Uoo,{"data-icon":"inline-start"}),"SQL query"]}),(0,r.jsxs)(I,{href:F,active:a===F||a.startsWith(`${F}/`),shortcut:b.Ar.migrations,children:[(0,r.jsx)(s.olY,{"data-icon":"inline-start"}),"Migrations"]}),y&&(0,r.jsxs)(I,{href:P,active:a===P,shortcut:b.Ar.compareSchema,children:[(0,r.jsx)(s.R4X,{"data-icon":"inline-start"}),"Compare schema"]}),(0,r.jsx)(x.L,{value:d.search,onChange:e=>{var t;v({search:t=e.target.value,collapsedSchemas:t.trim()?q(t,E):d.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"mt-1",trailing:(0,r.jsxs)(r.Fragment,{children:[!d.search&&(0,r.jsx)("kbd",{className:"font-mono text-[10px] text-muted-foreground/55",children:b.Ar.tableSearch}),(0,r.jsx)(C.V,{compact:!0,schemas:T,selected:E,onChange:function(e){v({selectedSchemas:e,collapsedSchemas:d.search.trim()?q(d.search,e):d.collapsedSchemas})}})]})})]}),(0,r.jsx)(p.F,{className:"min-h-0 flex-1 pt-1.5",children:i.error?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:i.error}):i.data?(0,r.jsx)(L,{connectionId:l.id,tables:$,search:d.search,collapsedSchemas:d.collapsedSchemas,pinnedTables:d.pinnedTables,onToggleSchema:function(e){v({collapsedSchemas:d.collapsedSchemas.includes(e)?d.collapsedSchemas.filter(t=>t!==e):[...d.collapsedSchemas,e]})},onTogglePin:function(e){let t=(0,w.i)(e);v({pinnedTables:d.pinnedTables.includes(t)?d.pinnedTables.filter(e=>e!==t):[...d.pinnedTables,t]})},onReorderPinned:function(e,t,n){if(e===t)return;let r=d.pinnedTables.filter(t=>t!==e),a=r.indexOf(t);-1!==a&&(r.splice(a+ +("after"===n),0,e),v({pinnedTables:r}))}}):(0,r.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(e,t)=>(0,r.jsx)(g.E,{className:"h-5 w-full"},t))})}),(0,r.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":j,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(e){e.preventDefault(),S.current={pointerId:e.pointerId,startX:e.clientX,startWidth:j},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:function(e){let t=S.current;t&&t.pointerId===e.pointerId&&(e.preventDefault(),k(z(t.startWidth+e.clientX-t.startX)))},onPointerUp:function(e){let n=S.current;if(!n||n.pointerId!==e.pointerId)return;let r=z(n.startWidth+e.clientX-n.startX);S.current=null,k(r),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(r)},onPointerCancel:function(e){let n=S.current;n&&n.pointerId===e.pointerId&&(S.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(j))},onKeyDown:function(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let n=z(j+("ArrowLeft"===e.key?-1:1)*16);k(n),t(n)},onDoubleClick:function(e){e.preventDefault(),k(256),t(256)},className:"group/resize absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors hover:after:bg-primary focus-visible:after:bg-primary"})]})}var M=n(67385),U=n(88406),P=n(86989),F=n(15923),q=n(19065);function O(e,{nested:t=!1}={}){let n=(0,f.useRouter)(),r=(0,f.usePathname)(),{connection:a,tables:l}=(0,m.k)(),[s]=(0,u.DE)(a.id),o=`/${encodeURIComponent(a.id)}`,i=`${o}/${e}`,c=t?r===i||r.startsWith(`${i}/`):r===i;return{open:c,href:i,toggle:()=>n.push(c?function(){for(let e of s.recentTables){let t=(l.data??[]).find(t=>(0,w.i)(t)===e);if(t)return`${o}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`}return o}():i)}}function G(){let e=O("migrations",{nested:!0});return{open:e.open,migrationsHref:e.href,toggle:e.toggle}}var K=n(48861);function Z(){let e=O("diff");return{open:e.open,diffHref:e.href,toggle:e.toggle}}function W(){let e=O("query");return{open:e.open,queryHref:e.href,toggle:e.toggle}}function B({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}async function Q(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}}function _(){let e=(0,f.useRouter)(),t=(0,f.useParams)(),{connection:n,tables:a}=(0,m.k)(),l=W(),o=Z(),i=G(),d=(0,u.y3)(n.id),p=(0,k.yG)(),x=(0,K.Q)(n.id),g=(0,c.Z)(e=>e.add),[y,j]=(0,u.DE)(n.id),[N,C]=(0,h.useState)(!1),[S,T]=(0,h.useState)("commands"),[E,$]=(0,h.useState)(""),[L,z]=(0,h.useState)(0),[D,R]=(0,h.useState)(!1),I=(0,h.useRef)(null),A=(0,h.useRef)(null),O=(0,h.useRef)(null),_=(0,h.useRef)(S),X=(0,U.C)(e=>e.theme),V=t.schema&&t.table?{schema:decodeURIComponent(t.schema),name:decodeURIComponent(t.table)}:null,H=!!V&&y.pinnedTables.includes((0,w.i)(V)),Y=(0,u.lz)(e=>V?e.tables[`${n.id}:${(0,w.i)(V)}`]:void 0),J=(0,h.useMemo)(()=>[{id:"sql-editor",title:l.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:b.Ar.sqlEditor,run:()=>l.toggle()},{id:"go-back",title:x.back?`Back to ${x.back.label}`:"Back",keywords:["back","previous","return","history","undo"],enabled:null!==x.back,shortcut:b.Ar.back,run:()=>x.goBack()},{id:"go-forward",title:x.forward?`Forward to ${x.forward.label}`:"Forward",keywords:["forward","next","history","redo"],enabled:null!==x.forward,shortcut:b.Ar.forward,run:()=>x.goForward()},{id:"switch-connection",title:p.next?`Switch Connection (${p.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:p.enabled,shortcut:b.Ar.switchConnection,run:()=>void p.run()},{id:"migrations",title:i.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:b.Ar.migrations,run:()=>i.toggle()},{id:"compare-schema",title:d.target?`Compare Schema with ${d.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==d.target,shortcut:b.Ar.compareSchema,run:()=>o.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:b.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,b.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==V,shortcut:b.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,b.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>a.reload()},{id:"pin-table",title:H?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==V,run:()=>{if(!V)return;let e=(0,w.i)(V);j({pinnedTables:y.pinnedTables.includes(e)?y.pinnedTables.filter(t=>t!==e):[...y.pinnedTables,e]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==V&&!!Y?.search,run:()=>{V&&u.lz.getState().setTable(n.id,V,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==V,run:()=>{V&&Q((0,w.i)(V))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let e=U.C.getState().theme,t=P.zG.findIndex(t=>t.id===e);T("themes"),$(""),z(-1===t?0:t)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>R(!0)}],[y.pinnedTables,d.target,n.id,x,i,H,o,j,l,p,V,Y?.search,a]),ee=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,J,e=>[e.title,...e.keywords].join(" ")).map(e=>e.item):J,[J,E]),et=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,[...P.zG],e=>[e.name,...e.keywords].join(" ")).map(e=>e.item):[...P.zG],[E]),en="themes"===S?et:ee,er="commands"===S?ee[L]??null:null,ea="themes"===S?et[L]??null:null;function el(e){e?.revertTheme&&"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),C(!1),$(""),z(0),T("commands")}function es(){el({revertTheme:!0})}function eo(){"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),T("commands"),$(""),z(0)}function ei(e){e.enabled&&(e.keepOpen||es(),e.run())}function ec(e){U.C.getState().setTheme(e.id),(0,P.AZ)(e.id),el({revertTheme:!1})}return(0,h.useEffect)(()=>{_.current=S},[S]),(0,h.useEffect)(()=>{if("themes"===S&&!E.trim()){let e=P.zG.findIndex(e=>e.id===U.C.getState().theme);z(-1===e?0:e);return}z(0)},[E,N,S]),(0,h.useEffect)(()=>{let e=O.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[L,en]),(0,h.useEffect)(()=>{if(!N)return;let e=window.requestAnimationFrame(()=>I.current?.focus());return()=>window.cancelAnimationFrame(e)},[N,S]),(0,h.useEffect)(()=>{if(!N||"themes"!==S)return;let e=et[L];e&&(0,P.AZ)(e.id)},[N,S,L,et]),(0,h.useEffect)(()=>(0,F.T)(es),[]),(0,h.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"p"===e.key.toLowerCase()){if(e.preventDefault(),N){"themes"===_.current&&eo(),I.current?.select();return}(0,F.r)(),$(""),z(0),T("commands"),C(!0);return}if(N&&"Escape"===e.key){if(e.preventDefault(),"themes"===_.current)return void eo();es()}}function t(e){!N||A.current?.contains(e.target)||es()}return window.addEventListener("keydown",e,!0),window.addEventListener("pointerdown",t),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("pointerdown",t)}},[N]),(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsxs)("div",{ref:A,"data-command-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,r.jsx)("input",{ref:I,value:E,onChange:e=>$(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e+1)%en.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e-1+en.length)%en.length);return}if("Enter"===e.key){if(e.preventDefault(),"themes"===S){ea&&ec(ea);return}er&&ei(er)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===S?"Select color theme":"Type a command","aria-label":"themes"===S?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:O,role:"listbox","aria-label":"themes"===S?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===en.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===S?"No matching themes":"No matching commands"}):"themes"===S?et.map((e,t)=>{let n=t===L,a=e.id===X;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ec(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:e.swatch}}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.name,query:E.trim()})}),a&&(0,r.jsx)(s.wiW,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},e.id)}):ee.map((e,t)=>{let n=t===L;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"aria-disabled":!e.enabled,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ei(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",n&&"bg-primary/10",!e.enabled&&"cursor-default opacity-40"),children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.title,query:E.trim()})}),e.shortcut&&(0,r.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:e.shortcut})]},e.id)})})]}),(0,r.jsx)(M.f,{open:D,onOpenChange:R,onSubmit:t=>{let{shareWith:n,...r}=t,a=g(r);(0,u.mQ)(a.id,n),e.push(`/${a.id}`)}})]})}function X(){let{toggle:e}=W(),{toggle:t}=Z(),{toggle:n}=G(),{run:r}=(0,k.yG)(),a=(0,K.Q)(),l=(0,c.Z)(e=>e.connections.length>1),s=(0,h.useRef)(e),o=(0,h.useRef)(t),i=(0,h.useRef)(n),u=(0,h.useRef)(r),d=(0,h.useRef)(a),m=(0,h.useRef)(l);return(0,h.useEffect)(()=>{s.current=e},[e]),(0,h.useEffect)(()=>{o.current=t},[t]),(0,h.useEffect)(()=>{i.current=n},[n]),(0,h.useEffect)(()=>{u.current=r},[r]),(0,h.useEffect)(()=>{m.current=l},[l]),(0,h.useEffect)(()=>{d.current=a},[a]),(0,h.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.repeat)return;let t=e.key.toLowerCase();if("["===t||"]"===t){if(e.shiftKey||function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t}(e.target))return;e.preventDefault(),(0,F.r)(),"["===t?d.current.goBack():d.current.goForward();return}if("m"===t&&e.shiftKey){e.preventDefault(),(0,F.r)(),i.current();return}if("d"===t&&e.shiftKey){if(!m.current)return;e.preventDefault(),(0,F.r)(),o.current();return}if("e"===t){if(e.preventDefault(),(0,F.r)(),e.shiftKey)return void u.current();s.current()}}return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),null}var V=n(27529);let H={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function Y({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}function J(e){try{return new URL(e).hostname}catch{return""}}function ee(e){return[e.name,J(e.url)].filter(Boolean)}function et(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e.schema)??2)-(n.get(t.schema)??2)||e.schema.localeCompare(t.schema)||e.name.localeCompare(t.name)}function en(e,t){return e.map((e,n)=>0===n?{...e,section:t}:e)}function er(){let e=(0,f.useRouter)(),t=(0,k.$C)(),n=(0,f.useParams)(),{connection:a,tables:l}=(0,m.k)(),o=(0,c.Z)(e=>e.connections),[i,d]=(0,h.useState)(!1),[p,x]=(0,h.useState)(""),[g,y]=(0,h.useState)(0),[N,C]=(0,h.useState)(null),S=(0,h.useRef)(null),T=(0,h.useRef)(null),E=(0,h.useRef)(null),$=o.find(e=>e.id===N)??null,L=$??a,z=$&&$.id!==a.id?$.url:null,D=function(e){let[t]=(0,h.useState)(()=>new Map),[n,r]=(0,h.useState)({url:"",error:null});if((0,h.useEffect)(()=>{if(!e)return;let n=new AbortController;return V.F.tables(e,n.signal).then(n=>{t.set(e,n),r({url:e,data:n,error:null})}).catch(a=>{if(n.signal.aborted)return;let l=a instanceof Error?a.message:String(a);r(n=>({url:e,data:n.url===e?n.data:t.get(e),error:l}))}),()=>n.abort()},[t,e]),!e)return{data:void 0,error:null,loading:!1};let a=n.url===e?n.data:t.get(e);return{data:a,error:n.url===e?n.error:null,loading:void 0===a}}(z),[R,I]=(0,u.DE)(a.id),[A,M]=(0,u.DE)(L.id),U=L.id===a.id?R:A,P=(0,h.useMemo)(()=>z?D.data??[]:l.data??[],[D.data,z,l.data]),O=z?D.loading:l.loading,G=z?D.error:null,K=(0,h.useMemo)(()=>[...new Set(P.map(e=>e.schema))],[P]),Z=null===U.selectedSchemas?null:U.selectedSchemas.filter(e=>K.includes(e)),W=(0,h.useMemo)(()=>null===Z?P:P.filter(e=>Z.includes(e.schema)),[P,Z]),B=U.pinnedTables,Q=U.recentTables,_=(0,h.useMemo)(()=>{let e,t;return -1===(t=(e=p.trim()).indexOf(":"))?{schema:null,table:e}:{schema:e.slice(0,t).trim(),table:e.slice(t+1).trim()}},[p]),X=_.table||(_.schema?"":p.trim()),er=(0,h.useMemo)(()=>{let e=new Set(B),t=new Set(Q),n=null===_.schema?null:function(e,t){if(!e)return t;let n=e.toLocaleLowerCase(),r=t.filter(e=>e.toLocaleLowerCase()===n);if(r.length>0)return r;let a=t.filter(e=>e.toLocaleLowerCase().startsWith(n));return a.length>0?a:(0,q.R6)(e,t,e=>e).map(e=>e.item)}(_.schema,K),r=null===n?W:P.filter(e=>n.includes(e.schema)),l=new Map(r.map(e=>[(0,w.i)(e),e])),s=B.flatMap(e=>{let t=l.get(e);return t?[t]:[]}),i=Q.flatMap(t=>{let n=l.get(t);return!n||e.has(t)?[]:[n]}),c=(e,t)=>({type:"table",key:`table:${(0,w.i)(e)}`,table:e,...t}),u=e=>({type:"connection",key:`connection:${e.id}`,connection:e,current:e.id===a.id}),d=null===_.schema?p.trim():_.table,m=null===$&&null===_.schema;if(!d){let e=new Set([...s.map(e=>(0,w.i)(e)),...i.map(e=>(0,w.i)(e))]),n=r.filter(t=>!e.has((0,w.i)(t))).sort(et),l=m?o.filter(e=>e.id!==a.id):[];return[...en(s.map(e=>c(e,{pinned:!0})),"pinned"),...en(i.map(e=>c(e,{pinned:!1,recent:!0})),"recent"),...en(n.map(e=>c(e,{pinned:!1,recent:t.has((0,w.i)(e))})),"tables"),...en(l.map(u),"connections")]}let f=(0,q.UO)(d,r,e=>null===_.schema?[e.name,`${e.schema}.${e.name}`,e.schema]:[e.name]).map(n=>({...n,score:n.score+80*!!e.has((0,w.i)(n.item))+40*!!t.has((0,w.i)(n.item))})).sort((e,t)=>t.score-e.score).map(n=>c(n.item,{pinned:e.has((0,w.i)(n.item)),recent:t.has((0,w.i)(n.item))}));return[...en(m?(0,q.UO)(p,o,ee).map(e=>u(e.item)):[],"connections"),...en(f,"tables")]},[P,a.id,o,$,_.schema,_.table,B,p,Q,K,W]),ea=er[g]??null;function el(){d(!1),x(""),y(0),C(null)}function es(){C(null),y(0),S.current?.focus()}function eo(n){var r,a;(el(),"connection"===n.type)?t(n.connection.id):e.push((r=L.id,a=n.table,`/${r}/${encodeURIComponent(a.schema)}/${encodeURIComponent(a.name)}`))}function ei(e){let t=(0,w.i)(e),n=U.pinnedTables.includes(t)?U.pinnedTables.filter(e=>e!==t):[...U.pinnedTables,t];(L.id===a.id?I:M)({pinnedTables:n})}(0,h.useEffect)(()=>{y(0)},[p,i,N]),(0,h.useEffect)(()=>{let e=E.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[g,er]),(0,h.useEffect)(()=>{if(!i)return;let e=window.requestAnimationFrame(()=>S.current?.focus());return()=>window.cancelAnimationFrame(e)},[i]),(0,h.useEffect)(()=>{if(!n.schema||!n.table)return;let e=`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`,t=u.lz.getState().browse[a.id]?.recentTables??[];t[0]!==e&&I({recentTables:[e,...t.filter(t=>t!==e)].slice(0,12)})},[a.id,n.schema,n.table,I]),(0,h.useEffect)(()=>{function e(){i?S.current?.select():((0,F.r)(),x(""),y(0),C(null),d(!0))}function t(t){if((t.metaKey||t.ctrlKey)&&"p"===t.key.toLowerCase()){if(t.shiftKey)return;t.preventDefault(),e();return}i&&"Escape"===t.key&&(t.preventDefault(),el())}function n(e){!i||T.current?.contains(e.target)||el()}window.addEventListener("keydown",t,!0),window.addEventListener("pointerdown",n);let r=(0,b.s5)(e);return()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("pointerdown",n),r()}},[i]),(0,h.useEffect)(()=>(0,F.T)(el),[]);let ec=L.id===a.id&&n.schema&&n.table?`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`:null;return i?(0,r.jsxs)("div",{ref:T,"data-table-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)(s.TfF,{className:"size-4 shrink-0 text-muted-foreground"}),$&&(0,r.jsxs)("button",{type:"button",onClick:es,"aria-label":`Stop searching ${$.name}`,className:"flex h-6 max-w-40 shrink-0 items-center gap-1.5 rounded-md bg-muted px-1.5 text-xs outline-none hover:bg-muted/80",children:[(0,r.jsx)(j.F,{connection:$,className:"size-2"}),(0,r.jsx)("span",{className:"truncate",children:$.name})]}),(0,r.jsx)("input",{ref:S,value:p,onChange:e=>x(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e+1)%er.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e-1+er.length)%er.length);return}if("Tab"===e.key){if(e.preventDefault(),$||e.shiftKey)return;ea?.type==="connection"&&(C(ea.connection.id),x(""),y(0));return}if("Backspace"===e.key&&""===p&&$){e.preventDefault(),es();return}"Enter"===e.key&&(e.preventDefault(),e.shiftKey&&ea?.type==="table"?ei(ea.table):ea&&eo(ea))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:$?`Search tables in ${$.name}`:"Go to table (schema:name)","aria-label":$?`Go to table in ${$.name}`:"Go to table or connection",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:E,role:"listbox","aria-label":$?`Tables in ${$.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:O&&0===P.length&&0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):G&&0===P.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:G}):0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p.trim()?"No matches":"No tables"}):er.map((e,t)=>{let n=t===g;if("connection"===e.type){let a=J(e.connection.url);return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>y(t),onClick:()=>eo(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)(s.bkQ,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(j.F,{connection:e.connection,className:"size-2"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",e.current&&"font-medium"),children:(0,r.jsx)(Y,{text:e.connection.name,query:X})}),(0,r.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:n?(0,r.jsx)("span",{children:"Tab to search"}):(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.current?"current":a||"connection"})})]})]},e.key)}let a=(0,w.i)(e.table)===ec;return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("div",{onMouseEnter:()=>y(t),className:(0,v.cn)("group/table-result flex items-center",n&&"bg-primary/10"),children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onClick:()=>eo(e),className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",children:[e.recent&&!e.pinned?(0,r.jsx)(s.A01,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,r.jsx)(s.ooN,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",a&&"font-medium"),children:(0,r.jsx)(Y,{text:e.table.name,query:X})}),(0,r.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===e.table.kind&&(0,r.jsx)("span",{children:"view"}),(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.table.schema})]})]}),(0,r.jsx)("button",{type:"button","aria-label":`${e.pinned?"Unpin":"Pin"} ${(0,w.i)(e.table)}`,"aria-pressed":e.pinned,title:e.pinned?"Unpin table":"Pin table",onClick:()=>ei(e.table),className:(0,v.cn)("mr-2 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-result:opacity-100",(e.pinned||n)&&"opacity-100",e.pinned&&"text-foreground"),children:e.pinned?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})]},e.key)})}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),ea?.type==="table"&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),ea.pinned?"Unpin":"Pin"]})]})]}):null}function ea({connectionId:e,children:t}){let n=(0,i.p)(),a=(0,c.w)(e),[f,h]=(0,u.DE)(e);if(!n)return null;if(!a)return(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)("p",{children:"Connection not found"}),(0,r.jsx)(l(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,d.Mq)(a);return(0,r.jsxs)(m.Z,{connection:a,children:[(0,r.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,r.jsx)("div",{"aria-hidden":!0,title:a.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[f.sidebarCollapsed?(0,r.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>h({sidebarCollapsed:!1}),children:(0,r.jsx)(s.cFu,{})})]}):(0,r.jsx)(A,{width:f.sidebarWidth,onWidthChange:e=>h({sidebarWidth:e}),onCollapse:()=>h({sidebarCollapsed:!0})},a.id),(0,r.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:t})]})]}),(0,r.jsx)(er,{}),(0,r.jsx)(_,{}),(0,r.jsx)(X,{})]})}},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>u,yG:()=>d});var r=n(73321),a=n(12115),l=n(27529),s=n(15923),o=n(20185),i=n(69586),c=n(36331);function u(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,c.k)(),u=(0,i.Z)(e=>e.connections);return(0,a.useCallback)(async r=>{if(r===n.id)return;let a=u.find(e=>e.id===r);if(!a)return;(0,s.r)();let i=(0,o.ZG)(t),c=!!n.layoutGroup&&n.layoutGroup===a.layoutGroup,d=!0;if("table"===i.kind&&!c)try{var m,f;m=await l.F.tables(a.url),f=i.table,d=m.some(e=>e.schema===f.schema&&e.name===f.name)}catch{d=!1}e.push((0,o.gZ)(t,r,{tableExists:d}))},[n.id,n.layoutGroup,u,t,e])}function d(){let{connection:e}=(0,c.k)(),t=(0,i.Z)(e=>e.connections),n=u(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var r=n(95155),a=n(40980);function l({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...t})}}},e=>{e.O(0,[4506,1731,8026,4730,8361,8322,6090,7709,6782,8441,3794,7358],()=>e(e.s=12860)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7123],{7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>s});var r=n(95155),a=n(13267),l=n(40980);function s({trailing:e,className:t,...n}){return(0,r.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,r.jsx)(a.TfF,{className:"size-3.5 shrink-0"}),(0,r.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},12860:(e,t,n)=>{Promise.resolve().then(n.bind(n,37875))},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>a,r:()=>l});let r=new Set;function a(e){return r.add(e),()=>{r.delete(e)}}function l(){for(let e of r)e()}},19065:(e,t,n)=>{"use strict";function r(e,t){if(0===t)return!0;let n=e[t-1];return"_"===n||"-"===n||" "===n||"."===n}function a(e,t,n){return l(e,t,e=>[n(e)])}function l(e,t,n){if(!e.trim())return[];let a=[];for(let l of t){let t=n(l),s=null;for(let n of t){let t=function(e,t){let n=e.trim().toLocaleLowerCase(),a=t.toLocaleLowerCase();if(!n)return 0;if(0===a.length)return null;if(a===n)return 1e4;if(a.startsWith(n))return 5e3-a.length;let l=a.indexOf(n);if(-1!==l)return 2400+1200*!!r(t,l)-l-a.length;let s=0,o=0,i=0;for(let e=0;e<a.length&&s<n.length;e+=1){if(a[e]!==n[s]){i=0;continue}o+=12,(i+=1)>1&&(o+=18*i),r(t,e)&&(o+=40),s+=1}if(s<n.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(n)?o+=2200:c.includes(n)&&(o+=700),o-(a.length-n.length)}(e,n);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&a.push({item:l,score:s})}return a.sort((e,t)=>t.score!==e.score?t.score-e.score:n(e.item)[0]?.localeCompare(n(t.item)[0]??"")??0)}n.d(t,{R6:()=>a,UO:()=>l})},23716:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});var r=n(95155),a=n(13267),l=n(72264),s=n(40980);function o({schemas:e,selected:t,onChange:n,compact:i=!1}){let c=null===t||t.length===e.length,u=null===t||t.length===e.length?"All schemas":0===t.length?"No schemas":1===t.length?t[0]:`${t.length} of ${e.length} schemas`;return(0,r.jsxs)(l.rI,{children:[i?(0,r.jsxs)(l.ty,{"aria-label":`Schemas: ${u}`,title:u,className:(0,s.cn)("flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-1 text-[11px] tabular-nums outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-foreground/10 data-open:text-foreground",c?"text-muted-foreground":"text-foreground"),children:[(0,r.jsx)(a.olY,{className:"size-3.5"}),!c&&(0,r.jsx)("span",{children:t.length})]}):(0,r.jsxs)(l.ty,{className:"group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left text-[0.8rem] outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60 data-open:bg-muted/60",children:[(0,r.jsx)(a.olY,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:u}),(0,r.jsx)(a.RQe,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-open:rotate-180"})]}),(0,r.jsx)(l.SQ,{align:i?"end":"start",sideOffset:6,className:(0,s.cn)("max-h-80 min-w-52",!i&&"w-(--anchor-width)"),children:(0,r.jsxs)(l.I,{children:[(0,r.jsx)(l.hO,{checked:c,onCheckedChange:e=>n(e?null:[]),children:"All schemas"}),(0,r.jsx)(l.mB,{}),e.map(a=>(0,r.jsx)(l.hO,{checked:c||(t?.includes(a)??!1),onCheckedChange:r=>{let l,s;return l=t??e,void n((s=r?[...new Set([...l,a])]:l.filter(e=>e!==a)).length===e.length?null:s)},children:(0,r.jsx)("span",{className:"truncate",children:a})},a))]})})]})}},35942:(e,t,n)=>{"use strict";n.d(t,{F:()=>u});var r=n(95155);n(12115);var a=n(76166),l=n(90839),s=n(84588),o=n(66784),i=n(64084),c=n(40980);function u({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,r.jsx)(l.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,r.jsx)(d,{}),(0,r.jsx)(s.I,{})]})}function d({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(o.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,c.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...n,children:(0,r.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},37875:(e,t,n)=>{"use strict";n.d(t,{ExplorerShell:()=>ea});var r=n(95155),a=n(98500),l=n.n(a),s=n(13267),o=n(89239),i=n(95377),c=n(69586),u=n(74590),d=n(32538),m=n(36331),f=n(73321),h=n(12115),p=n(35942),x=n(7412),g=n(86846),b=n(43262),w=n(95848),v=n(40980),y=n(72264),j=n(72194),k=n(79781);function N({current:e}){let t=(0,c.Z)(e=>e.connections),n=(0,k.$C)();return(0,r.jsxs)(y.rI,{children:[(0,r.jsxs)(y.ty,{className:"flex h-8 w-full items-center justify-between gap-2 rounded-lg px-2 text-left font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 data-open:bg-muted/60",children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(j.F,{connection:e}),(0,r.jsx)("span",{className:"truncate",children:e.name}),e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsx)(s.klM,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,r.jsxs)(y.SQ,{align:"start",className:"w-(--anchor-width)",children:[t.map(t=>(0,r.jsxs)(y._2,{onClick:()=>void n(t.id),className:t.id===e.id?"font-medium":void 0,children:[(0,r.jsx)(j.F,{connection:t}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.name}),t.layoutGroup&&t.layoutGroup===e.layoutGroup&&(0,r.jsx)(s.WnQ,{className:"size-3.5 shrink-0 text-muted-foreground"})]},t.id)),(0,r.jsx)(y.mB,{}),(0,r.jsx)(y._2,{render:(0,r.jsx)(l(),{href:"/"}),children:"Manage connections"})]})]})}var C=n(23716);function S(e,t){let n=e.trim(),r=n.lastIndexOf(".");return -1===r?n:"schema"===t?n.slice(0,r):n.slice(r+1)}function T({text:e,query:t}){if(!t)return e;let n=[],a=e.toLocaleLowerCase(),l=t.toLocaleLowerCase(),s=0,o=a.indexOf(l);if(-1===o)return e;for(;-1!==o;)o>s&&n.push(e.slice(s,o)),n.push((0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(o,o+t.length)},o)),s=o+t.length,o=a.indexOf(l,s);return s<e.length&&n.push(e.slice(s)),n}function E({connectionId:e,table:t,search:n,pinned:a,showSchema:o,active:i,reorderable:c,dragging:u,dropEdge:d,onTogglePin:m,onDragStart:f,onDragOver:h,onDrop:p,onDragEnd:x,onMove:g}){return(0,r.jsxs)("li",{onDragOver:h,onDrop:p,className:(0,v.cn)("group/table-row relative flex h-7 items-center rounded-md text-[13px] transition-[color,background-color,opacity] hover:bg-muted/60",i&&"bg-muted text-foreground",!i&&"text-foreground/80",u&&"opacity-45","before"===d&&"before:absolute before:inset-x-1 before:top-0 before:z-10 before:h-0.5 before:-translate-y-1/2 before:rounded-full before:bg-primary","after"===d&&"after:absolute after:inset-x-1 after:bottom-0 after:z-10 after:h-0.5 after:translate-y-1/2 after:rounded-full after:bg-primary"),children:[c&&(0,r.jsx)("button",{type:"button",draggable:!0,"aria-label":`Reorder ${t.schema}.${t.name}`,title:"Drag to reorder; use Up and Down arrow keys",onDragStart:f,onDragEnd:x,onKeyDown:e=>{("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),g?.("ArrowUp"===e.key?-1:1))},className:"ml-1.5 flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground opacity-50 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 active:cursor-grabbing",children:(0,r.jsx)(s.Mvf,{className:"size-3.5"})}),(0,r.jsxs)(l(),{href:`/${e}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`,className:(0,v.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/60",c?"pl-1":"pl-6"),children:[(0,r.jsx)("span",{className:"truncate",children:(0,r.jsx)(T,{text:t.name,query:S(n,"table")})}),o?(0,r.jsx)("span",{className:"ml-auto max-w-20 truncate text-[10px] text-muted-foreground",children:t.schema}):"view"===t.kind&&(0,r.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"view"})]}),(0,r.jsx)("button",{type:"button","aria-label":`${a?"Unpin":"Pin"} ${t.schema}.${t.name}`,"aria-pressed":a,title:a?"Unpin table":"Pin table",onClick:()=>m(t),className:(0,v.cn)("mr-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-row:opacity-100",a&&"text-foreground"),children:a?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})}function $({label:e,count:t,collapsed:n,pinned:a,search:l,onToggle:o}){return(0,r.jsxs)("button",{type:"button","aria-expanded":!n,onClick:o,className:"flex h-7 w-full cursor-pointer items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,r.jsx)(s.nNJ,{className:(0,v.cn)("size-3.5 transition-transform",!n&&"rotate-90")}),a&&(0,r.jsx)(s.M0d,{className:"mr-0.5 size-3"}),(0,r.jsx)("span",{className:"truncate",children:a?e:(0,r.jsx)(T,{text:e,query:S(l,"schema")})}),(0,r.jsx)("span",{className:"ml-auto pr-1 tabular-nums opacity-60",children:t})]})}function L({connectionId:e,tables:t,search:n,collapsedSchemas:a,pinnedTables:l,onToggleSchema:s,onTogglePin:o,onReorderPinned:i}){let c=(0,f.useParams)(),[u,d]=(0,h.useState)(!1),[m,p]=(0,h.useState)(null),[x,g]=(0,h.useState)(null),b=new Map(t.map(e=>[(0,w.i)(e),e])),v=l.flatMap(e=>{let t=b.get(e);return t?[t]:[]});function y(){p(null),g(null)}return 0===t.length?(0,r.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:n.trim()?"No tables match your search":"No tables in these schemas"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1 px-2 pb-4",children:[v.length>0&&(0,r.jsxs)("div",{className:"mb-1 border-b border-border/60 pb-1",children:[(0,r.jsx)($,{label:"Pinned tables",count:v.length,collapsed:u,pinned:!0,search:n,onToggle:()=>d(e=>!e)}),!u&&(0,r.jsx)("ul",{children:v.map(t=>{let a=(0,w.i)(t);return(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:!0,showSchema:!0,active:c.schema===t.schema&&c.table===t.name,reorderable:!0,dragging:m===a,dropEdge:x?.key===a?x.edge:null,onTogglePin:o,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",a),p(a),g(null)},onDragOver:e=>(function(e,t){if(!m||m===t)return;e.preventDefault(),e.dataTransfer.dropEffect="move";let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?"before":"after";g(e=>e?.key===t&&e.edge===r?e:{key:t,edge:r})})(e,a),onDrop:e=>{let t,n;return e.preventDefault(),t=m??e.dataTransfer.getData("text/plain"),n=x?.key===a?x.edge:"before",void(t&&i(t,a,n),y())},onDragEnd:y,onMove:e=>{let t,n;return t=v.findIndex(e=>(0,w.i)(e)===a),void((n=v[t+e])&&i(a,(0,w.i)(n),-1===e?"before":"after"))}},a)})})]}),(function(e){let t=new Map;for(let n of e)t.set(n.schema,[...t.get(n.schema)??[],n]);return[...t.entries()].sort(([e],[t])=>{let n;return((n=new Map([["public",0],["auth",1]])).get(e)??2)-(n.get(t)??2)||e.localeCompare(t)})})(t).map(([t,i])=>{let u=a.includes(t);return(0,r.jsxs)("div",{children:[(0,r.jsx)($,{label:t,count:i.length,collapsed:u,search:n,onToggle:()=>s(t)}),!u&&(0,r.jsx)("ul",{children:i.map(t=>(0,r.jsx)(E,{connectionId:e,table:t,search:n,pinned:l.includes((0,w.i)(t)),active:c.schema===t.schema&&c.table===t.name,onTogglePin:o},(0,w.i)(t)))})]},t)})]})}function z(e){return Math.min(480,Math.max(180,Math.round(e)))}function D(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e)??2)-(n.get(t)??2)||e.localeCompare(t)}function R(e,t,n){let r=t.trim().toLocaleLowerCase();return e.filter(e=>(null===n||!!n.includes(e.schema))&&(!r||e.name.toLocaleLowerCase().includes(r)||`${e.schema}.${e.name}`.toLocaleLowerCase().includes(r)))}function I({href:e,active:t,shortcut:n,children:a}){return(0,r.jsxs)(l(),{href:e,"aria-current":t?"page":void 0,className:(0,v.cn)((0,o.r)({variant:t?"secondary":"ghost",size:"sm"}),"h-8 w-full justify-start px-2"),children:[a,(0,r.jsx)("kbd",{className:"ml-auto font-mono text-[10px] text-muted-foreground/55",children:n})]})}function A({width:e,onWidthChange:t,onCollapse:n}){let a=(0,f.usePathname)(),{connection:l,tables:i}=(0,m.k)(),[d,v]=(0,u.DE)(l.id),y=(0,c.Z)(e=>e.connections.length>1),[j,k]=(0,h.useState)(()=>z(e)),S=(0,h.useRef)(null),T=(0,h.useMemo)(()=>[...new Set((i.data??[]).map(e=>e.schema))].sort(D),[i.data]),E=(0,h.useMemo)(()=>null===d.selectedSchemas?null:d.selectedSchemas.filter(e=>T.includes(e)),[d.selectedSchemas,T]),$=(0,h.useMemo)(()=>R(i.data??[],d.search,E),[i.data,d.search,E]),M=`/${encodeURIComponent(l.id)}`,U=`${M}/query`,P=`${M}/diff`,F=`${M}/migrations`;function q(e,t){let n=new Set(R(i.data??[],e,t).map(e=>e.schema));return d.collapsedSchemas.filter(e=>!n.has(e))}return(0,r.jsxs)("aside",{id:"database-explorer-sidebar",style:{width:j},className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 border-b border-sidebar-border/60 p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsx)(N,{current:l})}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Collapse database sidebar",title:"Collapse sidebar",onClick:n,children:(0,r.jsx)(s.cFu,{})})]}),(0,r.jsxs)(I,{href:U,active:a===U,shortcut:b.Ar.sqlEditor,children:[(0,r.jsx)(s.Uoo,{"data-icon":"inline-start"}),"SQL query"]}),(0,r.jsxs)(I,{href:F,active:a===F||a.startsWith(`${F}/`),shortcut:b.Ar.migrations,children:[(0,r.jsx)(s.olY,{"data-icon":"inline-start"}),"Migrations"]}),y&&(0,r.jsxs)(I,{href:P,active:a===P,shortcut:b.Ar.compareSchema,children:[(0,r.jsx)(s.R4X,{"data-icon":"inline-start"}),"Compare schema"]}),(0,r.jsx)(x.L,{value:d.search,onChange:e=>{var t;v({search:t=e.target.value,collapsedSchemas:t.trim()?q(t,E):d.collapsedSchemas})},placeholder:"Search tables","aria-label":"Search tables",className:"mt-1",trailing:(0,r.jsxs)(r.Fragment,{children:[!d.search&&(0,r.jsx)("kbd",{className:"font-mono text-[10px] text-muted-foreground/55",children:b.Ar.tableSearch}),(0,r.jsx)(C.V,{compact:!0,schemas:T,selected:E,onChange:function(e){v({selectedSchemas:e,collapsedSchemas:d.search.trim()?q(d.search,e):d.collapsedSchemas})}})]})})]}),(0,r.jsx)(p.F,{className:"min-h-0 flex-1 pt-1.5",children:i.error?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-destructive",children:i.error}):i.data?(0,r.jsx)(L,{connectionId:l.id,tables:$,search:d.search,collapsedSchemas:d.collapsedSchemas,pinnedTables:d.pinnedTables,onToggleSchema:function(e){v({collapsedSchemas:d.collapsedSchemas.includes(e)?d.collapsedSchemas.filter(t=>t!==e):[...d.collapsedSchemas,e]})},onTogglePin:function(e){let t=(0,w.i)(e);v({pinnedTables:d.pinnedTables.includes(t)?d.pinnedTables.filter(e=>e!==t):[...d.pinnedTables,t]})},onReorderPinned:function(e,t,n){if(e===t)return;let r=d.pinnedTables.filter(t=>t!==e),a=r.indexOf(t);-1!==a&&(r.splice(a+ +("after"===n),0,e),v({pinnedTables:r}))}}):(0,r.jsx)("div",{className:"flex flex-col gap-2 px-3 py-2",children:Array.from({length:8},(e,t)=>(0,r.jsx)(g.E,{className:"h-5 w-full"},t))})}),(0,r.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize database sidebar","aria-valuemin":180,"aria-valuemax":480,"aria-valuenow":j,tabIndex:0,title:"Drag to resize; double-click to reset",onPointerDown:function(e){e.preventDefault(),S.current={pointerId:e.pointerId,startX:e.clientX,startWidth:j},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:function(e){let t=S.current;t&&t.pointerId===e.pointerId&&(e.preventDefault(),k(z(t.startWidth+e.clientX-t.startX)))},onPointerUp:function(e){let n=S.current;if(!n||n.pointerId!==e.pointerId)return;let r=z(n.startWidth+e.clientX-n.startX);S.current=null,k(r),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(r)},onPointerCancel:function(e){let n=S.current;n&&n.pointerId===e.pointerId&&(S.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),t(j))},onKeyDown:function(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();let n=z(j+("ArrowLeft"===e.key?-1:1)*16);k(n),t(n)},onDoubleClick:function(e){e.preventDefault(),k(256),t(256)},className:"group/resize absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors hover:after:bg-primary focus-visible:after:bg-primary"})]})}var M=n(67385),U=n(88406),P=n(86989),F=n(15923),q=n(19065);function O(e,{nested:t=!1}={}){let n=(0,f.useRouter)(),r=(0,f.usePathname)(),{connection:a,tables:l}=(0,m.k)(),[s]=(0,u.DE)(a.id),o=`/${encodeURIComponent(a.id)}`,i=`${o}/${e}`,c=t?r===i||r.startsWith(`${i}/`):r===i;return{open:c,href:i,toggle:()=>n.push(c?function(){for(let e of s.recentTables){let t=(l.data??[]).find(t=>(0,w.i)(t)===e);if(t)return`${o}/${encodeURIComponent(t.schema)}/${encodeURIComponent(t.name)}`}return o}():i)}}function G(){let e=O("migrations",{nested:!0});return{open:e.open,migrationsHref:e.href,toggle:e.toggle}}var K=n(48861);function Z(){let e=O("diff");return{open:e.open,diffHref:e.href,toggle:e.toggle}}function W(){let e=O("query");return{open:e.open,queryHref:e.href,toggle:e.toggle}}function B({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}async function Q(e){try{await navigator.clipboard.writeText(e)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}}function _(){let e=(0,f.useRouter)(),t=(0,f.useParams)(),{connection:n,tables:a}=(0,m.k)(),l=W(),o=Z(),i=G(),d=(0,u.y3)(n.id),p=(0,k.yG)(),x=(0,K.Q)(n.id),g=(0,c.Z)(e=>e.add),[y,j]=(0,u.DE)(n.id),[N,C]=(0,h.useState)(!1),[S,T]=(0,h.useState)("commands"),[E,$]=(0,h.useState)(""),[L,z]=(0,h.useState)(0),[D,R]=(0,h.useState)(!1),I=(0,h.useRef)(null),A=(0,h.useRef)(null),O=(0,h.useRef)(null),_=(0,h.useRef)(S),X=(0,U.C)(e=>e.theme),V=t.schema&&t.table?{schema:decodeURIComponent(t.schema),name:decodeURIComponent(t.table)}:null,H=!!V&&y.pinnedTables.includes((0,w.i)(V)),Y=(0,u.lz)(e=>V?e.tables[`${n.id}:${(0,w.i)(V)}`]:void 0),J=(0,h.useMemo)(()=>[{id:"sql-editor",title:l.open?"Back to Table":"Open SQL Query",keywords:["new","query","sql","console","editor","close","back","table"],enabled:!0,shortcut:b.Ar.sqlEditor,run:()=>l.toggle()},{id:"go-back",title:x.back?`Back to ${x.back.label}`:"Back",keywords:["back","previous","return","history","undo"],enabled:null!==x.back,shortcut:b.Ar.back,run:()=>x.goBack()},{id:"go-forward",title:x.forward?`Forward to ${x.forward.label}`:"Forward",keywords:["forward","next","history","redo"],enabled:null!==x.forward,shortcut:b.Ar.forward,run:()=>x.goForward()},{id:"switch-connection",title:p.next?`Switch Connection (${p.next.name})`:"Switch Connection",keywords:["database","env","environment","next","cycle","other"],enabled:p.enabled,shortcut:b.Ar.switchConnection,run:()=>void p.run()},{id:"migrations",title:i.open?"Back to Table":"Open Migrations",keywords:["migration","migrate","apply","revert","rollback","ledger","schema","run"],enabled:!0,shortcut:b.Ar.migrations,run:()=>i.toggle()},{id:"compare-schema",title:d.target?`Compare Schema with ${d.target.name}`:"Compare Schema",keywords:["diff","difference","migration","drift","prod","dev","schema","compare"],enabled:null!==d.target,shortcut:b.Ar.compareSchema,run:()=>o.toggle()},{id:"search-tables",title:"Search Tables",keywords:["find","jump","open","goto","table"],enabled:!0,shortcut:b.Ar.tableSearch,run:()=>window.requestAnimationFrame(()=>(0,b.tT)())},{id:"search-columns",title:"Search Columns",keywords:["find","jump","goto","column","field"],enabled:null!==V,shortcut:b.Ar.columnSearch,run:()=>window.requestAnimationFrame(()=>(0,b.vI)())},{id:"reload-tables",title:"Reload Tables",keywords:["refresh","reload","tables","sync"],enabled:!0,run:()=>a.reload()},{id:"pin-table",title:H?"Unpin Table":"Pin Table",keywords:["pin","unpin","favorite","star"],enabled:null!==V,run:()=>{if(!V)return;let e=(0,w.i)(V);j({pinnedTables:y.pinnedTables.includes(e)?y.pinnedTables.filter(t=>t!==e):[...y.pinnedTables,e]})}},{id:"clear-filters",title:"Clear Filters",keywords:["filter","reset","remove"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{filters:[],page:0})}},{id:"clear-search",title:"Clear Search",keywords:["find","search","reset"],enabled:null!==V&&!!Y?.search,run:()=>{V&&u.lz.getState().setTable(n.id,V,{search:"",page:0})}},{id:"reset-columns",title:"Reset Columns",keywords:["pin","hide","frozen","layout","show"],enabled:null!==V,run:()=>{V&&u.lz.getState().setTable(n.id,V,{pinnedColumns:void 0,hiddenColumns:[]})}},{id:"copy-table",title:"Copy Schema.Table",keywords:["copy","name","qualified"],enabled:null!==V,run:()=>{V&&Q((0,w.i)(V))}},{id:"color-theme",title:"Color Theme",keywords:["theme","appearance","dark","light","color","set","preferences"],enabled:!0,keepOpen:!0,run:()=>{let e=U.C.getState().theme,t=P.zG.findIndex(t=>t.id===e);T("themes"),$(""),z(-1===t?0:t)}},{id:"add-connection",title:"Add Connection",keywords:["new","database","postgres"],enabled:!0,run:()=>R(!0)}],[y.pinnedTables,d.target,n.id,x,i,H,o,j,l,p,V,Y?.search,a]),ee=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,J,e=>[e.title,...e.keywords].join(" ")).map(e=>e.item):J,[J,E]),et=(0,h.useMemo)(()=>E.trim()?(0,q.R6)(E,[...P.zG],e=>[e.name,...e.keywords].join(" ")).map(e=>e.item):[...P.zG],[E]),en="themes"===S?et:ee,er="commands"===S?ee[L]??null:null,ea="themes"===S?et[L]??null:null;function el(e){e?.revertTheme&&"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),C(!1),$(""),z(0),T("commands")}function es(){el({revertTheme:!0})}function eo(){"themes"===_.current&&(0,P.AZ)(U.C.getState().theme),T("commands"),$(""),z(0)}function ei(e){e.enabled&&(e.keepOpen||es(),e.run())}function ec(e){U.C.getState().setTheme(e.id),(0,P.AZ)(e.id),el({revertTheme:!1})}return(0,h.useEffect)(()=>{_.current=S},[S]),(0,h.useEffect)(()=>{if("themes"===S&&!E.trim()){let e=P.zG.findIndex(e=>e.id===U.C.getState().theme);z(-1===e?0:e);return}z(0)},[E,N,S]),(0,h.useEffect)(()=>{let e=O.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[L,en]),(0,h.useEffect)(()=>{if(!N)return;let e=window.requestAnimationFrame(()=>I.current?.focus());return()=>window.cancelAnimationFrame(e)},[N,S]),(0,h.useEffect)(()=>{if(!N||"themes"!==S)return;let e=et[L];e&&(0,P.AZ)(e.id)},[N,S,L,et]),(0,h.useEffect)(()=>(0,F.T)(es),[]),(0,h.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"p"===e.key.toLowerCase()){if(e.preventDefault(),N){"themes"===_.current&&eo(),I.current?.select();return}(0,F.r)(),$(""),z(0),T("commands"),C(!0);return}if(N&&"Escape"===e.key){if(e.preventDefault(),"themes"===_.current)return void eo();es()}}function t(e){!N||A.current?.contains(e.target)||es()}return window.addEventListener("keydown",e,!0),window.addEventListener("pointerdown",t),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("pointerdown",t)}},[N]),(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsxs)("div",{ref:A,"data-command-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)("span",{className:"font-mono text-sm text-muted-foreground",children:">"}),(0,r.jsx)("input",{ref:I,value:E,onChange:e=>$(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e+1)%en.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===en.length)return;z(e=>(e-1+en.length)%en.length);return}if("Enter"===e.key){if(e.preventDefault(),"themes"===S){ea&&ec(ea);return}er&&ei(er)}},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:"themes"===S?"Select color theme":"Type a command","aria-label":"themes"===S?"Color theme":"Command palette",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:O,role:"listbox","aria-label":"themes"===S?"Color themes":"Commands",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:0===en.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"themes"===S?"No matching themes":"No matching commands"}):"themes"===S?et.map((e,t)=>{let n=t===L,a=e.id===X;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ec(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"size-3.5 shrink-0 rounded-sm border",style:{background:e.swatch}}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.name,query:E.trim()})}),a&&(0,r.jsx)(s.wiW,{className:"ml-auto size-3.5 shrink-0 text-muted-foreground"})]},e.id)}):ee.map((e,t)=>{let n=t===L;return(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"aria-disabled":!e.enabled,"data-active":n||void 0,onMouseEnter:()=>z(t),onClick:()=>ei(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center px-3 text-left text-[13px] outline-none",n&&"bg-primary/10",!e.enabled&&"cursor-default opacity-40"),children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:(0,r.jsx)(B,{text:e.title,query:E.trim()})}),e.shortcut&&(0,r.jsx)("kbd",{className:"ml-auto shrink-0 pl-3 font-mono text-[11px] text-muted-foreground/70",children:e.shortcut})]},e.id)})})]}),(0,r.jsx)(M.f,{open:D,onOpenChange:R,onSubmit:t=>{let{shareWith:n,...r}=t,a=g(r);(0,u.mQ)(a.id,n),e.push(`/${a.id}`)}})]})}function X(){let{toggle:e}=W(),{toggle:t}=Z(),{toggle:n}=G(),{run:r}=(0,k.yG)(),a=(0,K.Q)(),l=(0,c.Z)(e=>e.connections.length>1),s=(0,h.useRef)(e),o=(0,h.useRef)(t),i=(0,h.useRef)(n),u=(0,h.useRef)(r),d=(0,h.useRef)(a),m=(0,h.useRef)(l);return(0,h.useEffect)(()=>{s.current=e},[e]),(0,h.useEffect)(()=>{o.current=t},[t]),(0,h.useEffect)(()=>{i.current=n},[n]),(0,h.useEffect)(()=>{u.current=r},[r]),(0,h.useEffect)(()=>{m.current=l},[l]),(0,h.useEffect)(()=>{d.current=a},[a]),(0,h.useEffect)(()=>{function e(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.repeat)return;let t=e.key.toLowerCase();if("["===t||"]"===t){if(e.shiftKey||function(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t}(e.target))return;e.preventDefault(),(0,F.r)(),"["===t?d.current.goBack():d.current.goForward();return}if("m"===t&&e.shiftKey){e.preventDefault(),(0,F.r)(),i.current();return}if("d"===t&&e.shiftKey){if(!m.current)return;e.preventDefault(),(0,F.r)(),o.current();return}if("e"===t){if(e.preventDefault(),(0,F.r)(),e.shiftKey)return void u.current();s.current()}}return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),null}var V=n(27529);let H={pinned:"Pinned",recent:"Recent",tables:"Tables",connections:"Connections"};function Y({text:e,query:t}){if(!t)return e;let n=e.toLocaleLowerCase(),a=t.toLocaleLowerCase(),l=n.indexOf(a);return -1===l?e:(0,r.jsxs)(r.Fragment,{children:[e.slice(0,l),(0,r.jsx)("mark",{className:"rounded-[3px] bg-yellow-300/90 px-px text-yellow-950 dark:bg-yellow-400/85 dark:text-yellow-950",children:e.slice(l,l+t.length)}),e.slice(l+t.length)]})}function J(e){try{return new URL(e).hostname}catch{return""}}function ee(e){return[e.name,J(e.url)].filter(Boolean)}function et(e,t){let n=new Map([["public",0],["auth",1]]);return(n.get(e.schema)??2)-(n.get(t.schema)??2)||e.schema.localeCompare(t.schema)||e.name.localeCompare(t.name)}function en(e,t){return e.map((e,n)=>0===n?{...e,section:t}:e)}function er(){let e=(0,f.useRouter)(),t=(0,k.$C)(),n=(0,f.useParams)(),{connection:a,tables:l}=(0,m.k)(),o=(0,c.Z)(e=>e.connections),[i,d]=(0,h.useState)(!1),[p,x]=(0,h.useState)(""),[g,y]=(0,h.useState)(0),[N,C]=(0,h.useState)(null),S=(0,h.useRef)(null),T=(0,h.useRef)(null),E=(0,h.useRef)(null),$=o.find(e=>e.id===N)??null,L=$??a,z=$&&$.id!==a.id?$.url:null,D=function(e){let[t]=(0,h.useState)(()=>new Map),[n,r]=(0,h.useState)({url:"",error:null});if((0,h.useEffect)(()=>{if(!e)return;let n=new AbortController;return V.F.tables(e,n.signal).then(n=>{t.set(e,n),r({url:e,data:n,error:null})}).catch(a=>{if(n.signal.aborted)return;let l=a instanceof Error?a.message:String(a);r(n=>({url:e,data:n.url===e?n.data:t.get(e),error:l}))}),()=>n.abort()},[t,e]),!e)return{data:void 0,error:null,loading:!1};let a=n.url===e?n.data:t.get(e);return{data:a,error:n.url===e?n.error:null,loading:void 0===a}}(z),[R,I]=(0,u.DE)(a.id),[A,M]=(0,u.DE)(L.id),U=L.id===a.id?R:A,P=(0,h.useMemo)(()=>z?D.data??[]:l.data??[],[D.data,z,l.data]),O=z?D.loading:l.loading,G=z?D.error:null,K=(0,h.useMemo)(()=>[...new Set(P.map(e=>e.schema))],[P]),Z=null===U.selectedSchemas?null:U.selectedSchemas.filter(e=>K.includes(e)),W=(0,h.useMemo)(()=>null===Z?P:P.filter(e=>Z.includes(e.schema)),[P,Z]),B=U.pinnedTables,Q=U.recentTables,_=(0,h.useMemo)(()=>{let e,t;return -1===(t=(e=p.trim()).indexOf(":"))?{schema:null,table:e}:{schema:e.slice(0,t).trim(),table:e.slice(t+1).trim()}},[p]),X=_.table||(_.schema?"":p.trim()),er=(0,h.useMemo)(()=>{let e=new Set(B),t=new Set(Q),n=null===_.schema?null:function(e,t){if(!e)return t;let n=e.toLocaleLowerCase(),r=t.filter(e=>e.toLocaleLowerCase()===n);if(r.length>0)return r;let a=t.filter(e=>e.toLocaleLowerCase().startsWith(n));return a.length>0?a:(0,q.R6)(e,t,e=>e).map(e=>e.item)}(_.schema,K),r=null===n?W:P.filter(e=>n.includes(e.schema)),l=new Map(r.map(e=>[(0,w.i)(e),e])),s=B.flatMap(e=>{let t=l.get(e);return t?[t]:[]}),i=Q.flatMap(t=>{let n=l.get(t);return!n||e.has(t)?[]:[n]}),c=(e,t)=>({type:"table",key:`table:${(0,w.i)(e)}`,table:e,...t}),u=e=>({type:"connection",key:`connection:${e.id}`,connection:e,current:e.id===a.id}),d=null===_.schema?p.trim():_.table,m=null===$&&null===_.schema;if(!d){let e=new Set([...s.map(e=>(0,w.i)(e)),...i.map(e=>(0,w.i)(e))]),n=r.filter(t=>!e.has((0,w.i)(t))).sort(et),l=m?o.filter(e=>e.id!==a.id):[];return[...en(s.map(e=>c(e,{pinned:!0})),"pinned"),...en(i.map(e=>c(e,{pinned:!1,recent:!0})),"recent"),...en(n.map(e=>c(e,{pinned:!1,recent:t.has((0,w.i)(e))})),"tables"),...en(l.map(u),"connections")]}let f=(0,q.UO)(d,r,e=>null===_.schema?[e.name,`${e.schema}.${e.name}`,e.schema]:[e.name]).map(n=>({...n,score:n.score+80*!!e.has((0,w.i)(n.item))+40*!!t.has((0,w.i)(n.item))})).sort((e,t)=>t.score-e.score).map(n=>c(n.item,{pinned:e.has((0,w.i)(n.item)),recent:t.has((0,w.i)(n.item))}));return[...en(m?(0,q.UO)(p,o,ee).map(e=>u(e.item)):[],"connections"),...en(f,"tables")]},[P,a.id,o,$,_.schema,_.table,B,p,Q,K,W]),ea=er[g]??null;function el(){d(!1),x(""),y(0),C(null)}function es(){C(null),y(0),S.current?.focus()}function eo(n){var r,a;(el(),"connection"===n.type)?t(n.connection.id):e.push((r=L.id,a=n.table,`/${r}/${encodeURIComponent(a.schema)}/${encodeURIComponent(a.name)}`))}function ei(e){let t=(0,w.i)(e),n=U.pinnedTables.includes(t)?U.pinnedTables.filter(e=>e!==t):[...U.pinnedTables,t];(L.id===a.id?I:M)({pinnedTables:n})}(0,h.useEffect)(()=>{y(0)},[p,i,N]),(0,h.useEffect)(()=>{let e=E.current?.querySelector("[data-active=true]");e?.scrollIntoView({block:"nearest"})},[g,er]),(0,h.useEffect)(()=>{if(!i)return;let e=window.requestAnimationFrame(()=>S.current?.focus());return()=>window.cancelAnimationFrame(e)},[i]),(0,h.useEffect)(()=>{if(!n.schema||!n.table)return;let e=`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`,t=u.lz.getState().browse[a.id]?.recentTables??[];t[0]!==e&&I({recentTables:[e,...t.filter(t=>t!==e)].slice(0,12)})},[a.id,n.schema,n.table,I]),(0,h.useEffect)(()=>{function e(){i?S.current?.select():((0,F.r)(),x(""),y(0),C(null),d(!0))}function t(t){if((t.metaKey||t.ctrlKey)&&"p"===t.key.toLowerCase()){if(t.shiftKey)return;t.preventDefault(),e();return}i&&"Escape"===t.key&&(t.preventDefault(),el())}function n(e){!i||T.current?.contains(e.target)||el()}window.addEventListener("keydown",t,!0),window.addEventListener("pointerdown",n);let r=(0,b.s5)(e);return()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("pointerdown",n),r()}},[i]),(0,h.useEffect)(()=>(0,F.T)(el),[]);let ec=L.id===a.id&&n.schema&&n.table?`${decodeURIComponent(n.schema)}.${decodeURIComponent(n.table)}`:null;return i?(0,r.jsxs)("div",{ref:T,"data-table-palette":"",className:"fixed top-3 left-1/2 z-50 flex w-[min(36rem,calc(100%-1.5rem))] -translate-x-1/2 flex-col overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,r.jsx)(s.TfF,{className:"size-4 shrink-0 text-muted-foreground"}),$&&(0,r.jsxs)("button",{type:"button",onClick:es,"aria-label":`Stop searching ${$.name}`,className:"flex h-6 max-w-40 shrink-0 items-center gap-1.5 rounded-md bg-muted px-1.5 text-xs outline-none hover:bg-muted/80",children:[(0,r.jsx)(j.F,{connection:$,className:"size-2"}),(0,r.jsx)("span",{className:"truncate",children:$.name})]}),(0,r.jsx)("input",{ref:S,value:p,onChange:e=>x(e.target.value),onKeyDown:function(e){if("ArrowDown"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e+1)%er.length);return}if("ArrowUp"===e.key){if(e.preventDefault(),0===er.length)return;y(e=>(e-1+er.length)%er.length);return}if("Tab"===e.key){if(e.preventDefault(),$||e.shiftKey)return;ea?.type==="connection"&&(C(ea.connection.id),x(""),y(0));return}if("Backspace"===e.key&&""===p&&$){e.preventDefault(),es();return}"Enter"===e.key&&(e.preventDefault(),e.shiftKey&&ea?.type==="table"?ei(ea.table):ea&&eo(ea))},spellCheck:!1,autoComplete:"off",autoCorrect:"off",placeholder:$?`Search tables in ${$.name}`:"Go to table (schema:name)","aria-label":$?`Go to table in ${$.name}`:"Go to table or connection",className:"h-11 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,r.jsx)("div",{ref:E,role:"listbox","aria-label":$?`Tables in ${$.name}`:"Tables and connections",className:"max-h-[min(24rem,50vh)] overflow-auto py-1",children:O&&0===P.length&&0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tables…"}):G&&0===P.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:G}):0===er.length?(0,r.jsx)("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p.trim()?"No matches":"No tables"}):er.map((e,t)=>{let n=t===g;if("connection"===e.type){let a=J(e.connection.url);return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onMouseEnter:()=>y(t),onClick:()=>eo(e),className:(0,v.cn)("flex h-8 w-full cursor-pointer items-center gap-2 px-3 text-left text-[13px] outline-none",n&&"bg-primary/10"),children:[(0,r.jsx)(s.bkQ,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(j.F,{connection:e.connection,className:"size-2"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",e.current&&"font-medium"),children:(0,r.jsx)(Y,{text:e.connection.name,query:X})}),(0,r.jsx)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:n?(0,r.jsx)("span",{children:"Tab to search"}):(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.current?"current":a||"connection"})})]})]},e.key)}let a=(0,w.i)(e.table)===ec;return(0,r.jsxs)("div",{children:[e.section&&(0,r.jsx)("p",{className:"px-3 pt-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:H[e.section]}),(0,r.jsxs)("div",{onMouseEnter:()=>y(t),className:(0,v.cn)("group/table-result flex items-center",n&&"bg-primary/10"),children:[(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n||void 0,onClick:()=>eo(e),className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 pl-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",children:[e.recent&&!e.pinned?(0,r.jsx)(s.A01,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,r.jsx)(s.ooN,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:(0,v.cn)("min-w-0 truncate",a&&"font-medium"),children:(0,r.jsx)(Y,{text:e.table.name,query:X})}),(0,r.jsxs)("span",{className:"ml-auto flex min-w-0 shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:["view"===e.table.kind&&(0,r.jsx)("span",{children:"view"}),(0,r.jsx)("span",{className:"max-w-36 truncate",children:e.table.schema})]})]}),(0,r.jsx)("button",{type:"button","aria-label":`${e.pinned?"Unpin":"Pin"} ${(0,w.i)(e.table)}`,"aria-pressed":e.pinned,title:e.pinned?"Unpin table":"Pin table",onClick:()=>ei(e.table),className:(0,v.cn)("mr-2 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none transition-[color,background-color,opacity] hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover/table-result:opacity-100",(e.pinned||n)&&"opacity-100",e.pinned&&"text-foreground"),children:e.pinned?(0,r.jsx)(s.M0d,{className:"size-3.5"}):(0,r.jsx)(s.rq5,{className:"size-3.5"})})]})]},e.key)})}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↑↓"}),"Navigate"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"↵"}),"Open"]}),ea?.type==="table"&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"font-mono text-foreground/70",children:"⇧↵"}),ea.pinned?"Unpin":"Pin"]})]})]}):null}function ea({connectionId:e,children:t}){let n=(0,i.p)(),a=(0,c.w)(e),[f,h]=(0,u.DE)(e);if(!n)return null;if(!a)return(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)("p",{children:"Connection not found"}),(0,r.jsx)(l(),{href:"/",className:"text-foreground underline underline-offset-4",children:"Connections"})]});let p=(0,d.Mq)(a);return(0,r.jsxs)(m.Z,{connection:a,children:[(0,r.jsxs)("div",{className:"flex h-dvh flex-col overflow-hidden",children:[(0,r.jsx)("div",{"aria-hidden":!0,title:a.name,className:"h-1.5 w-full shrink-0",style:{background:p}}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[f.sidebarCollapsed?(0,r.jsxs)("aside",{className:"relative flex h-full w-10 shrink-0 justify-center border-r bg-sidebar pt-2",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1",style:{background:p}}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon-sm","aria-label":"Show database sidebar",title:"Show sidebar",onClick:()=>h({sidebarCollapsed:!1}),children:(0,r.jsx)(s.cFu,{})})]}):(0,r.jsx)(A,{width:f.sidebarWidth,onWidthChange:e=>h({sidebarWidth:e}),onCollapse:()=>h({sidebarCollapsed:!0})},a.id),(0,r.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:t})]})]}),(0,r.jsx)(er,{}),(0,r.jsx)(_,{}),(0,r.jsx)(X,{})]})}},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>u,yG:()=>d});var r=n(73321),a=n(12115),l=n(27529),s=n(15923),o=n(20185),i=n(69586),c=n(36331);function u(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,c.k)(),u=(0,i.Z)(e=>e.connections);return(0,a.useCallback)(async r=>{if(r===n.id)return;let a=u.find(e=>e.id===r);if(!a)return;(0,s.r)();let i=(0,o.ZG)(t),c=!!n.layoutGroup&&n.layoutGroup===a.layoutGroup,d=!0;if("table"===i.kind&&!c)try{var m,f;m=await l.F.tables(a.url),f=i.table,d=m.some(e=>e.schema===f.schema&&e.name===f.name)}catch{d=!1}e.push((0,o.gZ)(t,r,{tableExists:d}))},[n.id,n.layoutGroup,u,t,e])}function d(){let{connection:e}=(0,c.k)(),t=(0,i.Z)(e=>e.connections),n=u(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var r=n(95155),a=n(40980);function l({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...t})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,1981,9243,7709,6782,8441,3794,7358],()=>e(e.s=12860)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5838],{15923:(e,n,t)=>{"use strict";t.d(n,{T:()=>r,r:()=>i});let s=new Set;function r(e){return s.add(e),()=>{s.delete(e)}}function i(){for(let e of s)e()}},34263:(e,n,t)=>{"use strict";t.d(n,{En:()=>c,Pc:()=>d,jl:()=>o});var s=t(1934),r=t(31692),i=t(40980),a=t(63307);let l="ytdb:queries";(0,a.q)("db-studio:queries",l);let o=144,d=800,c=(0,s.v)()((0,r.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(n,t)=>e(e=>({drafts:{...e.drafts,[n]:t}})),setEditorHeight:n=>e({editorHeight:Math.min(d,Math.max(o,Math.round(n)))}),record:(n,t)=>e(e=>{let s=t.trim();if(!s)return e;let r=e.history.find(e=>e.connectionId===n&&e.sql===s),a={id:r?.id??(0,i.z)(),connectionId:n,sql:s,executedAt:Date.now()},l=0,o=0;return{history:[a,...e.history.filter(e=>e.id!==a.id)].filter(e=>!(l>=200)&&!(o+e.sql.length>1e6)&&(l+=1,o+=e.sql.length,!0))}}),remove:n=>e(e=>({history:e.history.filter(e=>e.id!==n)}))}),{name:l}))},52310:(e,n,t)=>{Promise.resolve().then(t.bind(t,92666))},79781:(e,n,t)=>{"use strict";t.d(n,{$C:()=>c,yG:()=>u});var s=t(73321),r=t(12115),i=t(27529),a=t(15923),l=t(20185),o=t(69586),d=t(36331);function c(){let e=(0,s.useRouter)(),n=(0,s.usePathname)(),{connection:t}=(0,d.k)(),c=(0,o.Z)(e=>e.connections);return(0,r.useCallback)(async s=>{if(s===t.id)return;let r=c.find(e=>e.id===s);if(!r)return;(0,a.r)();let o=(0,l.ZG)(n),d=!!t.layoutGroup&&t.layoutGroup===r.layoutGroup,u=!0;if("table"===o.kind&&!d)try{var m,x;m=await i.F.tables(r.url),x=o.table,u=m.some(e=>e.schema===x.schema&&e.name===x.name)}catch{u=!1}e.push((0,l.gZ)(n,s,{tableExists:u}))},[t.id,t.layoutGroup,c,n,e])}function u(){let{connection:e}=(0,d.k)(),n=(0,o.Z)(e=>e.connections),t=c(),s=function(e,n){let t=e.findIndex(e=>e.id===n);if(!(e.length<2)&&-1!==t)return e[(t+1)%e.length]}(n,e.id);return{run:()=>s?t(s.id):Promise.resolve(),enabled:void 0!==s,next:s}}},92666:(e,n,t)=>{"use strict";t.d(n,{MigrationDetail:()=>W});var s=t(95155),r=t(98500),i=t.n(r),a=t(73321),l=t(12115),o=t(13267),d=t(36331),c=t(79781),u=t(17491),m=t(89239),x=t(72264),p=t(35942),h=t(87364),g=t(27529),f=t(62417),j=t(56012),v=t(74590),b=t(9385),y=t(79668),N=t(34263),k=t(40980),S=t(72194),w=t(40891),C=t(30374),$=t(25),R=t(28335);let z="w-24",A="w-[104px]";function F({checked:e,label:n,onToggle:t}){return(0,s.jsx)("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":n,title:n,onMouseDown:e=>e.shiftKey&&e.preventDefault(),onClick:e=>t(e.shiftKey),className:(0,k.cn)("flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[5px] border outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/60",e?"border-foreground bg-foreground text-background":"border-input hover:border-foreground/50"),children:"mixed"===e?(0,s.jsx)(o.uPM,{className:"size-3"}):e?(0,s.jsx)(o.wiW,{className:"size-3"}):null})}let M={applied:"applied",drifted:"applied, but the file changed since",pending:"not applied",unknown:"not read yet"};function q({status:e}){return"applied"===e?(0,s.jsx)(o.wiW,{className:"size-4 text-emerald-600 dark:text-emerald-400"}):"drifted"===e?(0,s.jsx)(o.e5t,{className:"size-3.5 text-amber-600 dark:text-amber-400"}):"unknown"===e?(0,s.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):(0,s.jsx)(o.uPM,{className:"size-3.5 text-muted-foreground/40"})}function O({step:e,environments:n,targetId:t,status:r,isNewestApplied:i,expanded:a,busy:d,editable:c=!0,drift:u,selected:p,onSelect:h,onToggle:g,actions:f}){let[j,v]=(0,l.useState)(null),b="changes"!==j||u?j??(u?"changes":"apply"):"apply",y="revert"===b?"revert":"apply",[N,S]=(0,l.useState)(!1),D="revert"===y?e.revertSql??"":e.applySql,_=(0,$.qb)(e.transaction),E=(0,$.TA)(e.transaction),I=[];async function T(){await (0,w.mw)(D),S(!0),window.setTimeout(()=>S(!1),1500)}return"drifted"===r&&"changes"!==b&&I.push("This file changed after it was applied here, so it is no longer the migration that ran."),E&&I.push(E),(0,s.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,s.jsxs)("div",{className:(0,k.cn)("flex h-10 items-center transition-colors hover:bg-muted/40",p&&"bg-muted/30",d&&"opacity-60"),children:[(0,s.jsx)("span",{className:"flex h-10 shrink-0 items-center pl-3",children:(0,s.jsx)(F,{checked:p,label:p?`Deselect ${e.version}`:`Select ${e.version}`,onToggle:h})}),(0,s.jsxs)("button",{type:"button","aria-expanded":a,"aria-label":a?`Hide SQL for ${e.version}`:`Show SQL for ${e.version}`,onClick:g,className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,s.jsx)(o.nNJ,{className:(0,k.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",a&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.version}),(0,s.jsx)("span",{className:"min-w-0 truncate text-sm",children:e.name}),_&&(0,s.jsx)("span",{className:"shrink-0 rounded border border-amber-600/25 bg-amber-500/10 px-1.5 text-[10px] text-amber-700 dark:text-amber-400",children:_})]}),n.map(n=>{let r=n.connection.id===t;return(0,s.jsx)("span",{title:n.error?`${n.connection.name}: ${n.error}`:`${e.version} is ${M[n.status]} on ${n.connection.name}${n.entry?` — ${function(e){if(!e)return"";let n=new Date(e.appliedAt);return Number.isNaN(n.getTime())?e.appliedAt:n.toLocaleString()}(n.entry)}`:""}`,className:(0,k.cn)("flex h-10 shrink-0 items-center justify-center",z,r&&"bg-foreground/[0.04]"),children:(0,s.jsx)(q,{status:n.status})},n.connection.id)}),(0,s.jsxs)("div",{className:(0,k.cn)("flex shrink-0 items-center justify-end gap-1 pr-2 pl-1",A),children:["pending"===r&&(0,s.jsx)(m.$,{size:"xs",variant:"outline",disabled:d,onClick:f.onApplyThrough,children:"Apply"}),i&&e.revertSql&&(0,s.jsxs)(m.$,{size:"xs",variant:"ghost",disabled:d,onClick:f.onRevertThrough,children:[(0,s.jsx)(o.ij9,{"data-icon":"inline-start"}),"Revert"]}),(0,s.jsxs)(x.rI,{children:[(0,s.jsx)(x.ty,{render:(0,s.jsx)(m.$,{size:"icon-xs",variant:"ghost","aria-label":`Actions for ${e.version}`}),className:"cursor-pointer",children:(0,s.jsx)(o.YKd,{})}),(0,s.jsxs)(x.SQ,{align:"end",className:"min-w-56",children:[(0,s.jsx)(x._2,{disabled:d||"applied"===r,onClick:f.onApplyThrough,children:"Apply everything through here"}),(0,s.jsx)(x._2,{disabled:d||"applied"===r,onClick:f.onApplyOne,children:"Apply only this one"}),(0,s.jsx)(x._2,{disabled:d||"pending"===r||!e.revertSql,onClick:f.onRevertThrough,children:"Revert back through here"}),(0,s.jsx)(x.mB,{}),(0,s.jsxs)(x._2,{disabled:d||"applied"===r,onClick:f.onMarkApplied,children:[(0,s.jsx)(o.nXx,{}),"Mark as already applied"]}),(0,s.jsxs)(x._2,{disabled:d||"pending"===r,onClick:f.onMarkPending,children:[(0,s.jsx)(o.fJ4,{}),"Mark as not applied"]}),(0,s.jsx)(x.mB,{}),c&&(0,s.jsxs)(x._2,{onClick:f.onAttachRevert,children:[(0,s.jsx)(o.W4E,{}),e.revertSql?"Replace revert file…":"Add a revert file…"]}),(0,s.jsxs)(x._2,{onClick:()=>f.onOpenInEditor(D),children:[(0,s.jsx)(o.Uoo,{}),"Open ",y," SQL in editor"]}),(0,s.jsxs)(x._2,{onClick:()=>void T(),children:[(0,s.jsx)(o.hX7,{}),"Copy ",y," SQL"]}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.mB,{}),(0,s.jsx)(x._2,{variant:"destructive",onClick:f.onRemove,children:"Remove from this set"})]})]})]})]})]}),a&&(0,s.jsxs)("div",{className:"border-t bg-muted/25",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,s.jsx)(C.x,{label:`SQL for ${e.version}`,value:b,onChange:v,options:[...u?[{value:"changes",label:"Changes"}]:[],{value:"apply",label:"Apply"},{value:"revert",label:"Revert"}]}),"changes"===b&&u?(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-3 font-mono text-[11px]",children:[(0,s.jsxs)("span",{className:"shrink-0 text-red-600 dark:text-red-400",children:["− ran on ",u.connectionName]}),(0,s.jsxs)("span",{className:"truncate text-emerald-600 dark:text-emerald-400",children:["+ ",e.applyPath]})]}):(0,s.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:"revert"===b?e.revertPath??"no revert file":e.applyPath}),"changes"!==b&&(0,s.jsxs)(m.$,{size:"xs",variant:"ghost",className:"ml-auto",onClick:()=>void T(),children:[N?(0,s.jsx)(o.wiW,{"data-icon":"inline-start"}):(0,s.jsx)(o.hX7,{"data-icon":"inline-start"}),N?"Copied":"Copy"]})]}),I.length>0&&(0,s.jsx)("ul",{className:"space-y-1 px-3 pb-2",children:I.map(e=>(0,s.jsxs)("li",{className:"flex gap-1.5 text-[11px] text-amber-700 dark:text-amber-400",children:[(0,s.jsx)(o.e5t,{className:"mt-px size-3 shrink-0"}),(0,s.jsx)("span",{children:e})]},e))}),"changes"===b&&u?u.error?(0,s.jsx)("p",{className:"px-3 pb-3 font-mono text-xs text-destructive",children:u.error}):void 0===u.appliedSql?(0,s.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:["Reading what ran on ",u.connectionName,"…"]}):null===u.appliedSql?(0,s.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:[u.connectionName," did not keep the SQL it ran, so there is nothing to compare against."]}):(0,s.jsx)(R.u,{before:u.appliedSql,after:e.applySql,className:"max-h-96 pb-2"}):D?(0,s.jsx)(w.os,{sql:D,className:"max-h-72 overflow-auto px-3 pb-3"}):(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-3 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"No revert file, so this one cannot be undone from here."}),c&&(0,s.jsxs)(m.$,{size:"xs",variant:"outline",onClick:f.onAttachRevert,children:[(0,s.jsx)(o.W4E,{"data-icon":"inline-start"}),"Add one"]})]})]})]})}function D({environments:e,targetId:n,onSelect:t}){let r=e.find(e=>e.connection.id===n);return r?(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Running against"}),(0,s.jsxs)(x.rI,{children:[(0,s.jsxs)(x.ty,{disabled:e.length<2,className:"flex h-7 cursor-pointer items-center gap-1.5 rounded-lg border bg-background px-2 text-xs font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-default data-open:bg-muted/60",children:[(0,s.jsx)(S.F,{connection:r.connection}),(0,s.jsx)("span",{className:"max-w-32 truncate",children:r.connection.name})]}),(0,s.jsx)(x.SQ,{align:"start",className:"min-w-52",children:e.map(e=>(0,s.jsxs)(x._2,{onClick:()=>t(e.connection.id),className:e.connection.id===n?"font-medium":void 0,children:[(0,s.jsx)(S.F,{connection:e.connection}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.connection.name}),(0,s.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.summary.applied,"/",e.summary.total]})]},e.connection.id))})]})]}):null}function _({environments:e,targetId:n,caption:t,loading:r,selection:i,onSelect:a,onCompare:l}){return(0,s.jsxs)("div",{className:"flex h-11 shrink-0 items-center border-b bg-muted/20",children:[(0,s.jsx)("span",{className:"flex h-11 shrink-0 items-center pl-3",children:(0,s.jsx)(F,{checked:i.checked,label:i.checked?"Clear selection":"Select all",onToggle:()=>i.onToggle()})}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate px-2 text-xs text-muted-foreground",children:t}),e.map(e=>{let{connection:t,summary:i,ledger:l,error:o}=e,d=t.id===n;return(0,s.jsxs)("button",{type:"button",disabled:d,"aria-current":d?"true":void 0,title:d?`${t.name} is what Apply and Revert run against`:`Run against ${t.name} instead`,onClick:()=>a(t.id),className:(0,k.cn)("flex h-11 shrink-0 flex-col items-center justify-center gap-0.5 border-l text-[11px] outline-none",z,d?"cursor-default bg-foreground/[0.04] font-medium":"cursor-pointer text-muted-foreground hover:bg-muted/60 hover:text-foreground",r&&"opacity-60"),children:[(0,s.jsxs)("span",{className:"flex max-w-full items-center gap-1",children:[(0,s.jsx)(S.F,{connection:t,className:"size-1.5"}),(0,s.jsx)("span",{className:"truncate",children:t.name})]}),o?(0,s.jsx)("span",{className:"text-destructive",children:"unreachable"}):l?(0,s.jsxs)("span",{className:"tabular-nums text-muted-foreground/80",children:[i.applied,"/",i.total,i.drifted>0&&(0,s.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:" !"})]}):(0,s.jsx)("span",{className:"text-muted-foreground/70",children:"reading…"})]},t.id)}),(0,s.jsx)("div",{className:(0,k.cn)("flex shrink-0 items-center justify-end border-l pr-2 pl-1",A),children:e.length>1&&(0,s.jsx)(m.$,{size:"icon-xs",variant:"ghost",title:"Compare the two schemas","aria-label":"Compare schemas",onClick:()=>{let t=e.find(e=>e.connection.id!==n);t&&l(t.connection.id)},children:(0,s.jsx)(o.R4X,{})})})]})}var E=t(42763),I=t(60529),T=t(33807);function L({schema:e,found:n,onOpenChange:t,onSave:r}){let[i,a]=(0,l.useState)(e),o=i.trim(),d=(0,j.hD)(o),c=n.filter(e=>e.schema!==o);function u(){d&&(r(o),t(!1))}return(0,s.jsx)(E.lG,{open:!0,onOpenChange:t,children:(0,s.jsxs)(E.Cf,{className:"sm:max-w-md",children:[(0,s.jsxs)(E.c7,{children:[(0,s.jsx)(E.L3,{children:"Ledger schema"}),(0,s.jsx)(E.rr,{children:"Where each database keeps its record of what has run. Created on the first apply."})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(T.J,{htmlFor:"ledger-schema",children:"Schema"}),(0,s.jsx)(I.p,{id:"ledger-schema",value:i,spellCheck:!1,autoComplete:"off","aria-invalid":o.length>0&&!d,onChange:e=>a(e.target.value),onKeyDown:e=>"Enter"===e.key&&u()}),(0,s.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:d?`${o}.${j.R9}`:"\xa0"}),o.length>0&&!d&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:"Letters, digits and underscores only, starting with a letter or underscore."})]}),c.length>0&&(0,s.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[c.map(e=>`${e.name} keeps its ledger in ${e.schema}`).join("; "),". That one stays where it is."]}),(0,s.jsxs)(E.Es,{children:[o!==j.aC&&(0,s.jsx)(m.$,{variant:"ghost",onClick:()=>a(j.aC),children:"Reset"}),(0,s.jsx)(m.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(m.$,{disabled:!d,onClick:u,children:"Save"})]})]})})}var P=t(96911),B=t(41069),G=t(77649),V=t(27013),Y=t(18349);function Q({initial:e,file:n,onOpenChange:t,onSave:r}){let[i,a]=(0,l.useState)(e),[o,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),x=i.trim()!==e.trim();async function p(e){if(e?.preventDefault(),x&&!o){d(!0),u(null);try{await r(i.trim()),t(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{d(!1)}}}return(0,s.jsx)(E.lG,{open:!0,onOpenChange:e=>!o&&t(e),children:(0,s.jsx)(E.Cf,{className:"sm:max-w-lg",showCloseButton:!1,children:(0,s.jsxs)("form",{onSubmit:e=>void p(e),className:"flex flex-col gap-4",children:[(0,s.jsx)(E.c7,{children:(0,s.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,s.jsx)(E.L3,{children:"Note"}),n&&(0,s.jsx)("span",{className:"ml-auto truncate font-mono text-[11px] text-muted-foreground",title:"Written into the migration's folder, to commit with the SQL",children:n})]})}),(0,s.jsx)(Y.T,{autoFocus:!0,"aria-label":"Note",value:i,maxLength:j.XG,placeholder:"Apply 0001–0007, deploy the app, then apply 0008.",className:"max-h-[50vh] min-h-32",onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&p()}}),c&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:c}),(0,s.jsxs)(E.Es,{children:[(0,s.jsx)(m.$,{type:"button",variant:"ghost",disabled:o,onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(m.$,{type:"submit",disabled:!x||o,children:o?"Saving…":"Save"})]})]})})})}var K=t(83504),U=t(71612);function W({setId:e}){let n=(0,a.useRouter)(),{connection:t,tables:r}=(0,d.k)(),u=(0,y.jV)(e=>e.addFiles),S=(0,y.jV)(e=>e.renameSet),w=(0,y.jV)(e=>e.setNote),C=(0,y.jV)(e=>e.removeSet),$=(0,y.jV)(e=>e.removeStep),R=(0,y.jV)(e=>e.record),z=(0,y.jV)(e=>e.ledgerSchema),A=(0,y.jV)(e=>e.setLedgerSchema),F=(0,y.Ss)(e),{root:M,checkout:q}=(0,y.ox)(t.id),E=(0,U.y)((0,j.km)(e)?M:null,q),I=(0,j.km)(e)?E.data?.sets.find(n=>n.id===e)??null:F,T=!!I?.source,Y=(0,v.gz)(t.id),ee=(0,N.En)(e=>e.setDraft),en=(0,c.$C)(),[et,es]=(0,l.useState)("migrations"),[er,ei]=(0,l.useState)([]),[ea,el]=(0,l.useState)([]),eo=(0,l.useRef)(null),[ed,ec]=(0,l.useState)(null),[eu,em]=(0,l.useState)(null),[ex,ep]=(0,l.useState)(!1),[eh,eg]=(0,l.useState)(!1),[ef,ej]=(0,l.useState)(null),[ev,eb]=(0,l.useState)(null),[ey,eN]=(0,l.useState)(!1),[ek,eS]=(0,l.useState)(!1),[ew,eC]=(0,l.useState)(!1),e$=(0,l.useRef)(null),eR=(0,l.useRef)(!1),ez=(0,l.useMemo)(()=>[t,...Y],[t,Y]),eA=ez.map(e=>e.url).join("|"),eF=(0,h.Y)(`ledgers:${z}:${eA}`,async e=>Object.fromEntries(await Promise.all(ez.map(async n=>{try{return[n.id,{ledger:await g.F.ledger(n.url,z,e),error:null}]}catch(t){if(e.aborted)throw t;return[n.id,{ledger:null,error:t instanceof Error?t.message:String(t)}]}})))),eM=eF.data?.[t.id]??null,eq=I?.name??"",eO=(0,l.useMemo)(()=>(0,f.Gf)(eM?.ledger,eq),[eM?.ledger,eq]),eD=(0,l.useMemo)(()=>ez.map(e=>{let n=eF.data?.[e.id]??null,t=(0,f.Gf)(n?.ledger,eq);return{connection:e,ledger:t,error:n?.error??null,summary:(0,f.eh)(I,t)}}),[ez,eF.data,I,eq]),e_=(0,l.useMemo)(()=>{let e=new Set;for(let n of I?.steps??[])if(er.includes(n.version))for(let t of eD)"drifted"===(0,f.FY)(n,t.ledger)&&e.add(t.connection.id);return ez.filter(n=>e.has(n.id))},[I,er,eD,ez]),eE=(0,h.Y)(`stored:${z}:${e_.map(e=>e.url).join("|")}`,async e=>Object.fromEntries(await Promise.all(e_.map(async n=>{try{return[n.id,{ledger:await g.F.ledger(n.url,z,e,!0),error:null}]}catch(t){if(e.aborted)throw t;return[n.id,{ledger:null,error:t instanceof Error?t.message:String(t)}]}})))),eI=`/${encodeURIComponent(t.id)}/migrations`,eT=(0,y.jV)(e=>e.history),eL=(0,l.useMemo)(()=>(0,b.x)(eD.map(e=>({connection:e.connection,ledger:e.ledger})),eT).filter(e=>e.setName===eq),[eD,eT,eq]),eP=(0,f.eh)(I,eO),eB=(0,l.useMemo)(()=>(0,f.nb)(I,eO),[I,eO]),eG=(0,f.kB)(I,eO),eV=(0,l.useCallback)(n=>{ej(u(e,n.files)),es("migrations")},[u,e]),eY=(0,G.$)(eV);function eQ(e,n,t=!1){(0!==n.steps.length||n.blockedBy)&&(em(null),ec({...n,direction:e,recordOnly:t}))}function eK(e){return{steps:e,blockedBy:null}}async function eU(){if(!ed||!I)return;eR.current=!1,ep(!0);let e=ed.steps.map(e=>({version:e.version,name:e.name,status:"waiting"}));em(e);let n=(n,t)=>{em(e=e.map((e,s)=>s===n?{...e,...t}:e))},s=n=>{em(e=e.map((e,t)=>t>=n&&"waiting"===e.status?{...e,status:"skipped"}:e))};for(let[e,r]of ed.steps.entries()){if(eR.current){s(e);break}let i="apply"===ed.direction?r.applySql:r.revertSql;if(!i&&!ed.recordOnly){n(e,{status:"failed",error:"No revert file for this migration."}),s(e+1);break}n(e,{status:"running"});let a=crypto.randomUUID();try{let s=await g.F.migrate(t.url,{runId:a,direction:ed.direction,version:r.version,name:r.name,checksum:r.checksum,setName:I.name,sql:i??"",revertSql:"apply"===ed.direction?r.revertSql:void 0,ledgerSchema:z,recordOnly:ed.recordOnly});n(e,{status:"ok",durationMs:s.durationMs}),R({runId:s.runId??a,setId:I.id,setName:I.name,connectionId:t.id,connectionName:t.name,direction:ed.direction,version:r.version,name:r.name,status:"ok",recorded:ed.recordOnly,durationMs:s.durationMs})}catch(l){let i=l instanceof Error?l.message:String(l);n(e,{status:"failed",error:i}),s(e+1),R({runId:a,setId:I.id,setName:I.name,connectionId:t.id,connectionName:t.name,direction:ed.direction,version:r.version,name:r.name,status:"failed",durationMs:0,error:i});break}}ep(!1),eF.reload(),eE.reload(),r.reload(),e.every(e=>"ok"===e.status)&&el([])}function eW(e){ee(t.id,e),n.push(`/${encodeURIComponent(t.id)}/query`)}function eX(e){en(e)}async function eH(e){I&&(I.source?(await g.F.note(I.source.root,I.source.path,e),E.reload()):w(I.id,e))}async function eZ(e){let n=e?.[0];eb(null),n&&ev&&I&&ej(u(I.id,[{path:`revert/${ev}_${n.name}`,text:await n.text()}]))}if(!I){let n=(0,j.km)(e)&&E.loading;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,s.jsx)(X,{name:n?"Reading…":"Not found"}),(0,s.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:n?(0,s.jsx)("p",{className:"text-sm",children:"Reading the folder…"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm",children:E.error?E.error:(0,j.km)(e)?"That migration is not in the folder on the branch you have checked out.":"That migration is no longer here."}),(0,s.jsx)(i(),{href:eI,className:"text-foreground underline underline-offset-4",children:"All migrations"})]})})]})}let eJ=new Set(ea),e0=I.steps.filter(e=>eJ.has(e.version)).length,e1=e0>0,e2=e1?(0,f.DM)(I,eO,eJ):(0,f.gj)(I,eO),e3=e1?(0,f.n9)(I,eO,eJ):(0,f.e)(I,eO),e5=ex||eF.loading||E.loading;return(0,s.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",onDragOver:e=>{!T&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),eg(!0))},children:[(0,s.jsxs)(X,{name:I?.name??"",indexHref:eI,children:[I.source&&(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Read from ${I.source.path}`,children:[(0,s.jsx)(o.WzY,{className:"size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"max-w-48 truncate font-mono",children:I.source.path}),E.data?.git&&(0,s.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[E.data.git.branch,E.data.git.dirty&&"*"]})]}),(0,s.jsx)(D,{environments:eD,targetId:t.id,onSelect:eX}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,s.jsx)(m.$,{size:"icon-sm",variant:"ghost",disabled:eF.loading||E.loading,"aria-label":"Refresh",title:T?"Re-read the files and every environment's ledger":"Re-read every environment's ledger",onClick:function(){eF.reload(),eE.reload(),T&&E.reload()},children:(0,s.jsx)(o.oS8,{className:(0,k.cn)((eF.loading||E.loading)&&"animate-spin")})}),!T&&(0,s.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>eg(!0),children:[(0,s.jsx)(o.FeY,{"data-icon":"inline-start"}),"Import"]}),(0,s.jsxs)(x.rI,{children:[(0,s.jsx)(x.ty,{render:(0,s.jsx)(m.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,s.jsx)(o.YKd,{})}),(0,s.jsxs)(x.SQ,{align:"end",className:"min-w-64",children:[(0,s.jsxs)(x._2,{disabled:e5||0===e2.steps.length,onClick:()=>eQ("apply",eK(e2.steps),!0),children:[(0,s.jsx)(o.nXx,{}),"Mark ",e2.steps.length," as already applied"]}),(0,s.jsx)(x.mB,{}),(0,s.jsxs)(x._2,{disabled:e5||0===e3.steps.length,onClick:()=>eQ("revert",e3),children:[(0,s.jsx)(o.ij9,{}),e1?`Revert ${e3.steps.length} selected on ${t.name}`:`Revert everything on ${t.name}`]}),(0,s.jsx)(x.mB,{}),(0,s.jsxs)(x._2,{onClick:()=>eC(!0),children:[(0,s.jsx)(o.UA_,{}),I.note?"Edit note":"Add note"]}),!T&&(0,s.jsxs)(x._2,{onClick:()=>eS(!0),children:[(0,s.jsx)(o.NOV,{}),"Rename"]}),(0,s.jsxs)(x._2,{onClick:()=>eN(!0),children:[(0,s.jsx)(o.ooN,{}),"Ledger table",(0,s.jsxs)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:[z,".",j.R9]})]}),!T&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.mB,{}),(0,s.jsx)(x._2,{variant:"destructive",onClick:function(){I&&(C(I.id),n.push(eI))},children:"Forget this migration"})]})]})]}),(0,s.jsxs)(m.$,{size:"sm",disabled:e5||0===e2.steps.length,onClick:()=>eQ("apply",e2),children:[(0,s.jsx)(o.eGB,{"data-icon":"inline-start"}),0===e2.steps.length?e1?"Nothing selected to apply":"Up to date":`Apply ${e2.steps.length}${e1?" selected":""} to ${t.name}`]})]})]}),ef&&(0,s.jsx)(Z,{report:ef,onDismiss:()=>ej(null)}),eY.error&&(0,s.jsx)("p",{className:"border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:eY.error}),"migrations"===et&&I.note&&(0,s.jsx)(H,{note:I.note,notePath:I.source?.notePath??null,onEdit:()=>eC(!0)}),(0,s.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:["history"===et?(0,s.jsx)(p.F,{className:"min-h-0 flex-1",children:(0,s.jsx)(P.H,{events:eL,connections:ez,loading:eF.loading,ledgerSchema:z,setName:eq})}):eM?.error?(0,s.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:eM.error}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_,{environments:eD,targetId:t.id,caption:e1?`${e0} selected`:function(e,n){if(n&&0===e.total)return"Reading…";let t=`${e.total} migration${1===e.total?"":"s"}`;return e.foreign>0?`${t} \xb7 ${e.foreign} not in this folder`:t}(eP,eF.loading),loading:eF.loading,selection:{checked:0!==e0&&(e0===I.steps.length||"mixed"),onToggle:function(){if(!I)return;let e=I.steps.map(e=>e.version);el(n=>n.some(n=>e.includes(n))?[]:e)}},onSelect:eX,onCompare:function(e){v.lz.getState().setCompareTarget(t.id,e),n.push(`/${encodeURIComponent(t.id)}/diff`)}}),(0,s.jsxs)(p.F,{className:(0,k.cn)("min-h-0 flex-1",eF.loading&&"opacity-70"),children:[(I?.steps.length??0)===0&&!T&&(0,s.jsx)("div",{className:"p-6",children:(0,s.jsx)(G.k,{onFiles:eV,compact:!0})}),I.skipped.length>0&&T&&(0,s.jsxs)("div",{className:"border-b bg-muted/20 px-4 py-2 text-xs text-muted-foreground",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Skipped ",I.skipped.length," file",1===I.skipped.length?"":"s"]}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 pl-5 font-mono text-[11px]",children:I.skipped.map(e=>(0,s.jsx)("li",{children:e},e))})]}),(I?.steps??[]).map(e=>(0,s.jsx)(O,{step:e,targetId:t.id,status:(0,f.FY)(e,eO),environments:eD.map(n=>({connection:n.connection,status:(0,f.FY)(e,n.ledger),entry:(0,f.ay)(e,n.ledger),error:n.error})),isNewestApplied:eG?.version===e.version,expanded:er.includes(e.version),busy:e5,editable:!T,drift:function(e){let n=eD.filter(n=>"drifted"===(0,f.FY)(e,n.ledger)),s=n.find(e=>e.connection.id===t.id)??n[0];if(!s)return null;let r=eE.data?.[s.connection.id],i=r?.ledger?.entries.find(n=>n.setName===eq&&n.version===e.version);return{connectionName:s.connection.name,appliedSql:r?.ledger?i?.applySql??null:void 0,error:r?.error??null}}(e),selected:eJ.has(e.version),onSelect:n=>(function(e,n){if(!I)return;let t=I.steps.map(e=>e.version),s=eo.current;eo.current=e,el(r=>{let i=!r.includes(e),a=[e];if(n&&s&&s!==e&&t.includes(s)){let[n,r]=[t.indexOf(s),t.indexOf(e)].sort((e,n)=>e-n);a=t.slice(n,r+1)}let l=new Set(r);for(let e of a)i?l.add(e):l.delete(e);return t.filter(e=>l.has(e))})})(e.version,n),onToggle:()=>{var n;return n=e.version,void ei(e=>e.includes(n)?e.filter(e=>e!==n):[...e,n])},actions:{onApplyThrough:()=>eQ("apply",(0,f.gj)(I,eO,e.version)),onApplyOne:()=>eQ("apply",{steps:[e],blockedBy:null}),onRevertThrough:()=>eQ("revert",(0,f.e)(I,eO,e.version)),onMarkApplied:()=>eQ("apply",eK([e]),!0),onMarkPending:()=>eQ("revert",eK([e]),!0),onAttachRevert:()=>{eb(e.version),window.requestAnimationFrame(()=>e$.current?.click())},onRemove:()=>I&&$(I.id,e.version),onOpenInEditor:eW}},e.version)),eB.length>0&&(0,s.jsx)(J,{entries:eB,connectionName:t.name})]})]}),eh&&!T&&(0,s.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/85 p-6",onDragOver:e=>e.preventDefault(),onDragLeave:()=>eg(!1),onDrop:e=>{e.preventDefault(),eg(!1),eY.importFrom(e.dataTransfer)},children:(0,s.jsx)(G.k,{onFiles:eV,className:"w-full max-w-xl bg-background"})})]}),(0,s.jsx)(B.l,{pane:et,onPaneChange:es,historyCount:eL.length,migrationsLabel:"Files",caption:function({connectionName:e,summary:n,initialized:t,loading:s,foundIn:r,configuredSchema:i}){if(s&&null===t)return"Reading ledgers…";let a=[];return!1===t||n.pending>0?a.push(`${n.pending} of ${n.total} pending on ${e}`):a.push(`${e} is up to date`),n.drifted>0&&a.push(`${n.drifted} changed since applied`),r&&r!==i&&a.push(`ledger in ${r}`),a.join(" \xb7 ")}({connectionName:t.name,summary:eP,initialized:eO?.initialized??null,loading:eF.loading,foundIn:eO?.initialized?eO.schema:null,configuredSchema:z})}),(0,s.jsx)("input",{ref:e$,type:"file",accept:".sql",className:"sr-only",onChange:e=>{eZ(e.target.files),e.target.value=""}}),(0,s.jsx)(V.K,{open:ek,title:"Rename migration",initial:I.name,submitLabel:"Rename",onOpenChange:eS,onSubmit:function(e){I&&S(I.id,e)}}),ew&&(0,s.jsx)(Q,{initial:I.note??"",file:I.source?I.source.notePath?.split(/[\\/]/).at(-1)??"README.md":null,onOpenChange:eC,onSave:eH}),ey&&(0,s.jsx)(L,{schema:z,found:eD.filter(e=>e.ledger?.initialized).map(e=>({name:e.connection.name,schema:e.ledger?.schema??z})),onOpenChange:eN,onSave:e=>{A(e),eF.reload()}}),ed&&(0,s.jsx)(K.I,{open:!0,direction:ed.direction,connection:t,steps:ed.steps,blockedBy:ed.blockedBy,progress:eu,running:ex,recordOnly:ed.recordOnly??!1,note:I.note,onRun:()=>void eU(),onStop:()=>{eR.current=!0},onClose:function(){ex||(ec(null),em(null))}})]})}function X({name:e,indexHref:n,children:t}){let r=(0,s.jsx)(o.olY,{className:"size-4 shrink-0 text-muted-foreground"});return(0,s.jsxs)(u.X,{children:[n?(0,s.jsx)(i(),{href:n,title:"All migrations","aria-label":"All migrations",className:"flex size-6 shrink-0 items-center justify-center rounded-md outline-none hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60",children:r}):r,(0,s.jsx)("span",{className:"min-w-0 truncate font-medium",children:e}),t]})}function H({note:e,notePath:n,onEdit:t}){return(0,s.jsxs)("button",{type:"button",title:n?`${n} \xb7 click to edit`:"Click to edit",onClick:t,className:"group flex w-full cursor-pointer items-start gap-2 border-b px-4 py-2.5 text-left text-xs outline-none hover:bg-muted/30 focus-visible:bg-muted/30",children:[(0,s.jsx)(o.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"max-h-40 min-w-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words",children:e}),(0,s.jsx)(o.NOV,{className:"mt-px size-3.5 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"})]})}function Z({report:e,onDismiss:n}){let t=[];return e.added>0&&t.push(`added ${e.added}`),e.updated>0&&t.push(`updated ${e.updated}`),e.reverts>0&&t.push(`${e.reverts} revert file${1===e.reverts?"":"s"}`),(0,s.jsxs)("div",{className:"flex items-start gap-2 border-b bg-muted/30 px-4 py-1.5 text-xs",children:[(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[t.length>0?`Imported: ${t.join(", ")}`:"Nothing new in those files",e.skipped.length>0&&(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 skipped ",e.skipped.slice(0,2).join(", "),e.skipped.length>2&&` and ${e.skipped.length-2} more`]})]}),(0,s.jsx)(m.$,{size:"xs",variant:"ghost",onClick:n,children:"Dismiss"})]})}function J({entries:e,connectionName:n}){return(0,s.jsxs)("div",{className:"border-t bg-muted/20",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Applied on ",n,", not in this folder"]}),e.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 text-xs opacity-70",children:[(0,s.jsx)(q,{status:"applied"}),(0,s.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name||"—"}),(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:new Date(e.appliedAt).toLocaleString()})]},e.version))]})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,1981,9243,7709,1520,8098,8441,3794,7358],()=>e(e.s=52310)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9820],{28330:(e,t,n)=>{Promise.resolve().then(n.bind(n,69063))},69063:(e,t,n)=>{"use strict";n.d(t,{MigrationsIndex:()=>P});var s=n(95155),a=n(98500),r=n.n(a),i=n(73321),l=n(12115),o=n(13267),d=n(72194),c=n(36331),u=n(17491),m=n(89239),h=n(72264),p=n(66289),x=n(91075),g=n(85488),f=n(35942),j=n(7412),b=n(87364),v=n(27529),N=n(9385),k=n(62417),y=n(74590),w=n(79668),$=n(40980),C=n(96911),S=n(20642),z=n(77649),M=n(27013),F=n(41069),R=n(42763),E=n(83504);let I=[{verdict:"applied",title:"Already there",hint:"Everything these create or change is in the database.",preselected:!0},{verdict:"partial",title:"Partly there",hint:"Some of what these do is in the database and some is not — often a later migration changed it again.",preselected:!1},{verdict:"unknown",title:"Leaves no trace",hint:"Data changes, seeds, and grants cannot be seen in the schema. Include them if you know they ran.",preselected:!1},{verdict:"pending",title:"Not there",hint:"Nothing these do is in the database. Marking these hides work that still needs to run.",preselected:!1}];function q(e){return`${e.setName}\0${e.version}`}function O({connection:e,ledgerSchema:t,plan:n,onDone:a,onOpenChange:r}){let[i,c]=(0,l.useState)(null),[u,h]=(0,l.useState)(null),[p,x]=(0,l.useState)(new Set),[g,f]=(0,l.useState)([]),[j,b]=(0,l.useState)(!1),[N,k]=(0,l.useState)(null),[y,w]=(0,l.useState)(null);(0,l.useEffect)(()=>{let t=new AbortController;return v.F.detect(e.url,n.entries.map(e=>({setName:e.setName,version:e.version,sql:e.applySql})),t.signal).then(({results:e})=>{c(e);let t=new Set;for(let n of e)I.find(e=>e.verdict===n.verdict)?.preselected&&t.add(q(n));x(t)}).catch(e=>{t.signal.aborted||h(e instanceof Error?e.message:String(e))}),()=>t.abort()},[e.url,n.entries]);let C=(0,l.useMemo)(()=>{if(!i)return[];let e=new Map(n.entries.map(e=>[q(e),e]));return I.map(t=>({verdict:t.verdict,title:t.title,hint:t.hint,entries:i.filter(e=>e.verdict===t.verdict).flatMap(t=>{let n=e.get(q(t));return n?[{entry:n,result:t}]:[]})})).filter(e=>e.entries.length>0)},[i,n.entries]),S=n.entries.filter(e=>p.has(q(e)));async function z(n){b(!0),w(null);try{k(await v.F.adopt(e.url,{ledgerSchema:t,entries:n})),a()}catch(e){w(e instanceof Error?e.message:String(e))}finally{b(!1)}}let M=!i&&!u;return(0,s.jsx)(R.lG,{open:!0,onOpenChange:e=>!j&&r(e),children:(0,s.jsxs)(R.Cf,{className:"sm:max-w-xl",children:[(0,s.jsxs)(R.c7,{children:[(0,s.jsx)(R.L3,{children:N?`Marked ${N.recorded} as applied`:M?`Checking ${e.name}…`:`Mark as already applied on ${e.name}`}),(0,s.jsx)(R.rr,{children:(0,s.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{children:N?"Recorded on":"Records on"}),(0,s.jsx)(d.F,{connection:e}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.name}),(0,s.jsx)("span",{className:"font-mono text-[11px]",children:(0,E.p)(e.url)})]})})]}),N?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:N.existing>0?`${N.existing} were already in the ledger and were left as they were.`:"Every one of them was new to the ledger."}):M?(0,s.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(o.gnh,{className:"size-3.5 animate-spin"}),"Reading the schema to see which of the ",n.entries.length," have already run…"]}):u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:u}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The check could not run. You can still mark all ",n.entries.length," as applied if you know the database already has these changes."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"max-h-80 overflow-y-auto rounded-md border",children:C.map(e=>{let t=e.entries.filter(({entry:e})=>p.has(q(e))).length,n=g.includes(e.verdict);return(0,s.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox","aria-label":`Include ${e.title}`,className:"size-3.5 cursor-pointer accent-primary",checked:t===e.entries.length,ref:n=>{n&&(n.indeterminate=t>0&&t<e.entries.length)},onChange:t=>{var n;return n=t.target.checked,void x(t=>{let s=new Set(t);for(let{entry:t}of e.entries)n?s.add(q(t)):s.delete(q(t));return s})}}),(0,s.jsxs)("button",{type:"button","aria-expanded":n,onClick:()=>{var t;return t=e.verdict,void f(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",children:[(0,s.jsx)(o.nNJ,{className:(0,$.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",n&&"rotate-90")}),(0,s.jsx)("span",{className:"text-sm",children:e.title}),(0,s.jsxs)("span",{className:"tabular-nums text-xs text-muted-foreground",children:[t,"/",e.entries.length]})]}),(0,s.jsx)(V,{verdict:e.verdict})]}),!n&&(0,s.jsx)("p",{className:"px-9 pb-2 text-[11px] text-muted-foreground",children:e.hint}),n&&(0,s.jsxs)("div",{className:"bg-muted/25",children:[(0,s.jsx)("p",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:e.hint}),e.entries.map(({entry:e,result:t})=>{let n=t.evidence.filter(e=>!e.satisfied),a=t.evidence.find(e=>e.note)?.note;return(0,s.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 border-t px-3 py-1.5 text-xs hover:bg-muted/40",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5 size-3.5 cursor-pointer accent-primary",checked:p.has(q(e)),onChange:()=>{x(t=>{let n=new Set(t),s=q(e);return n.has(s)?n.delete(s):n.add(s),n})}}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.setName}),(0,s.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,s.jsx)("span",{className:"min-w-0 truncate",children:e.name})]}),(n.length>0||a)&&(0,s.jsxs)("span",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",children:[n.length>0&&(0,s.jsxs)(s.Fragment,{children:["Missing: ",n.slice(0,2).map(e=>e.description).join(", "),n.length>2&&` and ${n.length-2} more`]}),n.length>0&&a&&" \xb7 ",a]})]})]},q(e))})]})]},e.verdict)})}),(0,s.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on"," ",e.name," changes, in one transaction. Rows already there are not touched."]})]}),y&&(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:y}),(0,s.jsx)(R.Es,{children:N?(0,s.jsx)(m.$,{onClick:()=>r(!1),children:"Close"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{variant:"outline",disabled:j,onClick:()=>r(!1),children:"Cancel"}),u?(0,s.jsx)(m.$,{disabled:j,onClick:()=>void z(n.entries),children:j?"Marking…":`Mark all ${n.entries.length} as applied`}):(0,s.jsx)(m.$,{disabled:j||M||0===S.length,onClick:()=>void z(S),children:j?"Marking…":`Mark as applied (${S.length})`})]})})]})})}function V({verdict:e}){return"applied"===e?(0,s.jsx)(o.wiW,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}):"partial"===e?(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):"pending"===e?(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-destructive"}):(0,s.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"})}var L=n(60529),_=n(33807);function A({root:e,environmentNames:t,onOpenChange:n,onSave:a}){let[r,i]=(0,l.useState)(e??""),o=r.trim(),d=o.startsWith("/")||o.startsWith("~")||/^[A-Za-z]:[\\/]/.test(o);function c(){o&&d&&(a(o),n(!1))}return(0,s.jsx)(R.lG,{open:!0,onOpenChange:n,children:(0,s.jsxs)(R.Cf,{className:"sm:max-w-lg",children:[(0,s.jsxs)(R.c7,{children:[(0,s.jsx)(R.L3,{children:"Migrations folder"}),(0,s.jsxs)(R.rr,{children:["A folder on this computer. Each folder inside it that holds .sql files is one migration, read fresh from disk every time — whatever branch is checked out is what shows. ",t.join(", ")," will all read from it."]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(_.J,{htmlFor:"repo-root",children:"Path"}),(0,s.jsx)(L.p,{id:"repo-root",value:r,placeholder:"~/code/app/src/lib/supabase/migrations",spellCheck:!1,autoComplete:"off",autoFocus:!0,"aria-invalid":o.length>0&&!d,onChange:e=>i(e.target.value),onKeyDown:e=>"Enter"===e.key&&c()}),o.length>0&&!d&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:"An absolute path, or one starting with ~."})]}),(0,s.jsxs)(R.Es,{children:[e&&(0,s.jsx)(m.$,{variant:"ghost",className:"mr-auto",onClick:function(){a(null),n(!1)},children:"Stop reading from disk"}),(0,s.jsx)(m.$,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),(0,s.jsx)(m.$,{disabled:!o||!d,onClick:c,children:"Save"})]})]})})}var Q=n(71612);function P(){let e=(0,i.useRouter)(),{connection:t}=(0,c.k)(),n=(0,w.jV)(e=>e.sets),a=(0,w.jV)(e=>e.createSet),r=(0,w.jV)(e=>e.adoptSet),d=(0,w.jV)(e=>e.addFiles),p=(0,w.jV)(e=>e.removeSet),x=(0,w.jV)(e=>e.ledgerSchema),g=(0,w.jV)(e=>e.history),j=(0,y.gz)(t.id),[R,E]=(0,l.useState)("migrations"),[I,q]=(0,l.useState)(null),[V,L]=(0,l.useState)(null),[_,P]=(0,l.useState)(!1),[T,K]=(0,l.useState)(!1),[D,G]=(0,l.useState)(null),H=(0,l.useMemo)(()=>[t,...j],[t,j]),J=H.map(e=>e.url).join("|"),{scope:X,root:Z,checkout:ee}=(0,w.ox)(t.id),et=(0,w.jV)(e=>e.setRepoRoot),en=(0,w.jV)(e=>e.setRepoCheckout),es=(0,w.kG)(X),ea=(0,w.jV)(e=>e.setListFilter),er=(0,Q.y)(Z,ee),ei=(0,l.useMemo)(()=>[...er.data?.sets??[]].sort((e,t)=>t.importedAt-e.importedAt),[er.data]),el=(0,b.Y)(`ledgers:${x}:${J}`,async e=>Object.fromEntries(await Promise.all(H.map(async t=>{try{return[t.id,{ledger:await v.F.ledger(t.url,x,e),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),eo=(0,l.useMemo)(()=>(0,N.x)(H.map(e=>({connection:e,ledger:el.data?.[e.id]?.ledger??null})),g),[H,el.data,g]),ed=`/${encodeURIComponent(t.id)}/migrations`,ec=(0,l.useCallback)(t=>{let n=a(t.name);d(n,t.files),e.push(`${ed}/${encodeURIComponent(n)}`)},[a,d,e,ed]);async function eu(t){q(t),L(null);try{let n=await Promise.all(H.map(async e=>{try{return{read:await v.F.ledger(e.url,x,void 0,!0),error:null}}catch(e){return{read:null,error:e instanceof Error?e.message:String(e)}}})),s=n.find(e=>e.error);if(s?.error)return void L(s.error);let a=n.some(e=>e.read&&void 0===e.read.withSql),i=new Map;for(let{read:e}of n)for(let n of e?.entries??[]){if(n.setName.trim()!==t)continue;let e=i.get(n.version);e?.applySql||i.set(n.version,n)}let{set:l,missing:o}=(0,S.wQ)(t,[...i.values()]);if(0===l.steps.length)return void L(a?"The YTDB running on your machine is older than this page and cannot send stored SQL. Restart it with `npx @theobourgeois/ytdb@latest`.":`${t} was applied before YTDB stored SQL, so it cannot be rebuilt. Drop its folder instead.`);r(l),o.length>0&&L(`Rebuilt ${l.steps.length} of ${l.steps.length+o.length}. No SQL was stored for ${o.join(", ")}.`),e.push(`${ed}/${encodeURIComponent(l.id)}`)}catch(e){L(e instanceof Error?e.message:String(e))}finally{q(null)}}let em=(0,l.useMemo)(()=>[...n].sort((e,t)=>t.importedAt-e.importedAt),[n]),eh=(0,l.useMemo)(()=>(0,k.lF)(H.map(e=>({connection:e,ledger:el.data?.[e.id]?.ledger??null})),[...ei,...n].map(e=>e.name)),[H,el.data,ei,n]),ep=(0,l.useMemo)(()=>{let e=el.data?.[t.id]?.ledger??null,n=[],s=0;if(!e)return{sets:0,entries:n};for(let t of ei){let a=(0,k.gj)(t,(0,k.Gf)(e,t.name));if(0!==a.steps.length)for(let e of(s+=1,a.steps))n.push({setName:t.name,version:e.version,name:e.name,checksum:e.checksum,applySql:e.applySql,revertSql:e.revertSql})}return{sets:s,entries:n}},[el.data,t.id,ei]),ex=el.loading||er.loading,eg=0===ei.length&&0===n.length&&0===eh.length,ef=(0,l.useCallback)(e=>H.map(t=>({connection:t,summary:(0,k.eh)(e,el.data?.[t.id]?.ledger??null),read:!!el.data?.[t.id]?.ledger,error:el.data?.[t.id]?.error??null})),[H,el.data]),ej=(0,l.useCallback)(e=>(0,k.yy)(e,ef(e).map(e=>({connectionId:e.connection.id,summary:e.summary,read:e.read})),es),[ef,es]),eb=(0,l.useMemo)(()=>ei.filter(ej),[ei,ej]),ev=(0,l.useMemo)(()=>em.filter(ej),[em,ej]),eN=""!==es.query.trim()||"all"!==es.status,ek=ei.length+em.length-eb.length-ev.length;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,s.jsxs)(u.X,{children:[(0,s.jsx)(o.olY,{className:"size-4 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-medium",children:"Migrations"}),Z&&(0,s.jsx)(Y,{root:er.data?.root??Z,git:er.data?.git??null,checkouts:er.data?.checkouts??[],checkout:er.data?.checkout??null,onEdit:()=>K(!0),onPick:e=>en(X,e)}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(m.$,{size:"icon-sm",variant:"ghost",disabled:ex,"aria-label":"Refresh",title:Z?"Re-read the folder and every environment's ledger":"Re-read every environment's ledger",onClick:function(){el.reload(),er.reload()},children:(0,s.jsx)(o.oS8,{className:(0,$.cn)(ex&&"animate-spin")})}),!Z&&(0,s.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>K(!0),children:[(0,s.jsx)(o.WzY,{"data-icon":"inline-start"}),"Read from a folder"]}),(0,s.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>P(!0),children:[(0,s.jsx)(o.enO,{"data-icon":"inline-start"}),"New migration"]}),(Z||n.length>0)&&(0,s.jsxs)(h.rI,{children:[(0,s.jsx)(h.ty,{render:(0,s.jsx)(m.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,s.jsx)(o.YKd,{})}),(0,s.jsxs)(h.SQ,{align:"end",className:"min-w-72",children:[Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(h._2,{disabled:ex||0===ep.entries.length,onClick:()=>G(ep),children:[(0,s.jsx)(o.nXx,{}),"Mark everything as applied on ",t.name,(0,s.jsx)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:ep.entries.length})]}),(0,s.jsx)(h.mB,{}),(0,s.jsxs)(h._2,{onClick:()=>K(!0),children:[(0,s.jsx)(o.WzY,{}),"Change folder…"]})]}),n.length>0&&(0,s.jsxs)(s.Fragment,{children:[Z&&(0,s.jsx)(h.mB,{}),(0,s.jsxs)(h._2,{variant:"destructive",onClick:function(){for(let e of n)p(e.id)},children:["Forget ",n.length," imported migration",1===n.length?"":"s"]})]})]})]})]})]}),er.error&&(0,s.jsxs)("p",{className:"flex items-start gap-2 border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:[(0,s.jsx)(o.e5t,{className:"mt-px size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"min-w-0 flex-1",children:er.error}),(0,s.jsx)(m.$,{size:"xs",variant:"ghost",onClick:()=>K(!0),children:"Change folder"})]}),"history"===R?(0,s.jsx)(f.F,{className:"min-h-0 flex-1",children:(0,s.jsx)(C.H,{events:eo,connections:H,loading:el.loading,ledgerSchema:x})}):eg&&Z&&er.loading?(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Reading ",Z,"…"]}):eg&&Z?(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center",children:[(0,s.jsxs)("p",{className:"text-sm",children:["Nothing in ",Z," yet."]}),(0,s.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:"Each folder inside it that holds .sql files becomes a migration here, the moment it exists on the branch you have checked out."})]}):eg?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6",children:[(0,s.jsx)(z.k,{onFiles:ec,className:"w-full max-w-xl"}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Or"," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>K(!0),children:"read straight from a folder on this computer"}),", so nothing has to be imported."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(U,{filter:es,environments:H,hidden:ek,onChange:e=>ea(X,e)}),(0,s.jsxs)(f.F,{className:"min-h-0 flex-1",children:[eb.map(e=>(0,s.jsx)(B,{set:e,href:`${ed}/${encodeURIComponent(e.id)}`,environments:ef(e)},e.id)),ev.length>0&&Z&&(0,s.jsx)("p",{className:"border-b px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Imported into this browser rather than read from the folder.",children:"Imported"}),ev.map(e=>(0,s.jsx)(B,{set:e,href:`${ed}/${encodeURIComponent(e.id)}`,environments:ef(e)},e.id)),eN&&0===eb.length&&0===ev.length&&(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Nothing matches."," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>ea(X,{query:"",status:"all"}),children:"Clear the filter"})]}),eh.length>0&&(0,s.jsxs)("div",{className:"border-b bg-muted/20",children:[(0,s.jsx)("p",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Applied to a database from elsewhere. The SQL is kept in its ledger, so it opens without the folder.",children:"In the ledger only"}),eh.map(e=>(0,s.jsx)(W,{migration:e,busy:I===e.name,onOpen:()=>void eu(e.name)},e.name)),V&&(0,s.jsx)("p",{className:"px-4 pt-1 pb-2 text-xs text-destructive",children:V})]}),!Z&&(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(z.k,{onFiles:ec,compact:!0,className:"w-full"})})]})]}),(0,s.jsx)(F.l,{caption:function(e,t,n,s){if(s&&0===e)return"Reading folder…";if(0===e&&0===t&&0===n)return"No migrations yet";let a=[];return e>0&&a.push(`${e} migration${1===e?"":"s"} on disk`),t>0&&a.push(`${t} imported`),n>0&&a.push(`${n} in the ledger only`),a.join(" \xb7 ")}(ei.length,n.length,eh.length,null!==Z&&er.loading),pane:R,onPaneChange:E,historyCount:eo.length}),T&&(0,s.jsx)(A,{root:Z,environmentNames:H.map(e=>e.name),onOpenChange:K,onSave:e=>et(X,e)}),D&&(0,s.jsx)(O,{connection:t,ledgerSchema:x,plan:D,onDone:()=>el.reload(),onOpenChange:e=>!e&&G(null)}),(0,s.jsx)(M.K,{open:_,title:"New migration",submitLabel:"Create",onOpenChange:P,onSubmit:function(t){let n=a(t);e.push(`${ed}/${encodeURIComponent(n)}`)}})]})}let T={all:"All",pending:"Not fully applied",untouched:"Not started anywhere",complete:"Applied everywhere"};function U({filter:e,environments:t,hidden:n,onChange:a}){let r="all"!==e.status;return(0,s.jsxs)("div",{className:"flex items-center gap-1 border-b px-2 py-1",children:[(0,s.jsx)(j.L,{value:e.query,onChange:e=>a({query:e.target.value}),placeholder:"Search migrations","aria-label":"Search migrations",className:"min-w-0 flex-1",trailing:e.query?(0,s.jsx)("button",{type:"button","aria-label":"Clear search",className:"cursor-pointer rounded p-0.5 hover:text-foreground",onClick:()=>a({query:""}),children:(0,s.jsx)(o.yBK,{className:"size-3.5"})}):null}),(0,s.jsxs)(h.rI,{children:[(0,s.jsxs)(h.ty,{render:(0,s.jsx)(m.$,{size:"sm",variant:r?"outline":"ghost"}),className:"cursor-pointer",children:[function(e,t){if(e.startsWith("pending:")){let n=t.find(t=>t.id===e.slice(8));return n?`Pending on ${n.name}`:T.pending}return T[e]}(e.status,t),(0,s.jsx)(o.RQe,{"data-icon":"inline-end"})]}),(0,s.jsx)(h.SQ,{align:"end",className:"min-w-56",children:(0,s.jsxs)(h.Hr,{value:e.status,onValueChange:e=>a({status:e}),children:[Object.keys(T).map(e=>(0,s.jsx)(h.Ht,{value:e,children:T[e]},e)),t.length>1&&(0,s.jsx)(h.mB,{}),t.length>1&&t.map(e=>(0,s.jsxs)(h.Ht,{value:`pending:${e.id}`,children:[(0,s.jsx)(d.F,{connection:e,className:"size-1.5"}),"Pending on ",e.name]},e.id))]})})]}),n>0&&(0,s.jsxs)("span",{className:"shrink-0 pr-1 text-[11px] tabular-nums text-muted-foreground",children:[n," hidden"]})]})}function Y({root:e,git:t,checkouts:n,checkout:a,onEdit:r,onPick:i}){var d;let c,[u,m]=(0,l.useState)(""),h=(0,l.useMemo)(()=>{let e=u.trim().toLowerCase();return e?n.filter(t=>t.branch.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)):n},[n,u]),f="cursor-pointer rounded-md outline-none hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",j=t&&(0,s.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[t.branch,t.dirty&&"*"]});return(0,s.jsxs)("div",{className:"flex min-w-0 items-center text-xs text-muted-foreground",children:[(0,s.jsxs)("button",{type:"button",title:`Reading from ${e}. Click to change.`,onClick:r,className:(0,$.cn)("flex min-w-0 items-center gap-1.5 px-1.5 py-0.5",f),children:[(0,s.jsx)(o.WzY,{className:"size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"max-w-64 truncate font-mono text-[11px]",children:(c=(d=e).split(/[\/]/).filter(Boolean)).length>2?`…/${c.slice(-2).join("/")}`:d})]}),t&&n.length>1?(0,s.jsxs)(g.G3,{items:h,filter:null,value:n.find(e=>e.path===a)??null,inputValue:u,onInputValueChange:e=>m(e),onOpenChange:e=>e&&m(""),itemToStringLabel:e=>e.branch,isItemEqualToValue:(e,t)=>e.path===t.path,onValueChange:e=>e&&i(e.path),children:[(0,s.jsxs)(p.M,{title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""}). Read from another worktree.`,className:(0,$.cn)("flex shrink-0 items-center gap-0.5 px-1 py-0.5",f),children:[j,(0,s.jsx)(o.klM,{className:"size-3"})]}),(0,s.jsxs)(g.h5,{className:"w-max min-w-56",children:[(0,s.jsxs)("div",{className:"m-1 mb-0 flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground focus-within:bg-muted/60",children:[(0,s.jsx)(o.TfF,{className:"size-3.5 shrink-0"}),(0,s.jsx)(x.o,{placeholder:"Search worktrees",spellCheck:!1,autoComplete:"off",className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"})]}),(0,s.jsx)(g.$U,{children:"No matching worktrees"}),(0,s.jsx)(g.ex,{children:e=>(0,s.jsx)(g.x4,{value:e,title:e.path,children:(0,s.jsx)("span",{className:"font-mono text-xs",children:e.branch})},e.path)})]})]}):t&&(0,s.jsx)("span",{className:"px-1",title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""})`,children:j})]})}function B({set:e,href:t,environments:n}){return(0,s.jsxs)(r(),{href:t,className:"flex items-center gap-3 border-b px-4 py-3 outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[(0,s.jsx)("span",{className:"truncate",children:e.name}),e.note&&(0,s.jsx)("span",{title:e.note,className:"shrink-0 text-muted-foreground",children:(0,s.jsx)(o.UA_,{className:"size-3.5"})})]}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[0===e.steps.length?"No files yet":`${e.steps.length} migration${1===e.steps.length?"":"s"}`,e.steps.length>0&&` \xb7 ${e.steps[0].version}–${e.steps.at(-1)?.version}`,e.skipped.length>0&&` \xb7 ${e.skipped.length} skipped`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:n.map(e=>(0,s.jsx)(K,{environment:e},e.connection.id))}),(0,s.jsx)(o.nNJ,{className:"size-4 shrink-0 text-muted-foreground/60"})]})}function W({migration:e,busy:t,onOpen:n}){return(0,s.jsxs)("div",{className:"flex items-center gap-3 border-t px-4 py-2.5 first:border-t-0",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-sm",children:e.name}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[e.total," migration",1===e.total?"":"s",e.versions.length>0&&` \xb7 ${e.versions[0]}–${e.versions.at(-1)}`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:e.applied.map(t=>(0,s.jsxs)("span",{className:"flex h-6 items-center gap-1.5 rounded-lg border border-dashed px-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.connectionName}),(0,s.jsxs)("span",{className:"tabular-nums",children:[t.count,"/",e.total]})]},t.connectionId))}),(0,s.jsx)(m.$,{size:"xs",variant:"outline",disabled:t,onClick:n,children:t?"Opening…":"Open"})]})}function K({environment:e}){let{connection:t,summary:n,read:a,error:r}=e,i=a&&n.total>0&&0===n.pending&&0===n.drifted,l=a&&0===n.applied&&0===n.drifted;return(0,s.jsxs)("span",{title:r?`${t.name}: ${r}`:a?`${t.name}: ${n.applied} of ${n.total} applied`:`${t.name}: reading…`,className:(0,$.cn)("flex h-6 items-center gap-1.5 rounded-lg border px-2 text-[11px]",r&&"border-destructive/30 text-destructive",i&&"border-emerald-600/30 bg-emerald-500/10",!r&&!i&&!l&&"border-amber-600/30 bg-amber-500/10",l&&"text-muted-foreground"),children:[(0,s.jsx)(d.F,{connection:t,className:"size-1.5"}),(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.name}),(0,s.jsx)("span",{className:"tabular-nums",children:r?"—":a?`${n.applied}/${n.total}`:"…"})]})}},85488:(e,t,n)=>{"use strict";n.d(t,{G3:()=>C,h5:()=>F,$U:()=>I,oK:()=>M,x4:()=>E,ex:()=>R});var s=n(95155);n(12115);var a=n(92953),r=n(66289),i=n(58565),l=n(91075),o=n(2385),d=n(19001),c=n(93313),u=n(29432),m=n(56758),h=n(47028),p=n(63205),x=n(40980),g=n(89239),f=n(18460),j=n(60529);function b({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,x.cn)("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}n(18349);let v=(0,f.F)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function N({className:e,align:t="inline-start",...n}){return(0,s.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:(0,x.cn)(v({align:t}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}let k=(0,f.F)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function y({className:e,type:t="button",variant:n="ghost",size:a="xs",...r}){return(0,s.jsx)(g.$,{type:t,"data-size":a,variant:n,className:(0,x.cn)(k({size:a}),e),...r})}function w({className:e,...t}){return(0,s.jsx)(j.p,{"data-slot":"input-group-control",className:(0,x.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}var $=n(13267);let C=a.i;function S({className:e,children:t,...n}){return(0,s.jsxs)(r.M,{"data-slot":"combobox-trigger",className:(0,x.cn)("[&_svg:not([class*='size-'])]:size-4",e),...n,children:[t,(0,s.jsx)($.RQe,{className:"pointer-events-none size-4 text-muted-foreground"})]})}function z({className:e,...t}){return(0,s.jsx)(i.V,{"data-slot":"combobox-clear",render:(0,s.jsx)(y,{variant:"ghost",size:"icon-xs"}),className:(0,x.cn)(e),...t,children:(0,s.jsx)($.yBK,{className:"pointer-events-none"})})}function M({className:e,children:t,disabled:n=!1,showTrigger:a=!0,showClear:r=!1,inputRef:i,...o}){return(0,s.jsxs)(b,{className:(0,x.cn)("w-auto",e),children:[(0,s.jsx)(l.o,{ref:i,render:(0,s.jsx)(w,{disabled:n}),...o}),(0,s.jsxs)(N,{align:"inline-end",children:[a&&(0,s.jsx)(y,{size:"icon-xs",variant:"ghost",render:(0,s.jsx)(S,{}),"data-slot":"input-group-button",className:"group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",disabled:n}),r&&(0,s.jsx)(z,{disabled:n})]}),t]})}function F({className:e,side:t="bottom",sideOffset:n=6,align:a="start",alignOffset:r=0,anchor:i,...l}){return(0,s.jsx)(o.K,{children:(0,s.jsx)(d.o,{side:t,sideOffset:n,align:a,alignOffset:r,anchor:i,className:"isolate z-80",children:(0,s.jsx)(c.I,{"data-slot":"combobox-content","data-chips":!!i,className:(0,x.cn)("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...l})})})}function R({className:e,...t}){return(0,s.jsx)(u.e,{"data-slot":"combobox-list",className:(0,x.cn)("no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",e),...t})}function E({className:e,children:t,...n}){return(0,s.jsxs)(m.x,{"data-slot":"combobox-item",className:(0,x.cn)("relative flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[t,(0,s.jsx)(h.Q,{render:(0,s.jsx)("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:(0,s.jsx)($.wiW,{className:"pointer-events-none"})})]})}function I({className:e,...t}){return(0,s.jsx)(p.$,{"data-slot":"combobox-empty",className:(0,x.cn)("hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",e),...t})}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,3960,1981,9243,7709,1520,8098,8441,3794,7358],()=>e(e.s=28330)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2336],{4108:(e,t,n)=>{Promise.resolve().then(n.bind(n,21890))},21890:(e,t,n)=>{"use strict";n.d(t,{ConnectionHome:()=>p});var l=n(95155),o=n(73321),s=n(12115),r=n(74590),a=n(88263),u=n(20185),i=n(43262),c=n(95848),d=n(36331);function p(){let e=(0,o.useRouter)(),{connection:t,tables:n}=(0,d.k)(),[p]=(0,r.DE)(t.id),f=p.recentTables[0]??null,h=f?(n.data??[]).find(e=>(0,c.i)(e)===f):void 0;return((0,s.useEffect)(()=>{h&&(a.c.getState().markReplace(),e.replace((0,u.Jn)({kind:"table",connectionId:t.id,table:{schema:h.schema,name:h.name}})))},[h,t.id,e]),!n.data||h)?null:(0,l.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-1.5 text-muted-foreground",children:[(0,l.jsx)("p",{className:"text-sm",children:"Select a table"}),(0,l.jsx)("kbd",{className:"font-mono text-[11px] text-muted-foreground/60",children:i.Ar.tableSearch})]})}},73321:(e,t,n)=>{"use strict";var l=n(74645);n.o(l,"useParams")&&n.d(t,{useParams:function(){return l.useParams}}),n.o(l,"usePathname")&&n.d(t,{usePathname:function(){return l.usePathname}}),n.o(l,"useRouter")&&n.d(t,{useRouter:function(){return l.useRouter}})},74590:(e,t,n)=>{"use strict";n.d(t,{DE:()=>G,gz:()=>x,jn:()=>C,lz:()=>S,mQ:()=>T,y3:()=>k});var l=n(1934),o=n(31692),s=n(95848),r=n(40980),a=n(69586),u=n(63307);let i="ytdb:explorer";(0,u.q)("db-studio:explorer",i);let c={search:"",selectedSchemas:null,collapsedSchemas:[],pinnedTables:[],recentTables:[],sidebarWidth:256,sidebarCollapsed:!1},d={filters:[],search:"",sort:null,columnWidths:{},hiddenColumns:[],page:0,pageSize:50},p=["selectedSchemas","collapsedSchemas","pinnedTables"],f=["search","recentTables","sidebarWidth","sidebarCollapsed"],h=["columnWidths","hiddenColumns","pinnedColumns","pageSize"],m=["filters","search","sort","page"];function b(e,t){return`${e}:${(0,s.i)(t)}`}function y(e){let t=a.Z.getState().connections.find(t=>t.id===e);return t?.layoutGroup??e}function g(e,t){let n={};for(let l of t)Object.prototype.hasOwnProperty.call(e,l)&&(n[l]=e[l]);return n}let S=(0,l.v)()((0,o.Zr)(e=>({browse:{},tables:{},compareTargets:{},setBrowse:(t,n)=>e(e=>{let l=y(t),o=g(n,p),s=g(n,f),r={...e.browse};return l===t?r[t]={...r[t]??c,...o,...s}:(Object.keys(o).length>0&&(r[l]={...r[l]??c,...o}),Object.keys(s).length>0&&(r[t]={...r[t]??c,...s})),{browse:r}}),setTable:(t,n,l)=>e(e=>{let o=b(y(t),n),s=b(t,n),r=g(l,h),a=g(l,m),u={...e.tables};return o===s?u[s]={...u[s]??d,...r,...a}:(Object.keys(r).length>0&&(u[o]={...u[o]??d,...r}),Object.keys(a).length>0&&(u[s]={...u[s]??d,...a})),{tables:u}}),setCompareTarget:(t,n)=>e(e=>({compareTargets:{...e.compareTargets,[t]:n}})),copyLayout:(t,n)=>e(e=>{if(t===n)return e;let l={...e.browse},o=l[t];o&&(l[n]={...l[n]??c,...g(o,p)});let s={...e.tables},r=`${t}:`;for(let[t,l]of Object.entries(e.tables)){if(!t.startsWith(r))continue;let e=`${n}:${t.slice(r.length)}`;s[e]={...s[e]??d,...g(l,h)}}return{browse:l,tables:s}})}),{name:i}));function G(e){let t,n=(0,a.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),l=S(t=>n===e?void 0:t.browse[n]),o=S(t=>t.browse[e]),s=S(e=>e.setBrowse);return[(t=o&&"selectedSchemas"in o?o.selectedSchemas??null:o?.schema?[o.schema]:null,{...c,...o,selectedSchemas:t,...l?{selectedSchemas:l.selectedSchemas,collapsedSchemas:l.collapsedSchemas,pinnedTables:l.pinnedTables}:{}}),t=>s(e,t)]}function C(e,t){let n=(0,a.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),l=S(l=>n===e?void 0:l.tables[b(n,t)]),o=S(n=>n.tables[b(e,t)]),s=S(e=>e.setTable);return[{...d,...o,search:o?.search??d.search,hiddenColumns:o?.hiddenColumns??d.hiddenColumns,...l?{columnWidths:l.columnWidths,hiddenColumns:l.hiddenColumns,pinnedColumns:l.pinnedColumns,pageSize:l.pageSize}:{}},n=>s(e,t,n)]}function T(e,t){let n=[...new Set([e,...t])],{connections:l,update:o}=a.Z.getState(),s=S.getState(),u=l.find(t=>t.id===e);if(!u)return;let i=new Map;for(let e of l){if(!e.layoutGroup)continue;let t=i.get(e.layoutGroup)??[];t.push(e.id),i.set(e.layoutGroup,t)}let c=u.layoutGroup,d=c?i.get(c)??[e]:[e],p=d.filter(e=>!n.includes(e));for(let t of p)s.copyLayout(c??e,t),o(t,{layoutGroup:void 0});if(c){let t=d.filter(t=>!p.includes(t)&&t!==e);if(1===t.length){let e=t[0];e&&(s.copyLayout(c,e),o(e,{layoutGroup:void 0}))}}if(n.length<=1){c&&(s.copyLayout(c,e),o(e,{layoutGroup:void 0}));return}let f=c??(0,r.z)();for(let t of(c||s.copyLayout(e,f),n)){let e=l.find(e=>e.id===t);if(e){if(e.layoutGroup&&e.layoutGroup!==f){let l=e.layoutGroup,r=(i.get(l)??[]).filter(e=>e!==t&&!n.includes(e));if(1===r.length){let e=r[0];e&&(s.copyLayout(l,e),o(e,{layoutGroup:void 0}))}else r.length}o(t,{layoutGroup:f})}}}let v=[];function x(e){let t=(0,a.Z)(e=>e.connections),n=(0,a.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup);return n?t.filter(t=>t.layoutGroup===n&&t.id!==e):v}function k(e){let t=(0,a.Z)(e=>e.connections),n=S(t=>t.compareTargets[e]),l=S(e=>e.setCompareTarget),o=(0,a.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup),s=t.filter(t=>t.id!==e),r=o?s.filter(e=>e.layoutGroup===o):[];return{target:s.find(e=>e.id===n)??r[0]??s[0]??null,candidates:s,partnerIds:r.map(e=>e.id),setTarget:t=>l(e,t)}}},95848:(e,t,n)=>{"use strict";function l(e){return`${e.schema}.${e.name}`}n.d(t,{i:()=>l})}},e=>{e.O(0,[1731,1981,8441,3794,7358],()=>e(e.s=4108)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1083],{7412:(e,t,r)=>{"use strict";r.d(t,{L:()=>s});var n=r(95155),o=r(13267),l=r(40980);function s({trailing:e,className:t,...r}){return(0,n.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,n.jsx)(o.TfF,{className:"size-3.5 shrink-0"}),(0,n.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...r,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},17491:(e,t,r)=>{"use strict";r.d(t,{X:()=>d});var n=r(95155),o=r(40980),l=r(13267),s=r(89239),i=r(43262),a=r(36331),c=r(48861);function u({className:e}){let{connection:t}=(0,a.k)(),{back:r,forward:d,goBack:m,goForward:h}=(0,c.Q)(t.id);return(0,n.jsxs)("div",{className:(0,o.cn)("flex items-center",e),children:[(0,n.jsx)(s.$,{variant:"ghost",size:"icon-sm",disabled:!r,"aria-label":r?`Back to ${r.label}`:"Back",title:r?`Back to ${r.label} (${i.Ar.back})`:void 0,className:"disabled:opacity-30",onClick:m,children:(0,n.jsx)(l.SI1,{})}),(0,n.jsx)(s.$,{variant:"ghost",size:"icon-sm",disabled:!d,"aria-label":d?`Forward to ${d.label}`:"Forward",title:d?`Forward to ${d.label} (${i.Ar.forward})`:void 0,className:"disabled:opacity-30",onClick:h,children:(0,n.jsx)(l.nNJ,{})})]})}function d({children:e,className:t}){return(0,n.jsxs)("header",{className:(0,o.cn)("flex h-11 shrink-0 items-center gap-2 border-b pr-3 pl-1.5",t),children:[(0,n.jsx)(u,{className:"mr-0.5"}),e]})}},19065:(e,t,r)=>{"use strict";function n(e,t){if(0===t)return!0;let r=e[t-1];return"_"===r||"-"===r||" "===r||"."===r}function o(e,t,r){return l(e,t,e=>[r(e)])}function l(e,t,r){if(!e.trim())return[];let o=[];for(let l of t){let t=r(l),s=null;for(let r of t){let t=function(e,t){let r=e.trim().toLocaleLowerCase(),o=t.toLocaleLowerCase();if(!r)return 0;if(0===o.length)return null;if(o===r)return 1e4;if(o.startsWith(r))return 5e3-o.length;let l=o.indexOf(r);if(-1!==l)return 2400+1200*!!n(t,l)-l-o.length;let s=0,i=0,a=0;for(let e=0;e<o.length&&s<r.length;e+=1){if(o[e]!==r[s]){a=0;continue}i+=12,(a+=1)>1&&(i+=18*a),n(t,e)&&(i+=40),s+=1}if(s<r.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(r)?i+=2200:c.includes(r)&&(i+=700),i-(o.length-r.length)}(e,r);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&o.push({item:l,score:s})}return o.sort((e,t)=>t.score!==e.score?t.score-e.score:r(e.item)[0]?.localeCompare(r(t.item)[0]??"")??0)}r.d(t,{R6:()=>o,UO:()=>l})},21281:(e,t,r)=>{Promise.resolve().then(r.bind(r,96365))},34263:(e,t,r)=>{"use strict";r.d(t,{En:()=>u,Pc:()=>c,jl:()=>a});var n=r(1934),o=r(31692),l=r(40980),s=r(63307);let i="ytdb:queries";(0,s.q)("db-studio:queries",i);let a=144,c=800,u=(0,n.v)()((0,o.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(t,r)=>e(e=>({drafts:{...e.drafts,[t]:r}})),setEditorHeight:t=>e({editorHeight:Math.min(c,Math.max(a,Math.round(t)))}),record:(t,r)=>e(e=>{let n=r.trim();if(!n)return e;let o=e.history.find(e=>e.connectionId===t&&e.sql===n),s={id:o?.id??(0,l.z)(),connectionId:t,sql:n,executedAt:Date.now()},i=0,a=0;return{history:[s,...e.history.filter(e=>e.id!==s.id)].filter(e=>!(i>=200)&&!(a+e.sql.length>1e6)&&(i+=1,a+=e.sql.length,!0))}}),remove:t=>e(e=>({history:e.history.filter(e=>e.id!==t)}))}),{name:i}))},96365:(e,t,r)=>{"use strict";r.d(t,{QueryView:()=>q});var n=r(95155),o=r(12115),l=r(13267),s=r(36331),i=r(17491),a=r(48861),c=r(89239),u=r(27529),d=r(96532),m=r(43262),h=r(34263),f=r(40980),x=r(55737),g=r(82228),p=r(46732),b=r(14097),v=r(27071),j=r(89561),k=r(32638);let w=[j.Lz.theme({"&":{height:"100%",backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"13px"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace",lineHeight:"1.6",overflow:"auto"},".cm-content":{padding:"10px 0",caretColor:"var(--foreground)"},".cm-line":{padding:"0 16px 0 8px"},".cm-gutters":{backgroundColor:"color-mix(in oklch, var(--muted) 35%, var(--background))",color:"var(--muted-foreground)",borderRight:"1px solid var(--border)"},".cm-lineNumbers .cm-gutterElement":{minWidth:"42px",padding:"0 10px 0 6px"},".cm-activeLine":{backgroundColor:"color-mix(in oklch, var(--muted) 42%, transparent)"},".cm-activeLineGutter":{backgroundColor:"color-mix(in oklch, var(--muted) 68%, var(--background))",color:"var(--foreground)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"color-mix(in oklch, var(--primary) 18%, transparent) !important"},".cm-matchingBracket":{backgroundColor:"color-mix(in oklch, var(--primary) 16%, transparent)",outline:"1px solid color-mix(in oklch, var(--primary) 32%, transparent)"},".cm-tooltip":{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",backgroundColor:"var(--popover)",color:"var(--popover-foreground)",overflow:"hidden"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:"var(--accent)",color:"var(--accent-foreground)"}}),(0,p.y9)(p.cr.define([{tag:k._A.keyword,color:"var(--chart-1)",fontWeight:"600"},{tag:[k._A.string,k._A.special(k._A.string)],color:"var(--chart-2)"},{tag:[k._A.number,k._A.bool,k._A.null],color:"var(--chart-3)"},{tag:[k._A.typeName,k._A.className],color:"var(--chart-4)"},{tag:k._A.function(k._A.variableName),color:"var(--chart-4)"},{tag:k._A.comment,color:"var(--muted-foreground)",fontStyle:"italic"},{tag:[k._A.operator,k._A.punctuation],color:"var(--foreground)",opacity:"0.72"}]))],y=(0,o.forwardRef)(function({value:e,schema:t,maxLength:r,onChange:l,onRun:s,onLimitExceeded:i},a){let c=(0,o.useRef)(null),u=(0,o.useRef)(s);u.current=s;let d=(0,o.useRef)(i);d.current=i;let m=(0,o.useMemo)(()=>[(0,b.ll)({dialect:b.Rv,schema:t}),v.$t.changeFilter.of(e=>e.newDoc.length<=r||(queueMicrotask(()=>d.current()),!1)),j.Lz.contentAttributes.of({"aria-label":"SQL query editor"}),v.Nb.highest(j.w4.of([{key:"Mod-Enter",run:()=>(u.current(),!0)}])),j.w4.of([g.Yc])],[r,t]);return(0,o.useImperativeHandle)(a,()=>({focus(e=!1){let t=c.current;if(t){if(e){let e=t.state.doc.length;t.dispatch({selection:{anchor:e},scrollIntoView:!0})}t.focus()}},selectedText(){let e=c.current;if(!e)return"";let t=e.state.selection.main;return t.empty?"":e.state.sliceDoc(t.from,t.to)}})),(0,n.jsx)(x.Ay,{className:"h-full",value:e,height:"100%",theme:w,extensions:m,placeholder:"select *\nfrom public.users\nlimit 100;",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!1,highlightActiveLine:!0,highlightSelectionMatches:!0},onCreateEditor:e=>{c.current=e},onChange:l})});function N({statement:e}){return(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[(0,n.jsxs)("table",{className:"min-w-full border-separate border-spacing-0 font-mono text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"sticky top-0 left-0 z-20 h-9 w-10 border-r border-b bg-muted px-2 text-right font-normal text-muted-foreground",children:"#"}),e.columns.map((e,t)=>(0,n.jsx)("th",{className:"sticky top-0 z-10 h-9 min-w-32 border-r border-b bg-muted px-3 text-left font-medium whitespace-nowrap text-foreground last:border-r-0",children:e},`${e}:${t}`))]})}),(0,n.jsx)("tbody",{children:e.rows.map((t,r)=>(0,n.jsxs)("tr",{className:"group hover:bg-muted/45",children:[(0,n.jsx)("th",{className:"sticky left-0 z-10 h-8 border-r border-b bg-background px-2 text-right font-normal text-muted-foreground group-hover:bg-muted",children:r+1}),e.columns.map((e,r)=>{let o=t[r]??null,l=null===o?"null":String(o);return(0,n.jsx)("td",{title:l,className:"h-8 max-w-96 min-w-32 border-r border-b px-3 whitespace-nowrap last:border-r-0",children:(0,n.jsx)("span",{className:null===o?"text-muted-foreground/65":"block max-w-96 truncate text-foreground/90",children:l})},`${e}:${r}`)})]},r))})]}),0===e.rows.length?(0,n.jsx)("p",{className:"p-8 text-center text-sm text-muted-foreground",children:"Query returned no rows."}):null]})}function C({result:e,loading:t}){let[r,s]=(0,o.useState)({source:null,index:0});if(!e)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Run a query or migration to see its results."});let i=r.index;r.source!==e&&(i=Math.max(0,e.statements.length-1),s({source:e,index:i}));let a=e.statements[i];if(!a)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Execution completed without a result."});let c=function(e){if(e.truncated)return`${e.rows.length.toLocaleString()}+ rows`;let t=e.rowCount??e.rows.length;return 0===e.columns.length&&null===e.rowCount?null:`${t.toLocaleString()} ${1===t?"row":"rows"}`}(a);return(0,n.jsxs)("div",{className:(0,f.cn)("flex min-h-0 flex-1 flex-col",t&&"opacity-55"),"data-query-results":"",children:[(0,n.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,n.jsx)("span",{className:"mr-1 shrink-0 font-medium",children:"Results"}),e.statements.length>1?e.statements.map((t,r)=>(0,n.jsxs)("button",{type:"button","aria-pressed":r===i,onClick:()=>s({source:e,index:r}),className:(0,f.cn)("h-6 shrink-0 rounded-md px-2 font-mono text-[11px] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",r===i&&"bg-muted text-foreground"),children:[r+1," ",t.command]},r)):(0,n.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a.command}),c?(0,n.jsxs)("span",{className:"ml-1 shrink-0 text-muted-foreground",children:["\xb7 ",c]}):null,a.truncated?(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["\xb7 limited to ",a.rows.length]}):null,(0,n.jsxs)("span",{className:"ml-auto shrink-0 font-mono tabular-nums text-muted-foreground",children:[e.durationMs.toLocaleString()," ms"]})]}),a.columns.length>0?(0,n.jsx)(N,{statement:a}):(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-8 text-center",children:[(0,n.jsx)(l.Ykz,{className:"size-5 text-emerald-600 dark:text-emerald-400"}),(0,n.jsxs)("p",{className:"font-medium",children:[a.command," completed"]}),c?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c," affected"]}):null]})]})}var S=r(7412),A=r(19065);function E(e){return(e.split(/\r?\n/).find(e=>e.trim())?.trim()??e).replace(/\s+/g," ")}function L({connectionId:e,search:t,onSelect:r}){let s=(0,h.En)(e=>e.history),i=(0,h.En)(e=>e.remove),a=(0,o.useMemo)(()=>s.filter(t=>t.connectionId===e),[e,s]),c=(0,o.useMemo)(()=>t.trim()?(0,A.UO)(t,a,e=>[E(e.sql),e.sql]).map(e=>e.item):a,[a,t]);return 0===c.length?(0,n.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:0===a.length?"Queries you run will appear here.":"No matching queries."}):(0,n.jsx)("ul",{className:"flex flex-col gap-1 p-1.5",children:c.map(e=>{var t;return(0,n.jsxs)("li",{className:"group flex items-start rounded-md hover:bg-muted/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.sql),title:e.sql,className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,n.jsx)("span",{className:"block truncate font-mono text-xs text-foreground/90",children:E(e.sql)}),(0,n.jsx)("span",{className:"mt-1 block text-[10px] text-muted-foreground",children:(t=e.executedAt,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t))})]}),(0,n.jsx)("button",{type:"button",onClick:()=>i(e.id),"aria-label":"Remove query from history",title:"Remove from history",className:"mt-1.5 mr-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none hover:bg-foreground/10 hover:text-destructive focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover:opacity-100",children:(0,n.jsx)(l.mYx,{className:"size-3.5"})})]},e.id)})})}function $({connectionId:e,onSelectHistory:t}){let[r,l]=(0,o.useState)("");return(0,n.jsxs)("aside",{className:"flex w-72 max-w-[35%] shrink-0 flex-col border-l bg-sidebar","aria-label":"Query history",children:[(0,n.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-2",children:(0,n.jsx)(S.L,{value:r,onChange:e=>l(e.target.value),placeholder:"Search history","aria-label":"Search query history",className:"min-w-0 flex-1"})}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,n.jsx)(L,{connectionId:e,search:r,onSelect:t})})]})}let _=new Set(["SELECT","SHOW","EXPLAIN","FETCH"]);function q(){let{connection:e,tables:t}=(0,s.k)(),r=(0,h.En)(t=>t.drafts[e.id]??""),x=(0,h.En)(e=>e.setDraft),g=(0,h.En)(e=>e.record),p=(0,h.En)(e=>e.editorHeight),b=(0,h.En)(e=>e.setEditorHeight),[v,j]=(0,o.useState)(null),[k,w]=(0,o.useState)(null),[N,S]=(0,o.useState)(!1),A=(0,o.useRef)(null),E=(0,o.useRef)(null),L=(0,o.useRef)(null),q=(0,a.Q)(e.id),R=q.back?.route.kind==="migration"&&q.back.route.connectionId===e.id?q.back:null,z=(0,o.useMemo)(()=>{let e={};for(let r of t.data??[])(e[r.schema]??={})[r.name]=r.columns.map(e=>e.name);return e},[t.data]);async function H(){if(N)return;let n=A.current?.selectedText().trim()||r.trim();if(!n){w("Enter a query to run."),A.current?.focus();return}let o=new AbortController;L.current=o,g(e.id,n),S(!0),w(null);try{let r=await u.F.query(e.url,n,o.signal);j(r),r.statements.some(e=>!_.has(e.command))&&t.reload()}catch(e){if(o.signal.aborted)return;w(e instanceof Error?e.message:String(e))}finally{L.current===o&&(L.current=null,S(!1))}}return(0,o.useEffect)(()=>()=>L.current?.abort(),[]),(0,o.useEffect)(()=>{let e=E.current;if(!e)return;let t=null,r=new ResizeObserver(()=>{null!==t&&window.clearTimeout(t),t=window.setTimeout(()=>b(e.offsetHeight),200)});return r.observe(e),()=>{null!==t&&window.clearTimeout(t),r.disconnect()}},[b]),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("section",{className:"flex min-w-0 flex-1 flex-col",children:[(0,n.jsxs)(i.X,{children:[(0,n.jsx)(l.Uoo,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"font-medium",children:"Query"}),R&&(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",title:`Back to ${R.label} (${m.Ar.back})`,onClick:q.goBack,children:[(0,n.jsx)(l.a7N,{"data-icon":"inline-start"}),(0,n.jsx)("span",{className:"max-w-40 truncate",children:R.label})]}),(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:(0,f.cn)(!R&&"ml-auto"),disabled:N||!r,onClick:function(){x(e.id,""),w(null),A.current?.focus()},children:[(0,n.jsx)(l.GVO,{"data-icon":"inline-start"}),"Clear"]}),(0,n.jsxs)(c.$,{type:"button",size:"sm",disabled:N||!r.trim(),title:"Run the selection or the whole script (⌘↵)",onClick:()=>void H(),children:[N?(0,n.jsx)(l.gnh,{"data-icon":"inline-start",className:"animate-spin"}):(0,n.jsx)(l.eGB,{"data-icon":"inline-start"}),N?"Running":"Run"]})]}),(0,n.jsx)("div",{ref:E,style:{height:p,minHeight:h.jl,maxHeight:h.Pc},className:"max-h-[55vh] shrink-0 resize-y overflow-hidden border-b bg-background",children:(0,n.jsx)(y,{ref:A,value:r,schema:z,maxLength:d.H4,onChange:t=>x(e.id,t),onRun:()=>void H(),onLimitExceeded:()=>w(`Query is too long (maximum ${d.H4.toLocaleString()} characters).`)})}),k?(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:(0,n.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-xs whitespace-pre-wrap text-destructive",children:k})}):(0,n.jsx)(C,{result:v,loading:N})]}),(0,n.jsx)($,{connectionId:e.id,onSelectHistory:function(t){x(e.id,t),w(null),window.requestAnimationFrame(()=>A.current?.focus(!0))}})]})}},96532:(e,t,r)=>{"use strict";r.d(t,{H4:()=>o,d6:()=>n});let n=1e4,o=5e5}},e=>{e.O(0,[4506,6079,1731,8026,9159,4097,6090,8441,3794,7358],()=>e(e.s=21281)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1083],{7412:(e,t,r)=>{"use strict";r.d(t,{L:()=>s});var n=r(95155),o=r(13267),l=r(40980);function s({trailing:e,className:t,...r}){return(0,n.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,n.jsx)(o.TfF,{className:"size-3.5 shrink-0"}),(0,n.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...r,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},17491:(e,t,r)=>{"use strict";r.d(t,{X:()=>d});var n=r(95155),o=r(40980),l=r(13267),s=r(89239),i=r(43262),a=r(36331),c=r(48861);function u({className:e}){let{connection:t}=(0,a.k)(),{back:r,forward:d,goBack:m,goForward:h}=(0,c.Q)(t.id);return(0,n.jsxs)("div",{className:(0,o.cn)("flex items-center",e),children:[(0,n.jsx)(s.$,{variant:"ghost",size:"icon-sm",disabled:!r,"aria-label":r?`Back to ${r.label}`:"Back",title:r?`Back to ${r.label} (${i.Ar.back})`:void 0,className:"disabled:opacity-30",onClick:m,children:(0,n.jsx)(l.SI1,{})}),(0,n.jsx)(s.$,{variant:"ghost",size:"icon-sm",disabled:!d,"aria-label":d?`Forward to ${d.label}`:"Forward",title:d?`Forward to ${d.label} (${i.Ar.forward})`:void 0,className:"disabled:opacity-30",onClick:h,children:(0,n.jsx)(l.nNJ,{})})]})}function d({children:e,className:t}){return(0,n.jsxs)("header",{className:(0,o.cn)("flex h-11 shrink-0 items-center gap-2 border-b pr-3 pl-1.5",t),children:[(0,n.jsx)(u,{className:"mr-0.5"}),e]})}},19065:(e,t,r)=>{"use strict";function n(e,t){if(0===t)return!0;let r=e[t-1];return"_"===r||"-"===r||" "===r||"."===r}function o(e,t,r){return l(e,t,e=>[r(e)])}function l(e,t,r){if(!e.trim())return[];let o=[];for(let l of t){let t=r(l),s=null;for(let r of t){let t=function(e,t){let r=e.trim().toLocaleLowerCase(),o=t.toLocaleLowerCase();if(!r)return 0;if(0===o.length)return null;if(o===r)return 1e4;if(o.startsWith(r))return 5e3-o.length;let l=o.indexOf(r);if(-1!==l)return 2400+1200*!!n(t,l)-l-o.length;let s=0,i=0,a=0;for(let e=0;e<o.length&&s<r.length;e+=1){if(o[e]!==r[s]){a=0;continue}i+=12,(a+=1)>1&&(i+=18*a),n(t,e)&&(i+=40),s+=1}if(s<r.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(r)?i+=2200:c.includes(r)&&(i+=700),i-(o.length-r.length)}(e,r);null!==t&&(null===s||t>s)&&(s=t)}null!==s&&o.push({item:l,score:s})}return o.sort((e,t)=>t.score!==e.score?t.score-e.score:r(e.item)[0]?.localeCompare(r(t.item)[0]??"")??0)}r.d(t,{R6:()=>o,UO:()=>l})},21281:(e,t,r)=>{Promise.resolve().then(r.bind(r,96365))},34263:(e,t,r)=>{"use strict";r.d(t,{En:()=>u,Pc:()=>c,jl:()=>a});var n=r(1934),o=r(31692),l=r(40980),s=r(63307);let i="ytdb:queries";(0,s.q)("db-studio:queries",i);let a=144,c=800,u=(0,n.v)()((0,o.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(t,r)=>e(e=>({drafts:{...e.drafts,[t]:r}})),setEditorHeight:t=>e({editorHeight:Math.min(c,Math.max(a,Math.round(t)))}),record:(t,r)=>e(e=>{let n=r.trim();if(!n)return e;let o=e.history.find(e=>e.connectionId===t&&e.sql===n),s={id:o?.id??(0,l.z)(),connectionId:t,sql:n,executedAt:Date.now()},i=0,a=0;return{history:[s,...e.history.filter(e=>e.id!==s.id)].filter(e=>!(i>=200)&&!(a+e.sql.length>1e6)&&(i+=1,a+=e.sql.length,!0))}}),remove:t=>e(e=>({history:e.history.filter(e=>e.id!==t)}))}),{name:i}))},96365:(e,t,r)=>{"use strict";r.d(t,{QueryView:()=>q});var n=r(95155),o=r(12115),l=r(13267),s=r(36331),i=r(17491),a=r(48861),c=r(89239),u=r(27529),d=r(96532),m=r(43262),h=r(34263),f=r(40980),x=r(55737),g=r(82228),p=r(46732),b=r(14097),v=r(27071),j=r(89561),k=r(32638);let w=[j.Lz.theme({"&":{height:"100%",backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"13px"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace",lineHeight:"1.6",overflow:"auto"},".cm-content":{padding:"10px 0",caretColor:"var(--foreground)"},".cm-line":{padding:"0 16px 0 8px"},".cm-gutters":{backgroundColor:"color-mix(in oklch, var(--muted) 35%, var(--background))",color:"var(--muted-foreground)",borderRight:"1px solid var(--border)"},".cm-lineNumbers .cm-gutterElement":{minWidth:"42px",padding:"0 10px 0 6px"},".cm-activeLine":{backgroundColor:"color-mix(in oklch, var(--muted) 42%, transparent)"},".cm-activeLineGutter":{backgroundColor:"color-mix(in oklch, var(--muted) 68%, var(--background))",color:"var(--foreground)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"color-mix(in oklch, var(--primary) 18%, transparent) !important"},".cm-matchingBracket":{backgroundColor:"color-mix(in oklch, var(--primary) 16%, transparent)",outline:"1px solid color-mix(in oklch, var(--primary) 32%, transparent)"},".cm-tooltip":{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",backgroundColor:"var(--popover)",color:"var(--popover-foreground)",overflow:"hidden"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:"var(--accent)",color:"var(--accent-foreground)"}}),(0,p.y9)(p.cr.define([{tag:k._A.keyword,color:"var(--chart-1)",fontWeight:"600"},{tag:[k._A.string,k._A.special(k._A.string)],color:"var(--chart-2)"},{tag:[k._A.number,k._A.bool,k._A.null],color:"var(--chart-3)"},{tag:[k._A.typeName,k._A.className],color:"var(--chart-4)"},{tag:k._A.function(k._A.variableName),color:"var(--chart-4)"},{tag:k._A.comment,color:"var(--muted-foreground)",fontStyle:"italic"},{tag:[k._A.operator,k._A.punctuation],color:"var(--foreground)",opacity:"0.72"}]))],y=(0,o.forwardRef)(function({value:e,schema:t,maxLength:r,onChange:l,onRun:s,onLimitExceeded:i},a){let c=(0,o.useRef)(null),u=(0,o.useRef)(s);u.current=s;let d=(0,o.useRef)(i);d.current=i;let m=(0,o.useMemo)(()=>[(0,b.ll)({dialect:b.Rv,schema:t}),v.$t.changeFilter.of(e=>e.newDoc.length<=r||(queueMicrotask(()=>d.current()),!1)),j.Lz.contentAttributes.of({"aria-label":"SQL query editor"}),v.Nb.highest(j.w4.of([{key:"Mod-Enter",run:()=>(u.current(),!0)}])),j.w4.of([g.Yc])],[r,t]);return(0,o.useImperativeHandle)(a,()=>({focus(e=!1){let t=c.current;if(t){if(e){let e=t.state.doc.length;t.dispatch({selection:{anchor:e},scrollIntoView:!0})}t.focus()}},selectedText(){let e=c.current;if(!e)return"";let t=e.state.selection.main;return t.empty?"":e.state.sliceDoc(t.from,t.to)}})),(0,n.jsx)(x.Ay,{className:"h-full",value:e,height:"100%",theme:w,extensions:m,placeholder:"select *\nfrom public.users\nlimit 100;",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!1,highlightActiveLine:!0,highlightSelectionMatches:!0},onCreateEditor:e=>{c.current=e},onChange:l})});function N({statement:e}){return(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[(0,n.jsxs)("table",{className:"min-w-full border-separate border-spacing-0 font-mono text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"sticky top-0 left-0 z-20 h-9 w-10 border-r border-b bg-muted px-2 text-right font-normal text-muted-foreground",children:"#"}),e.columns.map((e,t)=>(0,n.jsx)("th",{className:"sticky top-0 z-10 h-9 min-w-32 border-r border-b bg-muted px-3 text-left font-medium whitespace-nowrap text-foreground last:border-r-0",children:e},`${e}:${t}`))]})}),(0,n.jsx)("tbody",{children:e.rows.map((t,r)=>(0,n.jsxs)("tr",{className:"group hover:bg-muted/45",children:[(0,n.jsx)("th",{className:"sticky left-0 z-10 h-8 border-r border-b bg-background px-2 text-right font-normal text-muted-foreground group-hover:bg-muted",children:r+1}),e.columns.map((e,r)=>{let o=t[r]??null,l=null===o?"null":String(o);return(0,n.jsx)("td",{title:l,className:"h-8 max-w-96 min-w-32 border-r border-b px-3 whitespace-nowrap last:border-r-0",children:(0,n.jsx)("span",{className:null===o?"text-muted-foreground/65":"block max-w-96 truncate text-foreground/90",children:l})},`${e}:${r}`)})]},r))})]}),0===e.rows.length?(0,n.jsx)("p",{className:"p-8 text-center text-sm text-muted-foreground",children:"Query returned no rows."}):null]})}function C({result:e,loading:t}){let[r,s]=(0,o.useState)({source:null,index:0});if(!e)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Run a query or migration to see its results."});let i=r.index;r.source!==e&&(i=Math.max(0,e.statements.length-1),s({source:e,index:i}));let a=e.statements[i];if(!a)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Execution completed without a result."});let c=function(e){if(e.truncated)return`${e.rows.length.toLocaleString()}+ rows`;let t=e.rowCount??e.rows.length;return 0===e.columns.length&&null===e.rowCount?null:`${t.toLocaleString()} ${1===t?"row":"rows"}`}(a);return(0,n.jsxs)("div",{className:(0,f.cn)("flex min-h-0 flex-1 flex-col",t&&"opacity-55"),"data-query-results":"",children:[(0,n.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,n.jsx)("span",{className:"mr-1 shrink-0 font-medium",children:"Results"}),e.statements.length>1?e.statements.map((t,r)=>(0,n.jsxs)("button",{type:"button","aria-pressed":r===i,onClick:()=>s({source:e,index:r}),className:(0,f.cn)("h-6 shrink-0 rounded-md px-2 font-mono text-[11px] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",r===i&&"bg-muted text-foreground"),children:[r+1," ",t.command]},r)):(0,n.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a.command}),c?(0,n.jsxs)("span",{className:"ml-1 shrink-0 text-muted-foreground",children:["\xb7 ",c]}):null,a.truncated?(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["\xb7 limited to ",a.rows.length]}):null,(0,n.jsxs)("span",{className:"ml-auto shrink-0 font-mono tabular-nums text-muted-foreground",children:[e.durationMs.toLocaleString()," ms"]})]}),a.columns.length>0?(0,n.jsx)(N,{statement:a}):(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-8 text-center",children:[(0,n.jsx)(l.Ykz,{className:"size-5 text-emerald-600 dark:text-emerald-400"}),(0,n.jsxs)("p",{className:"font-medium",children:[a.command," completed"]}),c?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c," affected"]}):null]})]})}var S=r(7412),A=r(19065);function E(e){return(e.split(/\r?\n/).find(e=>e.trim())?.trim()??e).replace(/\s+/g," ")}function L({connectionId:e,search:t,onSelect:r}){let s=(0,h.En)(e=>e.history),i=(0,h.En)(e=>e.remove),a=(0,o.useMemo)(()=>s.filter(t=>t.connectionId===e),[e,s]),c=(0,o.useMemo)(()=>t.trim()?(0,A.UO)(t,a,e=>[E(e.sql),e.sql]).map(e=>e.item):a,[a,t]);return 0===c.length?(0,n.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:0===a.length?"Queries you run will appear here.":"No matching queries."}):(0,n.jsx)("ul",{className:"flex flex-col gap-1 p-1.5",children:c.map(e=>{var t;return(0,n.jsxs)("li",{className:"group flex items-start rounded-md hover:bg-muted/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.sql),title:e.sql,className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,n.jsx)("span",{className:"block truncate font-mono text-xs text-foreground/90",children:E(e.sql)}),(0,n.jsx)("span",{className:"mt-1 block text-[10px] text-muted-foreground",children:(t=e.executedAt,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t))})]}),(0,n.jsx)("button",{type:"button",onClick:()=>i(e.id),"aria-label":"Remove query from history",title:"Remove from history",className:"mt-1.5 mr-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none hover:bg-foreground/10 hover:text-destructive focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover:opacity-100",children:(0,n.jsx)(l.mYx,{className:"size-3.5"})})]},e.id)})})}function $({connectionId:e,onSelectHistory:t}){let[r,l]=(0,o.useState)("");return(0,n.jsxs)("aside",{className:"flex w-72 max-w-[35%] shrink-0 flex-col border-l bg-sidebar","aria-label":"Query history",children:[(0,n.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-2",children:(0,n.jsx)(S.L,{value:r,onChange:e=>l(e.target.value),placeholder:"Search history","aria-label":"Search query history",className:"min-w-0 flex-1"})}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,n.jsx)(L,{connectionId:e,search:r,onSelect:t})})]})}let _=new Set(["SELECT","SHOW","EXPLAIN","FETCH"]);function q(){let{connection:e,tables:t}=(0,s.k)(),r=(0,h.En)(t=>t.drafts[e.id]??""),x=(0,h.En)(e=>e.setDraft),g=(0,h.En)(e=>e.record),p=(0,h.En)(e=>e.editorHeight),b=(0,h.En)(e=>e.setEditorHeight),[v,j]=(0,o.useState)(null),[k,w]=(0,o.useState)(null),[N,S]=(0,o.useState)(!1),A=(0,o.useRef)(null),E=(0,o.useRef)(null),L=(0,o.useRef)(null),q=(0,a.Q)(e.id),R=q.back?.route.kind==="migration"&&q.back.route.connectionId===e.id?q.back:null,z=(0,o.useMemo)(()=>{let e={};for(let r of t.data??[])(e[r.schema]??={})[r.name]=r.columns.map(e=>e.name);return e},[t.data]);async function H(){if(N)return;let n=A.current?.selectedText().trim()||r.trim();if(!n){w("Enter a query to run."),A.current?.focus();return}let o=new AbortController;L.current=o,g(e.id,n),S(!0),w(null);try{let r=await u.F.query(e.url,n,o.signal);j(r),r.statements.some(e=>!_.has(e.command))&&t.reload()}catch(e){if(o.signal.aborted)return;w(e instanceof Error?e.message:String(e))}finally{L.current===o&&(L.current=null,S(!1))}}return(0,o.useEffect)(()=>()=>L.current?.abort(),[]),(0,o.useEffect)(()=>{let e=E.current;if(!e)return;let t=null,r=new ResizeObserver(()=>{null!==t&&window.clearTimeout(t),t=window.setTimeout(()=>b(e.offsetHeight),200)});return r.observe(e),()=>{null!==t&&window.clearTimeout(t),r.disconnect()}},[b]),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("section",{className:"flex min-w-0 flex-1 flex-col",children:[(0,n.jsxs)(i.X,{children:[(0,n.jsx)(l.Uoo,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"font-medium",children:"Query"}),R&&(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",title:`Back to ${R.label} (${m.Ar.back})`,onClick:q.goBack,children:[(0,n.jsx)(l.a7N,{"data-icon":"inline-start"}),(0,n.jsx)("span",{className:"max-w-40 truncate",children:R.label})]}),(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:(0,f.cn)(!R&&"ml-auto"),disabled:N||!r,onClick:function(){x(e.id,""),w(null),A.current?.focus()},children:[(0,n.jsx)(l.GVO,{"data-icon":"inline-start"}),"Clear"]}),(0,n.jsxs)(c.$,{type:"button",size:"sm",disabled:N||!r.trim(),title:"Run the selection or the whole script (⌘↵)",onClick:()=>void H(),children:[N?(0,n.jsx)(l.gnh,{"data-icon":"inline-start",className:"animate-spin"}):(0,n.jsx)(l.eGB,{"data-icon":"inline-start"}),N?"Running":"Run"]})]}),(0,n.jsx)("div",{ref:E,style:{height:p,minHeight:h.jl,maxHeight:h.Pc},className:"max-h-[55vh] shrink-0 resize-y overflow-hidden border-b bg-background",children:(0,n.jsx)(y,{ref:A,value:r,schema:z,maxLength:d.H4,onChange:t=>x(e.id,t),onRun:()=>void H(),onLimitExceeded:()=>w(`Query is too long (maximum ${d.H4.toLocaleString()} characters).`)})}),k?(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:(0,n.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-xs whitespace-pre-wrap text-destructive",children:k})}):(0,n.jsx)(C,{result:v,loading:N})]}),(0,n.jsx)($,{connectionId:e.id,onSelectHistory:function(t){x(e.id,t),w(null),window.requestAnimationFrame(()=>A.current?.focus(!0))}})]})}},96532:(e,t,r)=>{"use strict";r.d(t,{H4:()=>o,d6:()=>n});let n=1e4,o=5e5}},e=>{e.O(0,[4506,6079,1731,8026,9159,4097,1981,9243,8441,3794,7358],()=>e(e.s=21281)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4909,5047,5374,5721,5794,6258,6306,6636,6819,6988,7761,7851,7981,8167,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
|