react-kd-grid 5.0.4 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/Badge.d.ts +14 -0
- package/dist/components/ui/Dropdown.d.ts +21 -0
- package/dist/components/ui/Modal.d.ts +17 -0
- package/dist/components/ui/Tooltip.d.ts +14 -0
- package/dist/grid/components/Shared/PaginationControls.d.ts +1 -1
- package/dist/grid/hooks/useGridServerData.d.ts +89 -0
- package/dist/grid/hooks/usePagination.d.ts +2 -1
- package/dist/grid/theme/KDGridProvider.d.ts +17 -0
- package/dist/grid/theme/defaultTheme.d.ts +6 -0
- package/dist/grid/theme/types.d.ts +28 -0
- package/dist/grid/theme/utils.d.ts +8 -0
- package/dist/grid/types.d.ts +5 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import t,{useState as r,useCallback as n,useRef as o,useEffect as l,useLayoutEffect as a,memo as s,useMemo as i,useTransition as c,useDeferredValue as d,forwardRef as u,useImperativeHandle as g}from"react";import*as h from"react-dom";import{createPortal as m}from"react-dom";var x,f={exports:{}},p={};function y(){if(x)return p;x=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(t,r,n){var o=null;if(void 0!==n&&(o=""+n),void 0!==r.key&&(o=""+r.key),"key"in r)for(var l in n={},r)"key"!==l&&(n[l]=r[l]);else n=r;return{$$typeof:e,type:t,key:o,ref:void 0!==(r=n.ref)?r:null,props:n}}return p.Fragment=t,p.jsx=r,p.jsxs=r,p}var b,v,w={};function k(){return b||(b=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===S?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case m:return"Fragment";case f:return"Profiler";case x:return"StrictMode";case v:return"Suspense";case k:return"SuspenseList";case N:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case h:return"Portal";case y:return t.displayName||"Context";case p:return(t._context.displayName||"Context")+".Consumer";case b:var r=t.render;return(t=t.displayName)||(t=""!==(t=r.displayName||r.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case j:return null!==(r=t.displayName||null)?r:e(t.type)||"Memo";case C:r=t._payload,t=t._init;try{return e(t(r))}catch(e){}}return null}function r(e){return""+e}function n(e){try{r(e);var t=!1}catch(e){t=!0}if(t){t=console;var n="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.error.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),r(e)}}function o(t){if(t===m)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===C)return"<...>";try{var r=e(t);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function l(){return Error("react-stack-top-frame")}function a(){var t=e(this.type);return A[t]||(A[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,r,o,l,s,c){var u,h=r.children;if(void 0!==h)if(l)if(D(h)){for(l=0;l<h.length;l++)i(h[l]);Object.freeze&&Object.freeze(h)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else i(h);if(M.call(r,"key")){h=e(t);var m=Object.keys(r).filter(function(e){return"key"!==e});l=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",z[h+l]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,h,m,h),z[h+l]=!0)}if(h=null,void 0!==o&&(n(o),h=""+o),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),h=""+r.key),"key"in r)for(var x in o={},r)"key"!==x&&(o[x]=r[x]);else o=r;return h&&function(e,t){function r(){d||(d=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(o,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,r,n,o,l){var s=r.ref;return e={$$typeof:g,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==s?s:null)?{enumerable:!1,get:a}:{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,h,o,null===(u=R.A)?null:u.getOwner(),s,c)}function i(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===C&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===g}var d,u=t,g=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),y=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,D=Array.isArray,E=console.createTask?console.createTask:function(){return null},A={},F=(u={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(u,l)(),L=E(o(l)),z={};w.Fragment=m,w.jsx=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!1,n?Error("react-stack-top-frame"):F,n?E(o(e)):L)},w.jsxs=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!0,n?Error("react-stack-top-frame"):F,n?E(o(e)):L)}}()),w}function j(){return v||(v=1,f.exports="production"===process.env.NODE_ENV?y():k()),f.exports}var C=j();const N=({size:e=16,children:t,...r})=>C.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:t}),S=e=>C.jsx(N,{...e,children:C.jsx("polyline",{points:"15 18 9 12 15 6"})}),R=e=>C.jsx(N,{...e,children:C.jsx("polyline",{points:"9 18 15 12 9 6"})}),M=e=>C.jsx(N,{...e,children:C.jsx("polyline",{points:"6 9 12 15 18 9"})}),D=e=>C.jsxs(N,{...e,children:[C.jsx("polyline",{points:"11 17 6 12 11 7"}),C.jsx("polyline",{points:"18 17 13 12 18 7"})]}),E=e=>C.jsxs(N,{...e,children:[C.jsx("polyline",{points:"13 17 18 12 13 7"}),C.jsx("polyline",{points:"6 17 11 12 6 7"})]}),A=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),C.jsx("polyline",{points:"5 12 12 5 19 12"})]}),F=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),C.jsx("polyline",{points:"19 12 12 19 5 12"})]}),L=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"m21 16-4 4-4-4"}),C.jsx("path",{d:"M17 20V4"}),C.jsx("path",{d:"m3 8 4-4 4 4"}),C.jsx("path",{d:"M7 4v16"})]}),z=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),C.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),I=e=>C.jsx(N,{...e,children:C.jsx("polyline",{points:"20 6 9 17 4 12"})}),T=e=>C.jsxs(N,{...e,children:[C.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),C.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),O=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),C.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),$=e=>C.jsxs(N,{...e,children:[C.jsx("polyline",{points:"3 6 5 6 21 6"}),C.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),C.jsx("path",{d:"M10 11v6"}),C.jsx("path",{d:"M14 11v6"}),C.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),P=e=>C.jsxs(N,{...e,children:[C.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),C.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),C.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),K=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),C.jsx("polyline",{points:"7 10 12 15 17 10"}),C.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),W=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),C.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),C.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),V=e=>C.jsx(N,{...e,children:C.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),_=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),C.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),B=e=>C.jsxs(N,{...e,children:[C.jsx("circle",{cx:"12",cy:"12",r:"3"}),C.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),G=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),C.jsx("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]}),H=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),C.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),C.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),C.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),U=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),C.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),C.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),C.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),C.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),Y=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),C.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),C.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),C.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),C.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),C.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),q=e=>C.jsxs(N,{...e,children:[C.jsx("circle",{cx:"12",cy:"12",r:"1"}),C.jsx("circle",{cx:"19",cy:"12",r:"1"}),C.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),X=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),C.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),J=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),C.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),C.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),Z=e=>C.jsxs(N,{...e,children:[C.jsx("circle",{cx:"11",cy:"11",r:"8"}),C.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),Q=e=>C.jsxs(N,{...e,children:[C.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),C.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),C.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),ee=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),C.jsx("polyline",{points:"14 2 14 8 20 8"}),C.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),C.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),C.jsx("polyline",{points:"10 9 9 9 8 9"})]}),te=e=>C.jsxs(N,{...e,children:[C.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),C.jsx("path",{d:"M3 9h18"}),C.jsx("path",{d:"M3 15h18"}),C.jsx("path",{d:"M9 3v18"})]}),re=e=>C.jsxs(N,{...e,children:[C.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),C.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),C.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]}),ne=e=>C.jsxs(N,{...e,children:[C.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),C.jsx("circle",{cx:"9",cy:"7",r:"4"}),C.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),C.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),oe=e=>C.jsxs(N,{...e,children:[C.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),C.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),C.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),C.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),C.jsx("circle",{cx:"12",cy:"12",r:"4"}),C.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),le=e=>C.jsx(N,{...e,children:C.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ae=({size:e=16,className:t,style:r,...n})=>C.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",className:t,style:r,...n,children:[C.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),C.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]});function se(){return"undefined"!=typeof window}function ie(e){return ue(e)?(e.nodeName||"").toLowerCase():"#document"}function ce(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function de(e){var t;return null==(t=(ue(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ue(e){return!!se()&&(e instanceof Node||e instanceof ce(e).Node)}function ge(e){return!!se()&&(e instanceof Element||e instanceof ce(e).Element)}function he(e){return!!se()&&(e instanceof HTMLElement||e instanceof ce(e).HTMLElement)}function me(e){return!(!se()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof ce(e).ShadowRoot)}const xe=new Set(["inline","contents"]);function fe(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Me(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!xe.has(o)}const pe=new Set(["table","td","th"]);function ye(e){return pe.has(ie(e))}const be=[":popover-open",":modal"];function ve(e){return be.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const we=["transform","translate","scale","rotate","perspective"],ke=["transform","translate","scale","rotate","perspective","filter"],je=["paint","layout","strict","content"];function Ce(e){const t=Ne(),r=ge(e)?Me(e):e;return we.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||ke.some(e=>(r.willChange||"").includes(e))||je.some(e=>(r.contain||"").includes(e))}function Ne(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Se=new Set(["html","body","#document"]);function Re(e){return Se.has(ie(e))}function Me(e){return ce(e).getComputedStyle(e)}function De(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ee(e){if("html"===ie(e))return e;const t=e.assignedSlot||e.parentNode||me(e)&&e.host||de(e);return me(t)?t.host:t}function Ae(e){const t=Ee(e);return Re(t)?e.ownerDocument?e.ownerDocument.body:e.body:he(t)&&fe(t)?t:Ae(t)}function Fe(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const o=Ae(e),l=o===(null==(n=e.ownerDocument)?void 0:n.body),a=ce(o);if(l){const e=Le(a);return t.concat(a,a.visualViewport||[],fe(o)?o:[],e&&r?Fe(e):[])}return t.concat(o,Fe(o,[],r))}function Le(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const ze=Math.min,Ie=Math.max,Te=Math.round,Oe=Math.floor,$e=e=>({x:e,y:e}),Pe={left:"right",right:"left",bottom:"top",top:"bottom"},Ke={start:"end",end:"start"};function We(e,t,r){return Ie(e,ze(t,r))}function Ve(e,t){return"function"==typeof e?e(t):e}function _e(e){return e.split("-")[0]}function Be(e){return e.split("-")[1]}function Ge(e){return"x"===e?"y":"x"}function He(e){return"y"===e?"height":"width"}const Ue=new Set(["top","bottom"]);function Ye(e){return Ue.has(_e(e))?"y":"x"}function qe(e){return Ge(Ye(e))}function Xe(e){return e.replace(/start|end/g,e=>Ke[e])}const Je=["left","right"],Ze=["right","left"],Qe=["top","bottom"],et=["bottom","top"];function tt(e){return e.replace(/left|right|bottom|top/g,e=>Pe[e])}function rt(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}var nt="undefined"!=typeof document?a:function(){};const ot={...e}.useInsertionEffect||(e=>e());function lt(e,t,r){let{reference:n,floating:o}=e;const l=Ye(t),a=qe(t),s=He(a),i=_e(t),c="y"===l,d=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,g=n[s]/2-o[s]/2;let h;switch(i){case"top":h={x:d,y:n.y-o.height};break;case"bottom":h={x:d,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:u};break;case"left":h={x:n.x-o.width,y:u};break;default:h={x:n.x,y:n.y}}switch(Be(t)){case"start":h[a]-=g*(r&&c?-1:1);break;case"end":h[a]+=g*(r&&c?-1:1)}return h}async function at(e,t){var r;void 0===t&&(t={});const{x:n,y:o,platform:l,rects:a,elements:s,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:g=!1,padding:h=0}=Ve(t,e),m=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(h),x=s[g?"floating"===u?"reference":"floating":u],f=rt(await l.getClippingRect({element:null==(r=await(null==l.isElement?void 0:l.isElement(x)))||r?x:x.contextElement||await(null==l.getDocumentElement?void 0:l.getDocumentElement(s.floating)),boundary:c,rootBoundary:d,strategy:i})),p="floating"===u?{x:n,y:o,width:a.floating.width,height:a.floating.height}:a.reference,y=await(null==l.getOffsetParent?void 0:l.getOffsetParent(s.floating)),b=await(null==l.isElement?void 0:l.isElement(y))&&await(null==l.getScale?void 0:l.getScale(y))||{x:1,y:1},v=rt(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:p,offsetParent:y,strategy:i}):p);return{top:(f.top-v.top+m.top)/b.y,bottom:(v.bottom-f.bottom+m.bottom)/b.y,left:(f.left-v.left+m.left)/b.x,right:(v.right-f.right+m.right)/b.x}}const st=new Set(["left","top"]);function it(e){const t=Me(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=he(e),l=o?e.offsetWidth:r,a=o?e.offsetHeight:n,s=Te(r)!==l||Te(n)!==a;return s&&(r=l,n=a),{width:r,height:n,$:s}}function ct(e){return ge(e)?e:e.contextElement}function dt(e){const t=ct(e);if(!he(t))return $e(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:l}=it(t);let a=(l?Te(r.width):r.width)/n,s=(l?Te(r.height):r.height)/o;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const ut=$e(0);function gt(e){const t=ce(e);return Ne()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ut}function ht(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const o=e.getBoundingClientRect(),l=ct(e);let a=$e(1);t&&(n?ge(n)&&(a=dt(n)):a=dt(e));const s=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==ce(e))&&t}(l,r,n)?gt(l):$e(0);let i=(o.left+s.x)/a.x,c=(o.top+s.y)/a.y,d=o.width/a.x,u=o.height/a.y;if(l){const e=ce(l),t=n&&ge(n)?ce(n):n;let r=e,o=Le(r);for(;o&&n&&t!==r;){const e=dt(o),t=o.getBoundingClientRect(),n=Me(o),l=t.left+(o.clientLeft+parseFloat(n.paddingLeft))*e.x,a=t.top+(o.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,c*=e.y,d*=e.x,u*=e.y,i+=l,c+=a,r=ce(o),o=Le(r)}}return rt({width:d,height:u,x:i,y:c})}function mt(e,t){const r=De(e).scrollLeft;return t?t.left+r:ht(de(e)).left+r}function xt(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-mt(e,r),y:r.top+t.scrollTop}}const ft=new Set(["absolute","fixed"]);function pt(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=ce(e),n=de(e),o=r.visualViewport;let l=n.clientWidth,a=n.clientHeight,s=0,i=0;if(o){l=o.width,a=o.height;const e=Ne();(!e||e&&"fixed"===t)&&(s=o.offsetLeft,i=o.offsetTop)}const c=mt(n);if(c<=0){const e=n.ownerDocument,t=e.body,r=getComputedStyle(t),o="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,a=Math.abs(n.clientWidth-t.clientWidth-o);a<=25&&(l-=a)}else c<=25&&(l+=c);return{width:l,height:a,x:s,y:i}}(e,r);else if("document"===t)n=function(e){const t=de(e),r=De(e),n=e.ownerDocument.body,o=Ie(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=Ie(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let a=-r.scrollLeft+mt(e);const s=-r.scrollTop;return"rtl"===Me(n).direction&&(a+=Ie(t.clientWidth,n.clientWidth)-o),{width:o,height:l,x:a,y:s}}(de(e));else if(ge(t))n=function(e,t){const r=ht(e,!0,"fixed"===t),n=r.top+e.clientTop,o=r.left+e.clientLeft,l=he(e)?dt(e):$e(1);return{width:e.clientWidth*l.x,height:e.clientHeight*l.y,x:o*l.x,y:n*l.y}}(t,r);else{const r=gt(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return rt(n)}function yt(e,t){const r=Ee(e);return!(r===t||!ge(r)||Re(r))&&("fixed"===Me(r).position||yt(r,t))}function bt(e,t,r){const n=he(t),o=de(t),l="fixed"===r,a=ht(e,!0,l,t);let s={scrollLeft:0,scrollTop:0};const i=$e(0);function c(){i.x=mt(o)}if(n||!n&&!l)if(("body"!==ie(t)||fe(o))&&(s=De(t)),n){const e=ht(t,!0,l,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else o&&c();l&&!n&&o&&c();const d=!o||n||l?$e(0):xt(o,s);return{x:a.left+s.scrollLeft-i.x-d.x,y:a.top+s.scrollTop-i.y-d.y,width:a.width,height:a.height}}function vt(e){return"static"===Me(e).position}function wt(e,t){if(!he(e)||"fixed"===Me(e).position)return null;if(t)return t(e);let r=e.offsetParent;return de(e)===r&&(r=r.ownerDocument.body),r}function kt(e,t){const r=ce(e);if(ve(e))return r;if(!he(e)){let t=Ee(e);for(;t&&!Re(t);){if(ge(t)&&!vt(t))return t;t=Ee(t)}return r}let n=wt(e,t);for(;n&&ye(n)&&vt(n);)n=wt(n,t);return n&&Re(n)&&vt(n)&&!Ce(n)?r:n||function(e){let t=Ee(e);for(;he(t)&&!Re(t);){if(Ce(t))return t;if(ve(t))return null;t=Ee(t)}return null}(e)||r}const jt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const l="fixed"===o,a=de(n),s=!!t&&ve(t.floating);if(n===a||s&&l)return r;let i={scrollLeft:0,scrollTop:0},c=$e(1);const d=$e(0),u=he(n);if((u||!u&&!l)&&(("body"!==ie(n)||fe(a))&&(i=De(n)),he(n))){const e=ht(n);c=dt(n),d.x=e.x+n.clientLeft,d.y=e.y+n.clientTop}const g=!a||u||l?$e(0):xt(a,i);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-i.scrollLeft*c.x+d.x+g.x,y:r.y*c.y-i.scrollTop*c.y+d.y+g.y}},getDocumentElement:de,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const l=[..."clippingAncestors"===r?ve(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=Fe(e,[],!1).filter(e=>ge(e)&&"body"!==ie(e)),o=null;const l="fixed"===Me(e).position;let a=l?Ee(e):e;for(;ge(a)&&!Re(a);){const t=Me(a),r=Ce(a);r||"fixed"!==t.position||(o=null),(l?!r&&!o:!r&&"static"===t.position&&o&&ft.has(o.position)||fe(a)&&!r&&yt(e,a))?n=n.filter(e=>e!==a):o=t,a=Ee(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=l.reduce((e,r)=>{const n=pt(t,r,o);return e.top=Ie(n.top,e.top),e.right=ze(n.right,e.right),e.bottom=ze(n.bottom,e.bottom),e.left=Ie(n.left,e.left),e},pt(t,l[0],o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:kt,getElementRects:async function(e){const t=this.getOffsetParent||kt,r=this.getDimensions,n=await r(e.floating);return{reference:bt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:r}=it(e);return{width:t,height:r}},getScale:dt,isElement:ge,isRTL:function(e){return"rtl"===Me(e).direction}};function Ct(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nt(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,c=ct(e),d=o||l?[...c?Fe(c):[],...Fe(t)]:[];d.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),l&&e.addEventListener("resize",r)});const u=c&&s?function(e,t){let r,n=null;const o=de(e);function l(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function a(s,i){void 0===s&&(s=!1),void 0===i&&(i=1),l();const c=e.getBoundingClientRect(),{left:d,top:u,width:g,height:h}=c;if(s||t(),!g||!h)return;const m={rootMargin:-Oe(u)+"px "+-Oe(o.clientWidth-(d+g))+"px "+-Oe(o.clientHeight-(u+h))+"px "+-Oe(d)+"px",threshold:Ie(0,ze(1,i))||1};let x=!0;function f(t){const n=t[0].intersectionRatio;if(n!==i){if(!x)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||Ct(c,e.getBoundingClientRect())||a(),x=!1}try{n=new IntersectionObserver(f,{...m,root:o.ownerDocument})}catch(e){n=new IntersectionObserver(f,m)}n.observe(e)}(!0),l}(c,r):null;let g,h=-1,m=null;a&&(m=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),r()}),c&&!i&&m.observe(c),m.observe(t));let x=i?ht(e):null;return i&&function t(){const n=ht(e);x&&!Ct(x,n)&&r(),x=n,g=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{o&&e.removeEventListener("scroll",r),l&&e.removeEventListener("resize",r)}),null==u||u(),null==(e=m)||e.disconnect(),m=null,i&&cancelAnimationFrame(g)}}const St=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:l,placement:a,middlewareData:s}=t,i=await async function(e,t){const{placement:r,platform:n,elements:o}=e,l=await(null==n.isRTL?void 0:n.isRTL(o.floating)),a=_e(r),s=Be(r),i="y"===Ye(r),c=st.has(a)?-1:1,d=l&&i?-1:1,u=Ve(t,e);let{mainAxis:g,crossAxis:h,alignmentAxis:m}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&"number"==typeof m&&(h="end"===s?-1*m:m),i?{x:h*d,y:g*c}:{x:g*c,y:h*d}}(t,e);return a===(null==(r=s.offset)?void 0:r.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:o+i.x,y:l+i.y,data:{...i,placement:a}}}}},Rt=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:l}=t,{mainAxis:a=!0,crossAxis:s=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...c}=Ve(e,t),d={x:r,y:n},u=await l.detectOverflow(t,c),g=Ye(_e(o)),h=Ge(g);let m=d[h],x=d[g];a&&(m=We(m+u["y"===h?"top":"left"],m,m-u["y"===h?"bottom":"right"])),s&&(x=We(x+u["y"===g?"top":"left"],x,x-u["y"===g?"bottom":"right"]));const f=i.fn({...t,[h]:m,[g]:x});return{...f,data:{x:f.x-r,y:f.y-n,enabled:{[h]:a,[g]:s}}}}}},Mt=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:l,rects:a,initialPlacement:s,platform:i,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...f}=Ve(e,t);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};const p=_e(o),y=Ye(s),b=_e(s)===s,v=await(null==i.isRTL?void 0:i.isRTL(c.floating)),w=g||(b||!x?[tt(s)]:function(e){const t=tt(e);return[Xe(e),t,Xe(t)]}(s)),k="none"!==m;!g&&k&&w.push(...function(e,t,r,n){const o=Be(e);let l=function(e,t,r){switch(e){case"top":case"bottom":return r?t?Ze:Je:t?Je:Ze;case"left":case"right":return t?Qe:et;default:return[]}}(_e(e),"start"===r,n);return o&&(l=l.map(e=>e+"-"+o),t&&(l=l.concat(l.map(Xe)))),l}(s,x,m,v));const j=[s,...w],C=await i.detectOverflow(t,f),N=[];let S=(null==(n=l.flip)?void 0:n.overflows)||[];if(d&&N.push(C[p]),u){const e=function(e,t,r){void 0===r&&(r=!1);const n=Be(e),o=qe(e),l=He(o);let a="x"===o?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[l]>t.floating[l]&&(a=tt(a)),[a,tt(a)]}(o,a,v);N.push(C[e[0]],C[e[1]])}if(S=[...S,{placement:o,overflows:N}],!N.every(e=>e<=0)){var R,M;const e=((null==(R=l.flip)?void 0:R.index)||0)+1,t=j[e];if(t&&("alignment"!==u||y===Ye(t)||S.every(e=>Ye(e.placement)!==y||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(M=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:M.placement;if(!r)switch(h){case"bestFit":{var D;const e=null==(D=S.filter(e=>{if(k){const t=Ye(e.placement);return t===y||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:D[0];e&&(r=e);break}case"initialPlacement":r=s}if(o!==r)return{reset:{placement:r}}}return{}}}},Dt=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:l,platform:a,elements:s}=t,{apply:i=()=>{},...c}=Ve(e,t),d=await a.detectOverflow(t,c),u=_e(o),g=Be(o),h="y"===Ye(o),{width:m,height:x}=l.floating;let f,p;"top"===u||"bottom"===u?(f=u,p=g===(await(null==a.isRTL?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(p=u,f="end"===g?"top":"bottom");const y=x-d.top-d.bottom,b=m-d.left-d.right;let v=ze(x-d[f],y),w=ze(m-d[p],b);if(null!=(r=t.middlewareData.shift)&&r.enabled.x&&(w=b),null!=(n=t.middlewareData.shift)&&n.enabled.y&&(v=y),!t.middlewareData.shift&&!g){const e=Ie(d.left,0),t=Ie(d.right,0),r=Ie(d.top,0),n=Ie(d.bottom,0);h?w=m-2*(0!==e||0!==t?e+t:Ie(d.left,d.right)):v=x-2*(0!==r||0!==n?r+n:Ie(d.top,d.bottom))}await i({...t,availableWidth:w,availableHeight:v});const k=await a.getDimensions(s.floating);return m!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}},Et=(e,t,r)=>{const n=new Map,o={platform:jt,...r},l={...o.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:l=[],platform:a}=r,s=l.filter(Boolean),i=await(null==a.isRTL?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:u}=lt(c,n,i),g=n,h={},m=0;for(let r=0;r<s.length;r++){var x;const{name:l,fn:f}=s[r],{x:p,y:y,data:b,reset:v}=await f({x:d,y:u,initialPlacement:n,placement:g,strategy:o,middlewareData:h,rects:c,platform:{...a,detectOverflow:null!=(x=a.detectOverflow)?x:at},elements:{reference:e,floating:t}});d=null!=p?p:d,u=null!=y?y:u,h={...h,[l]:{...h[l],...b}},v&&m<=50&&(m++,"object"==typeof v&&(v.placement&&(g=v.placement),v.rects&&(c=!0===v.rects?await a.getElementRects({reference:e,floating:t,strategy:o}):v.rects),({x:d,y:u}=lt(c,g,i))),r=-1)}return{x:d,y:u,placement:g,strategy:o,middlewareData:h}})(e,t,{...o,platform:l})};var At="undefined"!=typeof document?a:function(){};function Ft(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;0!==n--;)if(!Ft(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;0!==n--;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;0!==n--;){const r=o[n];if(!("_owner"===r&&e.$$typeof||Ft(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function Lt(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zt(e,t){const r=Lt(e);return Math.round(t*r)/r}function It(t){const r=e.useRef(t);return At(()=>{r.current=t}),r}const Tt=(e,t)=>({...St(e),options:[e,t]}),Ot=(e,t)=>({...Rt(e),options:[e,t]}),$t=(e,t)=>({...Dt(e),options:[e,t]}),Pt={...e};let Kt=!1,Wt=0;const Vt=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Wt++,_t=Pt.useId||function(){const[t,r]=e.useState(()=>Kt?Vt():void 0);return nt(()=>{null==t&&r(Vt())},[]),e.useEffect(()=>{Kt=!0},[]),t};let Bt;"production"!==process.env.NODE_ENV&&(Bt=new Set);const Gt=e.createContext(null),Ht=e.createContext(null);function Ut(t){void 0===t&&(t={});const{nodeId:r}=t,n=function(t){const{open:r=!1,onOpenChange:n,elements:o}=t,l=_t(),a=e.useRef({}),[s]=e.useState(()=>function(){const e=new Map;return{emit(t,r){var n;null==(n=e.get(t))||n.forEach(e=>e(r))},on(t,r){e.has(t)||e.set(t,new Set),e.get(t).add(r)},off(t,r){var n;null==(n=e.get(t))||n.delete(r)}}}()),i=null!=((null==(c=e.useContext(Gt))?void 0:c.id)||null);var c;if("production"!==process.env.NODE_ENV){const e=o.reference;e&&!ge(e)&&function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];const o="Floating UI: "+r.join(" ");var l;null!=(e=Bt)&&e.has(o)||(null==(l=Bt)||l.add(o),console.error(o))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[d,u]=e.useState(o.reference),g=function(t){const r=e.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return ot(()=>{r.current=t}),e.useCallback(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return null==r.current?void 0:r.current(...t)},[])}((e,t,r)=>{a.current.openEvent=e?t:void 0,s.emit("openchange",{open:e,event:t,reason:r,nested:i}),null==n||n(e,t,r)}),h=e.useMemo(()=>({setPositionReference:u}),[]),m=e.useMemo(()=>({reference:d||o.reference||null,floating:o.floating||null,domReference:o.reference}),[d,o.reference,o.floating]);return e.useMemo(()=>({dataRef:a,open:r,onOpenChange:g,elements:m,events:s,floatingId:l,refs:h}),[r,g,m,s,l,h])}({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||n,l=o.elements,[a,s]=e.useState(null),[i,c]=e.useState(null),d=(null==l?void 0:l.domReference)||a,u=e.useRef(null),g=e.useContext(Ht);nt(()=>{d&&(u.current=d)},[d]);const m=function(t){void 0===t&&(t={});const{placement:r="bottom",strategy:n="absolute",middleware:o=[],platform:l,elements:{reference:a,floating:s}={},transform:i=!0,whileElementsMounted:c,open:d}=t,[u,g]=e.useState({x:0,y:0,strategy:n,placement:r,middlewareData:{},isPositioned:!1}),[m,x]=e.useState(o);Ft(m,o)||x(o);const[f,p]=e.useState(null),[y,b]=e.useState(null),v=e.useCallback(e=>{e!==C.current&&(C.current=e,p(e))},[]),w=e.useCallback(e=>{e!==N.current&&(N.current=e,b(e))},[]),k=a||f,j=s||y,C=e.useRef(null),N=e.useRef(null),S=e.useRef(u),R=null!=c,M=It(c),D=It(l),E=It(d),A=e.useCallback(()=>{if(!C.current||!N.current)return;const e={placement:r,strategy:n,middleware:m};D.current&&(e.platform=D.current),Et(C.current,N.current,e).then(e=>{const t={...e,isPositioned:!1!==E.current};F.current&&!Ft(S.current,t)&&(S.current=t,h.flushSync(()=>{g(t)}))})},[m,r,n,D,E]);At(()=>{!1===d&&S.current.isPositioned&&(S.current.isPositioned=!1,g(e=>({...e,isPositioned:!1})))},[d]);const F=e.useRef(!1);At(()=>(F.current=!0,()=>{F.current=!1}),[]),At(()=>{if(k&&(C.current=k),j&&(N.current=j),k&&j){if(M.current)return M.current(k,j,A);A()}},[k,j,A,M,R]);const L=e.useMemo(()=>({reference:C,floating:N,setReference:v,setFloating:w}),[v,w]),z=e.useMemo(()=>({reference:k,floating:j}),[k,j]),I=e.useMemo(()=>{const e={position:n,left:0,top:0};if(!z.floating)return e;const t=zt(z.floating,u.x),r=zt(z.floating,u.y);return i?{...e,transform:"translate("+t+"px, "+r+"px)",...Lt(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,i,z.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:A,refs:L,elements:z,floatingStyles:I}),[u,A,L,z,I])}({...t,elements:{...l,...i&&{reference:i}}}),x=e.useCallback(e=>{const t=ge(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;c(t),m.refs.setReference(t)},[m.refs]),f=e.useCallback(e=>{(ge(e)||null===e)&&(u.current=e,s(e)),(ge(m.refs.reference.current)||null===m.refs.reference.current||null!==e&&!ge(e))&&m.refs.setReference(e)},[m.refs]),p=e.useMemo(()=>({...m.refs,setReference:f,setPositionReference:x,domReference:u}),[m.refs,f,x]),y=e.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),b=e.useMemo(()=>({...m,...o,refs:p,elements:y,nodeId:r}),[m,p,y,r,o]);return nt(()=>{o.dataRef.current.floatingContext=b;const e=null==g?void 0:g.nodesRef.current.find(e=>e.id===r);e&&(e.context=b)}),e.useMemo(()=>({...m,context:b,refs:p,elements:y}),[m,p,y,b])}const Yt=({open:e,anchorEl:t,onClose:r,placement:n="bottom-start",offset:o=8,sameWidth:a=!1,maxHeight:s,zIndex:i=1e3,className:c,children:d,shouldIgnoreClose:u})=>{const{refs:g,floatingStyles:h,update:x}=Ut({placement:n,whileElementsMounted:Nt,middleware:[Tt(o),(f={padding:8},{...Mt(f),options:[f,void 0]}),Ot({padding:8}),$t({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const o=t.floating;o&&(a&&(o.style.width=`${e.reference.width}px`),o.style.maxHeight=null!=s?"number"==typeof s?`${s}px`:String(s):`${r}px`,null!=n&&(o.style.maxWidth=`${n}px`))}})]});var f;return l(()=>{t&&g.setReference(t),e&&x&&x()},[t,e,g,x]),l(()=>{if(!e)return;const n=e=>{const n=e.target;if(u&&u(n))return;const o=g.floating.current;o&&(t&&t.contains(n)||o&&o.contains(n)||r())},o=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",o)}},[e,r,g.floating,t]),e&&t?m(C.jsx("div",{ref:g.setFloating,"data-popover-root":"true",style:{...h,zIndex:i,position:h.position,overflowX:"hidden"},className:c,children:d}),document.body):null},qt=e=>{switch(e){case"csv":return C.jsx(te,{size:18});case"json":return C.jsx(Q,{size:18});case"xlsx":return C.jsx(ee,{size:18});default:return C.jsx(K,{size:18})}},Xt=e=>{switch(e){case"delete":return C.jsx($,{size:18});case"archive":return C.jsx(P,{size:18});case"copy":return C.jsx(T,{size:18});case"edit":return C.jsx(O,{size:18});case"export":return C.jsx(K,{size:18});default:return C.jsx(q,{size:18})}},Jt=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},Zt=["sm","md","lg"],Qt=({isOpen:e,anchorEl:t,onClose:r,bulkActions:n,selectedRowsCount:o,onBulkAction:l})=>C.jsxs(Yt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[C.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[C.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Bulk Actions"}),C.jsxs("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:[o," row",1!==o?"s":""," selected"]})]}),C.jsx("div",{className:"p-2",children:n.map(e=>C.jsxs("button",{onClick:()=>l(e),disabled:e.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm rounded-md transition-colors "+(e.disabled?"text-gray-400 dark:text-gray-500 cursor-not-allowed":e.destructive?"text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"),children:[e.icon??Xt(e.id),e.label]},e.id))})]}),er=({isOpen:e,anchorEl:t,onClose:r,filteredColumns:n,columnVisibility:o,onColumnToggle:l,columnSearch:a,onColumnSearchChange:s,onResetColumns:i,onScrollToColumn:c,onColumnVisibilityChange:d,draggingKey:u,dragOver:g,handleDragStart:h,handleDragOver:m,handleDrop:x,handleDragEnd:f})=>C.jsxs(Yt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-72 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[C.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[C.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Show/Hide Columns"}),C.jsxs("div",{className:"relative mt-2",children:[C.jsx(Z,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),C.jsx("input",{type:"text",placeholder:"Search columns...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300",value:a,onChange:e=>s(e.target.value)})]})]}),C.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:n.map(e=>{const t=!1!==o[e.key];return C.jsxs("label",{className:`flex items-center gap-3 p-2 hover:bg-gray-50 rounded-md cursor-grab relative ${u===e.key?"opacity-60":""} dark:hover:bg-gray-800`,draggable:!0,onDragStart:t=>h(e.key,t),onDragOver:t=>m(e.key,t),onDrop:()=>x(e.key),onDragEnd:f,children:[g?.key===e.key&&C.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-blue-600",style:{top:"before"===g.position?0:void 0,bottom:"after"===g.position?0:void 0}}),C.jsx("input",{type:"checkbox",checked:t,onChange:()=>l(e.key),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),t?C.jsx(X,{className:"w-4 h-4 text-green-600"}):C.jsx(J,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),C.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:e.header}),C.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?c?.(e.key):(d?.(e.key,!0),requestAnimationFrame(()=>c?.(e.key)))},className:"ml-auto p-1 text-gray-400 hover:text-blue-600 dark:text-gray-500 transition-colors",title:"Scroll to this column",children:C.jsx(oe,{className:"w-4 h-4"})})]},e.key)})}),C.jsx("div",{className:"p-2 border-t border-gray-100 dark:border-gray-700",children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 cursor-pointer hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",children:[C.jsx("input",{type:"checkbox",checked:n.length>0&&n.every(e=>!1!==o[e.key]),onChange:e=>{n.forEach(t=>{d?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400"}),C.jsx("span",{children:"Select All"})]}),C.jsx("button",{className:"text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-50 px-3 py-1.5 rounded transition-colors min-h-9 dark:text-gray-400 dark:hover:text-gray-100 dark:hover:bg-gray-800",onClick:i,children:"Reset All"})]})})]}),tr=({isOpen:e,anchorEl:t,onClose:r,exportFormats:n,filteredDataLength:o,selectedRowsCount:l,onExport:a})=>{const s=l>0;return C.jsxs(Yt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-64 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[C.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[C.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Export Data"}),C.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Choose format and data scope"})]}),C.jsxs("div",{className:"p-2",children:[C.jsxs("div",{className:"mb-3",children:[C.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export All Data"}),C.jsx("div",{className:"space-y-1",children:n.map(e=>C.jsxs("button",{onClick:()=>a(e,!1),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md transition-colors cursor-pointer",children:[qt(e),C.jsxs("span",{children:["Export as ",Jt(e)]}),C.jsxs("span",{className:"ml-auto text-xs text-gray-500 dark:text-gray-400",children:[o.toLocaleString()," rows"]})]},`all-${e}`))})]}),s&&C.jsxs("div",{children:[C.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2 px-2 dark:text-gray-300",children:"Export Selected"}),C.jsx("div",{className:"space-y-1",children:n.map(e=>C.jsxs("button",{onClick:()=>a(e,!0),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-blue-700 hover:bg-blue-50 rounded-md transition-colors dark:text-blue-400 dark:hover:bg-blue-900/20",children:[qt(e),C.jsxs("span",{children:["Export as ",Jt(e)]}),C.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[l," rows"]})]},`selected-${e}`))})]})]})]})},rr=({options:e,value:t,placeholder:n="Select an option...",onChange:a,searchable:s=!0,className:i=""})=>{const[c,d]=r(!1),[u,g]=r(""),[h,m]=r(-1),x=o(null),f=o(null),p=o(null),y=e.find(e=>e.value===t),b=s?e.filter(e=>e.label?.toLowerCase()?.includes(u?.toLowerCase())):e;l(()=>{const e=e=>{x.current&&!x.current.contains(e.target)&&(d(!1),g(""),m(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l(()=>{const e=e=>{if(c)switch(e.key){case"ArrowDown":e.preventDefault(),m(e=>e<b.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),m(e=>e>0?e-1:b.length-1);break;case"Enter":e.preventDefault(),h>=0&&b[h]&&v(b[h].value);break;case"Escape":d(!1),g(""),m(-1)}};if(c)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[c,h,b]),l(()=>{if(h>=0&&p.current){const e=p.current.children[h];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[h]);const v=e=>{a(e),d(!1),g(""),m(-1)};return C.jsxs("div",{className:`relative ${i}`,ref:x,children:[C.jsx("div",{className:`relative w-full cursor-pointer border border-gray-300 rounded-lg bg-white transition-all duration-200 ${c?"ring-2 ring-blue-500 border-blue-500":"hover:border-gray-400 focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500"} dark:border-gray-600 dark:bg-gray-800`,onClick:()=>{d(!c),s&&!c&&setTimeout(()=>f.current?.focus(),0)},children:C.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[s&&c?C.jsx("input",{ref:f,type:"text",className:"flex-1 outline-none text-sm bg-transparent text-gray-900 dark:text-gray-100",placeholder:`Search ${n?.toLowerCase()}...`,value:u,onChange:e=>{g(e.target.value),m(-1),c||d(!0)},onClick:e=>e.stopPropagation()}):C.jsx("span",{className:"flex-1 text-sm truncate "+(y?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"),children:y?y.label:n}),C.jsx(M,{className:`w-4 h-4 text-gray-400 transition-transform duration-200 ${c?"rotate-180":""} dark:text-gray-400`})]})}),c&&C.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-99999 max-h-80 overflow-hidden dark:bg-gray-800 dark:border-gray-700",children:b.length>0?C.jsx("ul",{ref:p,className:"py-1 overflow-y-auto max-h-80",children:b.map((e,t)=>C.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===h?"bg-blue-50 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),onClick:()=>v(e.value),onMouseEnter:()=>m(t),children:[C.jsx("span",{className:"truncate",children:e.label}),y?.value===e.value&&C.jsx(I,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2 dark:text-blue-400"})]},e.value))}):C.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"})})]})},nr=({name:e,label:t,value:r,onChange:n,className:o=""})=>C.jsxs("div",{className:`space-y-1 ${o}`,children:[t&&C.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t}),C.jsx("input",{type:"date",name:e,value:r||"",onChange:e=>n(e.target.value||null),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),or=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,lr=e=>{const[t,r,n]=e.split("-").map(Number);return t&&r&&n?new Date(t,r-1,n):new Date(NaN)},ar=e=>`${String(e.getDate()).padStart(2,"0")}-${String(e.getMonth()+1).padStart(2,"0")}-${e.getFullYear()}`,sr=({columns:e,columnFilters:t,onColumnFilter:n})=>{const o=e.filter(e=>e.filterable),[a,s]=r(o.length>0?o[0].key:""),[i,c]=r(""),d=o.map(e=>({label:e.header,value:e.key})),u=o.find(e=>e.key===a);return l(()=>{c("")},[a]),C.jsxs("div",{className:"space-y-4",children:[C.jsxs("div",{children:[C.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Select Column to Filter"}),C.jsx(rr,{options:d,value:a,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),a&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",r=t[a];if("multiselect"===e&&u.filterable?.options){const e=i.toLowerCase(),t=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return C.jsxs("div",{className:"mt-3",children:[C.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),C.jsxs("div",{className:"relative mb-2",children:[C.jsx(Z,{className:"w-4 h-4 text-gray-400 absolute left-2 top-1/2 -translate-y-1/2 dark:text-gray-500"}),C.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"}),i&&C.jsx("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:"Clear search",children:C.jsx(z,{className:"w-3 h-3"})})]}),C.jsxs("div",{className:"max-h-32 overflow-y-auto border border-gray-300 rounded-md p-2 bg-white dark:border-gray-600 dark:bg-gray-800",children:[0===t.length&&C.jsx("div",{className:"text-xs text-gray-500 px-1 py-1 dark:text-gray-400",children:"No matches"}),t.map(e=>{const t=r?.value||[],o=Array.isArray(t)&&t.includes(e.value);return C.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-gray-50 cursor-pointer dark:hover:bg-gray-700 rounded px-1",children:[C.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:text-blue-400",checked:o,onChange:t=>{const o=r?.value||[];let l;l=t.target.checked?[...o,e.value]:o.filter(t=>t!==e.value),n?.(a,l.length>0?{type:"multiselect",value:l,operator:"in"}:null)}}),C.jsx("span",{className:"text-sm dark:text-gray-300",children:e.label})]},e.value)})]})]})}if("select"===e&&u.filterable?.options){const e=[{label:`All ${u.header}`,value:""},...u.filterable.options.map(e=>({label:e.label,value:String(e.value)}))];return C.jsxs("div",{className:"mt-3",children:[C.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),C.jsx(rr,{options:e,value:r?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{n?.(a,e?{type:"select",value:e,operator:"between"}:null)},searchable:!0})]})}if("date"===e){const e=e=>{if(!e)return null;if(e instanceof Date&&!isNaN(e.getTime()))return e;const t=lr(String(e));if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},t=e(r?.value),o=e(r?.secondValue),l=r?.operator||"between";return C.jsxs("div",{className:"mt-3",children:[C.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),C.jsx("div",{className:"mb-3",children:C.jsx(rr,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:l,placeholder:"Select date filter...",onChange:e=>{n?.(a,{type:"date",value:r?.value||"",operator:e,secondValue:r?.secondValue||""})},searchable:!1},`date-operator-${a}-${l}`)}),C.jsxs("div",{className:"flex items-end gap-2",children:[C.jsx("div",{className:"flex-1 min-w-37.5",children:C.jsx(nr,{name:"column_filter_start",label:"between"===l?"Start Date":"Date",value:t?or(t):null,onChange:e=>{if(e){const t=or(lr(e));n?.(a,{type:"date",value:t,operator:l,secondValue:r?.secondValue||null})}else n?.(a,null)},className:"w-full"})}),"between"===l&&C.jsx("div",{className:"flex-1 min-w-37.5",children:C.jsx(nr,{name:"column_filter_end",label:"End Date",value:o?or(o):null,onChange:e=>{if(e&&r){const t=or(lr(e));n?.(a,{...r,secondValue:t})}},className:"w-full"})})]})]})}return C.jsxs("div",{className:"mt-3",children:[C.jsxs("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:["Filter by ",u.header]}),C.jsxs(C.Fragment,{children:[C.jsx("input",{type:"text",placeholder:u.filterable?.placeholder||`Filter ${u.header.toLowerCase()}...`,className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",value:r?.value||"",onChange:e=>{n?.(a,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),r&&C.jsx("div",{className:"mt-2",children:C.jsx(rr,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:r?.operator||"contains",placeholder:"Select operator...",onChange:e=>{r&&n?.(a,{...r,operator:e})},searchable:!1})})]})]})})(),Object.keys(t).length>0&&C.jsxs("div",{className:"mt-4",children:[C.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block dark:text-gray-300",children:"Active Filters"}),C.jsx("div",{className:"space-y-2",children:Object.entries(t).map(([e,t])=>{const r=o.find(t=>t.key===e);return r?C.jsxs("div",{className:"flex items-center justify-between bg-blue-50 border border-blue-200 rounded-md px-3 py-2 cursor-pointer hover:bg-blue-100 dark:bg-blue-900/20 dark:border-blue-800 dark:hover:bg-blue-900/40",role:"button",title:`Edit filter for ${r.header}`,onClick:()=>(e=>{s(e)})(e),children:[C.jsxs("div",{className:"flex-1",children:[C.jsxs("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:[r.header,":"]}),C.jsx("span",{className:"text-sm text-blue-700 ml-1 dark:text-blue-300",children:(()=>{if(Array.isArray(t.value))return`${t.value.length} selected`;if("date"===t.type){const e=e=>{try{if(!e)return"";if(e instanceof Date&&!isNaN(e.getTime()))return ar(e);if("string"==typeof e){const t=lr(e);if(!isNaN(t.getTime()))return ar(t);const r=new Date(e);if(!isNaN(r.getTime()))return ar(r)}return String(e)}catch{return String(e??"")}},r={equals:"On",gt:"After",gte:"On or After",lt:"Before",lte:"On or Before",between:"Between"}[t.operator]||"On";return"between"===t.operator&&t.secondValue?`${r} ${e(t.value)} - ${e(t.secondValue)}`:`${r} ${e(t.value)}`}return t.value})()})]}),C.jsx("button",{onClick:t=>{t.stopPropagation(),n?.(e,null)},className:"text-blue-400 hover:text-red-500 transition-colors",title:"Clear filter",children:C.jsx(z,{className:"w-4 h-4"})})]},e):null})})]})]})},ir=({isOpen:e,anchorEl:t,onClose:r,onClearFilters:n,columns:o,columnFilters:l,onColumnFilter:a,hasFilterableColumns:s})=>s?C.jsxs(Yt,{open:e,anchorEl:t,onClose:r,placement:"bottom-start",offset:8,zIndex:1e3,maxHeight:520,className:"w-88 sm:w-88 max-w-[90vw] bg-white border border-gray-200 rounded-lg shadow-xl overflow-y-auto min-h-100 dark:bg-gray-800 dark:border-gray-700",shouldIgnoreClose:e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1},children:[C.jsxs("div",{className:"flex items-center justify-between px-2",children:[C.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[C.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Column Filters"}),C.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Filter data by column values"})]}),C.jsx("button",{onClick:n,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Clear All"})]}),C.jsx("div",{className:"p-3 space-y-3",children:C.jsx(sr,{columns:o,columnFilters:l,onColumnFilter:a})}),C.jsx("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700",children:C.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:Object.keys(l).length>0&&C.jsxs("span",{children:[Object.keys(l).length," filter",1!==Object.keys(l).length?"s":""," applied"]})})})]}):null,cr=({isOpen:e,anchorEl:t,onClose:r,density:n,onDensityChange:o,showDensityControl:l=!0})=>C.jsxs(Yt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-gray-200 rounded-lg shadow-xl dark:bg-gray-800 dark:border-gray-700",children:[C.jsxs("div",{className:"p-3 border-b border-gray-100 dark:border-gray-700",children:[C.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Grid Settings"}),C.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:"Customize your display preferences"})]}),C.jsx("div",{className:"p-3",children:l&&C.jsxs("div",{className:"space-y-3",children:[C.jsx("label",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 uppercase tracking-wider",children:"Row Density"}),C.jsx("div",{className:"flex items-center gap-1 bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-1",children:Zt.map(e=>C.jsx("button",{onClick:()=>o?.(e),className:"flex-1 px-2 py-1.5 text-xs font-medium rounded-md transition-all "+(n===e?"bg-blue-600 text-white shadow-md scale-105":"text-gray-600 dark:text-gray-400 hover:bg-white dark:hover:bg-gray-800 hover:shadow-sm"),children:e.toUpperCase()},e))})]})})]}),dr=({globalFilter:e,filteredDataLength:t,totalDataLength:a,selectedRowsCount:s=0,selectedRows:c=new Set,showExport:d=!0,showColumnToggle:u=!0,showBulkActions:g=!0,columns:h=[],columnVisibility:m={},columnFilters:x={},bulkActions:f=[],exportOptions:p,onGlobalFilterChange:y,onClearFilters:b,onColumnVisibilityChange:v,onColumnFilter:w,onResetColumns:k,columnOrder:j=[],onColumnOrderChange:N,pinnedColumns:S,onScrollToColumn:R,density:M="md",onDensityChange:D,showDensityControl:E=!1,customLeftContent:A,customRightContent:F})=>{const[L,I]=r(""),T=o(null),{showExportMenu:O,setShowExportMenu:$,exportMenuRef:P,exportAnchorRef:W,showFilters:_,setShowFilters:G,filtersMenuRef:H,filtersAnchorRef:U,showBulkActionsMenu:Y,setShowBulkActionsMenu:X,bulkActionsRef:J,bulkActionsAnchorRef:Q,showColumnMenu:ee,setShowColumnMenu:te,columnMenuRef:ne,columnAnchorRef:oe,showSettingsMenu:le,setShowSettingsMenu:ae,settingsMenuRef:se,settingsAnchorRef:ie}=function(){const[e,t]=r(!1),[a,s]=r(!1),[i,c]=r(!1),[d,u]=r(!1),[g,h]=r(!1),m=o(null),x=o(null),f=o(null),p=o(null),y=o(null),b=o(null),v=o(null),w=o(null),k=o(null),j=o(null),C=n(()=>{t(!1),s(!1),c(!1),u(!1),h(!1)},[]);return l(()=>{const r=r=>{const n=r.target;(e=>{let t=e;for(;t;){if(t.getAttribute&&"true"===t.getAttribute("data-popover-root")||t.dataset&&"true"===t.dataset.popoverRoot)return!0;t=t.parentNode}return!1})(n)||(e&&m.current&&!m.current.contains(n)&&t(!1),i&&x.current&&!x.current.contains(n)&&c(!1),d&&f.current&&!f.current.contains(n)&&u(!1),g&&y.current&&!y.current.contains(n)&&h(!1),a&&p.current&&!p.current.contains(n)&&!(e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1})(n)&&s(!1))};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,i,d,g,a]),{showExportMenu:e,setShowExportMenu:t,showFilters:a,setShowFilters:s,showBulkActionsMenu:i,setShowBulkActionsMenu:c,showColumnMenu:d,setShowColumnMenu:u,showSettingsMenu:g,setShowSettingsMenu:h,exportMenuRef:m,bulkActionsRef:x,columnMenuRef:f,filtersMenuRef:p,settingsMenuRef:y,exportAnchorRef:b,bulkActionsAnchorRef:v,columnAnchorRef:w,filtersAnchorRef:k,settingsAnchorRef:j,closeAllMenus:C}}(),{draggingKey:ce,dragOver:de,handleDragStart:ue,handleDragOver:ge,handleDrop:he,handleDragEnd:me}=function({columns:e,columnOrder:t,pinnedColumns:o,onColumnOrderChange:l}){const[a,s]=r(null),[i,c]=r(null),d=n((e,t)=>{s(e),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e))},[]),u=n((e,t)=>{t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move");const r=t.currentTarget.getBoundingClientRect();c({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},[]),g=n(r=>{const n=a;if(!n||n===r)return;if(o&&o.has(n)!==o.has(r))return s(null),void c(null);const d=i?.key!==r||"before"===i.position,u=(t&&t.length?t:e.map(e=>e.key)).filter(e=>e!==n);let g=u.indexOf(r);if(-1===g)return l?.(u),s(null),void c(null);d||(g+=1),u.splice(g,0,n),l?.(u),s(null),c(null)},[a,i,t,e,o,l]),h=n(()=>{s(null),c(null)},[]);return{draggingKey:a,dragOver:i,handleDragStart:d,handleDragOver:u,handleDrop:g,handleDragEnd:h}}({columns:h,columnOrder:j,pinnedColumns:S,onColumnOrderChange:N}),xe=p?.formats||["xlsx"],fe=(e?.length??0)>0||Object.keys(x||{}).length>0,pe=s>0;h.filter(e=>!1!==m[e.key]);const ye=i(()=>[...j.map(e=>h.find(t=>t.key===e)).filter(Boolean),...h.filter(e=>!j.includes(e.key))],[j,h]),be=i(()=>ye.filter(e=>e.header?.toLowerCase()?.includes(L?.toLowerCase())),[ye,L]),ve=i(()=>h.some(e=>e.filterable),[h]);return C.jsxs("div",{className:"bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700 font-inter",role:"toolbar","aria-label":"Data grid toolbar",children:[C.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[fe?`Showing ${t} of ${a} rows`:`${t} total rows`,pe&&`, ${s} row${1!==s?"s":""} selected`]}),C.jsx("div",{className:"px-3 py-2",children:C.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[C.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[C.jsxs("div",{className:"relative",ref:H,children:[ve&&C.jsxs("button",{ref:U,onClick:()=>G(!_),className:"flex cursor-pointer items-center gap-2 px-3 py-1.5 border rounded-lg transition-all duration-200 "+(_?"bg-blue-50 dark:bg-blue-900/40 border-blue-200 dark:border-blue-600 text-blue-700 dark:text-blue-300":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800"),"aria-haspopup":"menu","aria-expanded":_,title:"Filter columns",children:[C.jsx(V,{className:"w-4 h-4"}),C.jsx("span",{className:"hidden sm:inline text-sm font-medium",children:"Filters"}),Object.keys(x).length>0&&C.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),b?.()},className:"bg-red-500 hover:bg-red-600 text-white text-[10px] sm:text-xs px-1.5 py-0.5 rounded-full min-w-5 h-5 flex items-center justify-center transition-all group relative",title:"Clear all filters",children:[C.jsx("span",{className:"group-hover:hidden",children:Object.keys(x).length}),C.jsx(z,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),C.jsx(ir,{isOpen:_,anchorEl:U.current,onClose:()=>G(!1),onClearFilters:b,columns:h,columnFilters:x,onColumnFilter:w,hasFilterableColumns:ve})]}),A]}),C.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap flex-1 justify-end min-w-0",children:[F,d&&p?.enabled&&C.jsxs("div",{className:"relative",ref:P,children:[C.jsx("button",{ref:W,onClick:()=>$(!O),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 transition-all duration-200 "+(O?"bg-gray-100 dark:bg-gray-800 border-gray-400":""),title:"Export data","aria-haspopup":"menu","aria-expanded":O,children:C.jsx(K,{className:"w-4 h-4"})}),C.jsx(tr,{isOpen:O,anchorEl:W.current,onClose:()=>$(!1),exportFormats:xe,filteredDataLength:t,selectedRowsCount:s,onExport:(e,t=!1)=>{p?.onExport?.(e,t),$(!1)}})]}),C.jsxs("div",{className:"relative flex-1 min-w-0 max-w-[160px] sm:max-w-[240px]",children:[C.jsx(Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),C.jsx("input",{ref:T,type:"text",placeholder:"Global Search...",className:"w-full pl-10 pr-10 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 transition-all text-sm shadow-sm",value:e,onChange:y}),e&&C.jsx("button",{onClick:()=>y({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 transition-colors p-1",title:"Clear search",children:C.jsx(z,{className:"w-4 h-4"})})]}),g&&pe&&f.length>0&&C.jsxs("div",{className:"relative",ref:J,children:[C.jsxs("button",{ref:Q,onClick:()=>X(!Y),className:"flex items-center gap-2 px-3 py-2.5 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition-all shadow-md shrink-0 active:scale-95",children:[C.jsx(q,{className:"w-4 h-4"}),C.jsxs("span",{className:"hidden sm:inline text-sm font-semibold",children:["Actions (",s,")"]})]}),C.jsx(Qt,{isOpen:Y,anchorEl:Q.current,onClose:()=>X(!1),bulkActions:f,selectedRowsCount:s,onBulkAction:e=>{e.disabled||(e.onClick(c),X(!1))}})]}),u&&h.length>0&&C.jsxs("div",{className:"relative",ref:ne,children:[C.jsx("button",{ref:oe,onClick:()=>te(!ee),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-all shrink-0 "+(ee?"border-gray-400 bg-gray-50 dark:bg-gray-800":""),title:"Manage columns",children:C.jsx(re,{className:"w-4 h-4 dark:text-gray-300"})}),C.jsx(er,{isOpen:ee,anchorEl:oe.current,onClose:()=>te(!1),filteredColumns:be,columnVisibility:m,onColumnToggle:e=>{const t=!1!==m[e];v?.(e,!t)},columnSearch:L,onColumnSearchChange:I,onResetColumns:()=>{h.forEach(e=>{v?.(e.key,!1!==e.visible)}),N?.(h.map(e=>e.key)),k?.()},onScrollToColumn:R,onColumnVisibilityChange:v,draggingKey:ce,dragOver:de,handleDragStart:ue,handleDragOver:ge,handleDrop:he,handleDragEnd:me})]}),C.jsxs("div",{className:"relative",ref:se,children:[C.jsx("button",{ref:ie,onClick:()=>ae(!le),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300 transition-all "+(le?"bg-gray-100 dark:bg-gray-800":""),title:"Grid settings","aria-haspopup":"menu","aria-expanded":le,children:C.jsx(B,{className:"w-4 h-4"})}),C.jsx(cr,{isOpen:le,anchorEl:ie.current,onClose:()=>ae(!1),density:M,onDensityChange:D,showDensityControl:E})]})]})]})})]})};dr.displayName="SearchToolbar";const ur=s(dr),gr=({columns:e,groupedKeys:t,onRemove:n,onReorder:o,onDropColumnKey:l,onToggleExpandAll:a,isAnyExpanded:s=!1})=>{const[i,c]=r(null),[d,u]=r(null),[g,h]=r(!0),m=t=>e.find(e=>e.key===t)?.header||t,x=e=>t=>{c(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},f=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;u(e),h(n)};return C.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 border-b border-gray-200 text-sm dark:bg-gray-800 dark:border-gray-700",onDrop:e=>{e.preventDefault();const r=e.dataTransfer.getData("text/plain");r&&(t.includes(r)||l(r))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{c(null),u(null)},children:[C.jsx("span",{className:"text-gray-600 whitespace-nowrap dark:text-gray-400",children:"Group by:"}),t.length>0&&C.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-700",title:s?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),a?.()},children:s?"Collapse All":"Expand All"}),0===t.length&&C.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Drag a column here"}),C.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.map(e=>{return C.jsxs("div",{className:"inline-flex items-center gap-2 bg-blue-100 text-blue-800 px-2 py-1 rounded-md border border-blue-200 cursor-move relative dark:bg-blue-900/40 dark:text-blue-300 dark:border-blue-800",draggable:!0,onDragStart:x(e),onDragOver:f(e),onDrop:(r=e,()=>{if(!i||i===r)return c(null),void u(null);const e=t.filter(e=>e!==i),n=e.indexOf(r);-1!==n&&(e.splice(g?n:n+1,0,i),o(e),c(null),u(null))}),title:m(e),children:[C.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:m(e)}),C.jsx("button",{className:"text-blue-700 hover:text-blue-900 dark:text-blue-400",onClick:()=>n(e),"aria-label":`Remove grouping ${m(e)}`,children:"×"}),d===e&&C.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 dark:bg-blue-400 animate-pulse",style:{left:g?0:void 0,right:g?void 0:0},"aria-hidden":"true"})]},e);var r})})]})},hr=({showToolbar:e,filterable:t,globalFilter:r,filteredDataLength:n,totalDataLength:o,paginationMode:l,selectedRowsCount:a,showExport:s,columns:i,columnFilters:c,columnVisibility:d,onResetColumns:u,exportOptions:g,toolbarLeft:h,toolbarRight:m,onGlobalFilterChange:x,onClearFilters:f,onColumnFilter:p,onColumnVisibilityChange:y,columnOrder:b,onColumnOrderChange:v,pinnedColumns:w,onScrollToColumn:k,density:j,onDensityChange:N,showDensityControl:S,groupable:R,groupBarVisibility:M,groupConfig:D,removeGroupKey:E,setGroupKeys:A,addGroupKey:F,collapseAllGroups:L,expandAllGroups:z})=>C.jsxs(C.Fragment,{children:[e&&t&&C.jsx(ur,{globalFilter:r,filteredDataLength:n,totalDataLength:o,paginationMode:l,selectedRowsCount:a,showExport:s,columns:i,columnFilters:c,columnVisibility:d,onResetColumns:u,exportOptions:g,customLeftContent:h,customRightContent:m,onGlobalFilterChange:x,onClearFilters:f,onColumnFilter:p,onColumnVisibilityChange:y,columnOrder:b,onColumnOrderChange:v,pinnedColumns:w,onScrollToColumn:k,density:j,onDensityChange:N,showDensityControl:S}),R&&("visible"===M||"auto"===M&&D.columnKeys.length>0)&&C.jsx(gr,{columns:i,groupedKeys:D.columnKeys,onRemove:E,onReorder:A,onDropColumnKey:F,isAnyExpanded:D.expanded.size>0,onToggleExpandAll:()=>{D.expanded.size>0?L():z()}})]}),mr=48,xr=({value:e,onChange:t,placeholder:n="Enter text to filter..."})=>{const[o,l]=r(String(e?.value??"")),[a,s]=r(e?.operator||"contains");return C.jsxs("div",{className:"space-y-3",children:[C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),C.jsxs("select",{value:a,onChange:e=>(e=>{const r=e;s(r),o.trim()&&t({type:"text",value:o,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[C.jsx("option",{value:"contains",children:"Contains"}),C.jsx("option",{value:"equals",children:"Equals"}),C.jsx("option",{value:"startsWith",children:"Starts with"}),C.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Text Value"}),C.jsx("input",{type:"text",value:o,onChange:e=>{return l(r=e.target.value),void(r.trim()?t({type:"text",value:r,operator:a}):t(null));var r},placeholder:n,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},fr=({value:e,onChange:t,min:n,max:o})=>{const[l,a]=r(String(e?.value??"")),[s,i]=r(String(e?.secondValue??"")),[c,d]=r(e?.operator||"equals"),u=(e,r=!1)=>{r?i(e):a(e);const n=parseFloat(e),o=parseFloat(s);"between"===c?isNaN(n)||isNaN(o)?t(null):t({type:"number",value:Math.min(n,o),secondValue:Math.max(n,o),operator:"between"}):isNaN(n)?t(null):t({type:"number",value:n,operator:c})};return C.jsxs("div",{className:"space-y-3",children:[C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),C.jsxs("select",{value:c,onChange:e=>(e=>{const r=e;if(d(r),"between"===r){const e=parseFloat(l),r=parseFloat(s);isNaN(e)||isNaN(r)||t({type:"number",value:Math.min(e,r),secondValue:Math.max(e,r),operator:"between"})}else{const e=parseFloat(l);isNaN(e)||t({type:"number",value:e,operator:r})}})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[C.jsx("option",{value:"equals",children:"Equals"}),C.jsx("option",{value:"gt",children:"Greater than"}),C.jsx("option",{value:"gte",children:"Greater than or equal"}),C.jsx("option",{value:"lt",children:"Less than"}),C.jsx("option",{value:"lte",children:"Less than or equal"}),C.jsx("option",{value:"between",children:"Between"})]})]}),C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===c?"From Value":"Number Value"}),C.jsx("input",{type:"number",value:l,onChange:e=>u(e.target.value),min:n,max:o,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),"between"===c&&C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Value"}),C.jsx("input",{type:"number",value:s,onChange:e=>u(e.target.value,!0),min:n,max:o,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]})]})},pr=({value:e,onChange:t,min:n,max:o})=>{const a=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=lr(String(e));return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},s=e=>e?or(e):"",[c,d]=r(a(e?.value)),[u,g]=r("between"===e?.operator?a(e?.secondValue??e?.value):null),[h,m]=r(e?.operator||"between");l(()=>{m(e?.operator||"between"),d(a(e?.value)),g("between"===e?.operator?a(e?.secondValue??e?.value):null)},[e?.value,e?.secondValue,e?.operator]),l(()=>{"between"===h&&!u&&c&&g(c)},[h,c,u]);const x=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,f=(e,r=!1)=>{const n=r?c:e,o=r?e:u,l="between"===h&&u?u:y,a=r?x(e,c??p??void 0,y):x(e,p,l);if(r?g(a):d(a),"between"===h)if(n&&o){const e=n>=o?n:o;t({type:"date",value:s(n<=o?n:o),secondValue:s(e),operator:"between"})}else t(null);else t(a?{type:"date",value:s(a),operator:h}:null)},p=i(()=>n?new Date(n):void 0,[n]),y=i(()=>o?new Date(o):void 0,[o]);return C.jsxs("div",{className:"space-y-3",children:[C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Filter Type"}),C.jsxs("select",{value:h,onChange:e=>(e=>{const r=e;m(r),"between"===r?c&&u&&t({type:"date",value:c<=u?c:u,secondValue:c>=u?c:u,operator:"between"}):c&&t({type:"date",value:c,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[C.jsx("option",{value:"equals",children:"On Date"}),C.jsx("option",{value:"gt",children:"After"}),C.jsx("option",{value:"gte",children:"On or After"}),C.jsx("option",{value:"lt",children:"Before"}),C.jsx("option",{value:"lte",children:"On or Before"}),C.jsx("option",{value:"between",children:"Between Dates"})]})]}),C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"between"===h?"From Date":"Date"}),C.jsx(nr,{name:"date_filter_start",value:c?or(c):null,onChange:e=>f(e?lr(e):null,!1),className:"w-full"})]}),"between"===h&&C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"To Date"}),C.jsx(nr,{name:"date_filter_end",value:u?or(u):null,onChange:e=>f(e?lr(e):null,!0),className:"w-full"})]})]})},yr=({value:e,onChange:t,options:n,data:o,columnKey:a})=>{const[s,c]=r(""),[d,u]=r(new Set(Array.isArray(e?.value)?e.value:[]));l(()=>{u(new Set(Array.isArray(e?.value)?e.value:[]))},[e]);const g=i(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(n&&n.length>0)e=n;else{const r=o.map(e=>{const r=e[a];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const r=e.map(e=>{const r=t(e.value);return{...e,label:r?"Blank":e.label,value:r?null:e.value,isBlank:r}});return Array.from(new Map(r.map(e=>[e.isBlank?"__blank__":e.value,e])).values()).sort((e,t)=>e.isBlank&&!t.isBlank?1:!e.isBlank&&t.isBlank?-1:String(e.label).localeCompare(String(t.label)))},[n,o,a]),h=i(()=>{if(!s)return g;const e=s.toLowerCase();return g.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[g,s]);return C.jsxs("div",{className:"space-y-3",children:[C.jsxs("div",{className:"relative",children:[C.jsx(Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4 dark:text-gray-500"}),C.jsx("input",{type:"text",value:s,onChange:e=>c(e.target.value),placeholder:"Search options...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),C.jsxs("div",{className:"flex justify-between items-center text-sm",children:[C.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[d.size," of ",g.length," selected"]}),C.jsxs("div",{className:"flex gap-2",children:[C.jsx("button",{onClick:()=>{const e=new Set(h.map(e=>e.value));u(e),t({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-blue-600 hover:text-blue-800 transition-colors dark:text-blue-400",children:"Select All"}),C.jsx("button",{onClick:()=>{u(new Set),t(null)},className:"text-gray-600 hover:text-gray-800 transition-colors dark:text-gray-400",children:"Clear All"})]})]}),C.jsx("div",{className:"max-h-48 overflow-y-auto border border-gray-200 rounded-md dark:border-gray-700",children:0===h.length?C.jsx("div",{className:"p-3 text-sm text-gray-500 text-center dark:text-gray-400",children:"No options found"}):h.map((e,r)=>{const n=d.has(e.value);return C.jsxs("div",{className:`flex items-center gap-3 p-2 cursor-pointer hover:bg-gray-50 transition-colors ${n?"bg-blue-50 dark:bg-blue-900/30":""} dark:hover:bg-gray-800`,onClick:()=>(e=>{const r=new Set(d);r.has(e)?r.delete(e):r.add(e),u(r),t(r.size>0?{type:"multiselect",value:Array.from(r),operator:"equals"}:null)})(e.value),children:[C.jsx("div",{className:"w-4 h-4 border-2 rounded flex items-center justify-center "+(n?"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600"),children:n&&C.jsx(I,{className:"w-3 h-3"})}),C.jsx("span",{className:`text-sm ${n?"text-blue-900 dark:text-blue-100 font-medium":"text-gray-700 dark:text-gray-300"} ${e.isBlank?"italic text-gray-500 dark:text-gray-500":""}`,children:e.label})]},r)})})]})},br=({value:e,onChange:t})=>{const[n,o]=r(void 0!==e?.value?String(e.value):"");return C.jsx("div",{className:"space-y-3",children:C.jsxs("div",{children:[C.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 dark:text-gray-300",children:"Boolean Value"}),C.jsxs("select",{value:n,onChange:e=>{return o(r=e.target.value),void t(""===r?null:{type:"boolean",value:"true"===r,operator:"equals"});var r},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",children:[C.jsx("option",{value:"",children:"All values"}),C.jsx("option",{value:"true",children:"True"}),C.jsx("option",{value:"false",children:"False"})]})]})})},vr=({column:e,data:t,value:r,onChange:n})=>{const o=i(()=>{if("object"==typeof e.filterable)return e.filterable;const r=t.slice(0,100).map(t=>t[e.key]).filter(e=>null!=e);if(0===r.length)return{type:"text"};const n=r[0];if("boolean"==typeof n)return{type:"boolean"};if("number"==typeof n)return{type:"number"};if(n instanceof Date||"string"==typeof n&&!isNaN(Date.parse(n)))return{type:"date"};const o=[...new Set(r)];return o.length<=20?{type:"multiselect",options:o.map(e=>({label:String(e),value:e}))}:{type:"text"}},[e.filterable,e.key,t]);switch(o.type){case"text":return C.jsx(xr,{value:r,onChange:n,placeholder:o.placeholder});case"number":return C.jsx(fr,{value:r,onChange:n,min:o.min,max:o.max});case"date":return C.jsx(pr,{value:r,onChange:n,min:o.min,max:o.max});case"multiselect":return C.jsx(yr,{value:r,onChange:n,options:o.options||[],data:t,columnKey:e.key});case"boolean":return C.jsx(br,{value:r,onChange:n});default:return null}},wr=({pinnedColumns:e,unpinnedColumns:t,hvPadLeft:n=0,hvPadRight:o=0,headerHeight:a,sortConfig:s,columnFilters:c,selectable:d,selectedRows:u,totalRows:g,data:h,onSort:m,onColumnFilter:x,onSelectAll:f,onColumnResize:p,pinnedKeySet:y=new Set,onColumnPin:b,groupable:v=!1,groupedByColumn:w,onGroupBy:k,groupedByColumns:j=[],onGroupToggle:N,onAutosizeColumn:S,onAutosizeAllColumns:R,onResetColumns:M,columnOrder:D,onColumnOrderChange:E,paginationMode:z="client",minResizeWidth:I=80})=>{const T=i(()=>[...e,...t],[e,t]),[O,$]=r(null),[P,K]=r(null),[B,q]=r(null),[X,J]=r(0),[Z,Q]=r(0),[ee,te]=r("menu"),[re,ne]=r(null),[oe,le]=r(!1);l(()=>{le("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[ae,se]=r(null),[ie,ce]=r(null),de=u.size===g&&g>0,ue=u.size>0&&u.size<g,ge=(e,t)=>{if(t.stopPropagation(),O===e)$(null);else{$(e),te("menu"),ne(c[e]||null);const r=t.currentTarget.getBoundingClientRect(),n=t.currentTarget.closest("[data-grid-container]"),o=n?n.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),l=10,a=Math.max(o.left+l,Math.min(r.left,o.right-320-l));K({top:r.bottom+4,left:a,containerRect:o})}},he=e=>{x(e,re||null),$(null)},me=e=>null!=c[e],xe=(r,n)=>{n.preventDefault(),q(r),J(n.clientX);const o=[...e,...t].find(e=>e.key===r);Q(o?.width||100)},fe=e=>{if(!B||!p)return;const t=Math.max(I,Z+(e.clientX-X));p(B,t)},pe=()=>{q(null),J(0),Q(0)},[ye,be]=r(null),[ve,we]=r(null),ke=(e,t)=>{be(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},je=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();we({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},Ce=e=>{const t=ye;if(!t||t===e)return;if(y.has(t)!==y.has(e))return be(null),void we(null);const r=ve?.key!==e||"before"===ve?.position,n=D.filter(e=>e!==t);let o=n.indexOf(e);if(-1===o)return E(n),be(null),void we(null);r||(o+=1),n.splice(o,0,t),E(n),be(null),we(null)},Ne=()=>{be(null),we(null)},Se=(e,t)=>{se(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},Re=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();ce({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Me=e=>{const t=ae;if(!t||t===e)return;if(y.has(t)!==y.has(e))return se(null),void ce(null);const r=ie?.key!==e||"before"===ie?.position,n=D.filter(e=>e!==t);let o=n.indexOf(e);if(-1===o)return E(n),se(null),void ce(null);r||(o+=1),n.splice(o,0,t),E(n),se(null),ce(null)},De=()=>{se(null),ce(null)};return l(()=>{if(B)return document.addEventListener("mousemove",fe),document.addEventListener("mouseup",pe),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",pe),document.body.style.cursor="",document.body.style.userSelect=""}},[B,X,Z,p]),l(()=>{const e=e=>{O&&!e.target.closest("[data-column-menu]")&&$(null)};if(O)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[O]),C.jsx(C.Fragment,{children:C.jsx("div",{className:"bg-blue-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",style:{height:a},role:"row","aria-label":"Column headers",children:C.jsxs("div",{className:"flex h-full",children:[d&&C.jsx("div",{className:"px-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center bg-blue-50 dark:bg-gray-800 sticky left-0 z-3 h-full",style:{width:mr,height:a},role:"columnheader","aria-label":"Select all rows",children:C.jsx("input",{type:"checkbox",checked:de,ref:e=>{e&&(e.indeterminate=ue)},onChange:f,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),f())},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":de?"Deselect all rows":ue?`${u.size} rows selected. Click to select all`:"Select all rows",title:de?`Deselect all ${g} rows`:ue?`${u.size} of ${g} rows selected`:`Select all ${g} rows`})}),e.map((t,r)=>{const n=y.has(t.key),o=e.filter(e=>y.has(e.key)).map(e=>e.key),l=o.indexOf(t.key),i=n?o.slice(0,l).reduce((t,r)=>{const n=e.find(e=>e.key===r);return t+(n?.width||100)},d?mr:0):0,c="center"===t.headerAlign?"justify-center":"right"===t.headerAlign?"justify-end":"justify-start",u=!1!==t.sortable;return C.jsxs("div",{className:`flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative ${n?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700 sticky z-2":""} `,style:{width:t.width||100,left:n?`${i}px`:"auto",height:a},"data-column-key":t.key,draggable:!0,onDragStart:e=>ke(t.key,e),onDragOver:e=>je(t.key,e),onDrop:()=>Ce(t.key),onDragEnd:Ne,children:[ve?.key===t.key&&C.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ve?.position?0:void 0,right:"after"===ve?.position?0:void 0}}),C.jsx("div",{className:"px-3 h-full",children:C.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[C.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${c} ${u?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>u&&m(t.key),children:[C.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[me(t.key)&&C.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),C.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",children:t.header})]}),u&&s.key===t.key&&C.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:C.jsx("asc"===s.direction?A:F,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(t.filterable||b||v)&&C.jsxs("div",{className:"relative "+(O===t.key||oe?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[C.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:e=>ge(t.key,e),"data-menu-trigger":!0,children:C.jsx(W,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===t.key&&P&&C.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-1000 w-[320px] overflow-auto",style:{top:`${P.top}px`,left:`${P.left}px`,maxHeight:`${Math.max(160,P.containerRect.bottom-12-P.top)}px`},"data-column-menu":!0,children:[C.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("menu"),children:C.jsx(W,{className:"w-4 h-4"})}),t.filterable&&C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("filter"),children:C.jsx(V,{className:"w-4 h-4"})}),C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("reorder"),children:C.jsx(L,{className:"w-4 h-4"})})]}),"menu"===ee&&C.jsxs("div",{className:"py-1",children:[b&&(w===t.key?C.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-blue-600 dark:text-blue-400",children:[C.jsx(G,{className:"w-4 h-4"}),"Pinned by grouping"]}):C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),$(null),b?.(t.key,!y.has(t.key))},children:y.has(t.key)?C.jsxs(C.Fragment,{children:[C.jsx(H,{className:"w-4 h-4"}),"Unpin Column"]}):C.jsxs(C.Fragment,{children:[C.jsx(G,{className:"w-4 h-4"}),"Pin Column"]})})),S&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{S?.(t.key),$(null)},children:"Autosize This Column"}),R&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(),$(null)},children:"Autosize All Columns"}),v&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:e=>{e.stopPropagation(),$(null);const r=j?.includes(t.key)||w===t.key;N?N(t.key,!r):k?.(r?null:t.key)},children:w===t.key||j?.includes(t.key)?C.jsxs(C.Fragment,{children:[C.jsx(Y,{className:"w-4 h-4"}),"Ungroup"]}):C.jsxs(C.Fragment,{children:[C.jsx(U,{className:"w-4 h-4"}),"Group by ",t.header]})}),M&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),$(null)},children:"Reset Columns"})]}),"filter"===ee&&C.jsxs("div",{className:"p-3 w-full",children:[me(t.key)&&C.jsxs("button",{className:"mb-2 text-xs text-red-600 hover:underline flex items-center gap-1 dark:text-red-400",onClick:()=>{ne(null),x(t.key,null),$(null)},children:[C.jsx(_,{className:"w-3 h-3"})," Clear Filter"]}),C.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:C.jsx(vr,{column:t,data:h,value:re,onChange:e=>{ne(e),"server"!==z&&x(t.key,e)}})}),"server"===z?C.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[C.jsx("button",{className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-700",onClick:()=>$(null),children:"Cancel"}),C.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(t.key),children:"Apply"})]}):C.jsx("div",{className:"flex justify-end mt-3",children:C.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>$(null),children:"Close"})})]}),"reorder"===ee&&C.jsxs("div",{className:"px-3 py-2",children:[C.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),C.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...D.map(e=>T.find(t=>t.key===e)).filter(Boolean),...T.filter(e=>!D.includes(e.key))].map(e=>{const t=y.has(e.key);return C.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Se(e.key,t),onDragOver:t=>Re(e.key,t),onDrop:()=>Me(e.key),onDragEnd:De,children:[ie?.key===e.key&&C.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ie?.position?0:void 0,bottom:"after"===ie?.position?0:void 0}}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),C.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&C.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),C.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<e.length-1&&p&&C.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:e=>xe(t.key,e),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),S?.(t.key)},title:"Drag to resize • Double‑click to autosize",children:C.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},t.key+r)}),n>0&&C.jsx("div",{style:{width:n,height:a},className:"flex-none"}),t.map((e,r)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",o=!1!==e.sortable;return C.jsxs("div",{className:"flex-none border-r border-gray-200 dark:border-gray-700 last:border-r-0 relative",style:{width:e.width||100,height:a},"data-column-key":e.key,draggable:!0,onDragStart:t=>ke(e.key,t),onDragOver:t=>je(e.key,t),onDrop:()=>Ce(e.key),onDragEnd:Ne,children:[ve?.key===e.key&&C.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-blue-600 z-4",style:{left:"before"===ve?.position?0:void 0,right:"after"===ve?.position?0:void 0}}),C.jsx("div",{className:"px-3 h-full",children:C.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[C.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${o?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>o&&m(e.key),children:[C.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[me(e.key)&&C.jsx("div",{className:"w-2 h-2 bg-red-500 rounded-full shrink-0",title:"Filter applied"}),C.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100 text-sm truncate min-w-0",title:e.headerTooltip||e.header||"",children:e.header})]}),o&&s.key===e.key&&C.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:C.jsx("asc"===s.direction?A:F,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})})]}),(e.filterable||b||v)&&C.jsxs("div",{className:"relative "+(O===e.key||oe?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[C.jsx("button",{className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded shrink-0",onClick:t=>ge(e.key,t),"data-menu-trigger":!0,children:C.jsx(W,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"})}),O===e.key&&P&&C.jsxs("div",{className:"fixed bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg z-10 w-[320px] overflow-auto",style:{top:`${P.top}px`,left:`${P.left}px`,maxHeight:`${Math.max(160,P.containerRect.bottom-12-P.top)}px`},"data-column-menu":!0,children:[C.jsxs("div",{className:"flex items-center border-b border-gray-200 dark:border-gray-700",children:[C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("menu"),children:C.jsx(W,{className:"w-4 h-4"})}),e.filterable&&C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("filter"),children:C.jsx(V,{className:"w-4 h-4"})}),C.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===ee?"border-b-2 border-blue-600 text-blue-600":"text-gray-600 dark:text-gray-400"),onClick:()=>te("reorder"),children:C.jsx(L,{className:"w-4 h-4"})})]}),"menu"===ee&&C.jsxs("div",{className:"py-1",children:[b&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200",onClick:t=>{t.stopPropagation(),$(null);const r=!y.has(e.key);b?.(e.key,r)},children:y.has(e.key)?C.jsxs(C.Fragment,{children:[C.jsx(H,{className:"w-4 h-4"}),"Unpin Column"]}):C.jsxs(C.Fragment,{children:[C.jsx(G,{className:"w-4 h-4"}),"Pin Column"]})}),S&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{S?.(e.key),$(null)},children:"Autosize This Column"}),R&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{R?.(),$(null)},children:"Autosize All Columns"}),v&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 dark:hover:bg-gray-800 dark:text-gray-200 ",onClick:t=>{t.stopPropagation(),$(null);const r=j?.includes(e.key)||w===e.key;N?N(e.key,!r):k?.(r?null:e.key)},children:w===e.key||j?.includes(e.key)?C.jsxs(C.Fragment,{children:[C.jsx(Y,{className:"w-4 h-4"}),"Ungroup"]}):C.jsxs(C.Fragment,{children:[C.jsx(U,{className:"w-4 h-4"}),"Group by ",e.header]})}),M&&C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-gray-800 dark:text-gray-200",onClick:()=>{M?.(),$(null)},children:"Reset Columns"})]}),"filter"===ee&&C.jsxs("div",{className:"p-3 w-full",children:[C.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:C.jsx(vr,{column:e,data:h,value:re,onChange:t=>{ne(t),"server"!==z&&x(e.key,t)}})}),C.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[me(e.key)&&C.jsxs("button",{className:"px-3 py-1.5 text-sm bg-red-500 text-white rounded-md hover:bg-red-600 flex items-center gap-2 cursor-pointer",onClick:()=>{ne(null),x(e.key,null),$(null)},children:[C.jsx(_,{className:"w-3 h-3"})," Clear Filter"]}),C.jsx("button",{className:"px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded-md hover:bg-green-200 cursor-pointer dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50",onClick:()=>$(null),children:"Apply"}),"server"===z&&C.jsx("button",{className:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",onClick:()=>he(e.key),children:"Apply"})]})]}),"reorder"===ee&&C.jsxs("div",{className:"px-3 py-2",children:[C.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1 dark:text-gray-400",children:"Reorder Columns"}),C.jsx("div",{className:"max-h-60 overflow-auto border border-gray-200 rounded-md dark:border-gray-700",children:[...D.map(e=>T.find(t=>t.key===e)).filter(Boolean),...T.filter(e=>!D.includes(e.key))].map(e=>{const t=y.has(e.key);return C.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-white hover:bg-gray-50 border-b border-gray-100 last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-blue-50/40":""} dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-700`,draggable:!0,onDragStart:t=>Se(e.key,t),onDragOver:t=>Re(e.key,t),onDrop:()=>Me(e.key),onDragEnd:De,children:[ie?.key===e.key&&C.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-blue-600",style:{top:"before"===ie?.position?0:void 0,bottom:"after"===ie?.position?0:void 0}}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-gray-400 select-none dark:text-gray-500",children:"⋮⋮"}),C.jsxs("span",{className:"text-gray-800 truncate max-w-45 dark:text-gray-200",children:[e.header,t&&C.jsx("span",{className:"ml-1 text-[10px] text-blue-600 dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),C.jsx("div",{className:"text-[10px] text-gray-400 mt-1 dark:text-gray-500",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&p&&C.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-300 transition-colors group",onMouseDown:t=>xe(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),S?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:C.jsx("div",{className:"w-full h-full group-hover:bg-blue-400"})})]},e.key+r)}),o>0&&C.jsx("div",{style:{width:o,height:a},className:"flex-none"})]})})})};wr.displayName="GridHeader";const kr=s(wr);C.jsx(X,{className:"w-4 h-4"}),C.jsx(T,{className:"w-4 h-4"}),C.jsx($,{className:"w-4 h-4"});const jr=({row:e,position:t,isVisible:r,onClose:n,menuItems:a})=>{const s=o(null);l(()=>{if(!r)return;const e=e=>{s.current&&!s.current.contains(e.target)&&n()},t=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,n]);const c=i(()=>{if(!r||!a?.length)return t;const e=40*a.filter(e=>!e.separator).length+10*a.filter(e=>e.separator).length,n=window.innerWidth,o=window.innerHeight;let l=t.x,s=t.y;return l+100>n&&(l=n-100-10),l-100<0&&(l=110),s+e>o&&(s=s-e-10),{x:l,y:s}},[t,r,a]);return r&&a?.length?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"fixed inset-0 z-40",onClick:n}),C.jsx("div",{ref:s,role:"menu","aria-label":"Row actions",className:"fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 min-w-[180px]",style:{left:`${c.x}px`,top:`${c.y}px`,transform:"translate(-50%, 0)"},children:a.map(t=>t.separator?C.jsx("div",{role:"separator",className:"border-t border-gray-100 dark:border-gray-700 my-1"},t.id):C.jsxs("button",{role:"menuitem",onClick:()=>(t=>{t.disabled||t.separator||(t.onClick(e),n())})(t),disabled:t.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-left transition-colors "+(t.disabled?"text-gray-400 dark:text-gray-600 cursor-not-allowed":"delete"===t.id?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[t.icon&&C.jsx("span",{className:"shrink-0",children:t.icon}),C.jsx("span",{className:"flex-1",children:t.label})]},t.id))})]}):null},Cr=({column:e,row:t,initialValue:a,onCommit:s,onCancel:i})=>{const[c,d]=r(null==a?"":a),u=o(!1),g=o(!1),h=o(null),m=o(null),x=o(null);l(()=>{const e=m.current??h.current??x.current;e&&(e.focus(),"select"in e&&e.select())},[]);const f=n(()=>{if(u.current||g.current)return;g.current=!0;const t="number"===e.editorType&&""!==c?Number(c):c;s(t)},[c,e.editorType,s]),p=n(()=>{u.current=!0,i()},[i]),y=n(t=>{"Enter"===t.key&&"textarea"!==e.editorType?(t.preventDefault(),t.stopPropagation(),f()):"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),p()):"Tab"===t.key&&f()},[f,p,e.editorType]),b=n(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),f()):"Escape"===e.key?(e.preventDefault(),p()):"Tab"===e.key&&f()},[f,p]),v=n(()=>{f()},[f]),w="w-full h-full bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm outline-none border border-blue-500 dark:border-blue-400 rounded-sm px-2 focus:ring-2 focus:ring-blue-400/30 transition-shadow";return C.jsx("div",e.editor?{className:"absolute inset-0 z-10 flex items-center",children:e.editor(c,t,s,i)}:"textarea"===e.editorType?{className:"absolute inset-0 z-10 flex items-start p-0.5",children:C.jsx("textarea",{ref:m,value:c,rows:3,className:`${w} resize-none py-1`,onChange:e=>d(e.target.value),onKeyDown:b,onBlur:v})}:"select"===e.editorType?{className:"absolute inset-0 z-10 flex items-center p-0.5",children:C.jsxs("select",{ref:x,value:c,className:`${w} cursor-pointer`,onChange:e=>{d(e.target.value)},onKeyDown:y,onBlur:v,children:[C.jsx("option",{value:"",disabled:!0,hidden:!0,children:"Select..."}),e.editorOptions?.map(e=>C.jsx("option",{value:e.value,children:e.label},String(e.value)))]})}:{className:"absolute inset-0 z-10 flex items-center p-0.5",children:C.jsx("input",{ref:h,type:e.editorType??"text",value:c,className:w,onChange:e=>d(e.target.value),onKeyDown:y,onBlur:v})})},Nr=({data:e,columns:t,selectedRows:o,virtualized:l,virtualizedRange:a,rowHeight:s,selectable:c,isRowSelectable:d,onRowSelect:u,pinnedColumns:g=new Set,hvPadLeft:h=0,hvPadRight:m=0,rowStyle:x,globalFilter:f,onContextMenu:p,onRowDoubleClick:y,onRowClick:b,onCellClick:v,isCellFocused:w,isCellSelected:k,onCellContextMenu:j,onCellMouseDown:N,onCellMouseEnter:S,contextMenuItems:R,getRowId:M,isEditing:D,onStartEdit:E,onCommitEdit:A,onCancelEdit:F,editingInitialValue:L})=>{const z=i(()=>e.length*s,[e.length,s]),{leftOffsetByPinnedKey:I}=i(()=>{if(0===g.size)return{leftOffsetByPinnedKey:new Map};const e=t.filter(e=>g.has(e.key)).map(e=>e.key),r=new Map;for(const e of t)r.set(e.key,e.width||100);const n=new Map;let o=c?mr:0;for(const t of e)n.set(t,o),o+=r.get(t)||100;return{leftOffsetByPinnedKey:n}},[t,g,c]),T=i(()=>t.reduce((e,t)=>e+(g.has(t.key)?1:0),0),[t,g]),[O,$]=r(null),P=n((e,t)=>{e.preventDefault(),p?.({row:t,event:e}),R?.length&&$({row:t,x:e.clientX,y:e.clientY})},[p,R]),K=n(()=>$(null),[]);return C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{height:l?`${z}px`:"auto",position:"relative"},children:C.jsx("div",{style:{transform:l?`translate3d(0, ${a.offsetY}px, 0)`:"none",position:l?"absolute":"static",top:0,left:0,right:0},children:e.map((e,r)=>{const n=l?a.startIndex+r:r,i=x?.(e),p=((e,t)=>M?M(e):void 0!==e.id?e.id:("undefined"!=typeof window&&window.KD_DEV_LOG&&0===t&&console.warn("[KDGrid] No row IDs found. Either:\n 1. Add 'id' property to each row object, or\n 2. Provide 'getRowId' prop to extract a unique identifier.\n Using row index as fallback ID, but this may cause issues with pagination/filtering."),t??0))(e,n),R=n%2==0?"bg-white dark:bg-gray-900":"bg-gray-50 dark:bg-gray-800",z=o.has(p)?"bg-blue-50 dark:bg-blue-900/20":"";return C.jsxs("div",{className:`flex border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100 ${z||(i?"":R)}`,style:{height:`${s}px`,...i},onContextMenu:t=>P(t,e),onDoubleClick:t=>((e,t)=>{y?.({row:t,event:e})})(t,e),onClick:t=>((e,t)=>{b?.({row:t,event:e})})(t,e),children:[c&&C.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-inherit z-2 border-r border-gray-200 dark:border-gray-700",style:{width:mr},children:C.jsx("input",{type:"checkbox",checked:o.has(p),disabled:!!d&&!d(e),onChange:e=>u(p,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),u(p,!o.has(p)))},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":`Select row ${p}`,tabIndex:0})}),t.map((t,r)=>{const n=g.has(t.key),o=n&&I.get(t.key)||0,l=e[t.key];let a,s;if(t.cellRenderer?(a=t.cellRenderer(l,e),"string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l||(s=String(l))):t.formatter?(a=t.formatter(l),s=String(a)):(a="bigint"==typeof l?l.toString():l??"",s=a?String(a):void 0),f&&f.trim()&&!t.cellRenderer&&a){const e=String(a);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,f)&&(a=((e,t)=>{if(!t||!e)return e;const r=t.toLowerCase().trim(),n=e.toLowerCase();if(!r||!n.includes(r))return e;const o=[];let l=0,a=0,s=0;for(;-1!==(a=n.indexOf(r,l));)a>l&&o.push(e.slice(l,a)),o.push(C.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-600/40 text-current font-medium px-0.5 py-0 rounded-sm",style:{margin:0},children:e.slice(a,a+r.length)},"highlight-"+s++)),l=a+r.length;return l<e.length&&o.push(e.slice(l)),C.jsx(C.Fragment,{children:o})})(e,f))}s&&0===s.trim().length&&(s=void 0);const i="center"===t.align?"text-center":"right"===t.align?"text-right":"text-left",c="center"===t.align?"justify-center":"right"===t.align?"justify-end":"justify-start",d=t.noPadding?"p-0":"p-3",u="function"==typeof t.className?t.className(l,e):t.className||"",m="function"==typeof t.cellStyle?t.cellStyle(l,e):t.cellStyle||void 0,x="function"==typeof t.tooltip?t.tooltip(l,e):t.tooltip,y=C.jsxs("div",{title:x??("string"==typeof s?s:void 0),className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${d} text-sm flex items-center ${k?.(p,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?w?.(p,t.key)||D?.(p,t.key)?"sticky z-10 bg-inherit":"sticky z-1 bg-inherit":""} ${w?.(p,t.key)||D?.(p,t.key)?"relative z-10 box-border group/cell":"relative box-border group/cell"} ${i} ${c} ${u}`,style:{width:`${t.width||100}px`,left:n?`${o}px`:"auto",...m},onClick:r=>((e,t,r,n)=>{v?.({row:t,column:r,value:n,event:e})})(r,e,t,e[t.key]),onContextMenu:r=>{e._isGroupHeader||e._isGroupFooter||j&&(r.preventDefault(),r.stopPropagation(),j({row:e,column:t,value:e[t.key],displayValue:s??"",event:r}))},onMouseDown:r=>N?.({row:e,column:t,event:r}),onMouseEnter:r=>S?.({row:e,column:t,event:r}),onDoubleClick:r=>((e,t,r)=>{E?.(t,r)})(0,e,t),children:[w?.(p,t.key)&&C.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400 z-10"}),D?.(p,t.key)?C.jsx(Cr,{column:t,row:e,initialValue:L,onCommit:A,onCancel:F}):C.jsxs(C.Fragment,{children:[!1===t.wrapCellContent?C.jsx(C.Fragment,{children:a}):C.jsx("div",{className:"truncate w-full",children:a}),!!t.editable&&C.jsxs("svg",{className:"absolute bottom-1 right-1 w-2.5 h-2.5 text-blue-500 opacity-0 group-hover/cell:opacity-100 transition-opacity pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[C.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),C.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})]})]},`${t.key}-${r}`);return h>0&&r===T?C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{width:h},className:"flex-none"}),y]}):y}),m>0&&C.jsx("div",{style:{width:m},className:"flex-none"})]},`${p}-${n}`)})})}),O&&C.jsx(jr,{row:O.row,position:{x:O.x,y:O.y},isVisible:!0,onClose:K,menuItems:R})]})},Sr=(e,t)=>{if(e.isEditing!==t.isEditing)return!1;if(e.onCommitEdit!==t.onCommitEdit)return!1;if(e.editingInitialValue!==t.editingInitialValue)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.selectable!==t.selectable)return!1;if(e.virtualized!==t.virtualized)return!1;if(e.globalFilter!==t.globalFilter)return!1;if(e.virtualizedRange.startIndex!==t.virtualizedRange.startIndex)return!1;if(e.virtualizedRange.endIndex!==t.virtualizedRange.endIndex)return!1;if(e.virtualizedRange.offsetY!==t.virtualizedRange.offsetY)return!1;if(e.isCellSelected!==t.isCellSelected)return!1;if(e.isCellFocused!==t.isCellFocused)return!1;if(e.onCellMouseDown!==t.onCellMouseDown)return!1;if(e.onCellMouseEnter!==t.onCellMouseEnter)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.selectedRows.size!==t.selectedRows.size)return!1;if(e.pinnedColumns?.size!==t.pinnedColumns?.size)return!1;if(e.rowStyle!==t.rowStyle)return!1;if(e.columns.map(e=>e.key).join("|")!==t.columns.map(e=>e.key).join("|"))return!1;if(e.data.length!==t.data.length)return!1;if(e.data===t.data)return!0;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t;for(let n=0;n<t.data.length;n++)if(r(e.data[n],n,e.getRowId)!==r(t.data[n],n,t.getRowId))return!1;return!0};Nr.displayName="GridRows";const Rr=s(Nr,Sr),Mr=s(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:o,rowHeight:l=40,getHeaderLabel:a,getValueLabel:s,renderGroupActions:i})=>{const c=()=>{e._groupKey&&r(e._groupKey)};return C.jsxs("div",{className:"flex items-center bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-gray-800 hover:bg-blue-100/70 cursor-pointer sticky left-0 z-20 overflow-hidden",style:{minWidth:`${n+(o?mr:0)}px`,height:`${l}px`},onClick:c,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},children:[o&&C.jsx("div",{className:"w-12 flex items-center justify-center"}),C.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[C.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:C.jsx(t?M:R,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[e._groupColumnKey?`${a?a(e._groupColumnKey):e._groupColumnKey}: `:"",s&&e._groupColumnKey?s(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),C.jsxs("span",{className:"text-sm text-gray-600 bg-gray-200/70 px-2 py-1 rounded-full dark:text-gray-400",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&C.jsx("div",{className:"flex items-center px-4",onClick:e=>e.stopPropagation(),children:i({groupKey:e._groupKey||"",columnKey:e._groupColumnKey||"",groupValue:e._groupValue,rows:e._groupRows||[],count:e._groupCount||0,level:e._groupLevel||0})})]})]})}),Dr=({hasFilters:e=!1,hasData:t=!0,message:r,renderer:n})=>{if(n)return C.jsx(C.Fragment,{children:n()});const{title:o,description:l,icon:a}=r?{title:r,description:"",icon:Q}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:Z}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:Q}:{title:"No Data Available",description:"There is no data to display in this table.",icon:Q};return C.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[C.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mb-4",children:C.jsx(a,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),C.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:o}),C.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-md",children:l})]})},Er=()=>C.jsx("svg",{className:"w-10 h-10 mb-3 opacity-90 mx-auto text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:C.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Ar=()=>C.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center py-12 px-8 text-center select-none",children:[C.jsxs("div",{className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-red-100 dark:bg-red-900/30 px-3 py-1 text-xs font-semibold tracking-wide text-red-600 dark:text-red-400 uppercase",children:[C.jsx("span",{children:"⚠"}),"License Error"]}),C.jsx(Er,{}),C.jsx("h3",{className:"font-bold text-base text-red-800 dark:text-red-300 mb-1",children:"react-kd-grid: Invalid or Missing License Key"}),C.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400 max-w-xs mx-auto leading-relaxed",children:["Please provide a valid"," ",C.jsx("code",{className:"font-mono bg-red-100 dark:bg-red-900/40 px-1 py-0.5 rounded text-xs",children:"licenseKey"})," ","prop to unlock the grid."]})]}),Fr=({scrollRef:e,flatRows:t,columnsWithWidths:r,visibleColumns:n,totalWidth:o,selectable:l,dataToDisplay:a,pinnedAll:s,effectivePinnedColumns:i,hvPadLeftMemo:c,hvPadRightMemo:d,resolvedHeaderHeight:u,sortConfig:g,columnFilters:h,selectedRows:m,data:x,handleSort:f,setColumnFilter:p,handleSelectAll:y,handleColumnResize:b,handleColumnPin:v,addGroupKey:w,removeGroupKey:k,handleGroupBy:j,autosizeColumn:N,autosizeAllColumns:S,resetColumns:R,columnOrder:M,setColumnOrder:D,pagination:E,minResizeWidth:A,effectiveVirtualized:F,virtualizedRange:L,resolvedRowHeight:z,visibleData:I,isRowSelectable:T,handleRowSelect:O,rowStyle:$,globalFilter:P,onContextMenu:K,onRowDoubleClick:W,onRowClick:V,onCellClick:_,onCellContextMenu:B,isCellFocused:G,isCellSelected:H,handleCellMouseDown:U,handleCellMouseEnter:Y,contextMenuItems:q,getRowId:X,isEditing:J,startEdit:Z,commitEdit:Q,cancelEdit:ee,editingCell:te,safeGetRowId:re,toggleGroupExpansion:ne,containerWidth:oe,groupConfig:le,columns:se,renderGroupActions:ie,groupFooterVariant:ce,isValidLicense:de,infiniteScroll:ue,sentinelRef:ge,loading:he,showLoader:me,finishingLoader:xe,loaderTop:fe,noDataMessage:pe,noDataRenderer:ye,handleScroll:be,cellSelectionEnabled:ve})=>C.jsxs("div",{ref:e,role:"grid","aria-rowcount":t.length+1,"aria-colcount":r.length,"aria-label":"Data grid",className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(ve?"select-none":""),onScroll:be,children:[C.jsx("div",{className:"sticky top-0 z-3",children:C.jsx("div",{style:{minWidth:`${o+(l?mr:0)}px`},children:(()=>{const e=s,t=n.filter(e=>!i.has(e.key));return C.jsx(kr,{pinnedColumns:e,unpinnedColumns:t,hvPadLeft:c,hvPadRight:d,headerHeight:u,sortConfig:g,columnFilters:h,selectable:l,selectedRows:m,totalRows:a.length,data:x,onSort:f,onColumnFilter:p,onSelectAll:()=>y(m.size!==a.length),onColumnResize:b,pinnedKeySet:i,onColumnPin:v,groupable:!0,groupedByColumn:le.columnKeys[0]||null,groupedByColumns:le.columnKeys,onGroupToggle:(e,t)=>t?w(e):k(e),onGroupBy:j,onAutosizeColumn:N,onAutosizeAllColumns:S,onResetColumns:R,columnOrder:M,onColumnOrderChange:D,paginationMode:E?.enabled?E.mode:null,minResizeWidth:A})})()})}),C.jsx("div",{style:{minWidth:`${o+(l?mr:0)}px`,height:F?a.length*z+"px":"auto"},children:de&&C.jsx("div",{style:{transform:`translateY(${F?L.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let t=[];const a=()=>{if(!t.length)return;const r=`chunk-${re(t[0])}-${t.length}-${L.offsetY}`,o=null!=te&&t.some(e=>re(e)===te.rowId);e.push(C.jsx("div",{style:{opacity:he?.5:1},children:C.jsx(Rr,{data:t,columns:n,selectedRows:m,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:t.length-1,offsetY:0},rowHeight:z,selectable:l,isRowSelectable:T,onRowSelect:O,pinnedColumns:i,hvPadLeft:c,hvPadRight:d,rowStyle:$,globalFilter:P,onContextMenu:K,onRowDoubleClick:W,onRowClick:V,onCellClick:_,onCellContextMenu:B,isCellFocused:G,isCellSelected:H,onCellMouseDown:U,onCellMouseEnter:Y,contextMenuItems:q,getRowId:X,isEditing:J,onStartEdit:Z,onCommitEdit:Q,onCancelEdit:ee,editingInitialValue:o?te?.initialValue:void 0})},r)),t=[]};for(const n of I)if(n._isGroupHeader)a(),e.push(C.jsx(Mr,{row:n,isExpanded:le.expanded.has(n._groupKey||""),onToggle:ne,viewportWidth:oe,selectable:l,rowHeight:z,getHeaderLabel:e=>se.find(t=>t.key===e)?.header||e,getValueLabel:(e,t)=>{const r=se.find(t=>t.key===e);if(r?.formatter)try{return r.formatter(t)}catch(e){return String(t??"")}return String(t??"")},renderGroupActions:ie},n.id));else if(n._isGroupFooter)if(a(),"chips"===ce){const t=r.filter(e=>!!e.aggregate&&n._groupAgg&&void 0!==n._groupAgg[e.key]).map(e=>{const t=n._groupAgg[e.key],r=e.aggregateFormatter||e.formatter,o=r?(()=>{try{return r(t)}catch{return String(t)}})():String(t);return C.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-200 text-xs font-medium",title:`${e.header}`,children:[e.header,": ",o]},e.key)});e.push(C.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${o+(l?mr:0)}px`,height:`${z}px`},children:C.jsxs("div",{className:"flex items-center justify-between h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20 px-4",role:"contentinfo",children:[C.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:C.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No aggregates"})}),C.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},n.id))}else e.push(C.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 dark:bg-gray-900",style:{minWidth:`${o+(l?mr:0)}px`,height:`${z}px`},children:C.jsxs("div",{className:"flex h-full border-t border-blue-200 dark:border-blue-800 bg-blue-50/60 dark:bg-blue-900/20",role:"contentinfo",children:[l&&C.jsx("div",{style:{width:mr},className:"shrink-0"}),r.map(e=>{const t=e.width||100,r=n._groupAgg?n._groupAgg[e.key]:void 0,o=e.aggregateFormatter||e.formatter,l=void 0===r?"":o?(()=>{try{return o(r)}catch{return r}})():r;let a;if("number"==typeof l)a=Number.isInteger(l)?String(l):l.toFixed(2);else if(isNaN(l)||""===l||null===l)a=String(l??"");else{const e=Number(l);a=Number.isInteger(e)?String(e):e.toFixed(2)}return C.jsx("div",{className:"px-2 text-xs font-medium text-blue-800 dark:text-blue-200 flex items-center overflow-hidden",style:{width:t,minWidth:t,maxWidth:t},title:a?`${e.header}: ${a}`:void 0,children:C.jsx("span",{className:"truncate w-full",children:a})},`agg-cell-${n._groupKey}-${e.key}`)})]})},n.id));else t.push(n);return a(),e})()})}),de&&ue?.enabled&&C.jsxs("div",{style:{minWidth:`${o+(l?mr:0)}px`},children:[C.jsx("div",{ref:ge,style:{height:1},"aria-hidden":!0}),ue.isLoading&&C.jsx("div",{className:"flex items-center justify-center gap-3 py-4 text-sm text-gray-500 dark:text-gray-400","aria-live":"polite","aria-label":"Loading more rows",children:ue.loadingRenderer?ue.loadingRenderer():C.jsxs(C.Fragment,{children:[C.jsx(ae,{className:"animate-spin h-4 w-4 text-blue-500"}),C.jsx("span",{children:"Loading more rows…"})]})}),!ue.isLoading&&!ue.hasMore&&C.jsxs("div",{className:"flex items-center justify-center py-3 text-xs text-gray-400 dark:text-gray-600 gap-2",children:[C.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"}),"All rows loaded",C.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"})]})]}),me&&C.jsx("div",{className:`pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 ${xe?"opacity-0 transition-opacity duration-200":"opacity-100"} dark:bg-gray-700`,style:{top:fe},children:C.jsx("div",{className:"h-full w-1/3 bg-blue-500 animate-[slide_1.2s_linear_infinite]"})}),C.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:C.jsx("div",{className:"pointer-events-auto",children:de?he||0!==a.length?null:C.jsx(Dr,{hasFilters:!!P||Object.keys(h).length>0,hasData:x.length>0,message:pe,renderer:ye}):C.jsx(Ar,{})})})]}),Lr=s(({columns:e,data:t,selectable:r,rowHeight:n,pinnedColumns:o=new Set})=>{const l=i(()=>{const r={},n=e.filter(e=>e.footerAggregate);return 0===n.length||n.forEach(e=>{const n=t.map(t=>t[e.key]);let o=null;if("function"==typeof e.footerAggregate)try{o=e.footerAggregate(n)}catch(t){console.warn(`Error computing custom footer aggregate for column ${e.key}:`,t),o=null}else{const r=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),l=n.map(e=>{if("number"==typeof e)return e;if(null==e)return NaN;const t=String(e);if(r(t))return NaN;const n=parseFloat(t.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),a=()=>n.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));switch(e.footerAggregate){case"count":o=t.length;break;case"sum":l.length&&(o=l.reduce((e,t)=>e+t,0));break;case"avg":l.length&&(o=l.reduce((e,t)=>e+t,0)/l.length);break;case"min":if(l.length)o=Math.min(...l);else{const e=a();e.length&&(o=new Date(Math.min(...e)))}break;case"max":if(l.length)o=Math.max(...l);else{const e=a();e.length&&(o=new Date(Math.max(...e)))}break;default:o=null}}null!=o&&(r[e.key]=o)}),r},[e,t]);if(!e.some(e=>e.footerAggregate))return null;const a=e.reduce((e,t)=>e+t.width,0),s=i(()=>{const t=new Map,n=e.filter(e=>o.has(e.key)).map(e=>e.key);let l=r?mr:0;for(const r of n)t.set(r,l),l+=e.find(e=>e.key===r)?.width||100;return t},[e,o,r]);return C.jsxs("div",{className:"flex h-full",style:{minWidth:`${a+(r?mr:0)}px`,height:`${n}px`},children:[r&&C.jsx("div",{className:"w-12 p-3 border-r border-gray-200 dark:border-gray-700 flex items-center justify-center sticky left-0 bg-white dark:bg-gray-900 z-30",style:{height:`${n}px`},children:C.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Total"})},"select-footer-cell"),e.map(e=>{const t=e.width,r=l[e.key],a=e.footerAggregate&&void 0!==r;let i="";if(a){const t=e.footerAggregateFormatter||e.formatter;if(t)try{i=t(r)}catch{i=String(r)}else i="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const c=o.has(e.key),d=c&&s.get(e.key)||0;return C.jsx("div",{className:`border-r border-gray-200 dark:border-gray-700 last:border-r-0 ${e.noPadding?"p-0":"p-3"} text-sm flex items-center font-semibold text-gray-700 dark:text-gray-200 overflow-hidden ${"center"===e.align?"justify-center":"right"===e.align?"justify-end":"justify-start"} ${"center"===e.align?"text-center":"right"===e.align?"text-right":"text-left"} ${c?"sticky bg-white dark:bg-gray-900 z-20":""}`,style:{width:`${t}px`,minWidth:`${t}px`,maxWidth:`${t}px`,left:c?`${d}px`:"auto",height:`${n}px`},title:a?`${e.header}: ${i}`:void 0,children:a&&C.jsx("span",{className:"truncate w-full",children:i})},e.key)})]})}),zr=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:o,filteredDataLength:l,paginationMode:a="client",onPageChange:s,onPageSizeChange:i})=>{const{start:c,end:d,total:u}=(()=>{const r=e.enabled||"server"===a?e.totalRows||o:l||o;return{start:e.enabled?Math.min((t-1)*e.pageSize+1,r):1,end:e.enabled?Math.min(t*e.pageSize,r):r,total:r}})(),g="client"===a&&l&&l!==o;return C.jsx("div",{className:"px-3 sm:px-6 py-2 border-t border-gray-200 dark:border-gray-700 bg-linear-to-r from-white via-gray-50 to-white dark:from-gray-900 dark:via-gray-800 dark:to-gray-900",children:C.jsxs("div",{className:"flex flex-col xl:flex-row gap-4 xl:gap-6 xl:justify-between xl:items-center",children:[C.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 items-start sm:items-center",children:[C.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!e.enabled&&C.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-linear-to-r from-blue-500 to-blue-600 text-white shadow-lg ring-2 ring-blue-500/20",children:[C.jsx(Q,{className:"w-3 h-3"}),C.jsxs("span",{className:"font-bold",children:[u.toLocaleString()," ",1===u?"Record":"Records"]}),g&&C.jsxs("span",{className:"text-blue-100 font-normal",children:["(of ",o.toLocaleString(),")"]})]}),n>0&&C.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold bg-blue-500 text-white ring-2 ring-blue-500/20",children:[C.jsx(ne,{className:"w-3 h-3"}),C.jsxs("span",{children:[n.toLocaleString()," selected"]})]}),g&&C.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-linear-to-r from-warning/10 to-warning/5 text-warning border border-white dark:from-warning/10 dark:to-warning/5 dark:text-warning dark:border-warning/20",children:[C.jsx(X,{className:"w-3 h-3 dark:text-gray-300"}),C.jsx("span",{className:"dark:text-gray-300",children:"Filtered"})]}),e.enabled&&C.jsx("div",{className:"hidden sm:block text-sm text-gray-600 dark:text-gray-400 font-medium",children:C.jsxs("span",{className:"inline-flex items-center gap-1",children:[C.jsx("span",{children:"Showing"}),C.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:c.toLocaleString()}),C.jsx("span",{children:"-"}),C.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:d.toLocaleString()}),C.jsxs("span",{children:["of ",u.toLocaleString()]})]})})]}),e.enabled&&e.showPageSizeSelector&&C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:"Rows per page:"}),C.jsx("select",{value:e.pageSize,onChange:e=>i(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-1 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500",disabled:r,children:e.pageSizeOptions?.map(e=>C.jsx("option",{value:e,children:e},e))})]})]}),e.enabled&&C.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[r&&C.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-900/20 rounded-full border border-blue-200 dark:border-blue-800",children:[C.jsx(le,{className:"w-4 h-4 animate-spin text-primary"}),C.jsx("span",{className:"text-sm font-medium text-primary",children:"Loading..."})]}),C.jsx("div",{className:"sm:hidden text-sm text-gray-600 dark:text-gray-400 font-medium",children:C.jsxs("div",{className:"flex flex-col gap-1",children:[C.jsxs("span",{className:"inline-flex items-center gap-1",children:[C.jsx("span",{children:"Page"}),C.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:t.toLocaleString()}),C.jsx("span",{children:"of"}),C.jsx("span",{className:"px-2 py-0.5 bg-gray-100 dark:bg-gray-700 rounded-md font-bold text-gray-900 dark:text-gray-100",children:e.totalPages.toLocaleString()})]}),C.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-500",children:[c.toLocaleString()," - ",d.toLocaleString()," of"," ",u.toLocaleString()]})]})}),C.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[C.jsx("button",{onClick:()=>s(1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"First page","aria-label":"Go to first page",children:C.jsx(D,{className:"w-3.5 h-3.5"})}),C.jsx("button",{onClick:()=>s(t-1,e.pageSize),disabled:1===t||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Previous page","aria-label":"Go to previous page",children:C.jsx(S,{className:"w-3.5 h-3.5"})}),C.jsx("div",{className:"sm:hidden",children:C.jsx("select",{value:t,onChange:t=>s(Number(t.target.value),e.pageSize),className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-xl px-3 py-2 text-sm font-medium focus:ring-2 focus:ring-primary focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed shadow-sm min-w-[80px]",disabled:r,"aria-label":"Select page",children:Array.from({length:e.totalPages},(e,t)=>t+1).map(e=>C.jsx("option",{value:e,children:e},e))})}),C.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:(()=>{const n=[],o=e.totalPages,l=t,a="undefined"!=typeof window&&window.innerWidth>=768?7:5;if(o<=a)for(let e=1;e<=o;e++)n.push(e);else{const e=Math.floor(a/2)-1;if(l<=e+1){for(let e=1;e<=a-2;e++)n.push(e);n.push("ellipsis1"),n.push(o)}else if(l>=o-e){n.push(1),n.push("ellipsis1");for(let e=o-(a-3);e<=o;e++)n.push(e)}else{n.push(1),n.push("ellipsis1");for(let t=l-e;t<=l+e;t++)n.push(t);n.push("ellipsis2"),n.push(o)}}return n.map(t=>{if("string"==typeof t)return C.jsx("div",{className:"flex items-center justify-center w-8 h-8 text-gray-400 dark:text-gray-500 select-none","aria-hidden":"true",children:C.jsx("span",{className:"text-lg leading-none",children:"⋯"})},t);const n=t===l;return C.jsx("button",{onClick:()=>s(t,e.pageSize),disabled:r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold transition-all duration-200 focus:ring-2 focus:ring-primary/20 focus:outline-none cursor-pointer "+(n?"bg-linear-to-r from-primary to-primary text-white shadow-lg ring-2 ring-primary/20 transform scale-105 z-10 relative bg-blue-500":"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md disabled:opacity-40 disabled:cursor-not-allowed"),"aria-label":`Go to page ${t}`,"aria-current":n?"page":void 0,children:t},t)})})()}),C.jsx("button",{onClick:()=>s(t+1,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Next page","aria-label":"Go to next page",children:C.jsx(R,{className:"w-3.5 h-3.5"})}),C.jsx("button",{onClick:()=>s(e.totalPages,e.pageSize),disabled:t===e.totalPages||r,className:"inline-flex items-center justify-center w-8 h-8 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-200 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md focus:ring-2 focus:ring-primary/20 focus:border-primary",title:"Last page","aria-label":"Go to last page",children:C.jsx(E,{className:"w-3.5 h-3.5"})})]})]})]})})};zr.displayName="PaginationControls";const Ir=s(zr),Tr=({hasFooterAggregate:e,footerScrollRef:t,forwardWheelToBody:r,totalWidth:n,selectable:o,resolvedRowHeight:l,columnsWithWidths:a,flatRows:s,effectivePinnedColumns:i,infiniteScroll:c,paginationConfig:d,isServerLoading:u,selectedRowsCount:g,data:h,filteredData:m,pagination:x,handlePageChange:f,handlePageSizeChange:p})=>C.jsxs(C.Fragment,{children:[e&&C.jsx("div",{ref:t,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:r,children:C.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700",style:{minWidth:`${n+(o?mr:0)}px`,height:`${l}px`},children:C.jsx(Lr,{columns:a,data:s,selectable:o,rowHeight:l,pinnedColumns:i})})}),!c?.enabled&&C.jsx(Ir,{paginationConfig:d,currentPage:d.currentPage,isServerLoading:u,selectedRowsCount:g,totalDataLength:h.length,filteredDataLength:"server"===x?.mode?void 0:m.length,paginationMode:x.mode,onPageChange:f,onPageSizeChange:p})]}),Or=({data:e,columns:t})=>{const[l,a]=r(""),[s,u]=r({}),[g,h]=c(),[,m]=c(),x=n(e=>{h(()=>a(e))},[]),f=d(l),p=n((e,t,r,n)=>{const o=e[t];switch(r.type){case"text":{const e=String(o||"").toLowerCase(),t=String(r.value||"").toLowerCase();switch(r.operator){case"contains":default:return e.includes(t);case"equals":return e===t;case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t)}}case"number":{const e=parseFloat(o),t=parseFloat(String(r.value));if(isNaN(e)||isNaN(t))return!1;switch(r.operator){case"equals":default:return e===t;case"gt":return e>t;case"gte":return e>=t;case"lt":return e<t;case"lte":return e<=t;case"between":{const n=parseFloat(String(r.secondValue??""));return!isNaN(n)&&e>=t&&e<=n}}}case"date":{const e=n?.filterTs,t=n?.secondTs;if(void 0===e||isNaN(e))return!1;const l=new Date(o);if(isNaN(l.getTime()))return!1;const a=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();switch(r.operator){case"equals":default:return a===e;case"gt":return a>e;case"gte":return a>=e;case"lt":return a<e;case"lte":return a<=e;case"between":return void 0!==t&&!isNaN(t)&&a>=e&&a<=t}}case"boolean":return Boolean(o)===Boolean(r.value);case"multiselect":{const e=e=>null==e||""===e||"string"==typeof e&&""===e.trim()?null:e;return(Array.isArray(r.value)?r.value:[r.value]).map(e).includes(e(o))}default:return!0}},[]),y=o(new WeakMap),b=o(0),v=n(()=>{b.current>5e3&&(y.current=new WeakMap,b.current=0)},[]),w=i(()=>{v();const r=Object.keys(s).length>0,n=!!f;if(!r&&!n)return e;const o=f.toLowerCase(),l=y.current;let a=e;if(r)for(const[e,t]of Object.entries(s)){if(!t)continue;let r;if("date"===t.type){const e=t.value instanceof Date?t.value:new Date(String(t.value??"")),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let o;if(t.secondValue){const e=t.secondValue instanceof Date?t.secondValue:new Date(String(t.secondValue??""));o=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:o}}if(a=a.filter(n=>p(n,e,t,r)),0===a.length)break}if(n&&a.length>0){const e=t.filter(e=>!1!==e.visible);a=a.filter(t=>{let r=l.get(t);return null==r&&(r=e.map(e=>{const r=t[e.key];if(null==r)return"";if("string"==typeof r)return r.toLowerCase();if("number"==typeof r||"boolean"==typeof r)return String(r).toLowerCase();const n=String(r);return n.length>100?n.slice(0,100):n}).join("|"),b.current<5e3&&(l.set(t,r),b.current++)),r.includes(o)})}return a},[e,s,f,t,p,v]),k=n((e,t)=>{m(()=>{u(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),j=n(e=>{k(e,null)},[k]),C=n(()=>{h(()=>a("")),m(()=>u({})),y.current=new WeakMap,b.current=0},[]),N=n(()=>{let e=0;return f&&e++,e+Object.keys(s).length},[f,s]);return{globalFilter:l,setGlobalFilter:x,columnFilters:s,filteredData:w,setColumnFilter:k,clearColumnFilter:j,clearAllFilters:C,getActiveFilterCount:N,isFilterPending:g}};function $r(){const e=self,t=(e,t)=>{if(!e||0===e.length)return e;if(!t?.key)return e;const{key:r,direction:n}=t,o="asc"===n?1:-1;return[...e].sort((e,t)=>{const n=e?.[r],l=t?.[r];return null==n&&null==l?0:null==n?-1*o:null==l?1*o:"number"==typeof n&&"number"==typeof l?(n-l)*o:String(n).localeCompare(String(l))*o})};e.onmessage=r=>{const n=r.data;if(n&&"process"===n.type)try{const{rows:r,sort:o}=n.payload;e.postMessage({type:"result",payload:{rows:t(r,o??null)}})}catch{e.postMessage({type:"result",payload:{rows:n.payload?.rows??[]}})}}}function Pr(e){const t=e?.enabled??!0,r=o(null),a=o(null),s=o(t);l(()=>{s.current=t,!t&&r.current&&(r.current.terminate(),r.current=null,a.current&&(a.current.reject(new DOMException("Worker disabled","AbortError")),a.current=null))},[t]);const i=o(()=>null);return i.current=()=>{if(!s.current)return null;if(r.current)return r.current;const e=`(${$r.toString()})()`,t=new Blob([e],{type:"application/javascript"}),n=URL.createObjectURL(t),o=new Worker(n);return URL.revokeObjectURL(n),o.onmessage=e=>{"result"===e.data?.type&&(a.current?.resolve(e.data.payload.rows),a.current=null)},r.current=o,o},l(()=>()=>{r.current?.terminate(),r.current=null,a.current&&(a.current.reject(new DOMException("Unmounted","AbortError")),a.current=null)},[]),{process:n((e,t)=>{if(!s.current)return Promise.resolve(e);const r=i.current();return r?new Promise((n,o)=>{a.current&&a.current.reject(new DOMException("Superseded by newer sort","AbortError")),a.current={resolve:n,reject:o},r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const Kr="Unknown",Wr=e=>e.join("|"),Vr=(e,t,r,n,o)=>{const l=t[r],a=new Map;for(const t of e){const e=String(t[l]??Kr),r=a.get(e);r?r.push(t):a.set(e,[t])}for(const[e,s]of a.entries()){const a=[...n,`${l}=${e}`];o.add(Wr(a)),r<t.length-1&&Vr(s,t,r+1,a,o)}},_r=(e,t)=>{const r={};for(const n of t){if(!n.aggregate)continue;const t=e.map(e=>e[n.key]);let o=null;if("function"==typeof n.aggregate)try{o=n.aggregate(t)}catch(e){o=null}else{const e=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),r=t.map(t=>{if("number"==typeof t)return t;if(null==t)return NaN;const r=String(t);if(e(r))return NaN;const n=parseFloat(r.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),l=()=>t.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));if("sum"===n.aggregate||"avg"===n.aggregate)r.length&&(o="sum"===n.aggregate?r.reduce((e,t)=>e+t,0):r.reduce((e,t)=>e+t,0)/r.length);else if("min"===n.aggregate||"max"===n.aggregate)if(r.length)o="min"===n.aggregate?Math.min(...r):Math.max(...r);else{const e=l();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);o=new Date(t)}}}null!=o&&(r[n.key]=o)}return r},Br=({data:e,pagination:t})=>{const[o,a]=r(1),[s,c]=r(t?.pageSize||50),[d,u]=r(!1);l(()=>{const e=t?.pageSize;e&&e!==s&&(c(e),a(1))},[t?.pageSize]);const g=n(()=>{a(1)},[]),h=i(()=>{const r=!1!==t?.enabled,n="server"===(t?.mode||"client")?t?.serverConfig?.totalRows||0:e.length,l=Math.ceil(n/s);return{enabled:r,pageSize:s,currentPage:o,totalPages:l,totalRows:n,showPageSizeSelector:!1!==t?.showPageSizeSelector,pageSizeOptions:t?.pageSizeOptions||[25,50,100,200,500]}},[t,s,o,e.length]),m=i(()=>{if(!h.enabled||"server"===t?.mode)return e;const r=(o-1)*s;return e.slice(r,r+s)},[e,o,s,h.enabled,t?.mode]),x=n(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageChange){u(!0);try{await t.serverConfig.onPageChange(e,s)}finally{u(!1)}}a(e)},[t,s]),f=n(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageSizeChange){u(!0);try{await t.serverConfig.onPageSizeChange(e)}finally{u(!1)}}c(e),a(1)},[t]);return{currentPage:o,resetPage:g,paginationConfig:h,paginatedData:m,isServerLoading:d,handlePageChange:x,handlePageSizeChange:f}},Gr=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},Hr=({data:e,selectedRowIds:t,onRowSelect:o,getRowId:a})=>{const s=n((e,t)=>a?a(e):void 0!==e.id?e.id:t??0,[a]),[c,d]=r(()=>new Set(t?Array.from(t):[]));l(()=>{t&&d(e=>{const r=new Set(Array.from(t));return Gr(e,r)?e:r})},[t]);const u=i(()=>{const t=new Map;return e.forEach((e,r)=>t.set(s(e,r),e)),t},[e,s]);l(()=>{if(0===c.size)return;let e=!1;for(const t of c)if(!u.has(t)){e=!0;break}e&&d(e=>{const t=new Set;return e.forEach(e=>{u.has(e)&&t.add(e)}),Gr(e,t)?e:t})},[u]);const g=n((e,t)=>{if(d(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}),o){const t=u.get(e);t&&o(t)}},[u,o]),h=n(t=>{d(t?new Set(e.map((e,t)=>s(e,t))):new Set)},[e,s]);return{selectedRows:c,handleRowSelect:g,handleSelectAll:h}},Ur=({data:e,virtualized:t=!0,rowHeight:a=40,overscan:s=10,height:c})=>{const d=o(null),[u,g]=r(0),h=o(null),m=o(0),[x,f]=r(c);l(()=>{const e=d.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&f(t)});t.observe(e);const r=e.clientHeight;return r>0&&f(r),()=>t.disconnect()},[]),l(()=>{c>0&&f(c)},[c]);const p=i(()=>{if(!t)return{startIndex:0,endIndex:e.length-1,offsetY:0};const r=Math.max(1,Math.ceil(x/a)),n=Math.max(s,Math.min(r,20)),o=Math.max(0,Math.floor(u/a)-n),l=Math.ceil(x/a);return{startIndex:o,endIndex:Math.min(e.length-1,o+l+2*n),offsetY:o*a}},[u,x,e.length,a,s,t]),y=i(()=>t?e.slice(p.startIndex,p.endIndex+1):e,[e,p,t]),b=e.length*a,v=n(e=>{m.current=e.target.scrollTop,null==h.current&&(h.current=requestAnimationFrame(()=>{h.current=null,g(m.current)}))},[]);return l(()=>()=>{null!=h.current&&cancelAnimationFrame(h.current)},[]),{scrollRef:d,virtualizedRange:p,visibleData:y,totalHeight:b,handleScroll:v}};let Yr=null;function qr({scrollRef:e,rowIndexById:t,colIndexByKey:r,columnsWithWidths:o,resolvedRowHeight:l,selectable:a}){return{scrollToRow:n(r=>{const n=e.current;if(!n)return;const o=t.get(r);null!=o&&n.scrollTo({top:o*l,behavior:"smooth"})},[e,t,l]),scrollToColumn:n(t=>{const n=e.current;if(!n)return;const l=r.get(t);if(null==l)return;const s=o[l]?.width||100;let i=a?mr:0;for(let e=0;e<l;e++)i+=o[e]?.width||100;const c=i+s,d=n.clientWidth;if(i<n.scrollLeft)n.scrollTo({left:i,behavior:"smooth"});else if(c>n.scrollLeft+d)n.scrollTo({left:c-d,behavior:"smooth"});else{const e=Math.max(0,i-Math.max(0,(d-s)/2));n.scrollTo({left:e,behavior:"smooth"})}},[e,r,o,a])}}const Xr=new Uint32Array([439041101,1584364171,2626518639,1514880045]);function Jr(e,t){let r=e[0],n=e[1],o=3337565984;for(let e=0;e<32;e++)n=n-((r<<4)+t[2]^r+o^(r>>>5)+t[3])>>>0,r=r-((n<<4)+t[0]^n+o^(n>>>5)+t[1])>>>0,o=o-2654435769>>>0;e[0]=r,e[1]=n}let Zr;function Qr(e){Zr=e}const en=()=>!0,tn=u(function({data:e,columns:t,getRowId:a,height:s,density:c="md",headerDensity:d,headerHeight:u,minResizeWidth:h,onDensityChange:m,showDensityControl:x=!1,onRowSelect:f,onSelectedRowsChange:p,selectable:y=!1,isRowSelectable:b,showToolbar:v=!0,showExport:w=!1,filterable:k=!0,groupable:j=!1,virtualized:N=!0,rowHeight:S,overscan:R=6,rowStyle:M,onContextMenu:D,onRowDoubleClick:E,onRowClick:A,onCellClick:F,onCellContextMenu:L,cellFocusEnabled:z=!1,onCellFocusChange:I,onCellEdit:T,onCellEditStart:O,cellSelectionEnabled:$=!1,canSelectCell:P=en,onCellSelectionChange:K,pagination:W={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:V=300,loading:_=!1,onFilterChange:B,onSort:G,onColumnConfigChange:H,initialColumnConfig:U,toolbarLeft:Y,toolbarRight:q,groupBarVisibility:X="auto",groupFooterVariant:J="chips",onCopyCells:Z,selectedRowIds:Q,performanceConfig:ee={},exportOptions:te,renderGroupActions:re,contextMenuItems:ne,infiniteScroll:oe,licenseKey:le,noDataMessage:ae,noDataRenderer:se},ie){const ce=o(null),[de,ue]=r(0);l(()=>{const e=ce.current;if(!e)return;const t=()=>ue(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[ge,he]=r(c);l(()=>{he(c)},[c]);const me=i(()=>({sm:28,md:40,lg:56}),[]),xe=i(()=>null!=S?S:me[ge],[S,ge,me]),fe=i(()=>null!=u?u:me[d??"md"],[u,d,me]),{globalFilter:pe,columnFilters:ye,filteredData:be,setGlobalFilter:ve,setColumnFilter:we,clearAllFilters:ke}=Or({data:e,columns:t}),[je,Ce]=r({key:null,direction:null}),Ne=o(null),Se=o(null),Re=n(e=>{let t=e,r="asc";je.key!==e?(t=e,r="asc"):"asc"===je.direction?r="desc":"desc"===je.direction?(t=null,r=null):r="asc",Ce({key:t,direction:r}),G&&G(t??"",r)},[G,je.key,je.direction]),{process:Me}=Pr({enabled:!0}),[De,Ee]=r(be),Ae=ee?.sortWorkerThreshold??5e3;l(()=>{let e=!1;if(!je.key)return void Ee(be);const t=be;if(t.length<Ae){const e="asc"===je.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[je.key],o=r?.[je.key];return null==n&&null==o?0:null==n?-1*e:null==o?1*e:"number"==typeof n&&"number"==typeof o?(n-o)*e:String(n).localeCompare(String(o))*e});return void Ee(r)}return Me(t,{key:je.key,direction:je.direction}).then(t=>{e||Ee(t)}),()=>{e=!0}},[be,je,Me,Ae]);const Fe=i(()=>oe?.enabled?{enabled:!1}:W,[oe?.enabled,W?.enabled,W?.mode,W?.pageSize,W?.showPageSizeSelector,W?.pageSizeOptions,W?.serverConfig?.enabled,W?.serverConfig?.totalRows,W?.serverConfig?.loading,W?.serverConfig?.onPageChange,W?.serverConfig?.onPageSizeChange]),{paginationConfig:Le,paginatedData:ze,isServerLoading:Ie,handlePageChange:Te,handlePageSizeChange:Oe,resetPage:$e,currentPage:Pe}=Br({data:De,pagination:Fe}),Ke=W?.enabled?"server"===W.mode?e:ze:De,{groupConfig:We,displayData:Ve,handleGroupBy:_e,addGroupKey:Be,removeGroupKey:Ge,setGroupKeys:He,toggleGroupExpansion:Ue,isGrouped:Ye,expandAllGroups:qe,collapseAllGroups:Xe}=(({data:e,columns:t})=>{const[n,o]=r({columnKeys:[],expanded:new Set}),a=i(()=>{const r=n.columnKeys;if(!r.length)return e;const o=[],l=(e,a,s)=>{const i=r[a],c=new Map;for(const t of e){const e=String(t[i]??Kr),r=c.get(e);r?r.push(t):c.set(e,[t])}const d=Array.from(c.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[e,c]of d){const d=[...s,`${i}=${e}`],u=Wr(d);if(o.push({id:`group-${u}`,_isGroupHeader:!0,_groupKey:u,_groupCount:c.length,_groupLevel:a,_groupColumnKey:i,_groupValue:e,_groupRows:c}),!n.expanded.has(u))continue;if(a<r.length-1)l(c,a+1,d);else for(const e of c)o.push(e);const g=_r(c,t);o.push({id:`group-footer-${u}`,_isGroupFooter:!0,_groupKey:u,_groupLevel:a,_groupAgg:g})}};return l(e,0,[]),o},[e,t,n.columnKeys,n.expanded]);return l(()=>{if(!n.columnKeys.length)return;const t=new Set;Vr(e,n.columnKeys,0,[],t);let r=!1;if(t.size!==n.expanded.size)r=!0;else for(const e of t)if(!n.expanded.has(e)){r=!0;break}r&&o(e=>({...e,expanded:t}))},[n.columnKeys,e]),{groupConfig:n,displayData:a,handleGroupBy:e=>{o({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{o(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{o(t=>{const r=t.columnKeys.filter(t=>t!==e),n=new Set;for(const r of t.expanded)r.includes(`${e}=`)||n.add(r);return{columnKeys:r,expanded:n}})},setGroupKeys:e=>{o({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{o(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const t=n.columnKeys;if(!t.length)return;const r=new Set;Vr(e,t,0,[],r),o(e=>({...e,expanded:r}))},collapseAllGroups:()=>{o(e=>({...e,expanded:new Set}))},isGrouped:n.columnKeys.length>0}})({data:Ke,columns:t}),{columnVisibility:Je,pinnedColumns:Ze,handleColumnResize:Qe,handleColumnPin:et,handleColumnVisibilityChange:tt,setColumnOrder:rt,autosizeColumn:nt,autosizeAllColumns:ot,resetColumns:lt,columnsWithWidths:at,pinnedAll:st,unpinnedAll:it,effectivePinnedColumns:ct,columnOrder:dt}=(({columns:e,data:t,initialColumnConfig:a,onColumnConfigChange:s,setSortConfig:c,setGroupKeys:d,setDensity:u,setGlobalFilter:g,setColumnFilter:h,sortConfig:m,groupConfig:x,globalFilter:f,columnFilters:p,density:y,containerWidth:b,selectable:v})=>{const[w,k]=r(()=>{const t={};return e.forEach(e=>{t[e.key]=e.width||100}),t}),j=o(e.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),C=o(e.map(e=>e.key)),[N,S]=r(()=>C.current.slice()),[R,M]=r(new Set),[D,E]=r(()=>{const t={};return e.forEach(e=>{t[e.key]=!0}),t}),A=i(()=>new Set(R),[R]),F=i(()=>{if(0===e.length)return[];const t=new Map(N.map((e,t)=>[e,t])),r=e.filter(e=>!1!==D[e.key]).sort((e,r)=>(t.get(e.key)||0)-(t.get(r.key)||0)).map(e=>{const t=w[e.key]??e.width,r=Number.isFinite(Number(t))?Number(t):100,n=!1!==e.sortable;return{...e,width:r,sortable:n}}),n=Math.max(0,b-(v?mr:0)),o=r.reduce((e,t)=>e+t.width,0),l=new Map;if(n>o){const e=r.filter(e=>e.flex);if(e.length>0){const t=n-o,r=e.reduce((e,t)=>e+Math.max(0,!0===t.flex?1:"number"==typeof t.flex?t.flex:1),0);if(r>0)for(const n of e)l.set(n.key,Math.max(n.minWidth??0,Math.min(n.maxWidth??Number.POSITIVE_INFINITY,n.width+t*(!0===n.flex?1:"number"==typeof n.flex?n.flex:1)/r)))}}const a=e=>l.has(e.key)?{...e,width:l.get(e.key)}:e,s=[],i=[];for(const e of r)A.has(e.key)?s.push(a(e)):i.push(a(e));if(x.columnKeys&&x.columnKeys.length>0){const e=new Map(x.columnKeys.map((e,t)=>[e,t]));i.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...s,...i]},[e,w,A,D,N,x.columnKeys,b,v]),L=i(()=>F.filter(e=>A.has(e.key)),[F,A]),z=i(()=>F.filter(e=>!A.has(e.key)),[F,A]),I=n((e,t)=>{k(r=>({...r,[e]:t}))},[]),T=n((e,t)=>{M(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),O=n((e,t)=>{E(r=>({...r,[e]:t}))},[]),$=n(e=>{if(null==e)return 0;const t="string"==typeof e?e:String(e);if(!t)return 0;try{if("undefined"!=typeof document){if(!Yr){const e=document.createElement("canvas");Yr=e.getContext("2d"),Yr&&(Yr.font="13px Inter, ui-sans-serif, system-ui, sans-serif")}if(Yr)return Math.ceil(Yr.measureText(t).width)}}catch{}return 8*t.length},[]),P=n(r=>{const n=e.find(e=>e.key===r);if(!n)return;const o=$(n.header),l=t.slice(0,500);let a=0;for(const e of l)a=Math.max(a,$(e[r]));const s=Math.max(60,Math.min(500,Math.max(o,a)+32));k(e=>({...e,[r]:s}))},[e,t,$]),K=n(()=>{e.forEach(e=>P(e.key))},[e,P]),W=n(()=>{k({...j.current}),M(new Set),E(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),S(C.current.slice())},[]);return l(()=>{if(!a)return;const t=new Set(e.map(e=>e.key));if(a.columnWidths){const e=Object.fromEntries(Object.entries(a.columnWidths).filter(([e])=>t.has(e)));k(t=>({...t,...e}))}if(a.columnVisibility){const e=Object.fromEntries(Object.entries(a.columnVisibility).filter(([e])=>t.has(e)));E(t=>({...t,...e}))}if(a.pinnedColumns){const e=a.pinnedColumns.filter(e=>t.has(e));M(new Set(e))}if(a.sortConfig){const e="asc"===a.sortConfig.direction||"desc"===a.sortConfig.direction?a.sortConfig.direction:null;c({key:e?a.sortConfig.key:null,direction:e})}if(a.filters){g(a.filters.globalFilter||"");const e=Object.entries(a.filters.columnFilters||{}).filter(([e])=>t.has(e));for(const[t,r]of e)h(t,r)}if(a.columnOrder&&a.columnOrder.length){const r=a.columnOrder.filter(e=>t.has(e)),n=e.map(e=>e.key).filter(e=>!r.includes(e));S([...r,...n])}a.groupConfig?.columnKeys&&a.groupConfig.columnKeys.length&&d(a.groupConfig.columnKeys),a.density&&u(a.density)},[]),l(()=>{if(!s)return;const e=setTimeout(()=>{s({columnWidths:w,columnVisibility:D,pinnedColumns:Array.from(R),sortConfig:m,groupConfig:{columnKeys:x.columnKeys},filters:{globalFilter:f,columnFilters:p},columnOrder:N,density:y})},200);return()=>clearTimeout(e)},[s,w,D,R,m,x,f,p,N,y]),{columnWidths:w,columnOrder:N,pinnedColumns:R,columnVisibility:D,columnsWithWidths:F,pinnedAll:L,unpinnedAll:z,effectivePinnedColumns:A,handleColumnResize:I,handleColumnPin:T,handleColumnVisibilityChange:O,setColumnOrder:S,autosizeColumn:P,autosizeAllColumns:K,resetColumns:W,setColumnWidths:k,setPinnedColumns:M,setColumnVisibility:E}})({columns:t,data:e,initialColumnConfig:U,onColumnConfigChange:H,setSortConfig:Ce,setGroupKeys:He,setDensity:he,setGlobalFilter:ve,setColumnFilter:we,sortConfig:je,groupConfig:We,globalFilter:pe,columnFilters:ye,density:ge,containerWidth:de,selectable:y}),ut=Ye?Ve:Ke,gt=n(e=>a?a(e):void 0!==e.id?e.id:-1,[a]),{colIndexByKey:ht,colByKey:mt,flatRows:xt,rowIndexById:ft,rowById:pt,totalWidth:yt,columnKeys:bt,hasFooterAggregate:vt}=(({dataToDisplay:e,columnsWithWidths:t,getRowId:r})=>{const n=i(()=>{const e=new Map;return t.forEach((t,r)=>e.set(t.key,r)),e},[t]),o=i(()=>{const e=new Map;return t.forEach(t=>e.set(t.key,t)),e},[t]),l=i(()=>e.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[e]),a=i(()=>{const e=new Map;return l.forEach((t,n)=>{const o=r?r(t):void 0!==t.id?t.id:n;e.set(o,n)}),e},[l,r]),s=i(()=>{const e=new Map;return l.forEach((t,n)=>{const o=r?r(t):void 0!==t.id?t.id:n;e.set(o,t)}),e},[l,r]),c=i(()=>t.reduce((e,t)=>e+(t.width||100),0),[t]),d=i(()=>t.map(e=>e.key),[t]),u=i(()=>t.some(e=>e.footerAggregate),[t]);return{colIndexByKey:n,colByKey:o,flatRows:l,rowIndexById:a,rowById:s,totalWidth:c,columnKeys:d,hasFooterAggregate:u}})({dataToDisplay:ut,columnsWithWidths:at,getRowId:gt}),{selectedRows:wt,handleRowSelect:kt,handleSelectAll:jt}=Hr({data:ut,onRowSelect:f,selectedRowIds:Q,getRowId:gt}),Ct=o(p);l(()=>{Ct.current=p},[p]),l(()=>{Ct.current&&Ct.current(wt)},[wt]);const{exportData:Nt}=(({data:e,columns:t,selectedRows:r,filename:o="data",columnVisibility:l})=>{const a=n(()=>l?t.filter(e=>!1!==l[e.key]):t,[t,l]),s=n((e,t,r)=>{const n=new Blob([e],{type:r}),o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)},[]),i=n((e,t)=>{const r=a(),n=r.map(e=>e.header).join(","),o=e.map(e=>r.map(t=>{const r=String(e[t.key]??"");return r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r}).join(","));s([n,...o].join("\n"),`${t}.csv`,"text/csv")},[a,s]),c=n((e,t)=>{const r=a(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});s(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[a,s]),d=n(async(e,t)=>{const r=a(),[{default:n},{saveAs:o}]=await Promise.all([import("exceljs"),import("file-saver")]),l=new n.Workbook,s=l.addWorksheet("Data"),i=e.slice(0,50),c=e=>{if(null==e)return"";if("number"==typeof e||"boolean"==typeof e||e instanceof Date)return e;const t=String(e);if(/[a-zA-Z]/.test(t))return t;if(/^-?[\d,]+\.?\d*$/.test(t.trim())){const e=Number(t.replace(/,/g,""));if(Number.isFinite(e))return e}return t};s.columns=r.map(e=>{const t=e.header||e.key;let r=t?.length||10;for(const t of i){const n=null==t[e.key]?"":String(t[e.key]);n.length>r&&(r=n.length)}return{header:t,key:e.key,width:Math.max(8,Math.min(50,Math.ceil(1.1*r)))}});for(const t of e){const e={};for(const n of r)e[n.key]=c(t[n.key]);s.addRow(e)}s.getRow(1).font={bold:!0},s.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,s.rowCount),column:r.length}};const d=await l.xlsx.writeBuffer();o(new Blob([d],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[a]);return{exportData:n((t,n=!1)=>{const l=n&&r&&r.size>0?e.filter(e=>r.has(e.id)):e,a=n&&r&&r.size>0?`${o}_selected_${r.size}_rows`:o;switch(t){case"csv":i(l,a);break;case"json":c(l,a);break;case"xlsx":d(l,a);break;default:console.warn(`[KDGrid] Unsupported export format: ${t}`)}},[e,r,o,i,c,d]),canExportSelected:!!(r&&r.size>0),selectedCount:r?.size??0}})({data:Ke,columns:t,selectedRows:wt,filename:te&&te.filename||"grid-data",columnVisibility:Je}),St=n((e,t)=>{const r=Array.from(wt||[]);"server"===te?.exportMode&&"function"==typeof te?.onServerExport?te.onServerExport(e,t,r):Nt(e,t)},[te,Nt,wt]),Rt=i(()=>N&&ut.length>V,[N,ut.length,V]),{scrollRef:Mt,virtualizedRange:Dt,visibleData:Et,handleScroll:At}=Ur({data:ut,virtualized:Rt,rowHeight:xe,overscan:R,height:s||400}),{sentinelRef:Ft}=function({enabled:e,onLoadMore:t,threshold:r=200,rootRef:n}){const a=o(null),s=o(t);return l(()=>{s.current=t},[t]),l(()=>{if(!e)return;const t=a.current;if(!t)return;const o=new IntersectionObserver(e=>{e[0].isIntersecting&&s.current()},{root:n?.current||null,rootMargin:`0px 0px ${r}px 0px`,threshold:0});return o.observe(t),()=>o.disconnect()},[e,r,n]),{sentinelRef:a}}({enabled:oe?.enabled??!1,hasMore:oe?.hasMore??!1,isLoading:oe?.isLoading??!1,onLoadMore:()=>{!oe?.isLoading&&oe?.hasMore&&oe.onLoadMore()},threshold:oe?.threshold??250,rootRef:Mt}),{hScrollLeft:Lt,viewportWidth:zt,forwardWheelToBody:It}=(({scrollRef:e,footerScrollRef:t,hasFooterAggregate:a})=>{const[s,i]=r(0),c=o(0),d=o(null),u=n(e=>{c.current=e,null==d.current&&(d.current=requestAnimationFrame(()=>{d.current=null,i(c.current)}))},[]),[g,h]=r(0);l(()=>{const t=e.current;if(!t)return;const r=()=>h(t.clientWidth||0);r();const n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e]),l(()=>{const r=e.current;if(!r)return;let n=!1;const o=()=>{if(n)return;n=!0;const e=t.current;e&&e.scrollLeft!==r.scrollLeft&&(e.scrollLeft=r.scrollLeft),u(r.scrollLeft),requestAnimationFrame(()=>{n=!1})};return r.addEventListener("scroll",o,{passive:!0}),t.current&&(t.current.scrollLeft=r.scrollLeft),()=>{r.removeEventListener("scroll",o)}},[e,a,u]);const m=n(t=>{const r=e.current;if(!r)return;const n=Math.abs(t.deltaX)>=Math.abs(t.deltaY)?t.deltaX:t.deltaY;0!==n&&(t.preventDefault(),r.scrollBy({left:n,top:0,behavior:"auto"}))},[e]);return{hScrollLeft:s,viewportWidth:g,scheduleHScrollUpdate:u,forwardWheelToBody:m}})({scrollRef:Mt,footerScrollRef:Se,hasFooterAggregate:vt}),Tt=i(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,...ee}),[ee]),{visibleColumns:Ot,hvPadLeftMemo:$t,hvPadRightMemo:Pt}=(({columnsWithWidths:e,pinnedAll:t,unpinnedAll:r,effectivePinnedColumns:n,hScrollLeft:o,viewportWidth:l,selectable:a,enableHorizontalVirtualization:s,horizontalVirtualizationThreshold:c})=>{const d=i(()=>s&&e.length>c,[e.length,s,c]),u=i(()=>{const e=r.map(e=>e.width||100),t=new Array(e.length+1).fill(0);for(let r=0;r<e.length;r++)t[r+1]=t[r]+e[r];return{widths:e,prefix:t,totalWidth:t[e.length]||0}},[r]),g=i(()=>{if(!d)return e;const n=a?mr:0,s=t.reduce((e,t)=>e+(t.width||100),0),i=Math.max(0,o-200),c=o+l+200,g=n+s,h=Math.max(0,i-g),m=Math.max(0,Math.min(u.totalWidth,c-g)),x=(e=>{if(!u.widths.length)return 0;let t=0,r=u.widths.length-1,n=0;for(;t<=r;){const o=t+r>>1;u.prefix[o+1]>=e?(n=o,r=o-1):t=o+1}return Math.max(0,Math.min(n,u.widths.length-1))})(h),f=(e=>{if(!u.widths.length)return-1;let t=0,r=u.widths.length-1,n=u.widths.length-1;for(;t<=r;){const o=t+r>>1;u.prefix[o]<=e?(n=o,t=o+1):r=o-1}return Math.max(0,Math.min(n,u.widths.length-1))})(m),p=f>=x&&f>=0?r.slice(x,f+1):[];return[...t,...p]},[d,e,o,l,a,t,r,u]),h=i(()=>{const e=new Map;return r.forEach((t,r)=>e.set(t.key,r)),e},[r]),{hvPadLeftMemo:m,hvPadRightMemo:x}=i(()=>{if(!d)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=g.filter(e=>!n.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=h.get(e[0].key),r=h.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:u.prefix[t],hvPadRightMemo:u.totalWidth-u.prefix[r+1]}},[d,g,n,h,u]);return{needsHorizontalVirtualization:d,visibleColumns:g,hvPadLeftMemo:m,hvPadRightMemo:x}})({columnsWithWidths:at,pinnedAll:st,unpinnedAll:it,effectivePinnedColumns:ct,hScrollLeft:Lt,viewportWidth:zt,selectable:y,enableHorizontalVirtualization:Tt.enableHorizontalVirtualization,horizontalVirtualizationThreshold:Tt.horizontalVirtualizationThreshold}),{showLoader:Kt,finishingLoader:Wt,loaderTop:Vt}=(({loading:e,isServerLoading:t,resolvedHeaderHeight:n,scrollRef:o,containerRef:a})=>{const s=e||t,[i,c]=r(s),[d,u]=r(!1),[g,h]=r(0);return l(()=>{if(s)return c(!0),void u(!1);if(i){u(!0);const e=setTimeout(()=>{c(!1),u(!1)},200);return()=>clearTimeout(e)}},[s]),l(()=>{const e=()=>{const e=o.current;e&&h((e.offsetTop||0)+(n||0)-1)};e();const t=new ResizeObserver(e);return a.current&&t.observe(a.current),o.current&&t.observe(o.current),()=>t.disconnect()},[n]),{showLoader:i,finishingLoader:d,loaderTop:g}})({loading:_,isServerLoading:Ie,resolvedHeaderHeight:fe,scrollRef:Mt,containerRef:ce});l(()=>{B&&W?.enabled&&"server"===W.mode&&B({globalFilter:pe,columnFilters:ye,filterableKeys:t.filter(e=>!!e.filterable).map(e=>e.key)})},[pe,ye,B,t,W]),l(()=>{1!==Pe&&(W?.enabled&&"server"===W.mode?Te(1):$e())},[pe,ye]);const{focusedCell:_t,dragOverlay:Bt,isCellSelected:Gt,isCellFocused:Ht,handleCellMouseDown:Ut,handleCellMouseEnter:Yt}=(({cellFocusEnabled:e,cellSelectionEnabled:t,canSelectCell:a,flatRows:s,columnsWithWidths:c,rowIndexById:d,colIndexByKey:u,rowById:g,colByKey:h,scrollRef:m,headerScrollRef:x,resolvedRowHeight:f,selectable:p,onCellFocusChange:y,onCellSelectionChange:b,onCopyCells:v,columnKeys:w,getRowId:k})=>{const j=n((e,t)=>k?k(e):void 0!==e.id?e.id:t??0,[k]),[C,N]=r(null),[S,R]=r(null),[M,D]=r(null),[E,A]=r(null),F=o(!1),L=o(null),z=o(null),I=o(b),T=o(v),O=o(null);l(()=>{I.current=b},[b]),l(()=>{T.current=v},[v]);const $=i(()=>(e,r)=>{if(!t)return!1;if(!S||!M)return!1;const n=d.get(e),o=u.get(r);if(null==n||null==o)return!1;const l=g.get(e),s=h.get(r);if(l&&s&&!a(l,s))return!1;const i=Math.min(S.rowIndex,M.rowIndex),c=Math.max(S.rowIndex,M.rowIndex),m=Math.min(S.colIndex,M.colIndex),x=Math.max(S.colIndex,M.colIndex);return n>=i&&n<=c&&o>=m&&o<=x},[t,S,M,d,u,g,h,a]),P=i(()=>(e,t)=>C?.rowId===e&&C?.columnKey===t,[C]),K=n(({row:r,column:n,event:o})=>{const l=j(r),s=d.get(l),i=u.get(n.key);e&&null!=s&&null!=i&&(document.body.hasAttribute("data-modal-open")||(N({rowId:l,columnKey:n.key}),y&&y({row:r,column:n,value:r[n.key],rowIndex:s,colIndex:i}))),t&&a(r,n)&&0===o.button&&(F.current=!0,L.current={x:o.clientX,y:o.clientY},null!=s&&null!=i&&(N({rowId:l,columnKey:n.key}),R({rowIndex:s,colIndex:i}),D({rowIndex:s,colIndex:i}),A({x:o.clientX,y:o.clientY,rows:1,cols:1})))},[e,y,t,a,d,u,j]),W=n(({row:e,column:r,event:n})=>{if(!t)return;if(!F.current||!S)return;if(!a(e,r))return;const o=j(e),l=d.get(o),s=u.get(r.key);if(null==l||null==s)return;D({rowIndex:l,colIndex:s}),L.current={x:n.clientX,y:n.clientY};const i=Math.min(S.rowIndex,l),c=Math.max(S.rowIndex,l),g=Math.min(S.colIndex,s),h=Math.max(S.colIndex,s);A({x:n.clientX,y:n.clientY,rows:c-i+1,cols:h-g+1})},[t,a,S,d,u,j]);l(()=>{const e=()=>{F.current=!1,A(null),z.current&&(cancelAnimationFrame(z.current),z.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{F.current&&(L.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const V=n(()=>{if(null!=z.current)return;const e=()=>{if(z.current=null,!F.current)return;const t=m.current,r=L.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,o=24;let l=0,a=0;r.x<e.left+n?l=-(e.left+n-r.x):r.x>e.right-n&&(l=r.x-(e.right-n)),r.y<e.top+n?a=-(e.top+n-r.y):r.y>e.bottom-n&&(a=r.y-(e.bottom-n));const s=e=>Math.max(-o,Math.min(o,e));l=s(l),a=s(a),0===l&&0===a||t.scrollBy({left:l,top:a,behavior:"auto"})}z.current=requestAnimationFrame(e)};z.current=requestAnimationFrame(e)},[]);return l(()=>{F.current&&V()},[V,S]),l(()=>{const e=e=>{if("Escape"===e.key)return R(null),D(null),N(null),void A(null);const r=e.shiftKey,n=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!r||!n||!t)return;e.preventDefault();let o=M;if(!o){if(!C)return;{const e=d.get(C.rowId),t=u.get(C.columnKey);if(null==e||null==t)return;R({rowIndex:e,colIndex:t}),o={rowIndex:e,colIndex:t}}}const l=s.length-1,a=c.length-1;let i=o.rowIndex,g=o.colIndex;"ArrowUp"===e.key&&(i=Math.max(0,i-1)),"ArrowDown"===e.key&&(i=Math.min(l,i+1)),"ArrowLeft"===e.key&&(g=Math.max(0,g-1)),"ArrowRight"===e.key&&(g=Math.min(a,g+1)),D({rowIndex:i,colIndex:g});const h=m.current;if(h){const e=h.getBoundingClientRect();A({x:e.right-16,y:e.bottom-16,rows:Math.abs((S?.rowIndex??i)-i)+1,cols:Math.abs((S?.colIndex??g)-g)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,C,S,M,d,u,s.length,c.length]),l(()=>{if(!e)return;const t=m.current,r=x.current,n=e=>{if(!C)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:n}=e;if("ArrowLeft"!==n&&"ArrowRight"!==n&&"ArrowUp"!==n&&"ArrowDown"!==n)return;e.preventDefault();const o=d.get(C.rowId),l=u.get(C.columnKey);if(null==o||null==l)return;let a=o,i=l;"ArrowLeft"===n&&(i=Math.max(0,l-1)),"ArrowRight"===n&&(i=Math.min(c.length-1,l+1)),"ArrowUp"===n&&(a=Math.max(0,o-1)),"ArrowDown"===n&&(a=Math.min(s.length-1,o+1));const g=s[a],h=c[i];if(!g||!h)return;const m=j(g,a);N({rowId:m,columnKey:h.key}),y&&y({row:g,column:h,value:g[h.key],rowIndex:a,colIndex:i}),((e,n)=>{if(!t)return;const o=t.clientHeight,l=e*f,a=l+f;l<t.scrollTop?t.scrollTop=l:a>t.scrollTop+o&&(t.scrollTop=a-o);const s=c[n]?.width||100;let i=p?36:0;for(let e=0;e<n;e++)i+=c[e]?.width||100;const d=i+s,u=t.clientWidth;i<t.scrollLeft?t.scrollLeft=i:d>t.scrollLeft+u&&(t.scrollLeft=d-u),r&&(r.scrollLeft=t.scrollLeft)})(a,i)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,C,s,c,f,p,d,u,y]),l(()=>{if(!t||!S||!M){const e={bounds:null,cells:[]},t="none";return void(t!==O.current&&(O.current=t,I.current?.(e)))}const e=Math.min(S.rowIndex,M.rowIndex),r=Math.max(S.rowIndex,M.rowIndex),n=Math.min(S.colIndex,M.colIndex),o=Math.max(S.colIndex,M.colIndex),l=[];for(let t=e;t<=r;t++){const e=s[t];if(e)for(let r=n;r<=o;r++){const n=c[r];n&&a(e,n)&&l.push({row:e,column:n,value:e[n.key],rowIndex:t,colIndex:r})}}const i={bounds:{rowStart:e,rowEnd:r,colStart:n,colEnd:o},cells:l},d=`${e}-${r}-${n}-${o}|len:${l.length}`;d!==O.current&&(O.current=d,I.current?.(i))},[t,S,M,s,w,a]),l(()=>{if(!t&&!e)return;const r=async t=>{if(!t.metaKey&&!t.ctrlKey||"c"!==t.key.toLowerCase())return;const r=!!t.shiftKey,n=!(!S||!M),o=!(!e||!C);if(!n&&!o)return;if(!n&&o){const e=window.getSelection();if(e&&e.toString().length>0)return;const t=document.activeElement;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return}t.preventDefault();const l=(()=>{const e=[];if(n&&S&&M){const t=Math.min(S.rowIndex,M.rowIndex),r=Math.max(S.rowIndex,M.rowIndex),n=Math.min(S.colIndex,M.colIndex),o=Math.max(S.colIndex,M.colIndex);for(let l=t;l<=r;l++){const t=s[l];if(t)for(let r=n;r<=o;r++){const n=c[r];n&&a(t,n)&&e.push({row:t,column:n,value:t[n.key],rowIndex:l,colIndex:r})}}}else if(o&&C){const t=d.get(C.rowId),r=u.get(C.columnKey);if(null!=t&&null!=r){const n=s[t],o=c[r];n&&o&&e.push({row:n,column:o,value:n[o.key],rowIndex:t,colIndex:r})}}return e})();if(!l.length)return;const i=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let g="";if(n&&S&&M){const e=Math.min(S.rowIndex,M.rowIndex),t=Math.max(S.rowIndex,M.rowIndex),n=Math.min(S.colIndex,M.colIndex),o=Math.max(S.colIndex,M.colIndex);if(r){const e=[];for(let t=n;t<=o;t++){const r=c[t];r&&e.push(i(r.header??r.key))}g+=e.join("\t")+"\n"}for(let r=e;r<=t;r++){const e=s[r];if(!e)continue;const l=[];for(let t=n;t<=o;t++){const r=c[t];r&&(a(e,r)?l.push(i(e[r.key])):l.push(""))}g+=l.join("\t"),r<t&&(g+="\n")}}else g=i(l[0].value);try{await navigator.clipboard.writeText(g)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof T.current){const e=n&&S&&M?{rowStart:Math.min(S.rowIndex,M.rowIndex),rowEnd:Math.max(S.rowIndex,M.rowIndex),colStart:Math.min(S.colIndex,M.colIndex),colEnd:Math.max(S.colIndex,M.colIndex)}:null;try{T.current({text:g,bounds:e,cells:l,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,e,S,M,C,s,c,a,d,u]),{focusedCell:C,selectionAnchor:S,selectionEnd:M,dragOverlay:E,isCellSelected:$,isCellFocused:P,handleCellMouseDown:K,handleCellMouseEnter:W}})({cellFocusEnabled:z,cellSelectionEnabled:$,canSelectCell:P,flatRows:xt,columnsWithWidths:at,rowIndexById:ft,colIndexByKey:ht,rowById:pt,colByKey:mt,scrollRef:Mt,headerScrollRef:Ne,resolvedRowHeight:xe,selectable:y,onCellFocusChange:I,onCellSelectionChange:K,onCopyCells:Z,columnKeys:bt,getRowId:gt}),{editingCell:qt,startEdit:Xt,commitEdit:Jt,cancelEdit:Zt,isEditing:Qt}=(({getRowId:e,onCellEdit:t,onCellEditStart:o,focusedCell:a,getRowById:s,getColumnByKey:i})=>{const[c,d]=r(null),u=n((t,r)=>{if(!((e,t)=>!!e.editable&&("function"==typeof e.editable?e.editable(t):!!e.editable))(r,t))return;const n=t[r.key];if(o&&!1===o({row:t,column:r,value:n}))return;const l=e(t);d({rowId:l,columnKey:r.key,initialValue:n,row:t,column:r})},[e,o]),g=n(e=>{if(!c)return;const{row:r,column:n,initialValue:o,rowId:l}=c;d(null),e!==o&&t?.({row:r,column:n,oldValue:o,newValue:e,rowId:l})},[c,t]),h=n(()=>{d(null)},[]);l(()=>{if(!a||!s||!i)return;const e=e=>{if("F2"!==e.key)return;if(c)return;const t=s(a.rowId),r=i(a.columnKey);t&&r&&(e.preventDefault(),u(t,r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,s,i,u]);const m=n((e,t)=>c?.rowId===e&&c?.columnKey===t,[c]);return{editingCell:c,startEdit:u,commitEdit:g,cancelEdit:h,isEditing:m}})({getRowId:gt,onCellEdit:T,onCellEditStart:O,focusedCell:_t,getRowById:e=>pt.get(e),getColumnByKey:e=>mt.get(e)}),{scrollToRow:er,scrollToColumn:tr}=qr({scrollRef:Mt,rowIndexById:ft,colIndexByKey:ht,columnsWithWidths:at,resolvedRowHeight:xe,selectable:y});g(ie,()=>({setGroupKeys:He,addGroupKey:Be,removeGroupKey:Ge,expandAllGroups:qe,collapseAllGroups:Xe,toggleGroupExpansion:Ue,getGroupConfig:()=>We,setColumnFilter:we,clearColumnFilter:e=>we(e,null),clearAllFilters:ke,setGlobalFilter:ve,getRowId:gt,scrollToRow:er,scrollToColumn:tr}),[He,Be,Ge,qe,Xe,Ue,We,we,ke,ve,gt,er,tr]);const rr=i(()=>function(e){let t=(e||Zr||"").replace(/-/g,"").toLowerCase();if("kdinternaldevbypass"===t)return!0;if((t.startsWith("kdtest")||t.startsWith("kdlive"))&&(t=t.slice(6)),32!==t.length)return!1;try{const e=new Uint32Array(4);for(let r=0;r<4;r++)e[r]=parseInt(t.slice(8*r,8*r+8),16);const r=new Uint32Array([e[0],e[1]]),n=new Uint32Array([e[2],e[3]]);Jr(r,Xr),Jr(n,Xr);const o=r[1];if(1262769713!==r[0])return!1;const l=Math.floor(o/1e4),a=Math.floor(o%1e4/100)-1,s=o%100;if(l<2024||a<0||a>11||s<1||s>31)return!1;const i=new Date(l,a,s,23,59,59);return!(new Date>i&&(console.error("[KDGrid] License expired on "+i.toDateString()),1))}catch{return!1}}(le),[le]),nr=n(()=>ke(),[ke]),or=n(e=>{he(e),m&&m(e)},[m]),lr=n(e=>ve(e.target.value),[ve]);return C.jsxs("div",{ref:ce,className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-white dark:bg-gray-900 h-full flex flex-col","data-grid-container":!0,children:[C.jsx(hr,{showToolbar:v,filterable:k,globalFilter:pe,filteredDataLength:be.length,totalDataLength:Le.totalRows,paginationMode:W?.mode,selectedRowsCount:wt.size,showExport:w,columns:t,columnFilters:ye,columnVisibility:Je,onResetColumns:lt,exportOptions:{enabled:(te?.enabled??!0)&&w,formats:te?.formats??["xlsx"],filename:te?.filename??"grid-data",onExport:St},toolbarLeft:Y,toolbarRight:q,onGlobalFilterChange:lr,onClearFilters:nr,onColumnFilter:we,onColumnVisibilityChange:tt,columnOrder:dt,onColumnOrderChange:rt,pinnedColumns:Ze,onScrollToColumn:tr,density:ge,onDensityChange:or,showDensityControl:x,groupable:j,groupBarVisibility:X,groupConfig:We,removeGroupKey:Ge,setGroupKeys:He,addGroupKey:Be,collapseAllGroups:Xe,expandAllGroups:qe}),C.jsx("div",{className:"flex flex-col relative flex-1 min-h-50",children:C.jsx(Fr,{scrollRef:Mt,flatRows:xt,columnsWithWidths:at,visibleColumns:Ot,totalWidth:yt,selectable:y,dataToDisplay:ut,pinnedAll:st,effectivePinnedColumns:ct,hvPadLeftMemo:$t,hvPadRightMemo:Pt,resolvedHeaderHeight:fe,sortConfig:je,columnFilters:ye,selectedRows:wt,data:e,handleSort:Re,setColumnFilter:we,handleSelectAll:jt,handleColumnResize:Qe,handleColumnPin:et,addGroupKey:Be,removeGroupKey:Ge,handleGroupBy:_e,autosizeColumn:nt,autosizeAllColumns:ot,resetColumns:lt,columnOrder:dt,setColumnOrder:rt,pagination:W,minResizeWidth:h,effectiveVirtualized:Rt,virtualizedRange:Dt,resolvedRowHeight:xe,visibleData:Et,isRowSelectable:b,handleRowSelect:kt,rowStyle:M,globalFilter:pe,onContextMenu:D,onRowDoubleClick:E,onRowClick:A,onCellClick:F,onCellContextMenu:L,isCellFocused:Ht,isCellSelected:Gt,handleCellMouseDown:Ut,handleCellMouseEnter:Yt,contextMenuItems:ne,getRowId:a,isEditing:Qt,startEdit:Xt,commitEdit:Jt,cancelEdit:Zt,editingCell:qt,safeGetRowId:gt,toggleGroupExpansion:Ue,containerWidth:de,groupConfig:We,columns:t,renderGroupActions:re,groupFooterVariant:J,isValidLicense:rr,infiniteScroll:oe,sentinelRef:Ft,loading:_,showLoader:Kt,finishingLoader:Wt,loaderTop:Vt,noDataMessage:ae,noDataRenderer:se,handleScroll:At,cellSelectionEnabled:$})}),C.jsx(Tr,{hasFooterAggregate:vt,footerScrollRef:Se,forwardWheelToBody:It,totalWidth:yt,selectable:y,resolvedRowHeight:xe,columnsWithWidths:at,flatRows:xt,effectivePinnedColumns:ct,infiniteScroll:oe,paginationConfig:Le,isServerLoading:Ie,selectedRowsCount:wt.size,data:e,filteredData:be,pagination:W,handlePageChange:Te,handlePageSizeChange:Oe}),Bt&&C.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:Bt.y+12,left:Bt.x+12},children:C.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[Bt.rows," x ",Bt.cols]})})]})});var rn=tn;const nn=({children:e,variant:t="primary",size:r="md",isLoading:n,className:o="",disabled:l,...a})=>C.jsxs("button",{className:`inline-flex items-center justify-center rounded-lg font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed active:scale-95 select-none ${{primary:"bg-blue-600 text-white hover:bg-blue-700 shadow-sm border border-transparent",secondary:"bg-gray-100 text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-100 dark:hover:bg-gray-700 border border-transparent",outline:"border border-gray-300 bg-transparent hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",ghost:"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 dark:text-gray-300 border border-transparent",danger:"bg-red-600 text-white hover:bg-red-700 shadow-sm border border-transparent"}[t]} ${{sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"}[r]} ${o}`,disabled:l||n,...a,children:[n?C.jsx("span",{className:"mr-2 animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent transition-opacity"}):null,C.jsx("span",{className:"flex items-center gap-2",children:e})]}),on=({label:e,error:t,helperText:r,icon:n,className:o="",id:l,...a})=>C.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[e&&C.jsx("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),C.jsxs("div",{className:"relative group",children:[n&&C.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 group-focus-within:text-blue-500 transition-colors",children:n}),C.jsx("input",{id:l,className:`w-full ${n?"pl-10":"pl-3"} pr-3 py-2 bg-white dark:bg-gray-800 border rounded-lg text-sm transition-all shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none ${t?"border-red-500 focus:ring-red-500":"border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"} ${o}`,...a})]}),t&&C.jsx("p",{className:"text-xs text-red-500 font-medium",children:t}),!t&&r&&C.jsx("p",{className:"text-xs text-gray-500",children:r})]}),ln=({label:e,className:t="",id:r,...n})=>C.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none group",children:[C.jsx("div",{className:"relative flex items-center justify-center",children:C.jsx("input",{id:r,type:"checkbox",className:`peer w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 transition-all dark:border-gray-600 dark:bg-gray-800 dark:checked:bg-blue-600 ${t}`,...n})}),e&&C.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:e})]});export{nn as Button,ln as Checkbox,rr as CustomSelect,nr as DatePicker,Lr as FooterAggregate,kr as GridHeader,Rr as GridRows,gr as GroupBar,tn as KDGrid,Ir as PaginationControls,Yt as Popover,on as TextField,ur as Toolbar,rn as default,Qr as setLicenseKey,Or as useAdvancedFiltering,qr as useGridMethods,Br as usePagination,Hr as useSelection,Ur as useVirtualization};
|
|
1
|
+
import*as e from"react";import t,{createContext as r,useContext as n,useState as o,useEffect as l,useMemo as a,useCallback as s,useRef as i,useLayoutEffect as d,memo as c,useTransition as u,useDeferredValue as m,forwardRef as f,useImperativeHandle as h}from"react";import*as g from"react-dom";import{createPortal as p}from"react-dom";var x,v={exports:{}},y={};function b(){if(x)return y;x=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(t,r,n){var o=null;if(void 0!==n&&(o=""+n),void 0!==r.key&&(o=""+r.key),"key"in r)for(var l in n={},r)"key"!==l&&(n[l]=r[l]);else n=r;return{$$typeof:e,type:t,key:o,ref:void 0!==(r=n.ref)?r:null,props:n}}return y.Fragment=t,y.jsx=r,y.jsxs=r,y}var k,w,j={};function C(){return k||(k=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===S?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case p:return"Profiler";case g:return"StrictMode";case b:return"Suspense";case k:return"SuspenseList";case N:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case f:return"Portal";case v:return t.displayName||"Context";case x:return(t._context.displayName||"Context")+".Consumer";case y:var r=t.render;return(t=t.displayName)||(t=""!==(t=r.displayName||r.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case w:return null!==(r=t.displayName||null)?r:e(t.type)||"Memo";case C:r=t._payload,t=t._init;try{return e(t(r))}catch(e){}}return null}function r(e){return""+e}function n(e){try{r(e);var t=!1}catch(e){t=!0}if(t){t=console;var n="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.error.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),r(e)}}function o(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===C)return"<...>";try{var r=e(t);return r?"<"+r+">":"<...>"}catch(e){return"<...>"}}function l(){return Error("react-stack-top-frame")}function a(){var t=e(this.type);return F[t]||(F[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,r,o,l,s,d){var u,f=r.children;if(void 0!==f)if(l)if(D(f)){for(l=0;l<f.length;l++)i(f[l]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else i(f);if(M.call(r,"key")){f=e(t);var h=Object.keys(r).filter(function(e){return"key"!==e});l=0<h.length?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}",z[f+l]||(h=0<h.length?"{"+h.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,f,h,f),z[f+l]=!0)}if(f=null,void 0!==o&&(n(o),f=""+o),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(r)&&(n(r.key),f=""+r.key),"key"in r)for(var g in o={},r)"key"!==g&&(o[g]=r[g]);else o=r;return f&&function(e,t){function r(){c||(c=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(o,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,r,n,o,l){var s=r.ref;return e={$$typeof:m,type:e,key:t,props:r,_owner:n},Object.defineProperty(e,"ref",null!==(void 0!==s?s:null)?{enumerable:!1,get:a}:{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,f,o,null===(u=R.A)?null:u.getOwner(),s,d)}function i(e){d(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===C&&("fulfilled"===e._payload.status?d(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function d(e){return"object"==typeof e&&null!==e&&e.$$typeof===m}var c,u=t,m=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),v=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,D=Array.isArray,E=console.createTask?console.createTask:function(){return null},F={},A=(u={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(u,l)(),L=E(o(l)),z={};j.Fragment=h,j.jsx=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!1,n?Error("react-stack-top-frame"):A,n?E(o(e)):L)},j.jsxs=function(e,t,r){var n=1e4>R.recentlyCreatedOwnerStacks++;return s(e,t,r,!0,n?Error("react-stack-top-frame"):A,n?E(o(e)):L)}}()),j}function N(){return w||(w=1,v.exports="production"===process.env.NODE_ENV?b():C()),v.exports}var S=N();const R={name:"default",colors:{light:{primary:"#2563eb",primaryForeground:"#ffffff",accent:"#eff6ff",accentForeground:"#1e40af",background:"#ffffff",foreground:"#0f172a",muted:"#f8fafc",mutedForeground:"#64748b",border:"#e2e8f0",ring:"#3b82f6"},dark:{primary:"#3b82f6",primaryForeground:"#ffffff",accent:"#1e3a8a",accentForeground:"#dbeafe",background:"#0f172a",foreground:"#f8fafc",muted:"#1e293b",mutedForeground:"#94a3b8",border:"#334155",ring:"#3b82f6"}},radius:"0.5rem",shadow:"0 1px 2px 0 rgb(0 0 0 / 0.05)"},M=r(void 0),D=()=>{const e=n(M);if(!e)throw new Error("useKDGridTheme must be used within a KDGridProvider");return e},E=({theme:e=R,defaultMode:t="system",children:r})=>{const[n,s]=o(t),[i,d]=o("light");l(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");d(e.matches?"dark":"light");const t=e=>d(e.matches?"dark":"light");return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);const c=a(()=>"system"===n?i:n,[n,i]),u=a(()=>{return{"--kd-primary":(t="dark"===c?e.colors.dark:e.colors.light).primary,"--kd-primary-foreground":t.primaryForeground,"--kd-accent":t.accent,"--kd-accent-foreground":t.accentForeground,"--kd-background":t.background,"--kd-foreground":t.foreground,"--kd-muted":t.muted,"--kd-muted-foreground":t.mutedForeground,"--kd-border":t.border,"--kd-ring":t.ring,"--kd-radius":e.radius};var t},[e,c]),m=a(()=>({theme:e,mode:n,resolvedMode:c,setMode:s}),[e,n,c]);return S.jsx(M.Provider,{value:m,children:S.jsx("div",{className:`kd-grid-root ${c} h-full`,style:u,"data-theme-mode":c,children:r})})},F=({size:e=16,children:t,...r})=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:t}),A=e=>S.jsx(F,{...e,children:S.jsx("polyline",{points:"15 18 9 12 15 6"})}),L=e=>S.jsx(F,{...e,children:S.jsx("polyline",{points:"9 18 15 12 9 6"})}),z=e=>S.jsx(F,{...e,children:S.jsx("polyline",{points:"6 9 12 15 18 9"})}),I=e=>S.jsxs(F,{...e,children:[S.jsx("polyline",{points:"11 17 6 12 11 7"}),S.jsx("polyline",{points:"18 17 13 12 18 7"})]}),T=e=>S.jsxs(F,{...e,children:[S.jsx("polyline",{points:"13 17 18 12 13 7"}),S.jsx("polyline",{points:"6 17 11 12 6 7"})]}),O=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),S.jsx("polyline",{points:"5 12 12 5 19 12"})]}),$=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),S.jsx("polyline",{points:"19 12 12 19 5 12"})]}),P=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"m21 16-4 4-4-4"}),S.jsx("path",{d:"M17 20V4"}),S.jsx("path",{d:"m3 8 4-4 4 4"}),S.jsx("path",{d:"M7 4v16"})]}),K=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),S.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),W=e=>S.jsx(F,{...e,children:S.jsx("polyline",{points:"20 6 9 17 4 12"})}),V=e=>S.jsxs(F,{...e,children:[S.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),S.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),_=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),S.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),B=e=>S.jsxs(F,{...e,children:[S.jsx("polyline",{points:"3 6 5 6 21 6"}),S.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),S.jsx("path",{d:"M10 11v6"}),S.jsx("path",{d:"M14 11v6"}),S.jsx("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),G=e=>S.jsxs(F,{...e,children:[S.jsx("polyline",{points:"21 8 21 21 3 21 3 8"}),S.jsx("rect",{x:"1",y:"3",width:"22",height:"5"}),S.jsx("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]}),H=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),S.jsx("polyline",{points:"7 10 12 15 17 10"}),S.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),U=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),S.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),S.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),Y=e=>S.jsx(F,{...e,children:S.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),q=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M13.013 3H2l8 9.46V19l4 2v-6.54l.9-1.055"}),S.jsx("line",{x1:"22",y1:"3",x2:"11",y2:"14"})]}),X=e=>S.jsxs(F,{...e,children:[S.jsx("circle",{cx:"12",cy:"12",r:"3"}),S.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),J=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),S.jsx("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]}),Z=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),S.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),S.jsx("path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12"}),S.jsx("path",{d:"M15 9.34V6h1a2 2 0 0 0 0-4H7.89"})]}),Q=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),S.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),S.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),S.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),S.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),ee=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}),S.jsx("path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}),S.jsx("path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}),S.jsx("path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}),S.jsx("rect",{x:"7",y:"7",width:"4",height:"4",rx:"1"}),S.jsx("rect",{x:"13",y:"13",width:"4",height:"4",rx:"1"})]}),te=e=>S.jsxs(F,{...e,children:[S.jsx("circle",{cx:"12",cy:"12",r:"1"}),S.jsx("circle",{cx:"19",cy:"12",r:"1"}),S.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),re=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),S.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),ne=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),S.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),S.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),oe=e=>S.jsxs(F,{...e,children:[S.jsx("circle",{cx:"11",cy:"11",r:"8"}),S.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),le=e=>S.jsxs(F,{...e,children:[S.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),S.jsx("path",{d:"M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"}),S.jsx("path",{d:"M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"})]}),ae=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),S.jsx("polyline",{points:"14 2 14 8 20 8"}),S.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),S.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),S.jsx("polyline",{points:"10 9 9 9 8 9"})]}),se=e=>S.jsxs(F,{...e,children:[S.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),S.jsx("path",{d:"M3 9h18"}),S.jsx("path",{d:"M3 15h18"}),S.jsx("path",{d:"M9 3v18"})]}),ie=e=>S.jsxs(F,{...e,children:[S.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),S.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),S.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]}),de=e=>S.jsxs(F,{...e,children:[S.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),S.jsx("circle",{cx:"9",cy:"7",r:"4"}),S.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),S.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),ce=e=>S.jsxs(F,{...e,children:[S.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),S.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),S.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),S.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),S.jsx("circle",{cx:"12",cy:"12",r:"4"}),S.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"})]}),ue=({size:e=16,className:t,style:r,...n})=>S.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",className:t,style:r,...n,children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]});function me(){return"undefined"!=typeof window}function fe(e){return pe(e)?(e.nodeName||"").toLowerCase():"#document"}function he(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function ge(e){var t;return null==(t=(pe(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function pe(e){return!!me()&&(e instanceof Node||e instanceof he(e).Node)}function xe(e){return!!me()&&(e instanceof Element||e instanceof he(e).Element)}function ve(e){return!!me()&&(e instanceof HTMLElement||e instanceof he(e).HTMLElement)}function ye(e){return!(!me()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof he(e).ShadowRoot)}const be=new Set(["inline","contents"]);function ke(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Le(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!be.has(o)}const we=new Set(["table","td","th"]);function je(e){return we.has(fe(e))}const Ce=[":popover-open",":modal"];function Ne(e){return Ce.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Se=["transform","translate","scale","rotate","perspective"],Re=["transform","translate","scale","rotate","perspective","filter"],Me=["paint","layout","strict","content"];function De(e){const t=Ee(),r=xe(e)?Le(e):e;return Se.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||Re.some(e=>(r.willChange||"").includes(e))||Me.some(e=>(r.contain||"").includes(e))}function Ee(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Fe=new Set(["html","body","#document"]);function Ae(e){return Fe.has(fe(e))}function Le(e){return he(e).getComputedStyle(e)}function ze(e){return xe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ie(e){if("html"===fe(e))return e;const t=e.assignedSlot||e.parentNode||ye(e)&&e.host||ge(e);return ye(t)?t.host:t}function Te(e){const t=Ie(e);return Ae(t)?e.ownerDocument?e.ownerDocument.body:e.body:ve(t)&&ke(t)?t:Te(t)}function Oe(e,t,r){var n;void 0===t&&(t=[]),void 0===r&&(r=!0);const o=Te(e),l=o===(null==(n=e.ownerDocument)?void 0:n.body),a=he(o);if(l){const e=$e(a);return t.concat(a,a.visualViewport||[],ke(o)?o:[],e&&r?Oe(e):[])}return t.concat(o,Oe(o,[],r))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Pe=Math.min,Ke=Math.max,We=Math.round,Ve=Math.floor,_e=e=>({x:e,y:e}),Be={left:"right",right:"left",bottom:"top",top:"bottom"},Ge={start:"end",end:"start"};function He(e,t,r){return Ke(e,Pe(t,r))}function Ue(e,t){return"function"==typeof e?e(t):e}function Ye(e){return e.split("-")[0]}function qe(e){return e.split("-")[1]}function Xe(e){return"x"===e?"y":"x"}function Je(e){return"y"===e?"height":"width"}const Ze=new Set(["top","bottom"]);function Qe(e){return Ze.has(Ye(e))?"y":"x"}function et(e){return Xe(Qe(e))}function tt(e){return e.replace(/start|end/g,e=>Ge[e])}const rt=["left","right"],nt=["right","left"],ot=["top","bottom"],lt=["bottom","top"];function at(e){return e.replace(/left|right|bottom|top/g,e=>Be[e])}function st(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}var it="undefined"!=typeof document?d:function(){};const dt={...e}.useInsertionEffect||(e=>e());function ct(e,t,r){let{reference:n,floating:o}=e;const l=Qe(t),a=et(t),s=Je(a),i=Ye(t),d="y"===l,c=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,m=n[s]/2-o[s]/2;let f;switch(i){case"top":f={x:c,y:n.y-o.height};break;case"bottom":f={x:c,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:u};break;case"left":f={x:n.x-o.width,y:u};break;default:f={x:n.x,y:n.y}}switch(qe(t)){case"start":f[a]-=m*(r&&d?-1:1);break;case"end":f[a]+=m*(r&&d?-1:1)}return f}async function ut(e,t){var r;void 0===t&&(t={});const{x:n,y:o,platform:l,rects:a,elements:s,strategy:i}=e,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:u="floating",altBoundary:m=!1,padding:f=0}=Ue(t,e),h=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(f),g=s[m?"floating"===u?"reference":"floating":u],p=st(await l.getClippingRect({element:null==(r=await(null==l.isElement?void 0:l.isElement(g)))||r?g:g.contextElement||await(null==l.getDocumentElement?void 0:l.getDocumentElement(s.floating)),boundary:d,rootBoundary:c,strategy:i})),x="floating"===u?{x:n,y:o,width:a.floating.width,height:a.floating.height}:a.reference,v=await(null==l.getOffsetParent?void 0:l.getOffsetParent(s.floating)),y=await(null==l.isElement?void 0:l.isElement(v))&&await(null==l.getScale?void 0:l.getScale(v))||{x:1,y:1},b=st(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:v,strategy:i}):x);return{top:(p.top-b.top+h.top)/y.y,bottom:(b.bottom-p.bottom+h.bottom)/y.y,left:(p.left-b.left+h.left)/y.x,right:(b.right-p.right+h.right)/y.x}}const mt=new Set(["left","top"]);function ft(e){const t=Le(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=ve(e),l=o?e.offsetWidth:r,a=o?e.offsetHeight:n,s=We(r)!==l||We(n)!==a;return s&&(r=l,n=a),{width:r,height:n,$:s}}function ht(e){return xe(e)?e:e.contextElement}function gt(e){const t=ht(e);if(!ve(t))return _e(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:l}=ft(t);let a=(l?We(r.width):r.width)/n,s=(l?We(r.height):r.height)/o;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const pt=_e(0);function xt(e){const t=he(e);return Ee()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:pt}function vt(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1);const o=e.getBoundingClientRect(),l=ht(e);let a=_e(1);t&&(n?xe(n)&&(a=gt(n)):a=gt(e));const s=function(e,t,r){return void 0===t&&(t=!1),!(!r||t&&r!==he(e))&&t}(l,r,n)?xt(l):_e(0);let i=(o.left+s.x)/a.x,d=(o.top+s.y)/a.y,c=o.width/a.x,u=o.height/a.y;if(l){const e=he(l),t=n&&xe(n)?he(n):n;let r=e,o=$e(r);for(;o&&n&&t!==r;){const e=gt(o),t=o.getBoundingClientRect(),n=Le(o),l=t.left+(o.clientLeft+parseFloat(n.paddingLeft))*e.x,a=t.top+(o.clientTop+parseFloat(n.paddingTop))*e.y;i*=e.x,d*=e.y,c*=e.x,u*=e.y,i+=l,d+=a,r=he(o),o=$e(r)}}return st({width:c,height:u,x:i,y:d})}function yt(e,t){const r=ze(e).scrollLeft;return t?t.left+r:vt(ge(e)).left+r}function bt(e,t){const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-yt(e,r),y:r.top+t.scrollTop}}const kt=new Set(["absolute","fixed"]);function wt(e,t,r){let n;if("viewport"===t)n=function(e,t){const r=he(e),n=ge(e),o=r.visualViewport;let l=n.clientWidth,a=n.clientHeight,s=0,i=0;if(o){l=o.width,a=o.height;const e=Ee();(!e||e&&"fixed"===t)&&(s=o.offsetLeft,i=o.offsetTop)}const d=yt(n);if(d<=0){const e=n.ownerDocument,t=e.body,r=getComputedStyle(t),o="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,a=Math.abs(n.clientWidth-t.clientWidth-o);a<=25&&(l-=a)}else d<=25&&(l+=d);return{width:l,height:a,x:s,y:i}}(e,r);else if("document"===t)n=function(e){const t=ge(e),r=ze(e),n=e.ownerDocument.body,o=Ke(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=Ke(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let a=-r.scrollLeft+yt(e);const s=-r.scrollTop;return"rtl"===Le(n).direction&&(a+=Ke(t.clientWidth,n.clientWidth)-o),{width:o,height:l,x:a,y:s}}(ge(e));else if(xe(t))n=function(e,t){const r=vt(e,!0,"fixed"===t),n=r.top+e.clientTop,o=r.left+e.clientLeft,l=ve(e)?gt(e):_e(1);return{width:e.clientWidth*l.x,height:e.clientHeight*l.y,x:o*l.x,y:n*l.y}}(t,r);else{const r=xt(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return st(n)}function jt(e,t){const r=Ie(e);return!(r===t||!xe(r)||Ae(r))&&("fixed"===Le(r).position||jt(r,t))}function Ct(e,t,r){const n=ve(t),o=ge(t),l="fixed"===r,a=vt(e,!0,l,t);let s={scrollLeft:0,scrollTop:0};const i=_e(0);function d(){i.x=yt(o)}if(n||!n&&!l)if(("body"!==fe(t)||ke(o))&&(s=ze(t)),n){const e=vt(t,!0,l,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else o&&d();l&&!n&&o&&d();const c=!o||n||l?_e(0):bt(o,s);return{x:a.left+s.scrollLeft-i.x-c.x,y:a.top+s.scrollTop-i.y-c.y,width:a.width,height:a.height}}function Nt(e){return"static"===Le(e).position}function St(e,t){if(!ve(e)||"fixed"===Le(e).position)return null;if(t)return t(e);let r=e.offsetParent;return ge(e)===r&&(r=r.ownerDocument.body),r}function Rt(e,t){const r=he(e);if(Ne(e))return r;if(!ve(e)){let t=Ie(e);for(;t&&!Ae(t);){if(xe(t)&&!Nt(t))return t;t=Ie(t)}return r}let n=St(e,t);for(;n&&je(n)&&Nt(n);)n=St(n,t);return n&&Ae(n)&&Nt(n)&&!De(n)?r:n||function(e){let t=Ie(e);for(;ve(t)&&!Ae(t);){if(De(t))return t;if(Ne(t))return null;t=Ie(t)}return null}(e)||r}const Mt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const l="fixed"===o,a=ge(n),s=!!t&&Ne(t.floating);if(n===a||s&&l)return r;let i={scrollLeft:0,scrollTop:0},d=_e(1);const c=_e(0),u=ve(n);if((u||!u&&!l)&&(("body"!==fe(n)||ke(a))&&(i=ze(n)),ve(n))){const e=vt(n);d=gt(n),c.x=e.x+n.clientLeft,c.y=e.y+n.clientTop}const m=!a||u||l?_e(0):bt(a,i);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-i.scrollLeft*d.x+c.x+m.x,y:r.y*d.y-i.scrollTop*d.y+c.y+m.y}},getDocumentElement:ge,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const l=[..."clippingAncestors"===r?Ne(t)?[]:function(e,t){const r=t.get(e);if(r)return r;let n=Oe(e,[],!1).filter(e=>xe(e)&&"body"!==fe(e)),o=null;const l="fixed"===Le(e).position;let a=l?Ie(e):e;for(;xe(a)&&!Ae(a);){const t=Le(a),r=De(a);r||"fixed"!==t.position||(o=null),(l?!r&&!o:!r&&"static"===t.position&&o&&kt.has(o.position)||ke(a)&&!r&&jt(e,a))?n=n.filter(e=>e!==a):o=t,a=Ie(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=l.reduce((e,r)=>{const n=wt(t,r,o);return e.top=Ke(n.top,e.top),e.right=Pe(n.right,e.right),e.bottom=Pe(n.bottom,e.bottom),e.left=Ke(n.left,e.left),e},wt(t,l[0],o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Rt,getElementRects:async function(e){const t=this.getOffsetParent||Rt,r=this.getDimensions,n=await r(e.floating);return{reference:Ct(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:r}=ft(e);return{width:t,height:r}},getScale:gt,isElement:xe,isRTL:function(e){return"rtl"===Le(e).direction}};function Dt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Et(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:i=!1}=n,d=ht(e),c=o||l?[...d?Oe(d):[],...Oe(t)]:[];c.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),l&&e.addEventListener("resize",r)});const u=d&&s?function(e,t){let r,n=null;const o=ge(e);function l(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return function a(s,i){void 0===s&&(s=!1),void 0===i&&(i=1),l();const d=e.getBoundingClientRect(),{left:c,top:u,width:m,height:f}=d;if(s||t(),!m||!f)return;const h={rootMargin:-Ve(u)+"px "+-Ve(o.clientWidth-(c+m))+"px "+-Ve(o.clientHeight-(u+f))+"px "+-Ve(c)+"px",threshold:Ke(0,Pe(1,i))||1};let g=!0;function p(t){const n=t[0].intersectionRatio;if(n!==i){if(!g)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||Dt(d,e.getBoundingClientRect())||a(),g=!1}try{n=new IntersectionObserver(p,{...h,root:o.ownerDocument})}catch(e){n=new IntersectionObserver(p,h)}n.observe(e)}(!0),l}(d,r):null;let m,f=-1,h=null;a&&(h=new ResizeObserver(e=>{let[n]=e;n&&n.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),r()}),d&&!i&&h.observe(d),h.observe(t));let g=i?vt(e):null;return i&&function t(){const n=vt(e);g&&!Dt(g,n)&&r(),g=n,m=requestAnimationFrame(t)}(),r(),()=>{var e;c.forEach(e=>{o&&e.removeEventListener("scroll",r),l&&e.removeEventListener("resize",r)}),null==u||u(),null==(e=h)||e.disconnect(),h=null,i&&cancelAnimationFrame(m)}}const Ft=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:l,placement:a,middlewareData:s}=t,i=await async function(e,t){const{placement:r,platform:n,elements:o}=e,l=await(null==n.isRTL?void 0:n.isRTL(o.floating)),a=Ye(r),s=qe(r),i="y"===Qe(r),d=mt.has(a)?-1:1,c=l&&i?-1:1,u=Ue(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&"number"==typeof h&&(f="end"===s?-1*h:h),i?{x:f*c,y:m*d}:{x:m*d,y:f*c}}(t,e);return a===(null==(r=s.offset)?void 0:r.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:o+i.x,y:l+i.y,data:{...i,placement:a}}}}},At=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:l}=t,{mainAxis:a=!0,crossAxis:s=!1,limiter:i={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...d}=Ue(e,t),c={x:r,y:n},u=await l.detectOverflow(t,d),m=Qe(Ye(o)),f=Xe(m);let h=c[f],g=c[m];a&&(h=He(h+u["y"===f?"top":"left"],h,h-u["y"===f?"bottom":"right"])),s&&(g=He(g+u["y"===m?"top":"left"],g,g-u["y"===m?"bottom":"right"]));const p=i.fn({...t,[f]:h,[m]:g});return{...p,data:{x:p.x-r,y:p.y-n,enabled:{[f]:a,[m]:s}}}}}},Lt=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:l,rects:a,initialPlacement:s,platform:i,elements:d}=t,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:g=!0,...p}=Ue(e,t);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};const x=Ye(o),v=Qe(s),y=Ye(s)===s,b=await(null==i.isRTL?void 0:i.isRTL(d.floating)),k=m||(y||!g?[at(s)]:function(e){const t=at(e);return[tt(e),t,tt(t)]}(s)),w="none"!==h;!m&&w&&k.push(...function(e,t,r,n){const o=qe(e);let l=function(e,t,r){switch(e){case"top":case"bottom":return r?t?nt:rt:t?rt:nt;case"left":case"right":return t?ot:lt;default:return[]}}(Ye(e),"start"===r,n);return o&&(l=l.map(e=>e+"-"+o),t&&(l=l.concat(l.map(tt)))),l}(s,g,h,b));const j=[s,...k],C=await i.detectOverflow(t,p),N=[];let S=(null==(n=l.flip)?void 0:n.overflows)||[];if(c&&N.push(C[x]),u){const e=function(e,t,r){void 0===r&&(r=!1);const n=qe(e),o=et(e),l=Je(o);let a="x"===o?n===(r?"end":"start")?"right":"left":"start"===n?"bottom":"top";return t.reference[l]>t.floating[l]&&(a=at(a)),[a,at(a)]}(o,a,b);N.push(C[e[0]],C[e[1]])}if(S=[...S,{placement:o,overflows:N}],!N.every(e=>e<=0)){var R,M;const e=((null==(R=l.flip)?void 0:R.index)||0)+1,t=j[e];if(t&&("alignment"!==u||v===Qe(t)||S.every(e=>Qe(e.placement)!==v||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let r=null==(M=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:M.placement;if(!r)switch(f){case"bestFit":{var D;const e=null==(D=S.filter(e=>{if(w){const t=Qe(e.placement);return t===v||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:D[0];e&&(r=e);break}case"initialPlacement":r=s}if(o!==r)return{reset:{placement:r}}}return{}}}},zt=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:l,platform:a,elements:s}=t,{apply:i=()=>{},...d}=Ue(e,t),c=await a.detectOverflow(t,d),u=Ye(o),m=qe(o),f="y"===Qe(o),{width:h,height:g}=l.floating;let p,x;"top"===u||"bottom"===u?(p=u,x=m===(await(null==a.isRTL?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(x=u,p="end"===m?"top":"bottom");const v=g-c.top-c.bottom,y=h-c.left-c.right;let b=Pe(g-c[p],v),k=Pe(h-c[x],y);if(null!=(r=t.middlewareData.shift)&&r.enabled.x&&(k=y),null!=(n=t.middlewareData.shift)&&n.enabled.y&&(b=v),!t.middlewareData.shift&&!m){const e=Ke(c.left,0),t=Ke(c.right,0),r=Ke(c.top,0),n=Ke(c.bottom,0);f?k=h-2*(0!==e||0!==t?e+t:Ke(c.left,c.right)):b=g-2*(0!==r||0!==n?r+n:Ke(c.top,c.bottom))}await i({...t,availableWidth:k,availableHeight:b});const w=await a.getDimensions(s.floating);return h!==w.width||g!==w.height?{reset:{rects:!0}}:{}}}},It=(e,t,r)=>{const n=new Map,o={platform:Mt,...r},l={...o.platform,_c:n};return(async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:l=[],platform:a}=r,s=l.filter(Boolean),i=await(null==a.isRTL?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:u}=ct(d,n,i),m=n,f={},h=0;for(let r=0;r<s.length;r++){var g;const{name:l,fn:p}=s[r],{x:x,y:v,data:y,reset:b}=await p({x:c,y:u,initialPlacement:n,placement:m,strategy:o,middlewareData:f,rects:d,platform:{...a,detectOverflow:null!=(g=a.detectOverflow)?g:ut},elements:{reference:e,floating:t}});c=null!=x?x:c,u=null!=v?v:u,f={...f,[l]:{...f[l],...y}},b&&h<=50&&(h++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(d=!0===b.rects?await a.getElementRects({reference:e,floating:t,strategy:o}):b.rects),({x:c,y:u}=ct(d,m,i))),r=-1)}return{x:c,y:u,placement:m,strategy:o,middlewareData:f}})(e,t,{...o,platform:l})};var Tt="undefined"!=typeof document?d:function(){};function Ot(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;0!==n--;)if(!Ot(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;0!==n--;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;0!==n--;){const r=o[n];if(!("_owner"===r&&e.$$typeof||Ot(e[r],t[r])))return!1}return!0}return e!=e&&t!=t}function $t(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pt(e,t){const r=$t(e);return Math.round(t*r)/r}function Kt(t){const r=e.useRef(t);return Tt(()=>{r.current=t}),r}const Wt=(e,t)=>({...Ft(e),options:[e,t]}),Vt=(e,t)=>({...At(e),options:[e,t]}),_t=(e,t)=>({...zt(e),options:[e,t]}),Bt={...e};let Gt=!1,Ht=0;const Ut=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Ht++,Yt=Bt.useId||function(){const[t,r]=e.useState(()=>Gt?Ut():void 0);return it(()=>{null==t&&r(Ut())},[]),e.useEffect(()=>{Gt=!0},[]),t};let qt;"production"!==process.env.NODE_ENV&&(qt=new Set);const Xt=e.createContext(null),Jt=e.createContext(null);function Zt(t){void 0===t&&(t={});const{nodeId:r}=t,n=function(t){const{open:r=!1,onOpenChange:n,elements:o}=t,l=Yt(),a=e.useRef({}),[s]=e.useState(()=>function(){const e=new Map;return{emit(t,r){var n;null==(n=e.get(t))||n.forEach(e=>e(r))},on(t,r){e.has(t)||e.set(t,new Set),e.get(t).add(r)},off(t,r){var n;null==(n=e.get(t))||n.delete(r)}}}()),i=null!=((null==(d=e.useContext(Xt))?void 0:d.id)||null);var d;if("production"!==process.env.NODE_ENV){const e=o.reference;e&&!xe(e)&&function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];const o="Floating UI: "+r.join(" ");var l;null!=(e=qt)&&e.has(o)||(null==(l=qt)||l.add(o),console.error(o))}("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[c,u]=e.useState(o.reference),m=function(t){const r=e.useRef(()=>{if("production"!==process.env.NODE_ENV)throw new Error("Cannot call an event handler while rendering.")});return dt(()=>{r.current=t}),e.useCallback(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return null==r.current?void 0:r.current(...t)},[])}((e,t,r)=>{a.current.openEvent=e?t:void 0,s.emit("openchange",{open:e,event:t,reason:r,nested:i}),null==n||n(e,t,r)}),f=e.useMemo(()=>({setPositionReference:u}),[]),h=e.useMemo(()=>({reference:c||o.reference||null,floating:o.floating||null,domReference:o.reference}),[c,o.reference,o.floating]);return e.useMemo(()=>({dataRef:a,open:r,onOpenChange:m,elements:h,events:s,floatingId:l,refs:f}),[r,m,h,s,l,f])}({...t,elements:{reference:null,floating:null,...t.elements}}),o=t.rootContext||n,l=o.elements,[a,s]=e.useState(null),[i,d]=e.useState(null),c=(null==l?void 0:l.domReference)||a,u=e.useRef(null),m=e.useContext(Jt);it(()=>{c&&(u.current=c)},[c]);const f=function(t){void 0===t&&(t={});const{placement:r="bottom",strategy:n="absolute",middleware:o=[],platform:l,elements:{reference:a,floating:s}={},transform:i=!0,whileElementsMounted:d,open:c}=t,[u,m]=e.useState({x:0,y:0,strategy:n,placement:r,middlewareData:{},isPositioned:!1}),[f,h]=e.useState(o);Ot(f,o)||h(o);const[p,x]=e.useState(null),[v,y]=e.useState(null),b=e.useCallback(e=>{e!==C.current&&(C.current=e,x(e))},[]),k=e.useCallback(e=>{e!==N.current&&(N.current=e,y(e))},[]),w=a||p,j=s||v,C=e.useRef(null),N=e.useRef(null),S=e.useRef(u),R=null!=d,M=Kt(d),D=Kt(l),E=Kt(c),F=e.useCallback(()=>{if(!C.current||!N.current)return;const e={placement:r,strategy:n,middleware:f};D.current&&(e.platform=D.current),It(C.current,N.current,e).then(e=>{const t={...e,isPositioned:!1!==E.current};A.current&&!Ot(S.current,t)&&(S.current=t,g.flushSync(()=>{m(t)}))})},[f,r,n,D,E]);Tt(()=>{!1===c&&S.current.isPositioned&&(S.current.isPositioned=!1,m(e=>({...e,isPositioned:!1})))},[c]);const A=e.useRef(!1);Tt(()=>(A.current=!0,()=>{A.current=!1}),[]),Tt(()=>{if(w&&(C.current=w),j&&(N.current=j),w&&j){if(M.current)return M.current(w,j,F);F()}},[w,j,F,M,R]);const L=e.useMemo(()=>({reference:C,floating:N,setReference:b,setFloating:k}),[b,k]),z=e.useMemo(()=>({reference:w,floating:j}),[w,j]),I=e.useMemo(()=>{const e={position:n,left:0,top:0};if(!z.floating)return e;const t=Pt(z.floating,u.x),r=Pt(z.floating,u.y);return i?{...e,transform:"translate("+t+"px, "+r+"px)",...$t(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,i,z.floating,u.x,u.y]);return e.useMemo(()=>({...u,update:F,refs:L,elements:z,floatingStyles:I}),[u,F,L,z,I])}({...t,elements:{...l,...i&&{reference:i}}}),h=e.useCallback(e=>{const t=xe(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;d(t),f.refs.setReference(t)},[f.refs]),p=e.useCallback(e=>{(xe(e)||null===e)&&(u.current=e,s(e)),(xe(f.refs.reference.current)||null===f.refs.reference.current||null!==e&&!xe(e))&&f.refs.setReference(e)},[f.refs]),x=e.useMemo(()=>({...f.refs,setReference:p,setPositionReference:h,domReference:u}),[f.refs,p,h]),v=e.useMemo(()=>({...f.elements,domReference:c}),[f.elements,c]),y=e.useMemo(()=>({...f,...o,refs:x,elements:v,nodeId:r}),[f,x,v,r,o]);return it(()=>{o.dataRef.current.floatingContext=y;const e=null==m?void 0:m.nodesRef.current.find(e=>e.id===r);e&&(e.context=y)}),e.useMemo(()=>({...f,context:y,refs:x,elements:v}),[f,x,v,y])}const Qt=({open:e,anchorEl:t,onClose:r,placement:n="bottom-start",offset:o=8,sameWidth:a=!1,maxHeight:s,zIndex:i=1e3,className:d,children:c,shouldIgnoreClose:u})=>{const{refs:m,floatingStyles:f,update:h}=Zt({placement:n,whileElementsMounted:Et,middleware:[Wt(o),(g={padding:8},{...Lt(g),options:[g,void 0]}),Vt({padding:8}),_t({apply({rects:e,elements:t,availableHeight:r,availableWidth:n}){const o=t.floating;o&&(a&&(o.style.width=`${e.reference.width}px`),o.style.maxHeight=null!=s?"number"==typeof s?`${s}px`:String(s):`${r}px`,null!=n&&(o.style.maxWidth=`${n}px`))}})]});var g;return l(()=>{t&&m.setReference(t),e&&h&&h()},[t,e,m,h]),l(()=>{if(!e)return;const n=e=>{const n=e.target;if(u&&u(n))return;const o=m.floating.current;o&&(t&&t.contains(n)||o&&o.contains(n)||r())},o=e=>{"Escape"===e.key&&r()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",o)}},[e,r,m.floating,t]),e&&t?p(S.jsx("div",{ref:m.setFloating,"data-popover-root":"true",style:{...f,zIndex:i,position:f.position,overflowX:"hidden"},className:d,children:c}),document.body):null},er=e=>{switch(e){case"csv":return S.jsx(se,{size:18});case"json":return S.jsx(le,{size:18});case"xlsx":return S.jsx(ae,{size:18});default:return S.jsx(H,{size:18})}},tr=e=>{switch(e){case"delete":return S.jsx(B,{size:18});case"archive":return S.jsx(G,{size:18});case"copy":return S.jsx(V,{size:18});case"edit":return S.jsx(_,{size:18});case"export":return S.jsx(H,{size:18});default:return S.jsx(te,{size:18})}},rr=e=>{switch(e){case"csv":return"CSV";case"json":return"JSON";case"xlsx":return"Excel";default:return e}},nr=["sm","md","lg"],or=({isOpen:e,anchorEl:t,onClose:r,bulkActions:n,selectedRowsCount:o,onBulkAction:l})=>S.jsxs(Qt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl ",children:[S.jsxs("div",{className:"p-3 border-b border-[var(--kd-border)] ",children:[S.jsx("h3",{className:"font-medium text-[var(--kd-foreground)]",children:"Bulk Actions"}),S.jsxs("p",{className:"text-xs text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:[o," row",1!==o?"s":""," selected"]})]}),S.jsx("div",{className:"p-2",children:n.map(e=>S.jsxs("button",{onClick:()=>l(e),disabled:e.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm rounded-[var(--kd-radius)] transition-colors "+(e.disabled?"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] cursor-not-allowed":e.destructive?"text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-[var(--kd-foreground)] hover:bg-[var(--kd-muted)]"),children:[e.icon??tr(e.id),e.label]},e.id))})]}),lr=({isOpen:e,anchorEl:t,onClose:r,filteredColumns:n,columnVisibility:o,onColumnToggle:l,columnSearch:a,onColumnSearchChange:s,onResetColumns:i,onScrollToColumn:d,onColumnVisibilityChange:c,draggingKey:u,dragOver:m,handleDragStart:f,handleDragOver:h,handleDrop:g,handleDragEnd:p})=>S.jsxs(Qt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-72 max-w-[90vw] bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl ",children:[S.jsxs("div",{className:"p-3 border-b border-[var(--kd-border)] ",children:[S.jsx("h3",{className:"font-medium text-[var(--kd-foreground)]",children:"Show/Hide Columns"}),S.jsxs("div",{className:"relative mt-2",children:[S.jsx(oe,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--kd-muted-foreground)] w-4 h-4 dark:text-[var(--kd-muted-foreground)]"}),S.jsx("input",{type:"text",placeholder:"Search columns...",className:"w-full pl-8 pr-2 py-1.5 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] text-sm dark:border-gray-600 dark:text-gray-300",value:a,onChange:e=>s(e.target.value)})]})]}),S.jsx("div",{className:"max-h-60 overflow-y-auto p-2",children:n.map(e=>{const t=!1!==o[e.key];return S.jsxs("label",{className:`flex items-center gap-3 p-2 hover:bg-[var(--kd-muted)] rounded-[var(--kd-radius)] cursor-grab relative ${u===e.key?"opacity-60":""} dark:hover:bg-gray-800`,draggable:!0,onDragStart:t=>f(e.key,t),onDragOver:t=>h(e.key,t),onDrop:()=>g(e.key),onDragEnd:p,children:[m?.key===e.key&&S.jsx("span",{className:"absolute left-2 right-2 h-0.5 bg-[var(--kd-primary)]",style:{top:"before"===m.position?0:void 0,bottom:"after"===m.position?0:void 0}}),S.jsx("input",{type:"checkbox",checked:t,onChange:()=>l(e.key),className:"rounded border-gray-300 text-[var(--kd-primary)] focus:ring-[var(--kd-ring)] dark:border-gray-600 dark:text-blue-400"}),t?S.jsx(re,{className:"w-4 h-4 text-green-600"}):S.jsx(ne,{className:"w-4 h-4 text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"}),S.jsx("span",{className:"text-sm text-[var(--kd-foreground)] truncate",children:e.header}),S.jsx("button",{type:"button",onClick:r=>{r.preventDefault(),r.stopPropagation(),t?d?.(e.key):(c?.(e.key,!0),requestAnimationFrame(()=>d?.(e.key)))},className:"ml-auto p-1 text-[var(--kd-muted-foreground)] hover:text-[var(--kd-primary)] dark:text-[var(--kd-muted-foreground)] transition-colors",title:"Scroll to this column",children:S.jsx(ce,{className:"w-4 h-4"})})]},e.key)})}),S.jsx("div",{className:"p-2 border-t border-[var(--kd-border)] ",children:S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--kd-muted-foreground)] hover:text-[var(--kd-foreground)] cursor-pointer hover:bg-[var(--kd-muted)] px-3 py-1.5 rounded transition-colors min-h-9 dark:text-[var(--kd-muted-foreground)] dark:hover:text-gray-100 dark:hover:bg-gray-800",children:[S.jsx("input",{type:"checkbox",checked:n.length>0&&n.every(e=>!1!==o[e.key]),onChange:e=>{n.forEach(t=>{c?.(t.key,e.target.checked)})},className:"rounded border-gray-300 text-[var(--kd-primary)] focus:ring-[var(--kd-ring)] dark:border-gray-600 dark:text-blue-400"}),S.jsx("span",{children:"Select All"})]}),S.jsx("button",{className:"text-sm text-[var(--kd-muted-foreground)] hover:text-[var(--kd-foreground)] hover:bg-[var(--kd-muted)] px-3 py-1.5 rounded transition-colors min-h-9 dark:text-[var(--kd-muted-foreground)] dark:hover:text-gray-100 dark:hover:bg-gray-800",onClick:i,children:"Reset All"})]})})]}),ar=({isOpen:e,anchorEl:t,onClose:r,exportFormats:n,filteredDataLength:o,selectedRowsCount:l,onExport:a})=>{const s=l>0;return S.jsxs(Qt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-[90vw] sm:w-64 max-w-[90vw] bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl ",children:[S.jsxs("div",{className:"p-3 border-b border-[var(--kd-border)] ",children:[S.jsx("h3",{className:"font-medium text-[var(--kd-foreground)]",children:"Export Data"}),S.jsx("p",{className:"text-xs text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:"Choose format and data scope"})]}),S.jsxs("div",{className:"p-2",children:[S.jsxs("div",{className:"mb-3",children:[S.jsx("p",{className:"text-xs font-medium text-[var(--kd-foreground)] mb-2 px-2 dark:text-gray-300",children:"Export All Data"}),S.jsx("div",{className:"space-y-1",children:n.map(e=>S.jsxs("button",{onClick:()=>a(e,!1),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kd-foreground)] hover:bg-[var(--kd-muted)] rounded-[var(--kd-radius)] transition-colors cursor-pointer",children:[er(e),S.jsxs("span",{children:["Export as ",rr(e)]}),S.jsxs("span",{className:"ml-auto text-xs text-[var(--kd-muted-foreground)]",children:[o.toLocaleString()," rows"]})]},`all-${e}`))})]}),s&&S.jsxs("div",{children:[S.jsx("p",{className:"text-xs font-medium text-[var(--kd-foreground)] mb-2 px-2 dark:text-gray-300",children:"Export Selected"}),S.jsx("div",{className:"space-y-1",children:n.map(e=>S.jsxs("button",{onClick:()=>a(e,!0),className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-blue-700 hover:bg-[var(--kd-muted)] rounded-[var(--kd-radius)] transition-colors dark:text-blue-400 dark:hover:bg-blue-900/20",children:[er(e),S.jsxs("span",{children:["Export as ",rr(e)]}),S.jsxs("span",{className:"ml-auto text-xs text-blue-500",children:[l," rows"]})]},`selected-${e}`))})]})]})]})},sr=({options:e,value:t,placeholder:r="Select an option...",onChange:n,searchable:a=!0,className:s=""})=>{const[d,c]=o(!1),[u,m]=o(""),[f,h]=o(-1),g=i(null),p=i(null),x=i(null),v=e.find(e=>e.value===t),y=a?e.filter(e=>e.label?.toLowerCase()?.includes(u?.toLowerCase())):e;l(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(c(!1),m(""),h(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l(()=>{const e=e=>{if(d)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>e<y.length-1?e+1:0);break;case"ArrowUp":e.preventDefault(),h(e=>e>0?e-1:y.length-1);break;case"Enter":e.preventDefault(),f>=0&&y[f]&&b(y[f].value);break;case"Escape":c(!1),m(""),h(-1)}};if(d)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[d,f,y]),l(()=>{if(f>=0&&x.current){const e=x.current.children[f];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}},[f]);const b=e=>{n(e),c(!1),m(""),h(-1)};return S.jsxs("div",{className:`relative ${s}`,ref:g,children:[S.jsx("div",{className:"relative w-full cursor-pointer border border-[var(--kd-border)] rounded-[var(--kd-radius)] bg-[var(--kd-background)] transition-all duration-200 "+(d?"ring-2 ring-[var(--kd-ring)] border-[var(--kd-primary)]":"hover:border-[var(--kd-primary)]/40 focus-within:ring-2 focus-within:ring-[var(--kd-ring)] focus-within:border-[var(--kd-primary)]"),onClick:()=>{c(!d),a&&!d&&setTimeout(()=>p.current?.focus(),0)},children:S.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5",children:[a&&d?S.jsx("input",{ref:p,type:"text",className:"flex-1 outline-none text-sm bg-transparent text-[var(--kd-foreground)]",placeholder:r,value:u,onChange:e=>{m(e.target.value),h(-1),d||c(!0)},onClick:e=>e.stopPropagation()}):S.jsx("span",{className:"flex-1 text-sm truncate "+(v?"text-[var(--kd-foreground)]":"text-[var(--kd-muted-foreground)]"),children:v?v.label:r}),S.jsx(z,{className:"w-4 h-4 text-[var(--kd-muted-foreground)] transition-transform duration-200 "+(d?"rotate-180":"")})]})}),d&&S.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-[var(--kd-background)] border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-lg z-99999 max-h-80 overflow-hidden",children:y.length>0?S.jsx("ul",{ref:x,className:"py-1 overflow-y-auto max-h-80",children:y.map((e,t)=>S.jsxs("li",{className:"px-3 py-2 text-sm cursor-pointer flex items-center justify-between transition-colors "+(t===f?"bg-[var(--kd-muted)] text-[var(--kd-primary)]":"text-[var(--kd-foreground)] hover:bg-[var(--kd-muted)]"),onClick:()=>b(e.value),onMouseEnter:()=>h(t),children:[S.jsx("span",{className:"truncate",children:e.label}),v?.value===e.value&&S.jsx(W,{className:"w-4 h-4 text-[var(--kd-primary)] shrink-0 ml-2"})]},e.value))}):S.jsx("div",{className:"px-3 py-2 text-sm text-[var(--kd-muted-foreground)] text-center",children:"No options found"})})]})},ir=({name:e,label:t,value:r,onChange:n,className:o=""})=>S.jsxs("div",{className:`space-y-1 ${o}`,children:[t&&S.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t}),S.jsx("input",{type:"date",name:e,value:r||"",onChange:e=>n(e.target.value||null),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})]}),dr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,cr=e=>{const[t,r,n]=e.split("-").map(Number);return t&&r&&n?new Date(t,r-1,n):new Date(NaN)},ur=e=>`${String(e.getDate()).padStart(2,"0")}-${String(e.getMonth()+1).padStart(2,"0")}-${e.getFullYear()}`,mr=({columns:e,columnFilters:t,onColumnFilter:r})=>{const n=e.filter(e=>e.filterable),[a,s]=o(n.length>0?n[0].key:""),[i,d]=o(""),c=n.map(e=>({label:e.header,value:e.key})),u=n.find(e=>e.key===a);return l(()=>{d("")},[a]),S.jsxs("div",{className:"space-y-4",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:"Select Column to Filter"}),S.jsx(sr,{options:c,value:a,placeholder:"Choose a column...",onChange:e=>{s(e)},searchable:!0})]}),a&&(()=>{if(!u)return null;const e=u.filterable?.type||"text",n=t[a];if("multiselect"===e&&u.filterable?.options){const e=i.toLowerCase(),t=e?u.filterable.options.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)):u.filterable.options;return S.jsxs("div",{className:"mt-3",children:[S.jsxs("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:["Filter by ",u.header]}),S.jsxs("div",{className:"relative mb-2",children:[S.jsx(oe,{className:"w-4 h-4 text-[var(--kd-muted-foreground)] absolute left-2 top-1/2 -translate-y-1/2"}),S.jsx("input",{type:"text",value:i,onChange:e=>d(e.target.value),placeholder:"Search options...",className:"w-full pl-8 pr-2 py-1.5 border border-[var(--kd-border)] rounded-[var(--kd-radius)] text-sm focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] bg-[var(--kd-background)] text-[var(--kd-foreground)]"}),i&&S.jsx("button",{type:"button",onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--kd-muted-foreground)] hover:text-[var(--kd-foreground)]",title:"Clear search",children:S.jsx(K,{className:"w-3 h-3"})})]}),S.jsxs("div",{className:"max-h-32 overflow-y-auto border border-[var(--kd-border)] rounded-[var(--kd-radius)] p-2 bg-[var(--kd-background)]",children:[0===t.length&&S.jsx("div",{className:"text-xs text-[var(--kd-muted-foreground)] px-1 py-1",children:"No matches"}),t.map(e=>{const t=n?.value||[],o=Array.isArray(t)&&t.includes(e.value);return S.jsxs("label",{className:"flex items-center gap-2 py-1 hover:bg-[var(--kd-muted)] cursor-pointer rounded px-1 text-[var(--kd-foreground)]",children:[S.jsx("input",{type:"checkbox",className:"rounded border-[var(--kd-border)] text-[var(--kd-primary)] focus:ring-[var(--kd-ring)] bg-[var(--kd-background)] h-4 w-4",checked:o,onChange:t=>{const o=n?.value||[];let l;l=t.target.checked?[...o,e.value]:o.filter(t=>t!==e.value),r?.(a,l.length>0?{type:"multiselect",value:l,operator:"in"}:null)}}),S.jsx("span",{className:"text-sm",children:e.label})]},e.value)})]})]})}if("select"===e&&u.filterable?.options){const e=[{label:`All ${u.header}`,value:""},...u.filterable.options.map(e=>({label:e.label,value:String(e.value)}))];return S.jsxs("div",{className:"mt-3",children:[S.jsxs("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:["Filter by ",u.header]}),S.jsx(sr,{options:e,value:n?.value||"",placeholder:`Select ${u.header.toLowerCase()}...`,onChange:e=>{r?.(a,e?{type:"select",value:e,operator:"between"}:null)},searchable:!0})]})}if("date"===e){const e=e=>{if(!e)return null;if(e instanceof Date&&!isNaN(e.getTime()))return e;const t=cr(String(e));if(!isNaN(t.getTime()))return t;const r=new Date(e);return isNaN(r.getTime())?null:r},t=e(n?.value),o=e(n?.secondValue),l=n?.operator||"between";return S.jsxs("div",{className:"mt-3",children:[S.jsxs("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:["Filter by ",u.header]}),S.jsx("div",{className:"mb-3",children:S.jsx(sr,{options:[{label:"Between Dates",value:"between"},{label:"On Date",value:"equals"}],value:l,placeholder:"Select date filter...",onChange:e=>{r?.(a,{type:"date",value:n?.value||"",operator:e,secondValue:n?.secondValue||""})},searchable:!1},`date-operator-${a}-${l}`)}),S.jsxs("div",{className:"flex items-end gap-2",children:[S.jsx("div",{className:"flex-1 min-w-37.5",children:S.jsx(ir,{name:"column_filter_start",label:"between"===l?"Start Date":"Date",value:t?dr(t):null,onChange:e=>{if(e){const t=dr(cr(e));r?.(a,{type:"date",value:t,operator:l,secondValue:n?.secondValue||null})}else r?.(a,null)},className:"w-full"})}),"between"===l&&S.jsx("div",{className:"flex-1 min-w-37.5",children:S.jsx(ir,{name:"column_filter_end",label:"End Date",value:o?dr(o):null,onChange:e=>{if(e&&n){const t=dr(cr(e));r?.(a,{...n,secondValue:t})}},className:"w-full"})})]})]})}return S.jsxs("div",{className:"mt-3",children:[S.jsxs("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:["Filter by ",u.header]}),S.jsxs(S.Fragment,{children:[S.jsx("input",{type:"text",placeholder:u.filterable?.placeholder||`Filter ${u.header.toLowerCase()}...`,className:"w-full px-3 py-2.5 border border-[var(--kd-border)] rounded-[var(--kd-radius)] text-sm focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] transition-all duration-200 bg-[var(--kd-background)] text-[var(--kd-foreground)]",value:n?.value||"",onChange:e=>{r?.(a,e.target.value?{type:"text",value:e.target.value,operator:"contains"}:null)}}),n&&S.jsx("div",{className:"mt-2",children:S.jsx(sr,{options:[{label:"Contains",value:"contains"},{label:"Equals",value:"equals"},{label:"Starts with",value:"startsWith"},{label:"Ends with",value:"endsWith"}],value:n?.operator||"contains",placeholder:"Select operator...",onChange:e=>{n&&r?.(a,{...n,operator:e})},searchable:!1})})]})]})})(),Object.keys(t).length>0&&S.jsxs("div",{className:"mt-4",children:[S.jsx("label",{className:"text-sm font-medium text-[var(--kd-foreground)] mb-2 block",children:"Active Filters"}),S.jsx("div",{className:"space-y-2",children:Object.entries(t).map(([e,t])=>{const o=n.find(t=>t.key===e);return o?S.jsxs("div",{className:"flex items-center justify-between bg-[var(--kd-accent)] border border-[var(--kd-primary)]/20 rounded-[var(--kd-radius)] px-3 py-2 cursor-pointer hover:bg-[var(--kd-primary)]/10 text-[var(--kd-foreground)]",role:"button",title:`Edit filter for ${o.header}`,onClick:()=>(e=>{s(e)})(e),children:[S.jsxs("div",{className:"flex-1",children:[S.jsxs("span",{className:"text-sm font-medium",children:[o.header,":"]}),S.jsx("span",{className:"text-sm opacity-80 ml-1",children:(()=>{if(Array.isArray(t.value))return`${t.value.length} selected`;if("date"===t.type){const e=e=>{try{if(!e)return"";if(e instanceof Date&&!isNaN(e.getTime()))return ur(e);if("string"==typeof e){const t=cr(e);if(!isNaN(t.getTime()))return ur(t);const r=new Date(e);if(!isNaN(r.getTime()))return ur(r)}return String(e)}catch{return String(e??"")}},r={equals:"On",gt:"After",gte:"On or After",lt:"Before",lte:"On or Before",between:"Between"}[t.operator]||"On";return"between"===t.operator&&t.secondValue?`${r} ${e(t.value)} - ${e(t.secondValue)}`:`${r} ${e(t.value)}`}return t.value})()})]}),S.jsx("button",{onClick:t=>{t.stopPropagation(),r?.(e,null)},className:"text-[var(--kd-muted-foreground)] hover:text-red-500 transition-colors",title:"Clear filter",children:S.jsx(K,{className:"w-4 h-4"})})]},e):null})})]})]})},fr=({isOpen:e,anchorEl:t,onClose:r,onClearFilters:n,columns:o,columnFilters:l,onColumnFilter:a,hasFilterableColumns:s})=>s?S.jsxs(Qt,{open:e,anchorEl:t,onClose:r,placement:"bottom-start",offset:8,zIndex:1e3,maxHeight:520,className:"w-88 sm:w-88 max-w-[90vw] bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl overflow-y-auto min-h-100 ",shouldIgnoreClose:e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1},children:[S.jsxs("div",{className:"flex items-center justify-between px-2",children:[S.jsxs("div",{className:"p-3 border-b border-[var(--kd-border)] ",children:[S.jsx("h3",{className:"font-medium text-[var(--kd-foreground)]",children:"Column Filters"}),S.jsx("p",{className:"text-xs text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:"Filter data by column values"})]}),S.jsx("button",{onClick:n,className:"px-3 py-1.5 text-sm text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] border border-gray-300 dark:border-gray-600 rounded-[var(--kd-radius)] hover:bg-[var(--kd-muted)] transition-colors",children:"Clear All"})]}),S.jsx("div",{className:"p-3 space-y-3",children:S.jsx(mr,{columns:o,columnFilters:l,onColumnFilter:a})}),S.jsx("div",{className:"flex items-center justify-between p-3 border-t border-[var(--kd-border)]",children:S.jsx("div",{className:"text-sm text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]",children:Object.keys(l).length>0&&S.jsxs("span",{children:[Object.keys(l).length," filter",1!==Object.keys(l).length?"s":""," applied"]})})})]}):null,hr=({isOpen:e,anchorEl:t,onClose:r,density:n,onDensityChange:o,showDensityControl:l=!0})=>S.jsxs(Qt,{open:e,anchorEl:t,onClose:r,placement:"bottom-end",offset:8,zIndex:1e3,className:"w-56 bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl ",children:[S.jsxs("div",{className:"p-3 border-b border-[var(--kd-border)] ",children:[S.jsx("h3",{className:"font-medium text-[var(--kd-foreground)]",children:"Grid Settings"}),S.jsx("p",{className:"text-xs text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:"Customize your display preferences"})]}),S.jsx("div",{className:"p-3",children:l&&S.jsxs("div",{className:"space-y-3",children:[S.jsx("label",{className:"text-xs font-semibold text-[var(--kd-foreground)] uppercase tracking-wider",children:"Row Density"}),S.jsx("div",{className:"flex items-center gap-1 bg-[var(--kd-muted)] /50 border border-[var(--kd-border)] rounded-[var(--kd-radius)] p-1",children:nr.map(e=>S.jsx("button",{onClick:()=>o?.(e),className:"flex-1 px-2 py-1.5 text-xs font-medium rounded-[var(--kd-radius)] transition-all "+(n===e?"bg-[var(--kd-primary)] text-white shadow-md scale-105":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] hover:bg-white dark:hover:bg-gray-800 hover:shadow-sm"),children:e.toUpperCase()},e))})]})})]}),gr=({globalFilter:e,filteredDataLength:t,totalDataLength:r,selectedRowsCount:n=0,selectedRows:d=new Set,showExport:c=!0,showColumnToggle:u=!0,showBulkActions:m=!0,columns:f=[],columnVisibility:h={},columnFilters:g={},bulkActions:p=[],exportOptions:x,onGlobalFilterChange:v,onClearFilters:y,onColumnVisibilityChange:b,onColumnFilter:k,onResetColumns:w,columnOrder:j=[],onColumnOrderChange:C,pinnedColumns:N,onScrollToColumn:R,density:M="md",onDensityChange:D,showDensityControl:E=!1,customLeftContent:F,customRightContent:A})=>{const[L,z]=o(""),I=i(null),{showExportMenu:T,setShowExportMenu:O,exportMenuRef:$,exportAnchorRef:P,showFilters:W,setShowFilters:V,filtersMenuRef:_,filtersAnchorRef:B,showBulkActionsMenu:G,setShowBulkActionsMenu:U,bulkActionsRef:q,bulkActionsAnchorRef:J,showColumnMenu:Z,setShowColumnMenu:Q,columnMenuRef:ee,columnAnchorRef:re,showSettingsMenu:ne,setShowSettingsMenu:le,settingsMenuRef:ae,settingsAnchorRef:se}=function(){const[e,t]=o(!1),[r,n]=o(!1),[a,d]=o(!1),[c,u]=o(!1),[m,f]=o(!1),h=i(null),g=i(null),p=i(null),x=i(null),v=i(null),y=i(null),b=i(null),k=i(null),w=i(null),j=i(null),C=s(()=>{t(!1),n(!1),d(!1),u(!1),f(!1)},[]);return l(()=>{const o=o=>{const l=o.target;(e=>{let t=e;for(;t;){if(t.getAttribute&&"true"===t.getAttribute("data-popover-root")||t.dataset&&"true"===t.dataset.popoverRoot)return!0;t=t.parentNode}return!1})(l)||(e&&h.current&&!h.current.contains(l)&&t(!1),a&&g.current&&!g.current.contains(l)&&d(!1),c&&p.current&&!p.current.contains(l)&&u(!1),m&&v.current&&!v.current.contains(l)&&f(!1),r&&x.current&&!x.current.contains(l)&&!(e=>{let t=e;for(;t;){if(t.classList){const e=Array.from(t.classList).join(" ");if(/MuiPickers|MuiDatePicker|MuiPickersPopper/.test(e))return!0}if(t.getAttribute&&"dialog"===t.getAttribute("role")){const e=t.className?.toString()||"";if(/MuiPickers|MuiDatePicker/.test(e))return!0}t=t.parentNode}return!1})(l)&&n(!1))};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,a,c,m,r]),{showExportMenu:e,setShowExportMenu:t,showFilters:r,setShowFilters:n,showBulkActionsMenu:a,setShowBulkActionsMenu:d,showColumnMenu:c,setShowColumnMenu:u,showSettingsMenu:m,setShowSettingsMenu:f,exportMenuRef:h,bulkActionsRef:g,columnMenuRef:p,filtersMenuRef:x,settingsMenuRef:v,exportAnchorRef:y,bulkActionsAnchorRef:b,columnAnchorRef:k,filtersAnchorRef:w,settingsAnchorRef:j,closeAllMenus:C}}(),{draggingKey:de,dragOver:ce,handleDragStart:ue,handleDragOver:me,handleDrop:fe,handleDragEnd:he}=function({columns:e,columnOrder:t,pinnedColumns:r,onColumnOrderChange:n}){const[l,a]=o(null),[i,d]=o(null),c=s((e,t)=>{a(e),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e))},[]),u=s((e,t)=>{t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move");const r=t.currentTarget.getBoundingClientRect();d({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},[]),m=s(o=>{const s=l;if(!s||s===o)return;if(r&&r.has(s)!==r.has(o))return a(null),void d(null);const c=i?.key!==o||"before"===i.position,u=(t&&t.length?t:e.map(e=>e.key)).filter(e=>e!==s);let m=u.indexOf(o);if(-1===m)return n?.(u),a(null),void d(null);c||(m+=1),u.splice(m,0,s),n?.(u),a(null),d(null)},[l,i,t,e,r,n]),f=s(()=>{a(null),d(null)},[]);return{draggingKey:l,dragOver:i,handleDragStart:c,handleDragOver:u,handleDrop:m,handleDragEnd:f}}({columns:f,columnOrder:j,pinnedColumns:N,onColumnOrderChange:C}),ge=x?.formats||["xlsx"],pe=(e?.length??0)>0||Object.keys(g||{}).length>0,xe=n>0;f.filter(e=>!1!==h[e.key]);const ve=a(()=>[...j.map(e=>f.find(t=>t.key===e)).filter(Boolean),...f.filter(e=>!j.includes(e.key))],[j,f]),ye=a(()=>ve.filter(e=>e.header?.toLowerCase()?.includes(L?.toLowerCase())),[ve,L]),be=a(()=>f.some(e=>e.filterable),[f]);return S.jsxs("div",{className:"bg-[var(--kd-background)] border-b border-[var(--kd-border)] font-inter",role:"toolbar","aria-label":"Data grid toolbar",children:[S.jsxs("div",{id:"search-results-status",className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:[pe?`Showing ${t} of ${r} rows`:`${t} total rows`,xe&&`, ${n} row${1!==n?"s":""} selected`]}),S.jsx("div",{className:"px-3 py-2",children:S.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-4",children:[S.jsxs("div",{className:"order-1 flex items-center flex-wrap gap-2 sm:gap-3",children:[S.jsxs("div",{className:"relative",ref:_,children:[be&&S.jsxs("button",{ref:B,onClick:()=>V(!W),className:"flex cursor-pointer items-center gap-2 px-3 py-1.5 border rounded-[var(--kd-radius)] transition-all duration-200 "+(W?"bg-[var(--kd-muted)] dark:bg-blue-900/40 border-blue-200 dark:border-[var(--kd-primary)] text-blue-700 dark:text-blue-300":"border-gray-300 dark:border-gray-600 text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] hover:bg-[var(--kd-muted)]"),"aria-haspopup":"menu","aria-expanded":W,title:"Filter columns",children:[S.jsx(Y,{className:"w-4 h-4"}),S.jsx("span",{className:"hidden sm:inline text-sm font-medium",children:"Filters"}),Object.keys(g).length>0&&S.jsxs("button",{type:"button",onClick:e=>{e.stopPropagation(),y?.()},className:"bg-red-600 hover:bg-red-600 text-white text-[10px] sm:text-xs px-1.5 py-0.5 rounded-full min-w-5 h-5 flex items-center justify-center transition-all group relative",title:"Clear all filters",children:[S.jsx("span",{className:"group-hover:hidden",children:Object.keys(g).length}),S.jsx(K,{className:"w-3 h-3 hidden group-hover:block absolute"})]})]}),S.jsx(fr,{isOpen:W,anchorEl:B.current,onClose:()=>V(!1),onClearFilters:y,columns:f,columnFilters:g,onColumnFilter:k,hasFilterableColumns:be})]}),F]}),S.jsxs("div",{className:"order-2 flex items-center gap-2 sm:gap-3 flex-wrap sm:flex-nowrap flex-1 justify-end min-w-0",children:[A,c&&x?.enabled&&S.jsxs("div",{className:"relative",ref:$,children:[S.jsx("button",{ref:P,onClick:()=>O(!T),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-[var(--kd-radius)] hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)] transition-all duration-200 "+(T?"bg-[var(--kd-muted)] border-gray-400":""),title:"Export data","aria-haspopup":"menu","aria-expanded":T,children:S.jsx(H,{className:"w-4 h-4"})}),S.jsx(ar,{isOpen:T,anchorEl:P.current,onClose:()=>O(!1),exportFormats:ge,filteredDataLength:t,selectedRowsCount:n,onExport:(e,t=!1)=>{x?.onExport?.(e,t),O(!1)}})]}),S.jsxs("div",{className:"relative flex-1 min-w-0 max-w-[160px] sm:max-w-[240px]",children:[S.jsx(oe,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--kd-muted-foreground)] w-4 h-4 dark:text-[var(--kd-muted-foreground)]"}),S.jsx("input",{ref:I,type:"text",placeholder:"Global Search...",className:"w-full pl-10 pr-10 py-2 border border-gray-300 dark:border-gray-600 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:text-gray-200 transition-all text-sm shadow-sm",value:e,onChange:v}),e&&S.jsx("button",{onClick:()=>v({target:{value:""}}),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-[var(--kd-muted-foreground)] hover:text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] dark:hover:text-gray-300 transition-colors p-1",title:"Clear search",children:S.jsx(K,{className:"w-4 h-4"})})]}),m&&xe&&p.length>0&&S.jsxs("div",{className:"relative",ref:q,children:[S.jsxs("button",{ref:J,onClick:()=>U(!G),className:"flex items-center gap-2 px-3 py-2.5 bg-orange-600 text-white rounded-[var(--kd-radius)] hover:bg-orange-700 transition-all shadow-md shrink-0 active:scale-95",children:[S.jsx(te,{className:"w-4 h-4"}),S.jsxs("span",{className:"hidden sm:inline text-sm font-semibold",children:["Actions (",n,")"]})]}),S.jsx(or,{isOpen:G,anchorEl:J.current,onClose:()=>U(!1),bulkActions:p,selectedRowsCount:n,onBulkAction:e=>{e.disabled||(e.onClick(d),U(!1))}})]}),u&&f.length>0&&S.jsxs("div",{className:"relative",ref:ee,children:[S.jsx("button",{ref:re,onClick:()=>Q(!Z),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-[var(--kd-radius)] hover:bg-[var(--kd-muted)] transition-all shrink-0 "+(Z?"border-gray-400 bg-[var(--kd-muted)] ":""),title:"Manage columns",children:S.jsx(ie,{className:"w-4 h-4 dark:text-gray-300"})}),S.jsx(lr,{isOpen:Z,anchorEl:re.current,onClose:()=>Q(!1),filteredColumns:ye,columnVisibility:h,onColumnToggle:e=>{const t=!1!==h[e];b?.(e,!t)},columnSearch:L,onColumnSearchChange:z,onResetColumns:()=>{f.forEach(e=>{b?.(e.key,!1!==e.visible)}),C?.(f.map(e=>e.key)),w?.()},onScrollToColumn:R,onColumnVisibilityChange:b,draggingKey:de,dragOver:ce,handleDragStart:ue,handleDragOver:me,handleDrop:fe,handleDragEnd:he})]}),S.jsxs("div",{className:"relative",ref:ae,children:[S.jsx("button",{ref:se,onClick:()=>le(!ne),className:"p-2.5 cursor-pointer border border-gray-300 dark:border-gray-600 rounded-[var(--kd-radius)] hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)] transition-all "+(ne?"bg-[var(--kd-muted)] ":""),title:"Grid settings","aria-haspopup":"menu","aria-expanded":ne,children:S.jsx(X,{className:"w-4 h-4"})}),S.jsx(hr,{isOpen:ne,anchorEl:se.current,onClose:()=>le(!1),density:M,onDensityChange:D,showDensityControl:E})]})]})]})})]})};gr.displayName="SearchToolbar";const pr=c(gr),xr=({columns:e,groupedKeys:t,onRemove:r,onReorder:n,onDropColumnKey:l,onToggleExpandAll:a,isAnyExpanded:s=!1})=>{const[i,d]=o(null),[c,u]=o(null),[m,f]=o(!0),h=t=>e.find(e=>e.key===t)?.header||t,g=e=>t=>{d(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-group-key",e)},p=e=>t=>{t.preventDefault();const r=t.currentTarget.getBoundingClientRect(),n=t.clientX<r.left+r.width/2;u(e),f(n)};return S.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kd-muted)] border-b border-[var(--kd-border)] text-sm ",onDrop:e=>{e.preventDefault();const r=e.dataTransfer.getData("text/plain");r&&(t.includes(r)||l(r))},onDragOver:e=>{e.preventDefault()},onDragEnd:()=>{d(null),u(null)},children:[S.jsx("span",{className:"text-[var(--kd-muted-foreground)] whitespace-nowrap dark:text-[var(--kd-muted-foreground)]",children:"Group by:"}),t.length>0&&S.jsx("button",{type:"button",className:"ml-1 px-2 py-1 text-xs border border-gray-300 rounded hover:bg-[var(--kd-muted)] dark:border-gray-600 ",title:s?"Collapse all groups":"Expand all groups",onClick:e=>{e.preventDefault(),e.stopPropagation(),a?.()},children:s?"Collapse All":"Expand All"}),0===t.length&&S.jsx("span",{className:"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]",children:"Drag a column here"}),S.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.map(e=>{return S.jsxs("div",{className:"inline-flex items-center gap-2 bg-blue-100 text-blue-800 px-2 py-1 rounded-[var(--kd-radius)] border border-blue-200 cursor-move relative dark:bg-blue-900/40 dark:text-blue-300 dark:border-blue-800",draggable:!0,onDragStart:g(e),onDragOver:p(e),onDrop:(o=e,()=>{if(!i||i===o)return d(null),void u(null);const e=t.filter(e=>e!==i),r=e.indexOf(o);-1!==r&&(e.splice(m?r:r+1,0,i),n(e),d(null),u(null))}),title:h(e),children:[S.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:h(e)}),S.jsx("button",{className:"text-blue-700 hover:text-blue-900 dark:text-blue-400",onClick:()=>r(e),"aria-label":`Remove grouping ${h(e)}`,children:"×"}),c===e&&S.jsx("span",{className:"absolute top-0 bottom-0 w-0.5 bg-[var(--kd-primary)] dark:bg-blue-400 animate-pulse",style:{left:m?0:void 0,right:m?void 0:0},"aria-hidden":"true"})]},e);var o})})]})},vr=({showToolbar:e,filterable:t,globalFilter:r,filteredDataLength:n,totalDataLength:o,paginationMode:l,selectedRowsCount:a,showExport:s,columns:i,columnFilters:d,columnVisibility:c,onResetColumns:u,exportOptions:m,toolbarLeft:f,toolbarRight:h,onGlobalFilterChange:g,onClearFilters:p,onColumnFilter:x,onColumnVisibilityChange:v,columnOrder:y,onColumnOrderChange:b,pinnedColumns:k,onScrollToColumn:w,density:j,onDensityChange:C,showDensityControl:N,groupable:R,groupBarVisibility:M,groupConfig:D,removeGroupKey:E,setGroupKeys:F,addGroupKey:A,collapseAllGroups:L,expandAllGroups:z})=>S.jsxs(S.Fragment,{children:[e&&t&&S.jsx(pr,{globalFilter:r,filteredDataLength:n,totalDataLength:o,paginationMode:l,selectedRowsCount:a,showExport:s,columns:i,columnFilters:d,columnVisibility:c,onResetColumns:u,exportOptions:m,customLeftContent:f,customRightContent:h,onGlobalFilterChange:g,onClearFilters:p,onColumnFilter:x,onColumnVisibilityChange:v,columnOrder:y,onColumnOrderChange:b,pinnedColumns:k,onScrollToColumn:w,density:j,onDensityChange:C,showDensityControl:N}),R&&("visible"===M||"auto"===M&&D.columnKeys.length>0)&&S.jsx(xr,{columns:i,groupedKeys:D.columnKeys,onRemove:E,onReorder:F,onDropColumnKey:A,isAnyExpanded:D.expanded.size>0,onToggleExpandAll:()=>{D.expanded.size>0?L():z()}})]}),yr=48,br=({value:e,onChange:t,placeholder:r="Enter text to filter..."})=>{const[n,l]=o(String(e?.value??"")),[a,s]=o(e?.operator||"contains");return S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"Filter Type"}),S.jsxs("select",{value:a,onChange:e=>(e=>{const r=e;s(r),n.trim()&&t({type:"text",value:n,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 ",children:[S.jsx("option",{value:"contains",children:"Contains"}),S.jsx("option",{value:"equals",children:"Equals"}),S.jsx("option",{value:"startsWith",children:"Starts with"}),S.jsx("option",{value:"endsWith",children:"Ends with"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"Text Value"}),S.jsx("input",{type:"text",value:n,onChange:e=>{return l(r=e.target.value),void(r.trim()?t({type:"text",value:r,operator:a}):t(null));var r},placeholder:r,className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 "})]})]})},kr=({value:e,onChange:t,min:r,max:n})=>{const[l,a]=o(String(e?.value??"")),[s,i]=o(String(e?.secondValue??"")),[d,c]=o(e?.operator||"equals"),u=(e,r=!1)=>{r?i(e):a(e);const n=parseFloat(e),o=parseFloat(s);"between"===d?isNaN(n)||isNaN(o)?t(null):t({type:"number",value:Math.min(n,o),secondValue:Math.max(n,o),operator:"between"}):isNaN(n)?t(null):t({type:"number",value:n,operator:d})};return S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"Filter Type"}),S.jsxs("select",{value:d,onChange:e=>(e=>{const r=e;if(c(r),"between"===r){const e=parseFloat(l),r=parseFloat(s);isNaN(e)||isNaN(r)||t({type:"number",value:Math.min(e,r),secondValue:Math.max(e,r),operator:"between"})}else{const e=parseFloat(l);isNaN(e)||t({type:"number",value:e,operator:r})}})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 ",children:[S.jsx("option",{value:"equals",children:"Equals"}),S.jsx("option",{value:"gt",children:"Greater than"}),S.jsx("option",{value:"gte",children:"Greater than or equal"}),S.jsx("option",{value:"lt",children:"Less than"}),S.jsx("option",{value:"lte",children:"Less than or equal"}),S.jsx("option",{value:"between",children:"Between"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"between"===d?"From Value":"Number Value"}),S.jsx("input",{type:"number",value:l,onChange:e=>u(e.target.value),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 "})]}),"between"===d&&S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"To Value"}),S.jsx("input",{type:"number",value:s,onChange:e=>u(e.target.value,!0),min:r,max:n,className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 "})]})]})},wr=({value:e,onChange:t,min:r,max:n})=>{const s=e=>{if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;try{const t=cr(String(e));return isNaN(t.getTime())?null:t}catch(t){const r=new Date(e);return isNaN(r.getTime())?null:r}},i=e=>e?dr(e):"",[d,c]=o(s(e?.value)),[u,m]=o("between"===e?.operator?s(e?.secondValue??e?.value):null),[f,h]=o(e?.operator||"between");l(()=>{h(e?.operator||"between"),c(s(e?.value)),m("between"===e?.operator?s(e?.secondValue??e?.value):null)},[e?.value,e?.secondValue,e?.operator]),l(()=>{"between"===f&&!u&&d&&m(d)},[f,d,u]);const g=(e,t,r)=>e?t&&e<t||r&&e>r?null:e:null,p=(e,r=!1)=>{const n=r?d:e,o=r?e:u,l="between"===f&&u?u:v,a=r?g(e,d??x??void 0,v):g(e,x,l);if(r?m(a):c(a),"between"===f)if(n&&o){const e=n>=o?n:o;t({type:"date",value:i(n<=o?n:o),secondValue:i(e),operator:"between"})}else t(null);else t(a?{type:"date",value:i(a),operator:f}:null)},x=a(()=>r?new Date(r):void 0,[r]),v=a(()=>n?new Date(n):void 0,[n]);return S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"Filter Type"}),S.jsxs("select",{value:f,onChange:e=>(e=>{const r=e;h(r),"between"===r?d&&u&&t({type:"date",value:d<=u?d:u,secondValue:d>=u?d:u,operator:"between"}):d&&t({type:"date",value:d,operator:r})})(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 ",children:[S.jsx("option",{value:"equals",children:"On Date"}),S.jsx("option",{value:"gt",children:"After"}),S.jsx("option",{value:"gte",children:"On or After"}),S.jsx("option",{value:"lt",children:"Before"}),S.jsx("option",{value:"lte",children:"On or Before"}),S.jsx("option",{value:"between",children:"Between Dates"})]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"between"===f?"From Date":"Date"}),S.jsx(ir,{name:"date_filter_start",value:d?dr(d):null,onChange:e=>p(e?cr(e):null,!1),className:"w-full"})]}),"between"===f&&S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"To Date"}),S.jsx(ir,{name:"date_filter_end",value:u?dr(u):null,onChange:e=>p(e?cr(e):null,!0),className:"w-full"})]})]})},jr=({value:e,onChange:t,options:r,data:n,columnKey:s})=>{const[i,d]=o(""),[c,u]=o(new Set(Array.isArray(e?.value)?e.value:[]));l(()=>{u(new Set(Array.isArray(e?.value)?e.value:[]))},[e]);const m=a(()=>{let e=[];const t=e=>null==e||""===e||"string"==typeof e&&""===e.trim();if(r&&r.length>0)e=r;else{const r=n.map(e=>{const r=e[s];return t(r)?null:r});e=[...new Set(r)].map(e=>({label:null===e?"Blank":String(e),value:e}))}const o=e.map(e=>{const r=t(e.value);return{...e,label:r?"Blank":e.label,value:r?null:e.value,isBlank:r}});return Array.from(new Map(o.map(e=>[e.isBlank?"__blank__":e.value,e])).values()).sort((e,t)=>e.isBlank&&!t.isBlank?1:!e.isBlank&&t.isBlank?-1:String(e.label).localeCompare(String(t.label)))},[r,n,s]),f=a(()=>{if(!i)return m;const e=i.toLowerCase();return m.filter(t=>t.label.toLowerCase().includes(e)||String(t.value).toLowerCase().includes(e)||"blank"===e&&t.isBlank)},[m,i]);return S.jsxs("div",{className:"space-y-3",children:[S.jsxs("div",{className:"relative",children:[S.jsx(oe,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--kd-muted-foreground)] w-4 h-4 dark:text-[var(--kd-muted-foreground)]"}),S.jsx("input",{type:"text",value:i,onChange:e=>d(e.target.value),placeholder:"Search options...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 "})]}),S.jsxs("div",{className:"flex justify-between items-center text-sm",children:[S.jsxs("span",{className:"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]",children:[c.size," of ",m.length," selected"]}),S.jsxs("div",{className:"flex gap-2",children:[S.jsx("button",{onClick:()=>{const e=new Set(f.map(e=>e.value));u(e),t({type:"multiselect",value:Array.from(e),operator:"equals"})},className:"text-[var(--kd-primary)] hover:text-blue-800 transition-colors dark:text-blue-400",children:"Select All"}),S.jsx("button",{onClick:()=>{u(new Set),t(null)},className:"text-[var(--kd-muted-foreground)] hover:text-[var(--kd-foreground)] transition-colors dark:text-[var(--kd-muted-foreground)]",children:"Clear All"})]})]}),S.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--kd-border)] rounded-[var(--kd-radius)] ",children:0===f.length?S.jsx("div",{className:"p-3 text-sm text-[var(--kd-muted-foreground)] text-center dark:text-[var(--kd-muted-foreground)]",children:"No options found"}):f.map((e,r)=>{const n=c.has(e.value);return S.jsxs("div",{className:`flex items-center gap-3 p-2 cursor-pointer hover:bg-[var(--kd-muted)] transition-colors ${n?"bg-[var(--kd-muted)] dark:bg-blue-900/30":""} dark:hover:bg-gray-800`,onClick:()=>(e=>{const r=new Set(c);r.has(e)?r.delete(e):r.add(e),u(r),t(r.size>0?{type:"multiselect",value:Array.from(r),operator:"equals"}:null)})(e.value),children:[S.jsx("div",{className:"w-4 h-4 border-2 rounded flex items-center justify-center "+(n?"bg-[var(--kd-primary)] border-[var(--kd-primary)] text-white":"border-gray-300 dark:border-gray-600"),children:n&&S.jsx(W,{className:"w-3 h-3"})}),S.jsx("span",{className:`text-sm ${n?"text-blue-900 dark:text-blue-100 font-medium":"text-[var(--kd-foreground)]"} ${e.isBlank?"italic text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]":""}`,children:e.label})]},r)})})]})},Cr=({value:e,onChange:t})=>{const[r,n]=o(void 0!==e?.value?String(e.value):"");return S.jsx("div",{className:"space-y-3",children:S.jsxs("div",{children:[S.jsx("label",{className:"block text-sm font-medium text-[var(--kd-foreground)] opacity-90 mb-1",children:"Boolean Value"}),S.jsxs("select",{value:r,onChange:e=>{return n(r=e.target.value),void t(""===r?null:{type:"boolean",value:"true"===r,operator:"equals"});var r},className:"w-full px-3 py-2 border border-gray-300 rounded-[var(--kd-radius)] focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] dark:border-gray-600 dark:bg-gray-700 ",children:[S.jsx("option",{value:"",children:"All values"}),S.jsx("option",{value:"true",children:"True"}),S.jsx("option",{value:"false",children:"False"})]})]})})},Nr=({column:e,data:t,value:r,onChange:n})=>{const o=a(()=>{if("object"==typeof e.filterable)return e.filterable;const r=t.slice(0,100).map(t=>t[e.key]).filter(e=>null!=e);if(0===r.length)return{type:"text"};const n=r[0];if("boolean"==typeof n)return{type:"boolean"};if("number"==typeof n)return{type:"number"};if(n instanceof Date||"string"==typeof n&&!isNaN(Date.parse(n)))return{type:"date"};const o=[...new Set(r)];return o.length<=20?{type:"multiselect",options:o.map(e=>({label:String(e),value:e}))}:{type:"text"}},[e.filterable,e.key,t]);switch(o.type){case"text":return S.jsx(br,{value:r,onChange:n,placeholder:o.placeholder});case"number":return S.jsx(kr,{value:r,onChange:n,min:o.min,max:o.max});case"date":return S.jsx(wr,{value:r,onChange:n,min:o.min,max:o.max});case"multiselect":return S.jsx(jr,{value:r,onChange:n,options:o.options||[],data:t,columnKey:e.key});case"boolean":return S.jsx(Cr,{value:r,onChange:n});default:return null}},Sr=({pinnedColumns:e,unpinnedColumns:t,hvPadLeft:r=0,hvPadRight:n=0,headerHeight:s,sortConfig:i,columnFilters:d,selectable:c,selectedRows:u,totalRows:m,data:f,onSort:h,onColumnFilter:g,onSelectAll:p,onColumnResize:x,pinnedKeySet:v=new Set,onColumnPin:y,groupable:b=!1,groupedByColumn:k,onGroupBy:w,groupedByColumns:j=[],onGroupToggle:C,onAutosizeColumn:N,onAutosizeAllColumns:R,onResetColumns:M,columnOrder:D,onColumnOrderChange:E,paginationMode:F="client",minResizeWidth:A=80})=>{const L=a(()=>[...e,...t],[e,t]),[z,I]=o(null),[T,K]=o(null),[W,V]=o(null),[_,B]=o(0),[G,H]=o(0),[X,te]=o("menu"),[re,ne]=o(null),[oe,le]=o(!1);l(()=>{le("ontouchstart"in window||navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches)},[]);const[ae,se]=o(null),[ie,de]=o(null),ce=u.size===m&&m>0,ue=u.size>0&&u.size<m,me=(e,t)=>{if(t.stopPropagation(),z===e)I(null);else{I(e),te("menu"),ne(d[e]||null);const r=t.currentTarget.getBoundingClientRect(),n=t.currentTarget.closest("[data-grid-container]"),o=n?n.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),l=10,a=Math.max(o.left+l,Math.min(r.left,o.right-320-l));K({top:r.bottom+4,left:a,containerRect:o})}},fe=e=>{g(e,re||null),I(null)},he=e=>null!=d[e],ge=(r,n)=>{n.preventDefault(),V(r),B(n.clientX);const o=[...e,...t].find(e=>e.key===r);H(o?.width||100)},pe=e=>{if(!W||!x)return;const t=Math.max(A,G+(e.clientX-_));x(W,t)},xe=()=>{V(null),B(0),H(0)},[ve,ye]=o(null),[be,ke]=o(null),we=(e,t)=>{ye(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},je=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();ke({key:e,position:t.clientX<r.left+r.width/2?"before":"after"})},Ce=e=>{const t=ve;if(!t||t===e)return;if(v.has(t)!==v.has(e))return ye(null),void ke(null);const r=be?.key!==e||"before"===be?.position,n=D.filter(e=>e!==t);let o=n.indexOf(e);if(-1===o)return E(n),ye(null),void ke(null);r||(o+=1),n.splice(o,0,t),E(n),ye(null),ke(null)},Ne=()=>{ye(null),ke(null)},Se=(e,t)=>{se(e),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)},Re=(e,t)=>{t.preventDefault(),t.dataTransfer.dropEffect="move";const r=t.currentTarget.getBoundingClientRect();de({key:e,position:t.clientY<r.top+r.height/2?"before":"after"})},Me=e=>{const t=ae;if(!t||t===e)return;if(v.has(t)!==v.has(e))return se(null),void de(null);const r=ie?.key!==e||"before"===ie?.position,n=D.filter(e=>e!==t);let o=n.indexOf(e);if(-1===o)return E(n),se(null),void de(null);r||(o+=1),n.splice(o,0,t),E(n),se(null),de(null)},De=()=>{se(null),de(null)};return l(()=>{if(W)return document.addEventListener("mousemove",pe),document.addEventListener("mouseup",xe),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",xe),document.body.style.cursor="",document.body.style.userSelect=""}},[W,_,G,x]),l(()=>{const e=e=>{z&&!e.target.closest("[data-column-menu]")&&I(null)};if(z)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[z]),S.jsx(S.Fragment,{children:S.jsx("div",{className:"bg-[var(--kd-muted)] border-b border-[var(--kd-border)]",style:{height:s},role:"row","aria-label":"Column headers",children:S.jsxs("div",{className:"flex h-full",children:[c&&S.jsx("div",{className:"px-3 border-r border-[var(--kd-border)] flex items-center justify-center bg-[var(--kd-muted)] sticky left-0 z-3 h-full",style:{width:yr,height:s},role:"columnheader","aria-label":"Select all rows",children:S.jsx("input",{type:"checkbox",checked:ce,ref:e=>{e&&(e.indeterminate=ue)},onChange:p,onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),p())},className:"rounded border-[var(--kd-border)] dark:border-[var(--kd-border)] text-[var(--kd-primary)] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":ce?"Deselect all rows":ue?`${u.size} rows selected. Click to select all`:"Select all rows",title:ce?`Deselect all ${m} rows`:ue?`${u.size} of ${m} rows selected`:`Select all ${m} rows`})}),e.map((t,r)=>{const n=v.has(t.key),o=e.filter(e=>v.has(e.key)).map(e=>e.key),l=o.indexOf(t.key),a=n?o.slice(0,l).reduce((t,r)=>{const n=e.find(e=>e.key===r);return t+(n?.width||100)},c?yr:0):0,d="center"===t.headerAlign?"justify-center":"right"===t.headerAlign?"justify-end":"justify-start",u=!1!==t.sortable;return S.jsxs("div",{className:`flex-none border-r border-[var(--kd-border)] last:border-r-0 relative ${n?"bg-[var(--kd-accent)] border-blue-200 dark:border-blue-700 sticky z-2":""} `,style:{width:t.width||100,left:n?`${a}px`:"auto",height:s},"data-column-key":t.key,draggable:!0,onDragStart:e=>we(t.key,e),onDragOver:e=>je(t.key,e),onDrop:()=>Ce(t.key),onDragEnd:Ne,children:[be?.key===t.key&&S.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-[var(--kd-primary)] z-4",style:{left:"before"===be?.position?0:void 0,right:"after"===be?.position?0:void 0}}),S.jsx("div",{className:"px-3 h-full",children:S.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[S.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${d} ${u?"cursor-pointer hover:text-[var(--kd-primary)]":""}`,onClick:()=>u&&h(t.key),children:[S.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[he(t.key)&&S.jsx("div",{className:"w-2 h-2 bg-red-600 rounded-full shrink-0",title:"Filter applied"}),S.jsx("span",{className:"font-medium text-[var(--kd-foreground)] text-sm truncate min-w-0",children:t.header})]}),u&&i.key===t.key&&S.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:S.jsx("asc"===i.direction?O:$,{className:"w-3 h-3 text-[var(--kd-primary)] dark:text-blue-400"})})]}),(t.filterable||y||b)&&S.jsxs("div",{className:"relative "+(z===t.key||oe?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[S.jsx("button",{className:"p-1 hover:bg-gray-200 rounded shrink-0",onClick:e=>me(t.key,e),"data-menu-trigger":!0,children:S.jsx(U,{className:"w-4 h-4 text-[var(--kd-muted-foreground)]"})}),z===t.key&&T&&S.jsxs("div",{className:"fixed bg-[var(--kd-background)] border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-lg z-1000 w-[320px] overflow-auto",style:{top:`${T.top}px`,left:`${T.left}px`,maxHeight:`${Math.max(160,T.containerRect.bottom-12-T.top)}px`},"data-column-menu":!0,children:[S.jsxs("div",{className:"flex items-center border-b border-[var(--kd-border)]",children:[S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("menu"),children:S.jsx(U,{className:"w-4 h-4"})}),t.filterable&&S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("filter"),children:S.jsx(Y,{className:"w-4 h-4"})}),S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("reorder"),children:S.jsx(P,{className:"w-4 h-4"})})]}),"menu"===X&&S.jsxs("div",{className:"py-1",children:[y&&(k===t.key?S.jsxs("div",{className:"w-full px-3 py-2 text-left text-sm flex items-center gap-2 text-[var(--kd-primary)] dark:text-blue-400",children:[S.jsx(J,{className:"w-4 h-4"}),"Pinned by grouping"]}):S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] flex items-center gap-2 dark:hover:bg-gray-800 text-[var(--kd-foreground)]",onClick:e=>{e.stopPropagation(),I(null),y?.(t.key,!v.has(t.key))},children:v.has(t.key)?S.jsxs(S.Fragment,{children:[S.jsx(Z,{className:"w-4 h-4"}),"Unpin Column"]}):S.jsxs(S.Fragment,{children:[S.jsx(J,{className:"w-4 h-4"}),"Pin Column"]})})),N&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{N?.(t.key),I(null)},children:"Autosize This Column"}),R&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{R?.(),I(null)},children:"Autosize All Columns"}),b&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] flex items-center gap-2 dark:hover:bg-gray-800 text-[var(--kd-foreground)]",onClick:e=>{e.stopPropagation(),I(null);const r=j?.includes(t.key)||k===t.key;C?C(t.key,!r):w?.(r?null:t.key)},children:k===t.key||j?.includes(t.key)?S.jsxs(S.Fragment,{children:[S.jsx(ee,{className:"w-4 h-4"}),"Ungroup"]}):S.jsxs(S.Fragment,{children:[S.jsx(Q,{className:"w-4 h-4"}),"Group by ",t.header]})}),M&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{M?.(),I(null)},children:"Reset Columns"})]}),"filter"===X&&S.jsxs("div",{className:"p-3 w-full",children:[he(t.key)&&S.jsxs("button",{className:"mb-2 text-xs text-red-500 hover:underline flex items-center gap-1 dark:text-red-400",onClick:()=>{ne(null),g(t.key,null),I(null)},children:[S.jsx(q,{className:"w-3 h-3"})," Clear Filter"]}),S.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:S.jsx(Nr,{column:t,data:f,value:re,onChange:e=>{ne(e),"server"!==F&&g(t.key,e)}})}),"server"===F?S.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[S.jsx("button",{className:"px-3 py-1.5 text-sm bg-[var(--kd-muted)] text-[var(--kd-foreground)] rounded-[var(--kd-radius)] hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 ",onClick:()=>I(null),children:"Cancel"}),S.jsx("button",{className:"px-3 py-1.5 text-sm bg-[var(--kd-primary)] text-white rounded-[var(--kd-radius)] hover:bg-blue-700",onClick:()=>fe(t.key),children:"Apply"})]}):S.jsx("div",{className:"flex justify-end mt-3",children:S.jsx("button",{className:"px-3 py-1.5 text-sm bg-[var(--kd-primary)] text-white rounded-[var(--kd-radius)] hover:bg-blue-700",onClick:()=>I(null),children:"Close"})})]}),"reorder"===X&&S.jsxs("div",{className:"px-3 py-2",children:[S.jsx("div",{className:"text-xs font-medium text-[var(--kd-muted-foreground)] mb-1 dark:text-[var(--kd-muted-foreground)]",children:"Reorder Columns"}),S.jsx("div",{className:"max-h-60 overflow-auto border border-[var(--kd-border)] rounded-[var(--kd-radius)] ",children:[...D.map(e=>L.find(t=>t.key===e)).filter(Boolean),...L.filter(e=>!D.includes(e.key))].map(e=>{const t=v.has(e.key);return S.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-[var(--kd-background)] hover:bg-[var(--kd-muted)] border-b border-[var(--kd-border)] last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-[var(--kd-muted)]/40":""} `,draggable:!0,onDragStart:t=>Se(e.key,t),onDragOver:t=>Re(e.key,t),onDrop:()=>Me(e.key),onDragEnd:De,children:[ie?.key===e.key&&S.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-[var(--kd-primary)]",style:{top:"before"===ie?.position?0:void 0,bottom:"after"===ie?.position?0:void 0}}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[var(--kd-muted-foreground)] select-none dark:text-[var(--kd-muted-foreground)]",children:"⋮⋮"}),S.jsxs("span",{className:"text-[var(--kd-foreground)] truncate max-w-45 text-[var(--kd-foreground)]",children:[e.header,t&&S.jsx("span",{className:"ml-1 text-[10px] text-[var(--kd-primary)] dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),S.jsx("div",{className:"text-[10px] text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<e.length-1&&x&&S.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-col-resize hover:bg-[var(--kd-primary)]/50 transition-all group z-20 active:bg-[var(--kd-primary)] active:w-1",onMouseDown:e=>ge(t.key,e),onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),N?.(t.key)},title:"Drag to resize • Double‑click to autosize",children:S.jsx("div",{className:"w-full h-full group-hover:bg-[var(--kd-primary)]/30 group-active:bg-[var(--kd-primary)]"})})]},t.key+r)}),r>0&&S.jsx("div",{style:{width:r,height:s},className:"flex-none"}),t.map((e,r)=>{const n="center"===e.headerAlign?"justify-center":"right"===e.headerAlign?"justify-end":"justify-start",o=!1!==e.sortable;return S.jsxs("div",{className:"flex-none border-r border-[var(--kd-border)] last:border-r-0 relative",style:{width:e.width||100,height:s},"data-column-key":e.key,draggable:!0,onDragStart:t=>we(e.key,t),onDragOver:t=>je(e.key,t),onDrop:()=>Ce(e.key),onDragEnd:Ne,children:[be?.key===e.key&&S.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-[var(--kd-primary)] z-4",style:{left:"before"===be?.position?0:void 0,right:"after"===be?.position?0:void 0}}),S.jsx("div",{className:"px-3 h-full",children:S.jsxs("div",{className:"flex items-center justify-between gap-1 group h-full",children:[S.jsxs("div",{className:`flex items-center min-w-0 flex-1 ${n} ${o?"cursor-pointer hover:text-[var(--kd-primary)]":""}`,onClick:()=>o&&h(e.key),children:[S.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[he(e.key)&&S.jsx("div",{className:"w-2 h-2 bg-red-600 rounded-full shrink-0",title:"Filter applied"}),S.jsx("span",{className:"font-medium text-[var(--kd-foreground)] text-sm truncate min-w-0",title:e.headerTooltip||e.header||"",children:e.header})]}),o&&i.key===e.key&&S.jsx("div",{className:"ml-1 shrink-0 pointer-events-none select-none",children:S.jsx("asc"===i.direction?O:$,{className:"w-3 h-3 text-[var(--kd-primary)] dark:text-blue-400"})})]}),(e.filterable||y||b)&&S.jsxs("div",{className:"relative "+(z===e.key||oe?"block":"hidden group-hover:block"),"data-column-menu":!0,children:[S.jsx("button",{className:"p-1 hover:bg-gray-200 rounded shrink-0",onClick:t=>me(e.key,t),"data-menu-trigger":!0,children:S.jsx(U,{className:"w-4 h-4 text-[var(--kd-muted-foreground)]"})}),z===e.key&&T&&S.jsxs("div",{className:"fixed bg-[var(--kd-background)] border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-lg z-10 w-[320px] overflow-auto",style:{top:`${T.top}px`,left:`${T.left}px`,maxHeight:`${Math.max(160,T.containerRect.bottom-12-T.top)}px`},"data-column-menu":!0,children:[S.jsxs("div",{className:"flex items-center border-b border-[var(--kd-border)]",children:[S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("menu"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("menu"),children:S.jsx(U,{className:"w-4 h-4"})}),e.filterable&&S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("filter"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("filter"),children:S.jsx(Y,{className:"w-4 h-4"})}),S.jsx("button",{className:"px-3 py-2 text-sm flex items-center gap-2 "+("reorder"===X?"border-b-2 border-[var(--kd-primary)] text-[var(--kd-primary)]":"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"),onClick:()=>te("reorder"),children:S.jsx(P,{className:"w-4 h-4"})})]}),"menu"===X&&S.jsxs("div",{className:"py-1",children:[y&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] flex items-center gap-2 dark:hover:bg-gray-800 text-[var(--kd-foreground)]",onClick:t=>{t.stopPropagation(),I(null);const r=!v.has(e.key);y?.(e.key,r)},children:v.has(e.key)?S.jsxs(S.Fragment,{children:[S.jsx(Z,{className:"w-4 h-4"}),"Unpin Column"]}):S.jsxs(S.Fragment,{children:[S.jsx(J,{className:"w-4 h-4"}),"Pin Column"]})}),N&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{N?.(e.key),I(null)},children:"Autosize This Column"}),R&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{R?.(),I(null)},children:"Autosize All Columns"}),b&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] flex items-center gap-2 dark:hover:bg-gray-800 text-[var(--kd-foreground)] ",onClick:t=>{t.stopPropagation(),I(null);const r=j?.includes(e.key)||k===e.key;C?C(e.key,!r):w?.(r?null:e.key)},children:k===e.key||j?.includes(e.key)?S.jsxs(S.Fragment,{children:[S.jsx(ee,{className:"w-4 h-4"}),"Ungroup"]}):S.jsxs(S.Fragment,{children:[S.jsx(Q,{className:"w-4 h-4"}),"Group by ",e.header]})}),M&&S.jsx("button",{className:"w-full px-3 py-2 text-left text-sm hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",onClick:()=>{M?.(),I(null)},children:"Reset Columns"})]}),"filter"===X&&S.jsxs("div",{className:"p-3 w-full",children:[S.jsx("div",{className:"max-h-75 overflow-auto pr-1",children:S.jsx(Nr,{column:e,data:f,value:re,onChange:t=>{ne(t),"server"!==F&&g(e.key,t)}})}),S.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[he(e.key)&&S.jsxs("button",{className:"px-3 py-1.5 text-sm bg-red-600 text-white rounded-[var(--kd-radius)] hover:bg-red-600 flex items-center gap-2 cursor-pointer",onClick:()=>{ne(null),g(e.key,null),I(null)},children:[S.jsx(q,{className:"w-3 h-3"})," Clear Filter"]}),S.jsx("button",{className:"px-3 py-1.5 text-sm bg-emerald-500/10 text-emerald-600 dark:bg-emerald-500/20 dark:text-emerald-400",onClick:()=>I(null),children:"Apply"}),"server"===F&&S.jsx("button",{className:"px-3 py-1.5 text-sm bg-[var(--kd-primary)] text-white rounded-[var(--kd-radius)] hover:bg-blue-700",onClick:()=>fe(e.key),children:"Apply"})]})]}),"reorder"===X&&S.jsxs("div",{className:"px-3 py-2",children:[S.jsx("div",{className:"text-xs font-medium text-[var(--kd-muted-foreground)] mb-1 dark:text-[var(--kd-muted-foreground)]",children:"Reorder Columns"}),S.jsx("div",{className:"max-h-60 overflow-auto border border-[var(--kd-border)] rounded-[var(--kd-radius)] ",children:[...D.map(e=>L.find(t=>t.key===e)).filter(Boolean),...L.filter(e=>!D.includes(e.key))].map(e=>{const t=v.has(e.key);return S.jsxs("div",{className:`flex items-center justify-between px-2 py-1 text-sm bg-[var(--kd-background)] hover:bg-[var(--kd-muted)] border-b border-[var(--kd-border)] last:border-b-0 relative ${ae===e.key?"opacity-60":""} ${t?"bg-[var(--kd-muted)]/40":""} `,draggable:!0,onDragStart:t=>Se(e.key,t),onDragOver:t=>Re(e.key,t),onDrop:()=>Me(e.key),onDragEnd:De,children:[ie?.key===e.key&&S.jsx("div",{className:"absolute left-0 right-0 h-0.5 bg-[var(--kd-primary)]",style:{top:"before"===ie?.position?0:void 0,bottom:"after"===ie?.position?0:void 0}}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[var(--kd-muted-foreground)] select-none dark:text-[var(--kd-muted-foreground)]",children:"⋮⋮"}),S.jsxs("span",{className:"text-[var(--kd-foreground)] truncate max-w-45 text-[var(--kd-foreground)]",children:[e.header,t&&S.jsx("span",{className:"ml-1 text-[10px] text-[var(--kd-primary)] dark:text-blue-400",children:"(pinned)"})]})]})]},e.key)})}),S.jsx("div",{className:"text-[10px] text-[var(--kd-muted-foreground)] mt-1 dark:text-[var(--kd-muted-foreground)]",children:"Tip: You can only reorder within pinned or unpinned groups."})]})]})]})]})}),r<t.length-1&&x&&S.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-col-resize hover:bg-[var(--kd-primary)]/50 transition-all group z-20 active:bg-[var(--kd-primary)] active:w-1",onMouseDown:t=>ge(e.key,t),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),N?.(e.key)},title:"Drag to resize • Double‑click to autosize",children:S.jsx("div",{className:"w-full h-full group-hover:bg-[var(--kd-primary)]/30 group-active:bg-[var(--kd-primary)]"})})]},e.key+r)}),n>0&&S.jsx("div",{style:{width:n,height:s},className:"flex-none"})]})})})};Sr.displayName="GridHeader";const Rr=c(Sr);S.jsx(re,{className:"w-4 h-4"}),S.jsx(V,{className:"w-4 h-4"}),S.jsx(B,{className:"w-4 h-4"});const Mr=({row:e,position:t,isVisible:r,onClose:n,menuItems:o})=>{const s=i(null);l(()=>{if(!r)return;const e=e=>{s.current&&!s.current.contains(e.target)&&n()},t=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,n]);const d=a(()=>{if(!r||!o?.length)return t;const e=40*o.filter(e=>!e.separator).length+10*o.filter(e=>e.separator).length,n=window.innerWidth,l=window.innerHeight;let a=t.x,s=t.y;return a+100>n&&(a=n-100-10),a-100<0&&(a=110),s+e>l&&(s=s-e-10),{x:a,y:s}},[t,r,o]);return r&&o?.length?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"fixed inset-0 z-40",onClick:n}),S.jsx("div",{ref:s,role:"menu","aria-label":"Row actions",className:"fixed z-50 bg-white border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-lg py-1 min-w-[180px]",style:{left:`${d.x}px`,top:`${d.y}px`,transform:"translate(-50%, 0)"},children:o.map(t=>t.separator?S.jsx("div",{role:"separator",className:"border-t border-[var(--kd-border)] my-1"},t.id):S.jsxs("button",{role:"menuitem",onClick:()=>(t=>{t.disabled||t.separator||(t.onClick(e),n())})(t),disabled:t.disabled,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-left transition-colors "+(t.disabled?"text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] cursor-not-allowed":"delete"===t.id?"text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20":"text-[var(--kd-foreground)] dark:text-gray-200 hover:bg-[var(--kd-muted)] "),children:[t.icon&&S.jsx("span",{className:"shrink-0",children:t.icon}),S.jsx("span",{className:"flex-1",children:t.label})]},t.id))})]}):null},Dr=({column:e,row:t,initialValue:r,onCommit:n,onCancel:a})=>{const[d,c]=o(null==r?"":r),u=i(!1),m=i(!1),f=i(null),h=i(null),g=i(null);l(()=>{const e=h.current??f.current??g.current;e&&(e.focus(),"select"in e&&e.select())},[]);const p=s(()=>{if(u.current||m.current)return;m.current=!0;const t="number"===e.editorType&&""!==d?Number(d):d;n(t)},[d,e.editorType,n]),x=s(()=>{u.current=!0,a()},[a]),v=s(t=>{"Enter"===t.key&&"textarea"!==e.editorType?(t.preventDefault(),t.stopPropagation(),p()):"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),x()):"Tab"===t.key&&p()},[p,x,e.editorType]),y=s(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),p()):"Escape"===e.key?(e.preventDefault(),x()):"Tab"===e.key&&p()},[p,x]),b=s(()=>{p()},[p]),k="w-full h-full bg-white text-[var(--kd-foreground)] text-sm outline-none border border-blue-500 dark:border-blue-400 rounded-[calc(var(--kd-radius)*0.5)] px-2 focus:ring-2 focus:ring-blue-400/30 transition-shadow";return S.jsx("div",e.editor?{className:"absolute inset-0 z-10 flex items-center",children:e.editor(d,t,n,a)}:"textarea"===e.editorType?{className:"absolute inset-0 z-10 flex items-start p-0.5",children:S.jsx("textarea",{ref:h,value:d,rows:3,className:`${k} resize-none py-1`,onChange:e=>c(e.target.value),onKeyDown:y,onBlur:b})}:"select"===e.editorType?{className:"absolute inset-0 z-10 flex items-center p-0.5",children:S.jsxs("select",{ref:g,value:d,className:`${k} cursor-pointer`,onChange:e=>{c(e.target.value)},onKeyDown:v,onBlur:b,children:[S.jsx("option",{value:"",disabled:!0,hidden:!0,children:"Select..."}),e.editorOptions?.map(e=>S.jsx("option",{value:e.value,children:e.label},String(e.value)))]})}:{className:"absolute inset-0 z-10 flex items-center p-0.5",children:S.jsx("input",{ref:f,type:e.editorType??"text",value:d,className:k,onChange:e=>c(e.target.value),onKeyDown:v,onBlur:b})})},Er=({data:e,columns:t,selectedRows:r,virtualized:n,virtualizedRange:l,rowHeight:i,selectable:d,isRowSelectable:c,onRowSelect:u,pinnedColumns:m=new Set,hvPadLeft:f=0,hvPadRight:h=0,rowStyle:g,globalFilter:p,onContextMenu:x,onRowDoubleClick:v,onRowClick:y,onCellClick:b,isCellFocused:k,isCellSelected:w,onCellContextMenu:j,onCellMouseDown:C,onCellMouseEnter:N,contextMenuItems:R,getRowId:M,isEditing:D,onStartEdit:E,onCommitEdit:F,onCancelEdit:A,editingInitialValue:L})=>{const z=a(()=>e.length*i,[e.length,i]),{leftOffsetByPinnedKey:I}=a(()=>{if(0===m.size)return{leftOffsetByPinnedKey:new Map};const e=t.filter(e=>m.has(e.key)).map(e=>e.key),r=new Map;for(const e of t)r.set(e.key,e.width||100);const n=new Map;let o=d?yr:0;for(const t of e)n.set(t,o),o+=r.get(t)||100;return{leftOffsetByPinnedKey:n}},[t,m,d]),T=a(()=>t.reduce((e,t)=>e+(m.has(t.key)?1:0),0),[t,m]),[O,$]=o(null),P=s((e,t)=>{e.preventDefault(),x?.({row:t,event:e}),R?.length&&$({row:t,x:e.clientX,y:e.clientY})},[x,R]),K=s(()=>$(null),[]);return S.jsxs(S.Fragment,{children:[S.jsx("div",{style:{height:n?`${z}px`:"auto",position:"relative"},children:S.jsx("div",{style:{transform:n?`translate3d(0, ${l.offsetY}px, 0)`:"none",position:n?"absolute":"static",top:0,left:0,right:0},children:e.map((e,o)=>{const a=n?l.startIndex+o:o,s=g?.(e),x=((e,t)=>M?M(e):void 0!==e.id?e.id:("undefined"!=typeof window&&window.KD_DEV_LOG&&0===t&&console.warn("[KDGrid] No row IDs found. Either:\n 1. Add 'id' property to each row object, or\n 2. Provide 'getRowId' prop to extract a unique identifier.\n Using row index as fallback ID, but this may cause issues with pagination/filtering."),t??0))(e,a),R=a%2==0?"bg-[var(--kd-background)]":"bg-[var(--kd-muted)] ",z=r.has(x)?"bg-[var(--kd-accent)]":"";return S.jsxs("div",{className:`flex border-b border-[var(--kd-border)] hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)] ${z||(s?"":R)}`,style:{height:`${i}px`,...s},onContextMenu:t=>P(t,e),onDoubleClick:t=>((e,t)=>{v?.({row:t,event:e})})(t,e),onClick:t=>((e,t)=>{y?.({row:t,event:e})})(t,e),children:[d&&S.jsx("div",{className:"flex items-center justify-center sticky left-0 bg-inherit z-2 border-r border-[var(--kd-border)]",style:{width:yr},children:S.jsx("input",{type:"checkbox",checked:r.has(x),disabled:!!c&&!c(e),onChange:e=>u(x,e.target.checked),onKeyDown:e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),u(x,!r.has(x)))},className:"rounded border-gray-300 dark:border-gray-600 text-[var(--kd-primary)] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 h-4 w-4 transition-all duration-150 dark:text-blue-400","aria-label":`Select row ${x}`,tabIndex:0})}),t.map((t,r)=>{const n=m.has(t.key),o=n&&I.get(t.key)||0,l=e[t.key];let a,s;if(t.cellRenderer?(a=t.cellRenderer(l,e),"string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l||(s=String(l))):t.formatter?(a=t.formatter(l),s=String(a)):(a="bigint"==typeof l?l.toString():l??"",s=a?String(a):void 0),p&&p.trim()&&!t.cellRenderer&&a){const e=String(a);((e,t)=>{if(!t||null==e)return!1;const r=t.toLowerCase().trim();return!!r&&String(e).toLowerCase().includes(r)})(e,p)&&(a=((e,t)=>{if(!t||!e)return e;const r=t.toLowerCase().trim(),n=e.toLowerCase();if(!r||!n.includes(r))return e;const o=[];let l=0,a=0,s=0;for(;-1!==(a=n.indexOf(r,l));)a>l&&o.push(e.slice(l,a)),o.push(S.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-600/40 text-current font-medium px-0.5 py-0 rounded-[calc(var(--kd-radius)*0.5)]",style:{margin:0},children:e.slice(a,a+r.length)},"highlight-"+s++)),l=a+r.length;return l<e.length&&o.push(e.slice(l)),S.jsx(S.Fragment,{children:o})})(e,p))}s&&0===s.trim().length&&(s=void 0);const i="center"===t.align?"text-center":"right"===t.align?"text-right":"text-left",d="center"===t.align?"justify-center":"right"===t.align?"justify-end":"justify-start",c=t.noPadding?"p-0":"p-3",u="function"==typeof t.className?t.className(l,e):t.className||"",h="function"==typeof t.cellStyle?t.cellStyle(l,e):t.cellStyle||void 0,g="function"==typeof t.tooltip?t.tooltip(l,e):t.tooltip,v=S.jsxs("div",{title:g??("string"==typeof s?s:void 0),className:`border-r border-[var(--kd-border)] last:border-r-0 ${c} text-sm flex items-center ${w?.(x,t.key)?"bg-blue-100/60 dark:bg-blue-900/30":""} ${n?k?.(x,t.key)||D?.(x,t.key)?"sticky z-10 bg-inherit":"sticky z-1 bg-inherit":""} ${k?.(x,t.key)||D?.(x,t.key)?"relative z-10 box-border group/cell":"relative box-border group/cell"} ${i} ${d} ${u}`,style:{width:`${t.width||100}px`,left:n?`${o}px`:"auto",...h},onClick:r=>((e,t,r,n)=>{b?.({row:t,column:r,value:n,event:e})})(r,e,t,e[t.key]),onContextMenu:r=>{e._isGroupHeader||e._isGroupFooter||j&&(r.preventDefault(),r.stopPropagation(),j({row:e,column:t,value:e[t.key],displayValue:s??"",event:r}))},onMouseDown:r=>C?.({row:e,column:t,event:r}),onMouseEnter:r=>N?.({row:e,column:t,event:r}),onDoubleClick:r=>((e,t,r)=>{E?.(t,r)})(0,e,t),children:[k?.(x,t.key)&&S.jsx("div",{className:"pointer-events-none absolute inset-0 border border-blue-400 z-10"}),D?.(x,t.key)?S.jsx(Dr,{column:t,row:e,initialValue:L,onCommit:F,onCancel:A}):S.jsxs(S.Fragment,{children:[!1===t.wrapCellContent?S.jsx(S.Fragment,{children:a}):S.jsx("div",{className:"truncate w-full",children:a}),!!t.editable&&S.jsxs("svg",{className:"absolute bottom-1 right-1 w-2.5 h-2.5 text-blue-500 opacity-0 group-hover/cell:opacity-100 transition-opacity pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[S.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),S.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})]})]},`${t.key}-${r}`);return f>0&&r===T?S.jsxs(S.Fragment,{children:[S.jsx("div",{style:{width:f},className:"flex-none"}),v]}):v}),h>0&&S.jsx("div",{style:{width:h},className:"flex-none"})]},`${x}-${a}`)})})}),O&&S.jsx(Mr,{row:O.row,position:{x:O.x,y:O.y},isVisible:!0,onClose:K,menuItems:R})]})},Fr=(e,t)=>{if(e.isEditing!==t.isEditing)return!1;if(e.onCommitEdit!==t.onCommitEdit)return!1;if(e.editingInitialValue!==t.editingInitialValue)return!1;if(e.rowHeight!==t.rowHeight)return!1;if(e.selectable!==t.selectable)return!1;if(e.virtualized!==t.virtualized)return!1;if(e.globalFilter!==t.globalFilter)return!1;if(e.virtualizedRange.startIndex!==t.virtualizedRange.startIndex)return!1;if(e.virtualizedRange.endIndex!==t.virtualizedRange.endIndex)return!1;if(e.virtualizedRange.offsetY!==t.virtualizedRange.offsetY)return!1;if(e.isCellSelected!==t.isCellSelected)return!1;if(e.isCellFocused!==t.isCellFocused)return!1;if(e.onCellMouseDown!==t.onCellMouseDown)return!1;if(e.onCellMouseEnter!==t.onCellMouseEnter)return!1;if(e.getRowId!==t.getRowId)return!1;if(e.selectedRows.size!==t.selectedRows.size)return!1;if(e.pinnedColumns?.size!==t.pinnedColumns?.size)return!1;if(e.rowStyle!==t.rowStyle)return!1;if(e.columns.map(e=>e.key).join("|")!==t.columns.map(e=>e.key).join("|"))return!1;if(e.data.length!==t.data.length)return!1;if(e.data===t.data)return!0;const r=(e,t,r)=>r?r(e):void 0!==e.id?e.id:t;for(let n=0;n<t.data.length;n++)if(r(e.data[n],n,e.getRowId)!==r(t.data[n],n,t.getRowId))return!1;return!0};Er.displayName="GridRows";const Ar=c(Er,Fr),Lr=c(({row:e,isExpanded:t,onToggle:r,viewportWidth:n,selectable:o,rowHeight:l=40,getHeaderLabel:a,getValueLabel:s,renderGroupActions:i})=>{const d=()=>{e._groupKey&&r(e._groupKey)};return S.jsxs("div",{className:"flex items-center bg-[var(--kd-accent)] border-b border-[var(--kd-border)] dark:border-gray-800 hover:bg-blue-100/70 cursor-pointer sticky left-0 z-20 overflow-hidden",style:{minWidth:`${n+(o?yr:0)}px`,height:`${l}px`},onClick:d,role:"button",tabIndex:0,"aria-expanded":t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),d())},children:[o&&S.jsx("div",{className:"w-12 flex items-center justify-center"}),S.jsxs("div",{className:"flex items-center px-4 py-2 flex-1",children:[S.jsx("div",{className:"flex items-center mr-3",style:{paddingLeft:(e._groupLevel?16*e._groupLevel:0)+"px"},children:S.jsx(t?z:L,{className:"w-4 h-4 text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"})}),S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsxs("span",{className:"font-medium text-[var(--kd-foreground)]",children:[e._groupColumnKey?`${a?a(e._groupColumnKey):e._groupColumnKey}: `:"",s&&e._groupColumnKey?s(e._groupColumnKey,e._groupValue):e._groupValue??(e._groupKey||"Unknown")]}),S.jsxs("span",{className:"text-sm text-[var(--kd-muted-foreground)] bg-gray-200/70 px-2 py-1 rounded-full dark:text-[var(--kd-muted-foreground)]",children:[e._groupCount," ",1===e._groupCount?"item":"items"]})]}),i&&S.jsx("div",{className:"flex items-center px-4",onClick:e=>e.stopPropagation(),children:i({groupKey:e._groupKey||"",columnKey:e._groupColumnKey||"",groupValue:e._groupValue,rows:e._groupRows||[],count:e._groupCount||0,level:e._groupLevel||0})})]})]})}),zr=({hasFilters:e=!1,hasData:t=!0,message:r,renderer:n})=>{if(n)return S.jsx(S.Fragment,{children:n()});const{title:o,description:l,icon:a}=r?{title:r,description:"",icon:le}:t?e?{title:"No Results Found",description:"No data matches your current search criteria. Try adjusting your filters.",icon:oe}:{title:"No Data to Display",description:"There are no items to show at the moment.",icon:le}:{title:"No Data Available",description:"There is no data to display in this table.",icon:le};return S.jsxs("div",{className:"flex flex-col items-center justify-center pt-16 pb-10 px-4 text-center",children:[S.jsx("div",{className:"w-16 h-16 bg-[var(--kd-muted)] rounded-full flex items-center justify-center mb-4",children:S.jsx(a,{className:"w-8 h-8 text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)]"})}),S.jsx("h3",{className:"text-lg font-medium text-[var(--kd-foreground)] mb-2",children:o}),S.jsx("p",{className:"text-sm text-[var(--kd-muted-foreground)] max-w-md",children:l})]})},Ir=()=>S.jsx("svg",{className:"w-10 h-10 mb-3 opacity-90 mx-auto text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:S.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Tr=()=>S.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center py-12 px-8 text-center select-none",children:[S.jsxs("div",{className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-red-100 dark:bg-red-900/30 px-3 py-1 text-xs font-semibold tracking-wide text-red-500 dark:text-red-400 uppercase",children:[S.jsx("span",{children:"⚠"}),"License Error"]}),S.jsx(Ir,{}),S.jsx("h3",{className:"font-bold text-base text-red-800 dark:text-red-300 mb-1",children:"react-kd-grid: Invalid or Missing License Key"}),S.jsxs("p",{className:"text-sm text-red-500 dark:text-red-400 max-w-xs mx-auto leading-relaxed",children:["Please provide a valid"," ",S.jsx("code",{className:"font-mono bg-red-100 dark:bg-red-900/40 px-1 py-0.5 rounded text-xs",children:"licenseKey"})," ","prop to unlock the grid."]})]}),Or=({scrollRef:e,flatRows:t,columnsWithWidths:r,visibleColumns:n,totalWidth:o,selectable:l,dataToDisplay:a,pinnedAll:s,effectivePinnedColumns:i,hvPadLeftMemo:d,hvPadRightMemo:c,resolvedHeaderHeight:u,sortConfig:m,columnFilters:f,selectedRows:h,data:g,handleSort:p,setColumnFilter:x,handleSelectAll:v,handleColumnResize:y,handleColumnPin:b,addGroupKey:k,removeGroupKey:w,handleGroupBy:j,autosizeColumn:C,autosizeAllColumns:N,resetColumns:R,columnOrder:M,setColumnOrder:D,pagination:E,minResizeWidth:F,effectiveVirtualized:A,virtualizedRange:L,resolvedRowHeight:z,visibleData:I,isRowSelectable:T,handleRowSelect:O,rowStyle:$,globalFilter:P,onContextMenu:K,onRowDoubleClick:W,onRowClick:V,onCellClick:_,onCellContextMenu:B,isCellFocused:G,isCellSelected:H,handleCellMouseDown:U,handleCellMouseEnter:Y,contextMenuItems:q,getRowId:X,isEditing:J,startEdit:Z,commitEdit:Q,cancelEdit:ee,editingCell:te,safeGetRowId:re,toggleGroupExpansion:ne,containerWidth:oe,groupConfig:le,columns:ae,renderGroupActions:se,groupFooterVariant:ie,isValidLicense:de,infiniteScroll:ce,sentinelRef:me,loading:fe,showLoader:he,finishingLoader:ge,loaderTop:pe,noDataMessage:xe,noDataRenderer:ve,handleScroll:ye,cellSelectionEnabled:be})=>S.jsxs("div",{ref:e,role:"grid","aria-rowcount":t.length+1,"aria-colcount":r.length,"aria-label":"Data grid",className:"flex-1 overflow-auto relative [&::-webkit-scrollbar]:thin "+(be?"select-none":""),onScroll:ye,children:[S.jsx("div",{className:"sticky top-0 z-3",children:S.jsx("div",{style:{minWidth:`${o+(l?yr:0)}px`},children:(()=>{const e=s,t=n.filter(e=>!i.has(e.key));return S.jsx(Rr,{pinnedColumns:e,unpinnedColumns:t,hvPadLeft:d,hvPadRight:c,headerHeight:u,sortConfig:m,columnFilters:f,selectable:l,selectedRows:h,totalRows:a.length,data:g,onSort:p,onColumnFilter:x,onSelectAll:()=>v(h.size!==a.length),onColumnResize:y,pinnedKeySet:i,onColumnPin:b,groupable:!0,groupedByColumn:le.columnKeys[0]||null,groupedByColumns:le.columnKeys,onGroupToggle:(e,t)=>t?k(e):w(e),onGroupBy:j,onAutosizeColumn:C,onAutosizeAllColumns:N,onResetColumns:R,columnOrder:M,onColumnOrderChange:D,paginationMode:E?.enabled?E.mode:null,minResizeWidth:F})})()})}),S.jsx("div",{style:{minWidth:`${o+(l?yr:0)}px`,height:A?a.length*z+"px":"auto"},children:de&&S.jsx("div",{style:{transform:`translateY(${A?L.offsetY:0}px)`,willChange:"transform",contain:"content"},children:(()=>{const e=[];let t=[];const a=()=>{if(!t.length)return;const r=`chunk-${re(t[0])}-${t.length}-${L.offsetY}`,o=null!=te&&t.some(e=>re(e)===te.rowId);e.push(S.jsx("div",{style:{opacity:fe?.5:1},children:S.jsx(Ar,{data:t,columns:n,selectedRows:h,virtualized:!1,virtualizedRange:{startIndex:0,endIndex:t.length-1,offsetY:0},rowHeight:z,selectable:l,isRowSelectable:T,onRowSelect:O,pinnedColumns:i,hvPadLeft:d,hvPadRight:c,rowStyle:$,globalFilter:P,onContextMenu:K,onRowDoubleClick:W,onRowClick:V,onCellClick:_,onCellContextMenu:B,isCellFocused:G,isCellSelected:H,onCellMouseDown:U,onCellMouseEnter:Y,contextMenuItems:q,getRowId:X,isEditing:J,onStartEdit:Z,onCommitEdit:Q,onCancelEdit:ee,editingInitialValue:o?te?.initialValue:void 0})},r)),t=[]};for(const n of I)if(n._isGroupHeader)a(),e.push(S.jsx(Lr,{row:n,isExpanded:le.expanded.has(n._groupKey||""),onToggle:ne,viewportWidth:oe,selectable:l,rowHeight:z,getHeaderLabel:e=>ae.find(t=>t.key===e)?.header||e,getValueLabel:(e,t)=>{const r=ae.find(t=>t.key===e);if(r?.formatter)try{return r.formatter(t)}catch(e){return String(t??"")}return String(t??"")},renderGroupActions:se},n.id));else if(n._isGroupFooter)if(a(),"chips"===ie){const t=r.filter(e=>!!e.aggregate&&n._groupAgg&&void 0!==n._groupAgg[e.key]).map(e=>{const t=n._groupAgg[e.key],r=e.aggregateFormatter||e.formatter,o=r?(()=>{try{return r(t)}catch{return String(t)}})():String(t);return S.jsxs("span",{className:"px-2.5 py-1 rounded-[var(--kd-radius)] bg-[var(--kd-muted)] dark:bg-blue-900/40 text-blue-700 dark:text-blue-200 text-xs font-medium",title:`${e.header}`,children:[e.header,": ",o]},e.key)});e.push(S.jsx("div",{className:"sticky left-0 z-1",style:{minWidth:`${o+(l?yr:0)}px`,height:`${z}px`},children:S.jsxs("div",{className:"flex items-center justify-between h-full border-t border-blue-200 dark:border-blue-800 bg-[var(--kd-muted)]/60 dark:bg-blue-900/20 px-4",role:"contentinfo",children:[S.jsx("div",{className:"flex items-center gap-2 flex-wrap overflow-hidden",children:t.length?t:S.jsx("span",{className:"text-xs text-[var(--kd-muted-foreground)]",children:"No aggregates"})}),S.jsx("span",{className:"text-[10px] uppercase tracking-wide text-blue-700 dark:text-blue-300",children:"Group Summary"})]})},n.id))}else e.push(S.jsx("div",{className:"sticky left-0 z-1 bg-blue-100 ",style:{minWidth:`${o+(l?yr:0)}px`,height:`${z}px`},children:S.jsxs("div",{className:"flex h-full border-t border-blue-200 dark:border-blue-800 bg-[var(--kd-muted)]/60 dark:bg-blue-900/20",role:"contentinfo",children:[l&&S.jsx("div",{style:{width:yr},className:"shrink-0"}),r.map(e=>{const t=e.width||100,r=n._groupAgg?n._groupAgg[e.key]:void 0,o=e.aggregateFormatter||e.formatter,l=void 0===r?"":o?(()=>{try{return o(r)}catch{return r}})():r;let a;if("number"==typeof l)a=Number.isInteger(l)?String(l):l.toFixed(2);else if(isNaN(l)||""===l||null===l)a=String(l??"");else{const e=Number(l);a=Number.isInteger(e)?String(e):e.toFixed(2)}return S.jsx("div",{className:"px-2 text-xs font-medium text-blue-800 dark:text-blue-200 flex items-center overflow-hidden",style:{width:t,minWidth:t,maxWidth:t},title:a?`${e.header}: ${a}`:void 0,children:S.jsx("span",{className:"truncate w-full",children:a})},`agg-cell-${n._groupKey}-${e.key}`)})]})},n.id));else t.push(n);return a(),e})()})}),de&&ce?.enabled&&S.jsxs("div",{style:{minWidth:`${o+(l?yr:0)}px`},children:[S.jsx("div",{ref:me,style:{height:1},"aria-hidden":!0}),ce.isLoading&&S.jsx("div",{className:"flex items-center justify-center gap-3 py-4 text-sm text-[var(--kd-muted-foreground)]","aria-live":"polite","aria-label":"Loading more rows",children:ce.loadingRenderer?ce.loadingRenderer():S.jsxs(S.Fragment,{children:[S.jsx(ue,{className:"animate-spin h-4 w-4 text-blue-500"}),S.jsx("span",{children:"Loading more rows…"})]})}),!ce.isLoading&&!ce.hasMore&&S.jsxs("div",{className:"flex items-center justify-center py-3 text-xs text-[var(--kd-muted-foreground)] dark:text-[var(--kd-muted-foreground)] gap-2",children:[S.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"}),"All rows loaded",S.jsx("span",{className:"inline-block w-12 h-px bg-gray-200 dark:bg-gray-700"})]})]}),he&&S.jsx("div",{className:`pointer-events-none absolute left-0 right-0 h-1 bg-gray-200 overflow-hidden z-30 ${ge?"opacity-0 transition-opacity duration-200":"opacity-100"} dark:bg-gray-700`,style:{top:pe},children:S.jsx("div",{className:"h-full w-1/3 bg-[var(--kd-muted)]0 animate-[slide_1.2s_linear_infinite]"})}),S.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex items-center justify-center",children:S.jsx("div",{className:"pointer-events-auto",children:de?fe||0!==a.length?null:S.jsx(zr,{hasFilters:!!P||Object.keys(f).length>0,hasData:g.length>0,message:xe,renderer:ve}):S.jsx(Tr,{})})})]}),$r=c(({columns:e,data:t,selectable:r,rowHeight:n,pinnedColumns:o=new Set})=>{const l=a(()=>{const r={},n=e.filter(e=>e.footerAggregate);return 0===n.length||n.forEach(e=>{const n=t.map(t=>t[e.key]);let o=null;if("function"==typeof e.footerAggregate)try{o=e.footerAggregate(n)}catch(t){console.warn(`Error computing custom footer aggregate for column ${e.key}:`,t),o=null}else{const r=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),l=n.map(e=>{if("number"==typeof e)return e;if(null==e)return NaN;const t=String(e);if(r(t))return NaN;const n=parseFloat(t.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),a=()=>n.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));switch(e.footerAggregate){case"count":o=t.length;break;case"sum":l.length&&(o=l.reduce((e,t)=>e+t,0));break;case"avg":l.length&&(o=l.reduce((e,t)=>e+t,0)/l.length);break;case"min":if(l.length)o=Math.min(...l);else{const e=a();e.length&&(o=new Date(Math.min(...e)))}break;case"max":if(l.length)o=Math.max(...l);else{const e=a();e.length&&(o=new Date(Math.max(...e)))}break;default:o=null}}null!=o&&(r[e.key]=o)}),r},[e,t]);if(!e.some(e=>e.footerAggregate))return null;const s=e.reduce((e,t)=>e+t.width,0),i=a(()=>{const t=new Map,n=e.filter(e=>o.has(e.key)).map(e=>e.key);let l=r?yr:0;for(const r of n)t.set(r,l),l+=e.find(e=>e.key===r)?.width||100;return t},[e,o,r]);return S.jsxs("div",{className:"flex h-full",style:{minWidth:`${s+(r?yr:0)}px`,height:`${n}px`},children:[r&&S.jsx("div",{className:"w-12 p-3 border-r border-[var(--kd-border)] flex items-center justify-center sticky left-0 bg-[var(--kd-background)] z-30",style:{height:`${n}px`},children:S.jsx("span",{className:"text-xs font-medium text-[var(--kd-muted-foreground)] dark:text-gray-300",children:"Total"})},"select-footer-cell"),e.map(e=>{const t=e.width,r=l[e.key],a=e.footerAggregate&&void 0!==r;let s="";if(a){const t=e.footerAggregateFormatter||e.formatter;if(t)try{s=t(r)}catch{s=String(r)}else s="number"==typeof r?r%1==0?r.toString():r.toFixed(2):String(r?.toFixed)}const d=o.has(e.key),c=d&&i.get(e.key)||0;return S.jsx("div",{className:`border-r border-[var(--kd-border)] last:border-r-0 ${e.noPadding?"p-0":"p-3"} text-sm flex items-center font-semibold text-[var(--kd-foreground)] dark:text-gray-200 overflow-hidden ${"center"===e.align?"justify-center":"right"===e.align?"justify-end":"justify-start"} ${"center"===e.align?"text-center":"right"===e.align?"text-right":"text-left"} ${d?"sticky bg-[var(--kd-background)] z-20":""}`,style:{width:`${t}px`,minWidth:`${t}px`,maxWidth:`${t}px`,left:d?`${c}px`:"auto",height:`${n}px`},title:a?`${e.header}: ${s}`:void 0,children:a&&S.jsx("span",{className:"truncate w-full",children:s})},e.key)})]})}),Pr=({paginationConfig:e,currentPage:t,isServerLoading:r,selectedRowsCount:n,totalDataLength:o,paginationMode:l="client",onPageChange:a,onPageSizeChange:s})=>{const i="server"===l&&e.totalRows||o,{start:d,end:c}={start:e.enabled?Math.min((t-1)*e.pageSize+1,i):1,end:e.enabled?Math.min(t*e.pageSize,i):i};return e.enabled||0!==i?S.jsx("div",{className:"px-4 py-2.5 border-t border-[var(--kd-border)] bg-[var(--kd-background)] select-none",children:S.jsxs("div",{className:"flex flex-row items-center justify-between gap-4",children:[S.jsxs("div",{className:"flex items-center gap-4 text-sm text-[var(--kd-muted-foreground)]",children:[S.jsxs("div",e.enabled?{className:"flex items-center gap-1.5 font-medium whitespace-nowrap",children:[S.jsx("span",{children:"Showing"}),S.jsx("span",{className:"text-[var(--kd-foreground)] font-bold",children:d.toLocaleString()}),S.jsx("span",{className:"opacity-60",children:"-"}),S.jsx("span",{className:"text-[var(--kd-foreground)] font-bold",children:c.toLocaleString()}),S.jsx("span",{className:"mx-0.5",children:"of"}),S.jsx("span",{className:"text-[var(--kd-foreground)] font-bold",children:i.toLocaleString()}),S.jsx("span",{className:"ml-1 text-[var(--kd-muted-foreground)] font-normal",children:"records"})]}:{className:"flex items-center gap-2",children:[S.jsx(le,{className:"w-4 h-4 text-[var(--kd-primary)]/70"}),S.jsxs("span",{className:"font-semibold text-[var(--kd-foreground)]",children:[i.toLocaleString()," ",1===i?"Record":"Records"]})]}),n>0&&S.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-0.5 bg-[var(--kd-primary)]/10 text-[var(--kd-primary)] rounded-full text-xs font-bold border border-[var(--kd-primary)]/20 animate-in fade-in zoom-in duration-200",children:[S.jsx(de,{className:"w-3.5 h-3.5"}),S.jsxs("span",{children:[n.toLocaleString()," Selected"]})]})]}),S.jsxs("div",{className:"flex items-center gap-6",children:[e.enabled&&e.showPageSizeSelector&&S.jsxs("div",{className:"flex items-center gap-2.5",children:[S.jsx("span",{className:"text-[11px] font-bold text-[var(--kd-muted-foreground)] uppercase tracking-wider",children:"Rows per page"}),S.jsxs("div",{className:"relative",children:[S.jsx("select",{value:e.pageSize,onChange:e=>s(Number(e.target.value)),className:"bg-[var(--kd-muted)]/50 hover:bg-[var(--kd-muted)] border-none text-xs font-bold text-[var(--kd-foreground)] rounded-[var(--kd-radius)] py-1 pl-3 pr-8 focus:ring-1 focus:ring-[var(--kd-primary)] transition-all cursor-pointer appearance-none",disabled:r,children:e.pageSizeOptions?.map(e=>S.jsx("option",{value:e,className:"bg-[var(--kd-background)] text-sm",children:e},e))}),S.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none opacity-50",children:S.jsx(Wr,{})})]})]}),e.enabled&&S.jsx("div",{className:"flex items-center gap-2 border-l border-[var(--kd-border)] pl-6",children:S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(Kr,{onClick:()=>a(1,e.pageSize),disabled:1===t||r,title:"First Page",children:S.jsx(I,{className:"w-4 h-4"})}),S.jsx(Kr,{onClick:()=>a(t-1,e.pageSize),disabled:1===t||r,title:"Previous Page",children:S.jsx(A,{className:"w-4 h-4"})}),S.jsx("div",{className:"flex items-center px-3 text-xs font-bold text-[var(--kd-foreground)] min-w-[90px] justify-center",children:S.jsxs("span",{children:["Page ",t," of ",e.totalPages]})}),S.jsx(Kr,{onClick:()=>a(t+1,e.pageSize),disabled:t===e.totalPages||r,title:"Next Page",children:S.jsx(L,{className:"w-4 h-4"})}),S.jsx(Kr,{onClick:()=>a(e.totalPages,e.pageSize),disabled:t===e.totalPages||r,title:"Last Page",children:S.jsx(T,{className:"w-4 h-4"})})]})})]})]})}):null},Kr=({children:e,onClick:t,disabled:r,title:n})=>S.jsx("button",{onClick:t,disabled:r,title:n,className:"w-8 h-8 flex items-center justify-center rounded-[var(--kd-radius)] hover:bg-[var(--kd-muted)] disabled:opacity-30 disabled:pointer-events-none transition-all active:scale-95 text-[var(--kd-foreground)]",children:e}),Wr=()=>S.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:S.jsx("path",{d:"m6 9 6 6 6-6"})});Pr.displayName="PaginationControls";const Vr=c(Pr),_r=({hasFooterAggregate:e,footerScrollRef:t,forwardWheelToBody:r,totalWidth:n,selectable:o,resolvedRowHeight:l,columnsWithWidths:a,flatRows:s,effectivePinnedColumns:i,infiniteScroll:d,paginationConfig:c,isServerLoading:u,selectedRowsCount:m,data:f,filteredData:h,pagination:g,handlePageChange:p,handlePageSizeChange:x})=>S.jsxs(S.Fragment,{children:[e&&S.jsx("div",{ref:t,className:"shrink-0 overflow-x-hidden overflow-y-visible [&::-webkit-scrollbar]:hidden",style:{scrollbarWidth:"none",msOverflowStyle:"none"},onWheel:r,children:S.jsx("div",{className:"bg-[var(--kd-muted)] border-t border-[var(--kd-border)]",style:{minWidth:`${n+(o?yr:0)}px`,height:`${l}px`},children:S.jsx($r,{columns:a,data:s,selectable:o,rowHeight:l,pinnedColumns:i})})}),!d?.enabled&&S.jsx(Vr,{paginationConfig:c,currentPage:c.currentPage,isServerLoading:u,selectedRowsCount:m,totalDataLength:f.length,filteredDataLength:"server"===g?.mode?void 0:h.length,paginationMode:g.mode,onPageChange:p,onPageSizeChange:x})]}),Br=({data:e,columns:t})=>{const[r,n]=o(""),[l,d]=o({}),[c,f]=u(),[,h]=u(),g=s(e=>{f(()=>n(e))},[]),p=m(r),x=s((e,t,r,n)=>{const o=e[t];switch(r.type){case"text":{const e=String(o||"").toLowerCase(),t=String(r.value||"").toLowerCase();switch(r.operator){case"contains":default:return e.includes(t);case"equals":return e===t;case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t)}}case"number":{const e=parseFloat(o),t=parseFloat(String(r.value));if(isNaN(e)||isNaN(t))return!1;switch(r.operator){case"equals":default:return e===t;case"gt":return e>t;case"gte":return e>=t;case"lt":return e<t;case"lte":return e<=t;case"between":{const n=parseFloat(String(r.secondValue??""));return!isNaN(n)&&e>=t&&e<=n}}}case"date":{const e=n?.filterTs,t=n?.secondTs;if(void 0===e||isNaN(e))return!1;const l=new Date(o);if(isNaN(l.getTime()))return!1;const a=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();switch(r.operator){case"equals":default:return a===e;case"gt":return a>e;case"gte":return a>=e;case"lt":return a<e;case"lte":return a<=e;case"between":return void 0!==t&&!isNaN(t)&&a>=e&&a<=t}}case"boolean":return Boolean(o)===Boolean(r.value);case"multiselect":{const e=e=>null==e||""===e||"string"==typeof e&&""===e.trim()?null:e;return(Array.isArray(r.value)?r.value:[r.value]).map(e).includes(e(o))}default:return!0}},[]),v=i(new WeakMap),y=i(0),b=s(()=>{y.current>5e3&&(v.current=new WeakMap,y.current=0)},[]),k=a(()=>{b();const r=Object.keys(l).length>0,n=!!p;if(!r&&!n)return e;const o=p.toLowerCase(),a=v.current;let s=e;if(r)for(const[e,t]of Object.entries(l)){if(!t)continue;let r;if("date"===t.type){const e=t.value instanceof Date?t.value:new Date(String(t.value??"")),n=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let o;if(t.secondValue){const e=t.secondValue instanceof Date?t.secondValue:new Date(String(t.secondValue??""));o=isNaN(e.getTime())?NaN:new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}r={filterTs:n,secondTs:o}}if(s=s.filter(n=>x(n,e,t,r)),0===s.length)break}if(n&&s.length>0){const e=t.filter(e=>!1!==e.visible);s=s.filter(t=>{let r=a.get(t);return null==r&&(r=e.map(e=>{const r=t[e.key];if(null==r)return"";if("string"==typeof r)return r.toLowerCase();if("number"==typeof r||"boolean"==typeof r)return String(r).toLowerCase();const n=String(r);return n.length>100?n.slice(0,100):n}).join("|"),y.current<5e3&&(a.set(t,r),y.current++)),r.includes(o)})}return s},[e,l,p,t,x,b]),w=s((e,t)=>{h(()=>{d(r=>{const n={...r};return t?n[e]=t:delete n[e],n})})},[]),j=s(e=>{w(e,null)},[w]),C=s(()=>{f(()=>n("")),h(()=>d({})),v.current=new WeakMap,y.current=0},[]),N=s(()=>{let e=0;return p&&e++,e+Object.keys(l).length},[p,l]);return{globalFilter:r,setGlobalFilter:g,columnFilters:l,filteredData:k,setColumnFilter:w,clearColumnFilter:j,clearAllFilters:C,getActiveFilterCount:N,isFilterPending:c}};function Gr(){const e=self,t=(e,t)=>{if(!e||0===e.length)return e;if(!t?.key)return e;const{key:r,direction:n}=t,o="asc"===n?1:-1;return[...e].sort((e,t)=>{const n=e?.[r],l=t?.[r];return null==n&&null==l?0:null==n?-1*o:null==l?1*o:"number"==typeof n&&"number"==typeof l?(n-l)*o:String(n).localeCompare(String(l))*o})};e.onmessage=r=>{const n=r.data;if(n&&"process"===n.type)try{const{rows:r,sort:o}=n.payload;e.postMessage({type:"result",payload:{rows:t(r,o??null)}})}catch{e.postMessage({type:"result",payload:{rows:n.payload?.rows??[]}})}}}function Hr(e){const t=e?.enabled??!0,r=i(null),n=i(null),o=i(t);l(()=>{o.current=t,!t&&r.current&&(r.current.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Worker disabled","AbortError")),n.current=null))},[t]);const a=i(()=>null);return a.current=()=>{if(!o.current)return null;if(r.current)return r.current;const e=`(${Gr.toString()})()`,t=new Blob([e],{type:"application/javascript"}),l=URL.createObjectURL(t),a=new Worker(l);return URL.revokeObjectURL(l),a.onmessage=e=>{"result"===e.data?.type&&(n.current?.resolve(e.data.payload.rows),n.current=null)},r.current=a,a},l(()=>()=>{r.current?.terminate(),r.current=null,n.current&&(n.current.reject(new DOMException("Unmounted","AbortError")),n.current=null)},[]),{process:s((e,t)=>{if(!o.current)return Promise.resolve(e);const r=a.current();return r?new Promise((o,l)=>{n.current&&n.current.reject(new DOMException("Superseded by newer sort","AbortError")),n.current={resolve:o,reject:l},r.postMessage({type:"process",payload:{rows:e,sort:t}})}):Promise.resolve(e)},[])}}const Ur="Unknown",Yr=e=>e.join("|"),qr=(e,t,r,n,o)=>{const l=t[r],a=new Map;for(const t of e){const e=String(t[l]??Ur),r=a.get(e);r?r.push(t):a.set(e,[t])}for(const[e,s]of a.entries()){const a=[...n,`${l}=${e}`];o.add(Yr(a)),r<t.length-1&&qr(s,t,r+1,a,o)}},Xr=(e,t)=>{const r={};for(const n of t){if(!n.aggregate)continue;const t=e.map(e=>e[n.key]);let o=null;if("function"==typeof n.aggregate)try{o=n.aggregate(t)}catch(e){o=null}else{const e=e=>!!(/^\d{4}-\d{2}-\d{2}$/.test(e)||/^\d{2}-\d{2}-\d{4}$/.test(e)||/^\d{4}\/\d{2}\/\d{2}$/.test(e)||/^\d{2}\/\d{2}\/\d{4}$/.test(e)||(e.includes("-")||e.includes("/"))&&Number.isFinite(Date.parse(e))),r=t.map(t=>{if("number"==typeof t)return t;if(null==t)return NaN;const r=String(t);if(e(r))return NaN;const n=parseFloat(r.replace(/,/g,""));return Number.isFinite(n)?n:NaN}).filter(e=>Number.isFinite(e)),l=()=>t.map(e=>{if(e instanceof Date)return e.getTime();if("string"==typeof e||"number"==typeof e){const t=Date.parse(String(e));return Number.isFinite(t)?t:NaN}return NaN}).filter(e=>Number.isFinite(e));if("sum"===n.aggregate||"avg"===n.aggregate)r.length&&(o="sum"===n.aggregate?r.reduce((e,t)=>e+t,0):r.reduce((e,t)=>e+t,0)/r.length);else if("min"===n.aggregate||"max"===n.aggregate)if(r.length)o="min"===n.aggregate?Math.min(...r):Math.max(...r);else{const e=l();if(e.length){const t="min"===n.aggregate?Math.min(...e):Math.max(...e);o=new Date(t)}}}null!=o&&(r[n.key]=o)}return r},Jr=({data:e,pagination:t,isLoading:r})=>{const[n,i]=o(1),[d,c]=o(t?.pageSize||50),[u,m]=o(!1),f=r||u||!!t?.serverConfig?.loading;l(()=>{const e=t?.pageSize;e&&e!==d&&(c(e),i(1))},[t?.pageSize]);const h=s(()=>{i(1)},[]),g=a(()=>{const r=!1!==t?.enabled,o="server"===(t?.mode||"client")?t?.serverConfig?.totalRows||0:e.length,l=Math.ceil(o/d);return{enabled:r,pageSize:d,currentPage:n,totalPages:l,totalRows:o,showPageSizeSelector:!1!==t?.showPageSizeSelector,pageSizeOptions:t?.pageSizeOptions||[25,50,100,200,500]}},[t,d,n,e.length]),p=a(()=>{if(!g.enabled||"server"===t?.mode)return e;const r=(n-1)*d;return e.slice(r,r+d)},[e,n,d,g.enabled,t?.mode]),x=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageChange){m(!0);try{await t.serverConfig.onPageChange(e,d)}finally{m(!1)}}i(e)},[t,d]),v=s(async e=>{if("server"===t?.mode&&t?.serverConfig?.onPageSizeChange){m(!0);try{await t.serverConfig.onPageSizeChange(e)}finally{m(!1)}}c(e),i(1)},[t]);return{currentPage:n,resetPage:h,paginationConfig:g,paginatedData:p,isServerLoading:f,handlePageChange:x,handlePageSizeChange:v}},Zr=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},Qr=({data:e,selectedRowIds:t,onRowSelect:r,getRowId:n})=>{const i=s((e,t)=>n?n(e):void 0!==e.id?e.id:t??0,[n]),[d,c]=o(()=>new Set(t?Array.from(t):[]));l(()=>{t&&c(e=>{const r=new Set(Array.from(t));return Zr(e,r)?e:r})},[t]);const u=a(()=>{const t=new Map;return e.forEach((e,r)=>t.set(i(e,r),e)),t},[e,i]);l(()=>{if(0===d.size)return;let e=!1;for(const t of d)if(!u.has(t)){e=!0;break}e&&c(e=>{const t=new Set;return e.forEach(e=>{u.has(e)&&t.add(e)}),Zr(e,t)?e:t})},[u]);const m=s((e,t)=>{if(c(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n}),r){const t=u.get(e);t&&r(t)}},[u,r]),f=s(t=>{c(t?new Set(e.map((e,t)=>i(e,t))):new Set)},[e,i]);return{selectedRows:d,handleRowSelect:m,handleSelectAll:f}},en=({data:e,virtualized:t=!0,rowHeight:r=40,overscan:n=10,height:d})=>{const c=i(null),[u,m]=o(0),f=i(null),h=i(0),[g,p]=o(d);l(()=>{const e=c.current;if(!e)return;const t=new ResizeObserver(([e])=>{const t=e.contentRect.height;t>0&&p(t)});t.observe(e);const r=e.clientHeight;return r>0&&p(r),()=>t.disconnect()},[]),l(()=>{d>0&&p(d)},[d]);const x=a(()=>{if(!t)return{startIndex:0,endIndex:e.length-1,offsetY:0};const o=Math.max(1,Math.ceil(g/r)),l=Math.max(n,Math.min(o,20)),a=Math.max(0,Math.floor(u/r)-l),s=Math.ceil(g/r);return{startIndex:a,endIndex:Math.min(e.length-1,a+s+2*l),offsetY:a*r}},[u,g,e.length,r,n,t]),v=a(()=>t?e.slice(x.startIndex,x.endIndex+1):e,[e,x,t]),y=e.length*r,b=s(e=>{h.current=e.target.scrollTop,null==f.current&&(f.current=requestAnimationFrame(()=>{f.current=null,m(h.current)}))},[]);return l(()=>()=>{null!=f.current&&cancelAnimationFrame(f.current)},[]),{scrollRef:c,virtualizedRange:x,visibleData:v,totalHeight:y,handleScroll:b}};let tn=null;function rn({scrollRef:e,rowIndexById:t,colIndexByKey:r,columnsWithWidths:n,resolvedRowHeight:o,selectable:l}){return{scrollToRow:s(r=>{const n=e.current;if(!n)return;const l=t.get(r);null!=l&&n.scrollTo({top:l*o,behavior:"smooth"})},[e,t,o]),scrollToColumn:s(t=>{const o=e.current;if(!o)return;const a=r.get(t);if(null==a)return;const s=n[a]?.width||100;let i=l?yr:0;for(let e=0;e<a;e++)i+=n[e]?.width||100;const d=i+s,c=o.clientWidth;if(i<o.scrollLeft)o.scrollTo({left:i,behavior:"smooth"});else if(d>o.scrollLeft+c)o.scrollTo({left:d-c,behavior:"smooth"});else{const e=Math.max(0,i-Math.max(0,(c-s)/2));o.scrollTo({left:e,behavior:"smooth"})}},[e,r,n,l])}}const nn=new Uint32Array([439041101,1584364171,2626518639,1514880045]);function on(e,t){let r=e[0],n=e[1],o=3337565984;for(let e=0;e<32;e++)n=n-((r<<4)+t[2]^r+o^(r>>>5)+t[3])>>>0,r=r-((n<<4)+t[0]^n+o^(n>>>5)+t[1])>>>0,o=o-2654435769>>>0;e[0]=r,e[1]=n}let ln;function an(e){ln=e}const sn=()=>!0,dn=f(function({data:e,columns:t,getRowId:r,height:n,density:d="md",headerDensity:c,headerHeight:u,minResizeWidth:m,onDensityChange:f,showDensityControl:g=!1,onRowSelect:p,onSelectedRowsChange:x,selectable:v=!1,isRowSelectable:y,showToolbar:b=!0,showExport:k=!1,filterable:w=!0,groupable:j=!1,virtualized:C=!0,rowHeight:N,overscan:R=6,rowStyle:M,onContextMenu:D,onRowDoubleClick:F,onRowClick:A,onCellClick:L,onCellContextMenu:z,cellFocusEnabled:I=!1,onCellFocusChange:T,onCellEdit:O,onCellEditStart:$,cellSelectionEnabled:P=!1,canSelectCell:K=sn,onCellSelectionChange:W,pagination:V={enabled:!1,mode:"client",pageSize:50},virtualizationThreshold:_=300,loading:B=!1,onFilterChange:G,onSort:H,onColumnConfigChange:U,initialColumnConfig:Y,toolbarLeft:q,toolbarRight:X,groupBarVisibility:J="auto",groupFooterVariant:Z="chips",onCopyCells:Q,selectedRowIds:ee,performanceConfig:te={},exportOptions:re,renderGroupActions:ne,contextMenuItems:oe,infiniteScroll:le,licenseKey:ae,noDataMessage:se,noDataRenderer:ie,theme:de,themeMode:ce="system"},ue){const me=i(null),[fe,he]=o(0);l(()=>{const e=me.current;if(!e)return;const t=()=>he(e.clientWidth||0);t();const r=new ResizeObserver(()=>t());return r.observe(e),()=>r.disconnect()},[]);const[ge,pe]=o(d);l(()=>{pe(d)},[d]);const xe=a(()=>({sm:28,md:40,lg:56}),[]),ve=a(()=>null!=N?N:xe[ge],[N,ge,xe]),ye=a(()=>null!=u?u:xe[c??"md"],[u,c,xe]),{globalFilter:be,columnFilters:ke,filteredData:we,setGlobalFilter:je,setColumnFilter:Ce,clearAllFilters:Ne}=Br({data:e,columns:t}),[Se,Re]=o({key:null,direction:null}),Me=i(null),De=i(null),Ee=s(e=>{let t=e,r="asc";Se.key!==e?(t=e,r="asc"):"asc"===Se.direction?r="desc":"desc"===Se.direction?(t=null,r=null):r="asc",Re({key:t,direction:r}),H&&H(t??"",r)},[H,Se.key,Se.direction]),{process:Fe}=Hr({enabled:!0}),[Ae,Le]=o(we),ze=te?.sortWorkerThreshold??5e3;l(()=>{let e=!1;if(!Se.key)return void Le(we);const t=we;if(t.length<ze){const e="asc"===Se.direction?1:-1,r=[...t].sort((t,r)=>{const n=t?.[Se.key],o=r?.[Se.key];return null==n&&null==o?0:null==n?-1*e:null==o?1*e:"number"==typeof n&&"number"==typeof o?(n-o)*e:String(n).localeCompare(String(o))*e});return void Le(r)}return Fe(t,{key:Se.key,direction:Se.direction}).then(t=>{e||Le(t)}),()=>{e=!0}},[we,Se,Fe,ze]);const Ie=a(()=>le?.enabled?{enabled:!1}:V,[le?.enabled,V?.enabled,V?.mode,V?.pageSize,V?.showPageSizeSelector,V?.pageSizeOptions,V?.serverConfig?.enabled,V?.serverConfig?.totalRows,V?.serverConfig?.loading,V?.serverConfig?.onPageChange,V?.serverConfig?.onPageSizeChange]),{paginationConfig:Te,paginatedData:Oe,isServerLoading:$e,handlePageChange:Pe,handlePageSizeChange:Ke,resetPage:We,currentPage:Ve}=Jr({data:Ae,pagination:Ie,isLoading:B}),_e=V?.enabled?"server"===V.mode?e:Oe:Ae,{groupConfig:Be,displayData:Ge,handleGroupBy:He,addGroupKey:Ue,removeGroupKey:Ye,setGroupKeys:qe,toggleGroupExpansion:Xe,isGrouped:Je,expandAllGroups:Ze,collapseAllGroups:Qe}=(({data:e,columns:t})=>{const[r,n]=o({columnKeys:[],expanded:new Set}),s=a(()=>{const n=r.columnKeys;if(!n.length)return e;const o=[],l=(e,a,s)=>{const i=n[a],d=new Map;for(const t of e){const e=String(t[i]??Ur),r=d.get(e);r?r.push(t):d.set(e,[t])}const c=Array.from(d.entries()).sort(([e],[t])=>e.localeCompare(t));for(const[e,d]of c){const c=[...s,`${i}=${e}`],u=Yr(c);if(o.push({id:`group-${u}`,_isGroupHeader:!0,_groupKey:u,_groupCount:d.length,_groupLevel:a,_groupColumnKey:i,_groupValue:e,_groupRows:d}),!r.expanded.has(u))continue;if(a<n.length-1)l(d,a+1,c);else for(const e of d)o.push(e);const m=Xr(d,t);o.push({id:`group-footer-${u}`,_isGroupFooter:!0,_groupKey:u,_groupLevel:a,_groupAgg:m})}};return l(e,0,[]),o},[e,t,r.columnKeys,r.expanded]);return l(()=>{if(!r.columnKeys.length)return;const t=new Set;qr(e,r.columnKeys,0,[],t);let o=!1;if(t.size!==r.expanded.size)o=!0;else for(const e of t)if(!r.expanded.has(e)){o=!0;break}o&&n(e=>({...e,expanded:t}))},[r.columnKeys,e]),{groupConfig:r,displayData:s,handleGroupBy:e=>{n({columnKeys:e?[e]:[],expanded:new Set})},addGroupKey:e=>{n(t=>t.columnKeys.includes(e)?t:{...t,columnKeys:[...t.columnKeys,e]})},removeGroupKey:e=>{n(t=>{const r=t.columnKeys.filter(t=>t!==e),n=new Set;for(const r of t.expanded)r.includes(`${e}=`)||n.add(r);return{columnKeys:r,expanded:n}})},setGroupKeys:e=>{n({columnKeys:[...e],expanded:new Set})},toggleGroupExpansion:e=>{n(t=>{const r=new Set(t.expanded);return r.has(e)?r.delete(e):r.add(e),{...t,expanded:r}})},expandAllGroups:()=>{const t=r.columnKeys;if(!t.length)return;const o=new Set;qr(e,t,0,[],o),n(e=>({...e,expanded:o}))},collapseAllGroups:()=>{n(e=>({...e,expanded:new Set}))},isGrouped:r.columnKeys.length>0}})({data:_e,columns:t}),{columnVisibility:et,pinnedColumns:tt,handleColumnResize:rt,handleColumnPin:nt,handleColumnVisibilityChange:ot,setColumnOrder:lt,autosizeColumn:at,autosizeAllColumns:st,resetColumns:it,columnsWithWidths:dt,pinnedAll:ct,unpinnedAll:ut,effectivePinnedColumns:mt,columnOrder:ft}=(({columns:e,data:t,initialColumnConfig:r,onColumnConfigChange:n,setSortConfig:d,setGroupKeys:c,setDensity:u,setGlobalFilter:m,setColumnFilter:f,sortConfig:h,groupConfig:g,globalFilter:p,columnFilters:x,density:v,containerWidth:y,selectable:b})=>{const[k,w]=o(()=>{const t={};return e.forEach(e=>{t[e.key]=e.width||100}),t}),j=i(e.reduce((e,t)=>(e[t.key]=t.width||100,e),{})),C=i(e.map(e=>e.key)),[N,S]=o(()=>C.current.slice()),[R,M]=o(new Set),[D,E]=o(()=>{const t={};return e.forEach(e=>{t[e.key]=!0}),t}),F=a(()=>new Set(R),[R]),A=a(()=>{if(0===e.length)return[];const t=new Map(N.map((e,t)=>[e,t])),r=e.filter(e=>!1!==D[e.key]).sort((e,r)=>(t.get(e.key)||0)-(t.get(r.key)||0)).map(e=>{const t=k[e.key]??e.width,r=Number.isFinite(Number(t))?Number(t):100,n=!1!==e.sortable;return{...e,width:r,sortable:n}}),n=Math.max(0,y-(b?yr:0)),o=r.reduce((e,t)=>e+t.width,0),l=new Map;if(n>o){const e=r.filter(e=>e.flex);if(e.length>0){const t=n-o,r=e.reduce((e,t)=>e+Math.max(0,!0===t.flex?1:"number"==typeof t.flex?t.flex:1),0);if(r>0)for(const n of e)l.set(n.key,Math.max(n.minWidth??0,Math.min(n.maxWidth??Number.POSITIVE_INFINITY,n.width+t*(!0===n.flex?1:"number"==typeof n.flex?n.flex:1)/r)))}}const a=e=>l.has(e.key)?{...e,width:l.get(e.key)}:e,s=[],i=[];for(const e of r)F.has(e.key)?s.push(a(e)):i.push(a(e));if(g.columnKeys&&g.columnKeys.length>0){const e=new Map(g.columnKeys.map((e,t)=>[e,t]));i.sort((t,r)=>(e.get(t.key)??Number.POSITIVE_INFINITY)-(e.get(r.key)??Number.POSITIVE_INFINITY))}return[...s,...i]},[e,k,F,D,N,g.columnKeys,y,b]),L=a(()=>A.filter(e=>F.has(e.key)),[A,F]),z=a(()=>A.filter(e=>!F.has(e.key)),[A,F]),I=s((e,t)=>{w(r=>({...r,[e]:t}))},[]),T=s((e,t)=>{M(r=>{const n=new Set(r);return t?n.add(e):n.delete(e),n})},[]),O=s((e,t)=>{E(r=>({...r,[e]:t}))},[]),$=s(e=>{if(null==e)return 0;const t="string"==typeof e?e:String(e);if(!t)return 0;try{if("undefined"!=typeof document){if(!tn){const e=document.createElement("canvas");tn=e.getContext("2d"),tn&&(tn.font="13px Inter, ui-sans-serif, system-ui, sans-serif")}if(tn)return Math.ceil(tn.measureText(t).width)}}catch{}return 8*t.length},[]),P=s(r=>{const n=e.find(e=>e.key===r);if(!n)return;const o=$(n.header),l=t.slice(0,500);let a=0;for(const e of l)a=Math.max(a,$(e[r]));const s=Math.max(60,Math.min(500,Math.max(o,a)+32));w(e=>({...e,[r]:s}))},[e,t,$]),K=s(()=>{e.forEach(e=>P(e.key))},[e,P]),W=s(()=>{w({...j.current}),M(new Set),E(e=>{const t={};return Object.keys(e).forEach(e=>t[e]=!0),t}),S(C.current.slice())},[]);return l(()=>{if(!r)return;const t=new Set(e.map(e=>e.key));if(r.columnWidths){const e=Object.fromEntries(Object.entries(r.columnWidths).filter(([e])=>t.has(e)));w(t=>({...t,...e}))}if(r.columnVisibility){const e=Object.fromEntries(Object.entries(r.columnVisibility).filter(([e])=>t.has(e)));E(t=>({...t,...e}))}if(r.pinnedColumns){const e=r.pinnedColumns.filter(e=>t.has(e));M(new Set(e))}if(r.sortConfig){const e="asc"===r.sortConfig.direction||"desc"===r.sortConfig.direction?r.sortConfig.direction:null;d({key:e?r.sortConfig.key:null,direction:e})}if(r.filters){m(r.filters.globalFilter||"");const e=Object.entries(r.filters.columnFilters||{}).filter(([e])=>t.has(e));for(const[t,r]of e)f(t,r)}if(r.columnOrder&&r.columnOrder.length){const n=r.columnOrder.filter(e=>t.has(e)),o=e.map(e=>e.key).filter(e=>!n.includes(e));S([...n,...o])}r.groupConfig?.columnKeys&&r.groupConfig.columnKeys.length&&c(r.groupConfig.columnKeys),r.density&&u(r.density)},[]),l(()=>{if(!n)return;const e=setTimeout(()=>{n({columnWidths:k,columnVisibility:D,pinnedColumns:Array.from(R),sortConfig:h,groupConfig:{columnKeys:g.columnKeys},filters:{globalFilter:p,columnFilters:x},columnOrder:N,density:v})},200);return()=>clearTimeout(e)},[n,k,D,R,h,g,p,x,N,v]),{columnWidths:k,columnOrder:N,pinnedColumns:R,columnVisibility:D,columnsWithWidths:A,pinnedAll:L,unpinnedAll:z,effectivePinnedColumns:F,handleColumnResize:I,handleColumnPin:T,handleColumnVisibilityChange:O,setColumnOrder:S,autosizeColumn:P,autosizeAllColumns:K,resetColumns:W,setColumnWidths:w,setPinnedColumns:M,setColumnVisibility:E}})({columns:t,data:e,initialColumnConfig:Y,onColumnConfigChange:U,setSortConfig:Re,setGroupKeys:qe,setDensity:pe,setGlobalFilter:je,setColumnFilter:Ce,sortConfig:Se,groupConfig:Be,globalFilter:be,columnFilters:ke,density:ge,containerWidth:fe,selectable:v}),ht=Je?Ge:_e,gt=s(e=>r?r(e):void 0!==e.id?e.id:-1,[r]),{colIndexByKey:pt,colByKey:xt,flatRows:vt,rowIndexById:yt,rowById:bt,totalWidth:kt,columnKeys:wt,hasFooterAggregate:jt}=(({dataToDisplay:e,columnsWithWidths:t,getRowId:r})=>{const n=a(()=>{const e=new Map;return t.forEach((t,r)=>e.set(t.key,r)),e},[t]),o=a(()=>{const e=new Map;return t.forEach(t=>e.set(t.key,t)),e},[t]),l=a(()=>e.filter(e=>!e._isGroupHeader&&!e._isGroupFooter),[e]),s=a(()=>{const e=new Map;return l.forEach((t,n)=>{const o=r?r(t):void 0!==t.id?t.id:n;e.set(o,n)}),e},[l,r]),i=a(()=>{const e=new Map;return l.forEach((t,n)=>{const o=r?r(t):void 0!==t.id?t.id:n;e.set(o,t)}),e},[l,r]),d=a(()=>t.reduce((e,t)=>e+(t.width||100),0),[t]),c=a(()=>t.map(e=>e.key),[t]),u=a(()=>t.some(e=>e.footerAggregate),[t]);return{colIndexByKey:n,colByKey:o,flatRows:l,rowIndexById:s,rowById:i,totalWidth:d,columnKeys:c,hasFooterAggregate:u}})({dataToDisplay:ht,columnsWithWidths:dt,getRowId:gt}),{selectedRows:Ct,handleRowSelect:Nt,handleSelectAll:St}=Qr({data:ht,onRowSelect:p,selectedRowIds:ee,getRowId:gt}),Rt=i(x);l(()=>{Rt.current=x},[x]),l(()=>{Rt.current&&Rt.current(Ct)},[Ct]);const{exportData:Mt}=(({data:e,columns:t,selectedRows:r,filename:n="data",columnVisibility:o})=>{const l=s(()=>o?t.filter(e=>!1!==o[e.key]):t,[t,o]),a=s((e,t,r)=>{const n=new Blob([e],{type:r}),o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)},[]),i=s((e,t)=>{const r=l(),n=r.map(e=>e.header).join(","),o=e.map(e=>r.map(t=>{const r=String(e[t.key]??"");return r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r}).join(","));a([n,...o].join("\n"),`${t}.csv`,"text/csv")},[l,a]),d=s((e,t)=>{const r=l(),n=e.map(e=>{const t={};for(const n of r)t[n.header]=e[n.key];return t});a(JSON.stringify(n,null,2),`${t}.json`,"application/json")},[l,a]),c=s(async(e,t)=>{const r=l(),[{default:n},{saveAs:o}]=await Promise.all([import("exceljs"),import("file-saver")]),a=new n.Workbook,s=a.addWorksheet("Data"),i=e.slice(0,50),d=e=>{if(null==e)return"";if("number"==typeof e||"boolean"==typeof e||e instanceof Date)return e;const t=String(e);if(/[a-zA-Z]/.test(t))return t;if(/^-?[\d,]+\.?\d*$/.test(t.trim())){const e=Number(t.replace(/,/g,""));if(Number.isFinite(e))return e}return t};s.columns=r.map(e=>{const t=e.header||e.key;let r=t?.length||10;for(const t of i){const n=null==t[e.key]?"":String(t[e.key]);n.length>r&&(r=n.length)}return{header:t,key:e.key,width:Math.max(8,Math.min(50,Math.ceil(1.1*r)))}});for(const t of e){const e={};for(const n of r)e[n.key]=d(t[n.key]);s.addRow(e)}s.getRow(1).font={bold:!0},s.autoFilter={from:{row:1,column:1},to:{row:Math.max(1,s.rowCount),column:r.length}};const c=await a.xlsx.writeBuffer();o(new Blob([c],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)},[l]);return{exportData:s((t,o=!1)=>{const l=o&&r&&r.size>0?e.filter(e=>r.has(e.id)):e,a=o&&r&&r.size>0?`${n}_selected_${r.size}_rows`:n;switch(t){case"csv":i(l,a);break;case"json":d(l,a);break;case"xlsx":c(l,a);break;default:console.warn(`[KDGrid] Unsupported export format: ${t}`)}},[e,r,n,i,d,c]),canExportSelected:!!(r&&r.size>0),selectedCount:r?.size??0}})({data:_e,columns:t,selectedRows:Ct,filename:re&&re.filename||"grid-data",columnVisibility:et}),Dt=s((e,t)=>{const r=Array.from(Ct||[]);"server"===re?.exportMode&&"function"==typeof re?.onServerExport?re.onServerExport(e,t,r):Mt(e,t)},[re,Mt,Ct]),Et=a(()=>C&&ht.length>_,[C,ht.length,_]),{scrollRef:Ft,virtualizedRange:At,visibleData:Lt,handleScroll:zt}=en({data:ht,virtualized:Et,rowHeight:ve,overscan:R,height:n||400}),{sentinelRef:It}=function({enabled:e,onLoadMore:t,threshold:r=200,rootRef:n}){const o=i(null),a=i(t);return l(()=>{a.current=t},[t]),l(()=>{if(!e)return;const t=o.current;if(!t)return;const l=new IntersectionObserver(e=>{e[0].isIntersecting&&a.current()},{root:n?.current||null,rootMargin:`0px 0px ${r}px 0px`,threshold:0});return l.observe(t),()=>l.disconnect()},[e,r,n]),{sentinelRef:o}}({enabled:le?.enabled??!1,hasMore:le?.hasMore??!1,isLoading:le?.isLoading??!1,onLoadMore:()=>{!le?.isLoading&&le?.hasMore&&le.onLoadMore()},threshold:le?.threshold??250,rootRef:Ft}),{hScrollLeft:Tt,viewportWidth:Ot,forwardWheelToBody:$t}=(({scrollRef:e,footerScrollRef:t,hasFooterAggregate:r})=>{const[n,a]=o(0),d=i(0),c=i(null),u=s(e=>{d.current=e,null==c.current&&(c.current=requestAnimationFrame(()=>{c.current=null,a(d.current)}))},[]),[m,f]=o(0);l(()=>{const t=e.current;if(!t)return;const r=()=>f(t.clientWidth||0);r();const n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e]),l(()=>{const r=e.current;if(!r)return;let n=!1;const o=()=>{if(n)return;n=!0;const e=t.current;e&&e.scrollLeft!==r.scrollLeft&&(e.scrollLeft=r.scrollLeft),u(r.scrollLeft),requestAnimationFrame(()=>{n=!1})};return r.addEventListener("scroll",o,{passive:!0}),t.current&&(t.current.scrollLeft=r.scrollLeft),()=>{r.removeEventListener("scroll",o)}},[e,r,u]);const h=s(t=>{const r=e.current;if(!r)return;const n=Math.abs(t.deltaX)>=Math.abs(t.deltaY)?t.deltaX:t.deltaY;0!==n&&(t.preventDefault(),r.scrollBy({left:n,top:0,behavior:"auto"}))},[e]);return{hScrollLeft:n,viewportWidth:m,scheduleHScrollUpdate:u,forwardWheelToBody:h}})({scrollRef:Ft,footerScrollRef:De,hasFooterAggregate:jt}),Pt=a(()=>({enableHorizontalVirtualization:!0,horizontalVirtualizationThreshold:50,...te}),[te]),{visibleColumns:Kt,hvPadLeftMemo:Wt,hvPadRightMemo:Vt}=(({columnsWithWidths:e,pinnedAll:t,unpinnedAll:r,effectivePinnedColumns:n,hScrollLeft:o,viewportWidth:l,selectable:s,enableHorizontalVirtualization:i,horizontalVirtualizationThreshold:d})=>{const c=a(()=>i&&e.length>d,[e.length,i,d]),u=a(()=>{const e=r.map(e=>e.width||100),t=new Array(e.length+1).fill(0);for(let r=0;r<e.length;r++)t[r+1]=t[r]+e[r];return{widths:e,prefix:t,totalWidth:t[e.length]||0}},[r]),m=a(()=>{if(!c)return e;const n=s?yr:0,a=t.reduce((e,t)=>e+(t.width||100),0),i=Math.max(0,o-200),d=o+l+200,m=n+a,f=Math.max(0,i-m),h=Math.max(0,Math.min(u.totalWidth,d-m)),g=(e=>{if(!u.widths.length)return 0;let t=0,r=u.widths.length-1,n=0;for(;t<=r;){const o=t+r>>1;u.prefix[o+1]>=e?(n=o,r=o-1):t=o+1}return Math.max(0,Math.min(n,u.widths.length-1))})(f),p=(e=>{if(!u.widths.length)return-1;let t=0,r=u.widths.length-1,n=u.widths.length-1;for(;t<=r;){const o=t+r>>1;u.prefix[o]<=e?(n=o,t=o+1):r=o-1}return Math.max(0,Math.min(n,u.widths.length-1))})(h),x=p>=g&&p>=0?r.slice(g,p+1):[];return[...t,...x]},[c,e,o,l,s,t,r,u]),f=a(()=>{const e=new Map;return r.forEach((t,r)=>e.set(t.key,r)),e},[r]),{hvPadLeftMemo:h,hvPadRightMemo:g}=a(()=>{if(!c)return{hvPadLeftMemo:0,hvPadRightMemo:0};const e=m.filter(e=>!n.has(e.key));if(!e.length)return{hvPadLeftMemo:0,hvPadRightMemo:0};const t=f.get(e[0].key),r=f.get(e[e.length-1].key);return null==t||null==r?{hvPadLeftMemo:0,hvPadRightMemo:0}:{hvPadLeftMemo:u.prefix[t],hvPadRightMemo:u.totalWidth-u.prefix[r+1]}},[c,m,n,f,u]);return{needsHorizontalVirtualization:c,visibleColumns:m,hvPadLeftMemo:h,hvPadRightMemo:g}})({columnsWithWidths:dt,pinnedAll:ct,unpinnedAll:ut,effectivePinnedColumns:mt,hScrollLeft:Tt,viewportWidth:Ot,selectable:v,enableHorizontalVirtualization:Pt.enableHorizontalVirtualization,horizontalVirtualizationThreshold:Pt.horizontalVirtualizationThreshold}),{showLoader:_t,finishingLoader:Bt,loaderTop:Gt}=(({loading:e,isServerLoading:t,resolvedHeaderHeight:r,scrollRef:n,containerRef:a})=>{const s=e||t,[i,d]=o(s),[c,u]=o(!1),[m,f]=o(0);return l(()=>{if(s)return d(!0),void u(!1);if(i){u(!0);const e=setTimeout(()=>{d(!1),u(!1)},200);return()=>clearTimeout(e)}},[s]),l(()=>{const e=()=>{const e=n.current;e&&f((e.offsetTop||0)+(r||0)-1)};e();const t=new ResizeObserver(e);return a.current&&t.observe(a.current),n.current&&t.observe(n.current),()=>t.disconnect()},[r]),{showLoader:i,finishingLoader:c,loaderTop:m}})({loading:B,isServerLoading:$e,resolvedHeaderHeight:ye,scrollRef:Ft,containerRef:me});l(()=>{G&&V?.enabled&&"server"===V.mode&&G({globalFilter:be,columnFilters:ke,filterableKeys:t.filter(e=>!!e.filterable).map(e=>e.key)})},[be,ke,G,t,V?.enabled,V?.mode]),l(()=>{1!==Ve&&(V?.enabled&&"server"===V.mode?Pe(1):We())},[be,ke]);const{focusedCell:Ht,dragOverlay:Ut,isCellSelected:Yt,isCellFocused:qt,handleCellMouseDown:Xt,handleCellMouseEnter:Jt}=(({cellFocusEnabled:e,cellSelectionEnabled:t,canSelectCell:r,flatRows:n,columnsWithWidths:d,rowIndexById:c,colIndexByKey:u,rowById:m,colByKey:f,scrollRef:h,headerScrollRef:g,resolvedRowHeight:p,selectable:x,onCellFocusChange:v,onCellSelectionChange:y,onCopyCells:b,columnKeys:k,getRowId:w})=>{const j=s((e,t)=>w?w(e):void 0!==e.id?e.id:t??0,[w]),[C,N]=o(null),[S,R]=o(null),[M,D]=o(null),[E,F]=o(null),A=i(!1),L=i(null),z=i(null),I=i(y),T=i(b),O=i(null);l(()=>{I.current=y},[y]),l(()=>{T.current=b},[b]);const $=a(()=>(e,n)=>{if(!t)return!1;if(!S||!M)return!1;const o=c.get(e),l=u.get(n);if(null==o||null==l)return!1;const a=m.get(e),s=f.get(n);if(a&&s&&!r(a,s))return!1;const i=Math.min(S.rowIndex,M.rowIndex),d=Math.max(S.rowIndex,M.rowIndex),h=Math.min(S.colIndex,M.colIndex),g=Math.max(S.colIndex,M.colIndex);return o>=i&&o<=d&&l>=h&&l<=g},[t,S,M,c,u,m,f,r]),P=a(()=>(e,t)=>C?.rowId===e&&C?.columnKey===t,[C]),K=s(({row:n,column:o,event:l})=>{const a=j(n),s=c.get(a),i=u.get(o.key);e&&null!=s&&null!=i&&(document.body.hasAttribute("data-modal-open")||(N({rowId:a,columnKey:o.key}),v&&v({row:n,column:o,value:n[o.key],rowIndex:s,colIndex:i}))),t&&r(n,o)&&0===l.button&&(A.current=!0,L.current={x:l.clientX,y:l.clientY},null!=s&&null!=i&&(N({rowId:a,columnKey:o.key}),R({rowIndex:s,colIndex:i}),D({rowIndex:s,colIndex:i}),F({x:l.clientX,y:l.clientY,rows:1,cols:1})))},[e,v,t,r,c,u,j]),W=s(({row:e,column:n,event:o})=>{if(!t)return;if(!A.current||!S)return;if(!r(e,n))return;const l=j(e),a=c.get(l),s=u.get(n.key);if(null==a||null==s)return;D({rowIndex:a,colIndex:s}),L.current={x:o.clientX,y:o.clientY};const i=Math.min(S.rowIndex,a),d=Math.max(S.rowIndex,a),m=Math.min(S.colIndex,s),f=Math.max(S.colIndex,s);F({x:o.clientX,y:o.clientY,rows:d-i+1,cols:f-m+1})},[t,r,S,c,u,j]);l(()=>{const e=()=>{A.current=!1,F(null),z.current&&(cancelAnimationFrame(z.current),z.current=null)};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{A.current&&(L.current={x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]);const V=s(()=>{if(null!=z.current)return;const e=()=>{if(z.current=null,!A.current)return;const t=h.current,r=L.current;if(t&&r){const e=t.getBoundingClientRect(),n=24,o=24;let l=0,a=0;r.x<e.left+n?l=-(e.left+n-r.x):r.x>e.right-n&&(l=r.x-(e.right-n)),r.y<e.top+n?a=-(e.top+n-r.y):r.y>e.bottom-n&&(a=r.y-(e.bottom-n));const s=e=>Math.max(-o,Math.min(o,e));l=s(l),a=s(a),0===l&&0===a||t.scrollBy({left:l,top:a,behavior:"auto"})}z.current=requestAnimationFrame(e)};z.current=requestAnimationFrame(e)},[]);return l(()=>{A.current&&V()},[V,S]),l(()=>{const e=e=>{if("Escape"===e.key)return R(null),D(null),N(null),void F(null);const r=e.shiftKey,o=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key);if(!r||!o||!t)return;e.preventDefault();let l=M;if(!l){if(!C)return;{const e=c.get(C.rowId),t=u.get(C.columnKey);if(null==e||null==t)return;R({rowIndex:e,colIndex:t}),l={rowIndex:e,colIndex:t}}}const a=n.length-1,s=d.length-1;let i=l.rowIndex,m=l.colIndex;"ArrowUp"===e.key&&(i=Math.max(0,i-1)),"ArrowDown"===e.key&&(i=Math.min(a,i+1)),"ArrowLeft"===e.key&&(m=Math.max(0,m-1)),"ArrowRight"===e.key&&(m=Math.min(s,m+1)),D({rowIndex:i,colIndex:m});const f=h.current;if(f){const e=f.getBoundingClientRect();F({x:e.right-16,y:e.bottom-16,rows:Math.abs((S?.rowIndex??i)-i)+1,cols:Math.abs((S?.colIndex??m)-m)+1})}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,C,S,M,c,u,n.length,d.length]),l(()=>{if(!e)return;const t=h.current,r=g.current,o=e=>{if(!C)return;if(document.body.hasAttribute("data-modal-open"))return;const{key:o}=e;if("ArrowLeft"!==o&&"ArrowRight"!==o&&"ArrowUp"!==o&&"ArrowDown"!==o)return;e.preventDefault();const l=c.get(C.rowId),a=u.get(C.columnKey);if(null==l||null==a)return;let s=l,i=a;"ArrowLeft"===o&&(i=Math.max(0,a-1)),"ArrowRight"===o&&(i=Math.min(d.length-1,a+1)),"ArrowUp"===o&&(s=Math.max(0,l-1)),"ArrowDown"===o&&(s=Math.min(n.length-1,l+1));const m=n[s],f=d[i];if(!m||!f)return;const h=j(m,s);N({rowId:h,columnKey:f.key}),v&&v({row:m,column:f,value:m[f.key],rowIndex:s,colIndex:i}),((e,n)=>{if(!t)return;const o=t.clientHeight,l=e*p,a=l+p;l<t.scrollTop?t.scrollTop=l:a>t.scrollTop+o&&(t.scrollTop=a-o);const s=d[n]?.width||100;let i=x?36:0;for(let e=0;e<n;e++)i+=d[e]?.width||100;const c=i+s,u=t.clientWidth;i<t.scrollLeft?t.scrollLeft=i:c>t.scrollLeft+u&&(t.scrollLeft=c-u),r&&(r.scrollLeft=t.scrollLeft)})(s,i)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,C,n,d,p,x,c,u,v]),l(()=>{if(!t||!S||!M){const e={bounds:null,cells:[]},t="none";return void(t!==O.current&&(O.current=t,I.current?.(e)))}const e=Math.min(S.rowIndex,M.rowIndex),o=Math.max(S.rowIndex,M.rowIndex),l=Math.min(S.colIndex,M.colIndex),a=Math.max(S.colIndex,M.colIndex),s=[];for(let t=e;t<=o;t++){const e=n[t];if(e)for(let n=l;n<=a;n++){const o=d[n];o&&r(e,o)&&s.push({row:e,column:o,value:e[o.key],rowIndex:t,colIndex:n})}}const i={bounds:{rowStart:e,rowEnd:o,colStart:l,colEnd:a},cells:s},c=`${e}-${o}-${l}-${a}|len:${s.length}`;c!==O.current&&(O.current=c,I.current?.(i))},[t,S,M,n,k,r]),l(()=>{if(!t&&!e)return;const o=async t=>{if(!t.metaKey&&!t.ctrlKey||"c"!==t.key.toLowerCase())return;const o=!!t.shiftKey,l=!(!S||!M),a=!(!e||!C);if(!l&&!a)return;if(!l&&a){const e=window.getSelection();if(e&&e.toString().length>0)return;const t=document.activeElement;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return}t.preventDefault();const s=(()=>{const e=[];if(l&&S&&M){const t=Math.min(S.rowIndex,M.rowIndex),o=Math.max(S.rowIndex,M.rowIndex),l=Math.min(S.colIndex,M.colIndex),a=Math.max(S.colIndex,M.colIndex);for(let s=t;s<=o;s++){const t=n[s];if(t)for(let n=l;n<=a;n++){const o=d[n];o&&r(t,o)&&e.push({row:t,column:o,value:t[o.key],rowIndex:s,colIndex:n})}}}else if(a&&C){const t=c.get(C.rowId),r=u.get(C.columnKey);if(null!=t&&null!=r){const o=n[t],l=d[r];o&&l&&e.push({row:o,column:l,value:o[l.key],rowIndex:t,colIndex:r})}}return e})();if(!s.length)return;const i=e=>{const t=null==e?"":String(e);return t.includes('"')||t.includes("\t")||t.includes("\n")||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t};let m="";if(l&&S&&M){const e=Math.min(S.rowIndex,M.rowIndex),t=Math.max(S.rowIndex,M.rowIndex),l=Math.min(S.colIndex,M.colIndex),a=Math.max(S.colIndex,M.colIndex);if(o){const e=[];for(let t=l;t<=a;t++){const r=d[t];r&&e.push(i(r.header??r.key))}m+=e.join("\t")+"\n"}for(let o=e;o<=t;o++){const e=n[o];if(!e)continue;const s=[];for(let t=l;t<=a;t++){const n=d[t];n&&(r(e,n)?s.push(i(e[n.key])):s.push(""))}m+=s.join("\t"),o<t&&(m+="\n")}}else m=i(s[0].value);try{await navigator.clipboard.writeText(m)}catch{console.warn("Failed to write to clipboard")}if("function"==typeof T.current){const e=l&&S&&M?{rowStart:Math.min(S.rowIndex,M.rowIndex),rowEnd:Math.max(S.rowIndex,M.rowIndex),colStart:Math.min(S.colIndex,M.colIndex),colEnd:Math.max(S.colIndex,M.colIndex)}:null;try{T.current({text:m,bounds:e,cells:s,isRectangular:!!e,isFocusedCell:!e})}catch{}}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,e,S,M,C,n,d,r,c,u]),{focusedCell:C,selectionAnchor:S,selectionEnd:M,dragOverlay:E,isCellSelected:$,isCellFocused:P,handleCellMouseDown:K,handleCellMouseEnter:W}})({cellFocusEnabled:I,cellSelectionEnabled:P,canSelectCell:K,flatRows:vt,columnsWithWidths:dt,rowIndexById:yt,colIndexByKey:pt,rowById:bt,colByKey:xt,scrollRef:Ft,headerScrollRef:Me,resolvedRowHeight:ve,selectable:v,onCellFocusChange:T,onCellSelectionChange:W,onCopyCells:Q,columnKeys:wt,getRowId:gt}),{editingCell:Zt,startEdit:Qt,commitEdit:er,cancelEdit:tr,isEditing:rr}=(({getRowId:e,onCellEdit:t,onCellEditStart:r,focusedCell:n,getRowById:a,getColumnByKey:i})=>{const[d,c]=o(null),u=s((t,n)=>{if(!((e,t)=>!!e.editable&&("function"==typeof e.editable?e.editable(t):!!e.editable))(n,t))return;const o=t[n.key];if(r&&!1===r({row:t,column:n,value:o}))return;const l=e(t);c({rowId:l,columnKey:n.key,initialValue:o,row:t,column:n})},[e,r]),m=s(e=>{if(!d)return;const{row:r,column:n,initialValue:o,rowId:l}=d;c(null),e!==o&&t?.({row:r,column:n,oldValue:o,newValue:e,rowId:l})},[d,t]),f=s(()=>{c(null)},[]);l(()=>{if(!n||!a||!i)return;const e=e=>{if("F2"!==e.key)return;if(d)return;const t=a(n.rowId),r=i(n.columnKey);t&&r&&(e.preventDefault(),u(t,r))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,d,a,i,u]);const h=s((e,t)=>d?.rowId===e&&d?.columnKey===t,[d]);return{editingCell:d,startEdit:u,commitEdit:m,cancelEdit:f,isEditing:h}})({getRowId:gt,onCellEdit:O,onCellEditStart:$,focusedCell:Ht,getRowById:e=>bt.get(e),getColumnByKey:e=>xt.get(e)}),{scrollToRow:nr,scrollToColumn:or}=rn({scrollRef:Ft,rowIndexById:yt,colIndexByKey:pt,columnsWithWidths:dt,resolvedRowHeight:ve,selectable:v});h(ue,()=>({setGroupKeys:qe,addGroupKey:Ue,removeGroupKey:Ye,expandAllGroups:Ze,collapseAllGroups:Qe,toggleGroupExpansion:Xe,getGroupConfig:()=>Be,setColumnFilter:Ce,clearColumnFilter:e=>Ce(e,null),clearAllFilters:Ne,setGlobalFilter:je,getRowId:gt,scrollToRow:nr,scrollToColumn:or}),[qe,Ue,Ye,Ze,Qe,Xe,Be,Ce,Ne,je,gt,nr,or]);const lr=a(()=>function(e){let t=(e||ln||"").replace(/-/g,"").toLowerCase();if("kdinternaldevbypass"===t)return!0;if((t.startsWith("kdtest")||t.startsWith("kdlive"))&&(t=t.slice(6)),32!==t.length)return!1;try{const e=new Uint32Array(4);for(let r=0;r<4;r++)e[r]=parseInt(t.slice(8*r,8*r+8),16);const r=new Uint32Array([e[0],e[1]]),n=new Uint32Array([e[2],e[3]]);on(r,nn),on(n,nn);const o=r[1];if(1262769713!==r[0])return!1;const l=Math.floor(o/1e4),a=Math.floor(o%1e4/100)-1,s=o%100;if(l<2024||a<0||a>11||s<1||s>31)return!1;const i=new Date(l,a,s,23,59,59);return!(new Date>i&&(console.error("[KDGrid] License expired on "+i.toDateString()),1))}catch{return!1}}(ae),[ae]),ar=s(()=>Ne(),[Ne]),sr=s(e=>{pe(e),f&&f(e)},[f]),ir=s(e=>je(e.target.value),[je]);return S.jsx(E,{theme:de,defaultMode:ce,children:S.jsxs("div",{ref:me,className:"border border-[var(--kd-border)] rounded-[var(--kd-radius)] overflow-hidden bg-[var(--kd-background)] text-[var(--kd-foreground)] h-full flex flex-col","data-grid-container":!0,children:[S.jsx(vr,{showToolbar:b,filterable:w,globalFilter:be,filteredDataLength:we.length,totalDataLength:Te.totalRows,paginationMode:V?.mode,selectedRowsCount:Ct.size,showExport:k,columns:t,columnFilters:ke,columnVisibility:et,onResetColumns:it,exportOptions:{enabled:(re?.enabled??!0)&&k,formats:re?.formats??["xlsx"],filename:re?.filename??"grid-data",onExport:Dt},toolbarLeft:q,toolbarRight:X,onGlobalFilterChange:ir,onClearFilters:ar,onColumnFilter:Ce,onColumnVisibilityChange:ot,columnOrder:ft,onColumnOrderChange:lt,pinnedColumns:tt,onScrollToColumn:or,density:ge,onDensityChange:sr,showDensityControl:g,groupable:j,groupBarVisibility:J,groupConfig:Be,removeGroupKey:Ye,setGroupKeys:qe,addGroupKey:Ue,collapseAllGroups:Qe,expandAllGroups:Ze}),S.jsx("div",{className:"flex flex-col relative flex-1 min-h-50",children:S.jsx(Or,{scrollRef:Ft,flatRows:vt,columnsWithWidths:dt,visibleColumns:Kt,totalWidth:kt,selectable:v,dataToDisplay:ht,pinnedAll:ct,effectivePinnedColumns:mt,hvPadLeftMemo:Wt,hvPadRightMemo:Vt,resolvedHeaderHeight:ye,sortConfig:Se,columnFilters:ke,selectedRows:Ct,data:e,handleSort:Ee,setColumnFilter:Ce,handleSelectAll:St,handleColumnResize:rt,handleColumnPin:nt,addGroupKey:Ue,removeGroupKey:Ye,handleGroupBy:He,autosizeColumn:at,autosizeAllColumns:st,resetColumns:it,columnOrder:ft,setColumnOrder:lt,pagination:V,minResizeWidth:m,effectiveVirtualized:Et,virtualizedRange:At,resolvedRowHeight:ve,visibleData:Lt,isRowSelectable:y,handleRowSelect:Nt,rowStyle:M,globalFilter:be,onContextMenu:D,onRowDoubleClick:F,onRowClick:A,onCellClick:L,onCellContextMenu:z,isCellFocused:qt,isCellSelected:Yt,handleCellMouseDown:Xt,handleCellMouseEnter:Jt,contextMenuItems:oe,getRowId:r,isEditing:rr,startEdit:Qt,commitEdit:er,cancelEdit:tr,editingCell:Zt,safeGetRowId:gt,toggleGroupExpansion:Xe,containerWidth:fe,groupConfig:Be,columns:t,renderGroupActions:ne,groupFooterVariant:Z,isValidLicense:lr,infiniteScroll:le,sentinelRef:It,loading:B,showLoader:_t,finishingLoader:Bt,loaderTop:Gt,noDataMessage:se,noDataRenderer:ie,handleScroll:zt,cellSelectionEnabled:P})}),S.jsx(_r,{hasFooterAggregate:jt,footerScrollRef:De,forwardWheelToBody:$t,totalWidth:kt,selectable:v,resolvedRowHeight:ve,columnsWithWidths:dt,flatRows:vt,effectivePinnedColumns:mt,infiniteScroll:le,paginationConfig:Te,isServerLoading:$e,selectedRowsCount:Ct.size,data:e,filteredData:we,pagination:V,handlePageChange:Pe,handlePageSizeChange:Ke}),Ut&&S.jsx("div",{className:"fixed z-50 pointer-events-none select-none",style:{top:Ut.y+12,left:Ut.x+12},children:S.jsxs("div",{className:"px-2 py-1 rounded bg-gray-800 text-white text-xs shadow-lg opacity-90",children:[Ut.rows," x ",Ut.cols]})})]})})});var cn=dn;const un=({url:e,initialPageSize:t=25,initialSort:r={key:null,direction:null},debounceMs:n=300,mapParams:d,mapResponse:c,headers:u,staticParams:m,fetcher:f=("undefined"!=typeof window?window.fetch.bind(window):void 0)})=>{const[h,g]=o([]),[p,x]=o(!1),[v,y]=o(null),[b,k]=o(0),[w,j]=o(1),[C,N]=o(t),[S,R]=o(r),[M,D]=o(""),[E,F]=o({}),A=i(null),L=s(async t=>{if(f){x(!0),y(null);try{const r=d?d(t):{page:t.page,limit:t.pageSize,sort:t.sortField,order:t.sortOrder,q:t.globalFilter,filters:JSON.stringify(t.columnFilters),...m},n=new URLSearchParams(Object.entries(r).filter(([e,t])=>null!=t).map(([e,t])=>[e,String(t)])).toString(),o=await f(`${e}?${n}`,{headers:u});if(!o.ok)throw new Error(`Failed to fetch grid data: ${o.status} ${o.statusText}`);const l=await o.json();let a=[],s=0;if(c){const e=c(l);a=e.data,s=e.total}else a=l.data||(Array.isArray(l)?l:[]),s=l.total??l.totalCount??l.count??(Array.isArray(l)?l.length:l.data?.length??0);g(a),k(Number(s)||0)}catch(e){y(e instanceof Error?e:new Error(String(e))),g([]),k(0)}finally{x(!1)}}},[e,d,c,u,m]);l(()=>{const e={page:w,pageSize:C,sortField:S.key,sortOrder:S.direction,globalFilter:M,columnFilters:E};return A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{L(e)},n),()=>{A.current&&clearTimeout(A.current)}},[w,C,S,M,E,n,L]);const z=s((e,t)=>{R({key:e,direction:t}),j(1)},[]),I=s(e=>{D(t=>t!==e.globalFilter?(j(1),e.globalFilter):t),F(t=>JSON.stringify(t)!==JSON.stringify(e.columnFilters)?(j(1),e.columnFilters):t)},[]),T=s(e=>{j(e)},[]),O=s(e=>{N(e),j(1)},[]),$=a(()=>({data:h,loading:p,pagination:{enabled:!0,mode:"server",pageSize:C,serverConfig:{enabled:!0,totalRows:b,onPageChange:T,onPageSizeChange:O}},onSort:z,onFilterChange:I}),[h,p,C,b,T,O,z,I]);return{data:h,loading:p,error:v,totalCount:b,gridProps:$,params:{page:w,pageSize:C,sortConfig:S,globalFilter:M,columnFilters:E},refresh:()=>L({page:w,pageSize:C,sortField:S.key,sortOrder:S.direction,globalFilter:M,columnFilters:E}),setPage:j,setPageSize:N,setSortConfig:R,setGlobalFilter:D,setColumnFilters:F}},mn=({children:e,variant:t="primary",size:r="md",isLoading:n,className:o="",disabled:l,...a})=>S.jsxs("button",{className:`inline-flex items-center justify-center rounded-[var(--kd-radius)] font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--kd-ring)] focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed active:scale-95 select-none ${{primary:"bg-[var(--kd-primary)] text-[var(--kd-primary-foreground)] hover:brightness-90 shadow-sm border border-transparent",secondary:"bg-[var(--kd-muted)] text-[var(--kd-foreground)] hover:bg-[var(--kd-border)] border border-transparent",outline:"border border-[var(--kd-border)] bg-transparent hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)]",ghost:"bg-transparent hover:bg-[var(--kd-muted)] text-[var(--kd-foreground)] border border-transparent",danger:"bg-red-600 text-white hover:bg-red-700 shadow-sm border border-transparent"}[t]} ${{sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"}[r]} ${o}`,disabled:l||n,...a,children:[n?S.jsx("span",{className:"mr-2 animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent transition-opacity"}):null,S.jsx("span",{className:"flex items-center gap-2",children:e})]}),fn=({label:e,error:t,helperText:r,icon:n,className:o="",id:l,...a})=>S.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[e&&S.jsx("label",{htmlFor:l,className:"text-sm font-medium text-[var(--kd-foreground)] opacity-90",children:e}),S.jsxs("div",{className:"relative group",children:[n&&S.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--kd-muted-foreground)] group-focus-within:text-[var(--kd-primary)] transition-colors",children:n}),S.jsx("input",{id:l,className:`w-full ${n?"pl-10":"pl-3"} pr-3 py-2 bg-[var(--kd-background)] text-[var(--kd-foreground)] border rounded-[var(--kd-radius)] text-sm transition-all shadow-sm focus:ring-2 focus:ring-[var(--kd-ring)] focus:border-[var(--kd-primary)] outline-none ${t?"border-red-500 focus:ring-red-500":"border-[var(--kd-border)] group-hover:border-[var(--kd-muted-foreground)]"} ${o}`,...a})]}),t&&S.jsx("p",{className:"text-xs text-red-500 font-medium",children:t}),!t&&r&&S.jsx("p",{className:"text-xs text-gray-500",children:r})]}),hn=({label:e,className:t="",id:r,...n})=>S.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none group",children:[S.jsx("div",{className:"relative flex items-center justify-center",children:S.jsx("input",{id:r,type:"checkbox",className:`peer w-4 h-4 rounded-[var(--kd-radius)] border-[var(--kd-border)] text-[var(--kd-primary)] focus:ring-[var(--kd-ring)] transition-all bg-[var(--kd-background)] ${t}`,...n})}),e&&S.jsx("span",{className:"text-sm text-[var(--kd-foreground)] opacity-90 group-hover:text-[var(--kd-foreground)] transition-colors",children:e})]}),gn={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95%] h-[95%]"},pn=({isOpen:e,onClose:t,title:r,children:n,footer:o,size:a="md",showCloseButton:s=!0})=>{const d=i(null);return l(()=>{const r=e=>{"Escape"===e.key&&t()};return e&&(window.addEventListener("keydown",r),document.body.style.overflow="hidden"),()=>{window.removeEventListener("keydown",r),document.body.style.overflow="unset"}},[e,t]),e?p(S.jsxs("div",{className:"fixed inset-0 z-1000 flex items-center justify-center p-4",children:[S.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm transition-opacity duration-300 animate-in fade-in",onClick:t,"aria-hidden":"true"}),S.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",className:`relative w-full ${gn[a]} bg-[var(--kd-background)] border border-[var(--kd-border)] rounded-2xl shadow-2xl flex flex-col transition-all duration-300 animate-in fade-in zoom-in-95 overflow-hidden`,children:[S.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kd-border)] bg-[var(--kd-muted)]/30",children:[r?S.jsx("h2",{id:"modal-title",className:"text-lg font-semibold text-[var(--kd-foreground)] truncate",children:r}):S.jsx("div",{}),s&&S.jsx("button",{onClick:t,className:"p-1 rounded-full hover:bg-[var(--kd-muted)] text-[var(--kd-muted-foreground)] hover:text-[var(--kd-foreground)] transition-colors","aria-label":"Close modal",children:S.jsx(K,{className:"w-5 h-5"})})]}),S.jsx("div",{className:"flex-1 overflow-y-auto p-6 text-[var(--kd-foreground)]",children:n}),o&&S.jsx("div",{className:"p-4 border-t border-[var(--kd-border)] bg-[var(--kd-muted)]/10 flex justify-end gap-3",children:o})]})]}),document.body):null},xn={default:"bg-[var(--kd-muted)] text-[var(--kd-muted-foreground)] border-transparent",primary:"bg-[var(--kd-primary)] text-[var(--kd-primary-foreground)] border-transparent shadow-sm",success:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20 dark:bg-emerald-500/20 dark:text-emerald-400",warning:"bg-orange-500/10 text-orange-600 border-orange-500/20 dark:bg-orange-500/20 dark:text-orange-400",destructive:"bg-red-500/10 text-red-600 border-red-500/20 dark:bg-red-500/20 dark:text-red-400",outline:"bg-transparent border-[var(--kd-border)] text-[var(--kd-foreground)]"},vn=({children:e,variant:t="default",className:r=""})=>S.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold border transition-colors ${xn[t]} ${r}`,children:e}),yn=({content:e,children:r,position:n="top",delay:a=200})=>{const[s,d]=o(!1),[c,u]=o({top:0,left:0}),m=i(null),f=i(null);l(()=>()=>{f.current&&window.clearTimeout(f.current)},[]);const h=t.cloneElement(r,{ref:m,onMouseEnter:()=>{f.current=window.setTimeout(()=>{(()=>{if(!m.current)return;const e=m.current.getBoundingClientRect(),t=window.scrollX,r=window.scrollY;let o=0,l=0;switch(n){case"top":o=e.top+r-8,l=e.left+t+e.width/2;break;case"bottom":o=e.bottom+r+8,l=e.left+t+e.width/2;break;case"left":o=e.top+r+e.height/2,l=e.left+t-8;break;case"right":o=e.top+r+e.height/2,l=e.right+t+8}u({top:o,left:l})})(),d(!0)},a)},onMouseLeave:()=>{f.current&&window.clearTimeout(f.current),d(!1)}});return S.jsxs(S.Fragment,{children:[h,s&&p(S.jsx("div",{className:"fixed z-1000 px-2 py-1 bg-gray-900/90 text-white text-[11px] font-medium rounded shadow-lg backdrop-blur-sm pointer-events-none transition-opacity duration-200 animate-in fade-in zoom-in-95 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap border border-white/10",style:{top:c.top,left:c.left},children:e}),document.body)]})},bn=({trigger:e,items:t,align:r="left",className:n=""})=>{const[a,s]=o(!1),d=i(null);return l(()=>{const e=e=>{d.current&&!d.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),S.jsxs("div",{className:`relative inline-block ${n}`,ref:d,children:[S.jsx("div",{onClick:()=>s(!a),className:"cursor-pointer",children:e}),a&&S.jsx("div",{className:`absolute z-1000 mt-2 min-w-[160px] bg-[var(--kd-background)] border border-[var(--kd-border)] rounded-[var(--kd-radius)] shadow-xl py-1 animate-in fade-in zoom-in-95 origin-top-${"left"===r?"left":"right"} ${"right"===r?"right-0":"left-0"}`,children:t.map((e,t)=>S.jsxs("button",{disabled:e.disabled,onClick:()=>{e.onClick(),s(!1)},className:"w-full flex items-center gap-2 px-4 py-2 text-sm transition-colors "+(e.disabled?"opacity-50 cursor-not-allowed text-[var(--kd-muted-foreground)]":"destructive"===e.variant?"text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20":"text-[var(--kd-foreground)] hover:bg-[var(--kd-muted)]"),children:[e.icon&&S.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:e.icon}),S.jsx("span",{className:"flex-1 text-left",children:e.label})]},t))})]})};export{vn as Badge,mn as Button,hn as Checkbox,sr as CustomSelect,ir as DatePicker,bn as Dropdown,$r as FooterAggregate,Rr as GridHeader,Ar as GridRows,xr as GroupBar,dn as KDGrid,E as KDGridProvider,pn as Modal,Vr as PaginationControls,Qt as Popover,fn as TextField,pr as Toolbar,yn as Tooltip,cn as default,R as defaultTheme,an as setLicenseKey,Br as useAdvancedFiltering,rn as useGridMethods,un as useGridServerData,D as useKDGridTheme,Jr as usePagination,Qr as useSelection,en as useVirtualization};
|