planche 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/app/assets/{aL0ab6hA.js → 1E6FYbv2.js} +1 -1
  2. package/app/assets/B-Mrqvrb.css +2 -0
  3. package/app/assets/{C-MJZp-k.js → B3uI9Ppb.js} +1 -1
  4. package/app/assets/{g4S828aR.js → B5OocgEJ.js} +1 -1
  5. package/app/assets/{B6gKGoJk.js → B8xQ2o-X.js} +1 -1
  6. package/app/assets/{3tVT9YMh.js → BGOnv2_O.js} +1 -1
  7. package/app/assets/{B2VNJYl8.js → BIjF9ulh.js} +1 -1
  8. package/app/assets/{DURNOOys.js → Bpg8LzYe.js} +1 -1
  9. package/app/assets/{BxOkJTYb.js → BunrDTHn.js} +1 -1
  10. package/app/assets/{Brk9GcZh.js → C3bMAsUp.js} +1 -1
  11. package/app/assets/{BQ74FNAM.js → C4il2fft.js} +1 -1
  12. package/app/assets/{1qhRpHKv.js → COIa4uoZ.js} +1 -1
  13. package/app/assets/{8OZbP3hw.js → CkgLFvM5.js} +1 -1
  14. package/app/assets/{nij0MMY5.js → Cx_chT_j.js} +1 -1
  15. package/app/assets/{2sxOfzyn.js → D7Ze5md9.js} +5 -5
  16. package/app/assets/{D2AdQhHv.js → DFNc4ghA.js} +1 -1
  17. package/app/assets/{vIgrQ7V1.js → DGD5v9rw.js} +1 -1
  18. package/app/assets/{f1Yh3VFu.js → DZH-tLW-.js} +1 -1
  19. package/app/assets/{DkdStXtl.js → D_2UqK4k.js} +1 -1
  20. package/app/assets/{BCZ2DwDi.js → Dd9Cr3e8.js} +1 -1
  21. package/app/assets/{7D95fvkQ.js → Dh3YJ3G1.js} +1 -1
  22. package/app/assets/{BrwCR6-9.js → DiaA_DOW.js} +1 -1
  23. package/app/assets/{D98JmiqU.js → DlKZCiMg.js} +2 -2
  24. package/app/assets/{MdnUPkBs.js → DmejZTwI.js} +1 -1
  25. package/app/assets/{OQSC6nip.js → DnjY8W6t.js} +1 -1
  26. package/app/assets/{C3uDTQB5.js → FnB_uI57.js} +1 -1
  27. package/app/assets/{oSIomP-s.js → IzH8qyLi.js} +1 -1
  28. package/app/assets/{CCBE6CSG.js → NY_tAtcY.js} +1 -1
  29. package/app/assets/{q4qvsmm4.js → QBd1UkiI.js} +1 -1
  30. package/app/assets/{DCkfyKy4.js → RIOwEE7M.js} +1 -1
  31. package/app/assets/{Bfw0mW2q.js → S4Oofhu9.js} +1 -1
  32. package/app/assets/{B4qi_yRV.js → cc05Z2oj.js} +1 -1
  33. package/app/assets/{B_0rFJQl.js → dxLVUFtU.js} +1 -1
  34. package/app/assets/{Clm7zeUD.js → fCzQKDqY.js} +1 -1
  35. package/app/assets/{BmSO6bVX.js → og5dTmtH.js} +1 -1
  36. package/app/assets/{Bfuq7Ecs.js → qbvehL2h.js} +1 -1
  37. package/app/index.html +3 -3
  38. package/package.json +1 -1
  39. package/app/assets/ZV96pIZb.css +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/B_0rFJQl.js","assets/hePW80VL.js","assets/XzPc-eVf.js","assets/CKOS5Y-e.js","assets/DkdStXtl.js","assets/CZQ1r4zz.js","assets/CmJ3siBN.js","assets/DTxGpkJp.js","assets/eFSiW0Lh.js","assets/BBSxV90W.js","assets/BdPEUnLq.js","assets/ClyAuDY9.js","assets/Bit0Kfog.js","assets/CChaTOPr.js","assets/Cw_LYT6k.js","assets/C1RY7wUM.js","assets/DxuXBECK.js","assets/oSIomP-s.js","assets/DbRMSZEW.js","assets/D98JmiqU.js","assets/DAFA-E1-.js","assets/CfsL8_WC.js","assets/BM5G_YA7.js","assets/7D95fvkQ.js","assets/g4S828aR.js","assets/C-MJZp-k.js","assets/CnYBZPf9.js","assets/BmSO6bVX.js","assets/aL0ab6hA.js","assets/MdnUPkBs.js","assets/B3LyCSVJ.js","assets/q4qvsmm4.js","assets/vIgrQ7V1.js","assets/OQSC6nip.js","assets/Bs5VSn0X.js","assets/DURNOOys.js","assets/3tVT9YMh.js","assets/rcI4Fmt0.js","assets/BQ74FNAM.js","assets/BCZ2DwDi.js","assets/DCkfyKy4.js","assets/nij0MMY5.js","assets/D-RWduy5.js","assets/C3uDTQB5.js","assets/f1Yh3VFu.js","assets/CCBE6CSG.js","assets/B2VNJYl8.js","assets/B4qi_yRV.js","assets/Bfw0mW2q.js","assets/B6gKGoJk.js","assets/1qhRpHKv.js","assets/Brk9GcZh.js","assets/BrwCR6-9.js","assets/8OZbP3hw.js","assets/neLPq0_M.js","assets/Clm7zeUD.js","assets/BxOkJTYb.js","assets/Bfuq7Ecs.js","assets/D2AdQhHv.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t,t as n}from"./hePW80VL.js";import{c as r,f as i,h as a,i as o,m as s,n as c,o as l,r as u,s as d,u as f}from"./XzPc-eVf.js";import{_ as p,a as m,b as h,c as g,d as _,g as v,h as y,i as b,l as x,m as S,n as C,o as w,p as ee,r as te,s as T,t as ne,u as re,v as ie,y as ae}from"./CKOS5Y-e.js";import{a as E,i as oe,n as se,o as ce,r as le,t as ue}from"./ClyAuDY9.js";import{S as de,_ as fe,a as pe,b as me,c as he,d as ge,f as _e,g as ve,h as ye,i as be,l as xe,m as Se,n as Ce,o as we,p as Te,r as Ee,s as De,t as Oe,u as ke,v as Ae,x as je,y as Me}from"./CZQ1r4zz.js";import{i as Ne,t as Pe}from"./eFSiW0Lh.js";import{C as Fe,D as Ie,E as Le,O as Re,S as ze,_ as Be,b as Ve,c as He,d as Ue,i as We,l as Ge,o as Ke,s as qe,t as Je,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./DTxGpkJp.js";import{n as et,r as tt}from"./BBSxV90W.js";import{C as nt,D as rt,E as it,T as at,_ as ot,a as st,d as ct,f as lt,g as ut,h as dt,n as ft,o as pt,r as mt,v as ht,x as gt}from"./BdPEUnLq.js";import{n as _t,t as vt}from"./CChaTOPr.js";import{S as yt,_ as bt,a as xt,b as St,c as Ct,d as wt,f as Tt,h as Et,i as Dt,m as Ot,n as kt,o as At,p as jt,r as Mt,s as Nt,t as Pt,u as Ft,v as It,x as Lt,y as Rt}from"./Cw_LYT6k.js";import{i as zt,n as Bt,t as Vt}from"./C1RY7wUM.js";import{n as Ht,r as Ut}from"./DbRMSZEW.js";import{a as Wt,c as Gt,l as Kt,r as qt}from"./DAFA-E1-.js";import{a as Jt,c as Yt,f as Xt,i as Zt,n as Qt,o as $t,r as en,s as tn,u as nn}from"./CfsL8_WC.js";import{a as rn,i as an,n as on,r as sn,s as cn}from"./BM5G_YA7.js";import{_ as ln,a as un,c as dn,d as fn,f as pn,g as mn,h as hn,i as gn,l as _n,n as vn,o as yn,p as bn,r as xn,s as Sn,t as Cn,u as wn,v as Tn}from"./D98JmiqU.js";import{t as En}from"./B3LyCSVJ.js";import{t as Dn}from"./Bs5VSn0X.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var On=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}}var S=!1,C=-1,w=5,ee=-1;function te(){return g?!0:!(e.unstable_now()-ee<w)}function T(){if(g=!1,S){var t=e.unstable_now();ee=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function ae(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=n(((e,t)=>{t.exports=On()})),kn=n((e=>{var t=eee(),n=a(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return u(a),e;if(o===r)return u(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var E=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===E?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case ee:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,ce=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function he(e,t){fe++,de[fe]=e.current,e.current=t}var ge=pe(null),_e=pe(null),ve=pe(null),ye=pe(null);function be(e,t){switch(he(ve,t),he(_e,e),he(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Wd(t),e=Gd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(ge),he(ge,e)}function xe(){me(ge),me(_e),me(ve)}function Se(e){e.memoizedState!==null&&he(ye,e);var t=ge.current,n=Gd(t,e.type);t!==n&&(he(_e,e),he(ge,n))}function Ce(e){_e.current===e&&(me(ge),me(_e)),ye.current===e&&(me(ye),Xf._currentValue=ue)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dxLVUFtU.js","assets/hePW80VL.js","assets/XzPc-eVf.js","assets/CKOS5Y-e.js","assets/D_2UqK4k.js","assets/CZQ1r4zz.js","assets/CmJ3siBN.js","assets/DTxGpkJp.js","assets/eFSiW0Lh.js","assets/BBSxV90W.js","assets/BdPEUnLq.js","assets/ClyAuDY9.js","assets/Bit0Kfog.js","assets/CChaTOPr.js","assets/Cw_LYT6k.js","assets/C1RY7wUM.js","assets/DxuXBECK.js","assets/IzH8qyLi.js","assets/DbRMSZEW.js","assets/DlKZCiMg.js","assets/DAFA-E1-.js","assets/CfsL8_WC.js","assets/BM5G_YA7.js","assets/Dh3YJ3G1.js","assets/B5OocgEJ.js","assets/B3uI9Ppb.js","assets/CnYBZPf9.js","assets/og5dTmtH.js","assets/1E6FYbv2.js","assets/DmejZTwI.js","assets/B3LyCSVJ.js","assets/QBd1UkiI.js","assets/DGD5v9rw.js","assets/DnjY8W6t.js","assets/Bs5VSn0X.js","assets/Bpg8LzYe.js","assets/BGOnv2_O.js","assets/rcI4Fmt0.js","assets/C4il2fft.js","assets/Dd9Cr3e8.js","assets/RIOwEE7M.js","assets/Cx_chT_j.js","assets/D-RWduy5.js","assets/FnB_uI57.js","assets/DZH-tLW-.js","assets/NY_tAtcY.js","assets/BIjF9ulh.js","assets/cc05Z2oj.js","assets/S4Oofhu9.js","assets/B8xQ2o-X.js","assets/COIa4uoZ.js","assets/C3bMAsUp.js","assets/DiaA_DOW.js","assets/CkgLFvM5.js","assets/neLPq0_M.js","assets/fCzQKDqY.js","assets/BunrDTHn.js","assets/qbvehL2h.js","assets/DFNc4ghA.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./hePW80VL.js";import{c as r,f as i,h as a,i as o,m as s,n as c,o as l,r as u,s as d,u as f}from"./XzPc-eVf.js";import{_ as p,a as m,b as h,c as g,d as _,g as v,h as y,i as b,l as x,m as S,n as C,o as w,p as ee,r as te,s as T,t as ne,u as re,v as ie,y as ae}from"./CKOS5Y-e.js";import{a as E,i as oe,n as se,o as ce,r as le,t as ue}from"./ClyAuDY9.js";import{S as de,_ as fe,a as pe,b as me,c as he,d as ge,f as _e,g as ve,h as ye,i as be,l as xe,m as Se,n as Ce,o as we,p as Te,r as Ee,s as De,t as Oe,u as ke,v as Ae,x as je,y as Me}from"./CZQ1r4zz.js";import{i as Ne,t as Pe}from"./eFSiW0Lh.js";import{C as Fe,D as Ie,E as Le,O as Re,S as ze,_ as Be,b as Ve,c as He,d as Ue,i as We,l as Ge,o as Ke,s as qe,t as Je,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./DTxGpkJp.js";import{n as et,r as tt}from"./BBSxV90W.js";import{C as nt,D as rt,E as it,T as at,_ as ot,a as st,d as ct,f as lt,g as ut,h as dt,n as ft,o as pt,r as mt,v as ht,x as gt}from"./BdPEUnLq.js";import{n as _t,t as vt}from"./CChaTOPr.js";import{S as yt,_ as bt,a as xt,b as St,c as Ct,d as wt,f as Tt,h as Et,i as Dt,m as Ot,n as kt,o as At,p as jt,r as Mt,s as Nt,t as Pt,u as Ft,v as It,x as Lt,y as Rt}from"./Cw_LYT6k.js";import{i as zt,n as Bt,t as Vt}from"./C1RY7wUM.js";import{n as Ht,r as Ut}from"./DbRMSZEW.js";import{a as Wt,c as Gt,l as Kt,r as qt}from"./DAFA-E1-.js";import{a as Jt,c as Yt,f as Xt,i as Zt,n as Qt,o as $t,r as en,s as tn,u as nn}from"./CfsL8_WC.js";import{a as rn,i as an,n as on,r as sn,s as cn}from"./BM5G_YA7.js";import{_ as ln,a as un,c as dn,d as fn,f as pn,g as mn,h as hn,i as gn,l as _n,n as vn,o as yn,p as bn,r as xn,s as Sn,t as Cn,u as wn,v as Tn}from"./DlKZCiMg.js";import{t as En}from"./B3LyCSVJ.js";import{t as Dn}from"./Bs5VSn0X.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var On=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ne());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}}var S=!1,C=-1,w=5,ee=-1;function te(){return g?!0:!(e.unstable_now()-ee<w)}function T(){if(g=!1,S){var t=e.unstable_now();ee=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ne():S=!1}}}var ne;if(typeof y==`function`)ne=function(){y(T)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=T,ne=function(){ie.postMessage(null)}}else ne=function(){_(T,0)};function ae(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ne()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=n(((e,t)=>{t.exports=On()})),kn=n((e=>{var t=eee(),n=a(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return u(a),e;if(o===r)return u(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var E=Symbol.for(`react.client.reference`);function oe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===E?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case ee:return`SuspenseList`;case ne:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var se=Array.isArray,ce=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function he(e,t){fe++,de[fe]=e.current,e.current=t}var ge=pe(null),_e=pe(null),ve=pe(null),ye=pe(null);function be(e,t){switch(he(ve,t),he(_e,e),he(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Wd(t),e=Gd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(ge),he(ge,e)}function xe(){me(ge),me(_e),me(ve)}function Se(e){e.memoizedState!==null&&he(ye,e);var t=ge.current,n=Gd(t,e.type);t!==n&&(he(_e,e),he(ge,n))}function Ce(e){_e.current===e&&(me(ge),me(_e)),ye.current===e&&(me(ye),Xf._currentValue=ue)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -929,7 +929,7 @@ WHERE`).replace(/\s+;$/,`;`),s,E.t(`query.tabs.queryTitle`,{n:(_t.getState().tab
929
929
  `)||e.length>140;return(0,$.jsx)(`div`,{className:`mt-1 min-w-0`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-1`,children:[c?(0,$.jsx)(`button`,{type:`button`,className:`mt-0.5 shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>i(e=>!e),title:n(r?`result.message.hideSql`:`result.message.showSql`),children:r?(0,$.jsx)(b6,{className:`size-3`}):(0,$.jsx)(x6,{className:`size-3`})}):(0,$.jsx)(`span`,{className:`w-3 shrink-0`}),(0,$.jsx)(`pre`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-xs ${t===`error`?`text-destructive/90`:`text-muted-foreground`}`,children:r?e.trim():g3e(e)}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100`,onClick:s,title:n(`result.message.copy`),children:a?(0,$.jsx)(y6,{className:`size-3`}):(0,$.jsx)(E6,{className:`size-3`})})]})})}function v3e({hint:e}){let{t}=S(),n=e.params;switch(e.code){case`unknownColumn`:return(0,$.jsx)($.Fragment,{children:t(`result.hints.unknownColumn`,{name:n.name,suggestions:n.suggestions})});case`unknownTable`:return(0,$.jsx)($.Fragment,{children:t(`result.hints.unknownTable`,{name:n.name,suggestions:n.suggestions})});case`syntaxSwap`:return(0,$.jsx)($.Fragment,{children:t(`result.hints.syntaxSwap`,{engine:n.engine,found:n.found,expected:n.expected})});case`doubleQuotedLiteral`:return(0,$.jsx)($.Fragment,{children:t(`result.hints.doubleQuotedLiteral`,{engine:n.engine,value:n.value})})}}function y3e({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt).find(e=>e.id===t),i=r?.results??[],a=r?.error??null,o=r?.errorSql??null,s=r?.executionTime??null,c=r?.isExecuting??!1,[l,u]=(0,D.useState)([]),[d,f]=(0,D.useState)(!1),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(!a){u([]);return}let n=!0;return en(e,t).then(e=>n&&u(e)).catch(()=>n&&u([])),()=>{n=!1}},[e,t,a,o]),(0,D.useEffect)(()=>{if(g(null),v(null),!a)return;let e=!0;return s3e().then(t=>e&&f(t)),()=>{e=!1}},[e,t,a,o]);let y=(0,D.useCallback)(()=>{m(!0),v(null),l3e(e,t).then(g).catch(e=>v(e instanceof Error?e.message:String(e))).finally(()=>m(!1))},[e,t]);if(c)return(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(M6,{className:`size-4 animate-spin`}),n(`result.message.executing`)]});if(i.length===0&&!a)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:n(`result.message.ready`)});let b=+!!a;return(0,$.jsx)(K6,{className:`h-full`,children:(0,$.jsxs)(`div`,{className:`p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n(`result.message.log`)}),s!=null&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(w6,{className:`size-3`}),n(`result.message.summary`,{ok:i.length,failed:b,ms:h3e(s)})]})]}),(0,$.jsxs)(`ol`,{className:`divide-y divide-border/60 rounded-md border`,children:[i.map((e,t)=>{let r=e.fields.length>0;return(0,$.jsxs)(`li`,{className:`group flex gap-2 px-3 py-2`,children:[e.limited||e.warning?(0,$.jsx)(W6,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-yellow`}):(0,$.jsx)(S6,{className:`mt-0.5 size-4 shrink-0 text-green-500`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`result.message.statementN`,{n:t+1})}),(0,$.jsx)(`span`,{className:e.limited?`text-catppuccin-yellow`:``,children:e.message}),e.limited&&(0,$.jsx)(`span`,{className:`rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold uppercase text-catppuccin-yellow`,children:n(`result.message.limitedBadge`)}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground tabular-nums`,children:[r&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(R6,{className:`size-3`}),e.rows.length.toLocaleString()]}),!r&&e.affectedRows>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(P6,{className:`size-3`}),e.affectedRows.toLocaleString()]}),e.insertId>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(Q$e,{className:`size-3`}),n(`result.message.insertId`,{id:e.insertId})]}),e.executionTime!=null&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(w6,{className:`size-3`}),h3e(e.executionTime)]})]})]}),e.warning&&(0,$.jsx)(`div`,{className:`mt-1 text-[11px] text-catppuccin-yellow`,children:e.warning}),e.sql&&(0,$.jsx)(_3e,{sql:e.sql})]})]},t)}),a&&(0,$.jsxs)(`li`,{className:`group flex gap-2 bg-destructive/5 px-3 py-2`,children:[(0,$.jsx)(C6,{className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-2`,children:(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-destructive`,children:i.length>0?n(`result.message.statementN`,{n:i.length+1}):n(`result.message.failed`)})}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-destructive`,children:a}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:n(`result.message.failedStatement`)}),(0,$.jsx)(_3e,{sql:o,tone:`error`})]}),l.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-border/60 bg-background/60 p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(r1e,{className:`size-3`}),n(`result.hints.title`)]}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:l.map((e,t)=>(0,$.jsx)(`li`,{className:`text-xs leading-relaxed`,children:(0,$.jsx)(v3e,{hint:e})},t))})]}),d&&!h&&(0,$.jsxs)(`button`,{type:`button`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-60`,onClick:y,disabled:p,children:[p?(0,$.jsx)(M6,{className:`size-3 animate-spin`}):(0,$.jsx)(B6,{className:`size-3`}),n(p?`result.ai.thinking`:`result.ai.explain`)]}),_&&(0,$.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:n(`result.ai.failed`,{message:_})}),h&&(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-border/60 bg-background/60 p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(B6,{className:`size-3`}),n(`result.ai.title`),(0,$.jsx)(`span`,{className:`font-normal normal-case tracking-normal`,children:n(`result.ai.by`,{model:h.model})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed`,children:h.explanation}),h.fix&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded border bg-muted/50 p-2 font-mono text-[11px]`,children:h.fix}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-1.5 inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground`,onClick:()=>i8(e,h.fix,r?.database??``,n(`result.ai.title`)),children:[(0,$.jsx)(j$e,{className:`size-3`}),n(`result.ai.applyFix`)]})]})]})]})]})]})]})})}function b3e(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e}}function O5(e,t){return typeof e==`function`?e(t):e}function k5(e,t){return n=>{t.setState(t=>({...t,[e]:O5(n,t[e])}))}}function A5(e){return e instanceof Function}function x3e(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function S3e(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function j5(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
930
930
  font-size: .6rem;
931
931
  font-weight: bold;
932
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function M5(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function C3e(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:j5(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),M5(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function w3e(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:j5(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],M5(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:j5(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},M5(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var N5=`debugHeaders`;function T3e(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var E3e={createTable:e=>{e.getHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return P5(t,[...a,...s,...o],e)},M5(e.options,N5,`getHeaderGroups`)),e.getCenterHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),P5(t,n,e,`center`)),M5(e.options,N5,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>P5(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),M5(e.options,N5,`getLeftHeaderGroups`)),e.getRightHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>P5(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),M5(e.options,N5,`getRightHeaderGroups`)),e.getFooterGroups=j5(()=>[e.getHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getFooterGroups`)),e.getLeftFooterGroups=j5(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getLeftFooterGroups`)),e.getCenterFooterGroups=j5(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getCenterFooterGroups`)),e.getRightFooterGroups=j5(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getRightFooterGroups`)),e.getFlatHeaders=j5(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getFlatHeaders`)),e.getLeftFlatHeaders=j5(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=j5(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getCenterFlatHeaders`)),e.getRightFlatHeaders=j5(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getRightFlatHeaders`)),e.getCenterLeafHeaders=j5(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=j5(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getLeftLeafHeaders`)),e.getRightLeafHeaders=j5(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getRightLeafHeaders`)),e.getLeafHeaders=j5(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),M5(e.options,N5,`getLeafHeaders`))}};function P5(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=T3e(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>T3e(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var D3e=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>S3e(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:j5(()=>[e.getAllLeafColumns()],t=>t.map(t=>C3e(e,s,t,t.id)),M5(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:j5(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),M5(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},O3e={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},k3e=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!((i=e.getValue(t))!=null&&(i=i.toString())!=null&&(i=i.toLowerCase())!=null&&i.includes(a))};k3e.autoRemove=e=>L5(e);var A3e=(e,t,n)=>{var r;return!!((r=e.getValue(t))!=null&&(r=r.toString())!=null&&r.includes(n))};A3e.autoRemove=e=>L5(e);var j3e=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};j3e.autoRemove=e=>L5(e);var M3e=(e,t,n)=>e.getValue(t)?.includes(n);M3e.autoRemove=e=>L5(e);var N3e=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});N3e.autoRemove=e=>L5(e)||!(e!=null&&e.length);var P3e=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));P3e.autoRemove=e=>L5(e)||!(e!=null&&e.length);var F3e=(e,t,n)=>e.getValue(t)===n;F3e.autoRemove=e=>L5(e);var I3e=(e,t,n)=>e.getValue(t)==n;I3e.autoRemove=e=>L5(e);var F5=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};F5.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},F5.autoRemove=e=>L5(e)||L5(e[0])&&L5(e[1]);var I5={includesString:k3e,includesStringSensitive:A3e,equalsString:j3e,arrIncludes:M3e,arrIncludesAll:N3e,arrIncludesSome:P3e,equals:F3e,weakEquals:I3e,inNumberRange:F5};function L5(e){return e==null||e===``}var L3e={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:k5(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?I5.includesString:typeof n==`number`?I5.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?I5.equals:Array.isArray(n)?I5.arrIncludes:I5.weakEquals},e.getFilterFn=()=>A5(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??I5[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=O5(n,i?i.value:void 0);if(R3e(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>O5(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&R3e(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function R3e(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var R5={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!x3e(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},z3e={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:k5(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return R5.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return R5.extent},e.getAggregationFn=()=>{if(!e)throw Error();return A5(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??R5[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function B3e(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var V3e={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:k5(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=j5(e=>[W5(t,e)],t=>t.findIndex(t=>t.id===e.id),M5(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>W5(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=W5(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=j5(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return B3e(i,t,n)},M5(e.options,`debugTable`,`_getOrderColumnsFn`))}},z5=()=>({left:[],right:[]}),H3e={getInitialState:e=>({columnPinning:z5(),...e}),getDefaultOptions:e=>({onColumnPinningChange:k5(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},M5(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),M5(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),M5(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?z5():e.initialState?.columnPinning??z5()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),M5(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),M5(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},M5(e.options,`debugColumns`,`getCenterLeafColumns`))}};function U3e(e){return e||(typeof document<`u`?document:null)}var B5={size:150,minSize:20,maxSize:2**53-1},V5=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),W3e={getDefaultColumnDef:()=>B5,getInitialState:e=>({columnSizing:{},columnSizingInfo:V5(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:k5(`columnSizing`,e),onColumnSizingInfoChange:k5(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??B5.minSize,n??e.columnDef.size??B5.size),e.columnDef.maxSize??B5.maxSize)},e.getStart=j5(e=>[e,W5(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),M5(t.options,`debugColumns`,`getStart`)),e.getAfter=j5(e=>[e,W5(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),M5(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),U5(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=U5(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=U3e(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=G3e()?{passive:!1}:!1;U5(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?V5():e.initialState.columnSizingInfo??V5())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},H5=null;function G3e(){if(typeof H5==`boolean`)return H5;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return H5=e,H5}function U5(e){return e.type===`touchstart`}var K3e={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:k5(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=j5(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),M5(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=j5(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],M5(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>j5(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),M5(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function W5(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var q3e={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},J3e={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:k5(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>I5.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return A5(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??I5[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},Y3e={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:k5(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0||!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},G5=0,K5=10,q5=()=>({pageIndex:G5,pageSize:K5}),X3e={getInitialState:e=>({...e,pagination:{...q5(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:k5(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>O5(t,e)),e.resetPagination=t=>{e.setPagination(t?q5():e.initialState.pagination??q5())},e.setPageIndex=t=>{e.setPagination(n=>{let r=O5(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?G5:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??G5)},e.resetPageSize=t=>{var n;e.setPageSize(t?K5:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??K5)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,O5(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=O5(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=j5(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},M5(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1||n!==0&&t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},J5=()=>({top:[],bottom:[]}),Z3e={getInitialState:e=>({rowPinning:J5(),...e}),getDefaultOptions:e=>({onRowPinningChange:k5(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?J5():e.initialState?.rowPinning??J5()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),M5(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),M5(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},M5(e.options,`debugRows`,`getCenterRows`))}},Q3e={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:k5(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{Y5(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return!e.getIsAllPageRowsSelected()&&t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return Y5(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return Z5(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return Q5(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return Q5(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},Y5=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>Y5(e,t.id,n,r,i))};function X5(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=Z5(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function Z5(e,t){return t[e.id]??!1}function Q5(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(Z5(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=Q5(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var $5=/([0-9]+)/gm,$3e=(e,t,n)=>a6e(t7(e.getValue(n)).toLowerCase(),t7(t.getValue(n)).toLowerCase()),e6e=(e,t,n)=>a6e(t7(e.getValue(n)),t7(t.getValue(n))),t6e=(e,t,n)=>e7(t7(e.getValue(n)).toLowerCase(),t7(t.getValue(n)).toLowerCase()),n6e=(e,t,n)=>e7(t7(e.getValue(n)),t7(t.getValue(n))),r6e=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},i6e=(e,t,n)=>e7(e.getValue(n),t.getValue(n));function e7(e,t){return e===t?0:e>t?1:-1}function t7(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function a6e(e,t){let n=e.split($5).filter(Boolean),r=t.split($5).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var n7={alphanumeric:$3e,alphanumericCaseSensitive:e6e,text:t6e,textCaseSensitive:n6e,datetime:r6e,basic:i6e},o6e=[E3e,K3e,V3e,H3e,O3e,L3e,q3e,J3e,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:k5(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return n7.datetime;if(typeof n==`string`&&(r=!0,n.split($5).length>1))return n7.alphanumeric}return r?n7.text:n7.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return A5(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??n7[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},z3e,Y3e,X3e,Z3e,Q3e,W3e];function s6e(e){let t=[...o6e,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{let t=O5(e,n.options);n.options=i(t)},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:j5(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),M5(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:j5(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=w3e(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},M5(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:j5(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),M5(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:j5(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),M5(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:j5(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),M5(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function c6e(){return e=>j5(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=D3e(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},M5(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function l6e(){return e=>j5(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;let r=e.getState().sorting,i=[],a=r.filter(t=>e.getColumn(t.id)?.getCanSort()),o={};a.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let s=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<a.length;n+=1){let r=a[n],i=o[r.id],s=i.sortUndefined,c=r?.desc??!1,l=0;if(s){let n=e.getValue(r.id),i=t.getValue(r.id),a=n===void 0,o=i===void 0;if(a||o){if(s===`first`)return a?-1:1;if(s===`last`)return a?1:-1;l=a&&o?0:a?s:-s}}if(l===0&&(l=i.sortingFn(e,t,r.id)),l!==0)return c&&(l*=-1),i.invertSorting&&(l*=-1),l}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),(t=e.subRows)!=null&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:i,rowsById:n.rowsById}},M5(e.options,`debugTable`,`getSortedRowModel`,()=>e._autoResetPageIndex()))}function u6e(e,t){return e?d6e(e)?D.createElement(e,t):e:null}function d6e(e){return f6e(e)||typeof e==`function`||p6e(e)}function f6e(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function p6e(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function m6e(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=D.useState(()=>({current:s6e(t)})),[r,i]=D.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}function h6e(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function r7(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function g6e(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var _6e=(e,t)=>Math.abs(e-t)<1.01,v6e=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},i7,a7=()=>{if(i7!==void 0)return i7;if(typeof navigator>`u`)return i7=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return i7=!0;let e=navigator.maxTouchPoints;return i7=navigator.platform===`MacIntel`&&e!==void 0&&e>0},y6e=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b6e=e=>e,x6e=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},S6e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y6e(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y6e(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},o7={passive:!0},C6e=typeof window>`u`||`onscrollend`in window,w6e=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&C6e,o=0,s=a?null:v6e(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,o7),a&&r.addEventListener(`scrollend`,u,o7),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},T6e=(e,t)=>w6e(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),E6e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},D6e=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},O6e=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b6e,rangeExtractor:x6e,onChange:()=>{},measureElement:E6e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=r7(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!a7()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,o7),e.addEventListener(`touchend`,n,o7),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(a7()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=r7(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=r7(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=h6e(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=r7(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=j6e(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=r7(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=r7(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return g6e(t[k6e(0,t.length-1,r?e=>n[e*2]:e=>g6e(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:a7()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&_6e(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},k6e=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function A6e(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function j6e(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=A6e(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=k6e(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var s7=typeof document<`u`?D.useLayoutEffect:D.useEffect;function M6e({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=D.useReducer(e=>e+1,0)[1],a=D.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,sJe.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=D.useState(()=>{let e=new O6e(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),s7(()=>l._didMount(),[]),s7(()=>(o(l),l._willUpdate())),s7(()=>{s(l)}),l}function N6e(e){return M6e({observeElementRect:S6e,observeElementOffset:T6e,scrollToFn:D6e,...e})}function P6e({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,$.jsx)(`table`,{"data-slot":`table`,className:w(`w-full caption-bottom text-sm`,e),...t})})}function F6e({className:e,...t}){return(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:w(`[&_tr]:border-b`,e),...t})}function I6e({className:e,...t}){return(0,$.jsx)(`tbody`,{"data-slot":`table-body`,className:w(`[&_tr:last-child]:border-0`,e),...t})}function c7({className:e,...t}){return(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:w(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function l7({className:e,...t}){return(0,$.jsx)(`th`,{"data-slot":`table-head`,className:w(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground border-r border-border last:border-r-0 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function u7({className:e,...t}){return(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:w(`p-2 align-middle whitespace-nowrap border-r border-border last:border-r-0 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function d7(e){if(typeof e!=`object`||!e||ArrayBuffer.isView(e))return null;try{return JSON.stringify(e)}catch{return null}}function f7(e){if(e==null)return` NULL`;if(typeof e==`object`)return e instanceof Uint8Array?` BIN${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`:d7(e)??String(e);if(typeof e==`boolean`)return e?`1`:`0`;let t=String(e),n=t.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.000)?Z?$/);return n?`${n[1]} ${n[2]}`:/^-?\d+\.\d*0+$/.test(t)?t.replace(/\.?0+$/,``):t}var L6e=(e,t)=>t.map(t=>f7(e[t])).join(``);function R6e(e,t,n,r,i){let a=new Set(i),o=new Set(r),s=r.filter(e=>a.has(e)&&!n.includes(e)),c=new Map(t.map(e=>[L6e(e,n),e])),l={keyColumns:n,compareColumns:s,added:[],removed:[],changed:[],identical:0,sourceOnlyColumns:r.filter(e=>!a.has(e)),targetOnlyColumns:i.filter(e=>!o.has(e))},u=new Set;for(let t of e){let e=L6e(t,n);u.add(e);let r=c.get(e);if(!r){l.added.push(t);continue}let i=s.filter(e=>f7(t[e])!==f7(r[e]));i.length>0?l.changed.push({key:e,source:t,target:r,columns:i}):l.identical++}for(let[e,t]of c)u.has(e)||l.removed.push(t);return l}var z6e=e=>e.split(`
932
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function M5(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function C3e(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:j5(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),M5(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function w3e(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:j5(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],M5(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:j5(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},M5(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var N5=`debugHeaders`;function T3e(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var E3e={createTable:e=>{e.getHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return P5(t,[...a,...s,...o],e)},M5(e.options,N5,`getHeaderGroups`)),e.getCenterHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),P5(t,n,e,`center`)),M5(e.options,N5,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>P5(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),M5(e.options,N5,`getLeftHeaderGroups`)),e.getRightHeaderGroups=j5(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>P5(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),M5(e.options,N5,`getRightHeaderGroups`)),e.getFooterGroups=j5(()=>[e.getHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getFooterGroups`)),e.getLeftFooterGroups=j5(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getLeftFooterGroups`)),e.getCenterFooterGroups=j5(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getCenterFooterGroups`)),e.getRightFooterGroups=j5(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),M5(e.options,N5,`getRightFooterGroups`)),e.getFlatHeaders=j5(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getFlatHeaders`)),e.getLeftFlatHeaders=j5(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=j5(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getCenterFlatHeaders`)),e.getRightFlatHeaders=j5(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),M5(e.options,N5,`getRightFlatHeaders`)),e.getCenterLeafHeaders=j5(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=j5(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getLeftLeafHeaders`)),e.getRightLeafHeaders=j5(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),M5(e.options,N5,`getRightLeafHeaders`)),e.getLeafHeaders=j5(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),M5(e.options,N5,`getLeafHeaders`))}};function P5(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=T3e(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>T3e(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var D3e=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>S3e(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:j5(()=>[e.getAllLeafColumns()],t=>t.map(t=>C3e(e,s,t,t.id)),M5(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:j5(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),M5(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},O3e={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},k3e=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!((i=e.getValue(t))!=null&&(i=i.toString())!=null&&(i=i.toLowerCase())!=null&&i.includes(a))};k3e.autoRemove=e=>L5(e);var A3e=(e,t,n)=>{var r;return!!((r=e.getValue(t))!=null&&(r=r.toString())!=null&&r.includes(n))};A3e.autoRemove=e=>L5(e);var j3e=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};j3e.autoRemove=e=>L5(e);var M3e=(e,t,n)=>e.getValue(t)?.includes(n);M3e.autoRemove=e=>L5(e);var N3e=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});N3e.autoRemove=e=>L5(e)||!(e!=null&&e.length);var P3e=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));P3e.autoRemove=e=>L5(e)||!(e!=null&&e.length);var F3e=(e,t,n)=>e.getValue(t)===n;F3e.autoRemove=e=>L5(e);var I3e=(e,t,n)=>e.getValue(t)==n;I3e.autoRemove=e=>L5(e);var F5=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};F5.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},F5.autoRemove=e=>L5(e)||L5(e[0])&&L5(e[1]);var I5={includesString:k3e,includesStringSensitive:A3e,equalsString:j3e,arrIncludes:M3e,arrIncludesAll:N3e,arrIncludesSome:P3e,equals:F3e,weakEquals:I3e,inNumberRange:F5};function L5(e){return e==null||e===``}var L3e={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:k5(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?I5.includesString:typeof n==`number`?I5.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?I5.equals:Array.isArray(n)?I5.arrIncludes:I5.weakEquals},e.getFilterFn=()=>A5(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??I5[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=O5(n,i?i.value:void 0);if(R3e(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>O5(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&R3e(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function R3e(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var R5={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!x3e(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},z3e={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:k5(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return R5.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return R5.extent},e.getAggregationFn=()=>{if(!e)throw Error();return A5(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??R5[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function B3e(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var V3e={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:k5(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=j5(e=>[W5(t,e)],t=>t.findIndex(t=>t.id===e.id),M5(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>W5(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=W5(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=j5(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return B3e(i,t,n)},M5(e.options,`debugTable`,`_getOrderColumnsFn`))}},z5=()=>({left:[],right:[]}),H3e={getInitialState:e=>({columnPinning:z5(),...e}),getDefaultOptions:e=>({onColumnPinningChange:k5(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},M5(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),M5(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=j5(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),M5(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?z5():e.initialState?.columnPinning??z5()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),M5(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),M5(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=j5(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},M5(e.options,`debugColumns`,`getCenterLeafColumns`))}};function U3e(e){return e||(typeof document<`u`?document:null)}var B5={size:150,minSize:20,maxSize:2**53-1},V5=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),W3e={getDefaultColumnDef:()=>B5,getInitialState:e=>({columnSizing:{},columnSizingInfo:V5(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:k5(`columnSizing`,e),onColumnSizingInfoChange:k5(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??B5.minSize,n??e.columnDef.size??B5.size),e.columnDef.maxSize??B5.maxSize)},e.getStart=j5(e=>[e,W5(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),M5(t.options,`debugColumns`,`getStart`)),e.getAfter=j5(e=>[e,W5(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),M5(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),U5(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=U5(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=U3e(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=G3e()?{passive:!1}:!1;U5(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?V5():e.initialState.columnSizingInfo??V5())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},H5=null;function G3e(){if(typeof H5==`boolean`)return H5;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return H5=e,H5}function U5(e){return e.type===`touchstart`}var K3e={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:k5(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=j5(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),M5(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=j5(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],M5(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>j5(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),M5(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function W5(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var q3e={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},J3e={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:k5(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>I5.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return A5(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??I5[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},Y3e={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:k5(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0||!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},G5=0,K5=10,q5=()=>({pageIndex:G5,pageSize:K5}),X3e={getInitialState:e=>({...e,pagination:{...q5(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:k5(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>O5(t,e)),e.resetPagination=t=>{e.setPagination(t?q5():e.initialState.pagination??q5())},e.setPageIndex=t=>{e.setPagination(n=>{let r=O5(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?G5:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??G5)},e.resetPageSize=t=>{var n;e.setPageSize(t?K5:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??K5)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,O5(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=O5(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=j5(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},M5(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1||n!==0&&t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},J5=()=>({top:[],bottom:[]}),Z3e={getInitialState:e=>({rowPinning:J5(),...e}),getDefaultOptions:e=>({onRowPinningChange:k5(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?J5():e.initialState?.rowPinning??J5()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),M5(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),M5(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=j5(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},M5(e.options,`debugRows`,`getCenterRows`))}},Q3e={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:k5(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{Y5(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=j5(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?X5(e,n):{rows:[],flatRows:[],rowsById:{}},M5(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return!e.getIsAllPageRowsSelected()&&t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return Y5(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return Z5(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return Q5(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return Q5(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},Y5=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>Y5(e,t.id,n,r,i))};function X5(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=Z5(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function Z5(e,t){return t[e.id]??!1}function Q5(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(Z5(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=Q5(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var $5=/([0-9]+)/gm,$3e=(e,t,n)=>a6e(t7(e.getValue(n)).toLowerCase(),t7(t.getValue(n)).toLowerCase()),e6e=(e,t,n)=>a6e(t7(e.getValue(n)),t7(t.getValue(n))),t6e=(e,t,n)=>e7(t7(e.getValue(n)).toLowerCase(),t7(t.getValue(n)).toLowerCase()),n6e=(e,t,n)=>e7(t7(e.getValue(n)),t7(t.getValue(n))),r6e=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},i6e=(e,t,n)=>e7(e.getValue(n),t.getValue(n));function e7(e,t){return e===t?0:e>t?1:-1}function t7(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function a6e(e,t){let n=e.split($5).filter(Boolean),r=t.split($5).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var n7={alphanumeric:$3e,alphanumericCaseSensitive:e6e,text:t6e,textCaseSensitive:n6e,datetime:r6e,basic:i6e},o6e=[E3e,K3e,V3e,H3e,O3e,L3e,q3e,J3e,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:k5(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return n7.datetime;if(typeof n==`string`&&(r=!0,n.split($5).length>1))return n7.alphanumeric}return r?n7.text:n7.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return A5(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??n7[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},z3e,Y3e,X3e,Z3e,Q3e,W3e];function s6e(e){let t=[...o6e,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{let t=O5(e,n.options);n.options=i(t)},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:j5(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),M5(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:j5(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=w3e(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},M5(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:j5(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),M5(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:j5(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),M5(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:j5(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),M5(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function c6e(){return e=>j5(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=D3e(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},M5(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function l6e(){return e=>j5(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;let r=e.getState().sorting,i=[],a=r.filter(t=>e.getColumn(t.id)?.getCanSort()),o={};a.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let s=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<a.length;n+=1){let r=a[n],i=o[r.id],s=i.sortUndefined,c=r?.desc??!1,l=0;if(s){let n=e.getValue(r.id),i=t.getValue(r.id),a=n===void 0,o=i===void 0;if(a||o){if(s===`first`)return a?-1:1;if(s===`last`)return a?1:-1;l=a&&o?0:a?s:-s}}if(l===0&&(l=i.sortingFn(e,t,r.id)),l!==0)return c&&(l*=-1),i.invertSorting&&(l*=-1),l}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),(t=e.subRows)!=null&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:i,rowsById:n.rowsById}},M5(e.options,`debugTable`,`getSortedRowModel`,()=>e._autoResetPageIndex()))}function u6e(e,t){return e?d6e(e)?D.createElement(e,t):e:null}function d6e(e){return f6e(e)||typeof e==`function`||p6e(e)}function f6e(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function p6e(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function m6e(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=D.useState(()=>({current:s6e(t)})),[r,i]=D.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}function h6e(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function r7(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function g6e(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var _6e=(e,t)=>Math.abs(e-t)<1.01,v6e=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},i7,a7=()=>{if(i7!==void 0)return i7;if(typeof navigator>`u`)return i7=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return i7=!0;let e=navigator.maxTouchPoints;return i7=navigator.platform===`MacIntel`&&e!==void 0&&e>0},y6e=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},b6e=e=>e,x6e=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},S6e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(y6e(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(y6e(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},o7={passive:!0},C6e=typeof window>`u`||`onscrollend`in window,w6e=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&C6e,o=0,s=a?null:v6e(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,o7),a&&r.addEventListener(`scrollend`,u,o7),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},T6e=(e,t)=>w6e(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),E6e=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},D6e=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},O6e=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:b6e,rangeExtractor:x6e,onChange:()=>{},measureElement:E6e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=r7(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!a7()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,o7),e.addEventListener(`touchend`,n,o7),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(a7()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=r7(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=r7(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=h6e(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=r7(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=j6e(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=r7(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=r7(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return g6e(t[k6e(0,t.length-1,r?e=>n[e*2]:e=>g6e(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:a7()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&_6e(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},k6e=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function A6e(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function j6e(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=A6e(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=k6e(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var s7=typeof document<`u`?D.useLayoutEffect:D.useEffect;function M6e({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=D.useReducer(e=>e+1,0)[1],a=D.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,sJe.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=D.useState(()=>{let e=new O6e(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),s7(()=>l._didMount(),[]),s7(()=>(o(l),l._willUpdate())),s7(()=>{s(l)}),l}function N6e(e){return M6e({observeElementRect:S6e,observeElementOffset:T6e,scrollToFn:D6e,...e})}function P6e({className:e,containerClassName:t,...n}){return(0,$.jsx)(`div`,{"data-slot":`table-container`,className:w(`relative w-full overflow-x-auto`,t),children:(0,$.jsx)(`table`,{"data-slot":`table`,className:w(`w-full caption-bottom text-sm`,e),...n})})}function F6e({className:e,...t}){return(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:w(`[&_tr]:border-b`,e),...t})}function I6e({className:e,...t}){return(0,$.jsx)(`tbody`,{"data-slot":`table-body`,className:w(`[&_tr:last-child]:border-0`,e),...t})}function c7({className:e,...t}){return(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:w(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function l7({className:e,...t}){return(0,$.jsx)(`th`,{"data-slot":`table-head`,className:w(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground border-r border-border last:border-r-0 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function u7({className:e,...t}){return(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:w(`p-2 align-middle whitespace-nowrap border-r border-border last:border-r-0 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function d7(e){if(typeof e!=`object`||!e||ArrayBuffer.isView(e))return null;try{return JSON.stringify(e)}catch{return null}}function f7(e){if(e==null)return` NULL`;if(typeof e==`object`)return e instanceof Uint8Array?` BIN${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`:d7(e)??String(e);if(typeof e==`boolean`)return e?`1`:`0`;let t=String(e),n=t.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.000)?Z?$/);return n?`${n[1]} ${n[2]}`:/^-?\d+\.\d*0+$/.test(t)?t.replace(/\.?0+$/,``):t}var L6e=(e,t)=>t.map(t=>f7(e[t])).join(``);function R6e(e,t,n,r,i){let a=new Set(i),o=new Set(r),s=r.filter(e=>a.has(e)&&!n.includes(e)),c=new Map(t.map(e=>[L6e(e,n),e])),l={keyColumns:n,compareColumns:s,added:[],removed:[],changed:[],identical:0,sourceOnlyColumns:r.filter(e=>!a.has(e)),targetOnlyColumns:i.filter(e=>!o.has(e))},u=new Set;for(let t of e){let e=L6e(t,n);u.add(e);let r=c.get(e);if(!r){l.added.push(t);continue}let i=s.filter(e=>f7(t[e])!==f7(r[e]));i.length>0?l.changed.push({key:e,source:t,target:r,columns:i}):l.identical++}for(let[e,t]of c)u.has(e)||l.removed.push(t);return l}var z6e=e=>e.split(`
933
933
  `).map(e=>`-- ${e}`).join(`
934
934
  `);function B6e(e,t,n,r={}){let i=t.qualify(n.database,n.table),a=e=>t.quoteIdentifier(e),o=e=>t.quoteLiteral(e),s=t=>e.keyColumns.map(e=>t[e]===null||t[e]===void 0?`${a(e)} IS NULL`:`${a(e)} = ${o(t[e])}`).join(` AND `),c=[...e.keyColumns,...e.compareColumns],l=[`-- Data sync: ${n.database}.${n.table} (${t.label})`,`-- Keyed by ${e.keyColumns.join(`, `)}. Review before running; DELETEs are commented out unless "Include DELETE statements" was checked.`,``];if(e.added.length>0){l.push(`-- ${e.added.length} rows missing in the target`);for(let t of e.added)l.push(`INSERT INTO ${i} (${c.map(a).join(`, `)}) VALUES (${c.map(e=>o(t[e])).join(`, `)});`);l.push(``)}if(e.changed.length>0){l.push(`-- ${e.changed.length} rows that differ`);for(let t of e.changed)l.push(`UPDATE ${i} SET ${t.columns.map(e=>`${a(e)} = ${o(t.source[e])}`).join(`, `)} WHERE ${s(t.target)};`);l.push(``)}if(e.removed.length>0){l.push(`-- ${e.removed.length} rows only in the target`);for(let t of e.removed){let e=`DELETE FROM ${i} WHERE ${s(t)};`;l.push(r.includeDeletes?e:z6e(e))}l.push(``)}return l.join(`
935
935
  `).trim()+`
@@ -937,9 +937,9 @@ WHERE`).replace(/\s+;$/,`;`),s,E.t(`query.tabs.queryTitle`,{n:(_t.getState().tab
937
937
  `)),c.getState().setFooterMessage(r(`result.grid.commitFailed`,{message:a[0]}))):Je.getState().transactionOpen[e]?c.getState().setFooterMessage(r(`result.grid.executedInTransaction`,{count:i.length})):c.getState().setFooterMessage(r(`result.grid.committed`,{count:i.length,table:`${Ue.database}.${Ue.table}`}));let s=_t.getState(),l=s.tabs[e]?.find(e=>e.id===t);if(l&&Re){let r=new Set(i.filter(e=>a.some(t=>t.startsWith(o(e.rowIdx)))).map(e=>e.rowIdx)),c=[];Re.rows.forEach((e,t)=>{if(Se.has(t)&&!r.has(t))return;let n=ve.get(t);if(n&&!r.has(t)&&!Se.has(t)){let t={...e};for(let[e,r]of n)t[e]=r;c.push(t)}else c.push(e)});for(let e=0;e<be;e++){let t=Re.rows.length+e;r.has(t)||c.push(ot[t]?{...ot[t],...Object.fromEntries(ve.get(t)??[])}:{})}let u=[...l.results];u[n]={...Re,rows:c},s.setResults(e,t,u)}ye(new Map),xe(0),Ce(new Set),Te(new Set),ke(null),He&&a.length===0&&kt({page:me})}finally{Fe(!1)}},[Ue,He,Re,ot,ve,be,Se,at,e,t,n,me,kt,jt,r]),Nt=(0,D.useCallback)((r,i)=>{if(!tt||!Ue||!Re)return;let a=r===`edit`&&i!=null?Re.rows[i]:void 0,o=a?p7(De,Re,a):void 0;r===`edit`&&!o||c.getState().openDialog(`row-form`,{connectionId:e,serverConnectionId:Ue.serverConnectionId,database:Ue.database,table:Ue.table,fields:Re.fields.filter(e=>!Q6(e.name)).map(e=>({name:e.name,orgName:e.orgName||e.name})),mode:r,row:a,where:o??void 0,onStage:(e,t)=>{if(e===`insert`){let e=Re.rows.length+be;xe(e=>e+1),ye(n=>{let r=new Map(n);return r.set(e,new Map(Object.entries(t))),r})}else i!=null&&ye(e=>{let n=new Map(e),r=new Map(n.get(i)??[]);for(let[e,n]of Object.entries(t))a&&a[e]===n?r.delete(e):r.set(e,n);return r.size>0?n.set(i,r):n.delete(i),n})},onCommitted:(r,a)=>{if(He){kt({page:me});return}let o=_t.getState(),s=o.tabs[e]?.find(e=>e.id===t);if(!s)return;let c=[...s.results],l=r===`edit`&&i!=null?Re.rows.map((e,t)=>t===i?{...e,...a}:e):[...Re.rows,{...Object.fromEntries(Re.fields.map(e=>[e.name,null])),...a}];c[n]={...Re,rows:l},o.setResults(e,t,c)}})},[tt,Ue,Re,De,e,t,n,be,He,kt,me]),Pt=(0,D.useCallback)(()=>{kt()},[kt]),It=(0,D.useCallback)(()=>{v(``),kt({value:``})},[kt]),Lt=(0,D.useCallback)(e=>{le(e),kt({sortCol:e})},[kt]),Rt=(0,D.useCallback)(e=>{de(e),ce&&kt({sortDir:e})},[kt,ce]),zt=(0,D.useCallback)(e=>{let t=ce===e?ue===`ASC`?`DESC`:null:`ASC`;le(t?e:``),t&&de(t),kt({sortCol:t?e:``,sortDir:t??ue})},[kt,ce,ue]),Bt=(0,D.useCallback)(()=>{kt({page:me})},[kt,me]),Vt=(0,D.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.target.closest(`th`)?.getBoundingClientRect().width??Ke(t);Le.current={colId:t,startX:e.clientX,startWidth:n};let r=n,i=!1,a=e=>{if(!Le.current)return;let t=e.clientX-Le.current.startX;!i&&Math.abs(t)<P9e||(i=!0,r=Math.max(56,Le.current.startWidth+t),f(e=>({...e,[Le.current.colId]:r})))},o=()=>{i&&Le.current&&qe(Le.current.colId,r),Le.current=null,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)},[qe,Ke]),Ht=(0,D.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation();let n=Re?.fields.find(e=>e.name===t);if(!n)return;let r=i8e(n,Re.rows,s8e);f(e=>({...e,[t]:r})),qe(t,r)},[Re,qe]),Ut=Ue??He;(0,D.useEffect)(()=>{if(!Ut)return;let t=!1;return(async()=>{try{let n=await B9e(e,Ut.serverConnectionId,Ut.database);if(t)return;ie(n.filter(e=>e.table===Ut.table).map(e=>({database:Ut.database,table:e.table,column:e.column,targetDatabase:Ut.database,targetTable:e.refTable,targetColumn:e.refColumn})))}catch{}})(),()=>{t=!0}},[e,Ut?.serverConnectionId,Ut?.database,Ut?.table]);let Wt=(0,D.useMemo)(()=>{let t=new Map;if(!Ut)return t;for(let e of re)t.set(e.column,e);for(let n of H8(oe,e,Ut.database,Ut.table))t.set(n.column,n);return t},[Ut,re,oe,e]),Gt=(0,D.useCallback)(e=>{if(!Re)return[];let t=ot[e]??{};return Re.fields.filter(e=>!Q6(e.name)).map(n=>[n.name,dt(e,n.name,t[n.name])])},[Re,ot,dt]),Kt=e=>e==null?``:typeof e==`object`?d7(e)??String(e):String(e),qt=e=>{navigator.clipboard.writeText(e)},Jt=(0,D.useCallback)(e=>we.has(e)&&we.size>1?[...we].sort((e,t)=>e-t):[e],[we]),Yt=e=>{let t=Kt(e);return/[",\n\r]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t},Xt=(0,D.useCallback)((e,t)=>{let n=e.map(Gt);if(n.length===0)return;let r=n[0].map(([e])=>e);switch(t){case`tsv`:qt([r.join(` `),...n.map(e=>e.map(([,e])=>Kt(e)).join(` `))].join(`
938
938
  `));break;case`csv`:qt([r.map(Yt).join(`,`),...n.map(e=>e.map(([,e])=>Yt(e)).join(`,`))].join(`
939
939
  `));break;case`json`:qt(JSON.stringify(n.map(e=>Object.fromEntries(e)),null,2));break;case`insert`:{if(!Ut)return;let e=r.map(e=>De.quoteIdentifier(e)).join(`, `);qt(n.map(t=>`INSERT INTO ${De.qualify(Ut.database,Ut.table)} (${e}) VALUES (${t.map(([,e])=>De.quoteLiteral(e)).join(`, `)});`).join(`
940
- `))}}},[Gt,Ut,De]),Zt=(0,D.useCallback)(async t=>{if(!Re)return;let n=Re.fields.filter(e=>!Q6(e.name)),i=t.map(e=>Object.fromEntries(Gt(e))),a=Je.getState().activeConnections.find(t=>t.id===e);try{let{connectionId:e,table:t}=await f2e({table:Ut?.table??`result`,fields:n,rows:i,sourceDbms:a?.dbms??`unknown`});c.getState().setFooterMessage(r(`result.grid.sentToScratchpad`,{count:i.length,table:t})),r8(e,`main`,t)}catch(e){e instanceof Cn||c.getState().setFooterMessage(e instanceof Error?e.message:String(e))}},[Re,Gt,e,Ut,r]),Qt=(0,D.useCallback)((e,t)=>{t!=null&&(g(e),v(String(t)),x(`equals`),kt({field:e,value:String(t),mode:`equals`}))},[kt]),$t=(0,D.useCallback)(e=>{if(e>=nt){Ct(new Set([e]));return}Ce(t=>new Set(t).add(e)),ke(null)},[nt,Ct]),en=(0,D.useCallback)((t,n)=>{n!=null&&X1e(t.targetConnectionId??e,t.targetDatabase,t.targetTable,t.targetColumn,String(n))},[e]),tn=(0,D.useMemo)(()=>Re?new Map(Re.fields.map(e=>[e.name,e.type])):new Map,[Re]),nn=(0,D.useMemo)(()=>!Re||Re.fields.length===0?[]:Re.fields.filter(e=>!Q6(e.name)).map(e=>F9e.accessor(t=>t[e.name],{id:e.name,header:e.name,cell:e=>{let t=e.getValue();if(t===null)return(0,$.jsx)(`span`,{className:`text-muted-foreground italic`,children:`NULL`});let n=d7(t);return n===null?_9(t)?(0,$.jsx)(N9e,{value:t}):String(t):(0,$.jsx)(j9e,{value:t,jsonString:n})}})),[Re]),rn=ot,an=m6e({data:rn,columns:nn,state:{sorting:o,columnVisibility:p},onSortingChange:s,onColumnVisibilityChange:m,getCoreRowModel:c6e(),getSortedRowModel:l6e()}),{rows:on}=an.getRowModel(),sn=N6e({count:on.length,getScrollElement:()=>a.current,estimateSize:()=>32,overscan:20});if(!ze)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`result.grid.noData`)});let cn=Re.fields.filter(e=>!Q6(e.name)).map(e=>e.name),ln=rn.length===0,un=an.getVisibleLeafColumns().length,dn=cn.length-un,fn=40+an.getVisibleLeafColumns().reduce((e,t)=>e+Ke(t.id),0);return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(Ue||He)&&(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:Ue?`${Ue.database}.${Ue.table}`:He?`${He.database}.${He.table}`:``}),$e&&(0,$.jsx)(`span`,{className:`rounded border border-catppuccin-yellow/50 px-1.5 py-px text-[10px] font-medium uppercase text-catppuccin-yellow`,title:$e,children:$e}),(Ue||He)&&(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),tt&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border px-2 text-xs disabled:opacity-40 bg-primary/10 text-primary border-primary/30 hover:bg-primary/20 disabled:hover:bg-primary/10`,onClick:()=>void Mt(),disabled:!at||Pe,children:[(0,$.jsx)(y6,{className:`size-3`}),r(`result.grid.commit`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:bt,disabled:!at,children:[(0,$.jsx)(G6,{className:`size-3`}),r(`result.grid.discard`)]}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40`,onClick:St,disabled:Pe,"aria-label":r(`result.grid.addRow`),children:(0,$.jsx)(I6,{className:`size-3.5`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.addRowHint`)})]}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40`,onClick:()=>Nt(`insert`),disabled:Pe,"aria-label":r(`result.grid.addRowForm`),children:(0,$.jsx)(l1e,{className:`size-3.5`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.addRowFormHint`)})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-destructive disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:Tt,disabled:we.size===0||Pe,title:r(`result.grid.deleteHint`),children:[(0,$.jsx)(U6,{className:`size-3`}),we.size>0?r(`result.grid.deleteCount`,{count:we.size}):r(`result.grid.delete`)]})]}),He&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50`,onClick:Bt,disabled:fe,"aria-label":r(`result.grid.refresh`),children:(0,$.jsx)(L6,{className:`size-3.5 ${fe?`animate-spin`:``}`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.refresh`)})]}),_e>0&&(me>0||rt)&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(0),disabled:me===0||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.firstPage`),children:(0,$.jsx)(z$e,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(me-1),disabled:me===0||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.prevPage`),children:(0,$.jsx)(L$e,{className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r(`result.grid.pageRange`,{from:me*_e+ +(nt>0),to:me*_e+nt})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(me+1),disabled:!rt||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.nextPage`),children:(0,$.jsx)(x6,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>void Ot(),disabled:!rt||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.lastPage`),children:(0,$.jsx)(B$e,{className:`size-3.5`})})]}),U6e(C)&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border px-2 text-xs ${ee?`border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`text-muted-foreground`}`,title:r(`result.grid.changesToggle`),onClick:()=>te(e=>!e),children:r(`result.grid.changesSince`,{changed:C.changedCount,added:C.newRows.size,gone:C.goneCount})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,title:r(`result.grid.changesDismiss`),onClick:()=>w(null),children:(0,$.jsx)(b,{className:`size-3.5`})})]})]}),(0,$.jsxs)(v7,{children:[(0,$.jsx)(y7,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`ml-auto flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs hover:text-foreground ${dn>0?`text-primary border-primary/30`:`text-muted-foreground`}`,title:r(`result.grid.columns`),children:[(0,$.jsx)(T6,{className:`size-3.5`}),dn>0?`${un}/${cn.length}`:r(`result.grid.columns`)]})}),(0,$.jsxs)(b7,{align:`end`,className:`w-56 p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2 border-b pb-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>an.toggleAllColumnsVisible(!0),disabled:dn===0,children:r(`result.grid.showAllColumns`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>an.toggleAllColumnsVisible(!1),disabled:un===0,children:r(`result.grid.hideAllColumns`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>{f({}),We&&_7.getState().resetColumnWidths(We)},disabled:Object.keys(d).length===0&&Object.keys(Ge).length===0,children:r(`result.grid.resetWidths`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:an.getAllLeafColumns().map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 text-xs hover:bg-accent`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.getIsVisible(),onChange:e.getToggleVisibilityHandler()}),(0,$.jsx)(`span`,{className:`truncate`,title:e.id,children:e.id})]},e.id))})]})]})]}),He&&(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/20 px-3 py-1.5`,children:[(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:h,onChange:e=>g(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:r(`result.grid.field`)}),cn.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1 text-xs`,value:y,onChange:e=>x(e.target.value),title:r(`result.grid.searchMode`),children:[(0,$.jsx)(`option`,{value:`contains`,children:r(`result.grid.contains`)}),(0,$.jsx)(`option`,{value:`equals`,children:r(`result.grid.equals`)})]}),(0,$.jsx)(`input`,{className:`h-7 w-36 rounded border bg-background px-2 text-xs placeholder:text-muted-foreground`,placeholder:r(`result.grid.searchPlaceholder`),value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!w8(e)&&Pt()}}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,onClick:Pt,children:(0,$.jsx)(z6,{className:`size-3.5`})}),_&&(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,onClick:It,children:(0,$.jsx)(b,{className:`size-3.5`})}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`result.grid.orderBy`)}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:ce,onChange:e=>Lt(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:r(`result.grid.none`)}),cn.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:ue,onChange:e=>Rt(e.target.value),disabled:!ce,children:[(0,$.jsx)(`option`,{value:`ASC`,children:`ASC`}),(0,$.jsx)(`option`,{value:`DESC`,children:`DESC`})]})]}),i?.error&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-xs text-destructive`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:i.error}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-70 hover:opacity-100`,onClick:()=>_t.getState().setError(e,t,null),"aria-label":r(`result.grid.dismiss`),children:(0,$.jsx)(b,{className:`size-3`})})]}),(0,$.jsxs)(h5,{onOpenChange:e=>{e||ne(null)},children:[(0,$.jsx)(g5,{asChild:!0,children:(0,$.jsx)(`div`,{ref:a,className:`flex-1 overflow-auto outline-none`,tabIndex:0,onKeyDown:e=>{if(!Oe){if((e.key===`F2`||e.key===`Enter`)&&Ae){e.preventDefault();let t=ot[Ae.rowIdx]?.[Ae.field];mt(Ae.rowIdx,Ae.field,dt(Ae.rowIdx,Ae.field,t));return}e.key===`Escape`&&(je(null),we.size>0&&Te(new Set))}},children:(0,$.jsxs)(P6e,{className:`min-w-full table-fixed [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0`,style:{width:fn},children:[(0,$.jsx)(F6e,{className:`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:text-[11px]`,children:an.getHeaderGroups().map(e=>(0,$.jsxs)(c7,{children:[(0,$.jsx)(l7,{className:`w-10 min-w-10 cursor-pointer select-none text-center !text-muted-foreground`,title:we.size===rn.length&&rn.length>0?r(`result.grid.clearSelection`):r(`result.grid.selectAll`),onClick:()=>{Te(e=>e.size===rn.length?new Set:new Set(rn.map((e,t)=>t)))},children:`#`}),e.headers.map(e=>{let t=e.id,n=He?ce===t?ue===`DESC`?`desc`:`asc`:!1:e.column.getIsSorted(),r=Ke(t);return(0,$.jsxs)(l7,{"data-header-id":t,className:`relative select-none`,style:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`},children:[(0,$.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-1`,onClick:He?()=>zt(t):e.column.getToggleSortingHandler(),children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.isPlaceholder?null:u6e(e.column.columnDef.header,e.getContext())}),n===`asc`&&(0,$.jsx)(M$e,{className:`size-3 shrink-0 text-primary`}),n===`desc`&&(0,$.jsx)(A$e,{className:`size-3 shrink-0 text-primary`})]}),(0,$.jsx)(`div`,{className:`absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize hover:bg-primary/30`,onMouseDown:e=>Vt(e,t),onDoubleClick:e=>Ht(e,t)})]},e.id)})]},e.id))}),(0,$.jsxs)(I6e,{children:[sn.getVirtualItems().length>0&&(0,$.jsx)(`tr`,{style:{height:sn.getVirtualItems()[0].start}}),ln&&(0,$.jsx)(`tr`,{children:(0,$.jsxs)(`td`,{colSpan:un+1,className:`py-10 text-center text-sm text-muted-foreground`,children:[r(He?`result.grid.emptyTable`:`result.grid.noRows`),tt&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:St,children:r(`result.grid.addARow`)})]})]})}),sn.getVirtualItems().map(e=>{let t=on[e.index],n=t.index>=nt,i=Se.has(t.index),a=we.has(t.index),o=ve.has(t.index),s=i?`[&_td]:bg-destructive/10 [&_td]:line-through [&_td]:text-muted-foreground`:a?`[&_td]:bg-primary/15`:n?`[&_td]:bg-green-500/10`:o?`[&_td]:bg-orange-500/10`:ee&&C?.newRows.has(t.index)?`[&_td]:bg-green-500/10`:e.index%2==1?`[&_td]:bg-muted/60`:void 0;return(0,$.jsxs)(c7,{className:s,"data-selected":a||void 0,children:[(0,$.jsx)(u7,{className:`group/num relative w-10 min-w-10 cursor-pointer select-none text-center text-xs tabular-nums !no-underline ${a?`!bg-primary/30 text-primary-foreground`:`text-muted-foreground`}`,title:r(i?`result.grid.markedForDeletion`:n?`result.grid.newRow`:`result.grid.clickToSelect`),onClick:e=>{if(i){Et(t.index);return}xt(t.index,e)},children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover/num:invisible`,children:`+`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 flex items-center justify-center text-destructive opacity-0 group-hover/num:opacity-100`,title:r(`result.grid.removeNewRow`),onClick:e=>{e.stopPropagation(),wt(t.index)},children:(0,$.jsx)(b,{className:`size-3.5`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:tt&&!i?`group-hover/num:invisible`:``,children:t.index+1}),tt&&!i&&(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 flex items-center justify-center text-primary opacity-0 group-hover/num:opacity-100`,title:r(`result.grid.editRowForm`),onClick:e=>{e.stopPropagation(),Nt(`edit`,t.index)},children:(0,$.jsx)(P6,{className:`size-3`})})]})}),t.getVisibleCells().map(e=>{let n=e.column.id,a=Ke(n),o=t.index,s=Oe?.rowIdx===o&&Oe?.field===n,c=!s&&Ae?.rowIdx===o&&Ae?.field===n,l=ft(o,n),u=t.original[n],d=dt(o,n,u),f=tn.get(n)??``,p=ee&&C?.changedCells.get(o)?.has(n)?{previous:C.changedCells.get(o).get(n)}:null,m=L9e(f),h=/datetime|timestamp/i.test(f);return(0,$.jsx)(u7,{"data-col-id":n,className:`relative ${tt?`cursor-text`:``} ${l?`!text-orange-500 font-medium`:``} ${p?`!bg-amber-500/20`:``} ${c?`ring-1 ring-inset ring-primary/70`:``}`,title:p?r(`result.grid.previousValue`,{value:p.previous===null||p.previous===void 0?`NULL`:String(p.previous)}):o8e(m7(d),a)?m7(d):void 0,style:{width:`${a}px`,minWidth:`${a}px`,maxWidth:`${a}px`,overflow:s?`visible`:`hidden`,textOverflow:`ellipsis`},onContextMenu:()=>{ne({rowIdx:o,column:n,value:d}),we.has(o)||(Te(new Set([o])),Ee.current=o)},onClick:e=>{if(e.shiftKey||e.metaKey||e.ctrlKey){e.preventDefault(),xt(o,e);return}s||(je({rowIdx:o,field:n}),(!we.has(o)||we.size>1)&&xt(o,e))},onDoubleClick:()=>mt(o,n,d),children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`invisible whitespace-nowrap`,children:d===null?`NULL`:String(d)}),(0,$.jsxs)(v7,{open:m,children:[(0,$.jsx)(u8e,{asChild:!0,children:(0,$.jsx)(`input`,{ref:Ie,className:`absolute inset-0 border-none bg-primary/10 px-2 py-0 text-sm outline-none ring-1 ring-inset ring-primary`,value:Me,onChange:e=>Ne(e.target.value),onKeyDown:e=>{if(w8(e)){e.stopPropagation();return}e.key===`Enter`&&ht(),e.key===`Escape`&&gt(),e.stopPropagation()},onBlur:e=>{e.relatedTarget?.closest(`[data-slot="calendar"]`)||ht()},onClick:e=>e.stopPropagation()})}),m&&(0,$.jsx)(b7,{align:`start`,className:`w-auto p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:(0,$.jsx)(O9e,{mode:`single`,selected:R9e(Me),onSelect:e=>{if(e){let t=V9e(e,h);Ne(t),Ie.current?.focus()}},defaultMonth:R9e(Me)})})]})]}):d===null?(0,$.jsx)(`span`,{className:`italic ${l?`text-orange-500`:`text-muted-foreground`}`,children:`NULL`}):(()=>{let e=d7(d);if(e!==null)return(0,$.jsx)(j9e,{value:d,jsonString:e,edited:l,editable:tt,onEdit:e=>yt(o,n,e)});if(_9(d))return(0,$.jsx)(N9e,{value:d,edited:l,editable:tt&&!i,onEdit:e=>yt(o,n,e)});let t=Wt.get(n);return t&&!i?(0,$.jsx)(`a`,{role:`link`,tabIndex:0,className:`cursor-pointer text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,title:`${t.targetConnectionId?`${z9e(t.targetConnectionId)} · `:``}${t.targetDatabase}.${t.targetTable}.${t.targetColumn} = ${String(d)}`,onClick:e=>{e.stopPropagation(),en(t,d)},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),en(t,d))},children:String(d)}):(0,$.jsx)(`span`,{children:String(d)})})()},e.id)})]},t.id)}),sn.getVirtualItems().length>0&&(0,$.jsx)(`tr`,{style:{height:sn.getTotalSize()-(sn.getVirtualItems().at(-1)?.end??0)}})]})]})})}),T&&(()=>{let t=Ut?Wt.get(T.column):void 0,n=T.value!==null&&T.value!==void 0,i=Se.has(T.rowIdx),a=tt&&!i,o=!!Ut&&H8(oe,e,Ut.database,Ut.table).some(e=>e.column===T.column),s=Jt(T.rowIdx);return(0,$.jsxs)(_5,{className:`min-w-60`,children:[t&&(0,$.jsxs)(v5,{disabled:!n,onSelect:()=>en(t,T.value),children:[(0,$.jsx)(j6,{className:`size-3.5`}),r(`result.grid.followLink`,{table:t.targetTable,column:t.targetColumn})]}),Ut&&(0,$.jsxs)(v5,{onSelect:()=>{Q8(`column_link`)&&ae(`link-column`,{connectionId:e,database:Ut.database,table:Ut.table,column:T.column})},children:[(0,$.jsx)(j6,{className:`size-3.5`}),r(t?`result.grid.editLink`:`result.grid.linkColumn`,{column:T.column}),(0,$.jsx)(Y8,{})]}),o&&Ut&&(0,$.jsx)(v5,{onSelect:()=>se(e,{database:Ut.database,table:Ut.table,column:T.column}),children:r(`result.grid.removeLink`)}),He&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsxs)(v5,{disabled:!n,onSelect:()=>Qt(T.column,T.value),children:[(0,$.jsx)(z6,{className:`size-3.5`}),r(`result.grid.filterByValue`,{column:T.column})]}),_&&(0,$.jsx)(v5,{onSelect:It,children:r(`result.grid.clearFilter`)}),(0,$.jsxs)(v5,{onSelect:()=>ae(`group-by`,{connectionId:e,database:He.database,table:He.table,column:T.column,where:Dt(h,_,y)}),children:[(0,$.jsx)(m1e,{className:`size-3.5`}),r(`result.grid.groupByValue`,{column:T.column})]})]}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{disabled:!n,onSelect:()=>qt(Kt(T.value)),children:r(`result.grid.copyValue`)}),(0,$.jsx)(v5,{onSelect:()=>qt(T.column),children:r(`result.grid.copyColumnName`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`tsv`),children:r(`result.grid.copyRowsTsv`,{count:s.length})}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`csv`),children:r(`result.grid.copyRowsCsv`,{count:s.length})}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`json`),children:r(`result.grid.copyRowsJson`,{count:s.length})}),Ut&&(0,$.jsx)(v5,{onSelect:()=>Xt(s,`insert`),children:r(`result.grid.copyRowsInsert`,{count:s.length})}),a&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsxs)(v5,{onSelect:()=>pt(T.rowIdx,T.column,T.value),children:[(0,$.jsx)(P6,{className:`size-3.5`}),r(`result.grid.editCell`)]}),(0,$.jsxs)(v5,{onSelect:()=>Nt(`edit`,T.rowIdx),children:[(0,$.jsx)(l1e,{className:`size-3.5`}),r(`result.grid.editRowForm`)]}),(0,$.jsx)(v5,{disabled:!n,onSelect:()=>yt(T.rowIdx,T.column,null),children:r(`result.grid.setNull`)}),(0,$.jsx)(v5,{onSelect:()=>yt(T.rowIdx,T.column,``),children:r(`result.grid.setEmpty`)}),(0,$.jsxs)(v5,{variant:`destructive`,onSelect:()=>{s.length>1?Tt():$t(T.rowIdx)},children:[(0,$.jsx)(U6,{className:`size-3.5`}),r(`result.grid.deleteRowsPending`,{count:s.length})]})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>Et(T.rowIdx),children:r(`result.grid.restoreRow`)})]}),(0,$.jsx)(y5,{}),!E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v5,{onSelect:()=>{Zt(s)},children:[(0,$.jsx)(N6,{className:`size-3.5`}),r(`result.grid.sendRowsToScratchpad`,{count:s.length})]}),ot.length>s.length&&(0,$.jsxs)(v5,{onSelect:()=>{Zt(ot.map((e,t)=>t).filter(e=>!Se.has(e)))},children:[(0,$.jsx)(N6,{className:`size-3.5`}),r(`result.grid.sendAllToScratchpad`,{count:ot.length-Se.size})]}),(0,$.jsx)(y5,{})]}),(0,$.jsxs)(v5,{onSelect:()=>m(e=>({...e,[T.column]:!1})),children:[(0,$.jsx)(T6,{className:`size-3.5`}),r(`result.grid.hideColumn`,{column:T.column})]})]})})()]}),(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 items-center border-t px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:be>0?r(`result.grid.rowsWithNew`,{count:nt,added:be}):r(`result.grid.rows`,{count:nt})}),He&&ce?(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.sortedBy`,{column:ce,direction:ue})}):o.length>0&&(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.sortedBy`,{column:o[0].id,direction:o[0].desc?`DESC`:`ASC`})}),we.size>0&&(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.selected`,{count:we.size})}),at&&(0,$.jsx)(`span`,{className:`ml-2 text-orange-500`,children:[it>0?r(`result.grid.cellsModified`,{count:it}):null,be>0?r(`result.grid.newCount`,{count:be}):null,Se.size>0?r(`result.grid.toDelete`,{count:Se.size}):null].filter(Boolean).join(`, `)})]})]})}function y9({icon:e,label:t,value:n,muted:r}){return(0,$.jsxs)(`div`,{className:`flex min-w-[140px] flex-1 items-center gap-3 rounded-md border bg-muted/30 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary [&_svg]:size-4`,children:e}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums ${r?`text-muted-foreground`:``}`,children:n})]})]})}function U9e(e){return e==null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(2)} s`}function W9e({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt).find(e=>e.id===t),i=_t(n=>n.history.find(n=>n.connectionId===e&&n.tabId===t)),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(()=>{i&&navigator.clipboard.writeText(i.query).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[i]),c=r?.results??[],l=r?.executionTime??null;if(c.length===0&&!i)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:n(`result.info.empty`)});let u=c.reduce((e,t)=>e+t.rows.length,0),d=c.reduce((e,t)=>e+(t.affectedRows||0),0),f=c.map(e=>e.insertId).filter(e=>e>0).pop();return(0,$.jsx)(K6,{className:`h-full`,children:(0,$.jsxs)(`div`,{className:`space-y-4 p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(y9,{icon:(0,$.jsx)(w6,{}),label:n(`result.info.executionTime`),value:U9e(l),muted:l==null}),(0,$.jsx)(y9,{icon:(0,$.jsx)(A6,{}),label:n(`result.info.resultSets`),value:c.length}),(0,$.jsx)(y9,{icon:(0,$.jsx)(R6,{}),label:n(`result.info.rowsReturned`),value:u.toLocaleString()}),(0,$.jsx)(y9,{icon:(0,$.jsx)(P6,{}),label:n(`result.info.affectedRows`),value:d.toLocaleString(),muted:d===0}),f!=null&&(0,$.jsx)(y9,{icon:(0,$.jsx)(Q$e,{}),label:n(`result.info.insertId`),value:f})]}),i&&(0,$.jsxs)(`section`,{className:`rounded-md border`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[i.success?(0,$.jsx)(S6,{className:`size-3.5 text-green-500`}):(0,$.jsx)(C6,{className:`size-3.5 text-destructive`}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:n(`result.info.lastQuery`)}),i.database&&(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px font-mono text-[10px] text-muted-foreground`,children:i.database}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:new Date(i.timestamp).toLocaleString(void 0,{hour12:!1})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:s,children:[a?(0,$.jsx)(y6,{className:`size-3`}):(0,$.jsx)(E6,{className:`size-3`}),n(a?`result.info.copied`:`result.info.copy`)]})]}),(0,$.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:i.query}),i.error&&(0,$.jsx)(`div`,{className:`border-t border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive`,children:i.error})]}),c.map((e,t)=>{let r=new Set(e.primaryKeys??[]),i=e.fields.some(e=>e.orgName&&e.orgName!==e.name),a=Array.from(new Set(e.fields.map(e=>e.orgTable?`${e.db?e.db+`.`:``}${e.orgTable}`:``).filter(Boolean)));return(0,$.jsxs)(`section`,{className:`rounded-md border`,children:[(0,$.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-primary`,children:n(`result.info.resultN`,{n:t+1})}),e.sourceTable?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs`,children:[(0,$.jsx)(H6,{className:`size-3 text-muted-foreground`}),e.sourceTable.database,`.`,e.sourceTable.table]}):a.length>0?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs text-muted-foreground`,children:[(0,$.jsx)(H6,{className:`size-3`}),a.join(`, `)]}):null,(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:n(`result.info.rowsAndFields`,{rows:e.rows.length.toLocaleString(),fields:e.fields.length})}),e.affectedRows>0&&(0,$.jsxs)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[`· `,n(`result.info.affectedRows`),` `,e.affectedRows.toLocaleString()]})]}),e.message&&(0,$.jsx)(`div`,{className:`border-b px-3 py-1.5 font-mono text-xs text-muted-foreground`,children:e.message}),e.fields.length>0?(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`w-8 px-3 py-1.5 font-medium`,children:`#`}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colName`)}),i&&(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colOrigin`)}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colType`)}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colTable`)})]})}),(0,$.jsx)(`tbody`,{children:e.fields.map((e,t)=>{let a=r.has(e.orgName||e.name);return(0,$.jsxs)(`tr`,{className:`border-b border-border/50 last:border-b-0 hover:bg-muted/30`,children:[(0,$.jsx)(`td`,{className:`px-3 py-1 text-muted-foreground tabular-nums`,children:t+1}),(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.name,a&&(0,$.jsxs)(`span`,{title:n(`result.info.primaryKey`),className:`flex items-center gap-0.5 rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold text-catppuccin-yellow`,children:[(0,$.jsx)(e1e,{className:`size-2.5`}),`PK`]})]})}),i&&(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono text-muted-foreground`,children:e.orgName&&e.orgName!==e.name?e.orgName:``}),(0,$.jsx)(`td`,{className:`px-3 py-1`,children:(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px font-mono text-[11px]`,children:e.type||`—`})}),(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono text-muted-foreground`,children:e.orgTable?`${e.db?e.db+`.`:``}${e.orgTable}`:``})]},`${e.name}-${t}`)})})]})}):(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`result.info.noFields`)})]},t)})]})})}function G9e(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function b9(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function K9e(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:n.slice(0,t)+`…`}function q9e(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(2)} s`}function J9e(e,t){let n=[],r=Date.now(),i=b9(r),a=b9(r-864e5);for(let r of e){let e=b9(r.timestamp),o=n[n.length-1];(!o||o.key!==e)&&(o={key:e,label:e===i?t(`result.history.today`):e===a?t(`result.history.yesterday`):new Date(r.timestamp).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`2-digit`}),entries:[]},n.push(o)),o.entries.push(r)}return n}var Y9e={SELECT:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,INSERT:`bg-green-500/10 text-green-600 dark:text-green-400`,UPDATE:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,DELETE:`bg-red-500/10 text-red-600 dark:text-red-400`};function X9e({connectionId:e}){let{t}=S(),n=_t(e=>e.history),r=_t(t=>t.activeTabId[e]??null),i=_t(e=>e.clearHistory),a=_t(e=>e.addHistory),o=c(e=>e.setFooterMessage),s=c(e=>e.requestDestructiveConfirm),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(``),[p,m]=(0,D.useState)(`all`),[h,g]=(0,D.useState)(!1),_=(0,D.useCallback)((e,n)=>{navigator.clipboard.writeText(n).then(()=>{u(e),o(t(`result.history.copied`)),setTimeout(()=>u(null),1500)})},[o,t]),v=(0,D.useCallback)((n,i)=>{let a=r?qt(e,r):void 0;if(!a){_(n,i);return}let s=a.getModel(),c=a.getSelection();if(!s||!c){_(n,i);return}let l=s.getLineContent(c.startLineNumber),u=c.startColumn>1&&l.trim()!==``,d=i.trim(),f=(u?`
940
+ `))}}},[Gt,Ut,De]),Zt=(0,D.useCallback)(async t=>{if(!Re)return;let n=Re.fields.filter(e=>!Q6(e.name)),i=t.map(e=>Object.fromEntries(Gt(e))),a=Je.getState().activeConnections.find(t=>t.id===e);try{let{connectionId:e,table:t}=await f2e({table:Ut?.table??`result`,fields:n,rows:i,sourceDbms:a?.dbms??`unknown`});c.getState().setFooterMessage(r(`result.grid.sentToScratchpad`,{count:i.length,table:t})),r8(e,`main`,t)}catch(e){e instanceof Cn||c.getState().setFooterMessage(e instanceof Error?e.message:String(e))}},[Re,Gt,e,Ut,r]),Qt=(0,D.useCallback)((e,t)=>{t!=null&&(g(e),v(String(t)),x(`equals`),kt({field:e,value:String(t),mode:`equals`}))},[kt]),$t=(0,D.useCallback)(e=>{if(e>=nt){Ct(new Set([e]));return}Ce(t=>new Set(t).add(e)),ke(null)},[nt,Ct]),en=(0,D.useCallback)((t,n)=>{n!=null&&X1e(t.targetConnectionId??e,t.targetDatabase,t.targetTable,t.targetColumn,String(n))},[e]),tn=(0,D.useMemo)(()=>Re?new Map(Re.fields.map(e=>[e.name,e.type])):new Map,[Re]),nn=(0,D.useMemo)(()=>!Re||Re.fields.length===0?[]:Re.fields.filter(e=>!Q6(e.name)).map(e=>F9e.accessor(t=>t[e.name],{id:e.name,header:e.name,cell:e=>{let t=e.getValue();if(t===null)return(0,$.jsx)(`span`,{className:`text-muted-foreground italic`,children:`NULL`});let n=d7(t);return n===null?_9(t)?(0,$.jsx)(N9e,{value:t}):String(t):(0,$.jsx)(j9e,{value:t,jsonString:n})}})),[Re]),rn=ot,an=m6e({data:rn,columns:nn,state:{sorting:o,columnVisibility:p},onSortingChange:s,onColumnVisibilityChange:m,getCoreRowModel:c6e(),getSortedRowModel:l6e()}),{rows:on}=an.getRowModel(),sn=N6e({count:on.length,getScrollElement:()=>a.current,estimateSize:()=>32,overscan:20});if(!ze)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`result.grid.noData`)});let cn=Re.fields.filter(e=>!Q6(e.name)).map(e=>e.name),ln=rn.length===0,un=an.getVisibleLeafColumns().length,dn=cn.length-un,fn=40+an.getVisibleLeafColumns().reduce((e,t)=>e+Ke(t.id),0);return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(Ue||He)&&(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:Ue?`${Ue.database}.${Ue.table}`:He?`${He.database}.${He.table}`:``}),$e&&(0,$.jsx)(`span`,{className:`rounded border border-catppuccin-yellow/50 px-1.5 py-px text-[10px] font-medium uppercase text-catppuccin-yellow`,title:$e,children:$e}),(Ue||He)&&(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),tt&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border px-2 text-xs disabled:opacity-40 bg-primary/10 text-primary border-primary/30 hover:bg-primary/20 disabled:hover:bg-primary/10`,onClick:()=>void Mt(),disabled:!at||Pe,children:[(0,$.jsx)(y6,{className:`size-3`}),r(`result.grid.commit`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:bt,disabled:!at,children:[(0,$.jsx)(G6,{className:`size-3`}),r(`result.grid.discard`)]}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40`,onClick:St,disabled:Pe,"aria-label":r(`result.grid.addRow`),children:(0,$.jsx)(I6,{className:`size-3.5`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.addRowHint`)})]}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40`,onClick:()=>Nt(`insert`),disabled:Pe,"aria-label":r(`result.grid.addRowForm`),children:(0,$.jsx)(l1e,{className:`size-3.5`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.addRowFormHint`)})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-destructive disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:Tt,disabled:we.size===0||Pe,title:r(`result.grid.deleteHint`),children:[(0,$.jsx)(U6,{className:`size-3`}),we.size>0?r(`result.grid.deleteCount`,{count:we.size}):r(`result.grid.delete`)]})]}),He&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsxs)(g6,{children:[(0,$.jsx)(_6,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50`,onClick:Bt,disabled:fe,"aria-label":r(`result.grid.refresh`),children:(0,$.jsx)(L6,{className:`size-3.5 ${fe?`animate-spin`:``}`})})}),(0,$.jsx)(v6,{side:`bottom`,children:r(`result.grid.refresh`)})]}),_e>0&&(me>0||rt)&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(0),disabled:me===0||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.firstPage`),children:(0,$.jsx)(z$e,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(me-1),disabled:me===0||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.prevPage`),children:(0,$.jsx)(L$e,{className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r(`result.grid.pageRange`,{from:me*_e+ +(nt>0),to:me*_e+nt})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>At(me+1),disabled:!rt||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.nextPage`),children:(0,$.jsx)(x6,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 hover:text-foreground disabled:opacity-40 disabled:hover:text-muted-foreground`,onClick:()=>void Ot(),disabled:!rt||fe||at,title:r(at?`result.grid.pagingBlocked`:`result.grid.lastPage`),children:(0,$.jsx)(B$e,{className:`size-3.5`})})]}),U6e(C)&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border px-2 text-xs ${ee?`border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`text-muted-foreground`}`,title:r(`result.grid.changesToggle`),onClick:()=>te(e=>!e),children:r(`result.grid.changesSince`,{changed:C.changedCount,added:C.newRows.size,gone:C.goneCount})}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,title:r(`result.grid.changesDismiss`),onClick:()=>w(null),children:(0,$.jsx)(b,{className:`size-3.5`})})]})]}),(0,$.jsxs)(v7,{children:[(0,$.jsx)(y7,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`ml-auto flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs hover:text-foreground ${dn>0?`text-primary border-primary/30`:`text-muted-foreground`}`,title:r(`result.grid.columns`),children:[(0,$.jsx)(T6,{className:`size-3.5`}),dn>0?`${un}/${cn.length}`:r(`result.grid.columns`)]})}),(0,$.jsxs)(b7,{align:`end`,className:`w-56 p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2 border-b pb-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>an.toggleAllColumnsVisible(!0),disabled:dn===0,children:r(`result.grid.showAllColumns`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>an.toggleAllColumnsVisible(!1),disabled:un===0,children:r(`result.grid.hideAllColumns`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-primary hover:underline disabled:opacity-40 disabled:no-underline`,onClick:()=>{f({}),We&&_7.getState().resetColumnWidths(We)},disabled:Object.keys(d).length===0&&Object.keys(Ge).length===0,children:r(`result.grid.resetWidths`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:an.getAllLeafColumns().map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 text-xs hover:bg-accent`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.getIsVisible(),onChange:e.getToggleVisibilityHandler()}),(0,$.jsx)(`span`,{className:`truncate`,title:e.id,children:e.id})]},e.id))})]})]})]}),He&&(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/20 px-3 py-1.5`,children:[(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:h,onChange:e=>g(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:r(`result.grid.field`)}),cn.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1 text-xs`,value:y,onChange:e=>x(e.target.value),title:r(`result.grid.searchMode`),children:[(0,$.jsx)(`option`,{value:`contains`,children:r(`result.grid.contains`)}),(0,$.jsx)(`option`,{value:`equals`,children:r(`result.grid.equals`)})]}),(0,$.jsx)(`input`,{className:`h-7 w-36 rounded border bg-background px-2 text-xs placeholder:text-muted-foreground`,placeholder:r(`result.grid.searchPlaceholder`),value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!w8(e)&&Pt()}}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,onClick:Pt,children:(0,$.jsx)(z6,{className:`size-3.5`})}),_&&(0,$.jsx)(`button`,{type:`button`,className:`flex h-7 items-center rounded border bg-background px-1.5 text-muted-foreground hover:text-foreground`,onClick:It,children:(0,$.jsx)(b,{className:`size-3.5`})}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`result.grid.orderBy`)}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:ce,onChange:e=>Lt(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:r(`result.grid.none`)}),cn.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]}),(0,$.jsxs)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs`,value:ue,onChange:e=>Rt(e.target.value),disabled:!ce,children:[(0,$.jsx)(`option`,{value:`ASC`,children:`ASC`}),(0,$.jsx)(`option`,{value:`DESC`,children:`DESC`})]})]}),i?.error&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-xs text-destructive`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:i.error}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-70 hover:opacity-100`,onClick:()=>_t.getState().setError(e,t,null),"aria-label":r(`result.grid.dismiss`),children:(0,$.jsx)(b,{className:`size-3`})})]}),(0,$.jsxs)(h5,{onOpenChange:e=>{e||ne(null)},children:[(0,$.jsx)(g5,{asChild:!0,children:(0,$.jsx)(`div`,{ref:a,className:`flex-1 overflow-auto outline-none`,tabIndex:0,onKeyDown:e=>{if(!Oe){if((e.key===`F2`||e.key===`Enter`)&&Ae){e.preventDefault();let t=ot[Ae.rowIdx]?.[Ae.field];mt(Ae.rowIdx,Ae.field,dt(Ae.rowIdx,Ae.field,t));return}e.key===`Escape`&&(je(null),we.size>0&&Te(new Set))}},children:(0,$.jsxs)(P6e,{containerClassName:`overflow-visible`,className:`min-w-full table-fixed [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0`,style:{width:fn},children:[(0,$.jsx)(F6e,{className:`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:text-[11px]`,children:an.getHeaderGroups().map(e=>(0,$.jsxs)(c7,{children:[(0,$.jsx)(l7,{className:`w-10 min-w-10 cursor-pointer select-none text-center !text-muted-foreground`,title:we.size===rn.length&&rn.length>0?r(`result.grid.clearSelection`):r(`result.grid.selectAll`),onClick:()=>{Te(e=>e.size===rn.length?new Set:new Set(rn.map((e,t)=>t)))},children:`#`}),e.headers.map(e=>{let t=e.id,n=He?ce===t?ue===`DESC`?`desc`:`asc`:!1:e.column.getIsSorted(),r=Ke(t);return(0,$.jsxs)(l7,{"data-header-id":t,className:`relative select-none`,style:{width:`${r}px`,minWidth:`${r}px`,maxWidth:`${r}px`},children:[(0,$.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-1`,onClick:He?()=>zt(t):e.column.getToggleSortingHandler(),children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.isPlaceholder?null:u6e(e.column.columnDef.header,e.getContext())}),n===`asc`&&(0,$.jsx)(M$e,{className:`size-3 shrink-0 text-primary`}),n===`desc`&&(0,$.jsx)(A$e,{className:`size-3 shrink-0 text-primary`})]}),(0,$.jsx)(`div`,{className:`absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize hover:bg-primary/30`,onMouseDown:e=>Vt(e,t),onDoubleClick:e=>Ht(e,t)})]},e.id)})]},e.id))}),(0,$.jsxs)(I6e,{children:[sn.getVirtualItems().length>0&&(0,$.jsx)(`tr`,{style:{height:sn.getVirtualItems()[0].start}}),ln&&(0,$.jsx)(`tr`,{children:(0,$.jsxs)(`td`,{colSpan:un+1,className:`py-10 text-center text-sm text-muted-foreground`,children:[r(He?`result.grid.emptyTable`:`result.grid.noRows`),tt&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:St,children:r(`result.grid.addARow`)})]})]})}),sn.getVirtualItems().map(e=>{let t=on[e.index],n=t.index>=nt,i=Se.has(t.index),a=we.has(t.index),o=ve.has(t.index),s=i?`[&_td]:bg-destructive/10 [&_td]:line-through [&_td]:text-muted-foreground`:a?`[&_td]:bg-primary/15`:n?`[&_td]:bg-green-500/10`:o?`[&_td]:bg-orange-500/10`:ee&&C?.newRows.has(t.index)?`[&_td]:bg-green-500/10`:e.index%2==1?`[&_td]:bg-muted/60`:void 0;return(0,$.jsxs)(c7,{className:s,"data-selected":a||void 0,children:[(0,$.jsx)(u7,{className:`group/num relative w-10 min-w-10 cursor-pointer select-none text-center text-xs tabular-nums !no-underline ${a?`!bg-primary/30 text-primary-foreground`:`text-muted-foreground`}`,title:r(i?`result.grid.markedForDeletion`:n?`result.grid.newRow`:`result.grid.clickToSelect`),onClick:e=>{if(i){Et(t.index);return}xt(t.index,e)},children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover/num:invisible`,children:`+`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 flex items-center justify-center text-destructive opacity-0 group-hover/num:opacity-100`,title:r(`result.grid.removeNewRow`),onClick:e=>{e.stopPropagation(),wt(t.index)},children:(0,$.jsx)(b,{className:`size-3.5`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:tt&&!i?`group-hover/num:invisible`:``,children:t.index+1}),tt&&!i&&(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 flex items-center justify-center text-primary opacity-0 group-hover/num:opacity-100`,title:r(`result.grid.editRowForm`),onClick:e=>{e.stopPropagation(),Nt(`edit`,t.index)},children:(0,$.jsx)(P6,{className:`size-3`})})]})}),t.getVisibleCells().map(e=>{let n=e.column.id,a=Ke(n),o=t.index,s=Oe?.rowIdx===o&&Oe?.field===n,c=!s&&Ae?.rowIdx===o&&Ae?.field===n,l=ft(o,n),u=t.original[n],d=dt(o,n,u),f=tn.get(n)??``,p=ee&&C?.changedCells.get(o)?.has(n)?{previous:C.changedCells.get(o).get(n)}:null,m=L9e(f),h=/datetime|timestamp/i.test(f);return(0,$.jsx)(u7,{"data-col-id":n,className:`relative ${tt?`cursor-text`:``} ${l?`!text-orange-500 font-medium`:``} ${p?`!bg-amber-500/20`:``} ${c?`ring-1 ring-inset ring-primary/70`:``}`,title:p?r(`result.grid.previousValue`,{value:p.previous===null||p.previous===void 0?`NULL`:String(p.previous)}):o8e(m7(d),a)?m7(d):void 0,style:{width:`${a}px`,minWidth:`${a}px`,maxWidth:`${a}px`,overflow:s?`visible`:`hidden`,textOverflow:`ellipsis`},onContextMenu:()=>{ne({rowIdx:o,column:n,value:d}),we.has(o)||(Te(new Set([o])),Ee.current=o)},onClick:e=>{if(e.shiftKey||e.metaKey||e.ctrlKey){e.preventDefault(),xt(o,e);return}s||(je({rowIdx:o,field:n}),(!we.has(o)||we.size>1)&&xt(o,e))},onDoubleClick:()=>mt(o,n,d),children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`invisible whitespace-nowrap`,children:d===null?`NULL`:String(d)}),(0,$.jsxs)(v7,{open:m,children:[(0,$.jsx)(u8e,{asChild:!0,children:(0,$.jsx)(`input`,{ref:Ie,className:`absolute inset-0 border-none bg-primary/10 px-2 py-0 text-sm outline-none ring-1 ring-inset ring-primary`,value:Me,onChange:e=>Ne(e.target.value),onKeyDown:e=>{if(w8(e)){e.stopPropagation();return}e.key===`Enter`&&ht(),e.key===`Escape`&&gt(),e.stopPropagation()},onBlur:e=>{e.relatedTarget?.closest(`[data-slot="calendar"]`)||ht()},onClick:e=>e.stopPropagation()})}),m&&(0,$.jsx)(b7,{align:`start`,className:`w-auto p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:(0,$.jsx)(O9e,{mode:`single`,selected:R9e(Me),onSelect:e=>{if(e){let t=V9e(e,h);Ne(t),Ie.current?.focus()}},defaultMonth:R9e(Me)})})]})]}):d===null?(0,$.jsx)(`span`,{className:`italic ${l?`text-orange-500`:`text-muted-foreground`}`,children:`NULL`}):(()=>{let e=d7(d);if(e!==null)return(0,$.jsx)(j9e,{value:d,jsonString:e,edited:l,editable:tt,onEdit:e=>yt(o,n,e)});if(_9(d))return(0,$.jsx)(N9e,{value:d,edited:l,editable:tt&&!i,onEdit:e=>yt(o,n,e)});let t=Wt.get(n);return t&&!i?(0,$.jsx)(`a`,{role:`link`,tabIndex:0,className:`cursor-pointer text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,title:`${t.targetConnectionId?`${z9e(t.targetConnectionId)} · `:``}${t.targetDatabase}.${t.targetTable}.${t.targetColumn} = ${String(d)}`,onClick:e=>{e.stopPropagation(),en(t,d)},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),en(t,d))},children:String(d)}):(0,$.jsx)(`span`,{children:String(d)})})()},e.id)})]},t.id)}),sn.getVirtualItems().length>0&&(0,$.jsx)(`tr`,{style:{height:sn.getTotalSize()-(sn.getVirtualItems().at(-1)?.end??0)}})]})]})})}),T&&(()=>{let t=Ut?Wt.get(T.column):void 0,n=T.value!==null&&T.value!==void 0,i=Se.has(T.rowIdx),a=tt&&!i,o=!!Ut&&H8(oe,e,Ut.database,Ut.table).some(e=>e.column===T.column),s=Jt(T.rowIdx);return(0,$.jsxs)(_5,{className:`min-w-60`,children:[t&&(0,$.jsxs)(v5,{disabled:!n,onSelect:()=>en(t,T.value),children:[(0,$.jsx)(j6,{className:`size-3.5`}),r(`result.grid.followLink`,{table:t.targetTable,column:t.targetColumn})]}),Ut&&(0,$.jsxs)(v5,{onSelect:()=>{Q8(`column_link`)&&ae(`link-column`,{connectionId:e,database:Ut.database,table:Ut.table,column:T.column})},children:[(0,$.jsx)(j6,{className:`size-3.5`}),r(t?`result.grid.editLink`:`result.grid.linkColumn`,{column:T.column}),(0,$.jsx)(Y8,{})]}),o&&Ut&&(0,$.jsx)(v5,{onSelect:()=>se(e,{database:Ut.database,table:Ut.table,column:T.column}),children:r(`result.grid.removeLink`)}),He&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsxs)(v5,{disabled:!n,onSelect:()=>Qt(T.column,T.value),children:[(0,$.jsx)(z6,{className:`size-3.5`}),r(`result.grid.filterByValue`,{column:T.column})]}),_&&(0,$.jsx)(v5,{onSelect:It,children:r(`result.grid.clearFilter`)}),(0,$.jsxs)(v5,{onSelect:()=>ae(`group-by`,{connectionId:e,database:He.database,table:He.table,column:T.column,where:Dt(h,_,y)}),children:[(0,$.jsx)(m1e,{className:`size-3.5`}),r(`result.grid.groupByValue`,{column:T.column})]})]}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{disabled:!n,onSelect:()=>qt(Kt(T.value)),children:r(`result.grid.copyValue`)}),(0,$.jsx)(v5,{onSelect:()=>qt(T.column),children:r(`result.grid.copyColumnName`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`tsv`),children:r(`result.grid.copyRowsTsv`,{count:s.length})}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`csv`),children:r(`result.grid.copyRowsCsv`,{count:s.length})}),(0,$.jsx)(v5,{onSelect:()=>Xt(s,`json`),children:r(`result.grid.copyRowsJson`,{count:s.length})}),Ut&&(0,$.jsx)(v5,{onSelect:()=>Xt(s,`insert`),children:r(`result.grid.copyRowsInsert`,{count:s.length})}),a&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsxs)(v5,{onSelect:()=>pt(T.rowIdx,T.column,T.value),children:[(0,$.jsx)(P6,{className:`size-3.5`}),r(`result.grid.editCell`)]}),(0,$.jsxs)(v5,{onSelect:()=>Nt(`edit`,T.rowIdx),children:[(0,$.jsx)(l1e,{className:`size-3.5`}),r(`result.grid.editRowForm`)]}),(0,$.jsx)(v5,{disabled:!n,onSelect:()=>yt(T.rowIdx,T.column,null),children:r(`result.grid.setNull`)}),(0,$.jsx)(v5,{onSelect:()=>yt(T.rowIdx,T.column,``),children:r(`result.grid.setEmpty`)}),(0,$.jsxs)(v5,{variant:`destructive`,onSelect:()=>{s.length>1?Tt():$t(T.rowIdx)},children:[(0,$.jsx)(U6,{className:`size-3.5`}),r(`result.grid.deleteRowsPending`,{count:s.length})]})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>Et(T.rowIdx),children:r(`result.grid.restoreRow`)})]}),(0,$.jsx)(y5,{}),!E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v5,{onSelect:()=>{Zt(s)},children:[(0,$.jsx)(N6,{className:`size-3.5`}),r(`result.grid.sendRowsToScratchpad`,{count:s.length})]}),ot.length>s.length&&(0,$.jsxs)(v5,{onSelect:()=>{Zt(ot.map((e,t)=>t).filter(e=>!Se.has(e)))},children:[(0,$.jsx)(N6,{className:`size-3.5`}),r(`result.grid.sendAllToScratchpad`,{count:ot.length-Se.size})]}),(0,$.jsx)(y5,{})]}),(0,$.jsxs)(v5,{onSelect:()=>m(e=>({...e,[T.column]:!1})),children:[(0,$.jsx)(T6,{className:`size-3.5`}),r(`result.grid.hideColumn`,{column:T.column})]})]})})()]}),(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 items-center border-t px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:be>0?r(`result.grid.rowsWithNew`,{count:nt,added:be}):r(`result.grid.rows`,{count:nt})}),He&&ce?(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.sortedBy`,{column:ce,direction:ue})}):o.length>0&&(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.sortedBy`,{column:o[0].id,direction:o[0].desc?`DESC`:`ASC`})}),we.size>0&&(0,$.jsx)(`span`,{className:`ml-2`,children:r(`result.grid.selected`,{count:we.size})}),at&&(0,$.jsx)(`span`,{className:`ml-2 text-orange-500`,children:[it>0?r(`result.grid.cellsModified`,{count:it}):null,be>0?r(`result.grid.newCount`,{count:be}):null,Se.size>0?r(`result.grid.toDelete`,{count:Se.size}):null].filter(Boolean).join(`, `)})]})]})}function y9({icon:e,label:t,value:n,muted:r}){return(0,$.jsxs)(`div`,{className:`flex min-w-[140px] flex-1 items-center gap-3 rounded-md border bg-muted/30 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary [&_svg]:size-4`,children:e}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums ${r?`text-muted-foreground`:``}`,children:n})]})]})}function U9e(e){return e==null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(2)} s`}function W9e({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt).find(e=>e.id===t),i=_t(n=>n.history.find(n=>n.connectionId===e&&n.tabId===t)),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(()=>{i&&navigator.clipboard.writeText(i.query).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[i]),c=r?.results??[],l=r?.executionTime??null;if(c.length===0&&!i)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:n(`result.info.empty`)});let u=c.reduce((e,t)=>e+t.rows.length,0),d=c.reduce((e,t)=>e+(t.affectedRows||0),0),f=c.map(e=>e.insertId).filter(e=>e>0).pop();return(0,$.jsx)(K6,{className:`h-full`,children:(0,$.jsxs)(`div`,{className:`space-y-4 p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(y9,{icon:(0,$.jsx)(w6,{}),label:n(`result.info.executionTime`),value:U9e(l),muted:l==null}),(0,$.jsx)(y9,{icon:(0,$.jsx)(A6,{}),label:n(`result.info.resultSets`),value:c.length}),(0,$.jsx)(y9,{icon:(0,$.jsx)(R6,{}),label:n(`result.info.rowsReturned`),value:u.toLocaleString()}),(0,$.jsx)(y9,{icon:(0,$.jsx)(P6,{}),label:n(`result.info.affectedRows`),value:d.toLocaleString(),muted:d===0}),f!=null&&(0,$.jsx)(y9,{icon:(0,$.jsx)(Q$e,{}),label:n(`result.info.insertId`),value:f})]}),i&&(0,$.jsxs)(`section`,{className:`rounded-md border`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[i.success?(0,$.jsx)(S6,{className:`size-3.5 text-green-500`}):(0,$.jsx)(C6,{className:`size-3.5 text-destructive`}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:n(`result.info.lastQuery`)}),i.database&&(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px font-mono text-[10px] text-muted-foreground`,children:i.database}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:new Date(i.timestamp).toLocaleString(void 0,{hour12:!1})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:s,children:[a?(0,$.jsx)(y6,{className:`size-3`}):(0,$.jsx)(E6,{className:`size-3`}),n(a?`result.info.copied`:`result.info.copy`)]})]}),(0,$.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:i.query}),i.error&&(0,$.jsx)(`div`,{className:`border-t border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive`,children:i.error})]}),c.map((e,t)=>{let r=new Set(e.primaryKeys??[]),i=e.fields.some(e=>e.orgName&&e.orgName!==e.name),a=Array.from(new Set(e.fields.map(e=>e.orgTable?`${e.db?e.db+`.`:``}${e.orgTable}`:``).filter(Boolean)));return(0,$.jsxs)(`section`,{className:`rounded-md border`,children:[(0,$.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-primary`,children:n(`result.info.resultN`,{n:t+1})}),e.sourceTable?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs`,children:[(0,$.jsx)(H6,{className:`size-3 text-muted-foreground`}),e.sourceTable.database,`.`,e.sourceTable.table]}):a.length>0?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs text-muted-foreground`,children:[(0,$.jsx)(H6,{className:`size-3`}),a.join(`, `)]}):null,(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:n(`result.info.rowsAndFields`,{rows:e.rows.length.toLocaleString(),fields:e.fields.length})}),e.affectedRows>0&&(0,$.jsxs)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[`· `,n(`result.info.affectedRows`),` `,e.affectedRows.toLocaleString()]})]}),e.message&&(0,$.jsx)(`div`,{className:`border-b px-3 py-1.5 font-mono text-xs text-muted-foreground`,children:e.message}),e.fields.length>0?(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b text-left text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(`th`,{className:`w-8 px-3 py-1.5 font-medium`,children:`#`}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colName`)}),i&&(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colOrigin`)}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colType`)}),(0,$.jsx)(`th`,{className:`px-3 py-1.5 font-medium`,children:n(`result.info.colTable`)})]})}),(0,$.jsx)(`tbody`,{children:e.fields.map((e,t)=>{let a=r.has(e.orgName||e.name);return(0,$.jsxs)(`tr`,{className:`border-b border-border/50 last:border-b-0 hover:bg-muted/30`,children:[(0,$.jsx)(`td`,{className:`px-3 py-1 text-muted-foreground tabular-nums`,children:t+1}),(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.name,a&&(0,$.jsxs)(`span`,{title:n(`result.info.primaryKey`),className:`flex items-center gap-0.5 rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold text-catppuccin-yellow`,children:[(0,$.jsx)(e1e,{className:`size-2.5`}),`PK`]})]})}),i&&(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono text-muted-foreground`,children:e.orgName&&e.orgName!==e.name?e.orgName:``}),(0,$.jsx)(`td`,{className:`px-3 py-1`,children:(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px font-mono text-[11px]`,children:e.type||`—`})}),(0,$.jsx)(`td`,{className:`px-3 py-1 font-mono text-muted-foreground`,children:e.orgTable?`${e.db?e.db+`.`:``}${e.orgTable}`:``})]},`${e.name}-${t}`)})})]})}):(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`result.info.noFields`)})]},t)})]})})}function G9e(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function b9(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function K9e(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:n.slice(0,t)+`…`}function q9e(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(2)} s`}function J9e(e,t){let n=[],r=Date.now(),i=b9(r),a=b9(r-864e5);for(let r of e){let e=b9(r.timestamp),o=n[n.length-1];(!o||o.key!==e)&&(o={key:e,label:e===i?t(`result.history.today`):e===a?t(`result.history.yesterday`):new Date(r.timestamp).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`2-digit`}),entries:[]},n.push(o)),o.entries.push(r)}return n}var Y9e={SELECT:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,INSERT:`bg-green-500/10 text-green-600 dark:text-green-400`,UPDATE:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,DELETE:`bg-red-500/10 text-red-600 dark:text-red-400`};function X9e({connectionId:e}){let{t}=S(),n=_t(e=>e.history),r=_t(t=>t.activeTabId[e]??null),i=_t(e=>e.clearHistory),a=_t(e=>e.addHistory),o=c(e=>e.setFooterMessage),s=c(e=>e.requestDestructiveConfirm),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(``),[p,m]=(0,D.useState)(`all`),[h,g]=(0,D.useState)(!1),_=(0,D.useCallback)((e,n)=>{navigator.clipboard.writeText(n).then(()=>{u(e),o(t(`result.history.copied`)),setTimeout(()=>u(null),1500)})},[o,t]),v=(0,D.useCallback)((n,i)=>{let a=r?qt(e,r):void 0;if(!a){_(n,i);return}let s=a.getModel(),c=a.getSelection();if(!s||!c){_(n,i);return}let l=s.getLineContent(c.startLineNumber),u=c.startColumn>1&&l.trim()!==``,d=i.trim(),f=(u?`
941
941
  `:``)+d+(d.endsWith(`;`)?``:`;`)+`
942
- `;a.executeEdits(`history`,[{range:c,text:f,forceMoveMarkers:!0}]),a.focus(),o(t(`result.history.inserted`))},[r,e,_,o,t]),y=(0,D.useMemo)(()=>n.filter(t=>!e||!t.connectionId||t.connectionId===e),[n,e]),x=(0,D.useCallback)(async()=>{if(!await s({title:t(`result.history.clearTitle`),description:t(`result.history.clearDescription`,{count:y.length}),confirmLabel:t(`result.history.clearConfirm`)}))return;let r=n.filter(t=>t.connectionId&&t.connectionId!==e);i();for(let e of[...r].reverse())a(e)},[s,t,y.length,n,e,i,a]),C=(0,D.useMemo)(()=>{let e=d.trim().toLowerCase();return y.filter(t=>!(p===`success`&&!t.success||p===`failed`&&t.success||h&&t.tabId!==r||e&&!t.query.toLowerCase().includes(e)&&!(t.database??``).toLowerCase().includes(e)&&!(t.error??``).toLowerCase().includes(e)))},[y,d,p,h,r]),w=(0,D.useMemo)(()=>J9e(C,t),[C,t]);if(y.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:t(`result.history.empty`)});let ee=(e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-xs ${p===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>m(e),children:t});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z6,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(`input`,{className:`h-7 w-52 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:t(`result.history.searchPlaceholder`),value:d,onChange:e=>f(e.target.value)}),d&&(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>f(``),children:(0,$.jsx)(b,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center rounded border bg-background p-0.5`,children:[ee(`all`,t(`result.history.all`)),ee(`success`,t(`result.history.success`)),ee(`failed`,t(`result.history.failed`))]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:h,onChange:e=>g(e.target.checked)}),t(`result.history.thisTab`)]}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t(`result.history.count`,{count:C.length})}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-destructive`,onClick:()=>void x(),children:[(0,$.jsx)(U6,{className:`size-3`}),t(`result.history.clear`)]})]}),(0,$.jsx)(K6,{className:`min-h-0 flex-1`,children:C.length===0?(0,$.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:t(`result.history.noMatch`)}):w.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-10 border-b bg-background/95 px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground backdrop-blur`,children:e.label}),(0,$.jsx)(`div`,{className:`divide-y divide-border/60 text-sm`,children:e.entries.map(e=>{let n=e.kind?.toUpperCase();return(0,$.jsxs)(`div`,{className:`group/row flex items-start gap-2 px-3 py-2 hover:bg-muted/50`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 flex-shrink-0`,children:e.success?(0,$.jsx)(S6,{className:`size-4 text-green-500`}):(0,$.jsx)(C6,{className:`size-4 text-destructive`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,onClick:()=>_(e.id,e.query),title:e.query,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs text-foreground`,children:K9e(e.query)}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`tabular-nums`,children:G9e(e.timestamp)}),n&&(0,$.jsx)(`span`,{className:`rounded px-1 text-[9px] font-semibold ${Y9e[n]??`bg-muted`}`,children:n}),e.database&&(0,$.jsx)(`span`,{className:`font-mono`,children:e.database}),e.rowCount!=null&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(R6,{className:`size-3`}),t(`result.history.rows`,{count:e.rowCount})]}),e.affectedRows!=null&&e.affectedRows>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(P6,{className:`size-3`}),t(`result.history.affected`,{count:e.affectedRows})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5 tabular-nums`,children:[(0,$.jsx)(w6,{className:`size-3`}),q9e(e.executionTime)]})]}),e.error&&(0,$.jsx)(`p`,{className:`mt-0.5 break-words text-xs text-destructive`,children:e.error})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-shrink-0 items-center gap-0.5 opacity-0 group-hover/row:opacity-100`,children:[(0,$.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`result.history.insert`),onClick:()=>v(e.id,e.query),children:(0,$.jsx)(q$e,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`result.history.copy`),onClick:()=>_(e.id,e.query),children:l===e.id?(0,$.jsx)(y6,{className:`size-3.5 text-green-500`}):(0,$.jsx)(E6,{className:`size-3.5`})})]})]},e.id)})})]},e.key))})]})}var Z9e={"full-scan":`border-destructive/50 text-destructive`,"no-index":`border-destructive/50 text-destructive`,"estimate-off":`border-catppuccin-yellow/50 text-catppuccin-yellow`,temporary:`border-catppuccin-yellow/50 text-catppuccin-yellow`,filesort:`border-catppuccin-yellow/50 text-catppuccin-yellow`},x9={"full-scan":{label:`result.plan.warnings.fullScan`,hint:`result.plan.hints.fullScan`},"no-index":{label:`result.plan.warnings.noIndex`,hint:`result.plan.hints.noIndex`},"estimate-off":{label:`result.plan.warnings.estimateOff`,hint:`result.plan.hints.estimateOff`},temporary:{label:`result.plan.warnings.temporary`,hint:`result.plan.hints.temporary`},filesort:{label:`result.plan.warnings.filesort`,hint:`result.plan.hints.filesort`}};function Q9e(e){return e<1e3?`${e.toFixed(e<10?2:0)} ms`:`${(e/1e3).toFixed(2)} s`}function S9(e){return e>=1e3?Math.round(e).toLocaleString():String(Math.round(e*100)/100)}function $9e(e,t){let n=[],r=(e,i)=>{let a=e.children.length>0,o=a&&!t.has(e.id);if(n.push({node:e,depth:i,hasChildren:a,expanded:o}),o)for(let t of e.children)r(t,i+1)};for(let t of e)r(t,0);return n}function eet(e,t){return t?e.timeMs??e.cost:e.cost}function tet(e,t){let n=0,r=e=>{let i=eet(e,t);i!==null&&i>n&&(n=i),e.children.forEach(r)};return e.forEach(r),n}function C9({icon:e,value:t,title:n}){return(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5 tabular-nums`,title:n,children:[(0,$.jsx)(e,{className:`size-3 shrink-0`}),t]})}function net({node:e}){let{t}=S();return(0,$.jsxs)(`div`,{className:`flex h-full w-72 shrink-0 flex-col border-l`,children:[(0,$.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`truncate text-xs font-semibold`,title:e.label,children:e.label}),e.object&&(0,$.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.object})]}),(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsxs)(`div`,{className:`p-3`,children:[e.warnings.length>0&&(0,$.jsx)(`ul`,{className:`mb-3 space-y-1.5`,children:e.warnings.map(e=>(0,$.jsxs)(`li`,{className:`text-[11px] leading-snug`,children:[(0,$.jsx)(`span`,{className:`mr-1 rounded border px-1 text-[9px] font-semibold uppercase ${Z9e[e]}`,children:t(x9[e].label)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(x9[e].hint)})]},e))}),e.details.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t(`result.plan.noDetails`)}):(0,$.jsx)(`dl`,{className:`space-y-1.5`,children:e.details.map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,$.jsx)(`dd`,{className:`break-words font-mono text-[11px]`,children:e.value})]},`${e.label}-${t}`))})]})})]})}function ret({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt),i=r.find(e=>e.id===t)?.plan??null,[a,o]=(0,D.useState)(!1),[s,c]=(0,D.useState)(!1),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(null),[p,m]=(0,D.useState)(new Set),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(u(null),f(null),!i)return;let e=!0;return s3e().then(t=>e&&o(t)),()=>{e=!1}},[e,t,i]);let y=(0,D.useCallback)(()=>{c(!0),f(null),m3e(e,t).then(u).catch(e=>f(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},[e,t]),b=(0,D.useMemo)(()=>i?$9e(i.roots,p):[],[i,p]),x=(0,D.useMemo)(()=>i?tet(i.roots,i.analyzed):0,[i]),C=(0,D.useMemo)(()=>b.find(e=>e.node.id===h)?.node??null,[b,h]);if(!i)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(`result.plan.empty`)});if(i.roots.length===0)return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`border-b px-3 py-2 text-xs text-muted-foreground`,children:n(`result.plan.unreadable`)}),(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-3 font-mono text-xs`,children:i.raw})})]});let w=e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-3 py-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded border px-1 text-[9px] font-semibold uppercase ${i.analyzed?`border-green-500/50 text-green-500`:`border-border`}`,title:n(i.analyzed?`result.plan.analyzedHint`:`result.plan.estimatedHint`),children:n(i.analyzed?`result.plan.analyzed`:`result.plan.estimated`)}),i.totalCost!==null&&(0,$.jsx)(C9,{icon:U$e,value:S9(i.totalCost),title:n(`result.plan.totalCost`)}),i.totalTimeMs!==null&&(0,$.jsx)(C9,{icon:w6,value:Q9e(i.totalTimeMs),title:n(`result.plan.totalTime`)}),(0,$.jsx)(`div`,{className:`flex-1`}),a&&(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground disabled:opacity-60`,onClick:y,disabled:s,children:[s?(0,$.jsx)(M6,{className:`size-3 animate-spin`}):(0,$.jsx)(B6,{className:`size-3`}),n(s?`result.ai.thinking`:`result.ai.explainPlan`)]}),(0,$.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground`,onClick:()=>v(e=>!e),children:n(_?`result.plan.showTree`:`result.plan.showRaw`)})]}),d&&(0,$.jsx)(`p`,{className:`border-b px-3 py-1.5 text-xs text-muted-foreground`,children:n(`result.ai.failed`,{message:d})}),l&&(0,$.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(B6,{className:`size-3`}),n(`result.ai.title`),(0,$.jsx)(`span`,{className:`font-normal normal-case tracking-normal`,children:n(`result.ai.by`,{model:l.model})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed`,children:l.explanation}),l.fix&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded border bg-muted/50 p-2 font-mono text-[11px]`,children:l.fix}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-1.5 inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground`,onClick:()=>i8(e,l.fix,r.find(e=>e.id===t)?.database??``,n(`result.ai.title`)),children:[(0,$.jsx)(j$e,{className:`size-3`}),n(`result.ai.applyFix`)]})]})]}),_?(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-3 font-mono text-xs`,children:i.raw})}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(K6,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`ul`,{className:`py-1 text-xs`,children:b.map(({node:e,depth:t,hasChildren:r,expanded:a})=>{let o=eet(e,i.analyzed),s=x>0&&o!==null?Math.max(o/x,.02):0,c=e.id===h;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`relative flex w-full items-center gap-1.5 py-1 pr-3 text-left ${c?`bg-primary/10`:`hover:bg-muted/60`}`,style:{paddingLeft:`${t*14+8}px`},onClick:()=>g(e.id),children:[s>0&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 bg-primary/10`,style:{width:`${s*100}%`}}),(0,$.jsx)(`span`,{className:`relative flex w-3 shrink-0 justify-center text-muted-foreground`,children:r&&(0,$.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:t=>{t.stopPropagation(),w(e.id)},children:a?(0,$.jsx)(b6,{className:`size-3`}):(0,$.jsx)(x6,{className:`size-3`})})}),(0,$.jsxs)(`span`,{className:`relative min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.object&&!e.label.includes(e.object)&&(0,$.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-muted-foreground`,children:e.object}),e.warnings.map(e=>(0,$.jsx)(`span`,{className:`ml-1.5 rounded border px-1 text-[9px] font-semibold uppercase ${Z9e[e]}`,children:n(x9[e].label)},e))]}),(0,$.jsxs)(`span`,{className:`relative flex shrink-0 items-center gap-2.5 text-[11px] text-muted-foreground`,children:[e.rows!==null&&(0,$.jsx)(C9,{icon:R6,value:S9(e.rows),title:n(`result.plan.rows`)}),e.actualRows!==null&&(0,$.jsx)(C9,{icon:X$e,value:S9(e.actualRows),title:n(`result.plan.actualRows`)}),e.cost!==null&&(0,$.jsx)(C9,{icon:U$e,value:S9(e.cost),title:n(`result.plan.cost`)}),e.timeMs!==null&&(0,$.jsx)(C9,{icon:w6,value:Q9e(e.timeMs),title:n(`result.plan.time`)})]})]})},e.id)})})}),C?(0,$.jsx)(net,{node:C}):(0,$.jsx)(`div`,{className:`flex w-72 shrink-0 items-center justify-center border-l px-4 text-center text-[11px] text-muted-foreground`,children:(0,$.jsxs)(`span`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(d1e,{className:`size-4`}),n(`result.plan.selectNode`)]})})]})]})}var iet=56,aet=16,w9=14;function oet(e,t){let n=new Map,r=new Set,i=e=>{let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=0;for(let n of t.get(e)??[])o=Math.max(o,i(n)+1);return r.delete(e),n.set(e,o),o};for(let t of e)i(t.id);let a=new Map;for(let[e,n]of t)for(let t of n)a.set(t,[...a.get(t)??[],e]);let o=Math.max(...e.map(e=>n.get(e.id)??0)),s=new Map,c=e=>{let t=s.get(e);if(t!==void 0)return t;if(r.has(e))return n.get(e)??0;r.add(e);let i=a.get(e)??[],l=i.length===0?o:Math.min(...i.map(e=>c(e)-1));return r.delete(e),s.set(e,Math.max(n.get(e)??0,l)),s.get(e)??0};for(let t of e)c(t.id);return s}function set(e){let t=new Map;for(let n of e.groups){let e=t.get(n.parentId)??[];e.push(n.id),t.set(n.parentId,e)}let n=new Map;for(let t of e.nodes){let e=n.get(t.groupId)??[];e.push(t.id),n.set(t.groupId,e)}let r=new Map,i=e=>{let a=r.get(e);if(a)return a;let o=[...n.get(e)??[]];for(let n of t.get(e)??[])o.push(...i(n));return r.set(e,o),o};for(let t of e.groups)i(t.id);let a=new Map,o=i=>{let s=[];for(let e of i===null?[]:n.get(i)??[])s.push({id:e,kind:`node`,width:196,height:56,x:0,y:0});for(let e of t.get(i)??[]){let t=o(e);a.set(e,t),s.push({id:e,kind:`group`,width:t.width+28,height:t.height+28+22,x:0,y:0})}if(s.length===0)return{width:0,height:0,items:s};let c=new Map;for(let e of s)if(e.kind===`node`)c.set(e.id,e.id);else for(let t of r.get(e.id)??[])c.set(t,e.id);let l=new Map;for(let t of e.edges){let e=c.get(t.from),n=c.get(t.to);if(!e||!n||e===n)continue;let r=l.get(n)??new Set;r.add(e),l.set(n,r)}let u=oet(s,l),d=new Map;for(let e of s){let t=u.get(e.id)??0,n=d.get(t)??[];n.push(e),d.set(t,n)}let f=[...d.keys()].sort((e,t)=>e-t).map(e=>{let t=d.get(e)??[];return{key:e,width:Math.max(...t.map(e=>e.width)),height:t.reduce((e,t)=>e+t.height,0)+aet*(t.length-1)}}),p=Math.max(...f.map(e=>e.height)),m=0;for(let e of f){let t=d.get(e.key)??[],n=(p-e.height)/2;for(let r of t)r.x=m+(e.width-r.width)/2,r.y=n,n+=r.height+aet;m+=e.width+iet}return{width:m-iet,height:p,items:s}},s=o(null);a.set(`__root`,s);let c=[],l=[],u=(t,n,r,i)=>{for(let o of t.items){let t=n+o.x,s=r+o.y;if(o.kind===`node`){c.push({id:o.id,x:t,y:s,width:o.width,height:o.height});continue}let d=e.groups.find(e=>e.id===o.id);l.push({id:o.id,x:t,y:s,width:o.width,height:o.height,label:d?.label??``,depth:i});let f=a.get(o.id);f&&u(f,t+w9,s+w9+22,i+1)}};return u(s,w9,w9,0),{nodes:c,groups:l,width:s.width+28,height:s.height+28}}var cet=.3,uet=2,det=.0012,fet=120,pet=e=>Math.max(cet,Math.min(uet,e)),met={table:`var(--t-green)`,cte:`var(--t-blue)`,"cte-ref":`var(--t-teal)`,derived:`var(--t-mauve)`,scalar:`var(--t-lavender)`,setop:`var(--t-sky)`,result:`var(--t-peach)`},het={table:`result.structure.kindTable`,cte:`result.structure.kindCte`,"cte-ref":`result.structure.kindCteRef`,derived:`result.structure.kindDerived`,scalar:`result.structure.kindScalar`,setop:`result.structure.kindSetop`,result:`result.structure.kindResult`};function get(e,t){let n=e.x+e.width,r=e.y+e.height/2,i=t.x,a=t.y+t.height/2,o=Math.max(28,Math.abs(i-n)/2);return`M ${n} ${r} C ${n+o} ${r}, ${i-o} ${a}, ${i} ${a}`}function _et({connectionId:e,tabId:t,index:n}){let{t:r}=S(),i=_t(t=>t.tabs[e]??vt).find(e=>e.id===t)?.graphs?.[n]??null,a=i?.graph??null;(0,D.useEffect)(()=>{i&&!i.enriched&&i.graph&&P8(e,t,n)},[e,t,n,i]);let[o,s]=(0,D.useState)(1),[c,l]=(0,D.useState)({x:0,y:0}),u=(0,D.useRef)(null),d=(0,D.useRef)(null),f=(0,D.useRef)(null),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(null),_=(0,D.useMemo)(()=>a?set(a):null,[a]),v=(0,D.useMemo)(()=>{if(!h||!a)return null;let e=new Set,t=new Set([h]);for(let n of a.edges)(n.from===h||n.to===h)&&(e.add(n.id),t.add(n.from),t.add(n.to));return{edges:e,nodes:t}},[h,a]),y=(0,D.useMemo)(()=>new Map((_?.nodes??[]).map(e=>[e.id,e])),[_]),b=(0,D.useMemo)(()=>new Map((a?.nodes??[]).map(e=>[e.id,e])),[a]),x=(0,D.useCallback)(()=>{let e=d.current;if(!e||!_||_.width===0)return;let t=pet(Math.min(e.clientWidth/_.width,e.clientHeight/_.height,1));s(t),l({x:(e.clientWidth-_.width*t)/2,y:(e.clientHeight-_.height*t)/2})},[_]),C=(0,D.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):f.current?.requestFullscreen().catch(()=>{})},[]);(0,D.useEffect)(()=>{let e=()=>{m(document.fullscreenElement===f.current),requestAnimationFrame(()=>x())};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[x]);let w=(0,D.useCallback)(e=>{e.preventDefault();let t=Math.max(-120,Math.min(fet,e.deltaY)),n=d.current?.getBoundingClientRect();s(r=>{let i=pet(r*(1-t*det));if(n){let t=e.clientX-n.left,a=e.clientY-n.top;l(e=>({x:t-(t-e.x)/r*i,y:a-(a-e.y)/r*i}))}return i})},[]),ee=(0,D.useCallback)(e=>{e.button===0&&(u.current={x:e.clientX,y:e.clientY,panX:c.x,panY:c.y})},[c]),te=(0,D.useCallback)(e=>{let t=u.current;t&&l({x:t.panX+(e.clientX-t.x),y:t.panY+(e.clientY-t.y)})},[]),T=(0,D.useCallback)(()=>{u.current=null},[]),ne=(0,D.useCallback)(n=>{!n.range||i?.documentOffset===null||i===null||Gt(e,t,i.documentOffset+n.range[0],i.documentOffset+n.range[1])},[e,t,i]);if(!i)return(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:r(`result.structure.empty`)});if(!a||!_)return(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:i.message});let re=e=>e===null?r(`result.structure.columnsUnknown`):r(`result.structure.columns`,{count:e});return(0,$.jsxs)(`div`,{ref:f,className:`relative h-full w-full overflow-hidden`,style:{background:`var(--t-mantle)`},children:[(0,$.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:x,className:`flex items-center gap-1 rounded border bg-background/80 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(a1e,{className:`size-3`}),r(`result.structure.fit`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:`flex items-center gap-1 rounded border bg-background/80 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground`,children:[p?(0,$.jsx)(p1e,{className:`size-3`}):(0,$.jsx)(G$e,{className:`size-3`}),r(p?`result.structure.exitFullscreen`:`result.structure.fullscreen`)]})]}),a.warnings.length>0&&(0,$.jsx)(`div`,{className:`absolute left-2 top-2 z-10 rounded border px-2 py-1 text-[11px]`,style:{borderColor:`var(--t-yellow)`,color:`var(--t-yellow)`},children:r(`result.structure.notDrawn`,{what:a.warnings.join(`; `)})}),(0,$.jsx)(`div`,{ref:d,className:`h-full w-full cursor-grab active:cursor-grabbing`,onWheel:w,onMouseDown:ee,onMouseMove:te,onMouseUp:T,onMouseLeave:T,children:(0,$.jsxs)(`div`,{className:`relative origin-top-left`,style:{width:_.width,height:_.height,transform:`translate(${c.x}px, ${c.y}px) scale(${o})`},children:[_.groups.map(e=>(0,$.jsx)(`div`,{className:`absolute rounded-md border border-dashed`,style:{left:e.x,top:e.y,width:e.width,height:e.height,borderColor:`var(--t-surface2, var(--t-overlay0))`,background:e.depth%2==0?`var(--t-base, transparent)`:`var(--t-surface0)`,opacity:.9},children:(0,$.jsx)(`div`,{className:`px-2 pt-1 text-[10px] font-semibold uppercase tracking-wide`,style:{height:22,color:`var(--t-overlay1)`},children:e.label})},e.id)),(0,$.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0`,width:_.width,height:_.height,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`marker`,{id:`qg-arrow`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,children:(0,$.jsx)(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:`var(--t-overlay1)`})}),(0,$.jsx)(`marker`,{id:`qg-arrow-lit`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,children:(0,$.jsx)(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:`var(--t-blue)`})})]}),a.edges.map(e=>{let t=y.get(e.from),n=y.get(e.to);if(!t||!n)return null;let r=b.get(e.from),i=v?.edges.has(e.id)??!1;return(0,$.jsxs)(`g`,{style:{opacity:v!==null&&!i?.18:1,transition:`opacity 120ms`},children:[(0,$.jsx)(`path`,{d:get(t,n),fill:`none`,stroke:i?`var(--t-blue)`:`var(--t-overlay1)`,strokeWidth:i?2.2:1.2,strokeDasharray:e.kind===`scalar`?`4 3`:void 0,markerEnd:i?`url(#qg-arrow-lit)`:`url(#qg-arrow)`}),r?.columnCount!==null&&r!==void 0&&(0,$.jsx)(`text`,{x:(t.x+t.width+n.x)/2,y:(t.y+n.y)/2+t.height/2-4,textAnchor:`middle`,fontSize:10,fontWeight:i?600:400,fill:i?`var(--t-blue)`:`var(--t-overlay1)`,children:r.columnCount})]},e.id)})]}),_.nodes.map(e=>{let t=b.get(e.id);if(!t)return null;let n=met[t.kind],i=v?.nodes.has(e.id)??!1,a=v!==null&&!i;return(0,$.jsxs)(`button`,{type:`button`,title:t.range?r(`result.structure.reveal`):void 0,onClick:()=>ne(t),onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(t=>t===e.id?null:t),onFocus:()=>g(e.id),onBlur:()=>g(t=>t===e.id?null:t),className:`absolute overflow-hidden rounded-md border text-left shadow-sm`,style:{left:e.x,top:e.y,width:e.width,height:e.height,background:h===e.id?`var(--t-surface1)`:`var(--t-surface0)`,borderColor:i?`var(--t-blue)`:`var(--t-surface2, var(--t-overlay0))`,borderLeft:`3px solid ${n}`,cursor:t.range?`pointer`:`default`,opacity:a?.35:1,transition:`opacity 120ms, background 120ms, border-color 120ms`},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 px-2 pt-1.5`,children:[(0,$.jsxs)(`span`,{className:`truncate text-[12px] font-semibold`,style:{color:`var(--t-foreground)`},children:[t.label,t.alias&&(0,$.jsx)(`span`,{className:`ml-1 font-normal`,style:{color:`var(--t-overlay1)`},children:t.alias})]}),(0,$.jsx)(`span`,{className:`shrink-0 rounded px-1 py-px text-[9px] font-semibold`,style:{background:n,color:`var(--t-crust, var(--t-background))`},children:r(het[t.kind])})]}),(0,$.jsx)(`div`,{className:`px-2 pb-1.5 pt-1 text-[11px]`,style:{color:`var(--t-overlay1)`},children:re(t.columnCount)})]},e.id)})]})})]})}var vet=[];function yet({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt).find(e=>e.id===t),i=r?.results??vet,a=!!r?.plan,o=(0,D.useMemo)(()=>r?.graphs??[],[r?.graphs]),[s,c]=(0,D.useState)({results:i,closed:new Set,activeTab:null}),l=s.results===i?s:{results:i,closed:new Set,activeTab:null},u=l.closed,d=(0,D.useMemo)(()=>i.map((e,t)=>({result:e,index:t})).filter(e=>e.result.fields.length>0),[i]),f=(0,D.useMemo)(()=>d.filter(e=>!u.has(e.index)),[d,u]),p=l.activeTab??(d.length>0?`result-${d[0].index}`:`message`),m=(0,D.useCallback)(e=>{c(t=>({...t.results===i?t:{results:i,closed:new Set},activeTab:e}))},[i]),h=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(h.current)return;let n=r?.sourceTable;!n||i.length>0||r?.isExecuting||(h.current=!0,_t.getState().setExecuting(e,t,!0),(async()=>{try{let r=await Z6(e,{database:n.database,table:n.table,tabId:t,page:0});r.sourceTable=n,_t.getState().setResults(e,t,[r])}catch(n){let r=n instanceof Error?n.message:String(n);_t.getState().setError(e,t,r)}finally{_t.getState().setExecuting(e,t,!1)}})())},[r?.sourceTable,r?.isExecuting,i,e,t]);let g=(0,D.useRef)(r?.graphs??null),_=(0,D.useRef)(r?.plan??null);(0,D.useEffect)(()=>{let e=r?.plan??null;e&&e!==_.current&&m(`plan`),_.current=e},[r?.plan,m]),(0,D.useEffect)(()=>{let e=r?.graphs??null;e&&e!==g.current&&e[0]?.focus&&m(`structure-0`),g.current=e},[r?.graphs,m]);let v=(0,D.useCallback)((e,t)=>{e.stopPropagation(),c(e=>{let n=e.results===i?e:{results:i,closed:new Set,activeTab:null},r=new Set(n.closed);r.add(t);let a=p===`result-${t}`;return{results:i,closed:r,activeTab:a?`message`:n.activeTab}})},[i,p]);return(0,$.jsxs)(b5,{value:p,onValueChange:m,className:`relative flex h-full flex-col`,children:[(0,$.jsx)(n3e,{connectionId:e,running:r?.isExecuting??!1}),(0,$.jsxs)(x5,{className:`h-8 w-full justify-start rounded-none border-b bg-muted/30`,children:[(0,$.jsx)(S5,{value:`message`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.message`)}),(0,$.jsx)(S5,{value:`info`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.info`)}),(0,$.jsx)(S5,{value:`history`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.history`)}),a&&(0,$.jsx)(S5,{value:`plan`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.plan`)}),f.map((e,t)=>(0,$.jsxs)(S5,{value:`result-${e.index}`,className:`h-7 gap-1 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:[(0,$.jsx)(`span`,{children:d.length===1?n(`result.tabs.result`):n(`result.tabs.resultN`,{n:t+1})}),(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:t=>v(t,e.index),children:(0,$.jsx)(b,{className:`size-3`})})]},`result-${e.index}`)),o.map((e,t)=>(0,$.jsx)(S5,{value:`structure-${t}`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:o.length===1?n(`result.tabs.structure`):n(`result.tabs.structureN`,{n:t+1})},`structure-${t}`))]}),(0,$.jsx)(C5,{value:`message`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(y3e,{connectionId:e,tabId:t})}),(0,$.jsx)(C5,{value:`info`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(W9e,{connectionId:e,tabId:t})}),(0,$.jsx)(C5,{value:`history`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(X9e,{connectionId:e})}),a&&(0,$.jsx)(C5,{value:`plan`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(ret,{connectionId:e,tabId:t})}),o.map((n,r)=>(0,$.jsx)(C5,{value:`structure-${r}`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(_et,{connectionId:e,tabId:t,index:r})},`structure-${r}`)),f.map(n=>(0,$.jsx)(C5,{value:`result-${n.index}`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(H9e,{connectionId:e,tabId:t,resultIndex:n.index})},`result-${n.index}`))]})}function bet({connectionId:e,tabId:t}){let[n,r]=(0,D.useState)(300),[i,a]=(0,D.useState)(!1),o=(0,D.useRef)(null),s=(0,D.useCallback)(e=>{e.preventDefault(),a(!0)},[]);return(0,D.useEffect)(()=>{if(!i)return;let e=e=>{if(!o.current)return;let t=o.current.getBoundingClientRect().bottom-e.clientY;r(Math.min(600,Math.max(100,t)))},t=()=>{a(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[i]),(0,$.jsxs)(`div`,{ref:o,className:`flex h-full flex-col`,style:{userSelect:i?`none`:void 0},children:[(0,$.jsx)(`div`,{className:`min-h-[100px] flex-1`,children:(0,$.jsx)(t3e,{connectionId:e,tabId:t})}),(0,$.jsx)(`div`,{onMouseDown:s,className:`h-1 flex-shrink-0 cursor-row-resize border-t transition-colors ${i?`bg-primary/40`:`hover:bg-primary/40`}`}),(0,$.jsx)(`div`,{className:`flex-shrink-0 overflow-hidden`,style:{height:n},children:(0,$.jsx)(yet,{connectionId:e,tabId:t})})]})}async function xet(e,t){let n=Ut(e),r=xt(e),{introspect:i}=n,a=await i.listTables(r,t),o=a.map(e=>e.name),[s,c,l]=await Promise.all([i.listAllColumns(r,t),i.listAllIndexes(r,t).catch(()=>new Map),i.listForeignKeys(r,t).catch(()=>[])]),u=new Set;for(let e of l)u.add(`${e.table}.${e.column}`);let d=new Set;for(let[e,t]of c)for(let n of t)n.type===`UNIQUE`&&n.columns.length===1&&d.add(`${e}.${n.columns[0]}`);let f=a.map(e=>({name:e.name,kind:`model`,x:0,y:0,comment:e.comment,columns:(s.get(e.name)??[]).map(t=>{let n=`${e.name}.${t.name}`,r=[];return t.key===`PRI`&&r.push(`PK`),u.has(n)&&r.push(`FK`),d.has(n)&&t.key!==`PRI`&&r.push(`UK`),{type:t.type+(t.extra.includes(`auto_increment`)?` AI`:``)+(t.nullable?`?`:``),name:t.name,badge:r.length>0?r[0]:null,badges:r,comment:t.comment}})})),p=new Set(o),m=new Set,h=[];for(let e of l){let{table:t,column:n,refTable:r}=e;if(!t||!r||!p.has(t)||!p.has(r)||t===r)continue;let i=`${t}->${r}:${n}`,a=`${r}->${t}:${n}`;m.has(i)||m.has(a)||(m.add(i),h.push({from:t,to:r,type:`1:N`,label:n}))}return{models:f,relations:h}}var T9=[70,170,180];function E9(e){return 52+e.columns.length*22+4}function D9(e){return e.reduce((e,t)=>e+t,0)+20}var Cet=2.399963229728653,O9=50,wet=50,k9=56,A9=D9(T9),Tet=120,Eet=.5,Det=.15,Oet=.15,ket=1.6;function Aet(e,t,n,r=80){let i=e.length,a=t.map(e=>({hw:e.w/2+n/2,hh:e.h/2+n/2})),o=!1;for(let t=0;t<r;t++){let t=!1;for(let n=0;n<i;n++)for(let r=n+1;r<i;r++){let i=e[r].x-e[n].x,o=e[r].y-e[n].y,s=a[n].hw+a[r].hw-Math.abs(i),c=a[n].hh+a[r].hh-Math.abs(o);if(s>0&&c>0){if(t=!0,s<c){let t=(i<0?-1:1)*s/2;e[n].x-=t,e[r].x+=t}else{let t=(o<0?-1:1)*c/2;e[n].y-=t,e[r].y+=t}}}if(!t)break;o=!0}return o}function jet(e,t){let n=e.length,r=e.map(e=>({w:A9,h:E9(e)})),i=r.reduce((e,t)=>e+t.h,0)/n,a=Math.max(A9,i)*.32+24,o=e.map((e,t)=>{let n=a*.55*Math.sqrt(t+.5);return{x:Math.cos(t*Cet)*n,y:Math.sin(t*Cet)*n}}),s=a*1.8,c=s/321,l=o.map(()=>({x:0,y:0}));for(let e=0;e<320;e++){for(let e=0;e<n;e++)l[e].x=0,l[e].y=0;for(let e=0;e<n;e++)for(let t=e+1;t<n;t++){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,s=.28*a*a/i,c=n/i,u=r/i;l[e].x+=c*s,l[e].y+=u*s,l[t].x-=c*s,l[t].y-=u*s}for(let[e,n]of t){let t=o[e].x-o[n].x,r=o[e].y-o[n].y,i=Math.hypot(t,r)||.01,s=i*i/a,c=t/i,u=r/i;l[e].x-=c*s,l[e].y-=u*s,l[n].x+=c*s,l[n].y+=u*s}for(let e=0;e<n;e++)l[e].x-=o[e].x*.1,l[e].y-=o[e].y*.1;for(let e=0;e<n;e++){let t=Math.hypot(l[e].x,l[e].y)||.01,n=Math.min(t,s);o[e].x+=l[e].x/t*n,o[e].y+=l[e].y/t*n}s=Math.max(s-c,a*.05)}Aet(o,r,k9);let u=1/0,d=1/0;for(let e=0;e<n;e++)u=Math.min(u,o[e].x-r[e].w/2),d=Math.min(d,o[e].y-r[e].h/2);return e.map((e,t)=>({x:o[t].x-r[t].w/2-u,y:o[t].y-r[t].h/2-d}))}function Met(e){let t=Math.max(1,Math.round(Math.sqrt(e.length))),n=Array(t).fill(0);return e.map(e=>{let r=0;for(let e=1;e<t;e++)n[e]<n[r]&&(r=e);let i={x:r*(A9+k9),y:n[r]};return n[r]+=E9(e)+k9,i})}function Net(e,t,n){let r=[...e,...t];if(r.length===0)return;let i=new Map(r.map((e,t)=>[e.name,t])),a=Array(r.length).fill(0),o=[];n.forEach(e=>{let t=i.get(e.from),n=i.get(e.to);t!==void 0&&n!==void 0&&t!==n&&(o.push([t,n]),a[t]++,a[n]++)});let s=r.filter((e,t)=>a[t]>0),c=r.filter((e,t)=>a[t]===0),l=O9;if(s.length>0){let e=new Map(s.map((e,t)=>[e.name,t])),t=jet(s,o.map(([t,n])=>[e.get(r[t].name),e.get(r[n].name)]).filter(([e,t])=>e!==void 0&&t!==void 0));s.forEach((e,n)=>{e.x=Math.round(O9+t[n].x),e.y=Math.round(wet+t[n].y),l=Math.max(l,e.x+A9)})}if(c.length>0){let e=s.length>0?l+Tet:O9,t=Met(c);c.forEach((n,r)=>{n.x=Math.round(e+t[r].x),n.y=Math.round(wet+t[r].y)})}}function Pet(e,t,n,r=100){let i=e.length;if(i<2)return!1;let a=e.map(e=>({w:n(e),h:E9(e)})),o=e.map((e,t)=>({x:e.x+a[t].w/2,y:e.y+a[t].h/2})),s=Math.min(...e.map(e=>e.x)),c=Math.min(...e.map(e=>e.y)),l=new Map(e.map((e,t)=>[e.name,t])),u=[];for(let e of t){let t=l.get(e.from),n=l.get(e.to);t!==void 0&&n!==void 0&&t!==n&&u.push([t,n])}let d=(e,t)=>Math.max((a[e].w+a[t].w)/2,(a[e].h+a[t].h)/2)+r,f=a.map(e=>(Math.max(e.w,e.h)+r)/2).reduce((e,t)=>e+t*t,0),p=Math.sqrt(f)*1.45,m=o.map(()=>({x:0,y:0})),h=r,g=h/201;for(let e=0;e<200;e++){for(let e=0;e<i;e++)m[e].x=0,m[e].y=0;for(let e=0;e<i;e++)for(let t=e+1;t<i;t++){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,a=d(e,t);if(i>=a)continue;let s=Eet*(a-i),c=n/i,l=r/i;m[e].x+=c*s,m[e].y+=l*s,m[t].x-=c*s,m[t].y-=l*s}for(let[e,t]of u){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,a=(i-d(e,t)*ket)*Det,s=n/i,c=r/i;m[e].x-=s*a,m[e].y-=c*a,m[t].x+=s*a,m[t].y+=c*a}let e=0,t=0;for(let n of o)e+=n.x,t+=n.y;e/=i,t/=i;for(let n=0;n<i;n++){let r=o[n].x-e,i=o[n].y-t,a=Math.hypot(r,i);if(a<=p)continue;let s=(a-p)*Oet;m[n].x-=r/a*s,m[n].y-=i/a*s}for(let e=0;e<i;e++){let t=Math.hypot(m[e].x,m[e].y)||.01,n=Math.min(t,h);o[e].x+=m[e].x/t*n,o[e].y+=m[e].y/t*n}h=Math.max(h-g,0)}Aet(o,a,r,300);let _=1/0,v=1/0;for(let e=0;e<i;e++)_=Math.min(_,o[e].x-a[e].w/2),v=Math.min(v,o[e].y-a[e].h/2);let y=s-_,b=c-v,x=!1;return e.forEach((e,t)=>{let n=Math.round(o[t].x-a[t].w/2+y),r=Math.round(o[t].y-a[t].h/2+b);(n!==e.x||r!==e.y)&&(x=!0),e.x=n,e.y=r}),x}function Fet(e,t){return`${e.targetConnectionId?`${t.connectionName(e.targetConnectionId)} · ${e.targetDatabase}`:e.targetDatabase}.${e.targetTable}`}function Iet(e,t,n,r){let i=new Map(e.map(e=>[e.name,e])),a=new Set(t.map(e=>`${e.from}->${e.to}:${e.label}`)),o=[...e],s=[...t],c=new Map;for(let e of n.filter(e=>e.database===r.database)){let t=i.get(e.table);if(!t)continue;let n=!e.targetConnectionId&&e.targetDatabase===r.database,l;if(n&&i.has(e.targetTable))l=e.targetTable;else{l=Fet(e,r);let n=c.get(l);n||(n={name:l,kind:`model`,external:e.targetConnectionId?r.connectionName(e.targetConnectionId):e.targetDatabase,x:t.x+D9(T9)+120,y:t.y,comment:``,columns:[]},c.set(l,n),o.push(n)),n.columns.some(t=>t.name===e.targetColumn)||n.columns.push({type:``,name:e.targetColumn,badge:`PK`,badges:[`PK`],comment:``})}if(e.table===l)continue;let u=`${e.table}->${l}:${e.column}`;a.has(u)||(a.add(u),s.push({from:e.table,to:l,type:`1:N`,label:e.column,virtual:!0}))}return{models:o,relations:s}}function Let({zoom:e,database:t,tableCount:n,relationCount:r,fieldCount:i,onZoomIn:a,onZoomOut:o,onResetView:s,onCenter:c,onFitAll:l,onSpreadAll:u,onResetLayout:d,onRefresh:f,isFullscreen:p,onToggleFullscreen:m}){let{t:h}=S();return(0,$.jsxs)(`div`,{className:`relative z-10 flex flex-wrap items-center gap-1.5 border-b px-4 py-1.5`,style:{background:`var(--t-mantle)`,borderColor:`var(--t-surface1)`},children:[t&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-semibold`,style:{color:`var(--t-yellow)`},children:[(0,$.jsx)(D6,{className:`size-3.5`}),t]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2.5 text-xs`,style:{borderColor:`var(--t-green)`,color:`var(--t-green)`},onClick:f,children:[(0,$.jsx)(L6,{className:`size-3.5`}),h(`erd.toolbar.refresh`)]}),(0,$.jsx)(`div`,{className:`mx-1 h-5 w-px`,style:{background:`var(--t-surface1)`}}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:a,children:[(0,$.jsx)(O1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.zoomIn`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:o,children:[(0,$.jsx)(k1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.zoomOut`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:s,children:[(0,$.jsx)(u1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.resetView`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:c,children:[(0,$.jsx)(W$e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.center`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:l,children:[(0,$.jsx)(a1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.fitAll`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:m,title:h(p?`erd.toolbar.exitFullscreen`:`erd.toolbar.fullscreen`),children:[p?(0,$.jsx)(p1e,{className:`mr-1 size-3.5`}):(0,$.jsx)(G$e,{className:`mr-1 size-3.5`}),h(p?`erd.toolbar.exitFullscreen`:`erd.toolbar.fullscreen`)]}),(0,$.jsxs)(`span`,{className:`ml-1 text-xs`,style:{color:`var(--t-overlay0)`},children:[Math.round(e*100),`%`]}),(0,$.jsx)(`div`,{className:`mx-1 h-5 w-px`,style:{background:`var(--t-surface1)`}}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,style:{background:`var(--t-blue)`,color:`var(--t-crust)`,borderColor:`var(--t-blue)`},onClick:u,children:[(0,$.jsx)(k$e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.spreadAll`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,style:{background:`var(--t-red)`,color:`var(--t-crust)`,borderColor:`var(--t-red)`},onClick:d,children:[(0,$.jsx)(n1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.resetLayout`)]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-4 text-[11px]`,style:{color:`var(--t-overlay0)`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`inline-block h-0.5 w-[30px]`,style:{background:`var(--t-red)`}}),`1:1`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`inline-block h-0.5 w-[30px]`,style:{background:`var(--t-blue)`}}),h(`erd.toolbar.legendOneToMany`)]}),n>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px]`,style:{color:`var(--t-overlay0)`},children:[(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.tables`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:n})]}),(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.relations`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:r})]}),(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.columns`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:i})]})]})]})]})}function Ret({name:e,kind:t,external:n,onDragStart:r}){let{t:i}=S(),a=i(n?`erd.entity.linkBadge`:t===`enum`?`erd.entity.enumBadge`:`erd.entity.modelBadge`),o=n?`var(--t-yellow)`:t===`enum`?`var(--t-peach)`:`var(--t-mauve)`;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-md border-b-2 px-3 py-2 text-[13px] font-bold`,style:{background:`var(--t-surface1)`,borderColor:`var(--t-surface2, var(--t-overlay0))`,color:`var(--t-mauve)`,cursor:`grab`},onMouseDown:r,children:[(0,$.jsx)(`span`,{title:n?i(`erd.entity.externalTitle`,{location:n}):void 0,children:e}),(0,$.jsx)(`span`,{className:`rounded px-1.5 py-px text-[9px] font-semibold`,style:{background:o,color:`var(--t-base)`},children:a})]})}function zet(e){switch(e){case`PK`:return`var(--t-red)`;case`FK`:return`var(--t-peach)`;case`UK`:return`var(--t-green)`;default:return`var(--t-overlay0)`}}function Bet({entity:e,colWidths:t,onColResizeStart:n}){let{t:r}=S(),i=e.kind===`enum`;return(0,$.jsx)(`div`,{className:`overflow-hidden p-0`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-[11px]`,style:{tableLayout:`fixed`},children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{style:{width:t[0]+`px`}}),(0,$.jsx)(`col`,{style:{width:t[1]+`px`}}),(0,$.jsx)(`col`,{style:{width:t[2]+`px`}})]}),(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.value`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,0)})]}),(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.comment`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,1)})]}),(0,$.jsx)(`th`,{className:`px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`}})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.type`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,0)})]}),(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.column`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,1)})]}),(0,$.jsx)(`th`,{className:`px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:r(`erd.entity.columns.comment`)})]})})}),(0,$.jsx)(`tbody`,{children:e.columns.map((t,n)=>(0,$.jsx)(`tr`,{style:{borderBottom:n<e.columns.length-1?`1px solid var(--t-surface1)`:`none`},children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-yellow)`,lineHeight:1.5},children:t.name}),(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px] text-[10px]`,style:{color:`var(--t-overlay0)`,lineHeight:1.5},colSpan:2,children:t.comment})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-blue)`,lineHeight:1.5},children:t.type.replace(`?`,``)}),(0,$.jsxs)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-text)`,lineHeight:1.5},children:[t.name,t.badges.map(e=>(0,$.jsx)(`span`,{className:`ml-1 inline-block rounded px-1 text-[9px] font-semibold`,style:{background:zet(e),color:`var(--t-base)`},children:e},e)),t.type.endsWith(`?`)&&(0,$.jsx)(`span`,{className:`ml-1 inline-block rounded px-1 text-[9px] font-semibold`,style:{background:`var(--t-overlay0)`,color:`var(--t-subtext0)`},title:r(`erd.entity.nullable`),children:`NULL`})]}),(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px] text-[10px]`,style:{color:`var(--t-overlay0)`,lineHeight:1.5},children:t.comment})]})},n))})]})})}function Vet({entity:e,colWidths:t,isSelected:n,onMouseDown:r,onColResizeStart:i}){let a=(0,D.useCallback)(t=>{r(t,e.name)},[r,e.name]),o=t.reduce((e,t)=>e+t,0)+20,s=n?`var(--t-yellow)`:e.kind===`enum`?`var(--t-peach)`:`var(--t-overlay0)`;return(0,$.jsxs)(`div`,{className:`absolute select-none rounded-lg`,style:{left:e.x,top:e.y,width:Math.max(o,200),minWidth:200,background:`var(--t-base)`,border:`2px solid ${s}`,boxShadow:n?`0 8px 24px rgba(0,0,0,0.6)`:`0 4px 12px rgba(0,0,0,0.4)`,zIndex:n?1e3:1,transition:`box-shadow 0.15s`},onMouseEnter:t=>{if(!n){let n=t.currentTarget;n.style.borderColor=e.kind===`enum`?`var(--t-yellow)`:`var(--t-blue)`}},onMouseLeave:t=>{if(!n){let n=t.currentTarget;n.style.borderColor=e.kind===`enum`?`var(--t-peach)`:`var(--t-overlay0)`}},children:[(0,$.jsx)(Ret,{name:e.name,kind:e.kind,external:e.external,onDragStart:a}),(0,$.jsx)(Bet,{entity:e,colWidths:t,onColResizeStart:i})]})}function Het(e,t){return e[t]||[...T9]}function Uet(e,t){let n=D9(Het(t,e.name)),r=E9(e);return{x:e.x,y:e.y,w:n,h:r,cx:e.x+n/2,cy:e.y+r/2}}function Wet({entities:e,relations:t,entityWidths:n}){let r=(()=>{if(e.length===0)return null;let r=new Map;e.forEach(e=>r.set(e.name,e));let i=1/0,a=1/0,o=-1/0,s=-1/0;e.forEach(e=>{let t=Het(n,e.name);i=Math.min(i,e.x-200),a=Math.min(a,e.y-200),o=Math.max(o,e.x+D9(t)+200),s=Math.max(s,e.y+E9(e)+200)});let c=o-i,l=s-a,u={};function d(e,t){let n=`${e}_${t}`;return u[n]||(u[n]=0),(u[n]++-1)*16}let f=[];return t.forEach(e=>{let t=r.get(e.from),i=r.get(e.to);if(!t||!i)return;let a=Uet(t,n),o=Uet(i,n),s,c,l,u,p=o.cx-a.cx,m=o.cy-a.cy;if(Math.abs(p)>Math.abs(m)){if(p>0){let t=d(e.from,`right`),n=d(e.to,`left`);s=a.x+a.w+16,c=a.y+40+t,l=o.x-16,u=o.y+40+n}else{let t=d(e.from,`left`),n=d(e.to,`right`);s=a.x-16,c=a.y+40+t,l=o.x+o.w+16,u=o.y+40+n}}else if(m>0){let t=d(e.from,`bottom`),n=d(e.to,`top`);s=a.x+60+t,c=a.y+a.h+16,l=o.x+60+n,u=o.y-16}else{let t=d(e.from,`top`),n=d(e.to,`bottom`);s=a.x+60+t,c=a.y-16,l=o.x+60+n,u=o.y+o.h+16}let h=e.type===`1:1`?`var(--t-red)`:`var(--t-blue)`,g=e.type===`1:1`?`url(#erd-one)`:`url(#erd-crowfoot)`,_=(s+l)/2,v=(c+u)/2,y=Math.abs(p)>Math.abs(m)?`M${s},${c} C${_},${c} ${_},${u} ${l},${u}`:`M${s},${c} C${s},${v} ${l},${v} ${l},${u}`;f.push({d:y,color:h,markerEnd:g,label:`${e.virtual?`⇢ `:``}${e.type} ${e.label}`,midX:_,midY:v,virtual:!!e.virtual})}),{minX:i,minY:a,svgW:c,svgH:l,paths:f}})();if(!r)return null;let{minX:i,minY:a,svgW:o,svgH:s,paths:c}=r;return(0,$.jsxs)(`svg`,{className:`pointer-events-none absolute left-0 top-0`,style:{left:i,top:a},width:o,height:s,viewBox:`${i} ${a} ${o} ${s}`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`marker`,{id:`erd-crowfoot`,viewBox:`0 0 12 12`,refX:`12`,refY:`6`,markerWidth:`10`,markerHeight:`10`,orient:`auto`,children:[(0,$.jsx)(`line`,{x1:`0`,y1:`0`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`}),(0,$.jsx)(`line`,{x1:`0`,y1:`12`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`}),(0,$.jsx)(`line`,{x1:`0`,y1:`6`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`})]}),(0,$.jsxs)(`marker`,{id:`erd-one`,viewBox:`0 0 12 12`,refX:`12`,refY:`6`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:[(0,$.jsx)(`line`,{x1:`8`,y1:`0`,x2:`8`,y2:`12`,stroke:`var(--t-red)`,strokeWidth:`2`}),(0,$.jsx)(`line`,{x1:`12`,y1:`0`,x2:`12`,y2:`12`,stroke:`var(--t-red)`,strokeWidth:`2`})]})]}),c.map((e,t)=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:`1.5`,fill:`none`,markerEnd:e.markerEnd,opacity:`0.7`,strokeDasharray:e.virtual?`6 4`:void 0}),(0,$.jsx)(`text`,{x:e.midX,y:e.midY-6,textAnchor:`middle`,fill:`var(--t-overlay0)`,fontSize:`10`,children:e.label})]},t))]})}var Get=.15,Ket=3,qet=.0012,Jet=120,Yet=e=>Math.max(Get,Math.min(Ket,e));function Xet(e){let t=yt.getState(),n=t.selectedNodeId[e],r=t.trees[e];if(!r)return null;let i=null,a=null;function o(e){for(let t of e){let e=t.metadata?.database;e&&a===null&&(t.type===Be.DATABASE||t.type===Be.SCHEMA)&&(a=e),t.id===n&&e&&(i=e),t.children.length>0&&o(t.children)}}return o(r),i??a}function Zet({connectionId:e}){let{t}=S(),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)([]),[o,s]=(0,D.useState)(1),[c,l]=(0,D.useState)(0),[u,d]=(0,D.useState)(0),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)({}),[g,_]=(0,D.useState)(null),[v,y]=(0,D.useState)(!1),[b,x]=(0,D.useState)(null),[,C]=(0,D.useState)(0),w=(0,D.useRef)(null),ee=(0,D.useRef)(null),[te,T]=(0,D.useState)(!1),ne=(0,D.useRef)(null),re=(0,D.useRef)(!1),ie=(0,D.useRef)({x:0,y:0}),ae=(0,D.useRef)({x:0,y:0}),E=(0,D.useRef)(1),oe=(0,D.useRef)(null),se=(0,D.useRef)(null),ce=(0,D.useRef)([]),le=(0,D.useRef)({}),ue=(0,D.useRef)(null),de=(0,D.useRef)(null),fe=V8(e=>e.links),pe=(0,D.useCallback)((t,n)=>{let r=(V8.getState().links[e]??[]).filter(e=>e.database===n);return r.length===0?{models:[...t.models],relations:[...t.relations]}:Iet(t.models.map(e=>({...e})),t.relations,r,{connectionId:e,database:n,connectionName:e=>{let t=Je.getState().activeConnections.find(t=>t.id===e)??Je.getState().savedConnections.find(t=>t.id===e);return t?t.hostName||t.host||t.file||t.id:e}})},[e]);(0,D.useEffect)(()=>{let e=de.current,t=ue.current;if(!e||!t)return;let n=pe(e,t),i=new Map(ce.current.map(e=>[e.name,{x:e.x,y:e.y}]));for(let e of n.models){let t=i.get(e.name);t&&(e.x=t.x,e.y=t.y)}ce.current=n.models,r(n.models),a(n.relations)},[fe]),ce.current=n,le.current=m,E.current=o,ae.current={x:c,y:u},ue.current=g;let me=(0,D.useCallback)(e=>le.current[e]||[...T9],[]),he=(0,D.useCallback)(()=>{let e={};ce.current.forEach(t=>{e[t.name]={x:t.x,y:t.y}}),R8.getState().savePositions(ue.current,e)},[]),ge=(0,D.useCallback)(()=>{R8.getState().saveColumnWidths(ue.current,le.current)},[]),_e=(0,D.useCallback)(e=>{let t=R8.getState().getPositions(ue.current);return t?(e.forEach(e=>{t[e.name]&&(e.x=t[e.name].x,e.y=t[e.name].y)}),!0):!1},[]),ve=(0,D.useCallback)(()=>R8.getState().getColumnWidths(ue.current),[]),ye=(0,D.useCallback)(()=>{let e=ce.current;if(e.length===0)return;let t=w.current;if(!t)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(e=>{let t=me(e.name);n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+D9(t)),a=Math.max(a,e.y+E9(e))});let o=i-n+80,c=a-r+80,u=t.clientWidth,f=t.clientHeight,p=Math.min(u/o,f/c,1),m=(u-o*p)/2-n*p+40,h=(f-c*p)/2-r*p+40;s(p),l(m),d(h)},[me]),be=(0,D.useCallback)(()=>{let e=ce.current;if(e.length===0)return;let t=w.current;if(!t)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(e=>{let t=me(e.name);n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+D9(t)),a=Math.max(a,e.y+E9(e))});let o=i-n+80,s=a-r+80,c=t.clientWidth,u=t.clientHeight,f=E.current;l((c-o*f)/2-n*f+40),d((u-s*f)/2-r*f+40)},[me]),xe=(0,D.useCallback)(async n=>{let i=Je.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId;if(!i){x(t(`erd.viewer.noServerConnection`));return}y(!0),x(null),_(n),ue.current=n,R8.getState().setDatabase(e,n);try{let e=await xet(i,n);de.current=e;let{models:t,relations:o}=pe(e,n);Net(t,[],o),_e(t);let s=ve();r([...t]),a(o),h(s),ce.current=t,le.current=s,setTimeout(()=>ye(),100)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e,_e,ve,ye,t]);(0,D.useEffect)(()=>{let t=R8.getState().database[e]||Xet(e);t&&xe(t)},[e]);let Se=(0,D.useCallback)(()=>{let t=g||Xet(e);t&&xe(t)},[g,e,xe]),Ce=(0,D.useCallback)((e,t)=>{e.stopPropagation();let n=w.current;if(!n)return;let r=ce.current.find(e=>e.name===t);if(!r)return;let i=n.getBoundingClientRect(),a=(e.clientX-i.left-ae.current.x)/E.current,o=(e.clientY-i.top-ae.current.y)/E.current;oe.current={name:t,offsetX:a-r.x,offsetY:o-r.y},p(t)},[]),we=(0,D.useCallback)((e,t,n)=>{e.stopPropagation(),e.preventDefault();let r=le.current[t]||[...T9];se.current={entityName:t,colIndex:n,startX:e.clientX,startWidth:r[n],nextStartWidth:r[n+1]},document.body.style.cursor=`col-resize`},[]),Te=(0,D.useCallback)(e=>{e.target.closest(`[data-entity]`)||e.button===0&&(re.current=!0,ie.current={x:e.clientX-ae.current.x,y:e.clientY-ae.current.y},p(null))},[]);(0,D.useEffect)(()=>{let e=e=>{if(se.current){let t=se.current,n=(e.clientX-t.startX)/E.current,r=Math.max(30,Math.round(t.startWidth+n)),i=Math.max(30,Math.round(t.nextStartWidth-n));h(e=>{let n=[...e[t.entityName]||[...T9]];return n[t.colIndex]=r,n[t.colIndex+1]=i,{...e,[t.entityName]:n}});return}if(oe.current){let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=(e.clientX-n.left-ae.current.x)/E.current,i=(e.clientY-n.top-ae.current.y)/E.current,a=Math.round(r-oe.current.offsetX),o=Math.round(i-oe.current.offsetY),s=ce.current.find(e=>e.name===oe.current.name);s&&(s.x=a,s.y=o,C(e=>e+1));return}re.current&&(l(e.clientX-ie.current.x),d(e.clientY-ie.current.y))},t=()=>{if(se.current){document.body.style.cursor=``,ge(),se.current=null;return}if(oe.current){oe.current=null,he();return}re.current=!1};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[he,ge]),(0,D.useEffect)(()=>{let e=w.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=E.current,o=t.deltaMode===1?16:t.deltaMode===2?n.height:1,c=Math.max(-120,Math.min(Jet,t.deltaY*o)),u=Yet(a*Math.exp(-c*qet));if(u===a)return;let f=(r-ae.current.x)/a,p=(i-ae.current.y)/a;l(r-f*u),d(i-p*u),s(u)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let Ee=(0,D.useCallback)(e=>{let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.width/2,i=n.height/2,a=E.current,o=Yet(a*e);if(o===a)return;let c=(r-ae.current.x)/a,u=(i-ae.current.y)/a;l(r-c*o),d(i-u*o),s(o)},[]),De=(0,D.useCallback)(()=>Ee(1.15),[Ee]),Oe=(0,D.useCallback)(()=>Ee(1/1.15),[Ee]),ke=(0,D.useCallback)(()=>{s(1),l(0),d(0)},[]),Ae=(0,D.useCallback)(()=>{Pet(ce.current,i,e=>D9(me(e.name)))&&(r([...ce.current]),he())},[i,he,me]),je=(0,D.useCallback)(()=>{R8.getState().resetLayout(ue.current),Net(ce.current,[],i),r([...ce.current]),h({}),setTimeout(()=>ye(),50)},[i,ye]),Me=n.length>0,Ne=n.reduce((e,t)=>e+t.columns.length,0),Pe=(0,D.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):ee.current?.requestFullscreen().catch(()=>{})},[]);return(0,D.useEffect)(()=>{let e=()=>{T(document.fullscreenElement===ee.current),setTimeout(()=>ye(),60)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[ye]),(0,$.jsxs)(`div`,{ref:ee,className:`flex h-full flex-col`,style:{background:`var(--t-background)`},children:[(0,$.jsx)(Let,{zoom:o,database:g,tableCount:n.length,relationCount:i.length,fieldCount:Ne,onZoomIn:De,onZoomOut:Oe,onResetView:ke,onCenter:be,onFitAll:ye,onSpreadAll:Ae,onResetLayout:je,onRefresh:Se,isFullscreen:te,onToggleFullscreen:Pe}),(0,$.jsxs)(`div`,{ref:w,className:`relative flex-1 overflow-hidden`,style:{cursor:re.current?`grabbing`:`grab`,background:`var(--t-background)`},onMouseDown:Te,children:[v&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-background/80`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(M6,{className:`size-5 animate-spin`}),t(`erd.viewer.loading`,{database:g})]})}),b&&!v&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-sm text-destructive`,children:[(0,$.jsx)(`p`,{children:t(`erd.viewer.loadFailed`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:b})]})}),!Me&&!v&&!b&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`p`,{children:t(`erd.viewer.noDatabase`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:t(`erd.viewer.selectDatabaseHint`)})]})}),Me&&(0,$.jsxs)(`div`,{ref:ne,className:`absolute left-0 top-0`,style:{transformOrigin:`0 0`,transform:`translate(${c}px, ${u}px) scale(${o})`},children:[(0,$.jsx)(Wet,{entities:n,relations:i,entityWidths:m}),n.map(e=>(0,$.jsx)(Vet,{entity:e,colWidths:m[e.name]||[...T9],isSelected:f===e.name,onMouseDown:Ce,onColResizeStart:we},e.name))]})]})]})}function Qet({connectionId:e}){let{t}=S(),n=_t(t=>t.tabs[e]??vt),r=_t(t=>t.activeTabId[e]??null),i=R8(t=>t.open[e]??!1),a=_t(e=>e.addQueryTab),o=_t(e=>e.removeQueryTab),s=_t(e=>e.removeQueryTabs),c=_t(e=>e.setActiveQueryTab),l=r&&(n.some(e=>e.id===r)||r===`erd`&&i)?r:n.length>0?n[n.length-1].id:i?`erd`:null;(0,D.useEffect)(()=>{l&&l!==r&&c(e,l)},[l,r,e,c]);let u=(0,D.useRef)(null);J4e(u,l);let{loadChildren:d}=hn(),f=n.find(e=>e.id===l),p=f?.sourceTable?{database:f.sourceTable.database,type:`TABLE`,name:f.sourceTable.table}:f?.sourceObject??null,m=p?`${p.database}/${p.type}/${p.name}`:null;(0,D.useEffect)(()=>{p&&ln(e,Tn(e,p.database,p.type,p.name),d)},[e,m]);let h=_t(e=>e.reorderQueryTab),g=(0,D.useMemo)(()=>n.map(e=>e.id),[n]),{dragProps:_,dropIndicator:v}=Ke(g,(0,D.useCallback)((t,n)=>h(e,t,n),[e,h])),y=R8(e=>e.closeERD),x=(0,D.useCallback)(e=>{y(e);let t=_t.getState();if(t.activeTabId[e]===`erd`){let n=t.tabs[e]??[];t.setActiveQueryTab(e,n.length>0?n[n.length-1].id:``)}},[y]),C=(0,D.useCallback)(()=>{let r={id:`tab-${Date.now()}`,title:t(`query.tabs.queryTitle`,{n:n.length+1}),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null};a(e,r)},[e,n.length,a,t]),w=(0,D.useCallback)((t,n)=>{if(t.stopPropagation(),n===`erd`){x(e);return}o(e,n)},[e,o,x]),ee=(0,D.useCallback)((t,r)=>{let a=n.findIndex(e=>e.id===t),o=n.filter((e,n)=>{switch(r){case`all`:return!0;case`others`:return e.id!==t;case`left`:return n<a;case`right`:return n>a}}).map(e=>e.id);o.length>0&&s(e,o),i&&(r===`all`||r===`others`||r===`right`)&&x(e)},[n,i,e,s,x]),te=(0,D.useCallback)(t=>{c(e,t);let r;r=t===`erd`?R8.getState().database[e]:n.find(e=>e.id===t)?.database,r&&mn(e,r)},[e,n,c]);return n.length===0&&!i?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(ne,{variant:`outline`,onClick:C,children:[(0,$.jsx)(I6,{className:`mr-1 size-4`}),t(`query.tabs.newQuery`)]})}):(0,$.jsxs)(b5,{value:l??void 0,onValueChange:te,className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center border-b bg-muted/30`,children:[(0,$.jsxs)(`div`,{ref:u,className:`min-w-0 flex-1 overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,$.jsxs)(x5,{className:`h-9 w-max rounded-none bg-transparent`,children:[n.map((r,a)=>(0,$.jsxs)(h5,{children:[(0,$.jsx)(g5,{asChild:!0,children:(0,$.jsxs)(S5,{value:r.id,..._(r.id),"data-drop-before":v===r.id||void 0,className:`shrink-0 gap-1 data-[drop-before]:shadow-[inset_2px_0_0_var(--color-primary)] !rounded-none !border-0 !border-b-2 !border-transparent px-3 py-1.5 !text-muted-foreground hover:!text-foreground aria-selected:!bg-primary aria-selected:!text-primary-foreground aria-selected:!border-primary aria-selected:font-semibold aria-selected:!shadow-none after:!hidden`,children:[r.sourceTable&&(0,$.jsx)(_1e,{className:`size-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`max-w-[120px] truncate text-xs`,children:r.title}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:e=>w(e,r.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w(e,r.id))},children:(0,$.jsx)(b,{className:`size-3`})})]})}),(0,$.jsxs)(_5,{children:[(0,$.jsx)(v5,{onSelect:()=>o(e,r.id),children:t(`query.tabs.close`)}),(0,$.jsx)(v5,{disabled:n.length<=1&&!i,onSelect:()=>ee(r.id,`others`),children:t(`query.tabs.closeOthers`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{disabled:a===0,onSelect:()=>ee(r.id,`left`),children:t(`query.tabs.closeLeft`)}),(0,$.jsx)(v5,{disabled:a===n.length-1&&!i,onSelect:()=>ee(r.id,`right`),children:t(`query.tabs.closeRight`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>ee(r.id,`all`),children:t(`query.tabs.closeAll`)})]})]},r.id)),i&&(0,$.jsxs)(S5,{value:`erd`,className:`shrink-0 gap-1 !rounded-none !border-0 !border-b-2 !border-transparent px-3 py-1.5 !text-muted-foreground hover:!text-foreground aria-selected:!bg-primary aria-selected:!text-primary-foreground aria-selected:!border-primary aria-selected:font-semibold aria-selected:!shadow-none after:!hidden`,children:[(0,$.jsx)(`span`,{className:`text-xs`,children:t(`query.tabs.erdViewer`)}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:e=>w(e,`erd`),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w(e,`erd`))},children:(0,$.jsx)(b,{className:`size-3`})})]})]}),v===`end`&&(0,$.jsx)(`div`,{className:`h-6 w-0.5 shrink-0 bg-primary`})]}),(0,$.jsx)(ne,{variant:`ghost`,size:`icon`,className:`mx-1 size-7 shrink-0`,onClick:C,children:(0,$.jsx)(I6,{className:`size-4`})})]}),n.map(t=>(0,$.jsx)(C5,{value:t.id,className:`mt-0 flex-1 overflow-hidden`,forceMount:t.id!==l||void 0,hidden:t.id!==l,children:t.sourceTable?(0,$.jsx)(yet,{connectionId:e,tabId:t.id}):(0,$.jsx)(bet,{connectionId:e,tabId:t.id})},t.id)),i&&(0,$.jsx)(C5,{value:`erd`,className:`mt-0 flex-1 overflow-hidden`,forceMount:l!==`erd`||void 0,hidden:l!==`erd`,children:(0,$.jsx)(Zet,{connectionId:e})})]})}function $et({connectionId:e,fileName:t}){let{t:n}=S(),[r,i]=(0,D.useState)(!1),a=Je(e=>e.closeConnection);async function o(){i(!0);try{let t=await Mt(e,{interactive:!0});if(!t)return;let r=Je.getState();r.updateServerConnectionId(e,t.connectionId),r.updateProfile(e,{file:t.fileName}),r.setPendingReopen(e,!1),r.setFileDetached(e,t.fileDetached),yt.getState().removeTree(e),c.getState().setFooterMessage(n(`connection.tab.reopened`,{file:t.fileName}))}catch(e){c.getState().setFooterMessage(n(`connection.tab.reopenFailed`,{message:e instanceof Error?e.message:String(e)}))}finally{i(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-yellow/40 bg-catppuccin-yellow/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(k6,{className:`size-4 shrink-0 text-catppuccin-yellow`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.reopenPrompt`,values:{file:t||n(`connection.tab.theSqliteFile`)},components:{b:(0,$.jsx)(`span`,{className:`font-medium`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:r,onClick:()=>{o()},children:n(`connection.tab.reopenFile`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 shrink-0 text-xs`,onClick:()=>a(e),children:n(`connection.tab.closeConnection`)})]})}function ett({connectionId:e,serverConnectionId:t,fileName:n}){let{t:r}=S(),[i,a]=(0,D.useState)(!1),o=Je(e=>e.setFileDetached);async function s(){a(!0);try{await Ot(e,t)?(o(e,!1),c.getState().setFooterMessage(r(`connection.tab.reconnected`,{file:n}))):c.getState().setFooterMessage(r(`connection.tab.accessNotGranted`))}finally{a(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-blue/40 bg-catppuccin-blue/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(j6,{className:`size-4 shrink-0 text-catppuccin-blue`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.detachedPrompt`,values:{file:n||r(`connection.tab.theSqliteFile`)},components:{b:(0,$.jsx)(`span`,{className:`font-medium`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:i,onClick:()=>{s()},children:r(`connection.tab.reconnectFile`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 shrink-0 text-xs`,onClick:()=>o(e,!1),title:r(`connection.tab.detachedHide`),children:(0,$.jsx)(b,{className:`size-3`})})]})}function ttt({connectionId:e,serverConnectionId:t,fileName:n,onDismiss:r}){let{t:i}=S(),[a,o]=(0,D.useState)(!1);async function s(){o(!0);try{let r=await Tt(e,t);if(!r)return;Je.getState().updateServerConnectionId(e,r.connectionId),yt.getState().removeTree(e),c.getState().setFooterMessage(r.appliedFrames>0?i(`connection.tab.walFramesApplied`,{count:r.appliedFrames,file:n}):i(`connection.tab.walNoChanges`))}catch(e){c.getState().setFooterMessage(i(`connection.tab.walLoadFailed`,{message:e instanceof Error?e.message:String(e)}))}finally{o(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-peach/40 bg-catppuccin-peach/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(k6,{className:`size-4 shrink-0 text-catppuccin-peach`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.walPrompt`,values:{file:n},components:{b:(0,$.jsx)(`span`,{className:`font-medium`}),mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:a,onClick:()=>{s()},children:i(`connection.tab.loadWal`)}),(0,$.jsx)(ne,{size:`sm`,variant:`outline`,className:`h-7 shrink-0 text-xs`,disabled:a,title:i(`connection.tab.noWalHint`),onClick:()=>{bt(t),c.getState().bumpTransportVersion(),r()},children:i(`connection.tab.noWal`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 w-7 shrink-0 p-0`,"aria-label":i(`connection.tab.dismiss`),title:i(`connection.tab.walHide`),onClick:r,children:(0,$.jsx)(b,{className:`size-3.5`})})]})}function ntt({connectionId:e}){let{t}=S(),n=Je(t=>t.activeConnections.find(t=>t.id===e)),r=m5(n?.environmentColor),i=Je(t=>t.pendingReopen[e]??!1),a=Je(t=>t.fileDetached[e]??!1),o=Ft(n?.serverConnectionId),[s,c]=(0,D.useState)(null),l=!i&&o?.wal&&!o.walApplied&&!o.walAcknowledged&&n?.serverConnectionId&&s!==n.serverConnectionId;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[i&&(0,$.jsx)($et,{connectionId:e,fileName:n?.file??``}),!i&&a&&!n?.sample&&!n?.scratchpad&&n?.serverConnectionId&&(0,$.jsx)(ett,{connectionId:e,serverConnectionId:n.serverConnectionId,fileName:n?.file??``}),l&&(0,$.jsx)(ttt,{connectionId:e,serverConnectionId:n.serverConnectionId,fileName:n?.file??``,onDismiss:()=>c(n.serverConnectionId)}),r&&(0,$.jsxs)(`div`,{className:`flex h-5 shrink-0 items-center gap-2 px-3 text-[11px] font-semibold uppercase tracking-wider text-white`,style:{background:r},children:[(0,$.jsx)(`span`,{children:n?.hostName||n?.host}),n?.readOnly&&(0,$.jsx)(`span`,{className:`rounded bg-black/25 px-1.5 py-px normal-case tracking-normal`,children:t(`connection.tab.readOnlyBadge`)})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,style:r?{boxShadow:`inset 3px 0 0 ${r}`}:void 0,children:(0,$.jsxs)(M4e,{direction:`horizontal`,defaultSize:200,minSize:150,maxSize:600,storageKey:`sidebar`,children:[(0,$.jsx)(`div`,{className:`h-full border-r border-catppuccin-surface1 bg-catppuccin-mantle overflow-hidden`,children:(0,$.jsx)(K4e,{connectionId:e})}),(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(Qet,{connectionId:e})})]})})]})}var j9=`<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>`,M9=`</title><path d="`,N9=`"/></svg>`,rtt={title:`Cloudflare`,slug:`cloudflare`,get svg(){return j9+`Cloudflare`+M9+this.path+N9},path:`M16.5088 16.8447c.1475-.5068.0908-.9707-.1553-1.3154-.2246-.3164-.6045-.499-1.0615-.5205l-8.6592-.1123a.1559.1559 0 0 1-.1333-.0713c-.0283-.042-.0351-.0986-.021-.1553.0278-.084.1123-.1484.2036-.1562l8.7359-.1123c1.0351-.0489 2.1601-.8868 2.5537-1.9136l.499-1.3013c.0215-.0561.0293-.1128.0147-.168-.5625-2.5463-2.835-4.4453-5.5499-4.4453-2.5039 0-4.6284 1.6177-5.3876 3.8614-.4927-.3658-1.1187-.5625-1.794-.499-1.2026.119-2.1665 1.083-2.2861 2.2856-.0283.31-.0069.6128.0635.894C1.5683 13.171 0 14.7754 0 16.752c0 .1748.0142.3515.0352.5273.0141.083.0844.1475.1689.1475h15.9814c.0909 0 .1758-.0645.2032-.1553l.12-.4268zm2.7568-5.5634c-.0771 0-.1611 0-.2383.0112-.0566 0-.1054.0415-.127.0976l-.3378 1.1744c-.1475.5068-.0918.9707.1543 1.3164.2256.3164.6055.498 1.0625.5195l1.8437.1133c.0557 0 .1055.0263.1329.0703.0283.043.0351.1074.0214.1562-.0283.084-.1132.1485-.204.1553l-1.921.1123c-1.041.0488-2.1582.8867-2.5527 1.914l-.1406.3585c-.0283.0713.0215.1416.0986.1416h6.5977c.0771 0 .1474-.0489.169-.126.1122-.4082.1757-.837.1757-1.2803 0-2.6025-2.125-4.727-4.7344-4.727`,source:`https://www.cloudflare.com/logo/`,hex:`F38020`,guidelines:`https://www.cloudflare.com/trademark/`},itt={mysql:{title:`MySQL`,slug:`mysql`,get svg(){return j9+`MySQL`+M9+this.path+N9},path:`M16.405 5.501c-.115 0-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77 18.695h-.927a50.854 50.854 0 00-.27-4.41h-.008l-1.41 4.41H2.45l-1.4-4.41h-.01a72.892 72.892 0 00-.195 4.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335 4.064h.008l1.347-4.064h1.095c.242 2.015.384 3.86.428 5.53zm4.017-4.08c-.378 2.045-.876 3.533-1.492 4.46-.482.716-1.01 1.073-1.583 1.073-.153 0-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268 0 .483-.075.647-.222.197-.18.295-.382.295-.605 0-.155-.077-.47-.23-.944L6.23 14.615h.91l.727 2.36c.164.536.233.91.205 1.123.4-1.064.678-2.227.835-3.483zm12.325 4.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253 0-1.83-.718-2.746-2.155-2.746-.704 0-1.254.232-1.65.697-.43.508-.646 1.256-.646 2.245 0 .972.19 1.686.574 2.14.35.41.877.615 1.583.615.264 0 .506-.033.725-.098l1.325.772.36-.622zM15.5 17.588c-.225-.36-.337-.94-.337-1.736 0-1.393.424-2.09 1.27-2.09.443 0 .77.167.977.5.224.362.336.936.336 1.723 0 1.404-.424 2.108-1.27 2.108-.445 0-.77-.167-.978-.5zm-1.658-.425c0 .47-.172.856-.516 1.156-.344.3-.803.45-1.384.45-.543 0-1.064-.172-1.573-.515l.237-.476c.438.22.833.328 1.19.328.332 0 .593-.073.783-.22a.754.754 0 00.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177 0-.45.157-.81.47-1.085.315-.278.72-.415 1.22-.415.512 0 .98.136 1.4.41l-.213.476a2.726 2.726 0 00-1.064-.23c-.283 0-.502.068-.654.206a.685.685 0 00-.248.524c0 .328.234.61.666.85.393.215 1.187.67 1.187.67.433.305.648.63.648 1.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223 3.223 0 00-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867 8.867 0 00-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69 17.69 0 01-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422 1.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146 1.693.194 2.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445 3.445 0 01-.35-.4 8.76 8.76 0 01-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188 1.01-.027.007-.014 0-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478 2.478 0 01-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953 5.953 0 012.085 2.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z`,source:`https://www.mysql.com/about/legal/logos.html`,hex:`4479A1`,guidelines:`https://www.mysql.com/about/legal/logos.html`},maria:{title:`MariaDB`,slug:`mariadb`,get svg(){return j9+`MariaDB`+M9+this.path+N9},path:`M23.157 4.412c-.676.284-.79.31-1.673.372-.65.045-.757.057-1.212.209-.75.246-1.395.75-2.02 1.59-.296.398-1.249 1.913-1.249 1.988 0 .057-.65.998-.915 1.32-.574.713-1.08 1.079-2.14 1.59-.77.36-1.224.524-4.102 1.477-1.073.353-2.133.738-2.367.864-.852.449-1.515 1.036-2.203 1.938-1.003 1.32-.972 1.313-3.042.947a12.264 12.264 0 00-.675-.063c-.644-.05-1.023.044-1.332.334L0 17.193l.177.088c.094.05.353.234.561.398.215.17.461.347.55.391.088.044.17.088.183.101.012.013-.089.17-.228.353-.435.581-.593.871-.574 1.048.019.164.032.17.43.17.517-.006.826-.056 1.261-.208.65-.233 2.058-.94 2.784-1.4.776-.5 1.717-.998 1.956-1.042.082-.02.354-.07.594-.114.58-.107 1.464-.095 2.587.05.108.013.373.045.6.064.227.025.43.057.454.076.026.012.474.037.998.056.934.026 1.104.007 1.3-.189.126-.133.385-.631.498-.985.209-.643.417-.921.366-.492-.113.966-.322 1.692-.713 2.411-.259.499-.663 1.092-.934 1.395-.322.347-.315.36.088.315.619-.063 1.471-.397 2.096-.82.827-.562 1.647-1.691 2.19-3.03.107-.27.22-.22.183.083-.013.094-.038.315-.057.498l-.031.328.353-.202c.833-.48 1.414-1.262 2.127-2.884.227-.518.877-2.922 1.073-3.976a9.64 9.64 0 01.271-1.042c.127-.429.196-.555.48-.858.183-.19.625-.555.978-.808.72-.505.953-.75 1.187-1.205.208-.417.284-1.13.132-1.357-.132-.202-.284-.196-.763.006Z`,source:`https://mariadb.com/about-us/logos/`,hex:`003545`,guidelines:`https://mariadb.com/about-us/logos/`},postgres:{title:`PostgreSQL`,slug:`postgresql`,get svg(){return j9+`PostgreSQL`+M9+this.path+N9},path:`M23.5594 14.7228a.5269.5269 0 0 0-.0563-.1191c-.139-.2632-.4768-.3418-1.0074-.2321-1.6533.3411-2.2935.1312-2.5256-.0191 1.342-2.0482 2.445-4.522 3.0411-6.8297.2714-1.0507.7982-3.5237.1222-4.7316a1.5641 1.5641 0 0 0-.1509-.235C21.6931.9086 19.8007.0248 17.5099.0005c-1.4947-.0158-2.7705.3461-3.1161.4794a9.449 9.449 0 0 0-.5159-.0816 8.044 8.044 0 0 0-1.3114-.1278c-1.1822-.0184-2.2038.2642-3.0498.8406-.8573-.3211-4.7888-1.645-7.2219.0788C.9359 2.1526.3086 3.8733.4302 6.3043c.0409.818.5069 3.334 1.2423 5.7436.4598 1.5065.9387 2.7019 1.4334 3.582.553.9942 1.1259 1.5933 1.7143 1.7895.4474.1491 1.1327.1441 1.8581-.7279.8012-.9635 1.5903-1.8258 1.9446-2.2069.4351.2355.9064.3625 1.39.3772a.0569.0569 0 0 0 .0004.0041 11.0312 11.0312 0 0 0-.2472.3054c-.3389.4302-.4094.5197-1.5002.7443-.3102.064-1.1344.2339-1.1464.8115-.0025.1224.0329.2309.0919.3268.2269.4231.9216.6097 1.015.6331 1.3345.3335 2.5044.092 3.3714-.6787-.017 2.231.0775 4.4174.3454 5.0874.2212.5529.7618 1.9045 2.4692 1.9043.2505 0 .5263-.0291.8296-.0941 1.7819-.3821 2.5557-1.1696 2.855-2.9059.1503-.8707.4016-2.8753.5388-4.1012.0169-.0703.0357-.1207.057-.1362.0007-.0005.0697-.0471.4272.0307a.3673.3673 0 0 0 .0443.0068l.2539.0223.0149.001c.8468.0384 1.9114-.1426 2.5312-.4308.6438-.2988 1.8057-1.0323 1.5951-1.6698zM2.371 11.8765c-.7435-2.4358-1.1779-4.8851-1.2123-5.5719-.1086-2.1714.4171-3.6829 1.5623-4.4927 1.8367-1.2986 4.8398-.5408 6.108-.13-.0032.0032-.0066.0061-.0098.0094-2.0238 2.044-1.9758 5.536-1.9708 5.7495-.0002.0823.0066.1989.0162.3593.0348.5873.0996 1.6804-.0735 2.9184-.1609 1.1504.1937 2.2764.9728 3.0892.0806.0841.1648.1631.2518.2374-.3468.3714-1.1004 1.1926-1.9025 2.1576-.5677.6825-.9597.5517-1.0886.5087-.3919-.1307-.813-.5871-1.2381-1.3223-.4796-.839-.9635-2.0317-1.4155-3.5126zm6.0072 5.0871c-.1711-.0428-.3271-.1132-.4322-.1772.0889-.0394.2374-.0902.4833-.1409 1.2833-.2641 1.4815-.4506 1.9143-1.0002.0992-.126.2116-.2687.3673-.4426a.3549.3549 0 0 0 .0737-.1298c.1708-.1513.2724-.1099.4369-.0417.156.0646.3078.26.3695.4752.0291.1016.0619.2945-.0452.4444-.9043 1.2658-2.2216 1.2494-3.1676 1.0128zm2.094-3.988-.0525.141c-.133.3566-.2567.6881-.3334 1.003-.6674-.0021-1.3168-.2872-1.8105-.8024-.6279-.6551-.9131-1.5664-.7825-2.5004.1828-1.3079.1153-2.4468.079-3.0586-.005-.0857-.0095-.1607-.0122-.2199.2957-.2621 1.6659-.9962 2.6429-.7724.4459.1022.7176.4057.8305.928.5846 2.7038.0774 3.8307-.3302 4.7363-.084.1866-.1633.3629-.2311.5454zm7.3637 4.5725c-.0169.1768-.0358.376-.0618.5959l-.146.4383a.3547.3547 0 0 0-.0182.1077c-.0059.4747-.054.6489-.115.8693-.0634.2292-.1353.4891-.1794 1.0575-.11 1.4143-.8782 2.2267-2.4172 2.5565-1.5155.3251-1.7843-.4968-2.0212-1.2217a6.5824 6.5824 0 0 0-.0769-.2266c-.2154-.5858-.1911-1.4119-.1574-2.5551.0165-.5612-.0249-1.9013-.3302-2.6462.0044-.2932.0106-.5909.019-.8918a.3529.3529 0 0 0-.0153-.1126 1.4927 1.4927 0 0 0-.0439-.208c-.1226-.4283-.4213-.7866-.7797-.9351-.1424-.059-.4038-.1672-.7178-.0869.067-.276.1831-.5875.309-.9249l.0529-.142c.0595-.16.134-.3257.213-.5012.4265-.9476 1.0106-2.2453.3766-5.1772-.2374-1.0981-1.0304-1.6343-2.2324-1.5098-.7207.0746-1.3799.3654-1.7088.5321a5.6716 5.6716 0 0 0-.1958.1041c.0918-1.1064.4386-3.1741 1.7357-4.4823a4.0306 4.0306 0 0 1 .3033-.276.3532.3532 0 0 0 .1447-.0644c.7524-.5706 1.6945-.8506 2.802-.8325.4091.0067.8017.0339 1.1742.081 1.939.3544 3.2439 1.4468 4.0359 2.3827.8143.9623 1.2552 1.9315 1.4312 2.4543-1.3232-.1346-2.2234.1268-2.6797.779-.9926 1.4189.543 4.1729 1.2811 5.4964.1353.2426.2522.4522.2889.5413.2403.5825.5515.9713.7787 1.2552.0696.087.1372.1714.1885.245-.4008.1155-1.1208.3825-1.0552 1.717-.0123.1563-.0423.4469-.0834.8148-.0461.2077-.0702.4603-.0994.7662zm.8905-1.6211c-.0405-.8316.2691-.9185.5967-1.0105a2.8566 2.8566 0 0 0 .135-.0406 1.202 1.202 0 0 0 .1342.103c.5703.3765 1.5823.4213 3.0068.1344-.2016.1769-.5189.3994-.9533.6011-.4098.1903-1.0957.333-1.7473.3636-.7197.0336-1.0859-.0807-1.1721-.151zm.5695-9.2712c-.0059.3508-.0542.6692-.1054 1.0017-.055.3576-.112.7274-.1264 1.1762-.0142.4368.0404.8909.0932 1.3301.1066.887.216 1.8003-.2075 2.7014a3.5272 3.5272 0 0 1-.1876-.3856c-.0527-.1276-.1669-.3326-.3251-.6162-.6156-1.1041-2.0574-3.6896-1.3193-4.7446.3795-.5427 1.3408-.5661 2.1781-.463zm.2284 7.0137a12.3762 12.3762 0 0 0-.0853-.1074l-.0355-.0444c.7262-1.1995.5842-2.3862.4578-3.4385-.0519-.4318-.1009-.8396-.0885-1.2226.0129-.4061.0666-.7543.1185-1.0911.0639-.415.1288-.8443.1109-1.3505.0134-.0531.0188-.1158.0118-.1902-.0457-.4855-.5999-1.938-1.7294-3.253-.6076-.7073-1.4896-1.4972-2.6889-2.0395.5251-.1066 1.2328-.2035 2.0244-.1859 2.0515.0456 3.6746.8135 4.8242 2.2824a.908.908 0 0 1 .0667.1002c.7231 1.3556-.2762 6.2751-2.9867 10.5405zm-8.8166-6.1162c-.025.1794-.3089.4225-.6211.4225a.5821.5821 0 0 1-.0809-.0056c-.1873-.026-.3765-.144-.5059-.3156-.0458-.0605-.1203-.178-.1055-.2844.0055-.0401.0261-.0985.0925-.1488.1182-.0894.3518-.1226.6096-.0867.3163.0441.6426.1938.6113.4186zm7.9305-.4114c.0111.0792-.049.201-.1531.3102-.0683.0717-.212.1961-.4079.2232a.5456.5456 0 0 1-.075.0052c-.2935 0-.5414-.2344-.5607-.3717-.024-.1765.2641-.3106.5611-.352.297-.0414.6111.0088.6356.1851z`,source:`https://wiki.postgresql.org/wiki/Logo`,hex:`4169E1`,guidelines:`https://www.postgresql.org/about/policies/trademarks/`},sqlite:{title:`SQLite`,slug:`sqlite`,get svg(){return j9+`SQLite`+M9+this.path+N9},path:`M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71 8.71 0 0 0-.547.535c-2.109 2.237-4.066 6.38-4.674 9.544.237.48.422 1.093.544 1.561a13.044 13.044 0 0 1 .164.703s-.019-.071-.096-.296l-.05-.146a1.689 1.689 0 0 0-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376 1.176.484.884.778 2.4.778 2.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304 1.346-.226 1.478.152.256.296.698.422 1.186.286 1.1.485 2.44.485 2.44l.017.224a22.41 22.41 0 0 0 .056 2.748c.095 1.146.273 2.13.5 2.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29 1.661-8.304 1.723-4.55 4.113-8.201 6.3-9.945-1.993 1.8-4.692 7.63-5.5 9.788-.904 2.416-1.545 4.684-1.931 6.857.666-2.037 2.821-2.912 2.821-2.912s1.057-1.304 2.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184 3.613-1.72C21.695 7.9 24.195 2.767 21.678.521m-18.573.543A1.842 1.842 0 0 0 1.27 2.9v16.608a1.84 1.84 0 0 0 1.835 1.834h9.418a22.953 22.953 0 0 1-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01 27.01 0 0 0-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432 0-.12.015-.245.037-.386a9.98 9.98 0 0 1 .234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8 32.8 0 0 1 .382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28 2.587-7.443 4.8-9.791.066-.069.133-.128.198-.194Z`,source:`https://github.com/sqlite/sqlite/blob/43e862723ec680542ca6f608f9963c0993dd7324/art/sqlite370.eps`,hex:`003B57`},mssql:{path:`M12 1.5c-4.97 0-9 1.79-9 4v13c0 2.21 4.03 4 9 4s9-1.79 9-4v-13c0-2.21-4.03-4-9-4zm0 2c3.87 0 7 1.12 7 2s-3.13 2-7 2-7-1.12-7-2 3.13-2 7-2zm0 2.9a2.1 2.1 0 1 1 0 4.2 2.1 2.1 0 0 1 0-4.2zM5 8.55c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45V11c0 .88-3.13 2-7 2s-7-1.12-7-2V8.55zm0 4.9c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45V16c0 .88-3.13 2-7 2s-7-1.12-7-2v-2.55zm0 5c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45`},oracle:{path:`M7.5 5.5h9a6.5 6.5 0 0 1 0 13h-9a6.5 6.5 0 0 1 0-13zm0 2.4a4.1 4.1 0 0 0 0 8.2h9a4.1 4.1 0 0 0 0-8.2h-9z`},neon:{title:`Neon`,slug:`neon`,get svg(){return j9+`Neon`+M9+this.path+N9},path:`M24 0V24l-9.365-8.045V24H0V0ZM2.942 21.087h8.751V9.563l9.365 8.204V2.919L2.942 2.914Z`,source:`https://neon.com/brand`,hex:`34D59A`,guidelines:`https://neon.com/brand`},supabase:{title:`Supabase`,slug:`supabase`,get svg(){return j9+`Supabase`+M9+this.path+N9},path:`M11.9 1.036c-.015-.986-1.26-1.41-1.874-.637L.764 12.05C-.33 13.427.65 15.455 2.409 15.455h9.579l.113 7.51c.014.985 1.259 1.408 1.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z`,source:`https://github.com/supabase/supabase/blob/4031a7549f5d46da7bc79c01d56be4177dc7c114/packages/common/assets/images/supabase-logo-wordmark--light.svg`,hex:`3FCF8E`},d1:rtt,do:rtt};function P9({dbms:e,className:t}){let n=itt[e];return n?(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,className:w(`size-4 shrink-0`,t),fill:`currentColor`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:n.path})}):(0,$.jsx)(D6,{className:w(`size-4 shrink-0`,t),"aria-hidden":!0})}function att(){let{t:e}=S(),{activeConnections:t,activeConnectionId:n,setActiveConnection:r,closeConnection:i}=Je(),a=(0,D.useRef)(null);J4e(a,n);let o=Je(e=>e.reorderActiveConnection),s=(0,D.useMemo)(()=>t.map(e=>e.id),[t]),{dragProps:c,dropIndicator:l}=Ke(s,(0,D.useCallback)((e,t)=>o(e,t),[o]));return t.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:e(`connection.tab.noConnections`)}):(0,$.jsxs)(b5,{value:n??void 0,onValueChange:r,className:`h-full gap-0`,children:[(0,$.jsx)(x5,{ref:a,variant:`line`,className:`w-full shrink-0 justify-start overflow-x-auto overflow-y-hidden border-b px-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:t.map(e=>(0,$.jsxs)(S5,{value:e.id,...c(e.id),"data-drop-before":l===e.id||void 0,className:`shrink-0 gap-1 data-[drop-before]:shadow-[inset_2px_0_0_var(--color-primary)] !rounded-none !border-0 !border-b-2 !border-transparent pr-1 !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:!border-primary data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:[m5(e.environmentColor)&&(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:m5(e.environmentColor)}}),(0,$.jsx)(P9,{dbms:e.dbms,className:`size-3.5 opacity-80`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:e.hostName||`${e.host}:${e.port}`}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-colors`,onClick:t=>{t.stopPropagation(),i(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),i(e.id))},children:(0,$.jsx)(b,{className:`size-3`})})]},e.id))}),t.map(e=>(0,$.jsx)(C5,{value:e.id,className:`mt-0 min-h-0 flex-1`,children:(0,$.jsx)(ntt,{connectionId:e.id})},e.id))]})}var ott=(0,D.lazy)(()=>oe(()=>import(`./B_0rFJQl.js`).then(e=>({default:e.ConnectDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),stt=(0,D.lazy)(()=>oe(()=>import(`./oSIomP-s.js`).then(e=>({default:e.CreateDatabaseDialog})),__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,18,15,19,11,10,12,13,14,20,21,22,16]))),ctt=(0,D.lazy)(()=>oe(()=>import(`./7D95fvkQ.js`).then(e=>({default:e.CreateSchemaDialog})),__vite__mapDeps([23,1,2,3,7,8,9,18,15,19,11,10,12,13,14,20,21,22,16,5]))),ltt=(0,D.lazy)(()=>oe(()=>import(`./g4S828aR.js`).then(e=>({default:e.CopyDatabaseDialog})),__vite__mapDeps([24,1,2,3,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16,5]))),utt=(0,D.lazy)(()=>oe(()=>import(`./C-MJZp-k.js`).then(e=>({default:e.DownloadToCSVDialog})),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,13,14,11,10,12,18,15,19,20,21,22,16,26]))),dtt=(0,D.lazy)(()=>oe(()=>import(`./BmSO6bVX.js`).then(e=>({default:e.SchemaToHTMLDialog})),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,13,14,11,10,12,18,15,22,16,26]))),ftt=(0,D.lazy)(()=>oe(()=>import(`./aL0ab6hA.js`).then(e=>({default:e.CopyTableDialog})),__vite__mapDeps([28,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),ptt=(0,D.lazy)(()=>oe(()=>import(`./MdnUPkBs.js`).then(e=>({default:e.LinkColumnDialog})),__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,16]))),mtt=(0,D.lazy)(()=>oe(()=>import(`./q4qvsmm4.js`).then(e=>({default:e.DataDiffDialog})),__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,16]))),htt=(0,D.lazy)(()=>oe(()=>import(`./vIgrQ7V1.js`).then(e=>({default:e.GroupByDialog})),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),gtt=(0,D.lazy)(()=>oe(()=>import(`./OQSC6nip.js`).then(e=>({default:e.SchemaDiffDialog})),__vite__mapDeps([33,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,34,16]))),F9=(0,D.lazy)(()=>oe(()=>import(`./DURNOOys.js`).then(e=>({default:e.EditSchemaDialog})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),_tt=(0,D.lazy)(()=>oe(()=>import(`./3tVT9YMh.js`).then(e=>({default:e.UserManagerDialog})),__vite__mapDeps([36,1,2,3,7,8,9,14,11,10,12,13,15,18,19,20,21,22,16,5,37]))),vtt=(0,D.lazy)(()=>oe(()=>import(`./BQ74FNAM.js`).then(e=>({default:e.UserAddDialog})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,16,37]))),ytt=(0,D.lazy)(()=>oe(()=>import(`./BCZ2DwDi.js`).then(e=>({default:e.ProcessListDialog})),__vite__mapDeps([39,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),btt=(0,D.lazy)(()=>oe(()=>import(`./DCkfyKy4.js`).then(e=>({default:e.VariablesDialog})),__vite__mapDeps([40,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),xtt=(0,D.lazy)(()=>oe(()=>import(`./nij0MMY5.js`).then(e=>({default:e.StatusDialog})),__vite__mapDeps([41,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),Stt=(0,D.lazy)(()=>oe(()=>import(`./D-RWduy5.js`).then(e=>({default:e.FlushDialog})),__vite__mapDeps([42,2,1,3,7,8,9,14,11,10,12,13,16,5]))),Ctt=(0,D.lazy)(()=>oe(()=>import(`./C3uDTQB5.js`).then(e=>({default:e.FindReplaceDialog})),__vite__mapDeps([43,1,2,3,6,7,8,9,13,20,12]))),wtt=(0,D.lazy)(()=>oe(()=>import(`./f1Yh3VFu.js`).then(e=>({default:e.SafetySettingsDialog})),__vite__mapDeps([44,2,1,3,9,8,16,5,45]))),Ttt=(0,D.lazy)(()=>oe(()=>import(`./B2VNJYl8.js`).then(e=>({default:e.QuerySettingsDialog})),__vite__mapDeps([46,2,1,3,4,5,6,9,8,16,45]))),Ett=(0,D.lazy)(()=>oe(()=>import(`./B4qi_yRV.js`).then(e=>({default:e.GeneralSettingsDialog})),__vite__mapDeps([47,2,1,3,11,4,5,6,9,8,16,45]))),Dtt=(0,D.lazy)(()=>oe(()=>import(`./Bfw0mW2q.js`).then(e=>({default:e.AiSettingsDialog})),__vite__mapDeps([48,1,2,3,4,5,6,9,8,10,11,12,16]))),Ott=(0,D.lazy)(()=>oe(()=>import(`./B6gKGoJk.js`).then(e=>({default:e.McpSetupDialog})),__vite__mapDeps([49,1,2,3,10,11,12,16,5]))),ktt=(0,D.lazy)(()=>oe(()=>import(`./1qhRpHKv.js`).then(e=>({default:e.LocalHistoryDialog})),__vite__mapDeps([50,1,2,3,7,8,9,13,16,5]))),Att=(0,D.lazy)(()=>oe(()=>import(`./Brk9GcZh.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([51,2,1,3,16,5]))),jtt=(0,D.lazy)(()=>oe(()=>import(`./BrwCR6-9.js`).then(e=>({default:e.LicenseDialog})),__vite__mapDeps([52,1,2,3,16,5,53,54]))),Mtt=(0,D.lazy)(()=>oe(()=>import(`./Clm7zeUD.js`).then(e=>({default:e.SyncDialog})),__vite__mapDeps([55,1,2,3,16,5,53,54]))),Ntt=(0,D.lazy)(()=>oe(()=>import(`./BxOkJTYb.js`).then(e=>({default:e.TermsDialog})),__vite__mapDeps([56,2,1,3,9,8,16,5]))),Ptt=(0,D.lazy)(()=>oe(()=>import(`./Bfuq7Ecs.js`).then(e=>({default:e.RowFormDialog})),__vite__mapDeps([57,1,2,3,7,8,9,14,11,10,12,13,19,15,18,20,21,22,16,5]))),Ftt={connect:ott,"create-database":stt,"create-schema":ctt,"copy-database":ltt,"export-csv":utt,"export-html":dtt,"alter-database":F9,"create-table":F9,"alter-table":F9,"duplicate-table-structure":F9,"copy-table":ftt,"schema-diff":gtt,"data-diff":mtt,"group-by":htt,"link-column":ptt,"user-manager":_tt,"user-add":vtt,"process-list":ytt,variables:btt,status:xtt,flush:Stt,"find-replace":Ctt,"quick-command":(0,D.lazy)(()=>oe(()=>import(`./D2AdQhHv.js`).then(e=>({default:e.QuickCommandPalette})),__vite__mapDeps([58,1,2,3,11,5,7,8,9,13,14,10,12,19,15,18,20,21,22,16]))),"safety-settings":wtt,"query-settings":Ttt,"general-settings":Ett,"ai-settings":Dtt,"mcp-setup":Ott,"local-history":ktt,about:Att,license:jtt,sync:Mtt,terms:Ntt,"row-form":Ptt};function Itt(){let e=c(e=>e.activeDialog);if(!e)return null;let t=Ftt[e];return t?(0,$.jsx)(D.Suspense,{fallback:null,children:(0,$.jsx)(t,{})}):null}function I9({...e}){return(0,$.jsx)(IKe,{"data-slot":`alert-dialog`,...e})}function Ltt({...e}){return(0,$.jsx)(LKe,{"data-slot":`alert-dialog-portal`,...e})}function Rtt({className:e,...t}){return(0,$.jsx)(RKe,{"data-slot":`alert-dialog-overlay`,className:w(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function L9({className:e,size:t=`default`,...n}){return(0,$.jsxs)(Ltt,{children:[(0,$.jsx)(Rtt,{}),(0,$.jsx)(zKe,{"data-slot":`alert-dialog-content`,"data-size":t,className:w(`group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg`,e),...n})]})}function R9({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:w(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function z9({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:w(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function B9({className:e,...t}){return(0,$.jsx)(HKe,{"data-slot":`alert-dialog-title`,className:w(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function V9({className:e,...t}){return(0,$.jsx)(UKe,{"data-slot":`alert-dialog-description`,className:w(`text-sm text-muted-foreground`,e),...t})}function H9({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,$.jsx)(ne,{variant:t,size:n,asChild:!0,children:(0,$.jsx)(BKe,{"data-slot":`alert-dialog-action`,className:w(e),...r})})}function U9({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,$.jsx)(ne,{variant:t,size:n,asChild:!0,children:(0,$.jsx)(VKe,{"data-slot":`alert-dialog-cancel`,className:w(e),...r})})}function W9({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,"data-slot":`input`,className:w(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function ztt({className:e,...t}){return(0,$.jsx)(MXe,{"data-slot":`label`,className:w(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Btt(){let e=c(e=>e.destructiveConfirm),t=c(e=>e.resolveDestructiveConfirm);return e?(0,$.jsx)(Vtt,{request:e.request,resolve:t},e.id):null}function Vtt({request:e,resolve:t}){let{t:n}=S(),[r,i]=(0,D.useState)(``),a=!!e.typeToConfirm,o=!a||r===e.typeToConfirm;return(0,$.jsx)(I9,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,$.jsx)(L9,{className:`max-w-lg overflow-hidden`,children:(0,$.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),o&&t(!0)},children:[(0,$.jsxs)(R9,{children:[(0,$.jsxs)(B9,{className:`flex min-w-0 items-center gap-2 break-words`,children:[(0,$.jsx)(W6,{className:`size-5 shrink-0 text-destructive`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,$.jsx)(V9,{className:`min-w-0 break-words [overflow-wrap:anywhere] whitespace-pre-line`,children:e.description??n(`confirm.defaultDescription`)})]}),e.statements&&e.statements.length>0&&(0,$.jsx)(`pre`,{className:`max-h-48 overflow-auto rounded-md border bg-muted p-3 font-mono text-xs whitespace-pre-wrap break-all`,children:e.statements.join(`
942
+ `;a.executeEdits(`history`,[{range:c,text:f,forceMoveMarkers:!0}]),a.focus(),o(t(`result.history.inserted`))},[r,e,_,o,t]),y=(0,D.useMemo)(()=>n.filter(t=>!e||!t.connectionId||t.connectionId===e),[n,e]),x=(0,D.useCallback)(async()=>{if(!await s({title:t(`result.history.clearTitle`),description:t(`result.history.clearDescription`,{count:y.length}),confirmLabel:t(`result.history.clearConfirm`)}))return;let r=n.filter(t=>t.connectionId&&t.connectionId!==e);i();for(let e of[...r].reverse())a(e)},[s,t,y.length,n,e,i,a]),C=(0,D.useMemo)(()=>{let e=d.trim().toLowerCase();return y.filter(t=>!(p===`success`&&!t.success||p===`failed`&&t.success||h&&t.tabId!==r||e&&!t.query.toLowerCase().includes(e)&&!(t.database??``).toLowerCase().includes(e)&&!(t.error??``).toLowerCase().includes(e)))},[y,d,p,h,r]),w=(0,D.useMemo)(()=>J9e(C,t),[C,t]);if(y.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:t(`result.history.empty`)});let ee=(e,t)=>(0,$.jsx)(`button`,{type:`button`,className:`rounded px-2 py-0.5 text-xs ${p===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>m(e),children:t});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z6,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(`input`,{className:`h-7 w-52 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:t(`result.history.searchPlaceholder`),value:d,onChange:e=>f(e.target.value)}),d&&(0,$.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>f(``),children:(0,$.jsx)(b,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center rounded border bg-background p-0.5`,children:[ee(`all`,t(`result.history.all`)),ee(`success`,t(`result.history.success`)),ee(`failed`,t(`result.history.failed`))]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:h,onChange:e=>g(e.target.checked)}),t(`result.history.thisTab`)]}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t(`result.history.count`,{count:C.length})}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-destructive`,onClick:()=>void x(),children:[(0,$.jsx)(U6,{className:`size-3`}),t(`result.history.clear`)]})]}),(0,$.jsx)(K6,{className:`min-h-0 flex-1`,children:C.length===0?(0,$.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:t(`result.history.noMatch`)}):w.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-10 border-b bg-background/95 px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground backdrop-blur`,children:e.label}),(0,$.jsx)(`div`,{className:`divide-y divide-border/60 text-sm`,children:e.entries.map(e=>{let n=e.kind?.toUpperCase();return(0,$.jsxs)(`div`,{className:`group/row flex items-start gap-2 px-3 py-2 hover:bg-muted/50`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 flex-shrink-0`,children:e.success?(0,$.jsx)(S6,{className:`size-4 text-green-500`}):(0,$.jsx)(C6,{className:`size-4 text-destructive`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,onClick:()=>_(e.id,e.query),title:e.query,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs text-foreground`,children:K9e(e.query)}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`tabular-nums`,children:G9e(e.timestamp)}),n&&(0,$.jsx)(`span`,{className:`rounded px-1 text-[9px] font-semibold ${Y9e[n]??`bg-muted`}`,children:n}),e.database&&(0,$.jsx)(`span`,{className:`font-mono`,children:e.database}),e.rowCount!=null&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(R6,{className:`size-3`}),t(`result.history.rows`,{count:e.rowCount})]}),e.affectedRows!=null&&e.affectedRows>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(P6,{className:`size-3`}),t(`result.history.affected`,{count:e.affectedRows})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5 tabular-nums`,children:[(0,$.jsx)(w6,{className:`size-3`}),q9e(e.executionTime)]})]}),e.error&&(0,$.jsx)(`p`,{className:`mt-0.5 break-words text-xs text-destructive`,children:e.error})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-shrink-0 items-center gap-0.5 opacity-0 group-hover/row:opacity-100`,children:[(0,$.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`result.history.insert`),onClick:()=>v(e.id,e.query),children:(0,$.jsx)(q$e,{className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`result.history.copy`),onClick:()=>_(e.id,e.query),children:l===e.id?(0,$.jsx)(y6,{className:`size-3.5 text-green-500`}):(0,$.jsx)(E6,{className:`size-3.5`})})]})]},e.id)})})]},e.key))})]})}var Z9e={"full-scan":`border-destructive/50 text-destructive`,"no-index":`border-destructive/50 text-destructive`,"estimate-off":`border-catppuccin-yellow/50 text-catppuccin-yellow`,temporary:`border-catppuccin-yellow/50 text-catppuccin-yellow`,filesort:`border-catppuccin-yellow/50 text-catppuccin-yellow`},x9={"full-scan":{label:`result.plan.warnings.fullScan`,hint:`result.plan.hints.fullScan`},"no-index":{label:`result.plan.warnings.noIndex`,hint:`result.plan.hints.noIndex`},"estimate-off":{label:`result.plan.warnings.estimateOff`,hint:`result.plan.hints.estimateOff`},temporary:{label:`result.plan.warnings.temporary`,hint:`result.plan.hints.temporary`},filesort:{label:`result.plan.warnings.filesort`,hint:`result.plan.hints.filesort`}};function Q9e(e){return e<1e3?`${e.toFixed(e<10?2:0)} ms`:`${(e/1e3).toFixed(2)} s`}function S9(e){return e>=1e3?Math.round(e).toLocaleString():String(Math.round(e*100)/100)}function $9e(e,t){let n=[],r=(e,i)=>{let a=e.children.length>0,o=a&&!t.has(e.id);if(n.push({node:e,depth:i,hasChildren:a,expanded:o}),o)for(let t of e.children)r(t,i+1)};for(let t of e)r(t,0);return n}function eet(e,t){return t?e.timeMs??e.cost:e.cost}function tet(e,t){let n=0,r=e=>{let i=eet(e,t);i!==null&&i>n&&(n=i),e.children.forEach(r)};return e.forEach(r),n}function C9({icon:e,value:t,title:n}){return(0,$.jsxs)(`span`,{className:`flex items-center gap-0.5 tabular-nums`,title:n,children:[(0,$.jsx)(e,{className:`size-3 shrink-0`}),t]})}function net({node:e}){let{t}=S();return(0,$.jsxs)(`div`,{className:`flex h-full w-72 shrink-0 flex-col border-l`,children:[(0,$.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`truncate text-xs font-semibold`,title:e.label,children:e.label}),e.object&&(0,$.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.object})]}),(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsxs)(`div`,{className:`p-3`,children:[e.warnings.length>0&&(0,$.jsx)(`ul`,{className:`mb-3 space-y-1.5`,children:e.warnings.map(e=>(0,$.jsxs)(`li`,{className:`text-[11px] leading-snug`,children:[(0,$.jsx)(`span`,{className:`mr-1 rounded border px-1 text-[9px] font-semibold uppercase ${Z9e[e]}`,children:t(x9[e].label)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t(x9[e].hint)})]},e))}),e.details.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t(`result.plan.noDetails`)}):(0,$.jsx)(`dl`,{className:`space-y-1.5`,children:e.details.map((e,t)=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,$.jsx)(`dd`,{className:`break-words font-mono text-[11px]`,children:e.value})]},`${e.label}-${t}`))})]})})]})}function ret({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt),i=r.find(e=>e.id===t)?.plan??null,[a,o]=(0,D.useState)(!1),[s,c]=(0,D.useState)(!1),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(null),[p,m]=(0,D.useState)(new Set),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(u(null),f(null),!i)return;let e=!0;return s3e().then(t=>e&&o(t)),()=>{e=!1}},[e,t,i]);let y=(0,D.useCallback)(()=>{c(!0),f(null),m3e(e,t).then(u).catch(e=>f(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},[e,t]),b=(0,D.useMemo)(()=>i?$9e(i.roots,p):[],[i,p]),x=(0,D.useMemo)(()=>i?tet(i.roots,i.analyzed):0,[i]),C=(0,D.useMemo)(()=>b.find(e=>e.node.id===h)?.node??null,[b,h]);if(!i)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(`result.plan.empty`)});if(i.roots.length===0)return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`div`,{className:`border-b px-3 py-2 text-xs text-muted-foreground`,children:n(`result.plan.unreadable`)}),(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-3 font-mono text-xs`,children:i.raw})})]});let w=e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-3 py-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded border px-1 text-[9px] font-semibold uppercase ${i.analyzed?`border-green-500/50 text-green-500`:`border-border`}`,title:n(i.analyzed?`result.plan.analyzedHint`:`result.plan.estimatedHint`),children:n(i.analyzed?`result.plan.analyzed`:`result.plan.estimated`)}),i.totalCost!==null&&(0,$.jsx)(C9,{icon:U$e,value:S9(i.totalCost),title:n(`result.plan.totalCost`)}),i.totalTimeMs!==null&&(0,$.jsx)(C9,{icon:w6,value:Q9e(i.totalTimeMs),title:n(`result.plan.totalTime`)}),(0,$.jsx)(`div`,{className:`flex-1`}),a&&(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground disabled:opacity-60`,onClick:y,disabled:s,children:[s?(0,$.jsx)(M6,{className:`size-3 animate-spin`}):(0,$.jsx)(B6,{className:`size-3`}),n(s?`result.ai.thinking`:`result.ai.explainPlan`)]}),(0,$.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground`,onClick:()=>v(e=>!e),children:n(_?`result.plan.showTree`:`result.plan.showRaw`)})]}),d&&(0,$.jsx)(`p`,{className:`border-b px-3 py-1.5 text-xs text-muted-foreground`,children:n(`result.ai.failed`,{message:d})}),l&&(0,$.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,$.jsx)(B6,{className:`size-3`}),n(`result.ai.title`),(0,$.jsx)(`span`,{className:`font-normal normal-case tracking-normal`,children:n(`result.ai.by`,{model:l.model})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-xs leading-relaxed`,children:l.explanation}),l.fix&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded border bg-muted/50 p-2 font-mono text-[11px]`,children:l.fix}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-1.5 inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground`,onClick:()=>i8(e,l.fix,r.find(e=>e.id===t)?.database??``,n(`result.ai.title`)),children:[(0,$.jsx)(j$e,{className:`size-3`}),n(`result.ai.applyFix`)]})]})]}),_?(0,$.jsx)(K6,{className:`flex-1`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-3 font-mono text-xs`,children:i.raw})}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(K6,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`ul`,{className:`py-1 text-xs`,children:b.map(({node:e,depth:t,hasChildren:r,expanded:a})=>{let o=eet(e,i.analyzed),s=x>0&&o!==null?Math.max(o/x,.02):0,c=e.id===h;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`relative flex w-full items-center gap-1.5 py-1 pr-3 text-left ${c?`bg-primary/10`:`hover:bg-muted/60`}`,style:{paddingLeft:`${t*14+8}px`},onClick:()=>g(e.id),children:[s>0&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 bg-primary/10`,style:{width:`${s*100}%`}}),(0,$.jsx)(`span`,{className:`relative flex w-3 shrink-0 justify-center text-muted-foreground`,children:r&&(0,$.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:t=>{t.stopPropagation(),w(e.id)},children:a?(0,$.jsx)(b6,{className:`size-3`}):(0,$.jsx)(x6,{className:`size-3`})})}),(0,$.jsxs)(`span`,{className:`relative min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.object&&!e.label.includes(e.object)&&(0,$.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-muted-foreground`,children:e.object}),e.warnings.map(e=>(0,$.jsx)(`span`,{className:`ml-1.5 rounded border px-1 text-[9px] font-semibold uppercase ${Z9e[e]}`,children:n(x9[e].label)},e))]}),(0,$.jsxs)(`span`,{className:`relative flex shrink-0 items-center gap-2.5 text-[11px] text-muted-foreground`,children:[e.rows!==null&&(0,$.jsx)(C9,{icon:R6,value:S9(e.rows),title:n(`result.plan.rows`)}),e.actualRows!==null&&(0,$.jsx)(C9,{icon:X$e,value:S9(e.actualRows),title:n(`result.plan.actualRows`)}),e.cost!==null&&(0,$.jsx)(C9,{icon:U$e,value:S9(e.cost),title:n(`result.plan.cost`)}),e.timeMs!==null&&(0,$.jsx)(C9,{icon:w6,value:Q9e(e.timeMs),title:n(`result.plan.time`)})]})]})},e.id)})})}),C?(0,$.jsx)(net,{node:C}):(0,$.jsx)(`div`,{className:`flex w-72 shrink-0 items-center justify-center border-l px-4 text-center text-[11px] text-muted-foreground`,children:(0,$.jsxs)(`span`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(d1e,{className:`size-4`}),n(`result.plan.selectNode`)]})})]})]})}var iet=56,aet=16,w9=14;function oet(e,t){let n=new Map,r=new Set,i=e=>{let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=0;for(let n of t.get(e)??[])o=Math.max(o,i(n)+1);return r.delete(e),n.set(e,o),o};for(let t of e)i(t.id);let a=new Map;for(let[e,n]of t)for(let t of n)a.set(t,[...a.get(t)??[],e]);let o=Math.max(...e.map(e=>n.get(e.id)??0)),s=new Map,c=e=>{let t=s.get(e);if(t!==void 0)return t;if(r.has(e))return n.get(e)??0;r.add(e);let i=a.get(e)??[],l=i.length===0?o:Math.min(...i.map(e=>c(e)-1));return r.delete(e),s.set(e,Math.max(n.get(e)??0,l)),s.get(e)??0};for(let t of e)c(t.id);return s}function set(e){let t=new Map;for(let n of e.groups){let e=t.get(n.parentId)??[];e.push(n.id),t.set(n.parentId,e)}let n=new Map;for(let t of e.nodes){let e=n.get(t.groupId)??[];e.push(t.id),n.set(t.groupId,e)}let r=new Map,i=e=>{let a=r.get(e);if(a)return a;let o=[...n.get(e)??[]];for(let n of t.get(e)??[])o.push(...i(n));return r.set(e,o),o};for(let t of e.groups)i(t.id);let a=new Map,o=i=>{let s=[];for(let e of i===null?[]:n.get(i)??[])s.push({id:e,kind:`node`,width:196,height:56,x:0,y:0});for(let e of t.get(i)??[]){let t=o(e);a.set(e,t),s.push({id:e,kind:`group`,width:t.width+28,height:t.height+28+22,x:0,y:0})}if(s.length===0)return{width:0,height:0,items:s};let c=new Map;for(let e of s)if(e.kind===`node`)c.set(e.id,e.id);else for(let t of r.get(e.id)??[])c.set(t,e.id);let l=new Map;for(let t of e.edges){let e=c.get(t.from),n=c.get(t.to);if(!e||!n||e===n)continue;let r=l.get(n)??new Set;r.add(e),l.set(n,r)}let u=oet(s,l),d=new Map;for(let e of s){let t=u.get(e.id)??0,n=d.get(t)??[];n.push(e),d.set(t,n)}let f=[...d.keys()].sort((e,t)=>e-t).map(e=>{let t=d.get(e)??[];return{key:e,width:Math.max(...t.map(e=>e.width)),height:t.reduce((e,t)=>e+t.height,0)+aet*(t.length-1)}}),p=Math.max(...f.map(e=>e.height)),m=0;for(let e of f){let t=d.get(e.key)??[],n=(p-e.height)/2;for(let r of t)r.x=m+(e.width-r.width)/2,r.y=n,n+=r.height+aet;m+=e.width+iet}return{width:m-iet,height:p,items:s}},s=o(null);a.set(`__root`,s);let c=[],l=[],u=(t,n,r,i)=>{for(let o of t.items){let t=n+o.x,s=r+o.y;if(o.kind===`node`){c.push({id:o.id,x:t,y:s,width:o.width,height:o.height});continue}let d=e.groups.find(e=>e.id===o.id);l.push({id:o.id,x:t,y:s,width:o.width,height:o.height,label:d?.label??``,depth:i});let f=a.get(o.id);f&&u(f,t+w9,s+w9+22,i+1)}};return u(s,w9,w9,0),{nodes:c,groups:l,width:s.width+28,height:s.height+28}}var cet=.3,uet=2,det=.0012,fet=120,pet=e=>Math.max(cet,Math.min(uet,e)),met={table:`var(--t-green)`,cte:`var(--t-blue)`,"cte-ref":`var(--t-teal)`,derived:`var(--t-mauve)`,scalar:`var(--t-lavender)`,setop:`var(--t-sky)`,result:`var(--t-peach)`},het={table:`result.structure.kindTable`,cte:`result.structure.kindCte`,"cte-ref":`result.structure.kindCteRef`,derived:`result.structure.kindDerived`,scalar:`result.structure.kindScalar`,setop:`result.structure.kindSetop`,result:`result.structure.kindResult`};function get(e,t){let n=e.x+e.width,r=e.y+e.height/2,i=t.x,a=t.y+t.height/2,o=Math.max(28,Math.abs(i-n)/2);return`M ${n} ${r} C ${n+o} ${r}, ${i-o} ${a}, ${i} ${a}`}function _et({connectionId:e,tabId:t,index:n}){let{t:r}=S(),i=_t(t=>t.tabs[e]??vt).find(e=>e.id===t)?.graphs?.[n]??null,a=i?.graph??null;(0,D.useEffect)(()=>{i&&!i.enriched&&i.graph&&P8(e,t,n)},[e,t,n,i]);let[o,s]=(0,D.useState)(1),[c,l]=(0,D.useState)({x:0,y:0}),u=(0,D.useRef)(null),d=(0,D.useRef)(null),f=(0,D.useRef)(null),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(null),_=(0,D.useMemo)(()=>a?set(a):null,[a]),v=(0,D.useMemo)(()=>{if(!h||!a)return null;let e=new Set,t=new Set([h]);for(let n of a.edges)(n.from===h||n.to===h)&&(e.add(n.id),t.add(n.from),t.add(n.to));return{edges:e,nodes:t}},[h,a]),y=(0,D.useMemo)(()=>new Map((_?.nodes??[]).map(e=>[e.id,e])),[_]),b=(0,D.useMemo)(()=>new Map((a?.nodes??[]).map(e=>[e.id,e])),[a]),x=(0,D.useCallback)(()=>{let e=d.current;if(!e||!_||_.width===0)return;let t=pet(Math.min(e.clientWidth/_.width,e.clientHeight/_.height,1));s(t),l({x:(e.clientWidth-_.width*t)/2,y:(e.clientHeight-_.height*t)/2})},[_]),C=(0,D.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):f.current?.requestFullscreen().catch(()=>{})},[]);(0,D.useEffect)(()=>{let e=()=>{m(document.fullscreenElement===f.current),requestAnimationFrame(()=>x())};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[x]);let w=(0,D.useCallback)(e=>{e.preventDefault();let t=Math.max(-120,Math.min(fet,e.deltaY)),n=d.current?.getBoundingClientRect();s(r=>{let i=pet(r*(1-t*det));if(n){let t=e.clientX-n.left,a=e.clientY-n.top;l(e=>({x:t-(t-e.x)/r*i,y:a-(a-e.y)/r*i}))}return i})},[]),ee=(0,D.useCallback)(e=>{e.button===0&&(u.current={x:e.clientX,y:e.clientY,panX:c.x,panY:c.y})},[c]),te=(0,D.useCallback)(e=>{let t=u.current;t&&l({x:t.panX+(e.clientX-t.x),y:t.panY+(e.clientY-t.y)})},[]),T=(0,D.useCallback)(()=>{u.current=null},[]),ne=(0,D.useCallback)(n=>{!n.range||i?.documentOffset===null||i===null||Gt(e,t,i.documentOffset+n.range[0],i.documentOffset+n.range[1])},[e,t,i]);if(!i)return(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:r(`result.structure.empty`)});if(!a||!_)return(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:i.message});let re=e=>e===null?r(`result.structure.columnsUnknown`):r(`result.structure.columns`,{count:e});return(0,$.jsxs)(`div`,{ref:f,className:`relative h-full w-full overflow-hidden`,style:{background:`var(--t-mantle)`},children:[(0,$.jsxs)(`div`,{className:`absolute right-2 top-2 z-10 flex gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:x,className:`flex items-center gap-1 rounded border bg-background/80 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(a1e,{className:`size-3`}),r(`result.structure.fit`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:`flex items-center gap-1 rounded border bg-background/80 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground`,children:[p?(0,$.jsx)(p1e,{className:`size-3`}):(0,$.jsx)(G$e,{className:`size-3`}),r(p?`result.structure.exitFullscreen`:`result.structure.fullscreen`)]})]}),a.warnings.length>0&&(0,$.jsx)(`div`,{className:`absolute left-2 top-2 z-10 rounded border px-2 py-1 text-[11px]`,style:{borderColor:`var(--t-yellow)`,color:`var(--t-yellow)`},children:r(`result.structure.notDrawn`,{what:a.warnings.join(`; `)})}),(0,$.jsx)(`div`,{ref:d,className:`h-full w-full cursor-grab active:cursor-grabbing`,onWheel:w,onMouseDown:ee,onMouseMove:te,onMouseUp:T,onMouseLeave:T,children:(0,$.jsxs)(`div`,{className:`relative origin-top-left`,style:{width:_.width,height:_.height,transform:`translate(${c.x}px, ${c.y}px) scale(${o})`},children:[_.groups.map(e=>(0,$.jsx)(`div`,{className:`absolute rounded-md border border-dashed`,style:{left:e.x,top:e.y,width:e.width,height:e.height,borderColor:`var(--t-surface2, var(--t-overlay0))`,background:e.depth%2==0?`var(--t-base, transparent)`:`var(--t-surface0)`,opacity:.9},children:(0,$.jsx)(`div`,{className:`px-2 pt-1 text-[10px] font-semibold uppercase tracking-wide`,style:{height:22,color:`var(--t-overlay1)`},children:e.label})},e.id)),(0,$.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0`,width:_.width,height:_.height,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`marker`,{id:`qg-arrow`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,children:(0,$.jsx)(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:`var(--t-overlay1)`})}),(0,$.jsx)(`marker`,{id:`qg-arrow-lit`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,children:(0,$.jsx)(`path`,{d:`M0,0 L8,4 L0,8 z`,fill:`var(--t-blue)`})})]}),a.edges.map(e=>{let t=y.get(e.from),n=y.get(e.to);if(!t||!n)return null;let r=b.get(e.from),i=v?.edges.has(e.id)??!1;return(0,$.jsxs)(`g`,{style:{opacity:v!==null&&!i?.18:1,transition:`opacity 120ms`},children:[(0,$.jsx)(`path`,{d:get(t,n),fill:`none`,stroke:i?`var(--t-blue)`:`var(--t-overlay1)`,strokeWidth:i?2.2:1.2,strokeDasharray:e.kind===`scalar`?`4 3`:void 0,markerEnd:i?`url(#qg-arrow-lit)`:`url(#qg-arrow)`}),r?.columnCount!==null&&r!==void 0&&(0,$.jsx)(`text`,{x:(t.x+t.width+n.x)/2,y:(t.y+n.y)/2+t.height/2-4,textAnchor:`middle`,fontSize:10,fontWeight:i?600:400,fill:i?`var(--t-blue)`:`var(--t-overlay1)`,children:r.columnCount})]},e.id)})]}),_.nodes.map(e=>{let t=b.get(e.id);if(!t)return null;let n=met[t.kind],i=v?.nodes.has(e.id)??!1,a=v!==null&&!i;return(0,$.jsxs)(`button`,{type:`button`,title:t.range?r(`result.structure.reveal`):void 0,onClick:()=>ne(t),onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(t=>t===e.id?null:t),onFocus:()=>g(e.id),onBlur:()=>g(t=>t===e.id?null:t),className:`absolute overflow-hidden rounded-md border text-left shadow-sm`,style:{left:e.x,top:e.y,width:e.width,height:e.height,background:h===e.id?`var(--t-surface1)`:`var(--t-surface0)`,borderColor:i?`var(--t-blue)`:`var(--t-surface2, var(--t-overlay0))`,borderLeft:`3px solid ${n}`,cursor:t.range?`pointer`:`default`,opacity:a?.35:1,transition:`opacity 120ms, background 120ms, border-color 120ms`},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 px-2 pt-1.5`,children:[(0,$.jsxs)(`span`,{className:`truncate text-[12px] font-semibold`,style:{color:`var(--t-foreground)`},children:[t.label,t.alias&&(0,$.jsx)(`span`,{className:`ml-1 font-normal`,style:{color:`var(--t-overlay1)`},children:t.alias})]}),(0,$.jsx)(`span`,{className:`shrink-0 rounded px-1 py-px text-[9px] font-semibold`,style:{background:n,color:`var(--t-crust, var(--t-background))`},children:r(het[t.kind])})]}),(0,$.jsx)(`div`,{className:`px-2 pb-1.5 pt-1 text-[11px]`,style:{color:`var(--t-overlay1)`},children:re(t.columnCount)})]},e.id)})]})})]})}var vet=[];function yet({connectionId:e,tabId:t}){let{t:n}=S(),r=_t(t=>t.tabs[e]??vt).find(e=>e.id===t),i=r?.results??vet,a=!!r?.plan,o=(0,D.useMemo)(()=>r?.graphs??[],[r?.graphs]),[s,c]=(0,D.useState)({results:i,closed:new Set,activeTab:null}),l=s.results===i?s:{results:i,closed:new Set,activeTab:null},u=l.closed,d=(0,D.useMemo)(()=>i.map((e,t)=>({result:e,index:t})).filter(e=>e.result.fields.length>0),[i]),f=(0,D.useMemo)(()=>d.filter(e=>!u.has(e.index)),[d,u]),p=l.activeTab??(d.length>0?`result-${d[0].index}`:`message`),m=(0,D.useCallback)(e=>{c(t=>({...t.results===i?t:{results:i,closed:new Set},activeTab:e}))},[i]),h=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(h.current)return;let n=r?.sourceTable;!n||i.length>0||r?.isExecuting||(h.current=!0,_t.getState().setExecuting(e,t,!0),(async()=>{try{let r=await Z6(e,{database:n.database,table:n.table,tabId:t,page:0});r.sourceTable=n,_t.getState().setResults(e,t,[r])}catch(n){let r=n instanceof Error?n.message:String(n);_t.getState().setError(e,t,r)}finally{_t.getState().setExecuting(e,t,!1)}})())},[r?.sourceTable,r?.isExecuting,i,e,t]);let g=(0,D.useRef)(r?.graphs??null),_=(0,D.useRef)(r?.plan??null);(0,D.useEffect)(()=>{let e=r?.plan??null;e&&e!==_.current&&m(`plan`),_.current=e},[r?.plan,m]),(0,D.useEffect)(()=>{let e=r?.graphs??null;e&&e!==g.current&&e[0]?.focus&&m(`structure-0`),g.current=e},[r?.graphs,m]);let v=(0,D.useCallback)((e,t)=>{e.stopPropagation(),c(e=>{let n=e.results===i?e:{results:i,closed:new Set,activeTab:null},r=new Set(n.closed);r.add(t);let a=p===`result-${t}`;return{results:i,closed:r,activeTab:a?`message`:n.activeTab}})},[i,p]);return(0,$.jsxs)(b5,{value:p,onValueChange:m,className:`relative flex h-full flex-col`,children:[(0,$.jsx)(n3e,{connectionId:e,running:r?.isExecuting??!1}),(0,$.jsxs)(x5,{className:`h-8 w-full justify-start rounded-none border-b bg-muted/30`,children:[(0,$.jsx)(S5,{value:`message`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.message`)}),(0,$.jsx)(S5,{value:`info`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.info`)}),(0,$.jsx)(S5,{value:`history`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.history`)}),a&&(0,$.jsx)(S5,{value:`plan`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:n(`result.tabs.plan`)}),f.map((e,t)=>(0,$.jsxs)(S5,{value:`result-${e.index}`,className:`h-7 gap-1 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:[(0,$.jsx)(`span`,{children:d.length===1?n(`result.tabs.result`):n(`result.tabs.resultN`,{n:t+1})}),(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:t=>v(t,e.index),children:(0,$.jsx)(b,{className:`size-3`})})]},`result-${e.index}`)),o.map((e,t)=>(0,$.jsx)(S5,{value:`structure-${t}`,className:`h-7 !rounded-sm !border-0 px-3 text-xs !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:o.length===1?n(`result.tabs.structure`):n(`result.tabs.structureN`,{n:t+1})},`structure-${t}`))]}),(0,$.jsx)(C5,{value:`message`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(y3e,{connectionId:e,tabId:t})}),(0,$.jsx)(C5,{value:`info`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(W9e,{connectionId:e,tabId:t})}),(0,$.jsx)(C5,{value:`history`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(X9e,{connectionId:e})}),a&&(0,$.jsx)(C5,{value:`plan`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(ret,{connectionId:e,tabId:t})}),o.map((n,r)=>(0,$.jsx)(C5,{value:`structure-${r}`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(_et,{connectionId:e,tabId:t,index:r})},`structure-${r}`)),f.map(n=>(0,$.jsx)(C5,{value:`result-${n.index}`,className:`mt-0 flex-1 overflow-hidden`,children:(0,$.jsx)(H9e,{connectionId:e,tabId:t,resultIndex:n.index})},`result-${n.index}`))]})}function bet({connectionId:e,tabId:t}){let[n,r]=(0,D.useState)(300),[i,a]=(0,D.useState)(!1),o=(0,D.useRef)(null),s=(0,D.useCallback)(e=>{e.preventDefault(),a(!0)},[]);return(0,D.useEffect)(()=>{if(!i)return;let e=e=>{if(!o.current)return;let t=o.current.getBoundingClientRect().bottom-e.clientY;r(Math.min(600,Math.max(100,t)))},t=()=>{a(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[i]),(0,$.jsxs)(`div`,{ref:o,className:`flex h-full flex-col`,style:{userSelect:i?`none`:void 0},children:[(0,$.jsx)(`div`,{className:`min-h-[100px] flex-1`,children:(0,$.jsx)(t3e,{connectionId:e,tabId:t})}),(0,$.jsx)(`div`,{onMouseDown:s,className:`h-1 flex-shrink-0 cursor-row-resize border-t transition-colors ${i?`bg-primary/40`:`hover:bg-primary/40`}`}),(0,$.jsx)(`div`,{className:`flex-shrink-0 overflow-hidden`,style:{height:n},children:(0,$.jsx)(yet,{connectionId:e,tabId:t})})]})}async function xet(e,t){let n=Ut(e),r=xt(e),{introspect:i}=n,a=await i.listTables(r,t),o=a.map(e=>e.name),[s,c,l]=await Promise.all([i.listAllColumns(r,t),i.listAllIndexes(r,t).catch(()=>new Map),i.listForeignKeys(r,t).catch(()=>[])]),u=new Set;for(let e of l)u.add(`${e.table}.${e.column}`);let d=new Set;for(let[e,t]of c)for(let n of t)n.type===`UNIQUE`&&n.columns.length===1&&d.add(`${e}.${n.columns[0]}`);let f=a.map(e=>({name:e.name,kind:`model`,x:0,y:0,comment:e.comment,columns:(s.get(e.name)??[]).map(t=>{let n=`${e.name}.${t.name}`,r=[];return t.key===`PRI`&&r.push(`PK`),u.has(n)&&r.push(`FK`),d.has(n)&&t.key!==`PRI`&&r.push(`UK`),{type:t.type+(t.extra.includes(`auto_increment`)?` AI`:``)+(t.nullable?`?`:``),name:t.name,badge:r.length>0?r[0]:null,badges:r,comment:t.comment}})})),p=new Set(o),m=new Set,h=[];for(let e of l){let{table:t,column:n,refTable:r}=e;if(!t||!r||!p.has(t)||!p.has(r)||t===r)continue;let i=`${t}->${r}:${n}`,a=`${r}->${t}:${n}`;m.has(i)||m.has(a)||(m.add(i),h.push({from:t,to:r,type:`1:N`,label:n}))}return{models:f,relations:h}}var T9=[70,170,180];function E9(e){return 52+e.columns.length*22+4}function D9(e){return e.reduce((e,t)=>e+t,0)+20}var Cet=2.399963229728653,O9=50,wet=50,k9=56,A9=D9(T9),Tet=120,Eet=.5,Det=.15,Oet=.15,ket=1.6;function Aet(e,t,n,r=80){let i=e.length,a=t.map(e=>({hw:e.w/2+n/2,hh:e.h/2+n/2})),o=!1;for(let t=0;t<r;t++){let t=!1;for(let n=0;n<i;n++)for(let r=n+1;r<i;r++){let i=e[r].x-e[n].x,o=e[r].y-e[n].y,s=a[n].hw+a[r].hw-Math.abs(i),c=a[n].hh+a[r].hh-Math.abs(o);if(s>0&&c>0){if(t=!0,s<c){let t=(i<0?-1:1)*s/2;e[n].x-=t,e[r].x+=t}else{let t=(o<0?-1:1)*c/2;e[n].y-=t,e[r].y+=t}}}if(!t)break;o=!0}return o}function jet(e,t){let n=e.length,r=e.map(e=>({w:A9,h:E9(e)})),i=r.reduce((e,t)=>e+t.h,0)/n,a=Math.max(A9,i)*.32+24,o=e.map((e,t)=>{let n=a*.55*Math.sqrt(t+.5);return{x:Math.cos(t*Cet)*n,y:Math.sin(t*Cet)*n}}),s=a*1.8,c=s/321,l=o.map(()=>({x:0,y:0}));for(let e=0;e<320;e++){for(let e=0;e<n;e++)l[e].x=0,l[e].y=0;for(let e=0;e<n;e++)for(let t=e+1;t<n;t++){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,s=.28*a*a/i,c=n/i,u=r/i;l[e].x+=c*s,l[e].y+=u*s,l[t].x-=c*s,l[t].y-=u*s}for(let[e,n]of t){let t=o[e].x-o[n].x,r=o[e].y-o[n].y,i=Math.hypot(t,r)||.01,s=i*i/a,c=t/i,u=r/i;l[e].x-=c*s,l[e].y-=u*s,l[n].x+=c*s,l[n].y+=u*s}for(let e=0;e<n;e++)l[e].x-=o[e].x*.1,l[e].y-=o[e].y*.1;for(let e=0;e<n;e++){let t=Math.hypot(l[e].x,l[e].y)||.01,n=Math.min(t,s);o[e].x+=l[e].x/t*n,o[e].y+=l[e].y/t*n}s=Math.max(s-c,a*.05)}Aet(o,r,k9);let u=1/0,d=1/0;for(let e=0;e<n;e++)u=Math.min(u,o[e].x-r[e].w/2),d=Math.min(d,o[e].y-r[e].h/2);return e.map((e,t)=>({x:o[t].x-r[t].w/2-u,y:o[t].y-r[t].h/2-d}))}function Met(e){let t=Math.max(1,Math.round(Math.sqrt(e.length))),n=Array(t).fill(0);return e.map(e=>{let r=0;for(let e=1;e<t;e++)n[e]<n[r]&&(r=e);let i={x:r*(A9+k9),y:n[r]};return n[r]+=E9(e)+k9,i})}function Net(e,t,n){let r=[...e,...t];if(r.length===0)return;let i=new Map(r.map((e,t)=>[e.name,t])),a=Array(r.length).fill(0),o=[];n.forEach(e=>{let t=i.get(e.from),n=i.get(e.to);t!==void 0&&n!==void 0&&t!==n&&(o.push([t,n]),a[t]++,a[n]++)});let s=r.filter((e,t)=>a[t]>0),c=r.filter((e,t)=>a[t]===0),l=O9;if(s.length>0){let e=new Map(s.map((e,t)=>[e.name,t])),t=jet(s,o.map(([t,n])=>[e.get(r[t].name),e.get(r[n].name)]).filter(([e,t])=>e!==void 0&&t!==void 0));s.forEach((e,n)=>{e.x=Math.round(O9+t[n].x),e.y=Math.round(wet+t[n].y),l=Math.max(l,e.x+A9)})}if(c.length>0){let e=s.length>0?l+Tet:O9,t=Met(c);c.forEach((n,r)=>{n.x=Math.round(e+t[r].x),n.y=Math.round(wet+t[r].y)})}}function Pet(e,t,n,r=100){let i=e.length;if(i<2)return!1;let a=e.map(e=>({w:n(e),h:E9(e)})),o=e.map((e,t)=>({x:e.x+a[t].w/2,y:e.y+a[t].h/2})),s=Math.min(...e.map(e=>e.x)),c=Math.min(...e.map(e=>e.y)),l=new Map(e.map((e,t)=>[e.name,t])),u=[];for(let e of t){let t=l.get(e.from),n=l.get(e.to);t!==void 0&&n!==void 0&&t!==n&&u.push([t,n])}let d=(e,t)=>Math.max((a[e].w+a[t].w)/2,(a[e].h+a[t].h)/2)+r,f=a.map(e=>(Math.max(e.w,e.h)+r)/2).reduce((e,t)=>e+t*t,0),p=Math.sqrt(f)*1.45,m=o.map(()=>({x:0,y:0})),h=r,g=h/201;for(let e=0;e<200;e++){for(let e=0;e<i;e++)m[e].x=0,m[e].y=0;for(let e=0;e<i;e++)for(let t=e+1;t<i;t++){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,a=d(e,t);if(i>=a)continue;let s=Eet*(a-i),c=n/i,l=r/i;m[e].x+=c*s,m[e].y+=l*s,m[t].x-=c*s,m[t].y-=l*s}for(let[e,t]of u){let n=o[e].x-o[t].x,r=o[e].y-o[t].y,i=Math.hypot(n,r)||.01,a=(i-d(e,t)*ket)*Det,s=n/i,c=r/i;m[e].x-=s*a,m[e].y-=c*a,m[t].x+=s*a,m[t].y+=c*a}let e=0,t=0;for(let n of o)e+=n.x,t+=n.y;e/=i,t/=i;for(let n=0;n<i;n++){let r=o[n].x-e,i=o[n].y-t,a=Math.hypot(r,i);if(a<=p)continue;let s=(a-p)*Oet;m[n].x-=r/a*s,m[n].y-=i/a*s}for(let e=0;e<i;e++){let t=Math.hypot(m[e].x,m[e].y)||.01,n=Math.min(t,h);o[e].x+=m[e].x/t*n,o[e].y+=m[e].y/t*n}h=Math.max(h-g,0)}Aet(o,a,r,300);let _=1/0,v=1/0;for(let e=0;e<i;e++)_=Math.min(_,o[e].x-a[e].w/2),v=Math.min(v,o[e].y-a[e].h/2);let y=s-_,b=c-v,x=!1;return e.forEach((e,t)=>{let n=Math.round(o[t].x-a[t].w/2+y),r=Math.round(o[t].y-a[t].h/2+b);(n!==e.x||r!==e.y)&&(x=!0),e.x=n,e.y=r}),x}function Fet(e,t){return`${e.targetConnectionId?`${t.connectionName(e.targetConnectionId)} · ${e.targetDatabase}`:e.targetDatabase}.${e.targetTable}`}function Iet(e,t,n,r){let i=new Map(e.map(e=>[e.name,e])),a=new Set(t.map(e=>`${e.from}->${e.to}:${e.label}`)),o=[...e],s=[...t],c=new Map;for(let e of n.filter(e=>e.database===r.database)){let t=i.get(e.table);if(!t)continue;let n=!e.targetConnectionId&&e.targetDatabase===r.database,l;if(n&&i.has(e.targetTable))l=e.targetTable;else{l=Fet(e,r);let n=c.get(l);n||(n={name:l,kind:`model`,external:e.targetConnectionId?r.connectionName(e.targetConnectionId):e.targetDatabase,x:t.x+D9(T9)+120,y:t.y,comment:``,columns:[]},c.set(l,n),o.push(n)),n.columns.some(t=>t.name===e.targetColumn)||n.columns.push({type:``,name:e.targetColumn,badge:`PK`,badges:[`PK`],comment:``})}if(e.table===l)continue;let u=`${e.table}->${l}:${e.column}`;a.has(u)||(a.add(u),s.push({from:e.table,to:l,type:`1:N`,label:e.column,virtual:!0}))}return{models:o,relations:s}}function Let({zoom:e,database:t,tableCount:n,relationCount:r,fieldCount:i,onZoomIn:a,onZoomOut:o,onResetView:s,onCenter:c,onFitAll:l,onSpreadAll:u,onResetLayout:d,onRefresh:f,isFullscreen:p,onToggleFullscreen:m}){let{t:h}=S();return(0,$.jsxs)(`div`,{className:`relative z-10 flex flex-wrap items-center gap-1.5 border-b px-4 py-1.5`,style:{background:`var(--t-mantle)`,borderColor:`var(--t-surface1)`},children:[t&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-semibold`,style:{color:`var(--t-yellow)`},children:[(0,$.jsx)(D6,{className:`size-3.5`}),t]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2.5 text-xs`,style:{borderColor:`var(--t-green)`,color:`var(--t-green)`},onClick:f,children:[(0,$.jsx)(L6,{className:`size-3.5`}),h(`erd.toolbar.refresh`)]}),(0,$.jsx)(`div`,{className:`mx-1 h-5 w-px`,style:{background:`var(--t-surface1)`}}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:a,children:[(0,$.jsx)(O1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.zoomIn`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:o,children:[(0,$.jsx)(k1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.zoomOut`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:s,children:[(0,$.jsx)(u1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.resetView`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:c,children:[(0,$.jsx)(W$e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.center`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:l,children:[(0,$.jsx)(a1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.fitAll`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:m,title:h(p?`erd.toolbar.exitFullscreen`:`erd.toolbar.fullscreen`),children:[p?(0,$.jsx)(p1e,{className:`mr-1 size-3.5`}):(0,$.jsx)(G$e,{className:`mr-1 size-3.5`}),h(p?`erd.toolbar.exitFullscreen`:`erd.toolbar.fullscreen`)]}),(0,$.jsxs)(`span`,{className:`ml-1 text-xs`,style:{color:`var(--t-overlay0)`},children:[Math.round(e*100),`%`]}),(0,$.jsx)(`div`,{className:`mx-1 h-5 w-px`,style:{background:`var(--t-surface1)`}}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,style:{background:`var(--t-blue)`,color:`var(--t-crust)`,borderColor:`var(--t-blue)`},onClick:u,children:[(0,$.jsx)(k$e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.spreadAll`)]}),(0,$.jsxs)(ne,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,style:{background:`var(--t-red)`,color:`var(--t-crust)`,borderColor:`var(--t-red)`},onClick:d,children:[(0,$.jsx)(n1e,{className:`mr-1 size-3.5`}),` `,h(`erd.toolbar.resetLayout`)]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-4 text-[11px]`,style:{color:`var(--t-overlay0)`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`inline-block h-0.5 w-[30px]`,style:{background:`var(--t-red)`}}),`1:1`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`inline-block h-0.5 w-[30px]`,style:{background:`var(--t-blue)`}}),h(`erd.toolbar.legendOneToMany`)]}),n>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px]`,style:{color:`var(--t-overlay0)`},children:[(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.tables`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:n})]}),(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.relations`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:r})]}),(0,$.jsxs)(`span`,{children:[h(`erd.toolbar.columns`),` `,(0,$.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--t-foreground)`},children:i})]})]})]})]})}function Ret({name:e,kind:t,external:n,onDragStart:r}){let{t:i}=S(),a=i(n?`erd.entity.linkBadge`:t===`enum`?`erd.entity.enumBadge`:`erd.entity.modelBadge`),o=n?`var(--t-yellow)`:t===`enum`?`var(--t-peach)`:`var(--t-mauve)`;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-md border-b-2 px-3 py-2 text-[13px] font-bold`,style:{background:`var(--t-surface1)`,borderColor:`var(--t-surface2, var(--t-overlay0))`,color:`var(--t-mauve)`,cursor:`grab`},onMouseDown:r,children:[(0,$.jsx)(`span`,{title:n?i(`erd.entity.externalTitle`,{location:n}):void 0,children:e}),(0,$.jsx)(`span`,{className:`rounded px-1.5 py-px text-[9px] font-semibold`,style:{background:o,color:`var(--t-base)`},children:a})]})}function zet(e){switch(e){case`PK`:return`var(--t-red)`;case`FK`:return`var(--t-peach)`;case`UK`:return`var(--t-green)`;default:return`var(--t-overlay0)`}}function Bet({entity:e,colWidths:t,onColResizeStart:n}){let{t:r}=S(),i=e.kind===`enum`;return(0,$.jsx)(`div`,{className:`overflow-hidden p-0`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-[11px]`,style:{tableLayout:`fixed`},children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{style:{width:t[0]+`px`}}),(0,$.jsx)(`col`,{style:{width:t[1]+`px`}}),(0,$.jsx)(`col`,{style:{width:t[2]+`px`}})]}),(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.value`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,0)})]}),(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.comment`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,1)})]}),(0,$.jsx)(`th`,{className:`px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`}})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.type`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,0)})]}),(0,$.jsxs)(`th`,{className:`relative px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:[r(`erd.entity.columns.column`),n&&(0,$.jsx)(`div`,{className:`absolute right-[-3px] top-0 z-10 h-full w-1.5 cursor-col-resize hover:opacity-40`,style:{background:`transparent`},onMouseDown:t=>n(t,e.name,1)})]}),(0,$.jsx)(`th`,{className:`px-2.5 py-1 text-left text-[10px] font-semibold uppercase`,style:{background:`var(--t-surface1)`,color:`var(--t-subtext0)`},children:r(`erd.entity.columns.comment`)})]})})}),(0,$.jsx)(`tbody`,{children:e.columns.map((t,n)=>(0,$.jsx)(`tr`,{style:{borderBottom:n<e.columns.length-1?`1px solid var(--t-surface1)`:`none`},children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-yellow)`,lineHeight:1.5},children:t.name}),(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px] text-[10px]`,style:{color:`var(--t-overlay0)`,lineHeight:1.5},colSpan:2,children:t.comment})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-blue)`,lineHeight:1.5},children:t.type.replace(`?`,``)}),(0,$.jsxs)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px]`,style:{color:`var(--t-text)`,lineHeight:1.5},children:[t.name,t.badges.map(e=>(0,$.jsx)(`span`,{className:`ml-1 inline-block rounded px-1 text-[9px] font-semibold`,style:{background:zet(e),color:`var(--t-base)`},children:e},e)),t.type.endsWith(`?`)&&(0,$.jsx)(`span`,{className:`ml-1 inline-block rounded px-1 text-[9px] font-semibold`,style:{background:`var(--t-overlay0)`,color:`var(--t-subtext0)`},title:r(`erd.entity.nullable`),children:`NULL`})]}),(0,$.jsx)(`td`,{className:`overflow-hidden text-ellipsis whitespace-nowrap px-2.5 py-[3px] text-[10px]`,style:{color:`var(--t-overlay0)`,lineHeight:1.5},children:t.comment})]})},n))})]})})}function Vet({entity:e,colWidths:t,isSelected:n,onMouseDown:r,onColResizeStart:i}){let a=(0,D.useCallback)(t=>{r(t,e.name)},[r,e.name]),o=t.reduce((e,t)=>e+t,0)+20,s=n?`var(--t-yellow)`:e.kind===`enum`?`var(--t-peach)`:`var(--t-overlay0)`;return(0,$.jsxs)(`div`,{className:`absolute select-none rounded-lg`,style:{left:e.x,top:e.y,width:Math.max(o,200),minWidth:200,background:`var(--t-base)`,border:`2px solid ${s}`,boxShadow:n?`0 8px 24px rgba(0,0,0,0.6)`:`0 4px 12px rgba(0,0,0,0.4)`,zIndex:n?1e3:1,transition:`box-shadow 0.15s`},onMouseEnter:t=>{if(!n){let n=t.currentTarget;n.style.borderColor=e.kind===`enum`?`var(--t-yellow)`:`var(--t-blue)`}},onMouseLeave:t=>{if(!n){let n=t.currentTarget;n.style.borderColor=e.kind===`enum`?`var(--t-peach)`:`var(--t-overlay0)`}},children:[(0,$.jsx)(Ret,{name:e.name,kind:e.kind,external:e.external,onDragStart:a}),(0,$.jsx)(Bet,{entity:e,colWidths:t,onColResizeStart:i})]})}function Het(e,t){return e[t]||[...T9]}function Uet(e,t){let n=D9(Het(t,e.name)),r=E9(e);return{x:e.x,y:e.y,w:n,h:r,cx:e.x+n/2,cy:e.y+r/2}}function Wet({entities:e,relations:t,entityWidths:n}){let r=(()=>{if(e.length===0)return null;let r=new Map;e.forEach(e=>r.set(e.name,e));let i=1/0,a=1/0,o=-1/0,s=-1/0;e.forEach(e=>{let t=Het(n,e.name);i=Math.min(i,e.x-200),a=Math.min(a,e.y-200),o=Math.max(o,e.x+D9(t)+200),s=Math.max(s,e.y+E9(e)+200)});let c=o-i,l=s-a,u={};function d(e,t){let n=`${e}_${t}`;return u[n]||(u[n]=0),(u[n]++-1)*16}let f=[];return t.forEach(e=>{let t=r.get(e.from),i=r.get(e.to);if(!t||!i)return;let a=Uet(t,n),o=Uet(i,n),s,c,l,u,p=o.cx-a.cx,m=o.cy-a.cy;if(Math.abs(p)>Math.abs(m)){if(p>0){let t=d(e.from,`right`),n=d(e.to,`left`);s=a.x+a.w+16,c=a.y+40+t,l=o.x-16,u=o.y+40+n}else{let t=d(e.from,`left`),n=d(e.to,`right`);s=a.x-16,c=a.y+40+t,l=o.x+o.w+16,u=o.y+40+n}}else if(m>0){let t=d(e.from,`bottom`),n=d(e.to,`top`);s=a.x+60+t,c=a.y+a.h+16,l=o.x+60+n,u=o.y-16}else{let t=d(e.from,`top`),n=d(e.to,`bottom`);s=a.x+60+t,c=a.y-16,l=o.x+60+n,u=o.y+o.h+16}let h=e.type===`1:1`?`var(--t-red)`:`var(--t-blue)`,g=e.type===`1:1`?`url(#erd-one)`:`url(#erd-crowfoot)`,_=(s+l)/2,v=(c+u)/2,y=Math.abs(p)>Math.abs(m)?`M${s},${c} C${_},${c} ${_},${u} ${l},${u}`:`M${s},${c} C${s},${v} ${l},${v} ${l},${u}`;f.push({d:y,color:h,markerEnd:g,label:`${e.virtual?`⇢ `:``}${e.type} ${e.label}`,midX:_,midY:v,virtual:!!e.virtual})}),{minX:i,minY:a,svgW:c,svgH:l,paths:f}})();if(!r)return null;let{minX:i,minY:a,svgW:o,svgH:s,paths:c}=r;return(0,$.jsxs)(`svg`,{className:`pointer-events-none absolute left-0 top-0`,style:{left:i,top:a},width:o,height:s,viewBox:`${i} ${a} ${o} ${s}`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`marker`,{id:`erd-crowfoot`,viewBox:`0 0 12 12`,refX:`12`,refY:`6`,markerWidth:`10`,markerHeight:`10`,orient:`auto`,children:[(0,$.jsx)(`line`,{x1:`0`,y1:`0`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`}),(0,$.jsx)(`line`,{x1:`0`,y1:`12`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`}),(0,$.jsx)(`line`,{x1:`0`,y1:`6`,x2:`12`,y2:`6`,stroke:`var(--t-blue)`,strokeWidth:`1.5`})]}),(0,$.jsxs)(`marker`,{id:`erd-one`,viewBox:`0 0 12 12`,refX:`12`,refY:`6`,markerWidth:`8`,markerHeight:`8`,orient:`auto`,children:[(0,$.jsx)(`line`,{x1:`8`,y1:`0`,x2:`8`,y2:`12`,stroke:`var(--t-red)`,strokeWidth:`2`}),(0,$.jsx)(`line`,{x1:`12`,y1:`0`,x2:`12`,y2:`12`,stroke:`var(--t-red)`,strokeWidth:`2`})]})]}),c.map((e,t)=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:`1.5`,fill:`none`,markerEnd:e.markerEnd,opacity:`0.7`,strokeDasharray:e.virtual?`6 4`:void 0}),(0,$.jsx)(`text`,{x:e.midX,y:e.midY-6,textAnchor:`middle`,fill:`var(--t-overlay0)`,fontSize:`10`,children:e.label})]},t))]})}var Get=.15,Ket=3,qet=.0012,Jet=120,Yet=e=>Math.max(Get,Math.min(Ket,e));function Xet(e){let t=yt.getState(),n=t.selectedNodeId[e],r=t.trees[e];if(!r)return null;let i=null,a=null;function o(e){for(let t of e){let e=t.metadata?.database;e&&a===null&&(t.type===Be.DATABASE||t.type===Be.SCHEMA)&&(a=e),t.id===n&&e&&(i=e),t.children.length>0&&o(t.children)}}return o(r),i??a}function Zet({connectionId:e}){let{t}=S(),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)([]),[o,s]=(0,D.useState)(1),[c,l]=(0,D.useState)(0),[u,d]=(0,D.useState)(0),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)({}),[g,_]=(0,D.useState)(null),[v,y]=(0,D.useState)(!1),[b,x]=(0,D.useState)(null),[,C]=(0,D.useState)(0),w=(0,D.useRef)(null),ee=(0,D.useRef)(null),[te,T]=(0,D.useState)(!1),ne=(0,D.useRef)(null),re=(0,D.useRef)(!1),ie=(0,D.useRef)({x:0,y:0}),ae=(0,D.useRef)({x:0,y:0}),E=(0,D.useRef)(1),oe=(0,D.useRef)(null),se=(0,D.useRef)(null),ce=(0,D.useRef)([]),le=(0,D.useRef)({}),ue=(0,D.useRef)(null),de=(0,D.useRef)(null),fe=V8(e=>e.links),pe=(0,D.useCallback)((t,n)=>{let r=(V8.getState().links[e]??[]).filter(e=>e.database===n);return r.length===0?{models:[...t.models],relations:[...t.relations]}:Iet(t.models.map(e=>({...e})),t.relations,r,{connectionId:e,database:n,connectionName:e=>{let t=Je.getState().activeConnections.find(t=>t.id===e)??Je.getState().savedConnections.find(t=>t.id===e);return t?t.hostName||t.host||t.file||t.id:e}})},[e]);(0,D.useEffect)(()=>{let e=de.current,t=ue.current;if(!e||!t)return;let n=pe(e,t),i=new Map(ce.current.map(e=>[e.name,{x:e.x,y:e.y}]));for(let e of n.models){let t=i.get(e.name);t&&(e.x=t.x,e.y=t.y)}ce.current=n.models,r(n.models),a(n.relations)},[fe]),ce.current=n,le.current=m,E.current=o,ae.current={x:c,y:u},ue.current=g;let me=(0,D.useCallback)(e=>le.current[e]||[...T9],[]),he=(0,D.useCallback)(()=>{let e={};ce.current.forEach(t=>{e[t.name]={x:t.x,y:t.y}}),R8.getState().savePositions(ue.current,e)},[]),ge=(0,D.useCallback)(()=>{R8.getState().saveColumnWidths(ue.current,le.current)},[]),_e=(0,D.useCallback)(e=>{let t=R8.getState().getPositions(ue.current);return t?(e.forEach(e=>{t[e.name]&&(e.x=t[e.name].x,e.y=t[e.name].y)}),!0):!1},[]),ve=(0,D.useCallback)(()=>R8.getState().getColumnWidths(ue.current),[]),ye=(0,D.useCallback)(()=>{let e=ce.current;if(e.length===0)return;let t=w.current;if(!t)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(e=>{let t=me(e.name);n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+D9(t)),a=Math.max(a,e.y+E9(e))});let o=i-n+80,c=a-r+80,u=t.clientWidth,f=t.clientHeight,p=Math.min(u/o,f/c,1),m=(u-o*p)/2-n*p+40,h=(f-c*p)/2-r*p+40;s(p),l(m),d(h)},[me]),be=(0,D.useCallback)(()=>{let e=ce.current;if(e.length===0)return;let t=w.current;if(!t)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(e=>{let t=me(e.name);n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+D9(t)),a=Math.max(a,e.y+E9(e))});let o=i-n+80,s=a-r+80,c=t.clientWidth,u=t.clientHeight,f=E.current;l((c-o*f)/2-n*f+40),d((u-s*f)/2-r*f+40)},[me]),xe=(0,D.useCallback)(async n=>{let i=Je.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId;if(!i){x(t(`erd.viewer.noServerConnection`));return}y(!0),x(null),_(n),ue.current=n,R8.getState().setDatabase(e,n);try{let e=await xet(i,n);de.current=e;let{models:t,relations:o}=pe(e,n);Net(t,[],o),_e(t);let s=ve();r([...t]),a(o),h(s),ce.current=t,le.current=s,setTimeout(()=>ye(),100)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e,_e,ve,ye,t]);(0,D.useEffect)(()=>{let t=R8.getState().database[e]||Xet(e);t&&xe(t)},[e]);let Se=(0,D.useCallback)(()=>{let t=g||Xet(e);t&&xe(t)},[g,e,xe]),Ce=(0,D.useCallback)((e,t)=>{e.stopPropagation();let n=w.current;if(!n)return;let r=ce.current.find(e=>e.name===t);if(!r)return;let i=n.getBoundingClientRect(),a=(e.clientX-i.left-ae.current.x)/E.current,o=(e.clientY-i.top-ae.current.y)/E.current;oe.current={name:t,offsetX:a-r.x,offsetY:o-r.y},p(t)},[]),we=(0,D.useCallback)((e,t,n)=>{e.stopPropagation(),e.preventDefault();let r=le.current[t]||[...T9];se.current={entityName:t,colIndex:n,startX:e.clientX,startWidth:r[n],nextStartWidth:r[n+1]},document.body.style.cursor=`col-resize`},[]),Te=(0,D.useCallback)(e=>{e.target.closest(`[data-entity]`)||e.button===0&&(re.current=!0,ie.current={x:e.clientX-ae.current.x,y:e.clientY-ae.current.y},p(null))},[]);(0,D.useEffect)(()=>{let e=e=>{if(se.current){let t=se.current,n=(e.clientX-t.startX)/E.current,r=Math.max(30,Math.round(t.startWidth+n)),i=Math.max(30,Math.round(t.nextStartWidth-n));h(e=>{let n=[...e[t.entityName]||[...T9]];return n[t.colIndex]=r,n[t.colIndex+1]=i,{...e,[t.entityName]:n}});return}if(oe.current){let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=(e.clientX-n.left-ae.current.x)/E.current,i=(e.clientY-n.top-ae.current.y)/E.current,a=Math.round(r-oe.current.offsetX),o=Math.round(i-oe.current.offsetY),s=ce.current.find(e=>e.name===oe.current.name);s&&(s.x=a,s.y=o,C(e=>e+1));return}re.current&&(l(e.clientX-ie.current.x),d(e.clientY-ie.current.y))},t=()=>{if(se.current){document.body.style.cursor=``,ge(),se.current=null;return}if(oe.current){oe.current=null,he();return}re.current=!1};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[he,ge]),(0,D.useEffect)(()=>{let e=w.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=E.current,o=t.deltaMode===1?16:t.deltaMode===2?n.height:1,c=Math.max(-120,Math.min(Jet,t.deltaY*o)),u=Yet(a*Math.exp(-c*qet));if(u===a)return;let f=(r-ae.current.x)/a,p=(i-ae.current.y)/a;l(r-f*u),d(i-p*u),s(u)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let Ee=(0,D.useCallback)(e=>{let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.width/2,i=n.height/2,a=E.current,o=Yet(a*e);if(o===a)return;let c=(r-ae.current.x)/a,u=(i-ae.current.y)/a;l(r-c*o),d(i-u*o),s(o)},[]),De=(0,D.useCallback)(()=>Ee(1.15),[Ee]),Oe=(0,D.useCallback)(()=>Ee(1/1.15),[Ee]),ke=(0,D.useCallback)(()=>{s(1),l(0),d(0)},[]),Ae=(0,D.useCallback)(()=>{Pet(ce.current,i,e=>D9(me(e.name)))&&(r([...ce.current]),he())},[i,he,me]),je=(0,D.useCallback)(()=>{R8.getState().resetLayout(ue.current),Net(ce.current,[],i),r([...ce.current]),h({}),setTimeout(()=>ye(),50)},[i,ye]),Me=n.length>0,Ne=n.reduce((e,t)=>e+t.columns.length,0),Pe=(0,D.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):ee.current?.requestFullscreen().catch(()=>{})},[]);return(0,D.useEffect)(()=>{let e=()=>{T(document.fullscreenElement===ee.current),setTimeout(()=>ye(),60)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[ye]),(0,$.jsxs)(`div`,{ref:ee,className:`flex h-full flex-col`,style:{background:`var(--t-background)`},children:[(0,$.jsx)(Let,{zoom:o,database:g,tableCount:n.length,relationCount:i.length,fieldCount:Ne,onZoomIn:De,onZoomOut:Oe,onResetView:ke,onCenter:be,onFitAll:ye,onSpreadAll:Ae,onResetLayout:je,onRefresh:Se,isFullscreen:te,onToggleFullscreen:Pe}),(0,$.jsxs)(`div`,{ref:w,className:`relative flex-1 overflow-hidden`,style:{cursor:re.current?`grabbing`:`grab`,background:`var(--t-background)`},onMouseDown:Te,children:[v&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-background/80`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(M6,{className:`size-5 animate-spin`}),t(`erd.viewer.loading`,{database:g})]})}),b&&!v&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-sm text-destructive`,children:[(0,$.jsx)(`p`,{children:t(`erd.viewer.loadFailed`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:b})]})}),!Me&&!v&&!b&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`p`,{children:t(`erd.viewer.noDatabase`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:t(`erd.viewer.selectDatabaseHint`)})]})}),Me&&(0,$.jsxs)(`div`,{ref:ne,className:`absolute left-0 top-0`,style:{transformOrigin:`0 0`,transform:`translate(${c}px, ${u}px) scale(${o})`},children:[(0,$.jsx)(Wet,{entities:n,relations:i,entityWidths:m}),n.map(e=>(0,$.jsx)(Vet,{entity:e,colWidths:m[e.name]||[...T9],isSelected:f===e.name,onMouseDown:Ce,onColResizeStart:we},e.name))]})]})]})}function Qet({connectionId:e}){let{t}=S(),n=_t(t=>t.tabs[e]??vt),r=_t(t=>t.activeTabId[e]??null),i=R8(t=>t.open[e]??!1),a=_t(e=>e.addQueryTab),o=_t(e=>e.removeQueryTab),s=_t(e=>e.removeQueryTabs),c=_t(e=>e.setActiveQueryTab),l=r&&(n.some(e=>e.id===r)||r===`erd`&&i)?r:n.length>0?n[n.length-1].id:i?`erd`:null;(0,D.useEffect)(()=>{l&&l!==r&&c(e,l)},[l,r,e,c]);let u=(0,D.useRef)(null);J4e(u,l);let{loadChildren:d}=hn(),f=n.find(e=>e.id===l),p=f?.sourceTable?{database:f.sourceTable.database,type:`TABLE`,name:f.sourceTable.table}:f?.sourceObject??null,m=p?`${p.database}/${p.type}/${p.name}`:null;(0,D.useEffect)(()=>{p&&ln(e,Tn(e,p.database,p.type,p.name),d)},[e,m]);let h=_t(e=>e.reorderQueryTab),g=(0,D.useMemo)(()=>n.map(e=>e.id),[n]),{dragProps:_,dropIndicator:v}=Ke(g,(0,D.useCallback)((t,n)=>h(e,t,n),[e,h])),y=R8(e=>e.closeERD),x=(0,D.useCallback)(e=>{y(e);let t=_t.getState();if(t.activeTabId[e]===`erd`){let n=t.tabs[e]??[];t.setActiveQueryTab(e,n.length>0?n[n.length-1].id:``)}},[y]),C=(0,D.useCallback)(()=>{let r={id:`tab-${Date.now()}`,title:t(`query.tabs.queryTitle`,{n:n.length+1}),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null};a(e,r)},[e,n.length,a,t]),w=(0,D.useCallback)((t,n)=>{if(t.stopPropagation(),n===`erd`){x(e);return}o(e,n)},[e,o,x]),ee=(0,D.useCallback)((t,r)=>{let a=n.findIndex(e=>e.id===t),o=n.filter((e,n)=>{switch(r){case`all`:return!0;case`others`:return e.id!==t;case`left`:return n<a;case`right`:return n>a}}).map(e=>e.id);o.length>0&&s(e,o),i&&(r===`all`||r===`others`||r===`right`)&&x(e)},[n,i,e,s,x]),te=(0,D.useCallback)(t=>{c(e,t);let r;r=t===`erd`?R8.getState().database[e]:n.find(e=>e.id===t)?.database,r&&mn(e,r)},[e,n,c]);return n.length===0&&!i?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(ne,{variant:`outline`,onClick:C,children:[(0,$.jsx)(I6,{className:`mr-1 size-4`}),t(`query.tabs.newQuery`)]})}):(0,$.jsxs)(b5,{value:l??void 0,onValueChange:te,className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center border-b bg-muted/30`,children:[(0,$.jsxs)(`div`,{ref:u,className:`min-w-0 flex-1 overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,$.jsxs)(x5,{className:`h-9 w-max rounded-none bg-transparent`,children:[n.map((r,a)=>(0,$.jsxs)(h5,{children:[(0,$.jsx)(g5,{asChild:!0,children:(0,$.jsxs)(S5,{value:r.id,..._(r.id),"data-drop-before":v===r.id||void 0,className:`shrink-0 gap-1 data-[drop-before]:shadow-[inset_2px_0_0_var(--color-primary)] !rounded-none !border-0 !border-b-2 !border-transparent px-3 py-1.5 !text-muted-foreground hover:!text-foreground aria-selected:!bg-primary aria-selected:!text-primary-foreground aria-selected:!border-primary aria-selected:font-semibold aria-selected:!shadow-none after:!hidden`,children:[r.sourceTable&&(0,$.jsx)(_1e,{className:`size-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`max-w-[120px] truncate text-xs`,children:r.title}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:e=>w(e,r.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w(e,r.id))},children:(0,$.jsx)(b,{className:`size-3`})})]})}),(0,$.jsxs)(_5,{children:[(0,$.jsx)(v5,{onSelect:()=>o(e,r.id),children:t(`query.tabs.close`)}),(0,$.jsx)(v5,{disabled:n.length<=1&&!i,onSelect:()=>ee(r.id,`others`),children:t(`query.tabs.closeOthers`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{disabled:a===0,onSelect:()=>ee(r.id,`left`),children:t(`query.tabs.closeLeft`)}),(0,$.jsx)(v5,{disabled:a===n.length-1&&!i,onSelect:()=>ee(r.id,`right`),children:t(`query.tabs.closeRight`)}),(0,$.jsx)(y5,{}),(0,$.jsx)(v5,{onSelect:()=>ee(r.id,`all`),children:t(`query.tabs.closeAll`)})]})]},r.id)),i&&(0,$.jsxs)(S5,{value:`erd`,className:`shrink-0 gap-1 !rounded-none !border-0 !border-b-2 !border-transparent px-3 py-1.5 !text-muted-foreground hover:!text-foreground aria-selected:!bg-primary aria-selected:!text-primary-foreground aria-selected:!border-primary aria-selected:font-semibold aria-selected:!shadow-none after:!hidden`,children:[(0,$.jsx)(`span`,{className:`text-xs`,children:t(`query.tabs.erdViewer`)}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded p-0.5 opacity-60 hover:bg-muted hover:opacity-100`,onClick:e=>w(e,`erd`),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w(e,`erd`))},children:(0,$.jsx)(b,{className:`size-3`})})]})]}),v===`end`&&(0,$.jsx)(`div`,{className:`h-6 w-0.5 shrink-0 bg-primary`})]}),(0,$.jsx)(ne,{variant:`ghost`,size:`icon`,className:`mx-1 size-7 shrink-0`,onClick:C,children:(0,$.jsx)(I6,{className:`size-4`})})]}),n.map(t=>(0,$.jsx)(C5,{value:t.id,className:`mt-0 flex-1 overflow-hidden`,forceMount:t.id!==l||void 0,hidden:t.id!==l,children:t.sourceTable?(0,$.jsx)(yet,{connectionId:e,tabId:t.id}):(0,$.jsx)(bet,{connectionId:e,tabId:t.id})},t.id)),i&&(0,$.jsx)(C5,{value:`erd`,className:`mt-0 flex-1 overflow-hidden`,forceMount:l!==`erd`||void 0,hidden:l!==`erd`,children:(0,$.jsx)(Zet,{connectionId:e})})]})}function $et({connectionId:e,fileName:t}){let{t:n}=S(),[r,i]=(0,D.useState)(!1),a=Je(e=>e.closeConnection);async function o(){i(!0);try{let t=await Mt(e,{interactive:!0});if(!t)return;let r=Je.getState();r.updateServerConnectionId(e,t.connectionId),r.updateProfile(e,{file:t.fileName}),r.setPendingReopen(e,!1),r.setFileDetached(e,t.fileDetached),yt.getState().removeTree(e),c.getState().setFooterMessage(n(`connection.tab.reopened`,{file:t.fileName}))}catch(e){c.getState().setFooterMessage(n(`connection.tab.reopenFailed`,{message:e instanceof Error?e.message:String(e)}))}finally{i(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-yellow/40 bg-catppuccin-yellow/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(k6,{className:`size-4 shrink-0 text-catppuccin-yellow`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.reopenPrompt`,values:{file:t||n(`connection.tab.theSqliteFile`)},components:{b:(0,$.jsx)(`span`,{className:`font-medium`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:r,onClick:()=>{o()},children:n(`connection.tab.reopenFile`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 shrink-0 text-xs`,onClick:()=>a(e),children:n(`connection.tab.closeConnection`)})]})}function ett({connectionId:e,serverConnectionId:t,fileName:n}){let{t:r}=S(),[i,a]=(0,D.useState)(!1),o=Je(e=>e.setFileDetached);async function s(){a(!0);try{await Ot(e,t)?(o(e,!1),c.getState().setFooterMessage(r(`connection.tab.reconnected`,{file:n}))):c.getState().setFooterMessage(r(`connection.tab.accessNotGranted`))}finally{a(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-blue/40 bg-catppuccin-blue/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(j6,{className:`size-4 shrink-0 text-catppuccin-blue`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.detachedPrompt`,values:{file:n||r(`connection.tab.theSqliteFile`)},components:{b:(0,$.jsx)(`span`,{className:`font-medium`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:i,onClick:()=>{s()},children:r(`connection.tab.reconnectFile`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 shrink-0 text-xs`,onClick:()=>o(e,!1),title:r(`connection.tab.detachedHide`),children:(0,$.jsx)(b,{className:`size-3`})})]})}function ttt({connectionId:e,serverConnectionId:t,fileName:n,onDismiss:r}){let{t:i}=S(),[a,o]=(0,D.useState)(!1);async function s(){o(!0);try{let r=await Tt(e,t);if(!r)return;Je.getState().updateServerConnectionId(e,r.connectionId),yt.getState().removeTree(e),c.getState().setFooterMessage(r.appliedFrames>0?i(`connection.tab.walFramesApplied`,{count:r.appliedFrames,file:n}):i(`connection.tab.walNoChanges`))}catch(e){c.getState().setFooterMessage(i(`connection.tab.walLoadFailed`,{message:e instanceof Error?e.message:String(e)}))}finally{o(!1)}}return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-catppuccin-peach/40 bg-catppuccin-peach/10 px-3 py-1.5 text-xs`,children:[(0,$.jsx)(k6,{className:`size-4 shrink-0 text-catppuccin-peach`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:(0,$.jsx)(or,{i18nKey:`connection.tab.walPrompt`,values:{file:n},components:{b:(0,$.jsx)(`span`,{className:`font-medium`}),mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(ne,{size:`sm`,className:`h-7 shrink-0 text-xs`,disabled:a,onClick:()=>{s()},children:i(`connection.tab.loadWal`)}),(0,$.jsx)(ne,{size:`sm`,variant:`outline`,className:`h-7 shrink-0 text-xs`,disabled:a,title:i(`connection.tab.noWalHint`),onClick:()=>{bt(t),c.getState().bumpTransportVersion(),r()},children:i(`connection.tab.noWal`)}),(0,$.jsx)(ne,{size:`sm`,variant:`ghost`,className:`h-7 w-7 shrink-0 p-0`,"aria-label":i(`connection.tab.dismiss`),title:i(`connection.tab.walHide`),onClick:r,children:(0,$.jsx)(b,{className:`size-3.5`})})]})}function ntt({connectionId:e}){let{t}=S(),n=Je(t=>t.activeConnections.find(t=>t.id===e)),r=m5(n?.environmentColor),i=Je(t=>t.pendingReopen[e]??!1),a=Je(t=>t.fileDetached[e]??!1),o=Ft(n?.serverConnectionId),[s,c]=(0,D.useState)(null),l=!i&&o?.wal&&!o.walApplied&&!o.walAcknowledged&&n?.serverConnectionId&&s!==n.serverConnectionId;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[i&&(0,$.jsx)($et,{connectionId:e,fileName:n?.file??``}),!i&&a&&!n?.sample&&!n?.scratchpad&&n?.serverConnectionId&&(0,$.jsx)(ett,{connectionId:e,serverConnectionId:n.serverConnectionId,fileName:n?.file??``}),l&&(0,$.jsx)(ttt,{connectionId:e,serverConnectionId:n.serverConnectionId,fileName:n?.file??``,onDismiss:()=>c(n.serverConnectionId)}),r&&(0,$.jsxs)(`div`,{className:`flex h-5 shrink-0 items-center gap-2 px-3 text-[11px] font-semibold uppercase tracking-wider text-white`,style:{background:r},children:[(0,$.jsx)(`span`,{children:n?.hostName||n?.host}),n?.readOnly&&(0,$.jsx)(`span`,{className:`rounded bg-black/25 px-1.5 py-px normal-case tracking-normal`,children:t(`connection.tab.readOnlyBadge`)})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,style:r?{boxShadow:`inset 3px 0 0 ${r}`}:void 0,children:(0,$.jsxs)(M4e,{direction:`horizontal`,defaultSize:200,minSize:150,maxSize:600,storageKey:`sidebar`,children:[(0,$.jsx)(`div`,{className:`h-full border-r border-catppuccin-surface1 bg-catppuccin-mantle overflow-hidden`,children:(0,$.jsx)(K4e,{connectionId:e})}),(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(Qet,{connectionId:e})})]})})]})}var j9=`<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>`,M9=`</title><path d="`,N9=`"/></svg>`,rtt={title:`Cloudflare`,slug:`cloudflare`,get svg(){return j9+`Cloudflare`+M9+this.path+N9},path:`M16.5088 16.8447c.1475-.5068.0908-.9707-.1553-1.3154-.2246-.3164-.6045-.499-1.0615-.5205l-8.6592-.1123a.1559.1559 0 0 1-.1333-.0713c-.0283-.042-.0351-.0986-.021-.1553.0278-.084.1123-.1484.2036-.1562l8.7359-.1123c1.0351-.0489 2.1601-.8868 2.5537-1.9136l.499-1.3013c.0215-.0561.0293-.1128.0147-.168-.5625-2.5463-2.835-4.4453-5.5499-4.4453-2.5039 0-4.6284 1.6177-5.3876 3.8614-.4927-.3658-1.1187-.5625-1.794-.499-1.2026.119-2.1665 1.083-2.2861 2.2856-.0283.31-.0069.6128.0635.894C1.5683 13.171 0 14.7754 0 16.752c0 .1748.0142.3515.0352.5273.0141.083.0844.1475.1689.1475h15.9814c.0909 0 .1758-.0645.2032-.1553l.12-.4268zm2.7568-5.5634c-.0771 0-.1611 0-.2383.0112-.0566 0-.1054.0415-.127.0976l-.3378 1.1744c-.1475.5068-.0918.9707.1543 1.3164.2256.3164.6055.498 1.0625.5195l1.8437.1133c.0557 0 .1055.0263.1329.0703.0283.043.0351.1074.0214.1562-.0283.084-.1132.1485-.204.1553l-1.921.1123c-1.041.0488-2.1582.8867-2.5527 1.914l-.1406.3585c-.0283.0713.0215.1416.0986.1416h6.5977c.0771 0 .1474-.0489.169-.126.1122-.4082.1757-.837.1757-1.2803 0-2.6025-2.125-4.727-4.7344-4.727`,source:`https://www.cloudflare.com/logo/`,hex:`F38020`,guidelines:`https://www.cloudflare.com/trademark/`},itt={mysql:{title:`MySQL`,slug:`mysql`,get svg(){return j9+`MySQL`+M9+this.path+N9},path:`M16.405 5.501c-.115 0-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77 18.695h-.927a50.854 50.854 0 00-.27-4.41h-.008l-1.41 4.41H2.45l-1.4-4.41h-.01a72.892 72.892 0 00-.195 4.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335 4.064h.008l1.347-4.064h1.095c.242 2.015.384 3.86.428 5.53zm4.017-4.08c-.378 2.045-.876 3.533-1.492 4.46-.482.716-1.01 1.073-1.583 1.073-.153 0-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268 0 .483-.075.647-.222.197-.18.295-.382.295-.605 0-.155-.077-.47-.23-.944L6.23 14.615h.91l.727 2.36c.164.536.233.91.205 1.123.4-1.064.678-2.227.835-3.483zm12.325 4.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253 0-1.83-.718-2.746-2.155-2.746-.704 0-1.254.232-1.65.697-.43.508-.646 1.256-.646 2.245 0 .972.19 1.686.574 2.14.35.41.877.615 1.583.615.264 0 .506-.033.725-.098l1.325.772.36-.622zM15.5 17.588c-.225-.36-.337-.94-.337-1.736 0-1.393.424-2.09 1.27-2.09.443 0 .77.167.977.5.224.362.336.936.336 1.723 0 1.404-.424 2.108-1.27 2.108-.445 0-.77-.167-.978-.5zm-1.658-.425c0 .47-.172.856-.516 1.156-.344.3-.803.45-1.384.45-.543 0-1.064-.172-1.573-.515l.237-.476c.438.22.833.328 1.19.328.332 0 .593-.073.783-.22a.754.754 0 00.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177 0-.45.157-.81.47-1.085.315-.278.72-.415 1.22-.415.512 0 .98.136 1.4.41l-.213.476a2.726 2.726 0 00-1.064-.23c-.283 0-.502.068-.654.206a.685.685 0 00-.248.524c0 .328.234.61.666.85.393.215 1.187.67 1.187.67.433.305.648.63.648 1.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223 3.223 0 00-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867 8.867 0 00-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69 17.69 0 01-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422 1.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146 1.693.194 2.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445 3.445 0 01-.35-.4 8.76 8.76 0 01-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188 1.01-.027.007-.014 0-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478 2.478 0 01-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953 5.953 0 012.085 2.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z`,source:`https://www.mysql.com/about/legal/logos.html`,hex:`4479A1`,guidelines:`https://www.mysql.com/about/legal/logos.html`},maria:{title:`MariaDB`,slug:`mariadb`,get svg(){return j9+`MariaDB`+M9+this.path+N9},path:`M23.157 4.412c-.676.284-.79.31-1.673.372-.65.045-.757.057-1.212.209-.75.246-1.395.75-2.02 1.59-.296.398-1.249 1.913-1.249 1.988 0 .057-.65.998-.915 1.32-.574.713-1.08 1.079-2.14 1.59-.77.36-1.224.524-4.102 1.477-1.073.353-2.133.738-2.367.864-.852.449-1.515 1.036-2.203 1.938-1.003 1.32-.972 1.313-3.042.947a12.264 12.264 0 00-.675-.063c-.644-.05-1.023.044-1.332.334L0 17.193l.177.088c.094.05.353.234.561.398.215.17.461.347.55.391.088.044.17.088.183.101.012.013-.089.17-.228.353-.435.581-.593.871-.574 1.048.019.164.032.17.43.17.517-.006.826-.056 1.261-.208.65-.233 2.058-.94 2.784-1.4.776-.5 1.717-.998 1.956-1.042.082-.02.354-.07.594-.114.58-.107 1.464-.095 2.587.05.108.013.373.045.6.064.227.025.43.057.454.076.026.012.474.037.998.056.934.026 1.104.007 1.3-.189.126-.133.385-.631.498-.985.209-.643.417-.921.366-.492-.113.966-.322 1.692-.713 2.411-.259.499-.663 1.092-.934 1.395-.322.347-.315.36.088.315.619-.063 1.471-.397 2.096-.82.827-.562 1.647-1.691 2.19-3.03.107-.27.22-.22.183.083-.013.094-.038.315-.057.498l-.031.328.353-.202c.833-.48 1.414-1.262 2.127-2.884.227-.518.877-2.922 1.073-3.976a9.64 9.64 0 01.271-1.042c.127-.429.196-.555.48-.858.183-.19.625-.555.978-.808.72-.505.953-.75 1.187-1.205.208-.417.284-1.13.132-1.357-.132-.202-.284-.196-.763.006Z`,source:`https://mariadb.com/about-us/logos/`,hex:`003545`,guidelines:`https://mariadb.com/about-us/logos/`},postgres:{title:`PostgreSQL`,slug:`postgresql`,get svg(){return j9+`PostgreSQL`+M9+this.path+N9},path:`M23.5594 14.7228a.5269.5269 0 0 0-.0563-.1191c-.139-.2632-.4768-.3418-1.0074-.2321-1.6533.3411-2.2935.1312-2.5256-.0191 1.342-2.0482 2.445-4.522 3.0411-6.8297.2714-1.0507.7982-3.5237.1222-4.7316a1.5641 1.5641 0 0 0-.1509-.235C21.6931.9086 19.8007.0248 17.5099.0005c-1.4947-.0158-2.7705.3461-3.1161.4794a9.449 9.449 0 0 0-.5159-.0816 8.044 8.044 0 0 0-1.3114-.1278c-1.1822-.0184-2.2038.2642-3.0498.8406-.8573-.3211-4.7888-1.645-7.2219.0788C.9359 2.1526.3086 3.8733.4302 6.3043c.0409.818.5069 3.334 1.2423 5.7436.4598 1.5065.9387 2.7019 1.4334 3.582.553.9942 1.1259 1.5933 1.7143 1.7895.4474.1491 1.1327.1441 1.8581-.7279.8012-.9635 1.5903-1.8258 1.9446-2.2069.4351.2355.9064.3625 1.39.3772a.0569.0569 0 0 0 .0004.0041 11.0312 11.0312 0 0 0-.2472.3054c-.3389.4302-.4094.5197-1.5002.7443-.3102.064-1.1344.2339-1.1464.8115-.0025.1224.0329.2309.0919.3268.2269.4231.9216.6097 1.015.6331 1.3345.3335 2.5044.092 3.3714-.6787-.017 2.231.0775 4.4174.3454 5.0874.2212.5529.7618 1.9045 2.4692 1.9043.2505 0 .5263-.0291.8296-.0941 1.7819-.3821 2.5557-1.1696 2.855-2.9059.1503-.8707.4016-2.8753.5388-4.1012.0169-.0703.0357-.1207.057-.1362.0007-.0005.0697-.0471.4272.0307a.3673.3673 0 0 0 .0443.0068l.2539.0223.0149.001c.8468.0384 1.9114-.1426 2.5312-.4308.6438-.2988 1.8057-1.0323 1.5951-1.6698zM2.371 11.8765c-.7435-2.4358-1.1779-4.8851-1.2123-5.5719-.1086-2.1714.4171-3.6829 1.5623-4.4927 1.8367-1.2986 4.8398-.5408 6.108-.13-.0032.0032-.0066.0061-.0098.0094-2.0238 2.044-1.9758 5.536-1.9708 5.7495-.0002.0823.0066.1989.0162.3593.0348.5873.0996 1.6804-.0735 2.9184-.1609 1.1504.1937 2.2764.9728 3.0892.0806.0841.1648.1631.2518.2374-.3468.3714-1.1004 1.1926-1.9025 2.1576-.5677.6825-.9597.5517-1.0886.5087-.3919-.1307-.813-.5871-1.2381-1.3223-.4796-.839-.9635-2.0317-1.4155-3.5126zm6.0072 5.0871c-.1711-.0428-.3271-.1132-.4322-.1772.0889-.0394.2374-.0902.4833-.1409 1.2833-.2641 1.4815-.4506 1.9143-1.0002.0992-.126.2116-.2687.3673-.4426a.3549.3549 0 0 0 .0737-.1298c.1708-.1513.2724-.1099.4369-.0417.156.0646.3078.26.3695.4752.0291.1016.0619.2945-.0452.4444-.9043 1.2658-2.2216 1.2494-3.1676 1.0128zm2.094-3.988-.0525.141c-.133.3566-.2567.6881-.3334 1.003-.6674-.0021-1.3168-.2872-1.8105-.8024-.6279-.6551-.9131-1.5664-.7825-2.5004.1828-1.3079.1153-2.4468.079-3.0586-.005-.0857-.0095-.1607-.0122-.2199.2957-.2621 1.6659-.9962 2.6429-.7724.4459.1022.7176.4057.8305.928.5846 2.7038.0774 3.8307-.3302 4.7363-.084.1866-.1633.3629-.2311.5454zm7.3637 4.5725c-.0169.1768-.0358.376-.0618.5959l-.146.4383a.3547.3547 0 0 0-.0182.1077c-.0059.4747-.054.6489-.115.8693-.0634.2292-.1353.4891-.1794 1.0575-.11 1.4143-.8782 2.2267-2.4172 2.5565-1.5155.3251-1.7843-.4968-2.0212-1.2217a6.5824 6.5824 0 0 0-.0769-.2266c-.2154-.5858-.1911-1.4119-.1574-2.5551.0165-.5612-.0249-1.9013-.3302-2.6462.0044-.2932.0106-.5909.019-.8918a.3529.3529 0 0 0-.0153-.1126 1.4927 1.4927 0 0 0-.0439-.208c-.1226-.4283-.4213-.7866-.7797-.9351-.1424-.059-.4038-.1672-.7178-.0869.067-.276.1831-.5875.309-.9249l.0529-.142c.0595-.16.134-.3257.213-.5012.4265-.9476 1.0106-2.2453.3766-5.1772-.2374-1.0981-1.0304-1.6343-2.2324-1.5098-.7207.0746-1.3799.3654-1.7088.5321a5.6716 5.6716 0 0 0-.1958.1041c.0918-1.1064.4386-3.1741 1.7357-4.4823a4.0306 4.0306 0 0 1 .3033-.276.3532.3532 0 0 0 .1447-.0644c.7524-.5706 1.6945-.8506 2.802-.8325.4091.0067.8017.0339 1.1742.081 1.939.3544 3.2439 1.4468 4.0359 2.3827.8143.9623 1.2552 1.9315 1.4312 2.4543-1.3232-.1346-2.2234.1268-2.6797.779-.9926 1.4189.543 4.1729 1.2811 5.4964.1353.2426.2522.4522.2889.5413.2403.5825.5515.9713.7787 1.2552.0696.087.1372.1714.1885.245-.4008.1155-1.1208.3825-1.0552 1.717-.0123.1563-.0423.4469-.0834.8148-.0461.2077-.0702.4603-.0994.7662zm.8905-1.6211c-.0405-.8316.2691-.9185.5967-1.0105a2.8566 2.8566 0 0 0 .135-.0406 1.202 1.202 0 0 0 .1342.103c.5703.3765 1.5823.4213 3.0068.1344-.2016.1769-.5189.3994-.9533.6011-.4098.1903-1.0957.333-1.7473.3636-.7197.0336-1.0859-.0807-1.1721-.151zm.5695-9.2712c-.0059.3508-.0542.6692-.1054 1.0017-.055.3576-.112.7274-.1264 1.1762-.0142.4368.0404.8909.0932 1.3301.1066.887.216 1.8003-.2075 2.7014a3.5272 3.5272 0 0 1-.1876-.3856c-.0527-.1276-.1669-.3326-.3251-.6162-.6156-1.1041-2.0574-3.6896-1.3193-4.7446.3795-.5427 1.3408-.5661 2.1781-.463zm.2284 7.0137a12.3762 12.3762 0 0 0-.0853-.1074l-.0355-.0444c.7262-1.1995.5842-2.3862.4578-3.4385-.0519-.4318-.1009-.8396-.0885-1.2226.0129-.4061.0666-.7543.1185-1.0911.0639-.415.1288-.8443.1109-1.3505.0134-.0531.0188-.1158.0118-.1902-.0457-.4855-.5999-1.938-1.7294-3.253-.6076-.7073-1.4896-1.4972-2.6889-2.0395.5251-.1066 1.2328-.2035 2.0244-.1859 2.0515.0456 3.6746.8135 4.8242 2.2824a.908.908 0 0 1 .0667.1002c.7231 1.3556-.2762 6.2751-2.9867 10.5405zm-8.8166-6.1162c-.025.1794-.3089.4225-.6211.4225a.5821.5821 0 0 1-.0809-.0056c-.1873-.026-.3765-.144-.5059-.3156-.0458-.0605-.1203-.178-.1055-.2844.0055-.0401.0261-.0985.0925-.1488.1182-.0894.3518-.1226.6096-.0867.3163.0441.6426.1938.6113.4186zm7.9305-.4114c.0111.0792-.049.201-.1531.3102-.0683.0717-.212.1961-.4079.2232a.5456.5456 0 0 1-.075.0052c-.2935 0-.5414-.2344-.5607-.3717-.024-.1765.2641-.3106.5611-.352.297-.0414.6111.0088.6356.1851z`,source:`https://wiki.postgresql.org/wiki/Logo`,hex:`4169E1`,guidelines:`https://www.postgresql.org/about/policies/trademarks/`},sqlite:{title:`SQLite`,slug:`sqlite`,get svg(){return j9+`SQLite`+M9+this.path+N9},path:`M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71 8.71 0 0 0-.547.535c-2.109 2.237-4.066 6.38-4.674 9.544.237.48.422 1.093.544 1.561a13.044 13.044 0 0 1 .164.703s-.019-.071-.096-.296l-.05-.146a1.689 1.689 0 0 0-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376 1.176.484.884.778 2.4.778 2.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304 1.346-.226 1.478.152.256.296.698.422 1.186.286 1.1.485 2.44.485 2.44l.017.224a22.41 22.41 0 0 0 .056 2.748c.095 1.146.273 2.13.5 2.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29 1.661-8.304 1.723-4.55 4.113-8.201 6.3-9.945-1.993 1.8-4.692 7.63-5.5 9.788-.904 2.416-1.545 4.684-1.931 6.857.666-2.037 2.821-2.912 2.821-2.912s1.057-1.304 2.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184 3.613-1.72C21.695 7.9 24.195 2.767 21.678.521m-18.573.543A1.842 1.842 0 0 0 1.27 2.9v16.608a1.84 1.84 0 0 0 1.835 1.834h9.418a22.953 22.953 0 0 1-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01 27.01 0 0 0-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432 0-.12.015-.245.037-.386a9.98 9.98 0 0 1 .234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8 32.8 0 0 1 .382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28 2.587-7.443 4.8-9.791.066-.069.133-.128.198-.194Z`,source:`https://github.com/sqlite/sqlite/blob/43e862723ec680542ca6f608f9963c0993dd7324/art/sqlite370.eps`,hex:`003B57`},mssql:{path:`M12 1.5c-4.97 0-9 1.79-9 4v13c0 2.21 4.03 4 9 4s9-1.79 9-4v-13c0-2.21-4.03-4-9-4zm0 2c3.87 0 7 1.12 7 2s-3.13 2-7 2-7-1.12-7-2 3.13-2 7-2zm0 2.9a2.1 2.1 0 1 1 0 4.2 2.1 2.1 0 0 1 0-4.2zM5 8.55c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45V11c0 .88-3.13 2-7 2s-7-1.12-7-2V8.55zm0 4.9c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45V16c0 .88-3.13 2-7 2s-7-1.12-7-2v-2.55zm0 5c1.6.9 4.2 1.45 7 1.45s5.4-.55 7-1.45`},oracle:{path:`M7.5 5.5h9a6.5 6.5 0 0 1 0 13h-9a6.5 6.5 0 0 1 0-13zm0 2.4a4.1 4.1 0 0 0 0 8.2h9a4.1 4.1 0 0 0 0-8.2h-9z`},neon:{title:`Neon`,slug:`neon`,get svg(){return j9+`Neon`+M9+this.path+N9},path:`M24 0V24l-9.365-8.045V24H0V0ZM2.942 21.087h8.751V9.563l9.365 8.204V2.919L2.942 2.914Z`,source:`https://neon.com/brand`,hex:`34D59A`,guidelines:`https://neon.com/brand`},supabase:{title:`Supabase`,slug:`supabase`,get svg(){return j9+`Supabase`+M9+this.path+N9},path:`M11.9 1.036c-.015-.986-1.26-1.41-1.874-.637L.764 12.05C-.33 13.427.65 15.455 2.409 15.455h9.579l.113 7.51c.014.985 1.259 1.408 1.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z`,source:`https://github.com/supabase/supabase/blob/4031a7549f5d46da7bc79c01d56be4177dc7c114/packages/common/assets/images/supabase-logo-wordmark--light.svg`,hex:`3FCF8E`},d1:rtt,do:rtt};function P9({dbms:e,className:t}){let n=itt[e];return n?(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,className:w(`size-4 shrink-0`,t),fill:`currentColor`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:n.path})}):(0,$.jsx)(D6,{className:w(`size-4 shrink-0`,t),"aria-hidden":!0})}function att(){let{t:e}=S(),{activeConnections:t,activeConnectionId:n,setActiveConnection:r,closeConnection:i}=Je(),a=(0,D.useRef)(null);J4e(a,n);let o=Je(e=>e.reorderActiveConnection),s=(0,D.useMemo)(()=>t.map(e=>e.id),[t]),{dragProps:c,dropIndicator:l}=Ke(s,(0,D.useCallback)((e,t)=>o(e,t),[o]));return t.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:e(`connection.tab.noConnections`)}):(0,$.jsxs)(b5,{value:n??void 0,onValueChange:r,className:`h-full gap-0`,children:[(0,$.jsx)(x5,{ref:a,variant:`line`,className:`w-full shrink-0 justify-start overflow-x-auto overflow-y-hidden border-b px-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:t.map(e=>(0,$.jsxs)(S5,{value:e.id,...c(e.id),"data-drop-before":l===e.id||void 0,className:`shrink-0 gap-1 data-[drop-before]:shadow-[inset_2px_0_0_var(--color-primary)] !rounded-none !border-0 !border-b-2 !border-transparent pr-1 !text-muted-foreground hover:!text-foreground data-[state=active]:!bg-primary data-[state=active]:!text-primary-foreground data-[state=active]:!border-primary data-[state=active]:font-semibold data-[state=active]:!shadow-none after:!hidden`,children:[m5(e.environmentColor)&&(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{background:m5(e.environmentColor)}}),(0,$.jsx)(P9,{dbms:e.dbms,className:`size-3.5 opacity-80`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:e.hostName||`${e.host}:${e.port}`}),(0,$.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-colors`,onClick:t=>{t.stopPropagation(),i(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),i(e.id))},children:(0,$.jsx)(b,{className:`size-3`})})]},e.id))}),t.map(e=>(0,$.jsx)(C5,{value:e.id,className:`mt-0 min-h-0 flex-1`,children:(0,$.jsx)(ntt,{connectionId:e.id})},e.id))]})}var ott=(0,D.lazy)(()=>oe(()=>import(`./dxLVUFtU.js`).then(e=>({default:e.ConnectDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),stt=(0,D.lazy)(()=>oe(()=>import(`./IzH8qyLi.js`).then(e=>({default:e.CreateDatabaseDialog})),__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,18,15,19,11,10,12,13,14,20,21,22,16]))),ctt=(0,D.lazy)(()=>oe(()=>import(`./Dh3YJ3G1.js`).then(e=>({default:e.CreateSchemaDialog})),__vite__mapDeps([23,1,2,3,7,8,9,18,15,19,11,10,12,13,14,20,21,22,16,5]))),ltt=(0,D.lazy)(()=>oe(()=>import(`./B5OocgEJ.js`).then(e=>({default:e.CopyDatabaseDialog})),__vite__mapDeps([24,1,2,3,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16,5]))),utt=(0,D.lazy)(()=>oe(()=>import(`./B3uI9Ppb.js`).then(e=>({default:e.DownloadToCSVDialog})),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,13,14,11,10,12,18,15,19,20,21,22,16,26]))),dtt=(0,D.lazy)(()=>oe(()=>import(`./og5dTmtH.js`).then(e=>({default:e.SchemaToHTMLDialog})),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,13,14,11,10,12,18,15,22,16,26]))),ftt=(0,D.lazy)(()=>oe(()=>import(`./1E6FYbv2.js`).then(e=>({default:e.CopyTableDialog})),__vite__mapDeps([28,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),ptt=(0,D.lazy)(()=>oe(()=>import(`./DmejZTwI.js`).then(e=>({default:e.LinkColumnDialog})),__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,16]))),mtt=(0,D.lazy)(()=>oe(()=>import(`./QBd1UkiI.js`).then(e=>({default:e.DataDiffDialog})),__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,16]))),htt=(0,D.lazy)(()=>oe(()=>import(`./DGD5v9rw.js`).then(e=>({default:e.GroupByDialog})),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),gtt=(0,D.lazy)(()=>oe(()=>import(`./DnjY8W6t.js`).then(e=>({default:e.SchemaDiffDialog})),__vite__mapDeps([33,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,30,34,16]))),F9=(0,D.lazy)(()=>oe(()=>import(`./Bpg8LzYe.js`).then(e=>({default:e.EditSchemaDialog})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,14,11,10,12,13,18,15,19,20,21,22,16]))),_tt=(0,D.lazy)(()=>oe(()=>import(`./BGOnv2_O.js`).then(e=>({default:e.UserManagerDialog})),__vite__mapDeps([36,1,2,3,7,8,9,14,11,10,12,13,15,18,19,20,21,22,16,5,37]))),vtt=(0,D.lazy)(()=>oe(()=>import(`./C4il2fft.js`).then(e=>({default:e.UserAddDialog})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,16,37]))),ytt=(0,D.lazy)(()=>oe(()=>import(`./Dd9Cr3e8.js`).then(e=>({default:e.ProcessListDialog})),__vite__mapDeps([39,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),btt=(0,D.lazy)(()=>oe(()=>import(`./RIOwEE7M.js`).then(e=>({default:e.VariablesDialog})),__vite__mapDeps([40,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),xtt=(0,D.lazy)(()=>oe(()=>import(`./Cx_chT_j.js`).then(e=>({default:e.StatusDialog})),__vite__mapDeps([41,1,2,3,11,7,8,9,14,10,12,13,18,15,16,5]))),Stt=(0,D.lazy)(()=>oe(()=>import(`./D-RWduy5.js`).then(e=>({default:e.FlushDialog})),__vite__mapDeps([42,2,1,3,7,8,9,14,11,10,12,13,16,5]))),Ctt=(0,D.lazy)(()=>oe(()=>import(`./FnB_uI57.js`).then(e=>({default:e.FindReplaceDialog})),__vite__mapDeps([43,1,2,3,6,7,8,9,13,20,12]))),wtt=(0,D.lazy)(()=>oe(()=>import(`./DZH-tLW-.js`).then(e=>({default:e.SafetySettingsDialog})),__vite__mapDeps([44,2,1,3,9,8,16,5,45]))),Ttt=(0,D.lazy)(()=>oe(()=>import(`./BIjF9ulh.js`).then(e=>({default:e.QuerySettingsDialog})),__vite__mapDeps([46,2,1,3,4,5,6,9,8,16,45]))),Ett=(0,D.lazy)(()=>oe(()=>import(`./cc05Z2oj.js`).then(e=>({default:e.GeneralSettingsDialog})),__vite__mapDeps([47,2,1,3,11,4,5,6,9,8,16,45]))),Dtt=(0,D.lazy)(()=>oe(()=>import(`./S4Oofhu9.js`).then(e=>({default:e.AiSettingsDialog})),__vite__mapDeps([48,1,2,3,4,5,6,9,8,10,11,12,16]))),Ott=(0,D.lazy)(()=>oe(()=>import(`./B8xQ2o-X.js`).then(e=>({default:e.McpSetupDialog})),__vite__mapDeps([49,1,2,3,10,11,12,16,5]))),ktt=(0,D.lazy)(()=>oe(()=>import(`./COIa4uoZ.js`).then(e=>({default:e.LocalHistoryDialog})),__vite__mapDeps([50,1,2,3,7,8,9,13,16,5]))),Att=(0,D.lazy)(()=>oe(()=>import(`./C3bMAsUp.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([51,2,1,3,16,5]))),jtt=(0,D.lazy)(()=>oe(()=>import(`./DiaA_DOW.js`).then(e=>({default:e.LicenseDialog})),__vite__mapDeps([52,1,2,3,16,5,53,54]))),Mtt=(0,D.lazy)(()=>oe(()=>import(`./fCzQKDqY.js`).then(e=>({default:e.SyncDialog})),__vite__mapDeps([55,1,2,3,16,5,53,54]))),Ntt=(0,D.lazy)(()=>oe(()=>import(`./BunrDTHn.js`).then(e=>({default:e.TermsDialog})),__vite__mapDeps([56,2,1,3,9,8,16,5]))),Ptt=(0,D.lazy)(()=>oe(()=>import(`./qbvehL2h.js`).then(e=>({default:e.RowFormDialog})),__vite__mapDeps([57,1,2,3,7,8,9,14,11,10,12,13,19,15,18,20,21,22,16,5]))),Ftt={connect:ott,"create-database":stt,"create-schema":ctt,"copy-database":ltt,"export-csv":utt,"export-html":dtt,"alter-database":F9,"create-table":F9,"alter-table":F9,"duplicate-table-structure":F9,"copy-table":ftt,"schema-diff":gtt,"data-diff":mtt,"group-by":htt,"link-column":ptt,"user-manager":_tt,"user-add":vtt,"process-list":ytt,variables:btt,status:xtt,flush:Stt,"find-replace":Ctt,"quick-command":(0,D.lazy)(()=>oe(()=>import(`./DFNc4ghA.js`).then(e=>({default:e.QuickCommandPalette})),__vite__mapDeps([58,1,2,3,11,5,7,8,9,13,14,10,12,19,15,18,20,21,22,16]))),"safety-settings":wtt,"query-settings":Ttt,"general-settings":Ett,"ai-settings":Dtt,"mcp-setup":Ott,"local-history":ktt,about:Att,license:jtt,sync:Mtt,terms:Ntt,"row-form":Ptt};function Itt(){let e=c(e=>e.activeDialog);if(!e)return null;let t=Ftt[e];return t?(0,$.jsx)(D.Suspense,{fallback:null,children:(0,$.jsx)(t,{})}):null}function I9({...e}){return(0,$.jsx)(IKe,{"data-slot":`alert-dialog`,...e})}function Ltt({...e}){return(0,$.jsx)(LKe,{"data-slot":`alert-dialog-portal`,...e})}function Rtt({className:e,...t}){return(0,$.jsx)(RKe,{"data-slot":`alert-dialog-overlay`,className:w(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function L9({className:e,size:t=`default`,...n}){return(0,$.jsxs)(Ltt,{children:[(0,$.jsx)(Rtt,{}),(0,$.jsx)(zKe,{"data-slot":`alert-dialog-content`,"data-size":t,className:w(`group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg`,e),...n})]})}function R9({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:w(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function z9({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:w(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function B9({className:e,...t}){return(0,$.jsx)(HKe,{"data-slot":`alert-dialog-title`,className:w(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function V9({className:e,...t}){return(0,$.jsx)(UKe,{"data-slot":`alert-dialog-description`,className:w(`text-sm text-muted-foreground`,e),...t})}function H9({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,$.jsx)(ne,{variant:t,size:n,asChild:!0,children:(0,$.jsx)(BKe,{"data-slot":`alert-dialog-action`,className:w(e),...r})})}function U9({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,$.jsx)(ne,{variant:t,size:n,asChild:!0,children:(0,$.jsx)(VKe,{"data-slot":`alert-dialog-cancel`,className:w(e),...r})})}function W9({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,"data-slot":`input`,className:w(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function ztt({className:e,...t}){return(0,$.jsx)(MXe,{"data-slot":`label`,className:w(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Btt(){let e=c(e=>e.destructiveConfirm),t=c(e=>e.resolveDestructiveConfirm);return e?(0,$.jsx)(Vtt,{request:e.request,resolve:t},e.id):null}function Vtt({request:e,resolve:t}){let{t:n}=S(),[r,i]=(0,D.useState)(``),a=!!e.typeToConfirm,o=!a||r===e.typeToConfirm;return(0,$.jsx)(I9,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,$.jsx)(L9,{className:`max-w-lg overflow-hidden`,children:(0,$.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),o&&t(!0)},children:[(0,$.jsxs)(R9,{children:[(0,$.jsxs)(B9,{className:`flex min-w-0 items-center gap-2 break-words`,children:[(0,$.jsx)(W6,{className:`size-5 shrink-0 text-destructive`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,$.jsx)(V9,{className:`min-w-0 break-words [overflow-wrap:anywhere] whitespace-pre-line`,children:e.description??n(`confirm.defaultDescription`)})]}),e.statements&&e.statements.length>0&&(0,$.jsx)(`pre`,{className:`max-h-48 overflow-auto rounded-md border bg-muted p-3 font-mono text-xs whitespace-pre-wrap break-all`,children:e.statements.join(`
943
943
  `)}),a&&(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(ztt,{htmlFor:`destructive-confirm-input`,children:(0,$.jsx)(or,{i18nKey:`confirm.typeToConfirm`,components:{name:(0,$.jsx)(`span`,{className:`font-mono font-semibold`,children:e.typeToConfirm})}})}),(0,$.jsx)(W9,{id:`destructive-confirm-input`,autoFocus:!0,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),placeholder:e.typeToConfirm})]}),(0,$.jsxs)(z9,{children:[(0,$.jsx)(U9,{type:`button`,onClick:()=>t(!1),children:n(`confirm.cancel`)}),(0,$.jsx)(H9,{type:`submit`,variant:`destructive`,disabled:!o,onClick:()=>{o&&t(!0)},children:e.confirmLabel??n(`confirm.confirm`)})]})]})})})}var Htt=e=>e==null?`NULL`:typeof e==`object`?d7(e)??String(e):String(e);function Utt(){let e=c(e=>e.dryRun),t=c(e=>e.resolveDryRun);return e?(0,$.jsx)(Wtt,{request:e.request,resolve:t},e.id):null}function Wtt({request:e,resolve:t}){let{t:n}=S(),{statement:r,previewSql:i,count:a,fields:o,rows:s,truncated:c,error:l}=e,u=r.trim().slice(0,6).toUpperCase()===`DELETE`?`DELETE`:`UPDATE`;return(0,$.jsx)(I9,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,$.jsxs)(L9,{className:`max-w-3xl overflow-hidden`,children:[(0,$.jsxs)(R9,{children:[(0,$.jsxs)(B9,{className:`flex items-center gap-2`,children:[(0,$.jsx)(O6,{className:`size-5 shrink-0 text-primary`}),l||a===null?n(`dryRun.titleUnknown`,{kind:u}):n(`dryRun.title`,{kind:u,count:a})]}),(0,$.jsx)(V9,{className:`whitespace-pre-line`,children:l?n(`dryRun.previewFailed`,{error:l}):n(`dryRun.description`)})]}),(0,$.jsx)(`pre`,{className:`max-h-24 overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap break-all`,children:r}),!l&&(0,$.jsx)(`div`,{className:`max-h-72 overflow-auto rounded-md border`,children:s.length===0?(0,$.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:n(`dryRun.noRows`)}):(0,$.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-muted text-muted-foreground`,children:(0,$.jsx)(`tr`,{children:o.map(e=>(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-normal whitespace-nowrap`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:s.map((e,t)=>(0,$.jsx)(`tr`,{className:t%2?`bg-muted/40`:``,children:e.map((e,t)=>(0,$.jsx)(`td`,{className:`px-2 py-0.5 whitespace-nowrap max-w-[240px] overflow-hidden text-ellipsis`,children:Htt(e)},t))},t))})]})}),c&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`dryRun.truncated`,{shown:s.length,count:a??`?`})}),(0,$.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:n(`dryRun.previewQuery`)}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-24 overflow-auto rounded-md border bg-muted p-2 font-mono whitespace-pre-wrap break-all`,children:i})]}),(0,$.jsxs)(z9,{children:[(0,$.jsx)(U9,{type:`button`,onClick:()=>t(!1),children:n(`confirm.cancel`)}),(0,$.jsx)(H9,{type:`button`,onClick:()=>t(!0),className:u===`DELETE`?`bg-destructive text-white hover:bg-destructive/90`:``,children:a===null||l?n(`dryRun.runAnyway`):n(`dryRun.run`,{kind:u,count:a})})]})]})})}var Gtt={info:(0,$.jsx)($$e,{className:`size-5 shrink-0 text-muted-foreground`}),success:(0,$.jsx)(S6,{className:`size-5 shrink-0 text-green-500`}),error:(0,$.jsx)(H$e,{className:`size-5 shrink-0 text-destructive`})};function Ktt(){let{t:e}=S(),t=c(e=>e.message),n=c(e=>e.resolveMessage);if(!t)return null;let{title:r,description:i,tone:a=`info`}=t.request;return(0,$.jsx)(I9,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(L9,{className:`max-w-md overflow-hidden`,children:[(0,$.jsxs)(R9,{children:[(0,$.jsxs)(B9,{className:`flex min-w-0 items-center gap-2 break-words`,children:[Gtt[a],(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:r})]}),(0,$.jsx)(V9,{className:`min-w-0 break-words [overflow-wrap:anywhere] whitespace-pre-line`,children:i??``})]}),(0,$.jsx)(z9,{children:(0,$.jsx)(H9,{autoFocus:!0,onClick:()=>n(),children:e(`confirm.ok`)})})]})},t.id)}function qtt(){let e=c(e=>e.prompt),t=c(e=>e.resolvePrompt);return e?(0,$.jsx)(Jtt,{request:e.request,resolve:t},e.id):null}function Jtt({request:e,resolve:t}){let{t:n}=S(),[r,i]=(0,D.useState)(e.defaultValue??``),a=r.trim().length>0;return(0,$.jsx)(I9,{open:!0,onOpenChange:e=>{e||t(null)},children:(0,$.jsx)(L9,{className:`max-w-md overflow-hidden`,children:(0,$.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),a&&t(r.trim())},children:[(0,$.jsxs)(R9,{children:[(0,$.jsx)(B9,{className:`min-w-0 break-words`,children:e.title}),(0,$.jsx)(V9,{className:`min-w-0 break-words [overflow-wrap:anywhere] whitespace-pre-line`,children:e.description??``})]}),(0,$.jsx)(W9,{autoFocus:!0,autoComplete:`off`,spellCheck:!1,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value),onFocus:e=>e.target.select()}),(0,$.jsxs)(z9,{children:[(0,$.jsx)(U9,{type:`button`,onClick:()=>t(null),children:n(`confirm.cancel`)}),(0,$.jsx)(H9,{type:`submit`,disabled:!a,onClick:()=>{a&&t(r.trim())},children:e.confirmLabel??n(`confirm.confirm`)})]})]})})})}function Ytt(e){let t=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!t)return!0;let n=parseInt(t[1],16);return(.2126*(n>>16&255)+.7152*(n>>8&255)+.0722*(n&255))/255<.5}function Xtt(){let e=z8(e=>e.themeId);(0,D.useEffect)(()=>{let t=a2e(e),n=document.documentElement,r=t.colors;n.style.setProperty(`--t-background`,r.background),n.style.setProperty(`--t-foreground`,r.foreground),n.style.setProperty(`--t-card`,r.card),n.style.setProperty(`--t-card-foreground`,r.cardForeground),n.style.setProperty(`--t-popover`,r.popover),n.style.setProperty(`--t-popover-foreground`,r.popoverForeground),n.style.setProperty(`--t-primary`,r.primary),n.style.setProperty(`--t-primary-foreground`,r.primaryForeground),n.style.setProperty(`--t-secondary`,r.secondary),n.style.setProperty(`--t-secondary-foreground`,r.secondaryForeground),n.style.setProperty(`--t-muted`,r.muted),n.style.setProperty(`--t-muted-foreground`,r.mutedForeground),n.style.setProperty(`--t-accent`,r.accent),n.style.setProperty(`--t-accent-foreground`,r.accentForeground),n.style.setProperty(`--t-destructive`,r.destructive),n.style.setProperty(`--t-destructive-foreground`,r.destructiveForeground),n.style.setProperty(`--t-border`,r.border),n.style.setProperty(`--t-input`,r.input),n.style.setProperty(`--t-ring`,r.ring),n.style.setProperty(`--t-sidebar-background`,r.mantle),n.style.setProperty(`--t-sidebar-foreground`,r.foreground),n.style.setProperty(`--t-sidebar-primary`,r.primary),n.style.setProperty(`--t-sidebar-primary-foreground`,r.primaryForeground),n.style.setProperty(`--t-sidebar-accent`,r.surface0),n.style.setProperty(`--t-sidebar-accent-foreground`,r.foreground),n.style.setProperty(`--t-sidebar-border`,r.surface1),n.style.setProperty(`--t-sidebar-ring`,r.ring),n.style.setProperty(`--t-red`,r.red),n.style.setProperty(`--t-peach`,r.peach),n.style.setProperty(`--t-yellow`,r.yellow),n.style.setProperty(`--t-green`,r.green),n.style.setProperty(`--t-teal`,r.teal),n.style.setProperty(`--t-blue`,r.blue),n.style.setProperty(`--t-lavender`,r.lavender),n.style.setProperty(`--t-mauve`,r.mauve),n.style.setProperty(`--t-sky`,r.sky),n.style.setProperty(`--t-overlay0`,r.overlay0),n.style.setProperty(`--t-overlay1`,r.overlay1),n.style.setProperty(`--t-surface0`,r.surface0),n.style.setProperty(`--t-surface1`,r.surface1),n.style.setProperty(`--t-surface2`,r.surface2),n.style.setProperty(`--t-mantle`,r.mantle),n.style.setProperty(`--t-crust`,r.crust);let i=document.getElementById(`planche-scrollbar-style`)??document.createElement(`style`);i.id=`planche-scrollbar-style`,i.textContent=`
944
944
  ::-webkit-scrollbar-track { background: ${r.scrollTrack}; }
945
945
  ::-webkit-scrollbar-thumb { background: ${r.scrollThumb}; border-radius: 4px; }