react-base-data-table 0.5.1 → 0.5.3

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/index.cjs.js CHANGED
@@ -38,7 +38,7 @@ object-assign
38
38
  (c) Sindre Sorhus
39
39
  @license MIT
40
40
  */var eo,zl;function Dp(){if(zl)return eo;zl=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function i(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var o={},a=0;a<10;a++)o["_"+String.fromCharCode(a)]=a;var l=Object.getOwnPropertyNames(o).map(function(u){return o[u]});if(l.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(u){c[u]=u}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return eo=i()?Object.assign:function(s,o){for(var a,l=r(s),c,u=1;u<arguments.length;u++){a=Object(arguments[u]);for(var d in a)t.call(a,d)&&(l[d]=a[d]);if(e){c=e(a);for(var h=0;h<c.length;h++)n.call(a,c[h])&&(l[c[h]]=a[c[h]])}}return l},eo}var to,Vl;function ga(){if(Vl)return to;Vl=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return to=e,to}var no,Wl;function vh(){return Wl||(Wl=1,no=Function.call.bind(Object.prototype.hasOwnProperty)),no}var ro,Ul;function kp(){if(Ul)return ro;Ul=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=ga(),n={},r=vh();e=function(s){var o="Warning: "+s;typeof console<"u"&&console.error(o);try{throw new Error(o)}catch{}}}function i(s,o,a,l,c){if(process.env.NODE_ENV!=="production"){for(var u in s)if(r(s,u)){var d;try{if(typeof s[u]!="function"){var h=Error((l||"React class")+": "+a+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof s[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw h.name="Invariant Violation",h}d=s[u](o,u,l,a,null,t)}catch(p){d=p}if(d&&!(d instanceof Error)&&e((l||"React class")+": type specification of "+a+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof d+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),d instanceof Error&&!(d.message in n)){n[d.message]=!0;var g=c?c():"";e("Failed "+a+" type: "+d.message+(g??""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},ro=i,ro}var io,Gl;function Ip(){if(Gl)return io;Gl=1;var e=bh(),t=Dp(),n=ga(),r=vh(),i=kp(),s=function(){};process.env.NODE_ENV!=="production"&&(s=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}});function o(){return null}return io=function(a,l){var c=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function d(E){var T=E&&(c&&E[c]||E[u]);if(typeof T=="function")return T}var h="<<anonymous>>",g={array:v("array"),bigint:v("bigint"),bool:v("boolean"),func:v("function"),number:v("number"),object:v("object"),string:v("string"),symbol:v("symbol"),any:y(),arrayOf:S,element:w(),elementType:x(),instanceOf:C,node:$(),objectOf:M,oneOf:A,oneOfType:R,shape:j,exact:q};function p(E,T){return E===T?E!==0||1/E===1/T:E!==E&&T!==T}function m(E,T){this.message=E,this.data=T&&typeof T=="object"?T:{},this.stack=""}m.prototype=Error.prototype;function b(E){if(process.env.NODE_ENV!=="production")var T={},P=0;function L(U,H,G,Y,D,O,B){if(Y=Y||h,O=O||G,B!==n){if(l){var k=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw k.name="Invariant Violation",k}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var K=Y+":"+G;!T[K]&&P<3&&(s("You are manually calling a React.PropTypes validation function for the `"+O+"` prop on `"+Y+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),T[K]=!0,P++)}}return H[G]==null?U?H[G]===null?new m("The "+D+" `"+O+"` is marked as required "+("in `"+Y+"`, but its value is `null`.")):new m("The "+D+" `"+O+"` is marked as required in "+("`"+Y+"`, but its value is `undefined`.")):null:E(H,G,Y,D,O)}var N=L.bind(null,!1);return N.isRequired=L.bind(null,!0),N}function v(E){function T(P,L,N,U,H,G){var Y=P[L],D=X(Y);if(D!==E){var O=F(Y);return new m("Invalid "+U+" `"+H+"` of type "+("`"+O+"` supplied to `"+N+"`, expected ")+("`"+E+"`."),{expectedType:E})}return null}return b(T)}function y(){return b(o)}function S(E){function T(P,L,N,U,H){if(typeof E!="function")return new m("Property `"+H+"` of component `"+N+"` has invalid PropType notation inside arrayOf.");var G=P[L];if(!Array.isArray(G)){var Y=X(G);return new m("Invalid "+U+" `"+H+"` of type "+("`"+Y+"` supplied to `"+N+"`, expected an array."))}for(var D=0;D<G.length;D++){var O=E(G,D,N,U,H+"["+D+"]",n);if(O instanceof Error)return O}return null}return b(T)}function w(){function E(T,P,L,N,U){var H=T[P];if(!a(H)){var G=X(H);return new m("Invalid "+N+" `"+U+"` of type "+("`"+G+"` supplied to `"+L+"`, expected a single ReactElement."))}return null}return b(E)}function x(){function E(T,P,L,N,U){var H=T[P];if(!e.isValidElementType(H)){var G=X(H);return new m("Invalid "+N+" `"+U+"` of type "+("`"+G+"` supplied to `"+L+"`, expected a single ReactElement type."))}return null}return b(E)}function C(E){function T(P,L,N,U,H){if(!(P[L]instanceof E)){var G=E.name||h,Y=J(P[L]);return new m("Invalid "+U+" `"+H+"` of type "+("`"+Y+"` supplied to `"+N+"`, expected ")+("instance of `"+G+"`."))}return null}return b(T)}function A(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&(arguments.length>1?s("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):s("Invalid argument supplied to oneOf, expected an array.")),o;function T(P,L,N,U,H){for(var G=P[L],Y=0;Y<E.length;Y++)if(p(G,E[Y]))return null;var D=JSON.stringify(E,function(B,k){var K=F(k);return K==="symbol"?String(k):k});return new m("Invalid "+U+" `"+H+"` of value `"+String(G)+"` "+("supplied to `"+N+"`, expected one of "+D+"."))}return b(T)}function M(E){function T(P,L,N,U,H){if(typeof E!="function")return new m("Property `"+H+"` of component `"+N+"` has invalid PropType notation inside objectOf.");var G=P[L],Y=X(G);if(Y!=="object")return new m("Invalid "+U+" `"+H+"` of type "+("`"+Y+"` supplied to `"+N+"`, expected an object."));for(var D in G)if(r(G,D)){var O=E(G,D,N,U,H+"."+D,n);if(O instanceof Error)return O}return null}return b(T)}function R(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&s("Invalid argument supplied to oneOfType, expected an instance of array."),o;for(var T=0;T<E.length;T++){var P=E[T];if(typeof P!="function")return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(P)+" at index "+T+"."),o}function L(N,U,H,G,Y){for(var D=[],O=0;O<E.length;O++){var B=E[O],k=B(N,U,H,G,Y,n);if(k==null)return null;k.data&&r(k.data,"expectedType")&&D.push(k.data.expectedType)}var K=D.length>0?", expected one of type ["+D.join(", ")+"]":"";return new m("Invalid "+G+" `"+Y+"` supplied to "+("`"+H+"`"+K+"."))}return b(L)}function $(){function E(T,P,L,N,U){return Z(T[P])?null:new m("Invalid "+N+" `"+U+"` supplied to "+("`"+L+"`, expected a ReactNode."))}return b(E)}function I(E,T,P,L,N){return new m((E||"React class")+": "+T+" type `"+P+"."+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+N+"`.")}function j(E){function T(P,L,N,U,H){var G=P[L],Y=X(G);if(Y!=="object")return new m("Invalid "+U+" `"+H+"` of type `"+Y+"` "+("supplied to `"+N+"`, expected `object`."));for(var D in E){var O=E[D];if(typeof O!="function")return I(N,U,H,D,F(O));var B=O(G,D,N,U,H+"."+D,n);if(B)return B}return null}return b(T)}function q(E){function T(P,L,N,U,H){var G=P[L],Y=X(G);if(Y!=="object")return new m("Invalid "+U+" `"+H+"` of type `"+Y+"` "+("supplied to `"+N+"`, expected `object`."));var D=t({},P[L],E);for(var O in D){var B=E[O];if(r(E,O)&&typeof B!="function")return I(N,U,H,O,F(B));if(!B)return new m("Invalid "+U+" `"+H+"` key `"+O+"` supplied to `"+N+"`.\nBad object: "+JSON.stringify(P[L],null," ")+`
41
- Valid keys: `+JSON.stringify(Object.keys(E),null," "));var k=B(G,O,N,U,H+"."+O,n);if(k)return k}return null}return b(T)}function Z(E){switch(typeof E){case"number":case"string":case"undefined":return!0;case"boolean":return!E;case"object":if(Array.isArray(E))return E.every(Z);if(E===null||a(E))return!0;var T=d(E);if(T){var P=T.call(E),L;if(T!==E.entries){for(;!(L=P.next()).done;)if(!Z(L.value))return!1}else for(;!(L=P.next()).done;){var N=L.value;if(N&&!Z(N[1]))return!1}}else return!1;return!0;default:return!1}}function W(E,T){return E==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function X(E){var T=typeof E;return Array.isArray(E)?"array":E instanceof RegExp?"object":W(T,E)?"symbol":T}function F(E){if(typeof E>"u"||E===null)return""+E;var T=X(E);if(T==="object"){if(E instanceof Date)return"date";if(E instanceof RegExp)return"regexp"}return T}function re(E){var T=F(E);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function J(E){return!E.constructor||!E.constructor.name?h:E.constructor.name}return g.checkPropTypes=i,g.resetWarningCache=i.resetWarningCache,g.PropTypes=g,g},io}var so,Yl;function $p(){if(Yl)return so;Yl=1;var e=ga();function t(){}function n(){}return n.resetWarningCache=t,so=function(){function r(o,a,l,c,u,d){if(d!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return s.PropTypes=s,s},so}var ql;function xh(){if(ql)return Mi.exports;if(ql=1,process.env.NODE_ENV!=="production"){var e=bh(),t=!0;Mi.exports=Ip()(e.isElement,t)}else Mi.exports=$p()();return Mi.exports}var Pp=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(r,i,s){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:s})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var o in r)n.d(s,o,(function(a){return r[a]}).bind(null,o));return s},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=2)}([function(e,t){e.exports=xh()},function(e,t){e.exports=f},function(e,t,n){n.r(t);var r=n(1),i=n(0),s=function(){return(s=Object.assign||function(p){for(var m,b=1,v=arguments.length;b<v;b++)for(var y in m=arguments[b])Object.prototype.hasOwnProperty.call(m,y)&&(p[y]=m[y]);return p}).apply(this,arguments)},o=function(p,m){var b={};for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&m.indexOf(v)<0&&(b[v]=p[v]);if(p!=null&&typeof Object.getOwnPropertySymbols=="function"){var y=0;for(v=Object.getOwnPropertySymbols(p);y<v.length;y++)m.indexOf(v[y])<0&&Object.prototype.propertyIsEnumerable.call(p,v[y])&&(b[v[y]]=p[v[y]])}return b},a=0,l=r.forwardRef(function(p,m){var b=p.title,v=b===void 0?null:b,y=p.description,S=y===void 0?null:y,w=p.size,x=w===void 0?null:w,C=p.color,A=C===void 0?"currentColor":C,M=p.horizontal,R=M===void 0?null:M,$=p.vertical,I=$===void 0?null:$,j=p.rotate,q=j===void 0?null:j,Z=p.spin,W=Z===void 0?null:Z,X=p.style,F=X===void 0?{}:X,re=p.children,J=o(p,["title","description","size","color","horizontal","vertical","rotate","spin","style","children"]);a++;var E,T=W!==null&&W,P=r.Children.map(re,function(H){var G=H;T!==!0&&(T=(W===null?G.props.spin:W)===!0);var Y=G.props.size;typeof x=="number"&&typeof G.props.size=="number"&&(Y=G.props.size/x);var D={size:Y,color:A===null?G.props.color:A,horizontal:R===null?G.props.horizontal:R,vertical:I===null?G.props.vertical:I,rotate:q===null?G.props.rotate:q,spin:W===null?G.props.spin:W,inStack:!0};return r.cloneElement(G,D)});x!==null&&(F.width=typeof x=="string"?x:1.5*x+"rem");var L,N="stack_labelledby_"+a,U="stack_describedby_"+a;if(v)E=S?N+" "+U:N;else if(L="presentation",S)throw new Error("title attribute required when description is set");return r.createElement("svg",s({ref:m,viewBox:"0 0 24 24",style:F,role:L,"aria-labelledby":E},J),v&&r.createElement("title",{id:N},v),S&&r.createElement("desc",{id:U},S),T&&r.createElement("style",null,"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }","@keyframes spin-inverse { from { transform: rotate(0deg) } to { transform: rotate(-360deg) } }"),P)});l.displayName="Stack",l.propTypes={size:i.oneOfType([i.number,i.string]),color:i.string,horizontal:i.bool,vertical:i.bool,rotate:i.number,spin:i.oneOfType([i.bool,i.number]),children:i.oneOfType([i.arrayOf(i.node),i.node]).isRequired,className:i.string,style:i.object},l.defaultProps={size:null,color:null,horizontal:null,vertical:null,rotate:null,spin:null};var c=l;n.d(t,"Icon",function(){return g}),n.d(t,"Stack",function(){return c});var u=function(){return(u=Object.assign||function(p){for(var m,b=1,v=arguments.length;b<v;b++)for(var y in m=arguments[b])Object.prototype.hasOwnProperty.call(m,y)&&(p[y]=m[y]);return p}).apply(this,arguments)},d=function(p,m){var b={};for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&m.indexOf(v)<0&&(b[v]=p[v]);if(p!=null&&typeof Object.getOwnPropertySymbols=="function"){var y=0;for(v=Object.getOwnPropertySymbols(p);y<v.length;y++)m.indexOf(v[y])<0&&Object.prototype.propertyIsEnumerable.call(p,v[y])&&(b[v[y]]=p[v[y]])}return b},h=0,g=r.forwardRef(function(p,m){var b=p.path,v=p.id,y=v===void 0?++h:v,S=p.title,w=S===void 0?null:S,x=p.description,C=x===void 0?null:x,A=p.size,M=A===void 0?null:A,R=p.color,$=R===void 0?"currentColor":R,I=p.horizontal,j=I!==void 0&&I,q=p.vertical,Z=q!==void 0&&q,W=p.rotate,X=W===void 0?0:W,F=p.spin,re=F!==void 0&&F,J=p.style,E=J===void 0?{}:J,T=p.inStack,P=T!==void 0&&T,L=d(p,["path","id","title","description","size","color","horizontal","vertical","rotate","spin","style","inStack"]),N={},U=[];M!==null&&(P?U.push("scale("+M+")"):(E.width=typeof M=="string"?M:1.5*M+"rem",E.height=E.width)),j&&U.push("scaleX(-1)"),Z&&U.push("scaleY(-1)"),X!==0&&U.push("rotate("+X+"deg)"),$!==null&&(N.fill=$);var H=r.createElement("path",u({d:b,style:N},P?L:{})),G=H;U.length>0&&(E.transform=U.join(" "),E.transformOrigin="center",P&&(G=r.createElement("g",{style:E},H,r.createElement("rect",{width:"24",height:"24",fill:"transparent"}))));var Y,D=G,O=re===!0||typeof re!="number"?2:re,B=!P&&(j||Z);if(O<0&&(B=!B),re&&(D=r.createElement("g",{style:{animation:"spin"+(B?"-inverse":"")+" linear "+Math.abs(O)+"s infinite",transformOrigin:"center"}},G,!(j||Z||X!==0)&&r.createElement("rect",{width:"24",height:"24",fill:"transparent"}))),P)return D;var k,K="icon_labelledby_"+y,ne="icon_describedby_"+y;if(w)Y=C?K+" "+ne:K;else if(k="presentation",C)throw new Error("title attribute required when description is set");return r.createElement("svg",u({ref:m,viewBox:"0 0 24 24",style:E,role:k,"aria-labelledby":Y},L),w&&r.createElement("title",{id:K},w),C&&r.createElement("desc",{id:ne},C),!P&&re&&(B?r.createElement("style",null,"@keyframes spin-inverse { from { transform: rotate(0deg) } to { transform: rotate(-360deg) } }"):r.createElement("style",null,"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }")),D)});g.displayName="Icon",g.propTypes={path:i.string.isRequired,size:i.oneOfType([i.number,i.string]),color:i.string,horizontal:i.bool,vertical:i.bool,rotate:i.number,spin:i.oneOfType([i.bool,i.number]),style:i.object,inStack:i.bool,className:i.string},g.defaultProps={size:null,color:"currentColor",horizontal:!1,vertical:!1,rotate:0,spin:!1},t.default=g}]);const ft=mh(Pp);var Lp="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",jp="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",Xl="M22,21H2V3H4V19H6V10H10V19H12V6H16V19H18V14H22V21Z",Fp="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",yh="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",wh="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",_h="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",Np="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z",Hp="M20 6.91L17.09 4L12 9.09L6.91 4L4 6.91L9.09 12L4 17.09L6.91 20L12 14.91L17.09 20L20 17.09L14.91 12L20 6.91Z",Bp="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22H9M11,6V9H8V11H11V14H13V11H16V9H13V6H11Z",zp="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",Sh="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",Vp="M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z",Wp="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z",Up="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z",Gp="M23 16V15.5A2.5 2.5 0 0 0 18 15.5V16A1 1 0 0 0 17 17V21A1 1 0 0 0 18 22H23A1 1 0 0 0 24 21V17A1 1 0 0 0 23 16M22 16H19V15.5A1.5 1.5 0 0 1 22 15.5M7 8.9H11V7H7A5 5 0 0 0 7 17H11V15.1H7A3.1 3.1 0 0 1 7 8.9M8 11V13H16V11M13 15.1V17H15V15.1M17 7H13V8.9H17A3.09 3.09 0 0 1 19.94 11A5.12 5.12 0 0 1 20.5 11H21.9A5 5 0 0 0 17 7Z",Yp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",qp="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",Xp="M18 21L14 17H17V7H14L18 3L22 7H19V17H22M2 19V17H12V19M2 13V11H9V13M2 7V5H6V7H2Z",Kp="M4,3H20A2,2 0 0,1 22,5V20A2,2 0 0,1 20,22H4A2,2 0 0,1 2,20V5A2,2 0 0,1 4,3M4,7V10H8V7H4M10,7V10H14V7H10M20,10V7H16V10H20M4,12V15H8V12H4M4,20H8V17H4V20M10,12V15H14V12H10M10,20H14V17H10V20M20,20V17H16V20H20M20,12H16V15H20V12Z",Kl="M12.35 20H10V17H12.09C12.21 16.28 12.46 15.61 12.81 15H10V12H14V13.54C14.58 13 15.25 12.61 16 12.35V12H20V12.35C20.75 12.61 21.42 13 22 13.54V5C22 3.9 21.1 3 20 3H4C2.9 3 2 3.9 2 5V20C2 21.1 2.9 22 4 22H13.54C13 21.42 12.61 20.75 12.35 20M16 7H20V10H16V7M10 7H14V10H10V7M8 20H4V17H8V20M8 15H4V12H8V15M8 10H4V7H8V10M17 14H19V17H22V19H19V22H17V19H14V17H17V14",Zp="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z",Jp="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z";function Qp(e,t){f.useEffect(()=>{function n(r){Array.isArray(e)?e.every(s=>{var o;return!((o=s.current)!=null&&o.contains(r.target))})&&r.target&&t():e.current&&r.target&&!e.current.contains(r.target)&&t()}return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[e,t])}var Lt=(e=>(e.STRING="string",e.NUMBER="number",e))(Lt||{});function st(e){const t=f.useMemo(()=>e.iconSize?e.iconSize:e.small?.8:1,[e.iconSize,e.small]),n=_.jsxs("button",{type:e.type??"button",id:e.id,className:`btn ${e.className??""} ${e.ghost?" btn-ghost":""} ${e.small?"btn-xs":"btn-sm"} content-center ${e.circle?"btn-circle":""}`,onClick:e.onClick,disabled:e.disabled===!0,children:[e.icon&&_.jsx(ft,{path:e.icon??"",color:e.disabled?e.iconColorDisabled??"lightgrey":e.iconColor,size:t}),e.text&&_.jsx("div",{className:`text-${e.small?"xs":"sm"}`,children:e.text})]});return _.jsx(_.Fragment,{children:e.tooltip?_.jsx("div",{className:`tooltip ${e.tooltipRight?"tooltip-right":"tooltip-top"} tooltip-top before:whitespace-pre-wrap text-left`,"data-tip":`${e.tooltip}`,children:n}):n})}const Zl=e=>{let t;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(r,i,a);return a},em=e=>e?Zl(e):Zl,tm=e=>e;function nm(e,t=tm){const n=f.useSyncExternalStore(e.subscribe,f.useCallback(()=>t(e.getState()),[e,t]),f.useCallback(()=>t(e.getInitialState()),[e,t]));return f.useDebugValue(n),n}const Jl=e=>{const t=em(e),n=r=>nm(t,r);return Object.assign(n,t),n},rn=e=>e?Jl(e):Jl,rm=e=>e.every(t=>typeof t=="number"),Ch=(e,t)=>e<t?-1:e>t?1:0,im=(e,t)=>e>t?-1:e<t?1:0,Eh=" ",sm=(e,t)=>{const n=JSON.parse(JSON.stringify(e));return e.length===0?[]:t.length===0?n:n.filter(r=>{for(const i of t){let s=r[i.headerId],o=!1;if(rm(i.itemsToHide)?(s=typeof s=="string"?s.split(Eh).join(""):s,o=i.itemsToHide.includes(Number(s))):i.itemsToHide.includes(s)&&(o=!0),o)return!1}return!0})},om=(e,t,n,r)=>{const i=[...e];if(!r)return i;const s=t.find(a=>a.id===r);if(s!=null&&s.customSort)return i.sort((a,l)=>s.customSort(a,l,n==="asc")),i;let o=!0;return i.forEach(a=>{var d;const l=(d=a[r])==null?void 0:d.toString();if(!l)return;const c=oo(l),u=["NaN"];isNaN(c)&&!u.includes(l)&&(o=!1)}),o?(i.sort((a,l)=>{const c=oo(a[r]),u=oo(l[r]),d=typeof c=="number"&&!isNaN(c),h=typeof u=="number"&&!isNaN(u);return d&&!h?-1:!d&&h?1:n==="desc"?u-c:c-u}),i):(n==="desc"?i.sort((a,l)=>Ch(l[r],a[r])):i.sort((a,l)=>im(l[r],a[r])),i)},oo=e=>typeof e=="number"?e:typeof e=="string"?Number(e.split(Eh).join("")):e,Pe=rn((e,t)=>({items:[],headers:[],hiddenHeadersId:[],processedHeaders:[],leafHeaders:[],processedLeafHeaders:[],processedItems:[],activeFilters:[],filterItemsCache:{},ascendingOrder:!0,comments:[],highlightConditions:[],advancedSetting:void 0,groupBy:void 0,linkedGroups:void 0,collapsedGroups:[],actions:{setItems:n=>{e({items:n})},setHeaders:n=>{const r=No(n);e({headers:n,leafHeaders:r})},setHiddenHeadersId:n=>{e({hiddenHeadersId:n})},setActiveFilter:(n,r,i)=>{const{activeFilters:s}=t(),o=[...s],a=o.findIndex(l=>l.headerId===n);a!==-1?r.length>0?o[a]={headerId:n,itemsToHide:r,numberConditions:i}:o.splice(a,1):r.length>0&&o.push({headerId:n,itemsToHide:r,numberConditions:i}),e({activeFilters:o})},clearActiveFilters:()=>{e({activeFilters:[]})},onResetSort:()=>{e({currentSortId:void 0,ascendingOrder:!0})},onSortByColumn:n=>{const{currentSortId:r,ascendingOrder:i}=t();if(!(n!=null&&n.sortable))return;let s;r===n.id?s=!i:s=!0,e({currentSortId:n.id,ascendingOrder:s})},processItems:()=>{const{items:n,activeFilters:r,headers:i,currentSortId:s,ascendingOrder:o}=t();let a=[...n];r.length>0&&(a=am(a,r)),s&&(a=lm(a,i,o,s)),e({processedItems:a})},processHeaders:()=>{const{headers:n,hiddenHeadersId:r}=t(),i=new Map,s=(u,d)=>{for(const h of u)d&&i.set(h.id,d),h.children&&h.children.length>0&&s(h.children,h.id)};s(n);const o=u=>{if(r.includes(u))return!0;let d=u;for(;i.has(d);)if(d=i.get(d),r.includes(d))return!0;return!1},a=u=>u.filter(d=>!o(d.id)).map(d=>d.children&&d.children.length>0?{...d,children:a(d.children)}:d),l=a(n),c=No(l);e({processedHeaders:l,processedLeafHeaders:c})},processFilterItemsCache:()=>{const{processedItems:n,activeFilters:r,leafHeaders:i}=t(),s={};i.forEach(o=>{let a=n.map(c=>c[o.id]);const l=r.find(c=>c.headerId===o.id);l&&(a=a.concat(l.itemsToHide)),s[o.id]=[...new Set(a)].filter(c=>typeof c=="string"||typeof c=="number")}),e({filterItemsCache:s})},setGroupBy:n=>{e({groupBy:n})},setLinkedGroups:n=>{e({linkedGroups:n})},collapseGroup:n=>{const{collapsedGroups:r}=t(),s=r.includes(n)?r.filter(o=>o!==n):[...r,n];e({collapsedGroups:s})},setCollapsedGroups:n=>{e({collapsedGroups:n})},setComments:n=>{e({comments:n})},setHighlightConditions:n=>{e({highlightConditions:n})},setAdvancedSettings:n=>{e({advancedSetting:n})}}}));function No(e){return e.flatMap(t=>t.children&&t.children.length>0?No(t.children):[t])}function am(e,t){return sm(e,t)}function lm(e,t,n,r){return om(e,t,n?"asc":"desc",r)}const Ah=()=>Pe(e=>e.headers),Mh=()=>Pe(e=>e.hiddenHeadersId),cm=()=>Pe(e=>e.processedHeaders),ui=()=>Pe(e=>e.processedLeafHeaders),Oh=()=>Pe(e=>e.items),Th=()=>Pe(e=>e.filterItemsCache),di=()=>Pe(e=>e.processedItems),Rh=()=>Pe(e=>e.currentSortId),pa=()=>Pe(e=>e.ascendingOrder),hi=()=>Pe(e=>e.activeFilters),xn=()=>Pe(e=>e.advancedSetting),Dh=()=>Pe(e=>e.comments),kh=()=>Pe(e=>e.highlightConditions),As=()=>Pe(e=>e.groupBy),um=()=>Pe(e=>e.linkedGroups),Ih=()=>Pe(e=>e.collapsedGroups),yn=()=>Pe(e=>e.actions);function dm(e){const{setActiveFilter:t}=yn(),n=hi(),r=f.useMemo(()=>n.find(p=>p.headerId===e.headerId),[n,e.headerId]),[i,s]=f.useState(""),[o,a]=f.useState([]);f.useEffect(()=>{a((r==null?void 0:r.itemsToHide)??[])},[r==null?void 0:r.itemsToHide]);const l=f.useMemo(()=>{let p=[];return i?(p=[...e.items].filter(m=>m==null?void 0:m.toString().toLocaleLowerCase().includes(i==null?void 0:i.toString().toLocaleLowerCase())),e.filterType===Lt.STRING&&(p=p.sort(Ch))):p=[...e.items],p},[i,e.items]),c=p=>{p.preventDefault(),i&&t(e.headerId,[i])},u=()=>{a([...e.items])},d=()=>{a([])},h=p=>{const m=o.findIndex(v=>v===p);let b=[...o];m!==void 0&&(m===-1?b=[...b,p]:b.splice(m,1),a(b))},g=()=>{const p=l.filter(b=>!o.includes(b)),m=[...e.items].filter(b=>!p.includes(b));t(e.headerId,m.map(b=>b))};return _.jsxs("div",{children:[_.jsx("div",{className:"font-semibold text-sm mb-1",children:"Filter by value:"}),_.jsxs("form",{onSubmit:c,children:[_.jsx("input",{type:"text",value:i,onChange:p=>s(p==null?void 0:p.target.value),placeholder:"Search...",className:"input input-bordered input-xs w-full max-w-xs"}),_.jsx("input",{type:"submit",value:""})]}),_.jsxs("div",{className:"flex text-xs mt-1 font-semibold text-primary",children:[_.jsx("button",{onClick:d,onFocus:()=>{},className:"mr-4 cursor-pointer hover:border-none! border-none! focus:outline-hidden! bg-transparent btn-sm",children:"Select All"}),_.jsx("button",{onClick:u,onFocus:()=>{},className:"cursor-pointer hover:border-none! border-none! focus:outline-hidden! bg-transparent btn-sm",children:"Clear"})]}),_.jsx("div",{className:"overflow-auto max-h-44 mt-2",style:{scrollbarWidth:"thin"},children:l.map((p,m)=>_.jsxs("div",{className:"flex mt-2",children:[_.jsx("input",{type:"checkbox",onClick:()=>h(p),readOnly:!0,checked:!o.includes(p),className:"mr-2 "}),_.jsx("p",{className:"text-xs",children:(p==null?void 0:p.toString())||_.jsx("span",{className:"italic",children:"(Blanks)"})})]},`filter-item-${p}-${m}`))}),_.jsxs("div",{className:"flex float-end mt-2",children:[_.jsx(st,{onClick:()=>{g(),e.onShowOrHide(!1)},text:"OK",iconColor:"#6161bb",small:!0}),_.jsx(st,{className:"ml-1",onClick:()=>e.onShowOrHide(!1),text:"Cancel",iconColor:"#6161bb",small:!0})]})]})}function Ql(e){const[t,n]=f.useState(e.numberCondition.value1),[r,i]=f.useState(e.numberCondition.value2??0),s=f.useCallback((a,l)=>{e.updateCondition({id:e.numberCondition.id,operator:e.numberCondition.operator,value1:a==="value1"?l:e.numberCondition.value1,value2:a==="value2"?l:e.numberCondition.value2})},[e.numberCondition.id,e.numberCondition.operator]),o=(a,l)=>{a==null||a.preventDefault(),a==null||a.stopPropagation(),e.deleteCondition&&e.deleteCondition(l)};return _.jsxs("div",{className:"flex items-center gap-1 group",children:[_.jsxs("select",{value:e.numberCondition.operator,onChange:a=>e.updateCondition({id:e.numberCondition.id,operator:a.target.value,value1:e.numberCondition.value1,value2:e.numberCondition.value2}),className:" select select-xs px-1 grow",children:[_.jsx("option",{value:"=",children:"Equal"}),_.jsx("option",{value:">",children:"Greater than"}),_.jsx("option",{value:"<",children:"Less than"}),_.jsx("option",{value:">=",children:">="}),_.jsx("option",{value:"<=",children:"<="}),_.jsx("option",{value:"between",children:"Between"})]}),_.jsx("input",{type:"number",value:t,onChange:a=>{n(parseFloat(a.target.value)||0),e.immediatApply&&s("value1",parseFloat(a.target.value)||0)},onBlur:a=>s("value1",parseFloat(a.target.value)||0),className:"input input-xs w-12",step:"any"}),e.numberCondition.operator==="between"&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"text-xs font-semibold",children:"-"}),_.jsx("input",{type:"number",value:r,onChange:a=>{i(parseFloat(a.target.value)),e.immediatApply&&s("value2",parseFloat(a.target.value))},onBlur:a=>s("value2",parseFloat(a.target.value)),className:"input input-xs w-12",step:"any"})]}),e.isNew?_.jsx(_.Fragment,{}):_.jsx("button",{onClick:a=>o(a,e.numberCondition),className:"rounded bg-gray-200 p-0.5 cursor-pointer hover:bg-gray-300",children:_.jsx(ft,{path:zp,color:"#d11f1f",size:.7})})]},e.numberCondition.id)}function hm(e){var p,m;const{setActiveFilter:t}=yn(),n=hi(),r=f.useMemo(()=>n.find(b=>b.headerId===e.headerId),[n,e.headerId]),[i,s]=f.useState([]);f.useEffect(()=>{r!=null&&r.numberConditions&&s(r==null?void 0:r.numberConditions)},[r]),f.useEffect(()=>{c()},[i]);const[o,a]=f.useState({id:Date.now().toString()+Math.random().toString(36).substring(2),operator:"=",value1:0}),l=f.useMemo(()=>e.items.map(b=>typeof b=="string"?parseFloat(b):b).filter(b=>!isNaN(b)),[e.items]),c=f.useCallback(()=>{const b=e.items.filter((v,y)=>{const S=l[y];return typeof S!="number"?!0:i.some(w=>{switch(w.operator){case"=":return S!==w.value1;case">":return S<=w.value1;case"<":return S>=w.value1;case">=":return S<w.value1;case"<=":return S>w.value1;case"between":return w.value2===void 0?!0:S<w.value1||S>w.value2}})});e.items.length>0&&e.items[0],t(e.headerId,b,i)},[e.items,e.headerId,i,l,t]),u=b=>{b==null||b.preventDefault(),b==null||b.stopPropagation(),s(v=>[...v,o]),a({id:Date.now().toString(),operator:"=",value1:0})},d=(b,v)=>{s(y=>y.map(S=>S.id===b?{...S,...v}:S))},h=b=>{const v=i.filter(y=>y.id!==b);s(v)},g=()=>{s([]),t(e.headerId,[],[])};return _.jsxs("form",{onSubmit:u,className:"space-y-4",children:[_.jsxs("div",{className:"bg-blue-50/70 p-2 rounded-md",children:[_.jsx(Ql,{numberCondition:o,updateCondition:b=>a(b),isNew:!0,immediatApply:!0}),_.jsx("div",{className:"flex items-center gap-2 mt-2",children:_.jsx(st,{text:"Add Condition",type:"button",onClick:u,small:!0,className:"rounded-lg p-2 py-0",icon:qp,iconColor:"var(--comment-color)",iconSize:.7})})]}),_.jsx("div",{className:"mt-4",children:(p=r==null?void 0:r.numberConditions)==null?void 0:p.map((b,v)=>_.jsx("div",{className:"mb-1",children:_.jsx(Ql,{numberCondition:b,updateCondition:y=>d(y.id,y),deleteCondition:()=>h(b.id),isNew:!1})},"condition-"+v))}),_.jsx("div",{className:"flex justify-end gap-2 mt-8",children:_.jsx(st,{text:"Clear filter",disabled:!(r!=null&&r.numberConditions)||((m=r==null?void 0:r.numberConditions)==null?void 0:m.length)===0,onClick:g,small:!0})})]})}function fm(e){const[t,n]=f.useState(!1),r=f.useRef(null);f.useEffect(()=>{var c,u;if(e.show&&r.current){const d=r.current.getBoundingClientRect(),h=(u=(c=e.tableRef)==null?void 0:c.current)==null?void 0:u.getBoundingClientRect(),g=(h==null?void 0:h.width)??0,p=d.width+d.x>g;n(p)}else n(!1)},[e.show]),Qp([e.wrapperRef,r],()=>{e.show&&e.onShowOrHide(!1)});const[i,s]=f.useState();f.useEffect(()=>{if(e.show&&e.filterButtonRef.current){const c=e.filterButtonRef.current.getBoundingClientRect();s({top:c.bottom+window.scrollY,left:c.left+window.scrollX})}},[e.show]);const a=(c=>{switch(c){case Lt.NUMBER:return hm;case Lt.STRING:default:return dm}})(e.filterType),l=e.show&&i?hn.createPortal(_.jsx("div",{ref:r,className:`fixed mt-1 bg-white shadow p-3 w-60 z-300 rounded-md font-normal border border-gray-300 ${t?"right-0":""}`,style:{top:`${i.top}px`,left:`${i.left}px`},children:_.jsx(a,{headerId:e.headerId,filterType:e.filterType,items:e.items,onShowOrHide:e.onShowOrHide})}),document.body):null;return _.jsx("div",{children:e.show?l:""})}function gm(e){const t=f.useRef(null),n=f.useRef(null);return _.jsxs("div",{ref:t,className:"relative",children:[_.jsx("button",{ref:n,onClick:()=>e.onShowOrHide(!e.show),className:`border-solid border hover:!border-primary cursor-pointer border-gray-300 rounded focus:outline-hidden! ${e.currentFilter?"bg-purple-800":"bg-white"} `,children:_.jsx(ft,{path:Vp,color:e.currentFilter?"white":"grey",size:.6})}),_.jsx(fm,{...e,filterButtonRef:n,wrapperRef:t})]})}const $h=rn(e=>({contextMenu:void 0,actions:{setContextMenu:t=>e({contextMenu:t})}})),pm=()=>$h(e=>e.contextMenu),ma=()=>$h(e=>e.actions),Ir={LIST:"list",NUMBER:"number"},Le=rn(e=>({selectedHeaderIds:[],selectedCell:void 0,expandedSelection:[],actions:{setSelectedHeaderIds:t=>e({selectedHeaderIds:t}),setSelectedCell:t=>e({selectedCell:t}),setExpandedSelection:t=>e({expandedSelection:t}),clearSelection:()=>e({selectedCell:void 0,expandedSelection:[]})}})),Ph=()=>Le(e=>e.selectedHeaderIds),Ms=()=>Le(e=>e.expandedSelection),Lh=()=>Le(e=>e.actions),Jt=(e,t,n)=>`cell-${e}-${t}${n?`-fromArray-${n.index}`:""}`,mm=(e,t,n,r,i,s,o)=>{e.stopPropagation();let a=t,l=[...n];if(e.key==="Tab"){let c=(t==null?void 0:t.rowIndex)??0,u=(t==null?void 0:t.columnIndex)??0;if(n.length>1){const d=[...n].sort((m,b)=>m.rowIndex!==b.rowIndex?m.rowIndex-b.rowIndex:m.columnIndex-b.columnIndex),h=d.findIndex(m=>{var b,v;return m.rowIndex===(t==null?void 0:t.rowIndex)&&m.columnIndex===(t==null?void 0:t.columnIndex)&&((b=m.fromArrayData)==null?void 0:b.index)===((v=t==null?void 0:t.fromArrayData)==null?void 0:v.index)});let g;e.shiftKey?(g=h-1,g<0&&(g=d.length-1)):(g=h+1,g>=d.length&&(g=0)),a=d[g]}else{const d=bm(e,s,t,o);if(d)return{newSelectedCell:d,newExpandedSelection:[]};u=((t==null?void 0:t.columnIndex)??0)+(e.shiftKey?-1:1),u>=r?(u=0,c++):u<0&&(u=r-1,c--),c>=i&&(c=0),c<0&&(c=i-1),l=[],a={rowIndex:c,columnIndex:u}}}return{newSelectedCell:a,newExpandedSelection:l}},bm=(e,t,n,r)=>{const i=n==null?void 0:n.fromArrayData;if(!i||!r)return;const s=r[i.fromArray];if(!((s==null?void 0:s.length)??0))return;let a=document.getElementById(Jt(n.rowIndex,n.columnIndex+(e.shiftKey?-1:1),{index:i.index}));if(a)return{rowIndex:n.rowIndex,columnIndex:n.columnIndex+(e.shiftKey?-1:1),fromArrayData:{fromArray:n.fromArrayData.fromArray,index:i.index}};if(r&&r[n.fromArrayData.fromArray].length>0){const l=t.findIndex(u=>u.fromArray===n.fromArrayData.fromArray);let c;if(t.forEach(u=>{u.fromArray===n.fromArrayData.fromArray&&(c=t.indexOf(u))}),e.shiftKey){if(a=document.getElementById(Jt(n.rowIndex,c,{index:n.fromArrayData.index-1})),a)return{rowIndex:n.rowIndex,columnIndex:c,fromArrayData:{fromArray:n.fromArrayData.fromArray,index:n.fromArrayData.index-1}}}else if(a=document.getElementById(Jt(n.rowIndex,l,{index:n.fromArrayData.index+1})),a)return{rowIndex:n.rowIndex,columnIndex:l,fromArrayData:{fromArray:n.fromArrayData.fromArray,index:n.fromArrayData.index+1}}}},$n=rn(e=>({dragStartCell:void 0,isDragging:!1,actions:{setDragStartCell:t=>e({dragStartCell:t}),setIsDragging:t=>e({isDragging:t})}})),vm=()=>$n(e=>e.isDragging),xm=(e,t,n,r,i)=>{const s=t.filter(a=>{var l,c;return e.rowIndex===a.rowIndex&&((l=e.fromArrayData)==null?void 0:l.index)===((c=a.fromArrayData)==null?void 0:c.index)});return s.length>0?s.map(a=>{const l=n[a.columnIndex];let c;return a.fromArrayData?c=r[l.fromArray][a.fromArrayData.index][l.id]:c=r[l.id],{value:c,headerId:l.id}}):[{value:i,headerId:n[e.columnIndex].id}]},ym=(e,t)=>e.map(n=>t[n.columnIndex]),wm=(e,t,n,r)=>{var s,o,a,l,c;const i=r.find(u=>u.id===t);return!(!i||((s=i.editOptions)==null?void 0:s.type)!==((o=n.editOptions)==null?void 0:o.type)||((a=n.editOptions)==null?void 0:a.type)==="list"&&!((c=(l=n.editOptions)==null?void 0:l.options)==null?void 0:c.includes(e)))},_m=(e,t)=>{const n=e.getBoundingClientRect(),r=Math.max(0,Math.min(t.right,n.right)-Math.max(t.left,n.left)),i=Math.max(0,Math.min(t.bottom,n.bottom)-Math.max(t.top,n.top)),s=n.width*n.height;return r*i>=s*.3},ba=rn(e=>({clipboardData:[],actions:{setClipboardData:t=>e(()=>({clipboardData:t}))}})),Sm=()=>ba(e=>e.clipboardData),Cm=()=>ba(e=>e.actions),ao=(e,t)=>{var n,r;return e.rowIndex===(t==null?void 0:t.rowIndex)&&e.columnIndex===(t==null?void 0:t.columnIndex)&&((n=e.fromArrayData)==null?void 0:n.index)===((r=t==null?void 0:t.fromArrayData)==null?void 0:r.index)},ec=e=>{var t;return`${e.rowIndex}:${e.columnIndex}:${((t=e.fromArrayData)==null?void 0:t.index)??""}`},Em=(e,t)=>{const n=new Set(e.map(ec)),r=[...e];for(const i of t){const s=ec(i);n.has(s)||(n.add(s),r.push(i))}return r};function Am({items:e,groupedItemsEntries:t,onChange:n,onBulkChange:r,onBulkFieldChange:i,onRowDoubleClick:s,onSaveComment:o,onDeleteComment:a,onSetHighlightCondition:l,onRemoveHighlightCondition:c,onAddListOption:u}){const d=Ms(),{setSelectedCell:h,setExpandedSelection:g,setSelectedHeaderIds:p}=Lh(),m=Ph(),b=ui(),v=Ah(),{setDragStartCell:y,setIsDragging:S}=$n(D=>D.actions),w=f.useCallback(D=>{if(D)if(t){const O=t.flatMap(([B,k])=>k.filter(K=>K.rowIndex===D.rowIndex))[0];if(O)return O.item}else return e[D.rowIndex]},[t,e]),x=f.useCallback(D=>{const O=[];return D.forEach(B=>{const k=w(B);k&&O.push(k)}),O},[w]),C=f.useCallback((D,O,B,k)=>{const K=e.findIndex(ie=>ie===O);let ne;if(k){const ie=O[B.fromArray];ie[k.index]={...ie[k.index],[B.id]:D},ne={...O,[B.fromArray]:ie}}else ne={...O,[B.id]:D};return{itemUpdated:ne,originalIndex:K}},[e]),A=f.useCallback(async(D,O,B,k)=>{var ie;const{itemUpdated:K,originalIndex:ne}=C(D,O,B,k.fromArrayData);if(n){const he=(ie=k.fromArrayData)==null?void 0:ie.index;(he===void 0?O[B.id]!==D:O[B.fromArray][he]!==D)&&await n(K,ne,he?{fromArrayIndex:he,headerId:B.id}:void 0)}},[n,C]),M=f.useCallback((D,O)=>{O.preventDefault();const k=Le.getState().expandedSelection.some(K=>{var ne,ie,he,oe;return K.rowIndex===D.rowIndex&&K.columnIndex===D.columnIndex&&((ne=K.fromArrayData)==null?void 0:ne.index)===((ie=D.fromArrayData)==null?void 0:ie.index)&&((he=K.fromArrayData)==null?void 0:he.fromArray)===((oe=D.fromArrayData)==null?void 0:oe.fromArray)});h(D),k||g([])},[]),R=f.useCallback(async(D,O,B,k)=>{var he;const K=Le.getState().selectedCell,ne=Le.getState().expandedSelection;let ie=[...ne];if(K&&!ne.some(oe=>oe.rowIndex===K.rowIndex&&oe.columnIndex===K.columnIndex)&&(ie=[...ne,K]),(ne==null?void 0:ne.length)>1){const oe=ie.map(ye=>{const ce=w(ye);return ce?{itemUpdated:{...ce,[B.id]:D},originalIndex:e.findIndex(we=>we===ce)}:null}).filter(Boolean);r&&oe.length>0&&await r(oe,B.id)}else{const{itemUpdated:oe,originalIndex:ye}=C(D,O,B,k.fromArrayData);if(n){const ce=(he=k.fromArrayData)==null?void 0:he.index;(ce===void 0?O[B.id]!==D:O[B.fromArray][ce]!==D)&&(console.log("onCellEnter calling onChange",ce),await n(oe,ye,ce!==void 0?{fromArrayIndex:ce,headerId:B.id}:void 0))}}},[w,e,i,n,C]),$=f.useCallback(D=>{var B,k;const O=Le.getState().selectedCell;((O==null?void 0:O.rowIndex)!==D.rowIndex||(O==null?void 0:O.columnIndex)!==D.columnIndex||((B=O==null?void 0:O.fromArrayData)==null?void 0:B.index)!==((k=D.fromArrayData)==null?void 0:k.index))&&(h(D),g([]),p([]))},[]),I=f.useCallback((D,O)=>{m.includes(O)||j(D,O)},[m]),j=f.useCallback((D,O)=>{console.log("Header clicked:",O);const B=[];if(e.forEach((K,ne)=>{const ie=b.findIndex(he=>he.id===O);ie>=0&&B.push({rowIndex:ne,columnIndex:ie})}),D.ctrlKey||D.metaKey){console.log("Ctrl or Cmd pressed, adding to selection");const K=[...m];K.includes(O)||K.push(O),console.log("New selected header ids:",K),p(K);const ne=Em(d,B);g(ne)}else p([O]),h(void 0),g(B)},[e,d,b,m]),q=f.useCallback(D=>{const O=Le.getState().selectedCell,B=Le.getState().expandedSelection,k=O?{...O}:void 0,K=O?w(O):void 0,{newSelectedCell:ne,newExpandedSelection:ie}=mm(D,O,B,b.length,e.length,b,K);k&&ao(k,ne)||(h(ne),g(ie),p([]),Z(ne))},[v.length,e.length,e]),Z=D=>{if(D){const O=document.getElementById(Jt(D.rowIndex,D.columnIndex,D.fromArrayData));O&&O.focus()}},W=f.useCallback(async D=>{s&&await s(D)},[s]),X=f.useRef(!1),F=f.useCallback((D,O)=>{const B=Le.getState().selectedCell;if(D.ctrlKey||D.metaKey)if(!B)h(O),g([O]);else{const K=[...Le.getState().expandedSelection];K.findIndex(ne=>ao(ne,O))===-1&&K.push(O),g(K),h(O)}else ao(O,B)||(h(O),p([]),g([O]));X.current=!0,y(O)},[]),re=f.useCallback((D,O)=>{D.stopPropagation();const B=$n.getState().dragStartCell;if(!$n.getState().isDragging||!B)return;const K=[],ne=document.getElementById(Jt(B.rowIndex,B.columnIndex,B.fromArrayData)),ie=D.currentTarget;if(!ne||!ie)return;const he=ne.getBoundingClientRect(),oe=ie.getBoundingClientRect(),ye=Math.min(he.left,oe.left),ce=Math.min(he.top,oe.top),we=Math.max(he.right,oe.right),_e=Math.max(he.bottom,oe.bottom),We=ie.closest("table");if(!We)return;const Tt=We.getElementsByTagName("td"),Bt=new Set;Array.from(Tt).forEach(vt=>{if(_m(vt,{left:ye,right:we,top:ce,bottom:_e})){const z=parseInt(vt.getAttribute("data-row-index")||"-1"),te=parseInt(vt.getAttribute("data-col-index")||"-1"),le=vt.getAttribute("data-from-array"),fe=vt.getAttribute("data-array-index");if(z>=0&&te>=0){const De=le&&fe!==null?`${z}-${te}-${le}-${fe}`:`${z}-${te}`;if(Bt.has(De))return;Bt.add(De);const Fe={rowIndex:z,columnIndex:te};le&&fe!==null&&(Fe.fromArrayData={fromArray:le,index:parseInt(fe)}),K.push(Fe)}}}),g(K)},[e,b]),J=f.useCallback(D=>{D.preventDefault();const O=Le.getState().selectedCell,B=$n.getState().dragStartCell,k=$n.getState().isDragging;X.current&&!k&&S(!0),k&&B!==O&&(h(B),p([]))},[]),E=f.useCallback(()=>{X.current=!1,S(!1)},[]),T=f.useCallback(async()=>{var ye;const D=ba.getState().clipboardData,O=Le.getState().selectedCell,B=Le.getState().expandedSelection,k=Pe.getState().processedLeafHeaders;if(!n||!O||D.length===0)return;const K=w(O);if(!K)return;const ne=e.findIndex(ce=>ce===K),ie=(ye=O.fromArrayData)==null?void 0:ye.index,he=k[O.columnIndex],oe={...K};if(D.length===1){const{value:ce,headerId:we}=D[0],_e=k[O.columnIndex];wm(ce,we,_e,k)&&(L(oe,_e,ce,ie?{index:ie}:void 0),await n(oe,ne,ie!==void 0?{fromArrayIndex:ie,headerId:_e.id}:void 0))}else{const ce=ym(B,k);let we=!1;D.forEach(_e=>{const We=ce.find(Tt=>Tt.id===_e.headerId);We&&(L(oe,We,_e.value,ie?{index:ie}:void 0),we=!0)}),we&&await n(oe,ne,ie!==void 0?{fromArrayIndex:ie,headerId:he.id}:void 0)}},[e]),P=f.useCallback(async()=>{var ie,he;const D=Le.getState().selectedCell,O=Le.getState().expandedSelection,B=Pe.getState().processedLeafHeaders,k=void 0;if(!n||!D)return;if(O.length===0){const oe=w(D);if(!oe)return;const ye={...oe},ce=B[D.columnIndex];L(ye,ce,k,D.fromArrayData?{index:(ie=D.fromArrayData)==null?void 0:ie.index,headerId:ce.id}:void 0),await n(ye,e.findIndex(we=>we===oe),D.fromArrayData?{fromArrayIndex:(he=D.fromArrayData)==null?void 0:he.index,headerId:ce.id}:void 0);return}const K=new Map;console.log("expandedSelection",O),O.forEach(oe=>{const ye=w(oe);if(!ye)return;const ce=B[oe.columnIndex],we=e.findIndex(_e=>_e===ye);K.has(ye)||K.set(ye,{headers:new Set,itemIndex:we}),oe.fromArrayData?(K.get(ye).fromArray||(K.get(ye).fromArray=[]),K.get(ye).fromArray.push({index:oe.fromArrayData.index,headerId:ce.id})):K.get(ye).headers.add(ce)});const ne=[];K.forEach((oe,ye)=>{var we;const ce={...ye};oe.headers.forEach(_e=>{L(ce,_e,k)}),(we=oe.fromArray)==null||we.forEach(_e=>{L(ce,B.find(We=>We.id===_e.headerId),k,{index:_e.index,headerId:_e.headerId})}),ne.push({itemUpdated:ce,originalIndex:oe.itemIndex,fromArrayItemsAffected:oe.fromArray?oe.fromArray.map(_e=>({fromArrayIndex:_e.index,headerId:_e.headerId})):[]})}),await(r==null?void 0:r(ne))},[e]),L=(D,O,B,k)=>{k!==void 0?k.headerId?D[O.fromArray][k.index][k.headerId]=B:D[O.fromArray][k.index]=B:D[O.id]=B},N=f.useCallback(async(D,O)=>{a&&await a(D,O)},[o,e]),U=f.useCallback(async(D,O)=>{o&&await o(D,O)},[o,e]);return f.useEffect(()=>(window.addEventListener("mouseup",E),()=>{window.removeEventListener("mouseup",E)}),[E]),{setExpandedSelection:g,onHeaderClick:j,onHeaderRightClick:I,onCellBlur:A,onCellEnter:R,onCellClick:$,handleCellKeyDown:q,handleRowDoubleClick:W,resetDefaultValueForSelectedCells:P,saveCommentHandler:U,deleteCommentHandler:N,setHighlightCondition:async(D,O,B)=>{const k={propertyId:O,value:D[O],columnId:O,style:B};await(l==null?void 0:l(k,D))},removeHighlightCondition:(D,O,B)=>{const k={propertyId:O,value:D[O],columnId:O,style:{}};c==null||c(k,B,D)},onCellMouseDown:F,onCellMouseEnter:re,onMouseMove:J,pasteClipboardData:T,onRightClick:M,addListOption:async(D,O)=>{u&&await u(D,O)},getItemFromCellCoordinates:w,getItemsFromCellCoordinates:x}}const Mm=({items:e,onRowsReordered:t,groupBy:n})=>{const[r,i]=f.useState(null),[s,o]=f.useState(null),[a,l]=f.useState(null),[c,u]=f.useState(!1),d=f.useCallback(()=>{console.log(e),i(null),l(null),u(!1),o(null)},[]),h=f.useCallback((m,b)=>{i(m),u(!0),o(b)},[]),g=f.useCallback(m=>{if(r!==null&&a!==null&&r!==a){if(n&&m[n]!==(s==null?void 0:s[n])){console.warn("Cannot reorder items across different groups");return}t==null||t(r,a,s,m)}i(null),l(null),u(!1),o(null)},[r,a,t]),p=f.useCallback(m=>{r!==null&&r!==m&&l(m)},[r]);return{draggedRowIndex:r,dropTargetIndex:a,isDraggingRow:c,handleRowDragStart:h,handleDrop:g,handleDragEnd:d,handleRowDragOver:p}},jh=f.createContext(void 0),Om=({children:e,groupedItemsEntries:t,onChange:n,onBulkChange:r,onBulkFieldChange:i,onRowDoubleClick:s,onRowsReordered:o,onSaveComment:a,onDeleteComment:l,onSetHighlightCondition:c,onRemoveHighlightCondition:u,onAddListOption:d})=>{const h=di(),g=Oh(),p=As(),m=Am({items:g,groupedItemsEntries:t,onChange:n,onBulkFieldChange:i,onBulkChange:r,onRowDoubleClick:s,onAddListOption:d,onSaveComment:a,onDeleteComment:l,onSetHighlightCondition:c,onRemoveHighlightCondition:u}),b=Mm({items:h,onRowsReordered:o,groupBy:p}),v=f.useMemo(()=>({...m,...b}),[m,b]);return _.jsx(jh.Provider,{value:v,children:e})};function wn(){const e=f.useContext(jh);if(e===void 0)throw new Error("useTableInteractionContext must be used within a TableInteractionProvider");return e}const Tm=f.memo(e=>{var v;const t=Rh(),n=hi(),r=Th(),i=xn(),s=pa(),{setContextMenu:o}=ma(),{setActiveFilter:a,onResetSort:l,onSortByColumn:c}=yn(),{onHeaderClick:u,onHeaderRightClick:d}=wn(),h=Ph(),g=f.useMemo(()=>h.includes(e.header.id),[h,e.header.id]),p=y=>r[y]??[],m=y=>{if(n)return n.find(S=>S.headerId===y)},b=(y,S)=>{var A;if((A=y.editOptions)!=null&&A.type)switch(y.editOptions.type){case Ir.NUMBER:return Lt.NUMBER;default:return Lt.STRING}const w=[];let x=0;for(;w.length<10&&x<S.length;){const M=S[x];M!=null&&w.push(M),x++}return w.length===0?Lt.STRING:w.every(M=>typeof M=="number"?!0:typeof M=="string"?!isNaN(Number(M))&&M.trim()!=="":!1)?Lt.NUMBER:Lt.STRING};return _.jsx("th",{id:e.header.id,colSpan:e.colSpan,rowSpan:e.rowSpan,className:`${i!=null&&i.noBorder?"":"border-solid border-b border-r border-gray-300! bg-gray-50"} ${g?"!bg-blue-200 !outline-1 !outline-blue-500 -outline-offset-1":""} `,style:{...e.style},onClick:y=>{u(y,e.header.id)},onMouseEnter:()=>{},onContextMenu:y=>{y.preventDefault(),d(y,e.header.id),o({x:y.clientX,y:y.clientY,header:e.header})},children:_.jsxs("div",{style:{width:e.header.width?`${e.header.width}px`:"auto"},className:"flex justify-between",children:[_.jsxs("div",{className:"flex",children:[e.header.customHeader?e.header.customHeader(e.header):_.jsx("button",{onClick:()=>c==null?void 0:c(e.header),className:`font-semibold bg-transparent text-left text-slate-600 text-xs border-none outline-hidden! whitespace-pre ${e.header.sortable?"cursor-pointer hover:underline":"cursor-default"}`,children:e.header.text}),t===e.header.id&&_.jsxs(_.Fragment,{children:[_.jsx(ft,{path:s?jp:Lp,color:"grey",size:.6}),_.jsx("button",{onClick:l,className:`border-solid border bg-slate-300 hover:bg-slate-400! hover:border-transparent cursor-pointer rounded-lg h-min focus:outline-hidden!
41
+ Valid keys: `+JSON.stringify(Object.keys(E),null," "));var k=B(G,O,N,U,H+"."+O,n);if(k)return k}return null}return b(T)}function Z(E){switch(typeof E){case"number":case"string":case"undefined":return!0;case"boolean":return!E;case"object":if(Array.isArray(E))return E.every(Z);if(E===null||a(E))return!0;var T=d(E);if(T){var P=T.call(E),L;if(T!==E.entries){for(;!(L=P.next()).done;)if(!Z(L.value))return!1}else for(;!(L=P.next()).done;){var N=L.value;if(N&&!Z(N[1]))return!1}}else return!1;return!0;default:return!1}}function W(E,T){return E==="symbol"?!0:T?T["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&T instanceof Symbol:!1}function X(E){var T=typeof E;return Array.isArray(E)?"array":E instanceof RegExp?"object":W(T,E)?"symbol":T}function F(E){if(typeof E>"u"||E===null)return""+E;var T=X(E);if(T==="object"){if(E instanceof Date)return"date";if(E instanceof RegExp)return"regexp"}return T}function re(E){var T=F(E);switch(T){case"array":case"object":return"an "+T;case"boolean":case"date":case"regexp":return"a "+T;default:return T}}function J(E){return!E.constructor||!E.constructor.name?h:E.constructor.name}return g.checkPropTypes=i,g.resetWarningCache=i.resetWarningCache,g.PropTypes=g,g},io}var so,Yl;function $p(){if(Yl)return so;Yl=1;var e=ga();function t(){}function n(){}return n.resetWarningCache=t,so=function(){function r(o,a,l,c,u,d){if(d!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return s.PropTypes=s,s},so}var ql;function xh(){if(ql)return Mi.exports;if(ql=1,process.env.NODE_ENV!=="production"){var e=bh(),t=!0;Mi.exports=Ip()(e.isElement,t)}else Mi.exports=$p()();return Mi.exports}var Pp=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(r,i,s){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:s})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var o in r)n.d(s,o,(function(a){return r[a]}).bind(null,o));return s},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=2)}([function(e,t){e.exports=xh()},function(e,t){e.exports=f},function(e,t,n){n.r(t);var r=n(1),i=n(0),s=function(){return(s=Object.assign||function(p){for(var m,b=1,v=arguments.length;b<v;b++)for(var y in m=arguments[b])Object.prototype.hasOwnProperty.call(m,y)&&(p[y]=m[y]);return p}).apply(this,arguments)},o=function(p,m){var b={};for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&m.indexOf(v)<0&&(b[v]=p[v]);if(p!=null&&typeof Object.getOwnPropertySymbols=="function"){var y=0;for(v=Object.getOwnPropertySymbols(p);y<v.length;y++)m.indexOf(v[y])<0&&Object.prototype.propertyIsEnumerable.call(p,v[y])&&(b[v[y]]=p[v[y]])}return b},a=0,l=r.forwardRef(function(p,m){var b=p.title,v=b===void 0?null:b,y=p.description,S=y===void 0?null:y,w=p.size,x=w===void 0?null:w,C=p.color,A=C===void 0?"currentColor":C,M=p.horizontal,R=M===void 0?null:M,$=p.vertical,I=$===void 0?null:$,j=p.rotate,q=j===void 0?null:j,Z=p.spin,W=Z===void 0?null:Z,X=p.style,F=X===void 0?{}:X,re=p.children,J=o(p,["title","description","size","color","horizontal","vertical","rotate","spin","style","children"]);a++;var E,T=W!==null&&W,P=r.Children.map(re,function(H){var G=H;T!==!0&&(T=(W===null?G.props.spin:W)===!0);var Y=G.props.size;typeof x=="number"&&typeof G.props.size=="number"&&(Y=G.props.size/x);var D={size:Y,color:A===null?G.props.color:A,horizontal:R===null?G.props.horizontal:R,vertical:I===null?G.props.vertical:I,rotate:q===null?G.props.rotate:q,spin:W===null?G.props.spin:W,inStack:!0};return r.cloneElement(G,D)});x!==null&&(F.width=typeof x=="string"?x:1.5*x+"rem");var L,N="stack_labelledby_"+a,U="stack_describedby_"+a;if(v)E=S?N+" "+U:N;else if(L="presentation",S)throw new Error("title attribute required when description is set");return r.createElement("svg",s({ref:m,viewBox:"0 0 24 24",style:F,role:L,"aria-labelledby":E},J),v&&r.createElement("title",{id:N},v),S&&r.createElement("desc",{id:U},S),T&&r.createElement("style",null,"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }","@keyframes spin-inverse { from { transform: rotate(0deg) } to { transform: rotate(-360deg) } }"),P)});l.displayName="Stack",l.propTypes={size:i.oneOfType([i.number,i.string]),color:i.string,horizontal:i.bool,vertical:i.bool,rotate:i.number,spin:i.oneOfType([i.bool,i.number]),children:i.oneOfType([i.arrayOf(i.node),i.node]).isRequired,className:i.string,style:i.object},l.defaultProps={size:null,color:null,horizontal:null,vertical:null,rotate:null,spin:null};var c=l;n.d(t,"Icon",function(){return g}),n.d(t,"Stack",function(){return c});var u=function(){return(u=Object.assign||function(p){for(var m,b=1,v=arguments.length;b<v;b++)for(var y in m=arguments[b])Object.prototype.hasOwnProperty.call(m,y)&&(p[y]=m[y]);return p}).apply(this,arguments)},d=function(p,m){var b={};for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&m.indexOf(v)<0&&(b[v]=p[v]);if(p!=null&&typeof Object.getOwnPropertySymbols=="function"){var y=0;for(v=Object.getOwnPropertySymbols(p);y<v.length;y++)m.indexOf(v[y])<0&&Object.prototype.propertyIsEnumerable.call(p,v[y])&&(b[v[y]]=p[v[y]])}return b},h=0,g=r.forwardRef(function(p,m){var b=p.path,v=p.id,y=v===void 0?++h:v,S=p.title,w=S===void 0?null:S,x=p.description,C=x===void 0?null:x,A=p.size,M=A===void 0?null:A,R=p.color,$=R===void 0?"currentColor":R,I=p.horizontal,j=I!==void 0&&I,q=p.vertical,Z=q!==void 0&&q,W=p.rotate,X=W===void 0?0:W,F=p.spin,re=F!==void 0&&F,J=p.style,E=J===void 0?{}:J,T=p.inStack,P=T!==void 0&&T,L=d(p,["path","id","title","description","size","color","horizontal","vertical","rotate","spin","style","inStack"]),N={},U=[];M!==null&&(P?U.push("scale("+M+")"):(E.width=typeof M=="string"?M:1.5*M+"rem",E.height=E.width)),j&&U.push("scaleX(-1)"),Z&&U.push("scaleY(-1)"),X!==0&&U.push("rotate("+X+"deg)"),$!==null&&(N.fill=$);var H=r.createElement("path",u({d:b,style:N},P?L:{})),G=H;U.length>0&&(E.transform=U.join(" "),E.transformOrigin="center",P&&(G=r.createElement("g",{style:E},H,r.createElement("rect",{width:"24",height:"24",fill:"transparent"}))));var Y,D=G,O=re===!0||typeof re!="number"?2:re,B=!P&&(j||Z);if(O<0&&(B=!B),re&&(D=r.createElement("g",{style:{animation:"spin"+(B?"-inverse":"")+" linear "+Math.abs(O)+"s infinite",transformOrigin:"center"}},G,!(j||Z||X!==0)&&r.createElement("rect",{width:"24",height:"24",fill:"transparent"}))),P)return D;var k,K="icon_labelledby_"+y,ne="icon_describedby_"+y;if(w)Y=C?K+" "+ne:K;else if(k="presentation",C)throw new Error("title attribute required when description is set");return r.createElement("svg",u({ref:m,viewBox:"0 0 24 24",style:E,role:k,"aria-labelledby":Y},L),w&&r.createElement("title",{id:K},w),C&&r.createElement("desc",{id:ne},C),!P&&re&&(B?r.createElement("style",null,"@keyframes spin-inverse { from { transform: rotate(0deg) } to { transform: rotate(-360deg) } }"):r.createElement("style",null,"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }")),D)});g.displayName="Icon",g.propTypes={path:i.string.isRequired,size:i.oneOfType([i.number,i.string]),color:i.string,horizontal:i.bool,vertical:i.bool,rotate:i.number,spin:i.oneOfType([i.bool,i.number]),style:i.object,inStack:i.bool,className:i.string},g.defaultProps={size:null,color:"currentColor",horizontal:!1,vertical:!1,rotate:0,spin:!1},t.default=g}]);const ft=mh(Pp);var Lp="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",jp="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",Xl="M22,21H2V3H4V19H6V10H10V19H12V6H16V19H18V14H22V21Z",Fp="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",yh="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",wh="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",_h="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",Np="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z",Hp="M20 6.91L17.09 4L12 9.09L6.91 4L4 6.91L9.09 12L4 17.09L6.91 20L12 14.91L17.09 20L20 17.09L14.91 12L20 6.91Z",Bp="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22H9M11,6V9H8V11H11V14H13V11H16V9H13V6H11Z",zp="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",Sh="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",Vp="M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z",Wp="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z",Up="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z",Gp="M23 16V15.5A2.5 2.5 0 0 0 18 15.5V16A1 1 0 0 0 17 17V21A1 1 0 0 0 18 22H23A1 1 0 0 0 24 21V17A1 1 0 0 0 23 16M22 16H19V15.5A1.5 1.5 0 0 1 22 15.5M7 8.9H11V7H7A5 5 0 0 0 7 17H11V15.1H7A3.1 3.1 0 0 1 7 8.9M8 11V13H16V11M13 15.1V17H15V15.1M17 7H13V8.9H17A3.09 3.09 0 0 1 19.94 11A5.12 5.12 0 0 1 20.5 11H21.9A5 5 0 0 0 17 7Z",Yp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",qp="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",Xp="M18 21L14 17H17V7H14L18 3L22 7H19V17H22M2 19V17H12V19M2 13V11H9V13M2 7V5H6V7H2Z",Kp="M4,3H20A2,2 0 0,1 22,5V20A2,2 0 0,1 20,22H4A2,2 0 0,1 2,20V5A2,2 0 0,1 4,3M4,7V10H8V7H4M10,7V10H14V7H10M20,10V7H16V10H20M4,12V15H8V12H4M4,20H8V17H4V20M10,12V15H14V12H10M10,20H14V17H10V20M20,20V17H16V20H20M20,12H16V15H20V12Z",Kl="M12.35 20H10V17H12.09C12.21 16.28 12.46 15.61 12.81 15H10V12H14V13.54C14.58 13 15.25 12.61 16 12.35V12H20V12.35C20.75 12.61 21.42 13 22 13.54V5C22 3.9 21.1 3 20 3H4C2.9 3 2 3.9 2 5V20C2 21.1 2.9 22 4 22H13.54C13 21.42 12.61 20.75 12.35 20M16 7H20V10H16V7M10 7H14V10H10V7M8 20H4V17H8V20M8 15H4V12H8V15M8 10H4V7H8V10M17 14H19V17H22V19H19V22H17V19H14V17H17V14",Zp="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z",Jp="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z";function Qp(e,t){f.useEffect(()=>{function n(r){Array.isArray(e)?e.every(s=>{var o;return!((o=s.current)!=null&&o.contains(r.target))})&&r.target&&t():e.current&&r.target&&!e.current.contains(r.target)&&t()}return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[e,t])}var Lt=(e=>(e.STRING="string",e.NUMBER="number",e))(Lt||{});function st(e){const t=f.useMemo(()=>e.iconSize?e.iconSize:e.small?.8:1,[e.iconSize,e.small]),n=_.jsxs("button",{type:e.type??"button",id:e.id,className:`btn ${e.className??""} ${e.ghost?" btn-ghost":""} ${e.small?"btn-xs":"btn-sm"} content-center ${e.circle?"btn-circle":""}`,onClick:e.onClick,disabled:e.disabled===!0,children:[e.icon&&_.jsx(ft,{path:e.icon??"",color:e.disabled?e.iconColorDisabled??"lightgrey":e.iconColor,size:t}),e.text&&_.jsx("div",{className:`text-${e.small?"xs":"sm"}`,children:e.text})]});return _.jsx(_.Fragment,{children:e.tooltip?_.jsx("div",{className:`tooltip ${e.tooltipRight?"tooltip-right":"tooltip-top"} tooltip-top before:whitespace-pre-wrap text-left`,"data-tip":`${e.tooltip}`,children:n}):n})}const Zl=e=>{let t;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(r,i,a);return a},em=e=>e?Zl(e):Zl,tm=e=>e;function nm(e,t=tm){const n=f.useSyncExternalStore(e.subscribe,f.useCallback(()=>t(e.getState()),[e,t]),f.useCallback(()=>t(e.getInitialState()),[e,t]));return f.useDebugValue(n),n}const Jl=e=>{const t=em(e),n=r=>nm(t,r);return Object.assign(n,t),n},rn=e=>e?Jl(e):Jl,rm=e=>e.every(t=>typeof t=="number"),Ch=(e,t)=>e<t?-1:e>t?1:0,im=(e,t)=>e>t?-1:e<t?1:0,Eh=" ",sm=(e,t)=>{const n=JSON.parse(JSON.stringify(e));return e.length===0?[]:t.length===0?n:n.filter(r=>{for(const i of t){let s=r[i.headerId],o=!1;if(rm(i.itemsToHide)?(s=typeof s=="string"?s.split(Eh).join(""):s,o=i.itemsToHide.includes(Number(s))):i.itemsToHide.includes(s)&&(o=!0),o)return!1}return!0})},om=(e,t,n,r)=>{const i=[...e];if(!r)return i;const s=t.find(a=>a.id===r);if(s!=null&&s.customSort)return i.sort((a,l)=>s.customSort(a,l,n==="asc")),i;let o=!0;return i.forEach(a=>{var d;const l=(d=a[r])==null?void 0:d.toString();if(!l)return;const c=oo(l),u=["NaN"];isNaN(c)&&!u.includes(l)&&(o=!1)}),o?(i.sort((a,l)=>{const c=oo(a[r]),u=oo(l[r]),d=typeof c=="number"&&!isNaN(c),h=typeof u=="number"&&!isNaN(u);return d&&!h?-1:!d&&h?1:n==="desc"?u-c:c-u}),i):(n==="desc"?i.sort((a,l)=>Ch(l[r],a[r])):i.sort((a,l)=>im(l[r],a[r])),i)},oo=e=>typeof e=="number"?e:typeof e=="string"?Number(e.split(Eh).join("")):e,Pe=rn((e,t)=>({items:[],headers:[],hiddenHeadersId:[],processedHeaders:[],leafHeaders:[],processedLeafHeaders:[],processedItems:[],activeFilters:[],filterItemsCache:{},ascendingOrder:!0,comments:[],highlightConditions:[],advancedSetting:void 0,groupBy:void 0,linkedGroups:void 0,collapsedGroups:[],actions:{setItems:n=>{e({items:n})},setHeaders:n=>{const r=No(n);e({headers:n,leafHeaders:r})},setHiddenHeadersId:n=>{e({hiddenHeadersId:n})},setActiveFilter:(n,r,i)=>{const{activeFilters:s}=t(),o=[...s],a=o.findIndex(l=>l.headerId===n);a!==-1?r.length>0?o[a]={headerId:n,itemsToHide:r,numberConditions:i}:o.splice(a,1):r.length>0&&o.push({headerId:n,itemsToHide:r,numberConditions:i}),e({activeFilters:o})},clearActiveFilters:()=>{e({activeFilters:[]})},onResetSort:()=>{e({currentSortId:void 0,ascendingOrder:!0})},onSortByColumn:n=>{const{currentSortId:r,ascendingOrder:i}=t();if(!(n!=null&&n.sortable))return;let s;r===n.id?s=!i:s=!0,e({currentSortId:n.id,ascendingOrder:s})},processItems:()=>{const{items:n,activeFilters:r,headers:i,currentSortId:s,ascendingOrder:o}=t();let a=[...n];r.length>0&&(a=am(a,r)),s&&(a=lm(a,i,o,s)),e({processedItems:a})},processHeaders:()=>{const{headers:n,hiddenHeadersId:r}=t(),i=new Map,s=(u,d)=>{for(const h of u)d&&i.set(h.id,d),h.children&&h.children.length>0&&s(h.children,h.id)};s(n);const o=u=>{if(r.includes(u))return!0;let d=u;for(;i.has(d);)if(d=i.get(d),r.includes(d))return!0;return!1},a=u=>u.filter(d=>!o(d.id)).map(d=>d.children&&d.children.length>0?{...d,children:a(d.children)}:d),l=a(n),c=No(l);e({processedHeaders:l,processedLeafHeaders:c})},processFilterItemsCache:()=>{const{processedItems:n,activeFilters:r,leafHeaders:i}=t(),s={};i.forEach(o=>{let a=n.map(c=>c[o.id]);const l=r.find(c=>c.headerId===o.id);l&&(a=a.concat(l.itemsToHide)),s[o.id]=[...new Set(a)].filter(c=>typeof c=="string"||typeof c=="number")}),e({filterItemsCache:s})},setGroupBy:n=>{e({groupBy:n})},setLinkedGroups:n=>{e({linkedGroups:n})},collapseGroup:n=>{const{collapsedGroups:r}=t(),s=r.includes(n)?r.filter(o=>o!==n):[...r,n];e({collapsedGroups:s})},setCollapsedGroups:n=>{e({collapsedGroups:n})},setComments:n=>{e({comments:n})},setHighlightConditions:n=>{e({highlightConditions:n})},setAdvancedSettings:n=>{e({advancedSetting:n})}}}));function No(e){return e.flatMap(t=>t.children&&t.children.length>0?No(t.children):[t])}function am(e,t){return sm(e,t)}function lm(e,t,n,r){return om(e,t,n?"asc":"desc",r)}const Ah=()=>Pe(e=>e.headers),Mh=()=>Pe(e=>e.hiddenHeadersId),cm=()=>Pe(e=>e.processedHeaders),ui=()=>Pe(e=>e.processedLeafHeaders),Oh=()=>Pe(e=>e.items),Th=()=>Pe(e=>e.filterItemsCache),di=()=>Pe(e=>e.processedItems),Rh=()=>Pe(e=>e.currentSortId),pa=()=>Pe(e=>e.ascendingOrder),hi=()=>Pe(e=>e.activeFilters),xn=()=>Pe(e=>e.advancedSetting),Dh=()=>Pe(e=>e.comments),kh=()=>Pe(e=>e.highlightConditions),As=()=>Pe(e=>e.groupBy),um=()=>Pe(e=>e.linkedGroups),Ih=()=>Pe(e=>e.collapsedGroups),yn=()=>Pe(e=>e.actions);function dm(e){const{setActiveFilter:t}=yn(),n=hi(),r=f.useMemo(()=>n.find(p=>p.headerId===e.headerId),[n,e.headerId]),[i,s]=f.useState(""),[o,a]=f.useState([]);f.useEffect(()=>{a((r==null?void 0:r.itemsToHide)??[])},[r==null?void 0:r.itemsToHide]);const l=f.useMemo(()=>{let p=[];return i?(p=[...e.items].filter(m=>m==null?void 0:m.toString().toLocaleLowerCase().includes(i==null?void 0:i.toString().toLocaleLowerCase())),e.filterType===Lt.STRING&&(p=p.sort(Ch))):p=[...e.items],p},[i,e.items]),c=p=>{p.preventDefault(),i&&t(e.headerId,[i])},u=()=>{a([...e.items])},d=()=>{a([])},h=p=>{const m=o.findIndex(v=>v===p);let b=[...o];m!==void 0&&(m===-1?b=[...b,p]:b.splice(m,1),a(b))},g=()=>{const p=l.filter(b=>!o.includes(b)),m=[...e.items].filter(b=>!p.includes(b));t(e.headerId,m.map(b=>b))};return _.jsxs("div",{children:[_.jsx("div",{className:"font-semibold text-sm mb-1",children:"Filter by value:"}),_.jsxs("form",{onSubmit:c,children:[_.jsx("input",{type:"text",value:i,onChange:p=>s(p==null?void 0:p.target.value),placeholder:"Search...",className:"input input-bordered input-xs w-full max-w-xs"}),_.jsx("input",{type:"submit",value:""})]}),_.jsxs("div",{className:"flex text-xs mt-1 font-semibold text-primary",children:[_.jsx("button",{onClick:d,onFocus:()=>{},className:"mr-4 cursor-pointer hover:border-none! border-none! focus:outline-hidden! bg-transparent btn-sm",children:"Select All"}),_.jsx("button",{onClick:u,onFocus:()=>{},className:"cursor-pointer hover:border-none! border-none! focus:outline-hidden! bg-transparent btn-sm",children:"Clear"})]}),_.jsx("div",{className:"overflow-auto max-h-44 mt-2",style:{scrollbarWidth:"thin"},children:l.map((p,m)=>_.jsxs("div",{className:"flex mt-2",children:[_.jsx("input",{type:"checkbox",onClick:()=>h(p),readOnly:!0,checked:!o.includes(p),className:"mr-2 "}),_.jsx("p",{className:"text-xs",children:(p==null?void 0:p.toString())||_.jsx("span",{className:"italic",children:"(Blanks)"})})]},`filter-item-${p}-${m}`))}),_.jsxs("div",{className:"flex float-end mt-2",children:[_.jsx(st,{onClick:()=>{g(),e.onShowOrHide(!1)},text:"OK",iconColor:"#6161bb",small:!0}),_.jsx(st,{className:"ml-1",onClick:()=>e.onShowOrHide(!1),text:"Cancel",iconColor:"#6161bb",small:!0})]})]})}function Ql(e){const[t,n]=f.useState(e.numberCondition.value1),[r,i]=f.useState(e.numberCondition.value2??0),s=f.useCallback((a,l)=>{e.updateCondition({id:e.numberCondition.id,operator:e.numberCondition.operator,value1:a==="value1"?l:e.numberCondition.value1,value2:a==="value2"?l:e.numberCondition.value2})},[e.numberCondition.id,e.numberCondition.operator]),o=(a,l)=>{a==null||a.preventDefault(),a==null||a.stopPropagation(),e.deleteCondition&&e.deleteCondition(l)};return _.jsxs("div",{className:"flex items-center gap-1 group",children:[_.jsxs("select",{value:e.numberCondition.operator,onChange:a=>e.updateCondition({id:e.numberCondition.id,operator:a.target.value,value1:e.numberCondition.value1,value2:e.numberCondition.value2}),className:" select select-xs px-1 grow",children:[_.jsx("option",{value:"=",children:"Equal"}),_.jsx("option",{value:">",children:"Greater than"}),_.jsx("option",{value:"<",children:"Less than"}),_.jsx("option",{value:">=",children:">="}),_.jsx("option",{value:"<=",children:"<="}),_.jsx("option",{value:"between",children:"Between"})]}),_.jsx("input",{type:"number",value:t,onChange:a=>{n(parseFloat(a.target.value)||0),e.immediatApply&&s("value1",parseFloat(a.target.value)||0)},onBlur:a=>s("value1",parseFloat(a.target.value)||0),className:"input input-xs w-12",step:"any"}),e.numberCondition.operator==="between"&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"text-xs font-semibold",children:"-"}),_.jsx("input",{type:"number",value:r,onChange:a=>{i(parseFloat(a.target.value)),e.immediatApply&&s("value2",parseFloat(a.target.value))},onBlur:a=>s("value2",parseFloat(a.target.value)),className:"input input-xs w-12",step:"any"})]}),e.isNew?_.jsx(_.Fragment,{}):_.jsx("button",{onClick:a=>o(a,e.numberCondition),className:"rounded bg-gray-200 p-0.5 cursor-pointer hover:bg-gray-300",children:_.jsx(ft,{path:zp,color:"#d11f1f",size:.7})})]},e.numberCondition.id)}function hm(e){var p,m;const{setActiveFilter:t}=yn(),n=hi(),r=f.useMemo(()=>n.find(b=>b.headerId===e.headerId),[n,e.headerId]),[i,s]=f.useState([]);f.useEffect(()=>{r!=null&&r.numberConditions&&s(r==null?void 0:r.numberConditions)},[r]),f.useEffect(()=>{c()},[i]);const[o,a]=f.useState({id:Date.now().toString()+Math.random().toString(36).substring(2),operator:"=",value1:0}),l=f.useMemo(()=>e.items.map(b=>typeof b=="string"?parseFloat(b):b).filter(b=>!isNaN(b)),[e.items]),c=f.useCallback(()=>{const b=e.items.filter((v,y)=>{const S=l[y];return typeof S!="number"?!0:i.some(w=>{switch(w.operator){case"=":return S!==w.value1;case">":return S<=w.value1;case"<":return S>=w.value1;case">=":return S<w.value1;case"<=":return S>w.value1;case"between":return w.value2===void 0?!0:S<w.value1||S>w.value2}})});e.items.length>0&&e.items[0],t(e.headerId,b,i)},[e.items,e.headerId,i,l,t]),u=b=>{b==null||b.preventDefault(),b==null||b.stopPropagation(),s(v=>[...v,o]),a({id:Date.now().toString(),operator:"=",value1:0})},d=(b,v)=>{s(y=>y.map(S=>S.id===b?{...S,...v}:S))},h=b=>{const v=i.filter(y=>y.id!==b);s(v)},g=()=>{s([]),t(e.headerId,[],[])};return _.jsxs("form",{onSubmit:u,className:"space-y-4",children:[_.jsxs("div",{className:"bg-blue-50/70 p-2 rounded-md",children:[_.jsx(Ql,{numberCondition:o,updateCondition:b=>a(b),isNew:!0,immediatApply:!0}),_.jsx("div",{className:"flex items-center gap-2 mt-2",children:_.jsx(st,{text:"Add Condition",type:"button",onClick:u,small:!0,className:"rounded-lg p-2 py-0",icon:qp,iconColor:"var(--comment-color)",iconSize:.7})})]}),_.jsx("div",{className:"mt-4",children:(p=r==null?void 0:r.numberConditions)==null?void 0:p.map((b,v)=>_.jsx("div",{className:"mb-1",children:_.jsx(Ql,{numberCondition:b,updateCondition:y=>d(y.id,y),deleteCondition:()=>h(b.id),isNew:!1})},"condition-"+v))}),_.jsx("div",{className:"flex justify-end gap-2 mt-8",children:_.jsx(st,{text:"Clear filter",disabled:!(r!=null&&r.numberConditions)||((m=r==null?void 0:r.numberConditions)==null?void 0:m.length)===0,onClick:g,small:!0})})]})}function fm(e){const[t,n]=f.useState(!1),r=f.useRef(null);f.useEffect(()=>{var c,u;if(e.show&&r.current){const d=r.current.getBoundingClientRect(),h=(u=(c=e.tableRef)==null?void 0:c.current)==null?void 0:u.getBoundingClientRect(),g=(h==null?void 0:h.width)??0,p=d.width+d.x>g;n(p)}else n(!1)},[e.show]),Qp([e.wrapperRef,r],()=>{e.show&&e.onShowOrHide(!1)});const[i,s]=f.useState();f.useEffect(()=>{if(e.show&&e.filterButtonRef.current){const c=e.filterButtonRef.current.getBoundingClientRect();s({top:c.bottom+window.scrollY,left:c.left+window.scrollX})}},[e.show]);const a=(c=>{switch(c){case Lt.NUMBER:return hm;case Lt.STRING:default:return dm}})(e.filterType),l=e.show&&i?hn.createPortal(_.jsx("div",{ref:r,className:`fixed mt-1 bg-white shadow p-3 w-60 z-300 rounded-md font-normal border border-gray-300 ${t?"right-0":""}`,style:{top:`${i.top}px`,left:`${i.left}px`},children:_.jsx(a,{headerId:e.headerId,filterType:e.filterType,items:e.items,onShowOrHide:e.onShowOrHide})}),document.body):null;return _.jsx("div",{children:e.show?l:""})}function gm(e){const t=f.useRef(null),n=f.useRef(null);return _.jsxs("div",{ref:t,className:"relative",children:[_.jsx("button",{ref:n,onClick:()=>e.onShowOrHide(!e.show),className:`border-solid border hover:!border-primary cursor-pointer border-gray-300 rounded focus:outline-hidden! ${e.currentFilter?"bg-purple-800":"bg-white"} `,children:_.jsx(ft,{path:Vp,color:e.currentFilter?"white":"grey",size:.6})}),_.jsx(fm,{...e,filterButtonRef:n,wrapperRef:t})]})}const $h=rn(e=>({contextMenu:void 0,actions:{setContextMenu:t=>e({contextMenu:t})}})),pm=()=>$h(e=>e.contextMenu),ma=()=>$h(e=>e.actions),Ir={LIST:"list",NUMBER:"number"},Le=rn(e=>({selectedHeaderIds:[],selectedCell:void 0,expandedSelection:[],actions:{setSelectedHeaderIds:t=>e({selectedHeaderIds:t}),setSelectedCell:t=>e({selectedCell:t}),setExpandedSelection:t=>e({expandedSelection:t}),clearSelection:()=>e({selectedCell:void 0,expandedSelection:[]})}})),Ph=()=>Le(e=>e.selectedHeaderIds),Ms=()=>Le(e=>e.expandedSelection),Lh=()=>Le(e=>e.actions),Jt=(e,t,n)=>`cell-${e}-${t}${n?`-fromArray-${n.index}`:""}`,mm=(e,t,n,r,i,s,o)=>{e.stopPropagation();let a=t,l=[...n];if(e.key==="Tab"){let c=(t==null?void 0:t.rowIndex)??0,u=(t==null?void 0:t.columnIndex)??0;if(n.length>1){const d=[...n].sort((m,b)=>m.rowIndex!==b.rowIndex?m.rowIndex-b.rowIndex:m.columnIndex-b.columnIndex),h=d.findIndex(m=>{var b,v;return m.rowIndex===(t==null?void 0:t.rowIndex)&&m.columnIndex===(t==null?void 0:t.columnIndex)&&((b=m.fromArrayData)==null?void 0:b.index)===((v=t==null?void 0:t.fromArrayData)==null?void 0:v.index)});let g;e.shiftKey?(g=h-1,g<0&&(g=d.length-1)):(g=h+1,g>=d.length&&(g=0)),a=d[g]}else{const d=bm(e,s,t,o);if(d)return{newSelectedCell:d,newExpandedSelection:[]};u=((t==null?void 0:t.columnIndex)??0)+(e.shiftKey?-1:1),u>=r?(u=0,c++):u<0&&(u=r-1,c--),c>=i&&(c=0),c<0&&(c=i-1),l=[],a={rowIndex:c,columnIndex:u}}}return{newSelectedCell:a,newExpandedSelection:l}},bm=(e,t,n,r)=>{const i=n==null?void 0:n.fromArrayData;if(!i||!r)return;const s=r[i.fromArray];if(!((s==null?void 0:s.length)??0))return;let a=document.getElementById(Jt(n.rowIndex,n.columnIndex+(e.shiftKey?-1:1),{index:i.index}));if(a)return{rowIndex:n.rowIndex,columnIndex:n.columnIndex+(e.shiftKey?-1:1),fromArrayData:{fromArray:n.fromArrayData.fromArray,index:i.index}};if(r&&r[n.fromArrayData.fromArray].length>0){const l=t.findIndex(u=>u.fromArray===n.fromArrayData.fromArray);let c;if(t.forEach(u=>{u.fromArray===n.fromArrayData.fromArray&&(c=t.indexOf(u))}),e.shiftKey){if(a=document.getElementById(Jt(n.rowIndex,c,{index:n.fromArrayData.index-1})),a)return{rowIndex:n.rowIndex,columnIndex:c,fromArrayData:{fromArray:n.fromArrayData.fromArray,index:n.fromArrayData.index-1}}}else if(a=document.getElementById(Jt(n.rowIndex,l,{index:n.fromArrayData.index+1})),a)return{rowIndex:n.rowIndex,columnIndex:l,fromArrayData:{fromArray:n.fromArrayData.fromArray,index:n.fromArrayData.index+1}}}},$n=rn(e=>({dragStartCell:void 0,isDragging:!1,actions:{setDragStartCell:t=>e({dragStartCell:t}),setIsDragging:t=>e({isDragging:t})}})),vm=()=>$n(e=>e.isDragging),xm=(e,t,n,r,i)=>{const s=t.filter(a=>{var l,c;return e.rowIndex===a.rowIndex&&((l=e.fromArrayData)==null?void 0:l.index)===((c=a.fromArrayData)==null?void 0:c.index)});return s.length>0?s.map(a=>{const l=n[a.columnIndex];let c;return a.fromArrayData?c=r[l.fromArray][a.fromArrayData.index][l.id]:c=r[l.id],{value:c,headerId:l.id}}):[{value:i,headerId:n[e.columnIndex].id}]},ym=(e,t)=>e.map(n=>t[n.columnIndex]),wm=(e,t,n,r)=>{var s,o,a,l,c;const i=r.find(u=>u.id===t);return!(!i||((s=i.editOptions)==null?void 0:s.type)!==((o=n.editOptions)==null?void 0:o.type)||((a=n.editOptions)==null?void 0:a.type)==="list"&&!((c=(l=n.editOptions)==null?void 0:l.options)==null?void 0:c.includes(e)))},_m=(e,t)=>{const n=e.getBoundingClientRect(),r=Math.max(0,Math.min(t.right,n.right)-Math.max(t.left,n.left)),i=Math.max(0,Math.min(t.bottom,n.bottom)-Math.max(t.top,n.top)),s=n.width*n.height;return r*i>=s*.3},ba=rn(e=>({clipboardData:[],actions:{setClipboardData:t=>e(()=>({clipboardData:t}))}})),Sm=()=>ba(e=>e.clipboardData),Cm=()=>ba(e=>e.actions),ao=(e,t)=>{var n,r;return e.rowIndex===(t==null?void 0:t.rowIndex)&&e.columnIndex===(t==null?void 0:t.columnIndex)&&((n=e.fromArrayData)==null?void 0:n.index)===((r=t==null?void 0:t.fromArrayData)==null?void 0:r.index)},ec=e=>{var t;return`${e.rowIndex}:${e.columnIndex}:${((t=e.fromArrayData)==null?void 0:t.index)??""}`},Em=(e,t)=>{const n=new Set(e.map(ec)),r=[...e];for(const i of t){const s=ec(i);n.has(s)||(n.add(s),r.push(i))}return r};function Am({items:e,groupedItemsEntries:t,onChange:n,onBulkChange:r,onBulkFieldChange:i,onRowDoubleClick:s,onSaveComment:o,onDeleteComment:a,onSetHighlightCondition:l,onRemoveHighlightCondition:c,onAddListOption:u}){const d=Ms(),{setSelectedCell:h,setExpandedSelection:g,setSelectedHeaderIds:p}=Lh(),m=Ph(),b=ui(),v=Ah(),{setDragStartCell:y,setIsDragging:S}=$n(D=>D.actions),w=f.useCallback(D=>{if(D)if(t){const O=t.flatMap(([B,k])=>k.filter(K=>K.rowIndex===D.rowIndex))[0];if(O)return O.item}else return e[D.rowIndex]},[t,e]),x=f.useCallback(D=>{const O=[];return D.forEach(B=>{const k=w(B);k&&O.push(k)}),O},[w]),C=f.useCallback((D,O,B,k)=>{const K=e.findIndex(ie=>ie===O);let ne;if(k){const ie=O[B.fromArray];ie[k.index]={...ie[k.index],[B.id]:D},ne={...O,[B.fromArray]:ie}}else ne={...O,[B.id]:D};return{itemUpdated:ne,originalIndex:K}},[e]),A=f.useCallback(async(D,O,B,k)=>{var ie;const{itemUpdated:K,originalIndex:ne}=C(D,O,B,k.fromArrayData);if(n){const he=(ie=k.fromArrayData)==null?void 0:ie.index;(he===void 0?O[B.id]!==D:O[B.fromArray][he]!==D)&&await n(K,ne,he!==void 0?{fromArrayIndex:he,headerId:B.id}:void 0)}},[n,C]),M=f.useCallback((D,O)=>{O.preventDefault();const k=Le.getState().expandedSelection.some(K=>{var ne,ie,he,oe;return K.rowIndex===D.rowIndex&&K.columnIndex===D.columnIndex&&((ne=K.fromArrayData)==null?void 0:ne.index)===((ie=D.fromArrayData)==null?void 0:ie.index)&&((he=K.fromArrayData)==null?void 0:he.fromArray)===((oe=D.fromArrayData)==null?void 0:oe.fromArray)});h(D),k||(g([]),p([]))},[]),R=f.useCallback(async(D,O,B,k)=>{var he;const K=Le.getState().selectedCell,ne=Le.getState().expandedSelection;let ie=[...ne];if(K&&!ne.some(oe=>oe.rowIndex===K.rowIndex&&oe.columnIndex===K.columnIndex)&&(ie=[...ne,K]),(ne==null?void 0:ne.length)>1){const oe=ie.map(ye=>{const ce=w(ye);return ce?{itemUpdated:{...ce,[B.id]:D},originalIndex:e.findIndex(we=>we===ce)}:null}).filter(Boolean);r&&oe.length>0&&await r(oe,B.id)}else{const{itemUpdated:oe,originalIndex:ye}=C(D,O,B,k.fromArrayData);if(n){const ce=(he=k.fromArrayData)==null?void 0:he.index;(ce===void 0?O[B.id]!==D:O[B.fromArray][ce]!==D)&&(console.log("onCellEnter calling onChange",ce),await n(oe,ye,ce!==void 0?{fromArrayIndex:ce,headerId:B.id}:void 0))}}},[w,e,i,n,C]),$=f.useCallback(D=>{var B,k;const O=Le.getState().selectedCell;((O==null?void 0:O.rowIndex)!==D.rowIndex||(O==null?void 0:O.columnIndex)!==D.columnIndex||((B=O==null?void 0:O.fromArrayData)==null?void 0:B.index)!==((k=D.fromArrayData)==null?void 0:k.index))&&(h(D),g([]),p([]))},[]),I=f.useCallback((D,O)=>{m.includes(O)||j(D,O)},[m]),j=f.useCallback((D,O)=>{console.log("Header clicked:",O);const B=[];if(e.forEach((K,ne)=>{const ie=b.findIndex(he=>he.id===O);ie>=0&&B.push({rowIndex:ne,columnIndex:ie})}),D.ctrlKey||D.metaKey){console.log("Ctrl or Cmd pressed, adding to selection");const K=[...m];K.includes(O)||K.push(O),console.log("New selected header ids:",K),p(K);const ne=Em(d,B);g(ne)}else p([O]),h(void 0),g(B)},[e,d,b,m]),q=f.useCallback(D=>{const O=Le.getState().selectedCell,B=Le.getState().expandedSelection,k=O?{...O}:void 0,K=O?w(O):void 0,{newSelectedCell:ne,newExpandedSelection:ie}=mm(D,O,B,b.length,e.length,b,K);k&&ao(k,ne)||(h(ne),B.length!==ie.length&&p([]),g(ie),Z(ne))},[v.length,e.length,e]),Z=D=>{if(D){const O=document.getElementById(Jt(D.rowIndex,D.columnIndex,D.fromArrayData));O&&O.focus()}},W=f.useCallback(async D=>{s&&await s(D)},[s]),X=f.useRef(!1),F=f.useCallback((D,O)=>{const B=Le.getState().selectedCell;if(D.ctrlKey||D.metaKey)if(!B)h(O),g([O]);else{const K=[...Le.getState().expandedSelection];K.findIndex(ne=>ao(ne,O))===-1&&K.push(O),g(K),h(O)}else ao(O,B)||(h(O),p([]),g([O]));X.current=!0,y(O)},[]),re=f.useCallback((D,O)=>{D.stopPropagation();const B=$n.getState().dragStartCell;if(!$n.getState().isDragging||!B)return;const K=[],ne=document.getElementById(Jt(B.rowIndex,B.columnIndex,B.fromArrayData)),ie=D.currentTarget;if(!ne||!ie)return;const he=ne.getBoundingClientRect(),oe=ie.getBoundingClientRect(),ye=Math.min(he.left,oe.left),ce=Math.min(he.top,oe.top),we=Math.max(he.right,oe.right),_e=Math.max(he.bottom,oe.bottom),We=ie.closest("table");if(!We)return;const Tt=We.getElementsByTagName("td"),Bt=new Set;Array.from(Tt).forEach(vt=>{if(_m(vt,{left:ye,right:we,top:ce,bottom:_e})){const z=parseInt(vt.getAttribute("data-row-index")||"-1"),te=parseInt(vt.getAttribute("data-col-index")||"-1"),le=vt.getAttribute("data-from-array"),fe=vt.getAttribute("data-array-index");if(z>=0&&te>=0){const De=le&&fe!==null?`${z}-${te}-${le}-${fe}`:`${z}-${te}`;if(Bt.has(De))return;Bt.add(De);const Fe={rowIndex:z,columnIndex:te};le&&fe!==null&&(Fe.fromArrayData={fromArray:le,index:parseInt(fe)}),K.push(Fe)}}}),g(K)},[e,b]),J=f.useCallback(D=>{D.preventDefault();const O=Le.getState().selectedCell,B=$n.getState().dragStartCell,k=$n.getState().isDragging;X.current&&!k&&S(!0),k&&B!==O&&(h(B),p([]))},[]),E=f.useCallback(()=>{X.current=!1,S(!1)},[]),T=f.useCallback(async()=>{var ye;const D=ba.getState().clipboardData,O=Le.getState().selectedCell,B=Le.getState().expandedSelection,k=Pe.getState().processedLeafHeaders;if(!n||!O||D.length===0)return;const K=w(O);if(!K)return;const ne=e.findIndex(ce=>ce===K),ie=(ye=O.fromArrayData)==null?void 0:ye.index,he=k[O.columnIndex],oe={...K};if(D.length===1){const{value:ce,headerId:we}=D[0],_e=k[O.columnIndex];wm(ce,we,_e,k)&&(L(oe,_e,ce,ie?{index:ie}:void 0),await n(oe,ne,ie!==void 0?{fromArrayIndex:ie,headerId:_e.id}:void 0))}else{const ce=ym(B,k);let we=!1;D.forEach(_e=>{const We=ce.find(Tt=>Tt.id===_e.headerId);We&&(L(oe,We,_e.value,ie?{index:ie}:void 0),we=!0)}),we&&await n(oe,ne,ie!==void 0?{fromArrayIndex:ie,headerId:he.id}:void 0)}},[e]),P=f.useCallback(async()=>{var ie,he;const D=Le.getState().selectedCell,O=Le.getState().expandedSelection,B=Pe.getState().processedLeafHeaders,k=void 0;if(!n||!D)return;if(O.length===0){const oe=w(D);if(!oe)return;const ye={...oe},ce=B[D.columnIndex];L(ye,ce,k,D.fromArrayData?{index:(ie=D.fromArrayData)==null?void 0:ie.index,headerId:ce.id}:void 0),await n(ye,e.findIndex(we=>we===oe),D.fromArrayData?{fromArrayIndex:(he=D.fromArrayData)==null?void 0:he.index,headerId:ce.id}:void 0);return}const K=new Map;console.log("expandedSelection",O),O.forEach(oe=>{const ye=w(oe);if(!ye)return;const ce=B[oe.columnIndex],we=e.findIndex(_e=>_e===ye);K.has(ye)||K.set(ye,{headers:new Set,itemIndex:we}),oe.fromArrayData?(K.get(ye).fromArray||(K.get(ye).fromArray=[]),K.get(ye).fromArray.push({index:oe.fromArrayData.index,headerId:ce.id})):K.get(ye).headers.add(ce)});const ne=[];K.forEach((oe,ye)=>{var we;const ce={...ye};oe.headers.forEach(_e=>{L(ce,_e,k)}),(we=oe.fromArray)==null||we.forEach(_e=>{L(ce,B.find(We=>We.id===_e.headerId),k,{index:_e.index,headerId:_e.headerId})}),ne.push({itemUpdated:ce,originalIndex:oe.itemIndex,fromArrayItemsAffected:oe.fromArray?oe.fromArray.map(_e=>({fromArrayIndex:_e.index,headerId:_e.headerId})):[]})}),await(r==null?void 0:r(ne))},[e]),L=(D,O,B,k)=>{k!==void 0?k.headerId?D[O.fromArray][k.index][k.headerId]=B:D[O.fromArray][k.index]=B:D[O.id]=B},N=f.useCallback(async(D,O)=>{a&&await a(D,O)},[o,e]),U=f.useCallback(async(D,O)=>{o&&await o(D,O)},[o,e]);return f.useEffect(()=>(window.addEventListener("mouseup",E),()=>{window.removeEventListener("mouseup",E)}),[E]),{setExpandedSelection:g,onHeaderClick:j,onHeaderRightClick:I,onCellBlur:A,onCellEnter:R,onCellClick:$,handleCellKeyDown:q,handleRowDoubleClick:W,resetDefaultValueForSelectedCells:P,saveCommentHandler:U,deleteCommentHandler:N,setHighlightCondition:async(D,O,B)=>{const k={propertyId:O,value:D[O],columnId:O,style:B};await(l==null?void 0:l(k,D))},removeHighlightCondition:(D,O,B)=>{const k={propertyId:O,value:D[O],columnId:O,style:{}};c==null||c(k,B,D)},onCellMouseDown:F,onCellMouseEnter:re,onMouseMove:J,pasteClipboardData:T,onRightClick:M,addListOption:async(D,O)=>{u&&await u(D,O)},getItemFromCellCoordinates:w,getItemsFromCellCoordinates:x}}const Mm=({items:e,onRowsReordered:t,groupBy:n})=>{const[r,i]=f.useState(null),[s,o]=f.useState(null),[a,l]=f.useState(null),[c,u]=f.useState(!1),d=f.useCallback(()=>{console.log(e),i(null),l(null),u(!1),o(null)},[]),h=f.useCallback((m,b)=>{i(m),u(!0),o(b)},[]),g=f.useCallback(m=>{if(r!==null&&a!==null&&r!==a){if(n&&m[n]!==(s==null?void 0:s[n])){console.warn("Cannot reorder items across different groups");return}t==null||t(r,a,s,m)}i(null),l(null),u(!1),o(null)},[r,a,t]),p=f.useCallback(m=>{r!==null&&r!==m&&l(m)},[r]);return{draggedRowIndex:r,dropTargetIndex:a,isDraggingRow:c,handleRowDragStart:h,handleDrop:g,handleDragEnd:d,handleRowDragOver:p}},jh=f.createContext(void 0),Om=({children:e,groupedItemsEntries:t,onChange:n,onBulkChange:r,onBulkFieldChange:i,onRowDoubleClick:s,onRowsReordered:o,onSaveComment:a,onDeleteComment:l,onSetHighlightCondition:c,onRemoveHighlightCondition:u,onAddListOption:d})=>{const h=di(),g=Oh(),p=As(),m=Am({items:g,groupedItemsEntries:t,onChange:n,onBulkFieldChange:i,onBulkChange:r,onRowDoubleClick:s,onAddListOption:d,onSaveComment:a,onDeleteComment:l,onSetHighlightCondition:c,onRemoveHighlightCondition:u}),b=Mm({items:h,onRowsReordered:o,groupBy:p}),v=f.useMemo(()=>({...m,...b}),[m,b]);return _.jsx(jh.Provider,{value:v,children:e})};function wn(){const e=f.useContext(jh);if(e===void 0)throw new Error("useTableInteractionContext must be used within a TableInteractionProvider");return e}const Tm=f.memo(e=>{var v;const t=Rh(),n=hi(),r=Th(),i=xn(),s=pa(),{setContextMenu:o}=ma(),{setActiveFilter:a,onResetSort:l,onSortByColumn:c}=yn(),{onHeaderClick:u,onHeaderRightClick:d}=wn(),h=Ph(),g=f.useMemo(()=>h.includes(e.header.id),[h,e.header.id]),p=y=>r[y]??[],m=y=>{if(n)return n.find(S=>S.headerId===y)},b=(y,S)=>{var A;if((A=y.editOptions)!=null&&A.type)switch(y.editOptions.type){case Ir.NUMBER:return Lt.NUMBER;default:return Lt.STRING}const w=[];let x=0;for(;w.length<10&&x<S.length;){const M=S[x];M!=null&&w.push(M),x++}return w.length===0?Lt.STRING:w.every(M=>typeof M=="number"?!0:typeof M=="string"?!isNaN(Number(M))&&M.trim()!=="":!1)?Lt.NUMBER:Lt.STRING};return _.jsx("th",{id:e.header.id,colSpan:e.colSpan,rowSpan:e.rowSpan,className:`${i!=null&&i.noBorder?"":"border-solid border-b border-r border-gray-300! bg-gray-50"} ${g?"!bg-blue-200 !outline-1 !outline-blue-500 -outline-offset-1":""} `,style:{...e.style},onClick:y=>{u(y,e.header.id)},onMouseEnter:()=>{},onContextMenu:y=>{var S;y.preventDefault(),d(y,e.header.id),((S=i==null?void 0:i.contextMenu)==null?void 0:S.showOnHeader)!==!1&&o({x:y.clientX,y:y.clientY,header:e.header})},children:_.jsxs("div",{style:{width:e.header.width?`${e.header.width}px`:"auto"},className:"flex justify-between",children:[_.jsxs("div",{className:"flex",children:[e.header.customHeader?e.header.customHeader(e.header):_.jsx("button",{onClick:()=>c==null?void 0:c(e.header),className:`font-semibold bg-transparent text-left text-slate-600 text-xs border-none outline-hidden! whitespace-pre ${e.header.sortable?"cursor-pointer hover:underline":"cursor-default"}`,children:e.header.text}),t===e.header.id&&_.jsxs(_.Fragment,{children:[_.jsx(ft,{path:s?jp:Lp,color:"grey",size:.6}),_.jsx("button",{onClick:l,className:`border-solid border bg-slate-300 hover:bg-slate-400! hover:border-transparent cursor-pointer rounded-lg h-min focus:outline-hidden!
42
42
  `,children:_.jsx(ft,{path:Np,color:"grey",size:.6})})]})]}),e.header.hasFilter?_.jsx("div",{className:"ml-2",children:_.jsx(gm,{show:e.showFilter,tableRef:e.tableRef,currentFilter:m(e.header.id),filterName:e.header.text,headerId:e.header.id,filterType:b(e.header,p(e.header.id)),items:p(e.header.id),itemsToHide:((v=n==null?void 0:n.find(y=>y.headerId===e.header.id))==null?void 0:v.itemsToHide)??[],onShowOrHide:y=>e.onShowFilter(y,e.header.id),onSetFilter:a})}):_.jsx(_.Fragment,{})]})},e.header.id+`-${e.index}`)});function Rm(e){const[t,n]=f.useState(""),r=f.useRef([]),[i,s]=f.useState([]);f.useLayoutEffect(()=>{const h=r.current.map(g=>(g==null?void 0:g.getBoundingClientRect().height)||0);s(h)},[e.headers]);const o=(h,g)=>{if(!h){n("");return}n(g)},a=f.useMemo(()=>{function h(g){return g.reduce((p,m)=>m.children&&m.children.length>0?Math.max(p,1+h(m.children)):Math.max(p,1),0)}return h(e.headers)},[e.headers]),l=f.useCallback(h=>h.children&&h.children.length>0?h.children.reduce((g,p)=>g+l(p),0):1,[]);function c(h,g,p=0){const m=d(h,g,p),b=h.filter(v=>v.children&&v.children.length>0).map(v=>v.children).flat();return b.length>0?[m,...c(b,g,p+1)]:[m]}const u=f.useMemo(()=>{const h=d(e.headers,a,0),g=e.headers.filter(p=>p.children&&p.children.length>0).map(p=>p.children).flat();return g.length>0?[h,...c(g,a,1)]:[h]},[e.headers,t,i]);function d(h,g,p=0){return h.length===0?null:_.jsx("tr",{ref:m=>{r.current[p]=m},style:{zIndex:100-p},children:h.map((m,b)=>{const v=l(m),S=m.children&&m.children.length>0?1:g-p,w=i.slice(0,p).reduce((x,C)=>x+C,0);return _.jsx(f.Fragment,{children:_.jsx(Tm,{header:m,colSpan:v,rowSpan:S,index:b,showFilter:t===m.id,onShowFilter:o,style:{position:"sticky",top:`${w}px`}})},m.id+m.id)})},`header-row-${p}`)}return _.jsx("thead",{className:"relative",children:u})}function Dn(e,t,n){let r=n.initialDeps??[],i;function s(){var o,a,l,c;let u;n.key&&((o=n.debug)!=null&&o.call(n))&&(u=Date.now());const d=e();if(!(d.length!==r.length||d.some((p,m)=>r[m]!==p)))return i;r=d;let g;if(n.key&&((a=n.debug)!=null&&a.call(n))&&(g=Date.now()),i=t(...d),n.key&&((l=n.debug)!=null&&l.call(n))){const p=Math.round((Date.now()-u)*100)/100,m=Math.round((Date.now()-g)*100)/100,b=m/16,v=(y,S)=>{for(y=String(y);y.length<S;)y=" "+y;return y};console.info(`%c⏱ ${v(m,5)} /${v(p,5)} ms`,`
43
43
  font-size: .6rem;
44
44
  font-weight: bold;
@@ -92,7 +92,7 @@ Valid keys: `+JSON.stringify(Object.keys(E),null," "));var k=B(G,O,N,U,H+"."+O,
92
92
  `):e}function Wj(e,t){const{element:n,datasetIndex:r,index:i}=t,s=e.getDatasetMeta(r).controller,{label:o,value:a}=s.getLabelAndValue(i);return{chart:e,label:o,parsed:s.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:a,dataset:s.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function Kd(e,t){const n=e.chart.ctx,{body:r,footer:i,title:s}=e,{boxWidth:o,boxHeight:a}=t,l=Ve(t.bodyFont),c=Ve(t.titleFont),u=Ve(t.footerFont),d=s.length,h=i.length,g=r.length,p=ct(t.padding);let m=p.height,b=0,v=r.reduce((w,x)=>w+x.before.length+x.lines.length+x.after.length,0);if(v+=e.beforeBody.length+e.afterBody.length,d&&(m+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),v){const w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=g*w+(v-g)*l.lineHeight+(v-1)*t.bodySpacing}h&&(m+=t.footerMarginTop+h*u.lineHeight+(h-1)*t.footerSpacing);let y=0;const S=function(w){b=Math.max(b,n.measureText(w).width+y)};return n.save(),n.font=c.string,ve(e.title,S),n.font=l.string,ve(e.beforeBody.concat(e.afterBody),S),y=t.displayColors?o+2+t.boxPadding:0,ve(r,w=>{ve(w.before,S),ve(w.lines,S),ve(w.after,S)}),y=0,n.font=u.string,ve(e.footer,S),n.restore(),b+=p.width,{width:b,height:m}}function Uj(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function Gj(e,t,n,r){const{x:i,width:s}=r,o=n.caretSize+n.caretPadding;if(e==="left"&&i+s+o>t.width||e==="right"&&i-s-o<0)return!0}function Yj(e,t,n,r){const{x:i,width:s}=n,{width:o,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=i<=(a+l)/2?"left":"right":i<=s/2?c="left":i>=o-s/2&&(c="right"),Gj(c,e,t,n)&&(c="center"),c}function Zd(e,t,n){const r=n.yAlign||t.yAlign||Uj(e,n);return{xAlign:n.xAlign||t.xAlign||Yj(e,t,n,r),yAlign:r}}function qj(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function Xj(e,t,n){let{y:r,height:i}=e;return t==="top"?r+=n:t==="bottom"?r-=i+n:r-=i/2,r}function Jd(e,t,n,r){const{caretSize:i,caretPadding:s,cornerRadius:o}=e,{xAlign:a,yAlign:l}=n,c=i+s,{topLeft:u,topRight:d,bottomLeft:h,bottomRight:g}=er(o);let p=qj(t,a);const m=Xj(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(u,h)+i:a==="right"&&(p+=Math.max(d,g)+i),{x:ze(p,0,r.width-t.width),y:ze(m,0,r.height-t.height)}}function Ui(e,t,n){const r=ct(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function Qd(e){return St([],$t(e))}function Kj(e,t,n){return Tn(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function eh(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const dp={beforeTitle:kt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:kt,beforeBody:kt,beforeLabel:kt,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return be(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:kt,afterBody:kt,beforeFooter:kt,footer:kt,afterFooter:kt};function Ue(e,t,n,r){const i=e[t].call(n,r);return typeof i>"u"?dp[t].call(n,r):i}class da extends pt{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),i=r.enabled&&n.options.animation&&r.animations,s=new qg(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=Kj(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,i=Ue(r,"beforeTitle",this,t),s=Ue(r,"title",this,t),o=Ue(r,"afterTitle",this,t);let a=[];return a=St(a,$t(i)),a=St(a,$t(s)),a=St(a,$t(o)),a}getBeforeBody(t,n){return Qd(Ue(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,i=[];return ve(t,s=>{const o={before:[],lines:[],after:[]},a=eh(r,s);St(o.before,$t(Ue(a,"beforeLabel",this,s))),St(o.lines,Ue(a,"label",this,s)),St(o.after,$t(Ue(a,"afterLabel",this,s))),i.push(o)}),i}getAfterBody(t,n){return Qd(Ue(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,i=Ue(r,"beforeFooter",this,t),s=Ue(r,"footer",this,t),o=Ue(r,"afterFooter",this,t);let a=[];return a=St(a,$t(i)),a=St(a,$t(s)),a=St(a,$t(o)),a}_createItems(t){const n=this._active,r=this.chart.data,i=[],s=[],o=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(Wj(this.chart,n[l]));return t.filter&&(a=a.filter((u,d,h)=>t.filter(u,d,h,r))),t.itemSort&&(a=a.sort((u,d)=>t.itemSort(u,d,r))),ve(a,u=>{const d=eh(t.callbacks,u);i.push(Ue(d,"labelColor",this,u)),s.push(Ue(d,"labelPointStyle",this,u)),o.push(Ue(d,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=o,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),i=this._active;let s,o=[];if(!i.length)this.opacity!==0&&(s={opacity:0});else{const a=Br[r.position].call(this,i,this._eventPosition);o=this._createItems(r),this.title=this.getTitle(o,r),this.beforeBody=this.getBeforeBody(o,r),this.body=this.getBody(o,r),this.afterBody=this.getAfterBody(o,r),this.footer=this.getFooter(o,r);const l=this._size=Kd(this,r),c=Object.assign({},a,l),u=Zd(this.chart,r,c),d=Jd(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,s={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=o,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,i){const s=this.getCaretPosition(t,r,i);n.lineTo(s.x1,s.y1),n.lineTo(s.x2,s.y2),n.lineTo(s.x3,s.y3)}getCaretPosition(t,n,r){const{xAlign:i,yAlign:s}=this,{caretSize:o,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:d}=er(a),{x:h,y:g}=t,{width:p,height:m}=n;let b,v,y,S,w,x;return s==="center"?(w=g+m/2,i==="left"?(b=h,v=b-o,S=w+o,x=w-o):(b=h+p,v=b+o,S=w-o,x=w+o),y=b):(i==="left"?v=h+Math.max(l,u)+o:i==="right"?v=h+p-Math.max(c,d)-o:v=this.caretX,s==="top"?(S=g,w=S-o,b=v-o,y=v+o):(S=g+m,w=S+o,b=v+o,y=v-o),x=S),{x1:b,x2:v,x3:y,y1:S,y2:w,y3:x}}drawTitle(t,n,r){const i=this.title,s=i.length;let o,a,l;if(s){const c=tr(r.rtl,this.x,this.width);for(t.x=Ui(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",o=Ve(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=o.string,l=0;l<s;++l)n.fillText(i[l],c.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,l+1===s&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,i,s){const o=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=s,u=Ve(s.bodyFont),d=Ui(this,"left",s),h=i.x(d),g=l<u.lineHeight?(u.lineHeight-l)/2:0,p=n.y+g;if(s.usePointStyle){const m={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},b=i.leftForLtr(h,c)+c/2,v=p+l/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,oa(t,m,b,v),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,oa(t,m,b,v)}else{t.lineWidth=de(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const m=i.leftForLtr(h,c),b=i.leftForLtr(i.xPlus(h,1),c-2),v=er(o.borderRadius);Object.values(v).some(y=>y!==0)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,ws(t,{x:m,y:p,w:c,h:l,radius:v}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),ws(t,{x:b,y:p+1,w:c-2,h:l-2,radius:v}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(m,p,c,l),t.strokeRect(m,p,c,l),t.fillStyle=o.backgroundColor,t.fillRect(b,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:i}=this,{bodySpacing:s,bodyAlign:o,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,d=Ve(r.bodyFont);let h=d.lineHeight,g=0;const p=tr(r.rtl,this.x,this.width),m=function(M){n.fillText(M,p.x(t.x+g),t.y+h/2),t.y+=h+s},b=p.textAlign(o);let v,y,S,w,x,C,A;for(n.textAlign=o,n.textBaseline="middle",n.font=d.string,t.x=Ui(this,b,r),n.fillStyle=r.bodyColor,ve(this.beforeBody,m),g=a&&b!=="right"?o==="center"?c/2+u:c+2+u:0,w=0,C=i.length;w<C;++w){for(v=i[w],y=this.labelTextColors[w],n.fillStyle=y,ve(v.before,m),S=v.lines,a&&S.length&&(this._drawColorBox(n,t,w,p,r),h=Math.max(d.lineHeight,l)),x=0,A=S.length;x<A;++x)m(S[x]),h=d.lineHeight;ve(v.after,m)}g=0,h=d.lineHeight,ve(this.afterBody,m),t.y-=s}drawFooter(t,n,r){const i=this.footer,s=i.length;let o,a;if(s){const l=tr(r.rtl,this.x,this.width);for(t.x=Ui(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",o=Ve(r.footerFont),n.fillStyle=r.footerColor,n.font=o.string,a=0;a<s;++a)n.fillText(i[a],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+r.footerSpacing}}drawBackground(t,n,r,i){const{xAlign:s,yAlign:o}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:d,topRight:h,bottomLeft:g,bottomRight:p}=er(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+d,l),o==="top"&&this.drawCaret(t,n,r,i),n.lineTo(a+c-h,l),n.quadraticCurveTo(a+c,l,a+c,l+h),o==="center"&&s==="right"&&this.drawCaret(t,n,r,i),n.lineTo(a+c,l+u-p),n.quadraticCurveTo(a+c,l+u,a+c-p,l+u),o==="bottom"&&this.drawCaret(t,n,r,i),n.lineTo(a+g,l+u),n.quadraticCurveTo(a,l+u,a,l+u-g),o==="center"&&s==="left"&&this.drawCaret(t,n,r,i),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,i=r&&r.x,s=r&&r.y;if(i||s){const o=Br[t.position].call(this,this._active,this._eventPosition);if(!o)return;const a=this._size=Kd(this,t),l=Object.assign({},o,this._size),c=Zd(n,t,l),u=Jd(t,l,c,n);(i._to!==u.x||s._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const o=ct(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(s,t,i,n),Ug(t,n.textDirection),s.y+=o.top,this.drawTitle(s,t,n),this.drawBody(s,t,n),this.drawFooter(s,t,n),Gg(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,i=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),s=!vs(r,i),o=this._positionChanged(i,n);(s||o)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],o=this._getActiveElements(t,s,n,r),a=this._positionChanged(o,t),l=n||!vs(o,s)||a;return l&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,i){const s=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const o=this.chart.getElementsAtEventForMode(t,s.mode,s,r);return s.reverse&&o.reverse(),o}_positionChanged(t,n){const{caretX:r,caretY:i,options:s}=this,o=Br[s.position].call(this,t,n);return o!==!1&&(r!==o.x||i!==o.y)}}Q(da,"positioners",Br);var Zj={id:"tooltip",_element:da,positioners:Br,afterInit(e,t,n){n&&(e.tooltip=new da({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:dp},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Jj=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Qj(e,t,n,r){const i=e.indexOf(t);if(i===-1)return Jj(e,t,n,r);const s=e.lastIndexOf(t);return i!==s?n:i}const eF=(e,t)=>e===null?null:ze(Math.round(e),0,t);function th(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class ha extends br{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:i,label:s}of n)r[i]===s&&r.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(be(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:Qj(r,t,ae(n,t),this._addedLabels),eF(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(i=this.getLabels().length-1)),this.min=r,this.max=i}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,i=[];let s=this.getLabels();s=t===0&&n===s.length-1?s:s.slice(t,n+1),this._valueRange=Math.max(s.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let o=t;o<=n;o++)i.push({value:o});return i}getLabelForValue(t){return th.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}Q(ha,"id","category"),Q(ha,"defaults",{ticks:{callback:th}});function tF(e,t){const n=[],{bounds:i,step:s,min:o,max:a,precision:l,count:c,maxTicks:u,maxDigits:d,includeBounds:h}=e,g=s||1,p=u-1,{min:m,max:b}=t,v=!be(o),y=!be(a),S=!be(c),w=(b-m)/(d+1);let x=rd((b-m)/p/g)*g,C,A,M,R;if(x<1e-14&&!v&&!y)return[{value:m},{value:b}];R=Math.ceil(b/x)-Math.floor(m/x),R>p&&(x=rd(R*x/p/g)*g),be(l)||(C=Math.pow(10,l),x=Math.ceil(x*C)/C),i==="ticks"?(A=Math.floor(m/x)*x,M=Math.ceil(b/x)*x):(A=m,M=b),v&&y&&s&&wP((a-o)/s,x/1e3)?(R=Math.round(Math.min((a-o)/x,u)),x=(a-o)/R,A=o,M=a):S?(A=v?o:A,M=y?a:M,R=c-1,x=(M-A)/R):(R=(M-A)/x,Yr(R,Math.round(R),x/1e3)?R=Math.round(R):R=Math.ceil(R));const $=Math.max(id(x),id(A));C=Math.pow(10,be(l)?$:l),A=Math.round(A*C)/C,M=Math.round(M*C)/C;let I=0;for(v&&(h&&A!==o?(n.push({value:o}),A<o&&I++,Yr(Math.round((A+I*x)*C)/C,o,nh(o,w,e))&&I++):A<o&&I++);I<R;++I){const j=Math.round((A+I*x)*C)/C;if(y&&j>a)break;n.push({value:j})}return y&&h&&M!==a?n.length&&Yr(n[n.length-1].value,a,nh(a,w,e))?n[n.length-1].value=a:n.push({value:a}):(!y||M===a)&&n.push({value:M}),n}function nh(e,t,{horizontal:n,minRotation:r}){const i=jt(r),s=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(""+e).length;return Math.min(t/s,o)}class nF extends br{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return be(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:i,max:s}=this;const o=l=>i=n?i:l,a=l=>s=r?s:l;if(t){const l=At(i),c=At(s);l<0&&c<0?a(0):l>0&&c>0&&o(0)}if(i===s){let l=s===0?1:Math.abs(s*.05);a(s+l),t||o(i-l)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,i;return r?(i=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const i={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},s=this._range||this,o=tF(i,s);return t.bounds==="ticks"&&_P(o,this,"value"),t.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const i=(r-n)/Math.max(t.length-1,1)/2;n-=i,r+=i}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return Cl(t,this.chart.options.locale,this.options.ticks.format)}}class fa extends nF{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=lt(t)?t:0,this.max=lt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=jt(this.options.ticks.minRotation),i=(t?Math.sin(r):Math.cos(r))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}Q(fa,"id","linear"),Q(fa,"defaults",{ticks:{callback:jg.formatters.numeric}});const Ks={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Ge=Object.keys(Ks);function rh(e,t){return e-t}function ih(e,t){if(be(t))return null;const n=e._adapter,{parser:r,round:i,isoWeekday:s}=e._parseOpts;let o=t;return typeof r=="function"&&(o=r(o)),lt(o)||(o=typeof r=="string"?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i==="week"&&(ii(s)||s===!0)?n.startOf(o,"isoWeek",s):n.startOf(o,i)),+o)}function sh(e,t,n,r){const i=Ge.length;for(let s=Ge.indexOf(e);s<i-1;++s){const o=Ks[Ge[s]],a=o.steps?o.steps:Number.MAX_SAFE_INTEGER;if(o.common&&Math.ceil((n-t)/(a*o.size))<=r)return Ge[s]}return Ge[i-1]}function rF(e,t,n,r,i){for(let s=Ge.length-1;s>=Ge.indexOf(n);s--){const o=Ge[s];if(Ks[o].common&&e._adapter.diff(i,r,o)>=t-1)return o}return Ge[n?Ge.indexOf(n):0]}function iF(e){for(let t=Ge.indexOf(e)+1,n=Ge.length;t<n;++t)if(Ks[Ge[t]].common)return Ge[t]}function oh(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:i}=wl(n,t),s=n[r]>=t?n[r]:n[i];e[s]=!0}}function sF(e,t,n,r){const i=e._adapter,s=+i.startOf(t[0].value,r),o=t[t.length-1].value;let a,l;for(a=s;a<=o;a=+i.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function ah(e,t,n){const r=[],i={},s=t.length;let o,a;for(o=0;o<s;++o)a=t[o],i[a]=o,r.push({value:a,major:!1});return s===0||!n?r:sF(e,r,i,n)}class Es extends br{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),i=this._adapter=new aL._date(t.adapters.date);i.init(n),Gr(r.displayFormats,i.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:ih(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:i,max:s,minDefined:o,maxDefined:a}=this.getUserBounds();function l(c){!o&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(s=Math.max(s,c.max))}(!o||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=lt(i)&&!isNaN(i)?i:+n.startOf(Date.now(),r),s=lt(s)&&!isNaN(s)?s:+n.endOf(Date.now(),r)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,i=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,o=this.max,a=MP(i,s,o);return this._unit=n.unit||(r.autoSkip?sh(n.minUnit,this.min,this.max,this._getLabelCapacity(s)):rF(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:iF(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),ah(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,i,s;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,s=this.getDecimalForValue(t[t.length-1]),t.length===1?r=s:r=(s-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;n=ze(n,0,o),r=ze(r,0,o),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,i=this.options,s=i.time,o=s.unit||sh(s.minUnit,n,r,this._getLabelCapacity(n)),a=ae(i.ticks.stepSize,1),l=o==="week"?s.isoWeekday:!1,c=ii(l)||l===!0,u={};let d=n,h,g;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":o),t.diff(r,n,o)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+o);const p=i.ticks.source==="data"&&this.getDataTimestamps();for(h=d,g=0;h<r;h=+t.add(h,a,o),g++)oh(u,h,p);return(h===r||i.bounds==="ticks"||g===1)&&oh(u,h,p),Object.keys(u).sort(rh).map(m=>+m)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,s=this._unit,o=n||i[s];return this._adapter.format(t,o)}_tickFormatFunction(t,n,r,i){const s=this.options,o=s.ticks.callback;if(o)return Ae(o,[t,n,r],this);const a=s.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],d=c&&a[c],h=r[n],g=c&&d&&h&&h.major;return this._adapter.format(t,i||(g?d:u))}generateTickLabels(t){let n,r,i;for(n=0,r=t.length;n<r;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,i=jt(this.isHorizontal()?n.maxRotation:n.minRotation),s=Math.cos(i),o=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:r*s+a*o,h:r*o+a*s}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,i=r[n.unit]||r.millisecond,s=this._tickFormatFunction(t,0,ah(this,[t],this._majorUnit),i),o=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,r=i.length;n<r;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const i=this.getLabels();for(n=0,r=i.length;n<r;++n)t.push(ih(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return $g(t.sort(rh))}}Q(Es,"id","time"),Q(Es,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function Gi(e,t,n){let r=0,i=e.length-1,s,o,a,l;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=fn(e,"pos",t)),{pos:s,time:a}=e[r],{pos:o,time:l}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=fn(e,"time",t)),{time:s,pos:a}=e[r],{time:o,pos:l}=e[i]);const c=o-s;return c?a+(l-a)*(t-s)/c:a}class lh extends Es{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=Gi(n,this.min),this._tableRange=Gi(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,i=[],s=[];let o,a,l,c,u;for(o=0,a=t.length;o<a;++o)c=t[o],c>=n&&c<=r&&i.push(c);if(i.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(o=0,a=i.length;o<a;++o)u=i[o+1],l=i[o-1],c=i[o],Math.round((u+l)/2)!==c&&s.push({time:c,pos:o/(a-1)});return s}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((i,s)=>i-s)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(Gi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return Gi(this._table,r*this._tableRange+this._minPos,!0)}}Q(lh,"id","timeseries"),Q(lh,"defaults",Es.defaults);const hp="label";function ch(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function oF(e,t){const n=e.options;n&&t&&Object.assign(n,t)}function fp(e,t){e.labels=t}function gp(e,t,n=hp){const r=[];e.datasets=t.map(i=>{const s=e.datasets.find(o=>o[n]===i[n]);return!s||!i.data||r.includes(s)?{...i}:(r.push(s),Object.assign(s,i),s)})}function aF(e,t=hp){const n={labels:[],datasets:[]};return fp(n,e.labels),gp(n,e.datasets,t),n}function lF(e,t){const{height:n=150,width:r=300,redraw:i=!1,datasetIdKey:s,type:o,data:a,options:l,plugins:c=[],fallbackContent:u,updateMode:d,...h}=e,g=f.useRef(null),p=f.useRef(null),m=()=>{g.current&&(p.current=new Xs(g.current,{type:o,data:aF(a,s),options:l&&{...l},plugins:c}),ch(t,p.current))},b=()=>{ch(t,null),p.current&&(p.current.destroy(),p.current=null)};return f.useEffect(()=>{!i&&p.current&&l&&oF(p.current,l)},[i,l]),f.useEffect(()=>{!i&&p.current&&fp(p.current.config.data,a.labels)},[i,a.labels]),f.useEffect(()=>{!i&&p.current&&a.datasets&&gp(p.current.config.data,a.datasets,s)},[i,a.datasets]),f.useEffect(()=>{p.current&&(i?(b(),setTimeout(m)):p.current.update(d))},[i,l,a.labels,a.datasets,d]),f.useEffect(()=>{p.current&&(b(),setTimeout(m))},[o]),f.useEffect(()=>(m(),()=>b()),[]),_.jsx("canvas",{ref:g,role:"img",height:n,width:r,...h,children:u})}const cF=f.forwardRef(lF);function Zs(e,t){return Xs.register(t),f.forwardRef((n,r)=>_.jsx(cF,{...n,ref:r,type:e}))}const uF=Zs("line",Ki),dF=Zs("bar",Xi),uh=Zs("doughnut",Jn),dh=Zs("pie",aa);Xs.register(ha,fa,es,Hr,Qi,Vj,Zj,Bj,Nr);const hF=50,kr=10,_t=10,Lo=100,jo=1e4,ci=20,hh=50,fF=({title:e})=>{var C;const t=Ms(),n=di(),r=ui(),[i,s]=f.useState("auto"),[o,a]=f.useState("bar"),l=(A,M,R)=>{if(A.fromArrayData){const $=M[R.fromArray];if($&&$[A.fromArrayData.index])return $[A.fromArrayData.index][R.id]}else return M[R.id]},c=A=>{if(typeof A=="number")return A;if(typeof A=="string"){const M=parseFloat(A);return isNaN(M)?null:M}return null},u=f.useMemo(()=>{if(t.length===0||t.length>jo)return{raw:!1,distribution:!1,frequency:!1,summary:!1};let A=!1,M=!1;const R=new Set;for(const F of t){const re=n[F.rowIndex],J=r[F.columnIndex];if(!re||!J)continue;const E=l(F,re,J),T=c(E);T!==null?(A=!0,R.add(T)):E!=null&&E!==""&&(M=!0)}const $=new Set(t.map(F=>F.columnIndex)).size,I=new Set(t.map(F=>F.rowIndex)).size,j=$*I,q=A&&j>1,Z=A&&R.size>1;return{raw:q,distribution:Z,frequency:A||M,summary:A}},[t,n,r]),{chartData:d,chartTitle:h,stats:g,effectiveMode:p,isStringData:m,warning:b}=f.useMemo(()=>{if(t.length>jo)return{chartData:null,chartTitle:e||"Selection Data",stats:null,effectiveMode:"auto",isStringData:!1,warning:{type:"too_large",message:`Selection too large (${t.length.toLocaleString()} cells). Please select fewer than ${jo.toLocaleString()} cells.`,originalCount:t.length}};if(t.length===0)return{chartData:null,chartTitle:e||"Selection Data",stats:null,effectiveMode:"auto",isStringData:!1,warning:null};const A=[...new Set(t.map(J=>J.columnIndex))].sort((J,E)=>J-E),M=[...new Set(t.map(J=>J.rowIndex))].sort((J,E)=>J-E),R=[],$=[],I=new Map;t.forEach(J=>{const E=n[J.rowIndex],T=r[J.columnIndex];if(!E||!T)return;const P=l(J,E,T);R.push({value:P,colIndex:J.columnIndex});const L=c(P);L!==null&&($.push(L),I.has(J.columnIndex)||I.set(J.columnIndex,[]),I.get(J.columnIndex).push(L))});const j=$.length>0,q=t.length>hF,Z=!j;let W=i;i==="auto"?j?q?W="distribution":W="raw":W="frequency":i==="raw"&&!u.raw||i==="distribution"&&!u.distribution||i==="summary"&&!u.summary?W=u.frequency?"frequency":"auto":i==="frequency"&&!u.frequency&&(W="auto");const X=j?pp($):null,F=null;if(W==="summary"&&X)return{...pF(X,r,A,e,I),stats:X,effectiveMode:W,isStringData:Z,warning:F};if(W==="distribution"&&j)return{...gF($,r,A,e,I),stats:X,effectiveMode:W,isStringData:Z,warning:F};if(!j||W==="frequency")return{...bF(R,A,r,e),stats:X,effectiveMode:"frequency",isStringData:Z,warning:F};const re=mF(t,n,r,A,M,l,c,e);return{...re,stats:X,effectiveMode:"raw",isStringData:Z,warning:re.warning}},[t,n,r,e,i,u]),v=f.useMemo(()=>{var A;return{responsive:!0,maintainAspectRatio:!1,animation:{duration:t.length>100?0:400},plugins:{legend:{position:"top",display:(((A=d==null?void 0:d.datasets)==null?void 0:A.length)??0)<=10},title:{display:!!h,text:h}},scales:{y:{beginAtZero:!0}}}},[h,t.length,(C=d==null?void 0:d.datasets)==null?void 0:C.length]),y=f.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,animation:{duration:t.length>100?0:400},plugins:{legend:{position:"right",display:!0},title:{display:!!h,text:h},tooltip:{callbacks:{label:A=>{const M=A.label||"",R=A.raw||0,$=A.dataset.data.reduce((j,q)=>j+q,0),I=(R/$*100).toFixed(1);return`${M}: ${R} (${I}%)`}}}}}),[h,t.length]),S=A=>{if(!(A==="auto"||u[A]))switch(A){case"raw":return"Raw mode requires numeric data with multiple data points";case"distribution":return"Distribution mode requires numeric data with varied values";case"summary":return"Summary mode requires numeric data";case"frequency":return"No data available for frequency analysis";default:return}},w=f.useMemo(()=>{if(!m||!d)return null;if(d.datasets.length===1)return{labels:d.labels,datasets:[{data:d.datasets[0].data,backgroundColor:d.labels.map(($,I)=>Oe(I,.7)),borderColor:d.labels.map(($,I)=>Oe(I,1)),borderWidth:1}]};const A=new Map;d.datasets.forEach($=>{A.set($.label,$.data.reduce((I,j)=>I+(j||0),0))});const M=[...A.keys()],R=[...A.values()];return{labels:M,datasets:[{data:R,backgroundColor:M.map(($,I)=>Oe(I,.7)),borderColor:M.map(($,I)=>Oe(I,1)),borderWidth:1}]}},[d,m]);if((b==null?void 0:b.type)==="too_large")return _.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500 p-4",children:[_.jsxs("div",{className:"text-red-500 text-center mb-2",children:[_.jsx("svg",{className:"w-12 h-12 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,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"})}),_.jsx("p",{className:"font-semibold",children:"Selection Too Large"})]}),_.jsx("p",{className:"text-sm text-center",children:b.message}),_.jsx("p",{className:"text-xs text-gray-400 mt-2",children:"Try selecting a smaller range or use column headers to select entire columns (which will use aggregated views)."})]});if(!d||d.datasets.length===0)return _.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Select cells to display a chart"});const x=()=>{if(m&&(o==="pie"||o==="doughnut")){const A=w||d;return o==="pie"?_.jsx(dh,{data:A,options:y}):_.jsx(uh,{data:A,options:y})}switch(o){case"line":return _.jsx(uF,{data:d,options:v});case"pie":return _.jsx(dh,{data:w||d,options:y});case"doughnut":return _.jsx(uh,{data:w||d,options:y});default:return _.jsx(dF,{data:d,options:v})}};return _.jsxs("div",{className:"w-full h-full flex flex-col",children:[_.jsx("div",{className:"flex gap-1 px-2 pt-2 flex-wrap",children:["auto","raw","distribution","frequency","summary"].map(A=>{const M=A!=="auto"&&!u[A],R=S(A);return _.jsxs("button",{onClick:()=>!M&&s(A),disabled:M,title:R,className:`px-2 py-1 text-xs rounded transition-colors ${i===A?"bg-blue-500 text-white":M?"bg-gray-100 text-gray-400 cursor-not-allowed opacity-50":"bg-gray-100 hover:bg-gray-200 text-gray-700"}`,children:[A.charAt(0).toUpperCase()+A.slice(1),A==="auto"&&` (${p})`]},A)})}),_.jsx("div",{className:"flex gap-1 px-2 pt-1 flex-wrap",children:["bar","line","pie","doughnut"].map(A=>_.jsx("button",{onClick:()=>a(A),className:`px-2 py-1 text-xs rounded ${o===A?"bg-green-500 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700"}`,children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),(b==null?void 0:b.type)==="truncated"&&_.jsxs("div",{className:"mx-2 mt-2 px-3 py-2 bg-amber-50 border border-amber-200 rounded text-xs text-amber-700",children:[_.jsx("span",{className:"font-semibold",children:"⚠ Data truncated:"})," ",b.message]}),g&&_.jsxs("div",{className:"flex gap-3 px-4 py-2 text-xs text-gray-600 flex-wrap",children:[_.jsxs("span",{children:["Count: ",g.count]}),_.jsxs("span",{children:["Min: ",g.min.toFixed(2)]}),_.jsxs("span",{children:["Max: ",g.max.toFixed(2)]}),_.jsxs("span",{children:["Mean: ",g.mean.toFixed(2)]}),_.jsxs("span",{children:["Median: ",g.median.toFixed(2)]})]}),_.jsx("div",{className:"flex-1 min-h-[250px] p-2",children:x()})]})},pp=e=>{const t=[...e].sort((l,c)=>l-c),n=e.length,i=e.reduce((l,c)=>l+c,0)/n,s=n%2===0?(t[n/2-1]+t[n/2])/2:t[Math.floor(n/2)],o=e.reduce((l,c)=>l+Math.pow(c-i,2),0)/n,a=Math.sqrt(o);return{count:n,min:t[0],max:t[n-1],mean:i,median:s,stdDev:a}},gF=(e,t,n,r,i)=>{var g,p;const s=n.slice(0,ci);if(s.length>1&&i&&i.size>0){const m=[];i.forEach(C=>{m.push(...C)});const b=Math.min(...m),S=(Math.max(...m)-b)/_t||1,w=[];for(let C=0;C<_t;C++){const A=b+C*S,M=b+(C+1)*S;w.push(`${A.toFixed(1)}-${M.toFixed(1)}`)}const x=s.map((C,A)=>{const M=i.get(C)||[],R=new Array(_t).fill(0);M.forEach(j=>{let q=Math.floor((j-b)/S);q>=_t&&(q=_t-1),q<0&&(q=0),R[q]++});const $=t[C];return{label:($==null?void 0:$.text)||($==null?void 0:$.id)||`Column ${C+1}`,data:R,backgroundColor:Oe(A,.6),borderColor:Oe(A,1),borderWidth:1}});return{chartData:{labels:w,datasets:x},chartTitle:r||"Distribution by Column"}}const o=Math.min(...e),c=(Math.max(...e)-o)/_t||1,u=new Array(_t).fill(0),d=[];for(let m=0;m<_t;m++){const b=o+m*c,v=o+(m+1)*c;d.push(`${b.toFixed(1)}-${v.toFixed(1)}`)}e.forEach(m=>{let b=Math.floor((m-o)/c);b>=_t&&(b=_t-1),b<0&&(b=0),u[b]++});const h=n.length===1?((g=t[n[0]])==null?void 0:g.text)||((p=t[n[0]])==null?void 0:p.id)||"Values":"Selection";return{chartData:{labels:d,datasets:[{label:"Frequency",data:u,backgroundColor:Oe(0,.6),borderColor:Oe(0,1),borderWidth:1}]},chartTitle:r||`${h} - Distribution`}},pF=(e,t,n,r,i)=>{var u,d;const s=["Min","Q1 (est)","Median","Q3 (est)","Max","Mean"],o=n.slice(0,ci);if(o.length>1&&i&&i.size>0){const h=o.map((g,p)=>{var x,C;const m=i.get(g);if(!m||m.length===0)return{label:((x=t[g])==null?void 0:x.text)||((C=t[g])==null?void 0:C.id)||`Column ${g+1}`,data:[0,0,0,0,0,0],backgroundColor:Oe(p,.6),borderColor:Oe(p,1),borderWidth:1};const b=pp(m),v=b.median-b.stdDev*.675,y=b.median+b.stdDev*.675,S=t[g];return{label:(S==null?void 0:S.text)||(S==null?void 0:S.id)||`Column ${g+1}`,data:[b.min,v,b.median,y,b.max,b.mean],backgroundColor:Oe(p,.6),borderColor:Oe(p,1),borderWidth:1}});return{chartData:{labels:s,datasets:h},chartTitle:r||"Summary Statistics by Column"}}const a=e.median-e.stdDev*.675,l=e.median+e.stdDev*.675,c=n.length===1?((u=t[n[0]])==null?void 0:u.text)||((d=t[n[0]])==null?void 0:d.id)||"Values":"Selection";return{chartData:{labels:s,datasets:[{label:c,data:[e.min,a,e.median,l,e.max,e.mean],backgroundColor:s.map((h,g)=>Oe(g,.6)),borderColor:s.map((h,g)=>Oe(g,1)),borderWidth:1}]},chartTitle:r||`${c} - Summary Statistics`}},mF=(e,t,n,r,i,s,o,a)=>{const l=r.length>=i.length,c=r.length*i.length;let u=null,d=r,h=i;if(c>Lo){if(l){const p=Math.min(hh,i.length),m=Math.min(ci,Math.floor(Lo/p));h=i.slice(0,p),d=r.slice(0,m)}else{const p=Math.min(hh,r.length),m=Math.min(ci,Math.floor(Lo/p));d=r.slice(0,p),h=i.slice(0,m)}const g=d.length*h.length;u={type:"truncated",message:`Showing ${g.toLocaleString()} of ${c.toLocaleString()} data points. Use Distribution or Summary mode for full data analysis.`,originalCount:c,displayedCount:g}}if(l){const g=h.map(m=>{const b=t[m],v=n.find(y=>typeof b[y.id]=="string"&&!r.includes(n.indexOf(y)));return v?String(b[v.id]):`Row ${m+1}`}),p=d.map((m,b)=>{const v=n[m],y=h.map(S=>{const w=e.find(C=>C.rowIndex===S&&C.columnIndex===m);if(!w)return null;const x=s(w,t[S],v);return o(x)});return{label:(v==null?void 0:v.text)||(v==null?void 0:v.id)||`Column ${m+1}`,data:y,backgroundColor:Oe(b,.6),borderColor:Oe(b,1),borderWidth:1}});return{chartData:{labels:g,datasets:p},chartTitle:a||"Selection Data",warning:u}}else{const g=d.map(m=>{const b=n[m];return(b==null?void 0:b.text)||(b==null?void 0:b.id)||`Column ${m+1}`}),p=h.map((m,b)=>{const v=t[m],y=n.find(x=>typeof v[x.id]=="string"&&!r.includes(n.indexOf(x))),S=y?String(v[y.id]):`Row ${m+1}`,w=d.map(x=>{const C=e.find(R=>R.rowIndex===m&&R.columnIndex===x);if(!C)return null;const A=n[x],M=s(C,v,A);return o(M)});return{label:S,data:w,backgroundColor:Oe(b,.6),borderColor:Oe(b,1),borderWidth:1}});return{chartData:{labels:g,datasets:p},chartTitle:a||"Selection Data",warning:u}}},bF=(e,t,n,r)=>{const i={};if(e.forEach(({value:d,colIndex:h})=>{i[h]||(i[h]=[]),i[h].push(d)}),t.length===1){const d=t[0],h=i[d]||[],g=n[d],p=new Map;h.forEach(w=>{const x=w==null||w===""?"(empty)":String(w);p.set(x,(p.get(x)||0)+1)});let m=[...p.entries()].sort((w,x)=>x[1]-w[1]);if(m.length>kr){const w=m.slice(0,kr-1),x=m.slice(kr-1).reduce((C,[,A])=>C+A,0);m=[...w,["Others",x]]}const b=m.map(([w])=>w),y=[{label:"Count",data:m.map(([,w])=>w),backgroundColor:b.map((w,x)=>Oe(x,.6)),borderColor:b.map((w,x)=>Oe(x,1)),borderWidth:1}],S=(g==null?void 0:g.text)||(g==null?void 0:g.id)||"Values";return{chartData:{labels:b,datasets:y},chartTitle:r||`${S} - Frequency`}}const s=t.slice(0,ci),o=s.map(d=>{const h=n[d];return(h==null?void 0:h.text)||(h==null?void 0:h.id)||`Column ${d+1}`}),a=new Set;Object.values(i).forEach(d=>{d.forEach(h=>{const g=h==null||h===""?"(empty)":String(h);a.add(g)})});let l=[...a];if(l.length>kr){const d=new Map;Object.values(i).forEach(h=>{h.forEach(g=>{const p=g==null||g===""?"(empty)":String(g);d.set(p,(d.get(p)||0)+1)})}),l=[...d.entries()].sort((h,g)=>g[1]-h[1]).slice(0,kr-1).map(([h])=>h),l.push("Others")}const u=l.map((d,h)=>{const g=s.map(p=>{const m=i[p]||[];return d==="Others"?m.filter(b=>{const v=b==null||b===""?"(empty)":String(b);return!l.slice(0,-1).includes(v)}).length:m.filter(b=>(b==null||b===""?"(empty)":String(b))===d).length});return{label:d,data:g,backgroundColor:Oe(h,.6),borderColor:Oe(h,1),borderWidth:1}});return{chartData:{labels:o,datasets:u},chartTitle:r||"Value Frequency by Column"}},fh=["rgb(59, 130, 246)","rgb(239, 68, 68)","rgb(34, 197, 94)","rgb(234, 179, 8)","rgb(168, 85, 247)","rgb(249, 115, 22)","rgb(20, 184, 166)","rgb(236, 72, 153)","rgb(107, 114, 128)"],Oe=(e,t)=>fh[e%fh.length].replace("rgb","rgba").replace(")",`, ${t})`);function vF(){const e=Eg(),t=yn();return{getHeaderActions:(r,i,s,o)=>{const a=[];return r.sortable&&a.push({icon:Xp,iconColor:"#444",text:"Sort",onClick:()=>i(r)}),a.push({icon:Kl,iconColor:"var(--comment-color)",text:"Choose columns",onClick:l=>{e.openDialog({x:l.clientX||100,y:l.clientY||100},"Choose Columns",Kl,"var(--comment-color)",_.jsx(H$,{}))}}),a.push({icon:Kp,iconColor:"#444",text:"Reset columns",onClick:()=>{t.setHiddenHeadersId([])}}),a.push({icon:Xl,iconColor:"#2baf2b",text:"Chart range",onClick:l=>{e.openDialog({x:l.clientX||100,y:l.clientY||100},"Chart range",Xl,"#2baf2b",_.jsx(fF,{selectedHeader:r}))}}),a}}}const xF={position:"fixed",zIndex:1e3,background:"#fff",border:"1px solid #ccc",borderRadius:4,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",minWidth:160};function yF(e){const t=f.useRef(null),[n,r]=f.useState({left:e.x,top:e.y}),{getCellActions:i}=iI(),{getHeaderActions:s}=vF(),{setHighlightCondition:o,removeHighlightCondition:a,getItemsFromCellCoordinates:l}=wn(),c=Ms();f.useEffect(()=>{const g=p=>{t.current&&!t.current.contains(p.target)&&e.onClose()};return window.addEventListener("mousedown",g),()=>window.removeEventListener("mousedown",g)},[e.onClose]),f.useEffect(()=>{if(t.current){const{innerWidth:g,innerHeight:p}=window,m=t.current.getBoundingClientRect();let b=e.x,v=e.y;b+m.width>g&&(b=g-m.width-8),v+m.height>p&&(v=p-m.height-8),b=Math.max(b,8),v=Math.max(v,8),r({left:b,top:v})}},[e.x,e.y]);const u=(g,p)=>{g.preventDefault(),p.onClick(g,e.item,e.itemCoordinate),e.onClose()},h=(()=>{if(e.item===void 0)return s(e.header,()=>{},()=>{},()=>{});const g=l(c);return i(e.item,e.itemCoordinate,g,e.header.id,o,a,e.onClose)})();return _.jsx("div",{ref:t,style:{...xF,left:n.left,top:n.top},children:_.jsx("ul",{className:"menu menu-sm p-0.5 bg-base-200 rounded-box min-w-55 max-w-xs w-full",children:h.map((g,p)=>_.jsx(f.Fragment,{children:_.jsx("li",{onClick:m=>u(m,g),children:_.jsxs("a",{children:[g.icon&&_.jsx(ft,{path:g.icon,color:g.iconColor,size:.7}),g.text,g.customRender&&g.customRender()]})})},p))})})}function wF(e){return _.jsx(_.Fragment,{children:e.header.customRender(e.item,e.header,e.fromArrayData,e.isDisabled)})}function _F(e){const{comment:t,style:n,isEditing:r,onMouseEnter:i,setIsEditing:s,onMouseLeave:o}=e,[a,l]=f.useState((t==null?void 0:t.text)||""),{setOpenCommentCell:c}=cl(),u=xn(),d=()=>{e.saveComment&&(e.saveComment({...t,text:a,columnId:e.columnId,author:(u==null?void 0:u.currentUsername)||"Unknown"}),e.isNewComment&&c(void 0),s==null||s(!1))},h=()=>{e.isNewComment&&c(void 0),l(t.text),s==null||s(!1)},g=f.useMemo(()=>(t.author||(u==null?void 0:u.currentUsername)||"Unknown").split(" ").map(m=>m.charAt(0).toUpperCase()).join("").slice(0,2),[t.author]);return _.jsxs("div",{style:n,onMouseEnter:i,onMouseLeave:o,children:[_.jsxs("div",{className:"flex justify-between mb-2",children:[_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx("div",{className:"avatar avatar-placeholder w-5",children:_.jsx("div",{className:"bg-neutral text-neutral-content w-5 rounded-full",children:_.jsx("span",{className:"text-xs",children:g})})}),_.jsx("div",{children:_.jsx("span",{className:"text-xs font-bold",children:(e.isNewComment?u==null?void 0:u.currentUsername:t.author)||"Unknown"})})]}),_.jsx("div",{children:!r&&_.jsxs("div",{children:[_.jsx(st,{onClick:()=>{var p;return(p=e.deleteComment)==null?void 0:p.call(e,t)},className:"mb-1 h-5 min-h-5",iconSize:.6,small:!0,circle:!0,icon:Zp,iconColor:"var(--error-color)"}),_.jsx(st,{onClick:()=>s==null?void 0:s(!0),className:"mb-1 ml-1 h-5 min-h-5",iconSize:.6,small:!0,circle:!0,icon:Yp,iconColor:"var(--comment-color)"})]})})]}),_.jsx("div",{className:"ml-7",children:r?_.jsxs("div",{children:[_.jsx("input",{onMouseUp:p=>{p.stopPropagation()},onClick:p=>{p.stopPropagation()},onMouseDown:p=>{p.stopPropagation()},onKeyDown:p=>{p.stopPropagation()},className:"input input-xs",type:"text",value:a,onChange:p=>l(p.target.value)}),_.jsxs("div",{className:"flex justify-end mt-2",children:[_.jsx(st,{onClick:d,text:"Save",className:"mb-1 h-5 min-h-5 ",iconSize:.6,small:!0,icon:Fp,iconColor:"var(--comment-color)"}),_.jsx(st,{onClick:h,className:"mb-1 h-5 min-h-5 ml-1",ghost:!0,iconSize:.6,small:!0,icon:_h,text:"Cancel",iconColor:"var(--error-color)"})]})]}):_.jsx("div",{className:"text-xs ",children:_.jsxs("div",{children:[_.jsx("div",{children:t.text}),_.jsx("span",{className:"text-gray-500 font-light text-tiny",children:t.formatDateFunction?t.formatDateFunction(t.date):new Date(t.date).toLocaleString()})]})})})]})}function SF(e){return _.jsx("div",{className:"flex",children:_.jsxs("button",{className:`px-2 cursor-pointer grow-1 text-left hover:bg-gray-100 p-1 truncate whitespace-nowrap overflow-ellipsis ${e.italic?"italic text-gray-400":""} ${e.isSelected?"bg-[var(--primary-color_background)] rounded":""}`,onClick:()=>e.onClick(e.value,e.isOptionToAdd),children:[e.isOptionToAdd&&_.jsx("strong",{children:"Add "}),e.text]},"0-empty-option")},e.optionKey)}const mp=rn(e=>({tableRef:f.createRef(),scrollRef:f.createRef(),actions:{setTableRef:t=>e({tableRef:t}),setScrollRef:t=>e({scrollRef:t})}})),CF=()=>mp(e=>e.scrollRef),EF=()=>mp(e=>e.actions);function AF(e){const[t,n]=f.useState(!1),[r,i]=f.useState(""),[s,o]=f.useState(),a=f.useRef(null),l=xn(),{addListOption:c}=wn(),u=f.useMemo(()=>{var M;const C=[];C.push({value:"",toAdd:!1}),r&&(l!=null&&l.canAddListOptions)&&((M=e.header.editOptions)==null?void 0:M.canAddNewOption)!==!1&&!e.options.some(R=>R.toLowerCase()===r.toLowerCase())&&C.push({value:r,toAdd:!0});let A=[];return r===""||e.options.includes(r)?A=e.options.map(R=>({value:R,toAdd:!1})):A=e.options.filter(R=>r===""||e.options.includes(r)||R.toLowerCase().includes(r.toLowerCase())).map(R=>({value:R,toAdd:!1})),C.push(...A),C},[e.options,r,l==null?void 0:l.canAddListOptions]);f.useEffect(()=>{i(e.value||"")},[e.value]),f.useEffect(()=>{},[u]),f.useEffect(()=>{if(t&&s!==void 0&&a.current){const C=a.current,A=C.children[s];if(A){const M=C.scrollTop,R=M+C.clientHeight,$=A.offsetTop,I=$+A.offsetHeight;$<M?C.scrollTop=$:I>R&&(C.scrollTop=I-C.clientHeight)}}},[s,t]);const d=async(C,A)=>{A&&await c(C,e.header),e.onSelect(C),n(!1)},h=async(C,A)=>{A&&await c(C,e.header),e.onEnter(C),n(!1)},g=async C=>{if(C.key==="ArrowDown"||C.key==="ArrowUp"){if(C.preventDefault(),n(!0),u.length>0){let A=(s??-1)+(C.key==="ArrowDown"?1:-1);A<0?A=u.length-1:A>=u.length&&(A=0),o(A)}}else C.key==="Enter"&&(C.preventDefault(),C.stopPropagation(),t&&s!==void 0?await h(u[s].value,u[s].toAdd&&(l==null?void 0:l.canAddListOptions)):r&&[...e.options,""].includes(r)?await h(r,!1):console.log("Input does not match any option"))},p={width:"100%",outline:"none",border:"none",background:"transparent"},m=C=>{i(C.target.value),n(!0)},b=f.useRef(null),v=f.useRef(null),y=CF(),[S,w]=f.useState({left:"-8px",top:"23px"});f.useEffect(()=>{x()},[t,y]);const x=()=>{if(t&&b.current&&v.current&&y.current){const C=b.current.getBoundingClientRect(),A=v.current.getBoundingClientRect(),M=y.current.getBoundingClientRect(),R=C.left-M.left,$=C.top-M.top,I=R+A.width>y.current.clientWidth,j=$+A.height>y.current.clientHeight,q={left:I?`${-A.width+C.width}px`:"-8px",top:j?`${-A.height}px`:"23px"};w(q)}};return _.jsxs("div",{className:"relative ",ref:b,children:[_.jsxs("div",{className:"flex justify-between min-h-4",onClick:()=>{n(!t)},children:[_.jsx("input",{ref:e.inputRef,type:"text",value:r,onChange:m,onKeyDown:g,required:!0,style:p}),_.jsx("button",{className:"ml-1 w-0 h-0",style:{borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid #888",marginTop:"4px"},"aria-label":"dropdown indicator"})]}),t&&!e.hideOptions&&_.jsx("div",{ref:v,className:"absolute bg-base-100 border border-[var(--border-color)] z-300 w-52 p-1 shadow-sm",style:{left:S.left,top:S.top},children:_.jsx("div",{ref:a,className:"max-h-46 overflow-auto",children:u.map((C,A)=>_.jsx(f.Fragment,{children:_.jsx(SF,{optionKey:A+"-"+C,onClick:(M,R)=>{d(M,R)},isOptionToAdd:(l==null?void 0:l.canAddListOptions)&&C.toAdd===!0,value:C.value,text:C.value===""?"<Empty>":C.value,italic:C.value==="",isSelected:s===A})},A+"-"+C.value))})})]})}const ts=(e,t=5)=>{const n=typeof e=="string"?parseFloat(e):e;if(!Number.isFinite(n))return"";const r=Math.pow(10,t);return(Math.round(n*r)/r).toFixed(t).replace(/\.?0+$/,"")};function MF(e){const[t,n]=f.useState(ts(e.initialValue??""));f.useEffect(()=>{n(ts(e.initialValue??""))},[e.initialValue]);const r=s=>{s.key==="Escape"&&n(ts(e.cellValue??""))},i={width:"100%",outline:"none",border:"none",background:"transparent"};return _.jsx("input",{id:e.id,ref:e.inputRef,className:"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",type:"string",inputMode:"decimal",value:t,onKeyDown:r,onChange:s=>{n(s.target.value),e.onChange(s)},onBlur:e.onBlur,style:i})}const OF="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAQAAAC0NkA6AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAD/h4/MvwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+kLGQkCJz+zJYgAAARbSURBVFjDndjfb1RFFMDx77k7FRoMaNQYazWxoYIxghYhMZFoFROq/e0upVggGp8t/hO+Ukh8IhEatb92W6BpsoViINEHfYCixmC19AWCifGhECml7d7jw/7o/THX3tt9nNnZz52ZM+eeHSHwOQEgdLO8nDUc87fD8xxhgLne4Ag4RDVnKKz2nEQBask4VqIZ1fNV4R+qIcM4c4R7WtnMIAVvuwI8TYYfjZWo1qysUJlHhehmil8sRBs1nOEB9AZHfMQlpiUwIEUbRsdkxTKgk8v8BqGeVmrotxJHmOIqSIBIk9IRK9HBJWZcnDDxFN+yaCUucg3ACRDGStSS4RIzI8g6iN4i4iGGrUSaC8x8SSa4S9FEzyoBJhYxye970PjEIS7w8+ruSVzipyTExWIMlnsMqJE0qQiigzwzIUJojk+AUSMHQYe8RF+ZaCfP7MYAIaJNbOYbHsYhTgCOfBomHIA60kwya3gQmIW+zxYdiU+A4R89HyQU6viQc8waloML1comzcpyiHiGg1bCodFsyD0kgvgzZSMe1RELUUMHeW6EZ8EHvGAWWc1RQWIlLvEsHUxZ8oHQwpOc8uSudRO1pMkzMxI4rCLaxBNkWTSxiWaqI4lJZj4LHFYRbWKLDslyJUH2YSjAVjo5GyZEtJlqa26OOqxCC5s0V3wo4yHqyZANE5qiE0dHExG+pZW1CFvK6SsuQC3tXOSPtQiQ9RAOCs/RxiSz1SysGSBOiUgnJOo4UMwHC+EA2eQnwBSgnnZGuJmIiMoHxRhc8RJgeJkmRpmTpEQ4H0TWBw7tjDEnuP6IMnStRVgeaqM1zLcbTvF3mJBu0MGEhP21t5tGJy6RWh/xOrs57cld/0eUYrCTsYTELoaZT4WIrvBLrHKSRhMRb9DAMPNgQkRBs1KwEraUE10fvEkDXzMPbjlBVogVciQhulH/vCvELvqLxOdFZE3Cuhe23bMRIDGIdkaZcyiskygVd2sTljA/iARjEMRClIu7TGKiixXNBQkH3UtDkABDlbSzoBOSkCDnHwEO2sirnPYSx3EAhx4W3fHkBDbiNRvBI4bb+p2oesqi0tu+ZR3EVxZiCz2GKfBWXhtYgq3sJ8utBMTbEcRmDnPTUR/RwBK8yH7OcYswcSCSeMVKPMZRfpW8r7hrYBq2s58ctwn+6TF0ssx4BNHPPQvxCdfkiouJR6iRTh64E44mIqbligukygO+oD6aqJIDLLgTot6ljUFcdoFjxdzVxzhtsI2mSOJfdzwR8THXywRI5Q5kG/s4y524hMBb7IggjnJNvi8TICcRXHiJdxISe9nOcARxlR+8UWsEF3byLoP85T0xJSLNvfBeCOylXgfkfhSB51oBjAs7eI+BItEbJO5K3vHlg9LprtMhub/6/SDhL+4cdrOPAe54O04CUi3d3JW8emZxHGhBG9nqJ0q3J49zxEaAQxs5PwEgjmZYIq8aaGdiDzt10E8A6EYOc8NGwH9bMFQ4LjbeKgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNS0xMS0yNVQwOTowMjozMSswMDowMPBtsX8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTEtMjVUMDk6MDI6MzErMDA6MDCBMAnDAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI1LTExLTI1VDA5OjAyOjM5KzAwOjAw5cpmewAAAABJRU5ErkJggg==",gh=f.memo(e=>{var he,oe,ye,ce,we,_e,We,Tt,Bt,vt;const{onCellBlur:t,onCellEnter:n,handleCellKeyDown:r,onCellMouseDown:i,onCellMouseEnter:s,saveCommentHandler:o,deleteCommentHandler:a,onRightClick:l,pasteClipboardData:c,resetDefaultValueForSelectedCells:u}=wn(),d=f.useMemo(()=>e.fromArrayData?e.item[e.header.fromArray][e.fromArrayData.index][e.header.id]:e.item[e.header.id],[e.item,e.header,e.fromArrayData]),h=()=>d,[g,p]=f.useState(!1),m=f.useRef(d);f.useEffect(()=>{if(v(d),!!(C!=null&&C.showFlashOnCellUpdate)&&m.current!==d){p(!0),m.current=d;const z=setTimeout(()=>{p(!1)},1e3);return()=>clearTimeout(z)}},[d]);const[b,v]=f.useState(()=>h()),y=f.useMemo(()=>{var z;return((z=e.header.editOptions)==null?void 0:z.type)===Ir.NUMBER&&!isNaN(Number(b))&&b?Number(b):b},[b]),S=ui(),w=rI(),{setOpenCommentCell:x}=cl(),C=xn(),{setContextMenu:A}=ma(),M=Ms(),R=Sm(),{setClipboardData:$}=Cm(),I=f.useMemo(()=>({rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData}),[e.rowIndex,e.columnIndex,e.fromArrayData]);f.useEffect(()=>{v(h())},[e.item,e.header.id]);const j=z=>{const te=z.target;let le=te.value;if(te instanceof HTMLInputElement)switch(te.type){case"number":le=te.value===""?void 0:Number(te.value),typeof le=="number"&&isNaN(le)&&(le=void 0);break;case"date":le=te.value;break;default:le=te.value}else te instanceof HTMLSelectElement&&(le=te.value);v(le)},q=async()=>{y!==d&&await t(y,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData})},Z=z=>{z.button!==2&&(((w==null?void 0:w.columnIndex)!==e.columnIndex||w.rowIndex!==e.rowIndex)&&x(void 0),i(z,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData}))},W=z=>{var te;if(z.key==="Enter"&&N)n(y,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData});else if((z.ctrlKey||z.metaKey)&&z.key==="c"){if((te=window.getSelection())==null?void 0:te.toString()){$([]);return}z.preventDefault();const fe=xm(I,M,S,e.item,d);$(fe),z.preventDefault()}else if((z.ctrlKey||z.metaKey)&&z.key==="v"){if(R.length===0)return;z.preventDefault(),c()}else if(z.key==="Escape")v(h());else if(z.key==="Delete"&&N)u();else{if(X()&&["ArrowRight","ArrowLeft","ArrowDown","ArrowUp"].includes(z.key)&&!z.shiftKey)return;z.ctrlKey&&(z.key==="z"||z.key==="y")?z.preventDefault():(["ArrowDown","ArrowUp","Tab"].includes(z.key),r(z))}},X=()=>(document.activeElement===re.current||document.activeElement===J.current)&&N,F=f.useMemo(()=>{var z,te,le,fe;return(w==null?void 0:w.columnIndex)===e.columnIndex&&w.rowIndex===e.rowIndex&&((z=w.fromArrayData)==null?void 0:z.fromArray)===((te=e.fromArrayData)==null?void 0:te.fromArray)&&((le=w.fromArrayData)==null?void 0:le.index)===((fe=e.fromArrayData)==null?void 0:fe.index)},[w,e.columnIndex,e.rowIndex]),re=f.useRef(null),J=f.useRef(null),E=Le(z=>{var te,le,fe,De,Fe;return((te=z.selectedCell)==null?void 0:te.rowIndex)===e.rowIndex&&((le=z.selectedCell)==null?void 0:le.columnIndex)===e.columnIndex&&((De=(fe=z.selectedCell)==null?void 0:fe.fromArrayData)==null?void 0:De.index)===((Fe=e.fromArrayData)==null?void 0:Fe.index)}),T=Le(z=>{var te;return((te=z.expandedSelection)==null?void 0:te.some(le=>{var fe,De;return le.rowIndex===e.rowIndex&&le.columnIndex===e.columnIndex&&((fe=le.fromArrayData)==null?void 0:fe.index)===((De=e.fromArrayData)==null?void 0:De.index)}))||!1}),P={width:"100%",outline:"none",border:"none",background:"transparent"},L=f.useMemo(()=>{var z,te;return(te=(z=e.header.editOptions)==null?void 0:z.notApplicable)==null?void 0:te.call(z,e.item,e.fromArrayData)},[(he=e.header.editOptions)==null?void 0:he.notApplicable,e.item,e.fromArrayData]),N=f.useMemo(()=>{var z,te,le;return((z=e.header.editOptions)==null?void 0:z.editable)&&!e.isDisabled&&!((le=(te=e.header.editOptions).isDisabled)!=null&&le.call(te,e.item,e.fromArrayData))&&!L},[(oe=e.header.editOptions)==null?void 0:oe.editable,e.isDisabled,(ye=e.header.editOptions)==null?void 0:ye.isDisabled,L,e.item,e.fromArrayData]),U=f.useMemo(()=>{var Fe;const z=e.style||{},te={transition:"background-color 0.3s ease"};if(g)return{...z,background:"rgba(59, 130, 246, 0.4)",...te};if(L)return{...z,backgroundImage:`url(${OF})`,backgroundRepeat:"repeat",backgroundSize:"22px 22px"};const le=e.isDisabled||!N&&((Fe=e.header.editOptions)==null?void 0:Fe.greyedOutIfNotEditable);let fe=z.backgroundColor,De;return T&&!E&&(De="rgba(191, 219, 254, 0.5)"),le&&(fe=z.backgroundColor||"rgba(229, 231, 235, 0.5)"),e.rowIndex%2!==0&&(C!=null&&C.contrastRow)&&!z.backgroundColor&&(fe=fe||"rgba(239, 246, 255, 0.5)"),De&&fe?{...z,background:`
93
93
  linear-gradient(${De}, ${De}),
94
94
  linear-gradient(${fe}, ${fe})
95
- `}:{...z,background:fe||De,textAlign:e.header.align,maxWidth:e.header.width?`${e.header.width}px`:"none"}},[e.style,e.isDisabled,(ce=e.header.editOptions)==null?void 0:ce.editable,(we=e.header.editOptions)==null?void 0:we.greyedOutIfNotEditable,e.rowIndex,C==null?void 0:C.contrastRow,T,E,e.header.align,e.header.width,g]),H=f.useMemo(()=>{var z;if(L)return _.jsx("div",{});if(N&&E)switch(e.header.editOptions.type){case Ir.NUMBER:return _.jsx(MF,{id:Jt(e.rowIndex,e.columnIndex,e.fromArrayData),inputRef:re,initialValue:b!==void 0?String(b):void 0,cellValue:d,onChange:j,onBlur:q});case Ir.LIST:return _.jsx(AF,{inputRef:re,header:e.header,value:b,options:e.header.editOptions.options||[],onEnter:te=>{v(te),n(te,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData})},onSelect:te=>{v(te),t(te,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData})}});default:return _.jsx("div",{children:_.jsx("input",{ref:re,type:"text",value:b,onChange:j,autoFocus:!0,style:P})})}else{if(e.header.customRender)return _.jsx(wF,{item:e.item,header:e.header,fromArrayData:e.fromArrayData,isDisabled:e.isDisabled});{let te=d;return typeof d=="number"&&(te=ts(d)),_.jsxs("div",{className:"flex justify-between",children:[_.jsx("span",{className:"truncate whitespace-nowrap overflow-ellipsis",title:String(te),children:te}),((z=e.header.editOptions)==null?void 0:z.type)===Ir.LIST&&_.jsx("div",{className:"ml-1 w-0 h-0",style:{borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid #888",marginTop:"4px"},"aria-label":"dropdown indicator"})]})}}},[N,E,d,b,F,C==null?void 0:C.selectNewOptionOnAdd,e.item]),[G,Y]=f.useState(!1),D=z=>{s(z,I)},O=z=>{a==null||a(z,e.item),x(void 0)},B=()=>{F||setTimeout(()=>{requestAnimationFrame(()=>{var z;(z=re.current)==null||z.focus()})},0)},k=f.useRef(!1);f.useEffect(()=>{K()},[E,N]);const K=async()=>{E?k.current=!0:k.current&&N&&E===!1&&(await q(),k.current=!1,v(d))},[ne,ie]=f.useState(!1);return f.useEffect(()=>{var z;if(F){const te=document.getElementById(Jt(e.rowIndex,e.columnIndex,e.fromArrayData));if(te){const le=te.getBoundingClientRect(),fe=(z=te.closest("table"))==null?void 0:z.getBoundingClientRect();if(fe){const De=le.right+220>fe.right;ie(De)}}}},[F,e.rowIndex,e.columnIndex,e.fromArrayData]),_.jsxs("td",{id:Jt(e.rowIndex,e.columnIndex,e.fromArrayData),"data-row-index":e.rowIndex,"data-col-index":e.columnIndex,"data-from-array":(_e=e.fromArrayData)==null?void 0:_e.fromArray,"data-array-index":(We=e.fromArrayData)==null?void 0:We.index,tabIndex:0,onFocus:B,style:{...U,alignContent:"start",outline:E?"2px solid #3b82f6":"none"},rowSpan:e.rowSpan,className:`relative ${C!=null&&C.noBorder?"":"border-solid border border-gray-200"} ${E?"cell-selected":""}`,onKeyDown:W,onMouseDown:Z,onMouseEnter:D,onContextMenu:z=>{l({rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData},z),A({x:z.clientX,y:z.clientY,cellCoordinate:{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData},item:e.item,header:S[e.columnIndex]})},children:[e.comments&&e.comments.length>0&&_.jsx("div",{onClick:()=>x(F?void 0:I),className:"absolute top-0 right-0 ",style:{width:0,height:0,borderTop:"10px solid var(--comment-color)",borderLeft:"10px solid transparent"}}),H,F&&_.jsx("div",{className:`absolute z-2000 w-[220px] bg-white border-2 border-[var(--comment-color)] rounded shadow-lg p-2 px-3 top-0 ${ne?"left-0 ml-[-220px]":"right-0 mr-[-220px]"}`,children:_.jsx(_F,{comment:((Tt=e.comments)==null?void 0:Tt[0])||{text:"",propertyId:e.header.id,value:e.item[e.header.id],date:new Date},columnId:e.header.id,isNewComment:((Bt=e.comments)==null?void 0:Bt.length)===0,saveComment:z=>{o(z,e.item)},deleteComment:z=>O(z),setIsEditing:Y,isEditing:G||((vt=e.comments)==null?void 0:vt.length)===0})})]},`item-${e.columnIndex}-${e.rowIndex}`)}),TF=(e,t)=>e.filter(r=>r.columnId===t).reduce((r,i)=>({...r,...i.style||{}}),{}),RF=(e,t)=>t.filter(r=>e[r.propertyId]===r.value)||[],DF=f.memo(e=>{const t=xn(),n=As(),r=di(),i=Oh(),{draggedRowIndex:s,dropTargetIndex:o,handleDragEnd:a,handleRowDragStart:l,handleDrop:c,handleRowDragOver:u}=wn(),d=f.useMemo(()=>{const p=new Map;return i.forEach((m,b)=>{p.set(m,b+1)}),p},[i]),h=f.useMemo(()=>o===e.rowIndex,[o,e.rowIndex]),g=f.useMemo(()=>s!==null&&s<e.rowIndex,[s,e.rowIndex]);return _.jsxs("td",{rowSpan:e.rowSpan,style:{alignContent:"start"},className:`text-right pr-2 bg-gray-100 font-medium relative ${t!=null&&t.enableRowDragDrop?"cursor-grab":""}`,draggable:t==null?void 0:t.enableRowDragDrop,onDragEnd:t!=null&&t.enableRowDragDrop?a:void 0,onDragStart:t!=null&&t.enableRowDragDrop?()=>l(e.rowIndex,e.item):void 0,onDrop:t!=null&&t.enableRowDragDrop?()=>c(e.item):void 0,onDragOver:t!=null&&t.enableRowDragDrop?p=>{p.preventDefault(),u(e.rowIndex)}:void 0,onDragEnter:t!=null&&t.enableRowDragDrop?p=>{p.preventDefault(),u(e.rowIndex)}:void 0,children:[h&&_.jsx("div",{style:{position:"absolute",top:g?"100%":0,left:0,width:"100vw",height:"2px",backgroundColor:"rgb(59, 130, 246)",zIndex:10}}),_.jsxs("div",{className:"flex grow items-center justify-between",children:[(t==null?void 0:t.enableRowDragDrop)&&_.jsx(ft,{path:Sh,color:"grey",size:.8}),n?t!=null&&t.indexUseOriginalOrder?d.get(r[e.rowIndex]):e.rowIndex+1:d.get(e.item)]})]})}),ph=f.memo(e=>{const t=xn(),n=ui(),r=As(),i=Dh(),s=kh(),{draggedRowIndex:o,dropTargetIndex:a,handleRowDoubleClick:l}=wn(),c=f.useMemo(()=>RF(e.item,s),[s,e.item]),u=f.useMemo(()=>({...c.filter(b=>!b.columnId).reduce((b,v)=>({...b,...v.style||{}}),{}),opacity:o===e.index?.5:1,backgroundColor:a===e.index?"rgba(59, 130, 246, 0.1)":void 0,position:"relative"}),[c,o,a,e.index]);let d=0;const h=n.filter(b=>b.fromArray);h.length>0&&(n.forEach(b=>{b.fromArray&&Array.isArray(e.item[b.fromArray])&&(d=Math.max(d,e.item[b.fromArray].length))}),d++);const g=f.useMemo(()=>n.map((b,v)=>{const y=TF(c,b.id),S=i.filter(w=>w.columnId===b.id&&e.item[w.propertyId]===w.value);return _.jsx(gh,{isDisabled:e.isDisabled||(e.groupName&&e.isGroupLinked?e.isGroupLinked(e.groupName):void 0)||!1,header:b,item:e.item,style:y,rowIndex:e.index,columnIndex:v,comments:S,rowSpan:b.fromArray?1:Math.max(d,1)},`item-${e.index}-${v}-${b.id}`)}),[n,e.index,e.item,e.groupName,e.isGroupLinked,c,i,d]),p=f.useMemo(()=>t!=null&&t.rowIdProperty?String(e.item[t.rowIdProperty]):void 0,[e.item]),m=f.useMemo(()=>h.length===0||d<=1?null:Array.from({length:d-1}).map((b,v)=>_.jsx("tr",{children:h.map((y,S)=>{const w=n.findIndex(x=>x.id===y.id);return _.jsx(gh,{isDisabled:e.isDisabled||(e.groupName&&e.isGroupLinked?e.isGroupLinked(e.groupName):void 0)||!1,header:y,item:e.item,style:{},rowIndex:e.index,columnIndex:w,comments:[],rowSpan:y.fromArray?1:d,fromArrayData:{fromArray:y.fromArray,index:v}},`item-${e.index}-${S}`)})},`item-array-${e.index}-${v}`)),[h,e.index,e.item,e.groupName,e.isGroupLinked,d]);return _.jsxs(_.Fragment,{children:[_.jsxs("tr",{id:p,style:u,onDoubleClick:l?()=>l(e.item):void 0,ref:e.ref,"data-index":e.dataIndex,children:[(t==null?void 0:t.showIndex)&&_.jsx(DF,{item:e.item,rowIndex:e.index,rowSpan:Math.max(d,1)}),g]},`item-${r?e.item.groupName:""}-${e.index}`),m]})});function kF(e){return _.jsx("div",{className:"relative h-6 w-full bg-[#f0f0f0] border border-gray-200 text-sm font-semibold",children:e.footerCustomRender?e.footerCustomRender(e.itemsCount,e.filteredItemsCount,e.colSpan):_.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex justify-end gap-8 items-center text-gray-600",children:[e.filteredItemsCount!==e.itemsCount&&_.jsxs("div",{children:["Rows: ",e.filteredItemsCount," of ",e.itemsCount]}),_.jsxs("div",{children:["Total Rows: ",e.itemsCount]}),_.jsxs("div",{children:["Filtered: ",e.filteredItemsCount]})]})})}const IF=f.memo(kF),$F="main-base-table",PF=200,LF=150,jF=({dialogItem:e})=>{const[t,n]=f.useState(e.position),[r,i]=f.useState({width:e.width??300,height:e.height??400}),[s,o]=f.useState(!1),[a,l]=f.useState(null),[c,u]=f.useState({x:0,y:0}),d=f.useRef(null),h=f.useMemo(()=>e.minWidth??PF,[e.minWidth]),g=f.useMemo(()=>e.minHeight??LF,[e.minHeight]),{closeDialog:p}=Eg(),m=(S,w,x,C)=>{const A=window.innerWidth-x,M=window.innerHeight-C;return{x:Math.min(Math.max(0,S),A),y:Math.min(Math.max(0,w),M)}},b=S=>{var w;if(S.target===S.currentTarget||S.target.closest(".dialog-header")){o(!0);const x=(w=d.current)==null?void 0:w.getBoundingClientRect();x&&u({x:S.clientX-x.left,y:S.clientY-x.top})}},v=(S,w)=>{S.preventDefault(),S.stopPropagation(),l(w)};f.useEffect(()=>{if(!s)return;const S=x=>{var M;const C=(M=d.current)==null?void 0:M.getBoundingClientRect();if(!C)return;const A=m(x.clientX-c.x,x.clientY-c.y,C.width,C.height);n(A)},w=()=>{o(!1)};return document.addEventListener("mousemove",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",w)}},[s,c]),f.useEffect(()=>{if(!a)return;const S=x=>{const C={...r};if(a==="right"||a==="corner"){const A=x.clientX-t.x;C.width=Math.max(h,A)}if(a==="bottom"||a==="corner"){const A=x.clientY-t.y;C.height=Math.max(g,A)}i(C)},w=()=>{l(null)};return document.addEventListener("mousemove",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",w)}},[a,t]),f.useEffect(()=>{const S=w=>{w.key==="Escape"&&y()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[]);const y=()=>{p(e.id)};return _.jsxs("div",{ref:d,className:"fixed shadow-2xl bg-white rounded-md z-50 border border-gray-300",style:{left:t.x,top:t.y,width:`${r.width}px`,height:`${r.height}px`,cursor:s?"grabbing":"default",userSelect:s||a?"none":"text"},children:[_.jsxs("div",{className:"dialog-header flex justify-between items-center px-3 py-1 cursor-grab bg-gray-50 rounded-t-md border-b border-gray-200",onMouseDown:b,children:[_.jsxs("div",{className:"flex items-center",children:[e.iconPath&&_.jsx(ft,{path:e.iconPath,color:e.iconColor??"var(--comment-color)",size:1}),_.jsx("h3",{className:"text-sm font-semibold ml-2",children:e.title})]}),_.jsx(st,{icon:_h,className:"bg-white rounded-3xl hover:bg-gray-200",onClick:y,small:!0})]}),_.jsx("div",{className:"p-4 overflow-y-auto",style:{height:"calc(100% - 40px)"},children:e.dialogImplementation}),_.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-blue-400",onMouseDown:S=>v(S,"right")}),_.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-blue-400",onMouseDown:S=>v(S,"bottom")}),_.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize",onMouseDown:S=>v(S,"corner"),children:_.jsxs("svg",{className:"w-3 h-3 text-gray-400",viewBox:"0 0 12 12",fill:"currentColor",children:[_.jsx("path",{d:"M10 0L12 2L2 12L0 10L10 0Z"}),_.jsx("path",{d:"M10 4L12 6L6 12L4 10L10 4Z"}),_.jsx("path",{d:"M10 8L12 10L10 12L8 10L10 8Z"})]})})]})};function bp(){const e=Ih(),t=um(),n=As(),r=di(),i=f.useMemo(()=>{if(!n)return{"":r.map((g,p)=>({rowIndex:p,item:g}))};const c=r.reduce((h,g)=>{const p=g[n];return h[p]||(h[p]=[]),h[p].push({rowIndex:0,item:g}),h},{});let u=0;const d={};return Object.keys(c).forEach(h=>{d[h]=c[h].map(({item:g})=>({rowIndex:u++,item:g}))}),d},[r,n]),s=f.useMemo(()=>{const c=Object.entries(i);if(!t||t.length===0)return c;const u=new Set(t.map(v=>v.master)),d=new Set(t.flatMap(v=>v.linked)),h=new Map(t.map(v=>[v.master,v.linked])),g=new Set,p=[],m=new Map(c.map(v=>[v[0],v]));for(const[v,y]of c)if(!g.has(v))if(u.has(v)){p.push([v,y]),g.add(v);const S=h.get(v)||[];for(const w of S){const x=m.get(w);x&&!g.has(w)&&(p.push(x),g.add(w))}}else{if(d.has(v))continue;p.push([v,y]),g.add(v)}let b=0;return p.map(([v,y])=>{const S=y.map(({item:w})=>({rowIndex:b++,item:w}));return[v,S]})},[i,t]),o=f.useMemo(()=>c=>{var u;return(u=t==null?void 0:t.find(d=>d.linked.includes(c)))==null?void 0:u.master},[t]),a=f.useMemo(()=>{const c=[];return s.forEach(([u,d])=>{var g;const h=(e==null?void 0:e.includes(u))??!1;c.push({isGroup:!0,groupName:u,isCollapsed:h,masterGroupName:o(u),linkedGroupNames:(g=t==null?void 0:t.find(p=>p.master===u))==null?void 0:g.linked}),d.forEach(({rowIndex:p,item:m})=>{c.push({isGroup:!1,rowIndex:p,groupName:u,isCollapsed:h,item:m})})}),c},[s,e]),l=f.useMemo(()=>c=>!!(t!=null&&t.some(u=>u.linked.includes(c))),[t]);return{groupedItemsEntries:s,flatGroupedItems:a,isGroupLinked:l,getMasterGroupNameLinked:o}}function FF(e){const t=vm(),n=di(),r=hi(),i=ui(),s=Th(),o=pa(),a=Ih(),l=xn(),c=pm(),{clearActiveFilters:u,setActiveFilter:d,onResetSort:h,onSortByColumn:g,collapseGroup:p}=yn(),{setSelectedCell:m,setExpandedSelection:b}=Lh(),{setContextMenu:v}=ma(),{setTableRef:y,setScrollRef:S}=EF(),w=B$(),{groupedItemsEntries:x,flatGroupedItems:C,isGroupLinked:A}=bp(),M=f.useMemo(()=>C.filter(E=>E.isGroup?!0:!a.includes(E.groupName)),[C,a]),{onMouseMove:R}=wn(),$=f.useRef(null),I=f.useRef(null);f.useEffect(()=>{y($)},[$]),f.useEffect(()=>{S(I)},[I]),f.useEffect(()=>{if(!(l!=null&&l.focusedRowIndex))return;let E=l.focusedRowIndex;if(e.groupBy){let T=0;for(let P=0;P<M.length;P++)if(!M[P].isGroup){if(T===l.focusedRowIndex){E=P;break}T++}}requestAnimationFrame(()=>{F.virtualizer.scrollToIndex(E,{align:"center",behavior:"auto"})}),m({rowIndex:l.focusedRowIndex,columnIndex:0})},[l==null?void 0:l.focusedRowIndex]);const j=cm(),q=f.useMemo(()=>l!=null&&l.showIndex?[{id:"_index",text:"",sortable:!1,align:"right",children:[],width:l!=null&&l.enableRowDragDrop?55:40},...j]:j,[j,l==null?void 0:l.showIndex,l==null?void 0:l.enableRowDragDrop]),Z=f.useMemo(()=>({ids:e.headers.map(E=>E.id).join(","),count:e.headers.length}),[e.headers]);f.useEffect(()=>{v(void 0),u(),m(void 0),b([])},[Z.ids,Z.count]);const W=f.useMemo(()=>{if(e.groupBy){let E=0;return x.forEach(([T,P])=>{E+=1,a.includes(T)||(E+=P.length)}),E}else return n.length},[n,x,a,e.groupBy]),X=f.useMemo(()=>{if(e.groupBy){let E=0;return x.forEach(([T,P])=>{a.includes(T)||(E+=P.length)}),E}else return n.length},[n,x,e.groupBy]),F=Gm({scrollRef:I,rowsCount:W}),re=f.useMemo(()=>{const E=new Map;return e.groupBy&&C.forEach(T=>{T.isGroup||(E.has(T.groupName)||E.set(T.groupName,[]),E.get(T.groupName).push(T))}),E},[C,e.groupBy]),J=f.useMemo(()=>{var L,N;const E=F.virtualRows,T=(L=l==null?void 0:l.disabledRows)!=null&&L.values?new Set(l.disabledRows.values.map(String)):null,P=(N=l==null?void 0:l.disabledRows)==null?void 0:N.property;return e.groupBy?F.virtualRows.map(U=>{const H=M[U.index];if(H.isGroup){const G=re.get(H.groupName)||[];return _.jsx(f.Fragment,{children:_.jsx(Ym,{dataIndex:U.index,ref:F.virtualizer.measureElement,colSpan:i.length+(l!=null&&l.showIndex?1:0),groupBy:e.groupBy,groupName:H.groupName,isCollapsed:a.includes(H.groupName),masterGroupName:H.masterGroupName,linkedGroupNames:H.linkedGroupNames,onCollapseGroup:p,groupByCustomRender:e.groupByCustomRender?(Y,D)=>{var O;return(O=e.groupByCustomRender)==null?void 0:O.call(e,Y,D,i.length+(l!=null&&l.showIndex?1:0),H.isCollapsed||!1,p,G,H.masterGroupName,H.linkedGroupNames)}:void 0})},`group-${H.groupName}`)}else{const G=H,Y=T&&P?T.has(String(G.item[P])):!1;return _.jsx(f.Fragment,{children:_.jsx(ph,{dataIndex:U.index,ref:F.virtualizer.measureElement,item:G.item,index:G.rowIndex,groupName:G.groupName,isGroupLinked:A,isDisabled:Y})},`group-${H.groupName}-item-${G.rowIndex}`)}}):E.map(U=>{const H=n[U.index],G=T&&P?T.has(String(H[P])):!1;return _.jsx(ph,{dataIndex:U.index,ref:F.virtualizer.measureElement,item:H,index:U.index,isGroupLinked:A,isDisabled:G})})},[e.groupBy,F.virtualRows,n,M,a,F.virtualizer]);return _.jsxs(_.Fragment,{children:[c&&_.jsx(yF,{x:c.x,y:c.y,item:c.item,itemCoordinate:c.cellCoordinate,header:c.header,onClose:()=>v(void 0)}),_.jsxs("div",{ref:I,className:"overflow-auto h-min",style:{overflow:"auto",border:"1px solid lightgray",height:e.height?`calc(${e.height} - ${l!=null&&l.showFooter?"20px":"0rem"})`:`calc(100vh - ${l!=null&&l.marginTop?l==null?void 0:l.marginTop:"6rem"} - ${l!=null&&l.showFooter?"20px":"0rem"})`},children:[w.map(E=>_.jsx(jF,{dialogItem:E})),_.jsxs("table",{ref:$,onMouseMove:R,id:(l==null?void 0:l.tableId)??$F,style:{width:"100%",position:"unset",userSelect:t?"none":"auto",WebkitUserSelect:t?"none":"auto",MozUserSelect:t?"none":"auto",msUserSelect:t?"none":"auto"},className:`base-table table table-xs table-pin-rows
95
+ `}:{...z,background:fe||De,textAlign:e.header.align,maxWidth:e.header.width?`${e.header.width}px`:"none"}},[e.style,e.isDisabled,(ce=e.header.editOptions)==null?void 0:ce.editable,(we=e.header.editOptions)==null?void 0:we.greyedOutIfNotEditable,e.rowIndex,C==null?void 0:C.contrastRow,T,E,e.header.align,e.header.width,g]),H=f.useMemo(()=>{var z;if(L)return _.jsx("div",{});if(N&&E)switch(e.header.editOptions.type){case Ir.NUMBER:return _.jsx(MF,{id:Jt(e.rowIndex,e.columnIndex,e.fromArrayData),inputRef:re,initialValue:b!==void 0?String(b):void 0,cellValue:d,onChange:j,onBlur:q});case Ir.LIST:return _.jsx(AF,{inputRef:re,header:e.header,value:b,options:e.header.editOptions.options||[],onEnter:te=>{v(te),n(te,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData})},onSelect:te=>{v(te),t(te,e.item,e.header,{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData})}});default:return _.jsx("div",{children:_.jsx("input",{ref:re,type:"text",value:b,onChange:j,autoFocus:!0,style:P})})}else{if(e.header.customRender)return _.jsx(wF,{item:e.item,header:e.header,fromArrayData:e.fromArrayData,isDisabled:e.isDisabled});{let te=d;return typeof d=="number"&&(te=ts(d)),_.jsxs("div",{className:"flex justify-between",children:[_.jsx("span",{className:"truncate whitespace-nowrap overflow-ellipsis",title:String(te),children:te}),((z=e.header.editOptions)==null?void 0:z.type)===Ir.LIST&&_.jsx("div",{className:"ml-1 w-0 h-0",style:{borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid #888",marginTop:"4px"},"aria-label":"dropdown indicator"})]})}}},[N,E,d,b,F,C==null?void 0:C.selectNewOptionOnAdd,e.item]),[G,Y]=f.useState(!1),D=z=>{s(z,I)},O=z=>{a==null||a(z,e.item),x(void 0)},B=()=>{F||setTimeout(()=>{requestAnimationFrame(()=>{var z;(z=re.current)==null||z.focus()})},0)},k=f.useRef(!1);f.useEffect(()=>{K()},[E,N]);const K=async()=>{E?k.current=!0:k.current&&N&&E===!1&&(await q(),k.current=!1,v(d))},[ne,ie]=f.useState(!1);return f.useEffect(()=>{var z;if(F){const te=document.getElementById(Jt(e.rowIndex,e.columnIndex,e.fromArrayData));if(te){const le=te.getBoundingClientRect(),fe=(z=te.closest("table"))==null?void 0:z.getBoundingClientRect();if(fe){const De=le.right+220>fe.right;ie(De)}}}},[F,e.rowIndex,e.columnIndex,e.fromArrayData]),_.jsxs("td",{id:Jt(e.rowIndex,e.columnIndex,e.fromArrayData),"data-row-index":e.rowIndex,"data-col-index":e.columnIndex,"data-from-array":(_e=e.fromArrayData)==null?void 0:_e.fromArray,"data-array-index":(We=e.fromArrayData)==null?void 0:We.index,tabIndex:0,onFocus:B,style:{...U,alignContent:"start",outline:E?"2px solid #3b82f6":"none"},rowSpan:e.rowSpan,className:`relative ${C!=null&&C.noBorder?"":"border-solid border border-gray-200"} ${E?"cell-selected":""}`,onKeyDown:W,onMouseDown:Z,onMouseEnter:D,onContextMenu:z=>{var te;l({rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData},z),((te=C==null?void 0:C.contextMenu)==null?void 0:te.showOnCell)!==!1&&A({x:z.clientX,y:z.clientY,cellCoordinate:{rowIndex:e.rowIndex,columnIndex:e.columnIndex,fromArrayData:e.fromArrayData},item:e.item,header:S[e.columnIndex]})},children:[e.comments&&e.comments.length>0&&_.jsx("div",{onClick:()=>x(F?void 0:I),className:"absolute top-0 right-0 ",style:{width:0,height:0,borderTop:"10px solid var(--comment-color)",borderLeft:"10px solid transparent"}}),H,F&&_.jsx("div",{className:`absolute z-2000 w-[220px] bg-white border-2 border-[var(--comment-color)] rounded shadow-lg p-2 px-3 top-0 ${ne?"left-0 ml-[-220px]":"right-0 mr-[-220px]"}`,children:_.jsx(_F,{comment:((Tt=e.comments)==null?void 0:Tt[0])||{text:"",propertyId:e.header.id,value:e.item[e.header.id],date:new Date},columnId:e.header.id,isNewComment:((Bt=e.comments)==null?void 0:Bt.length)===0,saveComment:z=>{o(z,e.item)},deleteComment:z=>O(z),setIsEditing:Y,isEditing:G||((vt=e.comments)==null?void 0:vt.length)===0})})]},`item-${e.columnIndex}-${e.rowIndex}`)}),TF=(e,t)=>e.filter(r=>r.columnId===t).reduce((r,i)=>({...r,...i.style||{}}),{}),RF=(e,t)=>t.filter(r=>e[r.propertyId]===r.value)||[],DF=f.memo(e=>{const t=xn(),n=As(),r=di(),i=Oh(),{draggedRowIndex:s,dropTargetIndex:o,handleDragEnd:a,handleRowDragStart:l,handleDrop:c,handleRowDragOver:u}=wn(),d=f.useMemo(()=>{const p=new Map;return i.forEach((m,b)=>{p.set(m,b+1)}),p},[i]),h=f.useMemo(()=>o===e.rowIndex,[o,e.rowIndex]),g=f.useMemo(()=>s!==null&&s<e.rowIndex,[s,e.rowIndex]);return _.jsxs("td",{rowSpan:e.rowSpan,style:{alignContent:"start"},className:`text-right pr-2 bg-gray-100 font-medium relative ${t!=null&&t.enableRowDragDrop?"cursor-grab":""}`,draggable:t==null?void 0:t.enableRowDragDrop,onDragEnd:t!=null&&t.enableRowDragDrop?a:void 0,onDragStart:t!=null&&t.enableRowDragDrop?()=>l(e.rowIndex,e.item):void 0,onDrop:t!=null&&t.enableRowDragDrop?()=>c(e.item):void 0,onDragOver:t!=null&&t.enableRowDragDrop?p=>{p.preventDefault(),u(e.rowIndex)}:void 0,onDragEnter:t!=null&&t.enableRowDragDrop?p=>{p.preventDefault(),u(e.rowIndex)}:void 0,children:[h&&_.jsx("div",{style:{position:"absolute",top:g?"100%":0,left:0,width:"100vw",height:"2px",backgroundColor:"rgb(59, 130, 246)",zIndex:10}}),_.jsxs("div",{className:"flex grow items-center justify-between",children:[(t==null?void 0:t.enableRowDragDrop)&&_.jsx(ft,{path:Sh,color:"grey",size:.8}),n?t!=null&&t.indexUseOriginalOrder?d.get(r[e.rowIndex]):e.rowIndex+1:d.get(e.item)]})]})}),ph=f.memo(e=>{const t=xn(),n=ui(),r=As(),i=Dh(),s=kh(),{draggedRowIndex:o,dropTargetIndex:a,handleRowDoubleClick:l}=wn(),c=f.useMemo(()=>RF(e.item,s),[s,e.item]),u=f.useMemo(()=>({...c.filter(b=>!b.columnId).reduce((b,v)=>({...b,...v.style||{}}),{}),opacity:o===e.index?.5:1,backgroundColor:a===e.index?"rgba(59, 130, 246, 0.1)":void 0,position:"relative"}),[c,o,a,e.index]);let d=0;const h=n.filter(b=>b.fromArray);h.length>0&&(n.forEach(b=>{b.fromArray&&Array.isArray(e.item[b.fromArray])&&(d=Math.max(d,e.item[b.fromArray].length))}),d++);const g=f.useMemo(()=>n.map((b,v)=>{const y=TF(c,b.id),S=i.filter(w=>w.columnId===b.id&&e.item[w.propertyId]===w.value);return _.jsx(gh,{isDisabled:e.isDisabled||(e.groupName&&e.isGroupLinked?e.isGroupLinked(e.groupName):void 0)||!1,header:b,item:e.item,style:y,rowIndex:e.index,columnIndex:v,comments:S,rowSpan:b.fromArray?1:Math.max(d,1)},`item-${e.index}-${v}-${b.id}`)}),[n,e.index,e.item,e.groupName,e.isGroupLinked,c,i,d]),p=f.useMemo(()=>t!=null&&t.rowIdProperty?String(e.item[t.rowIdProperty]):void 0,[e.item]),m=f.useMemo(()=>h.length===0||d<=1?null:Array.from({length:d-1}).map((b,v)=>_.jsx("tr",{children:h.map((y,S)=>{const w=n.findIndex(x=>x.id===y.id);return _.jsx(gh,{isDisabled:e.isDisabled||(e.groupName&&e.isGroupLinked?e.isGroupLinked(e.groupName):void 0)||!1,header:y,item:e.item,style:{},rowIndex:e.index,columnIndex:w,comments:[],rowSpan:y.fromArray?1:d,fromArrayData:{fromArray:y.fromArray,index:v}},`item-${e.index}-${S}`)})},`item-array-${e.index}-${v}`)),[h,e.index,e.item,e.groupName,e.isGroupLinked,d]);return _.jsxs(_.Fragment,{children:[_.jsxs("tr",{id:p,style:u,onDoubleClick:l?()=>l(e.item):void 0,ref:e.ref,"data-index":e.dataIndex,children:[(t==null?void 0:t.showIndex)&&_.jsx(DF,{item:e.item,rowIndex:e.index,rowSpan:Math.max(d,1)}),g]},`item-${r?e.item.groupName:""}-${e.index}`),m]})});function kF(e){return _.jsx("div",{className:"relative h-6 w-full bg-[#f0f0f0] border border-gray-200 text-sm font-semibold",children:e.footerCustomRender?e.footerCustomRender(e.itemsCount,e.filteredItemsCount,e.colSpan):_.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex justify-end gap-8 items-center text-gray-600",children:[e.filteredItemsCount!==e.itemsCount&&_.jsxs("div",{children:["Rows: ",e.filteredItemsCount," of ",e.itemsCount]}),_.jsxs("div",{children:["Total Rows: ",e.itemsCount]}),_.jsxs("div",{children:["Filtered: ",e.filteredItemsCount]})]})})}const IF=f.memo(kF),$F="main-base-table",PF=200,LF=150,jF=({dialogItem:e})=>{const[t,n]=f.useState(e.position),[r,i]=f.useState({width:e.width??300,height:e.height??400}),[s,o]=f.useState(!1),[a,l]=f.useState(null),[c,u]=f.useState({x:0,y:0}),d=f.useRef(null),h=f.useMemo(()=>e.minWidth??PF,[e.minWidth]),g=f.useMemo(()=>e.minHeight??LF,[e.minHeight]),{closeDialog:p}=Eg(),m=(S,w,x,C)=>{const A=window.innerWidth-x,M=window.innerHeight-C;return{x:Math.min(Math.max(0,S),A),y:Math.min(Math.max(0,w),M)}},b=S=>{var w;if(S.target===S.currentTarget||S.target.closest(".dialog-header")){o(!0);const x=(w=d.current)==null?void 0:w.getBoundingClientRect();x&&u({x:S.clientX-x.left,y:S.clientY-x.top})}},v=(S,w)=>{S.preventDefault(),S.stopPropagation(),l(w)};f.useEffect(()=>{if(!s)return;const S=x=>{var M;const C=(M=d.current)==null?void 0:M.getBoundingClientRect();if(!C)return;const A=m(x.clientX-c.x,x.clientY-c.y,C.width,C.height);n(A)},w=()=>{o(!1)};return document.addEventListener("mousemove",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",w)}},[s,c]),f.useEffect(()=>{if(!a)return;const S=x=>{const C={...r};if(a==="right"||a==="corner"){const A=x.clientX-t.x;C.width=Math.max(h,A)}if(a==="bottom"||a==="corner"){const A=x.clientY-t.y;C.height=Math.max(g,A)}i(C)},w=()=>{l(null)};return document.addEventListener("mousemove",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",w)}},[a,t]),f.useEffect(()=>{const S=w=>{w.key==="Escape"&&y()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[]);const y=()=>{p(e.id)};return _.jsxs("div",{ref:d,className:"fixed shadow-2xl bg-white rounded-md z-50 border border-gray-300",style:{left:t.x,top:t.y,width:`${r.width}px`,height:`${r.height}px`,cursor:s?"grabbing":"default",userSelect:s||a?"none":"text"},children:[_.jsxs("div",{className:"dialog-header flex justify-between items-center px-3 py-1 cursor-grab bg-gray-50 rounded-t-md border-b border-gray-200",onMouseDown:b,children:[_.jsxs("div",{className:"flex items-center",children:[e.iconPath&&_.jsx(ft,{path:e.iconPath,color:e.iconColor??"var(--comment-color)",size:1}),_.jsx("h3",{className:"text-sm font-semibold ml-2",children:e.title})]}),_.jsx(st,{icon:_h,className:"bg-white rounded-3xl hover:bg-gray-200",onClick:y,small:!0})]}),_.jsx("div",{className:"p-4 overflow-y-auto",style:{height:"calc(100% - 40px)"},children:e.dialogImplementation}),_.jsx("div",{className:"absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-blue-400",onMouseDown:S=>v(S,"right")}),_.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-blue-400",onMouseDown:S=>v(S,"bottom")}),_.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize",onMouseDown:S=>v(S,"corner"),children:_.jsxs("svg",{className:"w-3 h-3 text-gray-400",viewBox:"0 0 12 12",fill:"currentColor",children:[_.jsx("path",{d:"M10 0L12 2L2 12L0 10L10 0Z"}),_.jsx("path",{d:"M10 4L12 6L6 12L4 10L10 4Z"}),_.jsx("path",{d:"M10 8L12 10L10 12L8 10L10 8Z"})]})})]})};function bp(){const e=Ih(),t=um(),n=As(),r=di(),i=f.useMemo(()=>{if(!n)return{"":r.map((g,p)=>({rowIndex:p,item:g}))};const c=r.reduce((h,g)=>{const p=g[n];return h[p]||(h[p]=[]),h[p].push({rowIndex:0,item:g}),h},{});let u=0;const d={};return Object.keys(c).forEach(h=>{d[h]=c[h].map(({item:g})=>({rowIndex:u++,item:g}))}),d},[r,n]),s=f.useMemo(()=>{const c=Object.entries(i);if(!t||t.length===0)return c;const u=new Set(t.map(v=>v.master)),d=new Set(t.flatMap(v=>v.linked)),h=new Map(t.map(v=>[v.master,v.linked])),g=new Set,p=[],m=new Map(c.map(v=>[v[0],v]));for(const[v,y]of c)if(!g.has(v))if(u.has(v)){p.push([v,y]),g.add(v);const S=h.get(v)||[];for(const w of S){const x=m.get(w);x&&!g.has(w)&&(p.push(x),g.add(w))}}else{if(d.has(v))continue;p.push([v,y]),g.add(v)}let b=0;return p.map(([v,y])=>{const S=y.map(({item:w})=>({rowIndex:b++,item:w}));return[v,S]})},[i,t]),o=f.useMemo(()=>c=>{var u;return(u=t==null?void 0:t.find(d=>d.linked.includes(c)))==null?void 0:u.master},[t]),a=f.useMemo(()=>{const c=[];return s.forEach(([u,d])=>{var g;const h=(e==null?void 0:e.includes(u))??!1;c.push({isGroup:!0,groupName:u,isCollapsed:h,masterGroupName:o(u),linkedGroupNames:(g=t==null?void 0:t.find(p=>p.master===u))==null?void 0:g.linked}),d.forEach(({rowIndex:p,item:m})=>{c.push({isGroup:!1,rowIndex:p,groupName:u,isCollapsed:h,item:m})})}),c},[s,e]),l=f.useMemo(()=>c=>!!(t!=null&&t.some(u=>u.linked.includes(c))),[t]);return{groupedItemsEntries:s,flatGroupedItems:a,isGroupLinked:l,getMasterGroupNameLinked:o}}function FF(e){const t=vm(),n=di(),r=hi(),i=ui(),s=Th(),o=pa(),a=Ih(),l=xn(),c=pm(),{clearActiveFilters:u,setActiveFilter:d,onResetSort:h,onSortByColumn:g,collapseGroup:p}=yn(),{setSelectedCell:m,setExpandedSelection:b}=Lh(),{setContextMenu:v}=ma(),{setTableRef:y,setScrollRef:S}=EF(),w=B$(),{groupedItemsEntries:x,flatGroupedItems:C,isGroupLinked:A}=bp(),M=f.useMemo(()=>C.filter(E=>E.isGroup?!0:!a.includes(E.groupName)),[C,a]),{onMouseMove:R}=wn(),$=f.useRef(null),I=f.useRef(null);f.useEffect(()=>{y($)},[$]),f.useEffect(()=>{S(I)},[I]),f.useEffect(()=>{if(!(l!=null&&l.focusedRowIndex))return;let E=l.focusedRowIndex;if(e.groupBy){let T=0;for(let P=0;P<M.length;P++)if(!M[P].isGroup){if(T===l.focusedRowIndex){E=P;break}T++}}requestAnimationFrame(()=>{F.virtualizer.scrollToIndex(E,{align:"center",behavior:"auto"})}),m({rowIndex:l.focusedRowIndex,columnIndex:0})},[l==null?void 0:l.focusedRowIndex]);const j=cm(),q=f.useMemo(()=>l!=null&&l.showIndex?[{id:"_index",text:"",sortable:!1,align:"right",children:[],width:l!=null&&l.enableRowDragDrop?55:40},...j]:j,[j,l==null?void 0:l.showIndex,l==null?void 0:l.enableRowDragDrop]),Z=f.useMemo(()=>({ids:e.headers.map(E=>E.id).join(","),count:e.headers.length}),[e.headers]);f.useEffect(()=>{v(void 0),u(),m(void 0),b([])},[Z.ids,Z.count]);const W=f.useMemo(()=>{if(e.groupBy){let E=0;return x.forEach(([T,P])=>{E+=1,a.includes(T)||(E+=P.length)}),E}else return n.length},[n,x,a,e.groupBy]),X=f.useMemo(()=>{if(e.groupBy){let E=0;return x.forEach(([T,P])=>{a.includes(T)||(E+=P.length)}),E}else return n.length},[n,x,e.groupBy]),F=Gm({scrollRef:I,rowsCount:W}),re=f.useMemo(()=>{const E=new Map;return e.groupBy&&C.forEach(T=>{T.isGroup||(E.has(T.groupName)||E.set(T.groupName,[]),E.get(T.groupName).push(T))}),E},[C,e.groupBy]),J=f.useMemo(()=>{var L,N;const E=F.virtualRows,T=(L=l==null?void 0:l.disabledRows)!=null&&L.values?new Set(l.disabledRows.values.map(String)):null,P=(N=l==null?void 0:l.disabledRows)==null?void 0:N.property;return e.groupBy?F.virtualRows.map(U=>{const H=M[U.index];if(H.isGroup){const G=re.get(H.groupName)||[];return _.jsx(f.Fragment,{children:_.jsx(Ym,{dataIndex:U.index,ref:F.virtualizer.measureElement,colSpan:i.length+(l!=null&&l.showIndex?1:0),groupBy:e.groupBy,groupName:H.groupName,isCollapsed:a.includes(H.groupName),masterGroupName:H.masterGroupName,linkedGroupNames:H.linkedGroupNames,onCollapseGroup:p,groupByCustomRender:e.groupByCustomRender?(Y,D)=>{var O;return(O=e.groupByCustomRender)==null?void 0:O.call(e,Y,D,i.length+(l!=null&&l.showIndex?1:0),H.isCollapsed||!1,p,G,H.masterGroupName,H.linkedGroupNames)}:void 0})},`group-${H.groupName}`)}else{const G=H,Y=T&&P?T.has(String(G.item[P])):!1;return _.jsx(f.Fragment,{children:_.jsx(ph,{dataIndex:U.index,ref:F.virtualizer.measureElement,item:G.item,index:G.rowIndex,groupName:G.groupName,isGroupLinked:A,isDisabled:Y})},`group-${H.groupName}-item-${G.rowIndex}`)}}):E.map(U=>{const H=n[U.index],G=T&&P?T.has(String(H[P])):!1;return _.jsx(ph,{dataIndex:U.index,ref:F.virtualizer.measureElement,item:H,index:U.index,isGroupLinked:A,isDisabled:G})})},[e.groupBy,F.virtualRows,n,M,a,F.virtualizer]);return _.jsxs(_.Fragment,{children:[c&&_.jsx(yF,{x:c.x,y:c.y,item:c.item,itemCoordinate:c.cellCoordinate,header:c.header,onClose:()=>v(void 0)}),_.jsxs("div",{ref:I,className:"overflow-auto h-min",style:{overflow:"auto",border:"1px solid lightgray",height:e.height?`calc(${e.height} - ${l!=null&&l.showFooter?"20px":"0rem"})`:`calc(100vh - ${l!=null&&l.marginTop?l==null?void 0:l.marginTop:"6rem"} - ${l!=null&&l.showFooter?"20px":"0rem"})`},children:[w.map(E=>_.jsx(jF,{dialogItem:E})),_.jsxs("table",{ref:$,onMouseMove:R,id:(l==null?void 0:l.tableId)??$F,style:{width:"100%",position:"unset",userSelect:t?"none":"auto",WebkitUserSelect:t?"none":"auto",MozUserSelect:t?"none":"auto",msUserSelect:t?"none":"auto"},className:`base-table table table-xs table-pin-rows
96
96
  will-change-transform overflow-contain transform-gpu
97
97
  ${l!=null&&l.pinColumns?" table-pin-cols":""} `,children:[_.jsx(Rm,{headers:q,noBorder:l==null?void 0:l.noBorder,alignCenterInLine:l==null?void 0:l.alignCenterInLine,activeFilters:r,tableRef:$,ascendingOrder:o,filterItemsCache:s,onResetSort:h,onSortByColumn:g,onSetFilter:d}),_.jsxs("tbody",{children:[F.before>0&&_.jsx("tr",{style:{height:F.before},children:_.jsx("td",{colSpan:i.length+(l!=null&&l.showIndex?1:0),style:{height:F.before}})}),J,F.after>0&&_.jsx("tr",{children:_.jsx("td",{colSpan:i.length+(l!=null&&l.showIndex?1:0),style:{height:F.after}})})]})]})]}),_.jsx(IF,{itemsCount:e.items.length,filteredItemsCount:X,colSpan:i.length+(l!=null&&l.showIndex?1:0)})]})}function NF(e){const t=hi(),n=Rh(),r=pa(),i=Mh(),{setItems:s,processItems:o,setHeaders:a,processFilterItemsCache:l,setGroupBy:c,setLinkedGroups:u,setHighlightConditions:d,setComments:h,setAdvancedSettings:g,processHeaders:p}=yn();f.useEffect(()=>{s(e.items),o(),l()},[e.items,e.headers,n,r,t]),f.useEffect(()=>{a(e.headers),p()},[e.headers,i]),f.useEffect(()=>{h(e.comments||[])},[e.comments]),f.useEffect(()=>{d(e.highlightCondition||[])},[e.highlightCondition]),f.useEffect(()=>{c(e.groupBy)},[e.groupBy]),f.useEffect(()=>{g(e.advancedSettings)},[e.advancedSettings]),f.useEffect(()=>{u(e.linkedGroups)},[e.linkedGroups]);const{groupedItemsEntries:m}=bp();return _.jsx(Om,{items:e.items,groupedItemsEntries:e.groupBy?m:void 0,onChange:e.onChange,onBulkFieldChange:e.onBulkFieldChange,onBulkChange:e.onBulkChange,onRowDoubleClick:e.onRowDoubleClick,onRowsReordered:e.onRowsReordered,onDeleteComment:e.onDeleteComment,onSaveComment:e.onSaveComment,onSetHighlightCondition:e.onSetHighlightCondition,onRemoveHighlightCondition:e.onRemoveHighlightCondition,onAddListOption:e.onAddListOption,children:_.jsx(FF,{...e})})}exports.BaseTable=NF;
98
98
  //# sourceMappingURL=index.cjs.js.map