@sage-bionetworks/react-datasheet-grid 4.11.5-sage.4 → 4.11.5-sage.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DataSheetGrid.d.ts","sourceRoot":"","sources":["../../src/components/DataSheetGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAA;AACd,OAAO,EAIL,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,UAAU,CAAA;AA2CjB,eAAO,MAAM,aAAa;;MAmxDrB,WAAW,CAAA"}
1
+ {"version":3,"file":"DataSheetGrid.d.ts","sourceRoot":"","sources":["../../src/components/DataSheetGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAA;AACd,OAAO,EAIL,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,UAAU,CAAA;AA2CjB,eAAO,MAAM,aAAa;;MAmzDrB,WAAW,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../src/components/Grid.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAC9D,OAAO,EACL,IAAI,EACJ,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,SAAS,EACV,MAAM,UAAU,CAAA;AAKjB,eAAO,MAAM,IAAI;;;cA6BL,UAAU,cAAc,CAAC;cACzB,UAAU,cAAc,CAAC;;0BAEb,OAAO;oBACb,OAAO;mBACR,MAAM;qBACJ,MAAM;uBACJ,MAAM,KAAK;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;eAIrC,OAAO;eACP,SAAS,GAAG,IAAI;gBACf,IAAI,GAAG,IAAI;cACb,SAAS;aACV,OAAO;yBACK,MAAM,eAAe,EAAE;2BACrB,MAAM,cAAc,IAAI;yBAC1B,MAAM,WAAW,MAAM,KAAK,IAAI;4BAC7B,MAAM,WAAW,MAAM,KAAK,IAAI;0BAClC,MAAM,UAAU,MAAM,KAAK,IAAI;yBAChC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI;;uBA4OpD,CAAA"}
1
+ {"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../src/components/Grid.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAC9D,OAAO,EACL,IAAI,EACJ,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,SAAS,EACV,MAAM,UAAU,CAAA;AAKjB,eAAO,MAAM,IAAI;;;cA6BL,UAAU,cAAc,CAAC;cACzB,UAAU,cAAc,CAAC;;0BAEb,OAAO;oBACb,OAAO;mBACR,MAAM;qBACJ,MAAM;uBACJ,MAAM,KAAK;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;eAIrC,OAAO;eACP,SAAS,GAAG,IAAI;gBACf,IAAI,GAAG,IAAI;cACb,SAAS;aACV,OAAO;yBACK,MAAM,eAAe,EAAE;2BACrB,MAAM,cAAc,IAAI;yBAC1B,MAAM,WAAW,MAAM,KAAK,IAAI;4BAC7B,MAAM,WAAW,MAAM,KAAK,IAAI;0BAClC,MAAM,UAAU,MAAM,KAAK,IAAI;yBAChC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI;;uBAqPpD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionRect.d.ts","sourceRoot":"","sources":["../../src/components/SelectionRect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAuC/C,eAAO,MAAM,aAAa,kDAqOzB,CAAA"}
1
+ {"version":3,"file":"SelectionRect.d.ts","sourceRoot":"","sources":["../../src/components/SelectionRect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAuC/C,eAAO,MAAM,aAAa,kDA6azB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useColumns.d.ts","sourceRoot":"","sources":["../../src/hooks/useColumns.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAY1D,eAAO,MAAM,cAAc,UAAW,MAAM,GAAG,MAAM;;;;CAyDpD,CAAA;AAED,eAAO,MAAM,UAAU,6ZAIL,OAAO,0BA0ExB,CAAA"}
1
+ {"version":3,"file":"useColumns.d.ts","sourceRoot":"","sources":["../../src/hooks/useColumns.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAY1D,eAAO,MAAM,cAAc,UAAW,MAAM,GAAG,MAAM;;;;CAyDpD,CAAA;AAED,eAAO,MAAM,UAAU,6ZAIL,OAAO,0BA4ExB,CAAA"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),d=require("react"),On=require("react-dom");function Rn(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const Pe=Rn(d),Dn=(e,r)=>{const t=r.map(({basis:n,minWidth:o,maxWidth:i})=>({basis:n,minWidth:o,maxWidth:i,size:n,violation:0,frozen:!1,factor:0}));let s=t.reduce((n,o)=>n-o.size,e);s>0?r.forEach(({grow:n},o)=>{t[o].factor=n}):s<0&&r.forEach(({shrink:n},o)=>{t[o].factor=n});for(const n of t)n.factor===0&&(n.frozen=!0);for(;t.some(({frozen:n})=>!n);){const n=t.reduce((i,a)=>i+(a.frozen?0:a.factor),0);let o=0;for(const i of t)i.frozen||(i.size+=s*i.factor/n,i.size<i.minWidth?i.violation=i.minWidth-i.size:i.maxWidth!==void 0&&i.size>i.maxWidth?i.violation=i.maxWidth-i.size:i.violation=0,i.size+=i.violation,o+=i.violation);if(o>0)for(const i of t)i.violation>0&&(i.frozen=!0);else if(o<0)for(const i of t)i.violation<0&&(i.frozen=!0);else break;s=t.reduce((i,a)=>i-a.size,e)}return t.map(({size:n})=>n)},Nn=(e,r)=>{const t=e.map(({basis:s,minWidth:n,maxWidth:o,grow:i,shrink:a})=>[s,n,o,i,a].join(",")).join("|");return d.useMemo(()=>{if(r===void 0)return{fullWidth:!1,columnWidths:void 0,columnRights:void 0,totalWidth:void 0};const s=Dn(r,e);let n=0;const o=s.map((i,a)=>(n+=i,a===s.length-1?1/0:n));return{fullWidth:Math.abs(r-n)<.1,columnWidths:s,columnRights:o,totalWidth:n}},[r,t])};var ze=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function We(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ye,It;function pt(){if(It)return Ye;It=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return Ye=e,Ye}var Ze,Ct;function jn(){if(Ct)return Ze;Ct=1;var e=typeof ze=="object"&&ze&&ze.Object===Object&&ze;return Ze=e,Ze}var Je,Tt;function Ht(){if(Tt)return Je;Tt=1;var e=jn(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return Je=t,Je}var Qe,Ot;function Mn(){if(Ot)return Qe;Ot=1;var e=Ht(),r=function(){return e.Date.now()};return Qe=r,Qe}var He,Rt;function kn(){if(Rt)return He;Rt=1;var e=/\s/;function r(t){for(var s=t.length;s--&&e.test(t.charAt(s)););return s}return He=r,He}var et,Dt;function An(){if(Dt)return et;Dt=1;var e=kn(),r=/^\s+/;function t(s){return s&&s.slice(0,e(s)+1).replace(r,"")}return et=t,et}var tt,Nt;function en(){if(Nt)return tt;Nt=1;var e=Ht(),r=e.Symbol;return tt=r,tt}var nt,jt;function _n(){if(jt)return nt;jt=1;var e=en(),r=Object.prototype,t=r.hasOwnProperty,s=r.toString,n=e?e.toStringTag:void 0;function o(i){var a=t.call(i,n),f=i[n];try{i[n]=void 0;var h=!0}catch{}var g=s.call(i);return h&&(a?i[n]=f:delete i[n]),g}return nt=o,nt}var rt,Mt;function zn(){if(Mt)return rt;Mt=1;var e=Object.prototype,r=e.toString;function t(s){return r.call(s)}return rt=t,rt}var st,kt;function Fn(){if(kt)return st;kt=1;var e=en(),r=_n(),t=zn(),s="[object Null]",n="[object Undefined]",o=e?e.toStringTag:void 0;function i(a){return a==null?a===void 0?n:s:o&&o in Object(a)?r(a):t(a)}return st=i,st}var ot,At;function Vn(){if(At)return ot;At=1;function e(r){return r!=null&&typeof r=="object"}return ot=e,ot}var it,_t;function Ln(){if(_t)return it;_t=1;var e=Fn(),r=Vn(),t="[object Symbol]";function s(n){return typeof n=="symbol"||r(n)&&e(n)==t}return it=s,it}var lt,zt;function Pn(){if(zt)return lt;zt=1;var e=An(),r=pt(),t=Ln(),s=NaN,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,a=parseInt;function f(h){if(typeof h=="number")return h;if(t(h))return s;if(r(h)){var g=typeof h.valueOf=="function"?h.valueOf():h;h=r(g)?g+"":g}if(typeof h!="string")return h===0?h:+h;h=e(h);var T=o.test(h);return T||i.test(h)?a(h.slice(2),T?2:8):n.test(h)?s:+h}return lt=f,lt}var at,Ft;function tn(){if(Ft)return at;Ft=1;var e=pt(),r=Mn(),t=Pn(),s="Expected a function",n=Math.max,o=Math.min;function i(a,f,h){var g,T,p,R,S,N,z=0,W=!1,D=!1,O=!0;if(typeof a!="function")throw new TypeError(s);f=t(f)||0,e(h)&&(W=!!h.leading,D="maxWait"in h,p=D?n(t(h.maxWait)||0,f):p,O="trailing"in h?!!h.trailing:O);function j(V){var Q=g,y=T;return g=T=void 0,z=V,R=a.apply(y,Q),R}function B(V){return z=V,S=setTimeout(se,f),W?j(V):R}function L(V){var Q=V-N,y=V-z,k=f-Q;return D?o(k,p-y):k}function ie(V){var Q=V-N,y=V-z;return N===void 0||Q>=f||Q<0||D&&y>=p}function se(){var V=r();if(ie(V))return K(V);S=setTimeout(se,L(V))}function K(V){return S=void 0,O&&g?j(V):(g=T=void 0,R)}function U(){S!==void 0&&clearTimeout(S),z=0,g=N=T=S=void 0}function he(){return S===void 0?R:K(r())}function pe(){var V=r(),Q=ie(V);if(g=arguments,T=this,N=V,Q){if(S===void 0)return B(N);if(D)return clearTimeout(S),S=setTimeout(se,f),j(N)}return S===void 0&&(S=setTimeout(se,f)),R}return pe.cancel=U,pe.flush=he,pe}return at=i,at}var qn=tn();const Wn=We(qn);var ct,Vt;function Bn(){if(Vt)return ct;Vt=1;var e=tn(),r=pt(),t="Expected a function";function s(n,o,i){var a=!0,f=!0;if(typeof n!="function")throw new TypeError(t);return r(i)&&(a="leading"in i?!!i.leading:a,f="trailing"in i?!!i.trailing:f),e(n,o,{leading:a,maxWait:o,trailing:f})}return ct=s,ct}var Kn=Bn();const Un=We(Kn),$n=(e,r,t,s)=>{switch(r){case"debounce":return Wn(e,t,s);case"throttle":return Un(e,t,s);default:return e}};function Gn({skipOnMount:e=!1,refreshMode:r,refreshRate:t=1e3,refreshOptions:s,handleWidth:n=!0,handleHeight:o=!0,targetRef:i,observerOptions:a,onResize:f}={}){const h=d.useRef(e),[g,T]=d.useState({width:void 0,height:void 0}),[p,R]=d.useState(i?.current||null);i&&setTimeout(()=>{i.current!==p&&R(i.current)},0);const S=d.useMemo(()=>new Proxy(D=>{D!==p&&R(D)},{get(D,O){return O==="current"?p:D[O]},set(D,O,j){return O==="current"?R(j):D[O]=j,!0}}),[p]),N=d.useCallback((D,O)=>!(D.width===O.width&&D.height===O.height||D.width===O.width&&!o||D.height===O.height&&!n),[n,o]),z=d.useCallback(D=>{if(!(!n&&!o)){if(h.current){h.current=!1;return}D.forEach(O=>{const{width:j,height:B}=O?.contentRect||{};T(L=>N(L,{width:j,height:B})?{width:j,height:B}:L)})}},[n,o,h,N]),W=d.useCallback($n(z,r,t,s),[z,r,t,s]);return d.useEffect(()=>{let D;return p?(D=new window.ResizeObserver(W),D.observe(p,a)):(g.width||g.height)&&T({width:void 0,height:void 0}),()=>{var O,j,B;(O=D?.disconnect)===null||O===void 0||O.call(D),(B=(j=W).cancel)===null||B===void 0||B.call(j)}},[W,p]),d.useEffect(()=>{f?.(g.width,g.height)},[g]),Object.assign({ref:S},g)}const Xn=()=>b.jsx(b.Fragment,{}),Yn=()=>!1,Lt=({rowData:e})=>e,Zn=()=>null,Jn=({rowIndex:e})=>b.jsx(b.Fragment,{children:e+1}),ut=()=>!0,Qn=e=>e,Hn=e=>{if(typeof e=="number")return{basis:0,grow:e,shrink:1};if(e.match(/^ *\d+(\.\d*)? *$/))return{basis:0,grow:parseFloat(e.trim()),shrink:1};if(e.match(/^ *\d+(\.\d*)? *px *$/))return{basis:parseFloat(e.trim()),grow:1,shrink:1};if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? *$/)){const[r,t]=e.trim().split(" ");return{basis:0,grow:parseFloat(r),shrink:parseFloat(t)}}if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? *px *$/)){const[r,t]=e.trim().split(" ");return{basis:parseFloat(t),grow:parseFloat(r),shrink:1}}if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? \d+(\.\d*)? *px *$/)){const[r,t,s]=e.trim().split(" ");return{basis:parseFloat(s),grow:parseFloat(r),shrink:parseFloat(t)}}return{basis:0,grow:1,shrink:1}},er=(e,r,t,s=!1)=>d.useMemo(()=>{const n=[r===!1?{basis:0,grow:0,shrink:0,minWidth:0,component:()=>b.jsx(b.Fragment,{}),headerClassName:"dsg-hidden-cell",cellClassName:"dsg-hidden-cell",isCellEmpty:ut}:{...r,basis:r?.basis??40,grow:r?.grow??0,shrink:r?.shrink??0,minWidth:r?.minWidth??0,title:r?.title??b.jsx("div",{className:"dsg-corner-indicator"}),component:r?.component??Jn,isCellEmpty:ut},...e];return t&&n.push({...t,basis:t?.basis??40,grow:t?.grow??0,shrink:t?.shrink??0,minWidth:t.minWidth??0,isCellEmpty:ut}),n.map((o,i)=>{const a=o.width!==void 0?Hn(o.width):{basis:void 0,grow:void 0,shrink:void 0},f=i===1&&s;return{...o,basis:o.basis??a.basis??0,grow:o.grow??a.grow??1,shrink:o.shrink??a.shrink??1,minWidth:o.minWidth??100,component:o.component??Xn,disableKeys:o.disableKeys??!1,disabled:o.disabled??!1,keepFocus:o.keepFocus??!1,deleteValue:o.deleteValue??Lt,copyValue:o.copyValue??Zn,pasteValue:o.pasteValue??Lt,prePasteValues:o.prePasteValues??Qn,isCellEmpty:o.isCellEmpty??Yn,stickyLeft:f}})},[r,t,e,s]);function qe(e,r,t,s){var n,o=!1,i=0;function a(){n&&clearTimeout(n)}function f(){a(),o=!0}typeof r!="boolean"&&(s=t,t=r,r=void 0);function h(){for(var g=arguments.length,T=new Array(g),p=0;p<g;p++)T[p]=arguments[p];var R=this,S=Date.now()-i;if(o)return;function N(){i=Date.now(),t.apply(R,T)}function z(){n=void 0}s&&!n&&N(),a(),s===void 0&&S>e?N():r!==!0&&(n=setTimeout(s?z:N,s===void 0?e-S:e))}return h.cancel=f,h}function tr(e,r,t){return t===void 0?qe(e,r,!1):qe(e,t,r!==!1)}var ft,Pt;function nr(){return Pt||(Pt=1,ft=function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var s,n,o;if(Array.isArray(r)){if(s=r.length,s!=t.length)return!1;for(n=s;n--!==0;)if(!e(r[n],t[n]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(o=Object.keys(r),s=o.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=s;n--!==0;){var i=o[n];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t}),ft}var rr=nr();const nn=We(rr),Le=e=>{const[r,t]=d.useState(e),s=d.useCallback(n=>{t(o=>{const i=typeof n=="function"?n(o):n;return nn(i,o)?o:i})},[t]);return[r,s]},sr=(e,r,t)=>{const[s,n]=Le({top:!0,right:!0,bottom:!0,left:!0});return d.useEffect(()=>{const o=qe(100,()=>{n({top:e.current?.scrollTop===0,right:(e.current?.scrollLeft??0)>=(e.current?.scrollWidth??0)-(r??0)-1,bottom:(e.current?.scrollTop??0)>=(e.current?.scrollHeight??0)-(t??0)-1,left:e.current?.scrollLeft===0})}),i=e.current;return i?.addEventListener("scroll",o),setTimeout(o,100),()=>{i?.removeEventListener("scroll",o),o.cancel()}},[t,r,e,n]),s},de=(e,r)=>{d.useEffect(()=>(document.addEventListener(e,r),()=>{document.removeEventListener(e,r)}),[r,e])},qt=(e,r=200)=>{const t=d.useRef(null),s=d.useMemo(()=>qe(r,!0,()=>{setTimeout(()=>t.current=e.current?.getBoundingClientRect()||null,0)}),[e,r]);return d.useCallback((n=!1)=>(n?t.current=e.current?.getBoundingClientRect()||null:s(),t.current),[e,s])},rn=(e={})=>(({addRows:r})=>{const[t,s]=d.useState(1),[n,o]=d.useState(String(t));return b.jsxs("div",{className:"dsg-add-row",children:[b.jsx("button",{type:"button",className:"dsg-add-row-btn",onClick:()=>r(t),children:e.button??"Add"})," ",b.jsx("input",{className:"dsg-add-row-input",value:n,onBlur:()=>o(String(t)),type:"number",min:1,onChange:i=>{o(i.target.value),s(Math.max(1,Math.round(parseInt(i.target.value)||0)))},onKeyDown:i=>{i.key==="Enter"&&r(t)}})," ",e.unit??"rows"]})}),sn=rn();sn.displayName="AddRows";const or=(e,r)=>{const[t,s]=d.useState(e),n=d.useRef();d.useEffect(()=>()=>n.current?.cancel(),[]);const o=d.useMemo(()=>n.current=tr(r,i=>{s(i)}),[r]);return[t,o]},gt=e=>e.type==="CUT"?b.jsx(b.Fragment,{children:"Cut"}):e.type==="COPY"?b.jsx(b.Fragment,{children:"Copy"}):e.type==="PASTE"?b.jsx(b.Fragment,{children:"Paste"}):e.type==="DELETE_ROW"?b.jsx(b.Fragment,{children:"Delete row"}):e.type==="DELETE_ROWS"?b.jsxs(b.Fragment,{children:["Delete rows ",b.jsx("b",{children:e.fromRow})," to ",b.jsx("b",{children:e.toRow})]}):e.type==="INSERT_ROW_BELLOW"?b.jsx(b.Fragment,{children:"Insert row below"}):e.type==="DUPLICATE_ROW"?b.jsx(b.Fragment,{children:"Duplicate row"}):e.type==="DUPLICATE_ROWS"?b.jsxs(b.Fragment,{children:["Duplicate rows ",b.jsx("b",{children:e.fromRow})," to ",b.jsx("b",{children:e.toRow})]}):e.type,on=(e=gt)=>(({clientX:r,clientY:t,items:s,close:n})=>{const o=d.useRef(null),i=d.useCallback(a=>{o.current?.contains(a.target)||n()},[n]);return de("mousedown",i),b.jsx("div",{className:"dsg-context-menu",style:{left:r+"px",top:t+"px"},ref:o,children:s.map(a=>b.jsx("div",{onClick:a.action,className:"dsg-context-menu-item",children:e(a)},a.type))})}),ln=on(gt);ln.displayName="ContextMenu";const ir=typeof DOMParser<"u"?new DOMParser:{parseFromString:()=>null},lr=e=>ir.parseFromString(e,"text/html"),dt=e=>{const r=lr(e.replace(/<br\/?>/g,`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),d=require("react"),Nn=require("react-dom");function Mn(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const Le=Mn(d),kn=(e,r)=>{const t=r.map(({basis:n,minWidth:o,maxWidth:i})=>({basis:n,minWidth:o,maxWidth:i,size:n,violation:0,frozen:!1,factor:0}));let s=t.reduce((n,o)=>n-o.size,e);s>0?r.forEach(({grow:n},o)=>{t[o].factor=n}):s<0&&r.forEach(({shrink:n},o)=>{t[o].factor=n});for(const n of t)n.factor===0&&(n.frozen=!0);for(;t.some(({frozen:n})=>!n);){const n=t.reduce((i,a)=>i+(a.frozen?0:a.factor),0);let o=0;for(const i of t)i.frozen||(i.size+=s*i.factor/n,i.size<i.minWidth?i.violation=i.minWidth-i.size:i.maxWidth!==void 0&&i.size>i.maxWidth?i.violation=i.maxWidth-i.size:i.violation=0,i.size+=i.violation,o+=i.violation);if(o>0)for(const i of t)i.violation>0&&(i.frozen=!0);else if(o<0)for(const i of t)i.violation<0&&(i.frozen=!0);else break;s=t.reduce((i,a)=>i-a.size,e)}return t.map(({size:n})=>n)},An=(e,r)=>{const t=e.map(({basis:s,minWidth:n,maxWidth:o,grow:i,shrink:a})=>[s,n,o,i,a].join(",")).join("|");return d.useMemo(()=>{if(r===void 0)return{fullWidth:!1,columnWidths:void 0,columnRights:void 0,totalWidth:void 0};const s=kn(r,e);let n=0;const o=s.map((i,a)=>(n+=i,a===s.length-1?1/0:n));return{fullWidth:Math.abs(r-n)<.1,columnWidths:s,columnRights:o,totalWidth:n}},[r,t])};var ze=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function We(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ze,Ct;function gt(){if(Ct)return Ze;Ct=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return Ze=e,Ze}var Je,Tt;function _n(){if(Tt)return Je;Tt=1;var e=typeof ze=="object"&&ze&&ze.Object===Object&&ze;return Je=e,Je}var Qe,Dt;function tn(){if(Dt)return Qe;Dt=1;var e=_n(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return Qe=t,Qe}var He,Rt;function zn(){if(Rt)return He;Rt=1;var e=tn(),r=function(){return e.Date.now()};return He=r,He}var et,Ot;function Fn(){if(Ot)return et;Ot=1;var e=/\s/;function r(t){for(var s=t.length;s--&&e.test(t.charAt(s)););return s}return et=r,et}var tt,jt;function Vn(){if(jt)return tt;jt=1;var e=Fn(),r=/^\s+/;function t(s){return s&&s.slice(0,e(s)+1).replace(r,"")}return tt=t,tt}var nt,Nt;function nn(){if(Nt)return nt;Nt=1;var e=tn(),r=e.Symbol;return nt=r,nt}var rt,Mt;function Pn(){if(Mt)return rt;Mt=1;var e=nn(),r=Object.prototype,t=r.hasOwnProperty,s=r.toString,n=e?e.toStringTag:void 0;function o(i){var a=t.call(i,n),f=i[n];try{i[n]=void 0;var m=!0}catch{}var g=s.call(i);return m&&(a?i[n]=f:delete i[n]),g}return rt=o,rt}var st,kt;function Ln(){if(kt)return st;kt=1;var e=Object.prototype,r=e.toString;function t(s){return r.call(s)}return st=t,st}var ot,At;function qn(){if(At)return ot;At=1;var e=nn(),r=Pn(),t=Ln(),s="[object Null]",n="[object Undefined]",o=e?e.toStringTag:void 0;function i(a){return a==null?a===void 0?n:s:o&&o in Object(a)?r(a):t(a)}return ot=i,ot}var it,_t;function Wn(){if(_t)return it;_t=1;function e(r){return r!=null&&typeof r=="object"}return it=e,it}var lt,zt;function Bn(){if(zt)return lt;zt=1;var e=qn(),r=Wn(),t="[object Symbol]";function s(n){return typeof n=="symbol"||r(n)&&e(n)==t}return lt=s,lt}var at,Ft;function Kn(){if(Ft)return at;Ft=1;var e=Vn(),r=gt(),t=Bn(),s=NaN,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,a=parseInt;function f(m){if(typeof m=="number")return m;if(t(m))return s;if(r(m)){var g=typeof m.valueOf=="function"?m.valueOf():m;m=r(g)?g+"":g}if(typeof m!="string")return m===0?m:+m;m=e(m);var R=o.test(m);return R||i.test(m)?a(m.slice(2),R?2:8):n.test(m)?s:+m}return at=f,at}var ct,Vt;function rn(){if(Vt)return ct;Vt=1;var e=gt(),r=zn(),t=Kn(),s="Expected a function",n=Math.max,o=Math.min;function i(a,f,m){var g,R,p,O,S,T,M=0,U=!1,D=!1,A=!0;if(typeof a!="function")throw new TypeError(s);f=t(f)||0,e(m)&&(U=!!m.leading,D="maxWait"in m,p=D?n(t(m.maxWait)||0,f):p,A="trailing"in m?!!m.trailing:A);function L(z){var Q=g,b=R;return g=R=void 0,M=z,O=a.apply(b,Q),O}function j(z){return M=z,S=setTimeout(se,f),U?L(z):O}function F(z){var Q=z-T,b=z-M,k=f-Q;return D?o(k,p-b):k}function ae(z){var Q=z-T,b=z-M;return T===void 0||Q>=f||Q<0||D&&b>=p}function se(){var z=r();if(ae(z))return ee(z);S=setTimeout(se,F(z))}function ee(z){return S=void 0,A&&g?L(z):(g=R=void 0,O)}function X(){S!==void 0&&clearTimeout(S),M=0,g=T=R=S=void 0}function ce(){return S===void 0?O:ee(r())}function q(){var z=r(),Q=ae(z);if(g=arguments,R=this,T=z,Q){if(S===void 0)return j(T);if(D)return clearTimeout(S),S=setTimeout(se,f),L(T)}return S===void 0&&(S=setTimeout(se,f)),O}return q.cancel=X,q.flush=ce,q}return ct=i,ct}var Un=rn();const $n=We(Un);var ut,Pt;function Gn(){if(Pt)return ut;Pt=1;var e=rn(),r=gt(),t="Expected a function";function s(n,o,i){var a=!0,f=!0;if(typeof n!="function")throw new TypeError(t);return r(i)&&(a="leading"in i?!!i.leading:a,f="trailing"in i?!!i.trailing:f),e(n,o,{leading:a,maxWait:o,trailing:f})}return ut=s,ut}var Xn=Gn();const Yn=We(Xn),Zn=(e,r,t,s)=>{switch(r){case"debounce":return $n(e,t,s);case"throttle":return Yn(e,t,s);default:return e}};function Jn({skipOnMount:e=!1,refreshMode:r,refreshRate:t=1e3,refreshOptions:s,handleWidth:n=!0,handleHeight:o=!0,targetRef:i,observerOptions:a,onResize:f}={}){const m=d.useRef(e),[g,R]=d.useState({width:void 0,height:void 0}),[p,O]=d.useState(i?.current||null);i&&setTimeout(()=>{i.current!==p&&O(i.current)},0);const S=d.useMemo(()=>new Proxy(D=>{D!==p&&O(D)},{get(D,A){return A==="current"?p:D[A]},set(D,A,L){return A==="current"?O(L):D[A]=L,!0}}),[p]),T=d.useCallback((D,A)=>!(D.width===A.width&&D.height===A.height||D.width===A.width&&!o||D.height===A.height&&!n),[n,o]),M=d.useCallback(D=>{if(!(!n&&!o)){if(m.current){m.current=!1;return}D.forEach(A=>{const{width:L,height:j}=A?.contentRect||{};R(F=>T(F,{width:L,height:j})?{width:L,height:j}:F)})}},[n,o,m,T]),U=d.useCallback(Zn(M,r,t,s),[M,r,t,s]);return d.useEffect(()=>{let D;return p?(D=new window.ResizeObserver(U),D.observe(p,a)):(g.width||g.height)&&R({width:void 0,height:void 0}),()=>{var A,L,j;(A=D?.disconnect)===null||A===void 0||A.call(D),(j=(L=U).cancel)===null||j===void 0||j.call(L)}},[U,p]),d.useEffect(()=>{f?.(g.width,g.height)},[g]),Object.assign({ref:S},g)}const Qn=()=>x.jsx(x.Fragment,{}),Hn=()=>!1,Lt=({rowData:e})=>e,er=()=>null,tr=({rowIndex:e})=>x.jsx(x.Fragment,{children:e+1}),ft=()=>!0,nr=e=>e,rr=e=>{if(typeof e=="number")return{basis:0,grow:e,shrink:1};if(e.match(/^ *\d+(\.\d*)? *$/))return{basis:0,grow:parseFloat(e.trim()),shrink:1};if(e.match(/^ *\d+(\.\d*)? *px *$/))return{basis:parseFloat(e.trim()),grow:1,shrink:1};if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? *$/)){const[r,t]=e.trim().split(" ");return{basis:0,grow:parseFloat(r),shrink:parseFloat(t)}}if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? *px *$/)){const[r,t]=e.trim().split(" ");return{basis:parseFloat(t),grow:parseFloat(r),shrink:1}}if(e.match(/^ *\d+(\.\d*)? \d+(\.\d*)? \d+(\.\d*)? *px *$/)){const[r,t,s]=e.trim().split(" ");return{basis:parseFloat(s),grow:parseFloat(r),shrink:parseFloat(t)}}return{basis:0,grow:1,shrink:1}},sr=(e,r,t,s=!1)=>d.useMemo(()=>{const n=[r===!1?{basis:0,grow:0,shrink:0,minWidth:0,component:()=>x.jsx(x.Fragment,{}),headerClassName:"dsg-hidden-cell",cellClassName:"dsg-hidden-cell",isCellEmpty:ft}:{...r,basis:r?.basis??40,grow:r?.grow??0,shrink:r?.shrink??0,minWidth:r?.minWidth??0,title:r?.title??x.jsx("div",{className:"dsg-corner-indicator"}),component:r?.component??tr,isCellEmpty:ft},...e];return t&&n.push({...t,basis:t?.basis??40,grow:t?.grow??0,shrink:t?.shrink??0,minWidth:t.minWidth??0,isCellEmpty:ft}),n.map((o,i)=>{const a=o.width!==void 0?rr(o.width):{basis:void 0,grow:void 0,shrink:void 0},f=o.stickyLeft!==void 0?o.stickyLeft:i===1&&s;return{...o,basis:o.basis??a.basis??0,grow:o.grow??a.grow??1,shrink:o.shrink??a.shrink??1,minWidth:o.minWidth??100,component:o.component??Qn,disableKeys:o.disableKeys??!1,disabled:o.disabled??!1,keepFocus:o.keepFocus??!1,deleteValue:o.deleteValue??Lt,copyValue:o.copyValue??er,pasteValue:o.pasteValue??Lt,prePasteValues:o.prePasteValues??nr,isCellEmpty:o.isCellEmpty??Hn,stickyLeft:f}})},[r,t,e,s]);function qe(e,r,t,s){var n,o=!1,i=0;function a(){n&&clearTimeout(n)}function f(){a(),o=!0}typeof r!="boolean"&&(s=t,t=r,r=void 0);function m(){for(var g=arguments.length,R=new Array(g),p=0;p<g;p++)R[p]=arguments[p];var O=this,S=Date.now()-i;if(o)return;function T(){i=Date.now(),t.apply(O,R)}function M(){n=void 0}s&&!n&&T(),a(),s===void 0&&S>e?T():r!==!0&&(n=setTimeout(s?M:T,s===void 0?e-S:e))}return m.cancel=f,m}function or(e,r,t){return t===void 0?qe(e,r,!1):qe(e,t,r!==!1)}var dt,qt;function ir(){return qt||(qt=1,dt=function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var s,n,o;if(Array.isArray(r)){if(s=r.length,s!=t.length)return!1;for(n=s;n--!==0;)if(!e(r[n],t[n]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(o=Object.keys(r),s=o.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=s;n--!==0;){var i=o[n];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t}),dt}var lr=ir();const sn=We(lr),Pe=e=>{const[r,t]=d.useState(e),s=d.useCallback(n=>{t(o=>{const i=typeof n=="function"?n(o):n;return sn(i,o)?o:i})},[t]);return[r,s]},ar=(e,r,t)=>{const[s,n]=Pe({top:!0,right:!0,bottom:!0,left:!0});return d.useEffect(()=>{const o=qe(100,()=>{n({top:e.current?.scrollTop===0,right:(e.current?.scrollLeft??0)>=(e.current?.scrollWidth??0)-(r??0)-1,bottom:(e.current?.scrollTop??0)>=(e.current?.scrollHeight??0)-(t??0)-1,left:e.current?.scrollLeft===0})}),i=e.current;return i?.addEventListener("scroll",o),setTimeout(o,100),()=>{i?.removeEventListener("scroll",o),o.cancel()}},[t,r,e,n]),s},pe=(e,r)=>{d.useEffect(()=>(document.addEventListener(e,r),()=>{document.removeEventListener(e,r)}),[r,e])},Wt=(e,r=200)=>{const t=d.useRef(null),s=d.useMemo(()=>qe(r,!0,()=>{setTimeout(()=>t.current=e.current?.getBoundingClientRect()||null,0)}),[e,r]);return d.useCallback((n=!1)=>(n?t.current=e.current?.getBoundingClientRect()||null:s(),t.current),[e,s])},on=(e={})=>(({addRows:r})=>{const[t,s]=d.useState(1),[n,o]=d.useState(String(t));return x.jsxs("div",{className:"dsg-add-row",children:[x.jsx("button",{type:"button",className:"dsg-add-row-btn",onClick:()=>r(t),children:e.button??"Add"})," ",x.jsx("input",{className:"dsg-add-row-input",value:n,onBlur:()=>o(String(t)),type:"number",min:1,onChange:i=>{o(i.target.value),s(Math.max(1,Math.round(parseInt(i.target.value)||0)))},onKeyDown:i=>{i.key==="Enter"&&r(t)}})," ",e.unit??"rows"]})}),ln=on();ln.displayName="AddRows";const cr=(e,r)=>{const[t,s]=d.useState(e),n=d.useRef();d.useEffect(()=>()=>n.current?.cancel(),[]);const o=d.useMemo(()=>n.current=or(r,i=>{s(i)}),[r]);return[t,o]},wt=e=>e.type==="CUT"?x.jsx(x.Fragment,{children:"Cut"}):e.type==="COPY"?x.jsx(x.Fragment,{children:"Copy"}):e.type==="PASTE"?x.jsx(x.Fragment,{children:"Paste"}):e.type==="DELETE_ROW"?x.jsx(x.Fragment,{children:"Delete row"}):e.type==="DELETE_ROWS"?x.jsxs(x.Fragment,{children:["Delete rows ",x.jsx("b",{children:e.fromRow})," to ",x.jsx("b",{children:e.toRow})]}):e.type==="INSERT_ROW_BELLOW"?x.jsx(x.Fragment,{children:"Insert row below"}):e.type==="DUPLICATE_ROW"?x.jsx(x.Fragment,{children:"Duplicate row"}):e.type==="DUPLICATE_ROWS"?x.jsxs(x.Fragment,{children:["Duplicate rows ",x.jsx("b",{children:e.fromRow})," to ",x.jsx("b",{children:e.toRow})]}):e.type,an=(e=wt)=>(({clientX:r,clientY:t,items:s,close:n})=>{const o=d.useRef(null),i=d.useCallback(a=>{o.current?.contains(a.target)||n()},[n]);return pe("mousedown",i),x.jsx("div",{className:"dsg-context-menu",style:{left:r+"px",top:t+"px"},ref:o,children:s.map(a=>x.jsx("div",{onClick:a.action,className:"dsg-context-menu-item",children:e(a)},a.type))})}),cn=an(wt);cn.displayName="ContextMenu";const ur=typeof DOMParser<"u"?new DOMParser:{parseFromString:()=>null},fr=e=>ur.parseFromString(e,"text/html"),ht=e=>{const r=fr(e.replace(/<br\/?>/g,`
2
2
  `)),t=r.getElementsByTagName("table")[0];if(t){const n=[];for(let o=0;o<t.rows.length;o++){const i=[];n.push(i);for(let a=0;a<t.rows[o].cells.length;a++)i.push(t.rows[o].cells[a].textContent??"")}return n}const s=r.getElementsByTagName("span")[0];return s?[[s.textContent??""]]:[[""]]},Fe=e=>{const r=e.replace(/\r|\n$/g,""),t=[[]];let s=0,n=0,o=!1,i=0;const a=()=>{let f=r.slice(n,s);f[0]==='"'&&f[f.length-1]==='"'&&(o=!0),o&&f[f.length-1]==='"'&&f.includes(`
3
3
  `)&&(f=f.slice(1,f.length-1).replace(/""/g,'"'),o=!1),o&&f[f.length-1]!=='"'?f.split(`
4
- `).forEach((h,g,{length:T})=>{t[i].push(h),g<T-1&&(t.push([]),i++)}):t[i].push(f)};for(;s<r.length;)o&&r[s]==='"'&&![void 0," ",'"'].includes(r[s+1])&&(o=!1),o&&r[s]==='"'&&r[s+1]==='"'&&s++,s===n&&r[s]==='"'&&(o=!0),r[s]===" "&&(a(),n=s+1,o=!1),r[s]===`
5
- `&&!o&&(a(),t.push([]),n=s+1,i++),s++;return a(),t},ar=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),cr=e=>e.match(/^[^\x00-\x20\x7F-\x9F]$/)!==null,mt=(e,r,t,s)=>{if(e===null||!r||!t)return null;if(typeof e!="object")throw new Error("Value must be an object or null");const n=s.findIndex(i=>i.id===e.col),o={col:Math.max(0,Math.min(r-1,n===-1?Number(e.col):n-1)),row:Math.max(0,Math.min(t-1,Number(e.row)))};if(isNaN(o.col)||isNaN(o.row))throw new Error("col or cell are not valid positive numbers");return o},Te=(e,r)=>e?{col:e.col,row:e.row,colId:r[e.col+1]?.id}:null,ur=(e,r,t,s)=>{if(e===null||!r||!t)return null;if(typeof e!="object")throw new Error("Value must be an object or null");const n={min:mt(e.min,r,t,s),max:mt(e.max,r,t,s)};if(!n.min||!n.max)throw new Error("min and max must be defined");return n},Wt=(e,r)=>e?{min:Te(e.min,r),max:Te(e.max,r)}:null,Bt=()=>Array.from(document.querySelectorAll("*")).filter(e=>e instanceof HTMLElement&&typeof e.tabIndex=="number"&&e.tabIndex>=0&&!e.disabled&&(!(e instanceof HTMLAnchorElement)||!!e.href||e.getAttribute("tabIndex")!==null)&&getComputedStyle(e).visibility!=="collapse");function Ce(e,r,t){let s=t.initialDeps??[],n,o=!0;function i(){var a,f,h;let g;t.key&&((a=t.debug)!=null&&a.call(t))&&(g=Date.now());const T=e();if(!(T.length!==s.length||T.some((S,N)=>s[N]!==S)))return n;s=T;let R;if(t.key&&((f=t.debug)!=null&&f.call(t))&&(R=Date.now()),n=r(...T),t.key&&((h=t.debug)!=null&&h.call(t))){const S=Math.round((Date.now()-g)*100)/100,N=Math.round((Date.now()-R)*100)/100,z=N/16,W=(D,O)=>{for(D=String(D);D.length<O;)D=" "+D;return D};console.info(`%c⏱ ${W(N,5)} /${W(S,5)} ms`,`
4
+ `).forEach((m,g,{length:R})=>{t[i].push(m),g<R-1&&(t.push([]),i++)}):t[i].push(f)};for(;s<r.length;)o&&r[s]==='"'&&![void 0," ",'"'].includes(r[s+1])&&(o=!1),o&&r[s]==='"'&&r[s+1]==='"'&&s++,s===n&&r[s]==='"'&&(o=!0),r[s]===" "&&(a(),n=s+1,o=!1),r[s]===`
5
+ `&&!o&&(a(),t.push([]),n=s+1,i++),s++;return a(),t},dr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),hr=e=>e.match(/^[^\x00-\x20\x7F-\x9F]$/)!==null,pt=(e,r,t,s)=>{if(e===null||!r||!t)return null;if(typeof e!="object")throw new Error("Value must be an object or null");const n=s.findIndex(i=>i.id===e.col),o={col:Math.max(0,Math.min(r-1,n===-1?Number(e.col):n-1)),row:Math.max(0,Math.min(t-1,Number(e.row)))};if(isNaN(o.col)||isNaN(o.row))throw new Error("col or cell are not valid positive numbers");return o},Re=(e,r)=>e?{col:e.col,row:e.row,colId:r[e.col+1]?.id}:null,mr=(e,r,t,s)=>{if(e===null||!r||!t)return null;if(typeof e!="object")throw new Error("Value must be an object or null");const n={min:pt(e.min,r,t,s),max:pt(e.max,r,t,s)};if(!n.min||!n.max)throw new Error("min and max must be defined");return n},Bt=(e,r)=>e?{min:Re(e.min,r),max:Re(e.max,r)}:null,Kt=()=>Array.from(document.querySelectorAll("*")).filter(e=>e instanceof HTMLElement&&typeof e.tabIndex=="number"&&e.tabIndex>=0&&!e.disabled&&(!(e instanceof HTMLAnchorElement)||!!e.href||e.getAttribute("tabIndex")!==null)&&getComputedStyle(e).visibility!=="collapse");function De(e,r,t){let s=t.initialDeps??[],n,o=!0;function i(){var a,f,m;let g;t.key&&((a=t.debug)!=null&&a.call(t))&&(g=Date.now());const R=e();if(!(R.length!==s.length||R.some((S,T)=>s[T]!==S)))return n;s=R;let O;if(t.key&&((f=t.debug)!=null&&f.call(t))&&(O=Date.now()),n=r(...R),t.key&&((m=t.debug)!=null&&m.call(t))){const S=Math.round((Date.now()-g)*100)/100,T=Math.round((Date.now()-O)*100)/100,M=T/16,U=(D,A)=>{for(D=String(D);D.length<A;)D=" "+D;return D};console.info(`%c⏱ ${U(T,5)} /${U(S,5)} ms`,`
6
6
  font-size: .6rem;
7
7
  font-weight: bold;
8
- color: hsl(${Math.max(0,Math.min(120-120*z,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(o&&t.skipInitialOnChange)&&t.onChange(n),o=!1,n}return i.updateDeps=a=>{s=a},i}function Kt(e,r){if(e===void 0)throw new Error("Unexpected undefined");return e}const fr=(e,r)=>Math.abs(e-r)<1.01,dr=(e,r,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>r.apply(this,n),t)}},Ut=e=>{const{offsetWidth:r,offsetHeight:t}=e;return{width:r,height:t}},hr=e=>e,an=e=>{const r=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),s=[];for(let n=r;n<=t;n++)s.push(n);return s},mr=(e,r)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=i=>{const{width:a,height:f}=i;r({width:Math.round(a),height:Math.round(f)})};if(n(Ut(t)),!s.ResizeObserver)return()=>{};const o=new s.ResizeObserver(i=>{const a=()=>{const f=i[0];if(f?.borderBoxSize){const h=f.borderBoxSize[0];if(h){n({width:h.inlineSize,height:h.blockSize});return}}n(Ut(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(t,{box:"border-box"}),()=>{o.unobserve(t)}},$t={passive:!0},Gt=typeof window>"u"?!0:"onscrollend"in window,pr=(e,r)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;let n=0;const o=e.options.useScrollendEvent&&Gt?()=>{}:dr(s,()=>{r(n,!1)},e.options.isScrollingResetDelay),i=g=>()=>{const{horizontal:T,isRtl:p}=e.options;n=T?t.scrollLeft*(p&&-1||1):t.scrollTop,o(),r(n,g)},a=i(!0),f=i(!1);t.addEventListener("scroll",a,$t);const h=e.options.useScrollendEvent&&Gt;return h&&t.addEventListener("scrollend",f,$t),()=>{t.removeEventListener("scroll",a),h&&t.removeEventListener("scrollend",f)}},gr=(e,r,t)=>{if(r?.borderBoxSize){const s=r.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},wr=(e,{adjustments:r=0,behavior:t},s)=>{var n,o;const i=e+r;(o=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||o.call(n,{[s.options.horizontal?"left":"top"]:i,behavior:t})};class xr{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var o;return(o=s())==null?void 0:o.observe(n,{box:"border-box"})},unobserve:n=>{var o;return(o=s())==null?void 0:o.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([s,n])=>{typeof n>"u"&&delete t[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:hr,rangeExtractor:an,onChange:()=>{},measureElement:gr,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Ce(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=o,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,s)=>{const n=new Map,o=new Map;for(let i=s-1;i>=0;i--){const a=t[i];if(n.has(a.lane))continue;const f=o.get(a.lane);if(f==null||a.end>f.end?o.set(a.lane,a):a.end<f.end&&n.set(a.lane,!0),n.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=Ce(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,s,n,o,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:s,scrollMargin:n,getItemKey:o,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=Ce(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:s,scrollMargin:n,getItemKey:o,enabled:i,lanes:a},f)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const g=this.measurementsCache.slice(0,h),T=new Array(a).fill(void 0);for(let p=0;p<h;p++){const R=g[p];R&&(T[R.lane]=p)}for(let p=h;p<t;p++){const R=o(p),S=this.laneAssignments.get(p);let N,z;if(S!==void 0&&this.options.lanes>1){N=S;const j=T[N],B=j!==void 0?g[j]:void 0;z=B?B.end+this.options.gap:s+n}else{const j=this.options.lanes===1?g[p-1]:this.getFurthestMeasurement(g,p);z=j?j.end+this.options.gap:s+n,N=j?j.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,N)}const W=f.get(R),D=typeof W=="number"?W:this.options.estimateSize(p),O=z+D;g[p]={index:p,start:z,size:D,end:O,key:R,lane:N},T[N]=p}return this.measurementsCache=g,g},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Ce(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,o)=>this.range=t.length>0&&s>0?br({measurements:t,outerSize:s,scrollOffset:n,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Ce(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,o,i)=>o===null||i===null?[]:t({startIndex:o,endIndex:i,overscan:s,count:n}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(t,s)=>{const n=this.indexFromElement(t),o=this.measurementsCache[n];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==t&&(a&&this.observer.unobserve(a),this.observer.observe(t),this.elementsCache.set(i,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,s,this))},this.resizeItem=(t,s)=>{const n=this.measurementsCache[t];if(!n)return;const o=this.itemSizeCache.get(n.key)??n.size,i=s-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,i,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,s)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((s,n)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=Ce(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let o=0,i=t.length;o<i;o++){const a=t[o],f=s[a];n.push(f)}return n},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length!==0)return Kt(s[cn(0,s.length-1,n=>Kt(s[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=t>=i+o?"end":"start"),s==="center"?t+=(n-o)/2:s==="end"&&(t-=o);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const o=this.getSize(),i=this.getScrollOffset();if(s==="auto")if(n.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(n.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,n.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:s="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,s),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:s="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let o=0;const i=10,a=h=>{if(!this.targetWindow)return;const g=this.getOffsetForIndex(t,h);if(!g){console.warn("Failed to get offset for index:",t);return}const[T,p]=g;this._scrollToOffset(T,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const R=()=>{if(this.currentScrollToIndex!==t)return;const S=this.getScrollOffset(),N=this.getOffsetForIndex(t,p);if(!N){console.warn("Failed to get offset for index:",t);return}fr(N[0],S)||f(p)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(R):R()})},f=h=>{this.targetWindow&&this.currentScrollToIndex===t&&(o++,o<i?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",o,i),this.targetWindow.requestAnimationFrame(()=>a(h))):console.warn(`Failed to scroll to index ${t} after ${i} attempts.`))};a(s)},this.scrollBy=(t,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=s[s.length-1])==null?void 0:t.end)??0;else{const o=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&o.some(a=>a===null);){const a=s[i];o[a.lane]===null&&(o[a.lane]=a.end),i--}n=Math.max(...o.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(r)}}const cn=(e,r,t,s)=>{for(;e<=r;){const n=(e+r)/2|0,o=t(n);if(o<s)e=n+1;else if(o>s)r=n-1;else return n}return e>0?e-1:0};function br({measurements:e,outerSize:r,scrollOffset:t,lanes:s}){const n=e.length-1,o=f=>e[f].start;if(e.length<=s)return{startIndex:0,endIndex:n};let i=cn(0,n,o,t),a=i;if(s===1)for(;a<n&&e[a].end<t+r;)a++;else if(s>1){const f=Array(s).fill(0);for(;a<n&&f.some(g=>g<t+r);){const g=e[a];f[g.lane]=g.end,a++}const h=Array(s).fill(t+r);for(;i>=0&&h.some(g=>g>=t);){const g=e[i];h[g.lane]=g.start,i--}i=Math.max(0,i-i%s),a=Math.min(n,a+(s-1-a%s))}return{startIndex:i,endIndex:a}}const Xt=typeof document<"u"?Pe.useLayoutEffect:Pe.useEffect;function yr({useFlushSync:e=!0,...r}){const t=Pe.useReducer(()=>({}),{})[1],s={...r,onChange:(o,i)=>{var a;e&&i?On.flushSync(t):t(),(a=r.onChange)==null||a.call(r,o,i)}},[n]=Pe.useState(()=>new xr(s));return n.setOptions(s),Xt(()=>n._didMount(),[]),Xt(()=>n._willUpdate()),n}function Yt(e){return yr({observeElementRect:mr,observeElementOffset:pr,scrollToFn:wr,...e})}var ht={exports:{}};var Zt;function vr(){return Zt||(Zt=1,(function(e){(function(){var r={}.hasOwnProperty;function t(){for(var o="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(o=n(o,s(a)))}return o}function s(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var a in o)r.call(o,a)&&o[a]&&(i=n(i,a));return i}function n(o,i){return i?o?o+" "+i:o+i:o}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(ht)),ht.exports}var Er=vr();const Z=We(Er),Jt=({children:e,gutter:r,stickyRight:t,stickyLeft:s,active:n,disabled:o,className:i,width:a,left:f})=>b.jsx("div",{className:Z("dsg-cell",r&&"dsg-cell-gutter",o&&"dsg-cell-disabled",r&&n&&"dsg-cell-gutter-active",t&&"dsg-cell-sticky-right",s&&"dsg-cell-sticky-left",i),style:{width:a,left:t?void 0:f},children:e}),Ve=(e,r)=>d.useMemo(()=>{const t=new Map;return s=>(t.has(s)||t.set(s,(...n)=>{e(s,...n.slice(0,r))}),t.get(s))},[r,e]),Sr=({data:e,columns:r,outerRef:t,innerRef:s,columnWidths:n,hasStickyRightColumn:o,pinFirstColumn:i,displayHeight:a,headerRowHeight:f,rowHeight:h,rowKey:g,fullWidth:T,selection:p,activeCell:R,rowClassName:S,cellClassName:N,children:z,editing:W,getContextMenuItems:D,setRowData:O,deleteRows:j,duplicateRows:B,insertRowAfter:L,stopEditing:ie,onScroll:se})=>{const K=Yt({count:e.length,getScrollElement:()=>t.current,paddingStart:f,estimateSize:E=>h(E).height,getItemKey:E=>{if(g&&E>0){const q=e[E-1];if(typeof g=="function")return g({rowData:q,rowIndex:E});if(typeof g=="string"&&q instanceof Object&&g in q){const F=q[g];if(typeof F=="string"||typeof F=="number")return F}}return E},overscan:5}),U=Yt({count:r.length,getScrollElement:()=>t.current,estimateSize:E=>n?.[E]??100,horizontal:!0,getItemKey:E=>r[E].id??E,overscan:1,rangeExtractor:E=>{const q=an(E);if(q[0]!==0&&q.unshift(0),i&&!q.includes(1)){const F=q.findIndex(ne=>ne>1);F===-1?q.push(1):q.splice(F,0,1)}return o&&q[q.length-1]!==r.length-1&&q.push(r.length-1),q}});d.useEffect(()=>{U.measure()},[U,n]);const he=Ve(O,1),pe=Ve(j,0),V=Ve(B,0),Q=Ve(L,0),y=E=>{if(!r[E].stickyLeft||!n)return 0;let q=0;for(let F=0;F<E;F++)q+=n[F];return q},k=p?.min.col??R?.col,ge=p?.max.col??R?.col,H=p?.min.row??R?.row,Oe=p?.max.row??R?.row;return b.jsx("div",{ref:t,className:"dsg-container",onScroll:se,style:{height:a},children:b.jsxs("div",{ref:s,style:{width:T?"100%":U.getTotalSize(),height:K.getTotalSize()},children:[f>0&&b.jsx("div",{className:Z("dsg-row","dsg-row-header"),style:{width:T?"100%":U.getTotalSize(),height:f},children:U.getVirtualItems().map(E=>{const q=!!r[E.index].stickyLeft;return b.jsx(Jt,{gutter:E.index===0,stickyRight:o&&E.index===r.length-1,stickyLeft:q,width:E.size,left:q?y(E.index):E.start,className:Z("dsg-cell-header",k!==void 0&&ge!==void 0&&k<=E.index-1&&ge>=E.index-1&&"dsg-cell-header-active",r[E.index].headerClassName),children:b.jsx("div",{className:"dsg-cell-header-container",children:r[E.index].title})},E.key)})}),K.getVirtualItems().map(E=>{const q=E.index>=(H??1/0)&&E.index<=(Oe??-1/0);return b.jsx("div",{className:Z("dsg-row",typeof S=="string"?S:null,typeof S=="function"?S({rowData:e[E.index],rowIndex:E.index}):null),style:{height:E.size,top:E.start,width:T?"100%":U.getTotalSize()},children:U.getVirtualItems().map(F=>{const ne=r[F.index].cellClassName,Re=r[F.index].disabled,Ae=r[F.index].component,De=Re===!0||typeof Re=="function"&&Re({rowData:e[E.index],rowIndex:E.index}),ae=R?.row===E.index&&R.col===F.index-1,le=!!r[F.index].stickyLeft;return b.jsx(Jt,{gutter:F.index===0,stickyRight:o&&F.index===r.length-1,stickyLeft:le,active:F.index===0&&q,disabled:De,className:Z(typeof ne=="function"?ne({rowData:e[E.index],rowIndex:E.index,columnId:r[F.index].id}):ne,typeof N=="function"?N({rowData:e[E.index],rowIndex:E.index,columnId:r[F.index].id}):N),width:F.size,left:le?y(F.index):F.start,children:b.jsx(Ae,{rowData:e[E.index],getContextMenuItems:D,disabled:De,active:ae,columnIndex:F.index-1,rowIndex:E.index,focus:ae&&W,deleteRow:pe(E.index),duplicateRow:V(E.index),stopEditing:ie,insertRowBelow:Q(E.index),setRowData:he(E.index),columnData:r[F.index].columnData})},F.key)})},E.key)}),z]})})},Qt=(e,r,t,s)=>[[s,e],[r,e],[r,t],[s,t],[s,e]],Ir=(e,r,t,s)=>`polygon(evenodd, ${[...Qt(0,"100%","100%",0),...Qt(e,r,t,s)].map(o=>o.map(i=>typeof i=="number"&&i!==0?i+"px":i).join(" ")).join(",")})`,un=d.memo(({columnWidths:e,columnRights:r,headerRowHeight:t,selection:s,rowHeight:n,activeCell:o,hasStickyRightColumn:i,dataLength:a,viewWidth:f,viewHeight:h,contentWidth:g,edges:T,isCellDisabled:p,editing:R,expandSelection:S})=>{const N=o?p(o):!1,z=d.useMemo(()=>{if(!s)return N;for(let K=s.min.col;K<=s.max.col;++K)for(let U=s.min.row;U<=s.max.row;++U)if(!p({col:K,row:U}))return!1;return!0},[N,p,s]);if(!e||!r)return null;const W=K=>K<a-1?1:0,D=K=>K<e.length-(i?3:2)?1:0,O=o&&{width:e[o.col+1]+D(o.col),height:n(o.row).height+W(o.row),left:r[o.col],top:n(o.row).top+t},j=s&&{width:e.slice(s.min.col+1,s.max.col+2).reduce((K,U)=>K+U)+D(s.max.col),height:n(s.max.row).top+n(s.max.row).height-n(s.min.row).top+W(s.max.row),left:r[s.min.col],top:n(s.min.row).top+t},B=s?.min||o,L=s?.max||o,ie=L&&S!==null&&{left:r[L.col]+e[L.col+1],top:n(L.row).top+n(L.row).height+t,transform:`translate(-${L.col<e.length-(i?3:2)?50:100}%, -${L.row<a-1?50:100}%)`},se=B&&L&&S!==null&&{width:e.slice(B.col+1,L.col+2).reduce((K,U)=>K+U)+D(L.col),height:n(L.row+S).top+n(L.row+S).height-n(L.row+1).top+W(L.row+S)-1,left:r[B.col],top:n(L.row).top+n(L.row).height+t+1};return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"dsg-scrollable-view-container",style:{height:n(a-1).top+n(a-1).height+t,width:g||"100%"},children:b.jsx("div",{className:Z({"dsg-scrollable-view":!0,"dsg-scrollable-view-t":!T.top,"dsg-scrollable-view-r":!T.right,"dsg-scrollable-view-b":!T.bottom,"dsg-scrollable-view-l":!T.left}),style:{top:t,left:e[0],height:h?h-t:0,width:g&&f?f-e[0]-(i?e[e.length-1]:0):`calc(100% - ${e[0]+(i?e[e.length-1]:0)}px)`}})}),(j||O)&&b.jsx("div",{className:"dsg-selection-col-marker-container",style:{left:j?.left??O?.left,width:j?.width??O?.width,height:n(a-1).top+n(a-1).height+t},children:b.jsx("div",{className:Z("dsg-selection-col-marker",z&&"dsg-selection-col-marker-disabled"),style:{top:t}})}),(j||O)&&b.jsx("div",{className:"dsg-selection-row-marker-container",style:{top:j?.top??O?.top,height:j?.height??O?.height,width:g||"100%"},children:b.jsx("div",{className:Z("dsg-selection-row-marker",z&&"dsg-selection-row-marker-disabled"),style:{left:e[0]}})}),O&&o&&b.jsx("div",{className:Z("dsg-active-cell",{"dsg-active-cell-focus":R,"dsg-active-cell-disabled":N}),style:O}),j&&O&&b.jsx("div",{className:Z("dsg-selection-rect",z&&"dsg-selection-rect-disabled"),style:{...j,clipPath:Ir(O.top-j.top,O.left-j.left,O.top+O.height-j.top,O.left+O.width-j.left)}}),se&&b.jsx("div",{className:Z("dsg-expand-rows-rect"),style:se}),ie&&b.jsx("div",{className:Z("dsg-expand-rows-indicator",z&&"dsg-expand-rows-indicator-disabled"),style:ie})]})});un.displayName="SelectionRect";const Cr=({value:e,rowHeight:r})=>{const t=d.useRef([]),[,s]=d.useState(0);return d.useMemo(()=>{const n=o=>{if(typeof r=="number")return Math.min(e.length-1,Math.max(-1,Math.floor(o/r)));let i=0,a=t.current.length-1;for(;i<=a;){const f=Math.floor((i+a)/2);if(t.current[f].top<o)i=f+1;else if(t.current[f].top>o)a=f-1;else return f}if(a===t.current.length-1&&e.length>t.current.length&&(!t.current.length||o>=t.current[a].top+t.current[a].height)){let f=a===-1?0:t.current[a].top+t.current[a].height;do{a++;const h=r({rowIndex:a,rowData:e[a]});t.current.push({height:h,top:f}),f+=h}while(f<=o&&a<t.current.length-1)}return a};return{resetAfter:o=>{t.current=t.current.slice(0,o),s(i=>i+1)},getRowSize:o=>{if(typeof r=="number")return{height:r,top:r*o};if(o>=e.length)return{height:0,top:0};if(o<t.current.length)return t.current[o];let i=t.current[t.current.length-1].top+t.current[t.current.length-1].height;for(let a=t.current.length;a<=o;a++){const f=r({rowIndex:a,rowData:e[a]});t.current.push({height:f,top:i}),i+=f}return t.current[o]},getRowIndex:n,totalSize:o=>{if(typeof r=="number")return e.length*r;const i=n(o);return t.current[i].top+t.current[i].height}}},[r,e])},Tr=[],Or=[],Rr=()=>({}),Me=()=>null,Dr=({rowData:e})=>({...e}),wt=d.memo(d.forwardRef(({value:e=Tr,className:r,style:t,height:s=400,onChange:n=Me,columns:o=Or,rowHeight:i=40,headerRowHeight:a=typeof i=="number"?i:40,gutterColumn:f,stickyRightColumn:h,rowKey:g,addRowsComponent:T=sn,createRow:p=Rr,autoAddRow:R=!1,lockRows:S=!1,disableExpandSelection:N=!1,disableSmartDelete:z=!1,duplicateRow:W=Dr,contextMenuComponent:D=ln,disableContextMenu:O=!1,onFocus:j=Me,onBlur:B=Me,onActiveCellChange:L=Me,onSelectionChange:ie=Me,rowClassName:se,cellClassName:K,onScroll:U,pinFirstColumn:he=!1},pe)=>{const V=d.useRef(null),Q=O||S,y=er(o,f,h,he),k=!!h,ge=d.useRef(null),H=d.useRef(null),Oe=d.useRef(null),E=d.useRef(null),[q,F]=or(1,100),{getRowSize:ne,totalSize:Re,getRowIndex:Ae}=Cr({value:e,rowHeight:i}),De=Math.min(s,a+Re(s)+q),{width:ae,height:le}=Gn({targetRef:H,refreshMode:"throttle",refreshRate:100});F(le?De-le:0);const pn=sr(H,ae,le),{fullWidth:xt,totalWidth:gn,columnWidths:$,columnRights:oe}=Nn(y,ae),[xe,re]=d.useState(null),[be,wn]=d.useState([]),[P,G]=d.useState(!1),[ye,bt]=d.useState(0),[ve,yt]=d.useState(null),[u,_]=Le(null),[Y,A]=Le(null),x=d.useMemo(()=>u&&Y&&{min:{col:Math.min(u.col,Y.col),row:Math.min(u.row,Y.row)},max:{col:Math.max(u.col,Y.col),row:Math.max(u.row,Y.row)}},[u,Y]),[ce,Ee]=Le({columns:!1,rows:!1,active:!1}),xn=N||P||ce.active||u?.row===e?.length-1||x?.max.row===e?.length-1||u&&y.slice((x?.min.col??u.col)+1,(x?.max.col??u.col)+2).every(l=>l.disabled===!0)?null:ye,vt=qt(ge),Et=qt(H);d.useEffect(()=>{u!==null&&(document.activeElement.blur(),window.getSelection()?.removeAllRanges())},[u!==null]);const we=d.useCallback((l,c=!1,w=!1)=>{const m=vt(c),I=w&&Et(c);if(m&&oe&&$){let v=l.clientX-m.left,M=l.clientY-m.top;return I&&(l.clientY-I.top<=a&&(M=0),l.clientX-I.left<=$[0]&&(v=0),he&&$.length>1&&l.clientX-I.left<=$[0]+$[1]&&v>$[0]&&(v=$[0]+1),k&&I.right-l.clientX<=$[$.length-1]&&(v=oe[oe.length-2]+1)),{col:oe.findIndex(C=>v<C)-1,row:Ae(M-a)}}return null},[oe,$,e.length,vt,Et,a,k,he,Ae]),ee=d.useRef(e);ee.current=e;const te=d.useCallback(l=>{const c=y[l.col+1].disabled;return!!(typeof c=="function"?c({rowData:ee.current[l.row],rowIndex:l.row}):c)},[y]),ue=d.useCallback((l,c=1)=>{S||(A(null),G(!1),n([...ee.current.slice(0,l+1),...new Array(c).fill(0).map(p),...ee.current.slice(l+1)],[{type:"CREATE",fromRowIndex:l+1,toRowIndex:l+1+c}]),_(w=>({col:w?.col||0,row:l+c,doNotScrollX:!0})))},[p,S,n,_,A]),Se=d.useCallback((l,c=l)=>{S||(n([...ee.current.slice(0,c+1),...ee.current.slice(l,c+1).map((w,m)=>W({rowData:w,rowIndex:m+l})),...ee.current.slice(c+1)],[{type:"CREATE",fromRowIndex:c+1,toRowIndex:c+2+c-l}]),_({col:0,row:c+1,doNotScrollX:!0}),A({col:y.length-(k?3:2),row:2*c-l+1,doNotScrollX:!0}),G(!1))},[y.length,W,S,n,_,A,k]),fe=d.useCallback(l=>{if(!(!le||!ae)){if(!l.doNotScrollY){const c=ne(l.row).top,w=ne(l.row).top+ne(l.row).height+a-le+1,m=H.current.scrollTop;m>c?H.current.scrollTop=c:m<w&&(H.current.scrollTop=w)}if(oe&&$&&H.current&&!l.doNotScrollX){const c=oe[l.col]-oe[0],w=oe[l.col]+$[l.col+1]+(k?$[$.length-1]:0)-ae+1,m=H.current.scrollLeft;m>c?H.current.scrollLeft=c:m<w&&(H.current.scrollLeft=w)}}},[le,ae,a,oe,$,ne,k]);d.useEffect(()=>{Y&&fe(Y)},[Y,fe]),d.useEffect(()=>{u&&fe(u)},[u,fe]);const bn=d.useCallback((l,c)=>{n([...ee.current?.slice(0,l),c,...ee.current?.slice(l+1)],[{type:"UPDATE",fromRowIndex:l,toRowIndex:l+1}])},[n]),Ie=d.useCallback((l,c=l)=>{S||(G(!1),_(w=>{const m=Math.min(ee.current.length-2-c+l,l);return m<0?null:w&&{col:w.col,row:m}}),A(null),n([...ee.current.slice(0,l),...ee.current.slice(c+1)],[{type:"DELETE",fromRowIndex:l,toRowIndex:c+1}]))},[S,n,_,A]),_e=d.useCallback((l=!0)=>{const c=l&&!z;if(!u)return;const w=x?.min||u,m=x?.max||u;if(e.slice(w.row,m.row+1).every((v,M)=>y.every(C=>C.isCellEmpty({rowData:v,rowIndex:M+w.row})))){c&&Ie(w.row,m.row);return}const I=[...e];for(let v=w.row;v<=m.row;++v)for(let M=w.col;M<=m.col;++M)if(!te({col:M,row:v})){const{deleteValue:C=({rowData:X})=>X}=y[M+1];I[v]=C({rowData:I[v],rowIndex:v})}if(c&&nn(I,e)){_({col:0,row:w.row,doNotScrollX:!0}),A({col:y.length-(k?3:2),row:m.row,doNotScrollX:!0});return}n(I,[{type:"UPDATE",fromRowIndex:w.row,toRowIndex:m.row+1}])},[u,y,e,Ie,te,n,x?.max,x?.min,_,A,k]),Be=d.useCallback(({nextRow:l=!0}={})=>{u?.row===ee.current.length-1?l&&R?ue(u.row):G(!1):(G(!1),l&&_(c=>c&&{col:c.col,row:c.row+1}))},[u?.row,R,ue,_]),Ne=d.useCallback(async l=>{if(!P&&u){const c=[],w=x?.min||u,m=x?.max||u;for(let C=w.row;C<=m.row;++C){c.push([]);for(let X=w.col;X<=m.col;++X){const{copyValue:J=()=>null}=y[X+1];c[C-w.row].push(J({rowData:e[C],rowIndex:C}))}}const I=c.map(C=>C.join(" ")).join(`
9
- `),v=`<table>${c.map(C=>`<tr>${C.map(X=>`<td>${ar(String(X??"")).replace(/\n/g,"<br/>")}</td>`).join("")}</tr>`).join("")}</table>`;if(l!==void 0){l.clipboardData?.setData("text/plain",I),l.clipboardData?.setData("text/html",v),l.preventDefault();return}let M=!1;if(navigator.clipboard.write!==void 0){const C=new Blob([I],{type:"text/plain"}),X=new Blob([v],{type:"text/html"}),J=[new ClipboardItem({"text/plain":C,"text/html":X})];await navigator.clipboard.write(J).then(()=>{M=!0})}else navigator.clipboard.writeText!==void 0?await navigator.clipboard.writeText(I).then(()=>{M=!0}):document.execCommand!==void 0&&document.execCommand("copy")&&(M=!0);M||alert("This action is unavailable in your browser, but you can still use Ctrl+C for copy or Ctrl+X for cut")}},[u,y,e,P,x]);de("copy",Ne);const Ke=d.useCallback(l=>{!P&&u&&(Ne(l),_e(!1))},[u,_e,P,Ne]);de("cut",Ke);const je=d.useCallback(async l=>{if(!P&&u){const c=x?.min||u,w=x?.max||u,m=await Promise.all(l[0].map((I,v)=>{const M=y[c.col+v+1]?.prePasteValues,C=l.map(X=>X[v]);return M?.(C)??C}));if(l=l.map((I,v)=>m.map(M=>M[v])),l.length===1){const I=[...e];for(let v=0;v<l[0].length;v++){const M=y[c.col+v+1]?.pasteValue;if(M)for(let C=c.row;C<=w.row;C++)te({col:v+c.col,row:C})||(I[C]=await M({rowData:I[C],value:l[0][v],rowIndex:C}))}n(I,[{type:"UPDATE",fromRowIndex:c.row,toRowIndex:w.row+1}]),_({col:c.col,row:c.row}),A({col:Math.min(c.col+l[0].length-1,y.length-(k?3:2)),row:w.row})}else{let I=[...e];const v=c.row+l.length-e.length;v>0&&(S?l.splice(l.length-v,v):I=[...I,...new Array(v).fill(0).map(()=>p())]);for(let C=0;C<l[0].length&&c.col+C<y.length-(k?2:1);C++){const X=y[c.col+C+1]?.pasteValue;if(X)for(let J=0;J<l.length;J++)te({col:c.col+C,row:c.row+J})||(I[c.row+J]=await X({rowData:I[c.row+J],value:l[J][C],rowIndex:c.row+J}))}const M=[{type:"UPDATE",fromRowIndex:c.row,toRowIndex:c.row+l.length-(!S&&v>0?v:0)}];v>0&&!S&&M.push({type:"CREATE",fromRowIndex:c.row+l.length-v,toRowIndex:c.row+l.length}),n(I,M),_({col:c.col,row:c.row}),A({col:Math.min(c.col+l[0].length-1,y.length-(k?3:2)),row:c.row+l.length-1})}}},[u,y,p,e,P,k,te,S,n,x?.max,x?.min,_,A]),yn=d.useCallback(l=>{if(u&&!P){let c=[[""]];l.clipboardData?.types.includes("text/html")?c=dt(l.clipboardData?.getData("text/html")):l.clipboardData?.types.includes("text/plain")?c=Fe(l.clipboardData?.getData("text/plain")):l.clipboardData?.types.includes("text")&&(c=Fe(l.clipboardData?.getData("text"))),je(c),l.preventDefault()}},[u,je,P]);de("paste",yn);const vn=d.useCallback(l=>{if(xe&&be.length)return;const c=l.button===2||l.button===0&&l.ctrlKey,w=ge.current?.contains(l.target)||!1,m=w?we(l,!0,!0):null;if(!w&&P&&u&&y[u.col+1].keepFocus)return;if(l.target instanceof HTMLElement&&l.target.className.includes("dsg-expand-rows-indicator")){yt(Math.max(u?.row??0,x?.max.row??0));return}const I=m&&u&&u.col===m.col&&u.row===m.row&&!te(u);if(I&&P)return;const v=m?.col===y.length-2&&k,M=c&&x&&m&&m.row>=x.min.row&&m.row<=x.max.row&&m.col>=x.min.col&&m.col<=x.max.col,C=c&&x&&m&&m.row===-1&&m.col>=x.min.col&&m.col<=x.max.col,X=c&&x&&m&&m.row>=x.min.row&&m.row<=x.max.row&&m.col===-1,J=v&&x&&m&&m.row>=x.min.row&&m.row<=x.max.row;if(c&&!Q&&re({x:l.clientX,y:l.clientY,cursorIndex:m}),(!(l.shiftKey&&u)||c)&&e.length>0&&_(m&&{col:(M||C)&&u?u.col:Math.max(0,v?0:m.col),row:(M||X||J)&&u?u.row:Math.max(0,m.row),doNotScrollX:!!(M&&u||v||m.col===-1),doNotScrollY:!!(M&&u||m.row===-1)}),I&&!c&&(V.current=u),G(!!(I&&!c)),Ee(m&&!c?{columns:m.col!==-1&&!v||!!(l.shiftKey&&u),rows:m.row!==-1||!!(l.shiftKey&&u),active:!0}:{columns:!1,rows:!1,active:!1}),l.shiftKey&&u&&!c)A(m&&{col:Math.max(0,m.col-(v?1:0)),row:Math.max(0,m.row)});else if(!M){if(m&&(m?.col===-1||m?.row===-1||v)){let Ue=m.col,$e=m.row,Ge=!1,Xe=!1;(m.col===-1||v)&&(Ue=y.length-(k?3:2),Ge=!0),m.row===-1&&($e=e.length-1,Xe=!0),C&&Y&&(Ue=Y.col,Xe=!0),(X||J)&&Y&&($e=Y.row,Ge=!0),A({col:Ue,row:$e,doNotScrollX:Ge,doNotScrollY:Xe})}else A(null);w&&l.preventDefault()}},[xe,be.length,we,P,u,y,te,x,k,Q,Ee,_,A,Y,e.length]);de("mousedown",vn);const En=d.useCallback(()=>{if(ve!==null){if(ye>0&&u){let l=[];const c=x?.min||u,w=x?.max||u;for(let m=c.row;m<=w.row;++m){l.push([]);for(let I=c.col;I<=w.col;++I){const{copyValue:v=()=>null}=y[I+1];l[m-c.row].push(String(v({rowData:e[m],rowIndex:m})??""))}}Promise.all(l[0].map((m,I)=>{const v=y[c.col+I+1]?.prePasteValues,M=l.map(C=>C[I]);return v?.(M)??M})).then(m=>{l=l.map((v,M)=>m.map(C=>C[M]));const I=[...e];for(let v=0;v<l[0].length;v++){const M=y[c.col+v+1]?.pasteValue;if(M)for(let C=w.row+1;C<=w.row+ye;C++)te({col:v+c.col,row:C})||(I[C]=M({rowData:I[C],value:l[(C-w.row-1)%l.length][v],rowIndex:C}))}n(I,[{type:"UPDATE",fromRowIndex:w.row+1,toRowIndex:w.row+1+ye}])}),bt(0),_({col:Math.min(u?.col??1/0,x?.min.col??1/0),row:Math.min(u?.row??1/0,x?.min.row??1/0),doNotScrollX:!0,doNotScrollY:!0}),A({col:Math.max(u?.col??0,x?.max.col??0),row:Math.max(u?.row??0,x?.max.row??0)+ye})}yt(null)}Ee({columns:!1,rows:!1,active:!1})},[ve,Ee,ye,u,x?.min,x?.max,e,n,_,A,y,te]);de("mouseup",En);const Sn=d.useCallback(l=>{if(ve!==null){const c=we(l);c&&(bt(Math.max(0,c.row-ve)),fe({col:c.col,row:Math.max(c.row,ve)}))}if(ce.active){const c=we(l),w=y.length-(k?3:2);A(c&&{col:ce.columns?Math.max(0,Math.min(w,c.col)):w,row:ce.rows?Math.max(0,c.row):e.length-1,doNotScrollX:!ce.columns,doNotScrollY:!ce.rows}),G(!1)}},[fe,ce.active,ce.columns,ce.rows,we,y.length,k,A,e.length,ve]);de("mousemove",Sn);const In=d.useCallback(l=>{if(u&&!l.isComposing){if(l.key==="Tab"&&!l.shiftKey&&u.col===y.length-(k?3:2)&&!y[u.col+1].disableKeys)if(u.row===e.length-1){if(E.current){l.preventDefault(),_(null),A(null),G(!1);const c=Bt(),w=c.indexOf(E.current);c[(w+1)%c.length].focus();return}}else{_(c=>({col:0,row:(c?.row??0)+1})),A(null),G(!1),l.preventDefault();return}if(l.key==="Tab"&&l.shiftKey&&u.col===0&&!y[u.col+1].disableKeys)if(u.row===0){if(Oe.current){l.preventDefault(),_(null),A(null),G(!1);const c=Bt(),w=c.indexOf(Oe.current);c[(w-1+c.length)%c.length].focus();return}}else{_(c=>({col:y.length-(k?3:2),row:(c?.row??1)-1})),A(null),G(!1),l.preventDefault();return}if(l.key?.startsWith("Arrow")||l.key==="Tab"){if(P&&y[u.col+1].disableKeys||P&&["ArrowLeft","ArrowRight"].includes(l.key))return;const c=([w,m],I)=>I&&{col:Math.max(0,Math.min(y.length-(k?3:2),I.col+w)),row:Math.max(0,Math.min(e.length-1,I.row+m))};if(l.key==="Tab"&&l.shiftKey)_(w=>c([-1,0],w)),A(null);else{const w={ArrowDown:[0,1],ArrowUp:[0,-1],ArrowLeft:[-1,0],ArrowRight:[1,0],Tab:[1,0]}[l.key];(l.ctrlKey||l.metaKey)&&(w[0]*=y.length,w[1]*=e.length),l.shiftKey?A(m=>c(w,m||u)):(_(m=>c(w,m)),A(null))}G(!1),l.preventDefault()}else l.key==="Escape"?(!P&&!Y&&_(null),A(null),G(!1)):(l.key==="Enter"||l.key==="F2")&&!l.ctrlKey&&!l.metaKey&&!l.altKey&&!l.shiftKey?(A(null),P?y[u.col+1].disableKeys||(Be(),l.preventDefault()):te(u)||(V.current=u,G(!0),fe(u),l.preventDefault())):l.key==="Enter"&&!l.ctrlKey&&!l.metaKey&&!l.altKey&&l.shiftKey?ue(x?.max.row||u.row):l.key==="d"&&(l.ctrlKey||l.metaKey)&&!l.altKey&&!l.shiftKey?(Se(x?.min.row||u.row,x?.max.row),l.preventDefault()):(cr(l.key)||l.code.match(/Key[A-Z]$/))&&!l.ctrlKey&&!l.metaKey&&!l.altKey?!P&&!te(u)&&(V.current=u,A(null),G(!0),fe(u)):["Backspace","Delete"].includes(l.key)?P||(_e(),l.preventDefault()):l.key==="a"&&(l.ctrlKey||l.metaKey)&&(P||(_({col:0,row:0,doNotScrollY:!0,doNotScrollX:!0}),A({col:y.length-(k?3:2),row:e.length-1,doNotScrollY:!0,doNotScrollX:!0}),l.preventDefault()))}},[u,y,e.length,_e,Se,P,ue,te,fe,x?.max.row,x?.min.row,Y,_,A,Be,k]);de("keydown",In);const Cn=d.useCallback(l=>{const c=ge.current?.contains(l.target)||!1,w=c?we(l,!0,!0):null,m=w&&u&&u.col===w.col&&u.row===w.row&&P;c&&!m&&l.preventDefault()},[we,u,P]);de("contextmenu",Cn),d.useEffect(()=>{const l=[];u?.row!==void 0&&l.push({type:"COPY",action:()=>{Ne(),re(null)}},{type:"CUT",action:()=>{Ke(),re(null)}},{type:"PASTE",action:async()=>{if(navigator.clipboard.read!==void 0)(await navigator.clipboard.read()).forEach(async w=>{let m=[[""]];if(w.types.includes("text/html")){const I=await w.getType("text/html");m=dt(await I.text())}else if(w.types.includes("text/plain")){const I=await w.getType("text/plain");m=Fe(await I.text())}else if(w.types.includes("text")){const I=await w.getType("text");m=dt(await I.text())}je(m)});else if(navigator.clipboard.readText!==void 0){const c=await navigator.clipboard.readText();je(Fe(c))}else alert("This action is unavailable in your browser, but you can still use Ctrl+V for paste");re(null)}}),x?.max.row!==void 0?l.push({type:"INSERT_ROW_BELLOW",action:()=>{re(null),ue(x.max.row)}}):u?.row!==void 0&&l.push({type:"INSERT_ROW_BELLOW",action:()=>{re(null),ue(u.row)}}),x?.min.row!==void 0&&x.min.row!==x.max.row?l.push({type:"DUPLICATE_ROWS",fromRow:x.min.row+1,toRow:x.max.row+1,action:()=>{re(null),Se(x.min.row,x.max.row)}}):u?.row!==void 0&&l.push({type:"DUPLICATE_ROW",action:()=>{re(null),Se(u.row)}}),x?.min.row!==void 0&&x.min.row!==x.max.row?l.push({type:"DELETE_ROWS",fromRow:x.min.row+1,toRow:x.max.row+1,action:()=>{re(null),Ie(x.min.row,x.max.row)}}):u?.row!==void 0&&l.push({type:"DELETE_ROW",action:()=>{re(null),Ie(u.row)}}),wn(l),l.length||re(null)},[x,u,Ie,Se,ue,Ke,Ne,je]);const St=d.useRef(be);St.current=be;const Tn=d.useCallback(()=>St.current,[]);d.useImperativeHandle(pe,()=>({activeCell:Te(u,y),selection:Wt(x??(u?{min:u,max:u}:null),y),setSelection:l=>{const c=ur(l,y.length-(k?2:1),e.length,y);_(c?.min||null),G(!1),Ee({columns:!1,active:!1,rows:!1}),A(c?.max||null)},setActiveCell:l=>{const c=mt(l,y.length-(k?2:1),e.length,y);_(c),G(!1),Ee({columns:!1,active:!1,rows:!1}),A(null)}}));const me=d.useRef({onFocus:j,onBlur:B,onActiveCellChange:L,onSelectionChange:ie});return me.current.onFocus=j,me.current.onBlur=B,me.current.onActiveCellChange=L,me.current.onSelectionChange=ie,d.useEffect(()=>{V.current&&(P?me.current.onFocus({cell:Te(V.current,y)}):me.current.onBlur({cell:Te(V.current,y)}))},[P,y]),d.useEffect(()=>{me.current.onActiveCellChange({cell:Te(u,y)})},[u?.col,u?.row,y]),d.useEffect(()=>{me.current.onSelectionChange({selection:Wt(x??(u?{min:u,max:u}:null),y)})},[x?.min.col??u?.col,x?.min.row??u?.row,x?.max.col??u?.col,x?.max.row??u?.row,u?.col,u?.row,y]),b.jsxs("div",{className:r,style:t,children:[b.jsx("div",{ref:Oe,tabIndex:o.length&&e.length?0:void 0,onFocus:l=>{l.target.blur(),_({col:0,row:0})}}),b.jsx(Sr,{columns:y,outerRef:H,columnWidths:$,hasStickyRightColumn:k,pinFirstColumn:he,displayHeight:De,data:e,fullWidth:xt,headerRowHeight:a,activeCell:u,innerRef:ge,rowHeight:ne,rowKey:g,selection:x,rowClassName:se,editing:P,getContextMenuItems:Tn,setRowData:bn,deleteRows:Ie,insertRowAfter:ue,duplicateRows:Se,stopEditing:Be,cellClassName:K,onScroll:U,children:b.jsx(un,{columnRights:oe,columnWidths:$,activeCell:u,selection:x,headerRowHeight:a,rowHeight:ne,hasStickyRightColumn:k,dataLength:e.length,viewHeight:le,viewWidth:ae,contentWidth:xt?void 0:gn,edges:pn,editing:P,isCellDisabled:te,expandSelection:xn})}),b.jsx("div",{ref:E,tabIndex:o.length&&e.length?0:void 0,onFocus:l=>{l.target.blur(),_({col:y.length-(k?3:2),row:e.length-1})}}),!S&&T&&b.jsx(T,{addRows:l=>ue(e.length-1,l)}),xe&&be.length>0&&b.jsx(D,{clientX:xe.x,clientY:xe.y,cursorIndex:xe.cursorIndex,items:be,close:()=>re(null)})]})}));wt.displayName="DataSheetGrid";const Nr=d.forwardRef(({columns:e,gutterColumn:r,stickyRightColumn:t,addRowsComponent:s,createRow:n,duplicateRow:o,style:i,rowKey:a,onFocus:f,onBlur:h,onActiveCellChange:g,onSelectionChange:T,rowClassName:p,rowHeight:R,...S},N)=>{const[z]=d.useState({columns:e,gutterColumn:r,stickyRightColumn:t,addRowsComponent:s,createRow:n,duplicateRow:o,style:i,rowKey:a,onFocus:f,onBlur:h,onActiveCellChange:g,onSelectionChange:T,rowClassName:p,rowHeight:R});return b.jsx(wt,{...z,...S,rowHeight:typeof R=="number"?R:z.rowHeight,ref:N})}),jr=()=>{const e=d.useRef(!0),r=e.current;return e.current=!1,r},fn=d.memo(({active:e,focus:r,rowData:t,setRowData:s,columnData:{placeholder:n,alignRight:o,formatInputOnFocus:i,formatBlurredInput:a,parseUserInput:f,continuousUpdates:h}})=>{const g=d.useRef(null),T=jr(),p=d.useRef({rowData:t,formatInputOnFocus:i,formatBlurredInput:a,setRowData:s,parseUserInput:f,continuousUpdates:h,firstRender:T,focusedAt:0,changedAt:0,escPressed:!1});return p.current={rowData:t,formatInputOnFocus:i,formatBlurredInput:a,setRowData:s,parseUserInput:f,continuousUpdates:h,firstRender:T,focusedAt:p.current.focusedAt,changedAt:p.current.changedAt,escPressed:p.current.escPressed},d.useLayoutEffect(()=>{r?(g.current&&(g.current.value=p.current.formatInputOnFocus(p.current.rowData),g.current.focus(),g.current.select()),p.current.escPressed=!1,p.current.focusedAt=Date.now()):g.current&&(!p.current.escPressed&&!p.current.continuousUpdates&&!p.current.firstRender&&p.current.changedAt>=p.current.focusedAt&&p.current.setRowData(p.current.parseUserInput(g.current.value)),g.current.blur())},[r]),d.useEffect(()=>{!r&&g.current&&(g.current.value=p.current.formatBlurredInput(t))},[r,t]),b.jsx("input",{defaultValue:a(t),className:Z("dsg-input",o&&"dsg-input-align-right"),placeholder:e?n:void 0,tabIndex:-1,ref:g,style:{pointerEvents:r?"auto":"none"},onChange:R=>{p.current.changedAt=Date.now(),h&&s(f(R.target.value))},onKeyDown:R=>{R.key==="Escape"&&(p.current.escPressed=!0)}})});fn.displayName="TextComponent";const Mr=ke();function ke({placeholder:e,alignRight:r=!1,continuousUpdates:t=!0,deletedValue:s=null,parseUserInput:n=h=>h.trim()||null,formatBlurredInput:o=h=>String(h??""),formatInputOnFocus:i=h=>String(h??""),formatForCopy:a=h=>String(h??""),parsePastedValue:f=h=>h.replace(/[\n\r]+/g," ").trim()||null}={}){return{component:fn,columnData:{placeholder:e,alignRight:r,continuousUpdates:t,formatInputOnFocus:i,formatBlurredInput:o,parseUserInput:n},deleteValue:()=>s,copyValue:({rowData:h})=>a(h),pasteValue:({value:h})=>f(h),isCellEmpty:({rowData:h})=>h==null}}const kr=["","false","no","off","disabled","0","n","f","unchecked","undefined","null","wrong","negative"],dn=d.memo(({focus:e,rowData:r,setRowData:t,active:s,stopEditing:n,disabled:o})=>{const i=d.useRef(null);return d.useLayoutEffect(()=>{e&&(t(!r),n({nextRow:!1}))},[e,n]),b.jsx("input",{className:"dsg-checkbox",tabIndex:-1,type:"checkbox",ref:i,disabled:o,checked:!!r,onMouseDown:()=>!s&&t(!r),onChange:()=>null})});dn.displayName="CheckboxComponent";const Ar={component:dn,deleteValue:()=>!1,copyValue:({rowData:e})=>e?"YES":"NO",pasteValue:({value:e})=>!kr.includes(e.toLowerCase()),isCellEmpty:({rowData:e})=>!e},_r=ke({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat().format(e):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:r},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:r}}),zr=ke({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat().format(e):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:Math.round(r)},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:Math.round(r)}}),Fr=1e12,Vr=1e10,Lr=ke({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat(void 0,{style:"percent"}).format(e):"",formatInputOnFocus:e=>typeof e=="number"&&!isNaN(e)?String(Math.round(e*Fr)/Vr):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:r/100},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:r}}),hn=d.memo(({focus:e,active:r,rowData:t,setRowData:s})=>{const n=d.useRef(null);return d.useLayoutEffect(()=>{e?n.current?.select():n.current?.blur()},[e]),b.jsx("input",{className:Z("dsg-input",!r&&"dsg-hide-date-picker"),type:"date",tabIndex:-1,max:"9999-12-31",ref:n,style:{pointerEvents:e?"auto":"none",opacity:t||r?void 0:0},value:t?.toISOString().substr(0,10)??"",onChange:o=>{const i=new Date(o.target.value);s(isNaN(i.getTime())?null:i)}})});hn.displayName="DateComponent";const Pr={component:hn,deleteValue:()=>null,copyValue:({rowData:e})=>e?e.toISOString().substr(0,10):null,pasteValue:({value:e})=>{const r=new Date(e.replace(/\.\s?|\//g,"-"));return isNaN(r.getTime())?null:r},minWidth:170,isCellEmpty:({rowData:e})=>!e},mn=d.memo(({focus:e,active:r,rowData:t,setRowData:s})=>{const n=d.useRef(null);return d.useLayoutEffect(()=>{e?n.current?.select():n.current?.blur()},[e]),b.jsx("input",{className:Z("dsg-input",!r&&"dsg-hide-date-picker"),type:"date",tabIndex:-1,max:"9999-12-31",ref:n,style:{pointerEvents:e?"auto":"none",opacity:t||r?void 0:0},value:t??"",onChange:o=>{const i=new Date(o.target.value);s(isNaN(i.getTime())?null:i.toISOString().substr(0,10))}})});mn.displayName="IsoDateComponent";const qr={component:mn,deleteValue:()=>null,copyValue:({rowData:e})=>e,pasteValue:({value:e})=>{const r=new Date(e.replace(/\.\s?|\//g,"-"));return isNaN(r.getTime())?null:r.toISOString().substr(0,10)},minWidth:170,isCellEmpty:({rowData:e})=>!e},Wr=({columnData:{key:e,original:r},rowData:t,setRowData:s,...n})=>{const o=d.useRef(t);o.current=t;const i=d.useCallback(f=>{s({...o.current,[e]:f})},[e,s]);if(!r.component)return b.jsx(b.Fragment,{});const a=r.component;return b.jsx(a,{columnData:r.columnData,setRowData:i,rowData:t[e],...n})},Br=(e,r)=>({id:e,...r,columnData:{key:e,original:r},component:Wr,copyValue:({rowData:t,rowIndex:s})=>r.copyValue?.({rowData:t[e],rowIndex:s})??null,deleteValue:({rowData:t,rowIndex:s})=>({...t,[e]:r.deleteValue?.({rowData:t[e],rowIndex:s})??null}),pasteValue:({rowData:t,value:s,rowIndex:n})=>({...t,[e]:r.pasteValue?.({rowData:t[e],value:s,rowIndex:n})??null}),disabled:typeof r.disabled=="function"?({rowData:t,rowIndex:s})=>typeof r.disabled=="function"?r.disabled({rowData:t[e],rowIndex:s}):r.disabled??!1:r.disabled,cellClassName:typeof r.cellClassName=="function"?({rowData:t,rowIndex:s,columnId:n})=>typeof r.cellClassName=="function"?r.cellClassName({rowData:t[e],rowIndex:s,columnId:n}):r.cellClassName??void 0:r.cellClassName,isCellEmpty:({rowData:t,rowIndex:s})=>r.isCellEmpty?.({rowData:t[e],rowIndex:s})??!1}),Kr=wt,Ur=Nr;exports.DataSheetGrid=Ur;exports.DynamicDataSheetGrid=Kr;exports.checkboxColumn=Ar;exports.createAddRowsComponent=rn;exports.createContextMenuComponent=on;exports.createTextColumn=ke;exports.dateColumn=Pr;exports.floatColumn=_r;exports.intColumn=zr;exports.isoDateColumn=qr;exports.keyColumn=Br;exports.percentColumn=Lr;exports.renderContextMenuItem=gt;exports.textColumn=Mr;
8
+ color: hsl(${Math.max(0,Math.min(120-120*M,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(o&&t.skipInitialOnChange)&&t.onChange(n),o=!1,n}return i.updateDeps=a=>{s=a},i}function Ut(e,r){if(e===void 0)throw new Error("Unexpected undefined");return e}const pr=(e,r)=>Math.abs(e-r)<1.01,gr=(e,r,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>r.apply(this,n),t)}},$t=e=>{const{offsetWidth:r,offsetHeight:t}=e;return{width:r,height:t}},wr=e=>e,un=e=>{const r=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),s=[];for(let n=r;n<=t;n++)s.push(n);return s},xr=(e,r)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=i=>{const{width:a,height:f}=i;r({width:Math.round(a),height:Math.round(f)})};if(n($t(t)),!s.ResizeObserver)return()=>{};const o=new s.ResizeObserver(i=>{const a=()=>{const f=i[0];if(f?.borderBoxSize){const m=f.borderBoxSize[0];if(m){n({width:m.inlineSize,height:m.blockSize});return}}n($t(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(t,{box:"border-box"}),()=>{o.unobserve(t)}},Gt={passive:!0},Xt=typeof window>"u"?!0:"onscrollend"in window,br=(e,r)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;let n=0;const o=e.options.useScrollendEvent&&Xt?()=>{}:gr(s,()=>{r(n,!1)},e.options.isScrollingResetDelay),i=g=>()=>{const{horizontal:R,isRtl:p}=e.options;n=R?t.scrollLeft*(p&&-1||1):t.scrollTop,o(),r(n,g)},a=i(!0),f=i(!1);t.addEventListener("scroll",a,Gt);const m=e.options.useScrollendEvent&&Xt;return m&&t.addEventListener("scrollend",f,Gt),()=>{t.removeEventListener("scroll",a),m&&t.removeEventListener("scrollend",f)}},yr=(e,r,t)=>{if(r?.borderBoxSize){const s=r.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},vr=(e,{adjustments:r=0,behavior:t},s)=>{var n,o;const i=e+r;(o=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||o.call(n,{[s.options.horizontal?"left":"top"]:i,behavior:t})};class Er{constructor(r){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var o;return(o=s())==null?void 0:o.observe(n,{box:"border-box"})},unobserve:n=>{var o;return(o=s())==null?void 0:o.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([s,n])=>{typeof n>"u"&&delete t[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:wr,rangeExtractor:un,onChange:()=>{},measureElement:yr,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=De(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=o,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,s)=>{const n=new Map,o=new Map;for(let i=s-1;i>=0;i--){const a=t[i];if(n.has(a.lane))continue;const f=o.get(a.lane);if(f==null||a.end>f.end?o.set(a.lane,a):a.end<f.end&&n.set(a.lane,!0),n.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=De(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,s,n,o,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:s,scrollMargin:n,getItemKey:o,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=De(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:s,scrollMargin:n,getItemKey:o,enabled:i,lanes:a},f)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));const m=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const g=this.measurementsCache.slice(0,m),R=new Array(a).fill(void 0);for(let p=0;p<m;p++){const O=g[p];O&&(R[O.lane]=p)}for(let p=m;p<t;p++){const O=o(p),S=this.laneAssignments.get(p);let T,M;if(S!==void 0&&this.options.lanes>1){T=S;const L=R[T],j=L!==void 0?g[L]:void 0;M=j?j.end+this.options.gap:s+n}else{const L=this.options.lanes===1?g[p-1]:this.getFurthestMeasurement(g,p);M=L?L.end+this.options.gap:s+n,T=L?L.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,T)}const U=f.get(O),D=typeof U=="number"?U:this.options.estimateSize(p),A=M+D;g[p]={index:p,start:M,size:D,end:A,key:O,lane:T},R[T]=p}return this.measurementsCache=g,g},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=De(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,o)=>this.range=t.length>0&&s>0?Sr({measurements:t,outerSize:s,scrollOffset:n,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=De(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,o,i)=>o===null||i===null?[]:t({startIndex:o,endIndex:i,overscan:s,count:n}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this._measureElement=(t,s)=>{const n=this.indexFromElement(t),o=this.measurementsCache[n];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==t&&(a&&this.observer.unobserve(a),this.observer.observe(t),this.elementsCache.set(i,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,s,this))},this.resizeItem=(t,s)=>{const n=this.measurementsCache[t];if(!n)return;const o=this.itemSizeCache.get(n.key)??n.size,i=s-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,i,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,s)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((s,n)=>{s.isConnected||(this.observer.unobserve(s),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=De(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let o=0,i=t.length;o<i;o++){const a=t[o],f=s[a];n.push(f)}return n},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length!==0)return Ut(s[fn(0,s.length-1,n=>Ut(s[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=t>=i+o?"end":"start"),s==="center"?t+=(n-o)/2:s==="end"&&(t-=o);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const o=this.getSize(),i=this.getScrollOffset();if(s==="auto")if(n.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(n.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,n.size),s]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:s="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,s),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:s="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let o=0;const i=10,a=m=>{if(!this.targetWindow)return;const g=this.getOffsetForIndex(t,m);if(!g){console.warn("Failed to get offset for index:",t);return}const[R,p]=g;this._scrollToOffset(R,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const O=()=>{if(this.currentScrollToIndex!==t)return;const S=this.getScrollOffset(),T=this.getOffsetForIndex(t,p);if(!T){console.warn("Failed to get offset for index:",t);return}pr(T[0],S)||f(p)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(O):O()})},f=m=>{this.targetWindow&&this.currentScrollToIndex===t&&(o++,o<i?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",o,i),this.targetWindow.requestAnimationFrame(()=>a(m))):console.warn(`Failed to scroll to index ${t} after ${i} attempts.`))};a(s)},this.scrollBy=(t,{behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:s})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=s[s.length-1])==null?void 0:t.end)??0;else{const o=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&o.some(a=>a===null);){const a=s[i];o[a.lane]===null&&(o[a.lane]=a.end),i--}n=Math.max(...o.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(r)}}const fn=(e,r,t,s)=>{for(;e<=r;){const n=(e+r)/2|0,o=t(n);if(o<s)e=n+1;else if(o>s)r=n-1;else return n}return e>0?e-1:0};function Sr({measurements:e,outerSize:r,scrollOffset:t,lanes:s}){const n=e.length-1,o=f=>e[f].start;if(e.length<=s)return{startIndex:0,endIndex:n};let i=fn(0,n,o,t),a=i;if(s===1)for(;a<n&&e[a].end<t+r;)a++;else if(s>1){const f=Array(s).fill(0);for(;a<n&&f.some(g=>g<t+r);){const g=e[a];f[g.lane]=g.end,a++}const m=Array(s).fill(t+r);for(;i>=0&&m.some(g=>g>=t);){const g=e[i];m[g.lane]=g.start,i--}i=Math.max(0,i-i%s),a=Math.min(n,a+(s-1-a%s))}return{startIndex:i,endIndex:a}}const Yt=typeof document<"u"?Le.useLayoutEffect:Le.useEffect;function Ir({useFlushSync:e=!0,...r}){const t=Le.useReducer(()=>({}),{})[1],s={...r,onChange:(o,i)=>{var a;e&&i?Nn.flushSync(t):t(),(a=r.onChange)==null||a.call(r,o,i)}},[n]=Le.useState(()=>new Er(s));return n.setOptions(s),Yt(()=>n._didMount(),[]),Yt(()=>n._willUpdate()),n}function Zt(e){return Ir({observeElementRect:xr,observeElementOffset:br,scrollToFn:vr,...e})}var mt={exports:{}};var Jt;function Cr(){return Jt||(Jt=1,(function(e){(function(){var r={}.hasOwnProperty;function t(){for(var o="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(o=n(o,s(a)))}return o}function s(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var a in o)r.call(o,a)&&o[a]&&(i=n(i,a));return i}function n(o,i){return i?o?o+" "+i:o+i:o}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(mt)),mt.exports}var Tr=Cr();const $=We(Tr),Qt=({children:e,gutter:r,stickyRight:t,stickyLeft:s,active:n,disabled:o,className:i,width:a,left:f})=>x.jsx("div",{className:$("dsg-cell",r&&"dsg-cell-gutter",o&&"dsg-cell-disabled",r&&n&&"dsg-cell-gutter-active",t&&"dsg-cell-sticky-right",s&&"dsg-cell-sticky-left",i),style:{width:a,left:t?void 0:f},children:e}),Ve=(e,r)=>d.useMemo(()=>{const t=new Map;return s=>(t.has(s)||t.set(s,(...n)=>{e(s,...n.slice(0,r))}),t.get(s))},[r,e]),Dr=({data:e,columns:r,outerRef:t,innerRef:s,columnWidths:n,hasStickyRightColumn:o,pinFirstColumn:i,displayHeight:a,headerRowHeight:f,rowHeight:m,rowKey:g,fullWidth:R,selection:p,activeCell:O,rowClassName:S,cellClassName:T,children:M,editing:U,getContextMenuItems:D,setRowData:A,deleteRows:L,duplicateRows:j,insertRowAfter:F,stopEditing:ae,onScroll:se})=>{const ee=Zt({count:e.length,getScrollElement:()=>t.current,paddingStart:f,estimateSize:v=>m(v).height,getItemKey:v=>{if(g&&v>0){const B=e[v-1];if(typeof g=="function")return g({rowData:B,rowIndex:v});if(typeof g=="string"&&B instanceof Object&&g in B){const V=B[g];if(typeof V=="string"||typeof V=="number")return V}}return v},overscan:5}),X=Zt({count:r.length,getScrollElement:()=>t.current,estimateSize:v=>n?.[v]??100,horizontal:!0,getItemKey:v=>r[v].id??v,overscan:1,rangeExtractor:v=>{const B=un(v);if(B[0]!==0&&B.unshift(0),(i||r[1]?.stickyLeft)&&r.length>1&&!B.includes(1)){const ge=B.findIndex(oe=>oe>1);ge===-1?B.push(1):B.splice(ge,0,1)}return o&&B[B.length-1]!==r.length-1&&B.push(r.length-1),B}});d.useEffect(()=>{X.measure()},[X,n]);const ce=Ve(A,1),q=Ve(L,0),z=Ve(j,0),Q=Ve(F,0),b=v=>{if(!r[v].stickyLeft)return 0;if(!n||!n.length){const V=X.getOffsetForIndex(v);return typeof V=="number"?V:0}let B=0;for(let V=0;V<v;V++)B+=n[V];return B},k=p?.min.col??O?.col,ue=p?.max.col??O?.col,te=p?.min.row??O?.row,W=p?.max.row??O?.row;return x.jsx("div",{ref:t,className:"dsg-container",onScroll:se,style:{height:a},children:x.jsxs("div",{ref:s,style:{width:R?"100%":X.getTotalSize(),height:ee.getTotalSize()},children:[f>0&&x.jsx("div",{className:$("dsg-row","dsg-row-header"),style:{width:R?"100%":X.getTotalSize(),height:f},children:X.getVirtualItems().map(v=>{const B=!!r[v.index].stickyLeft;return x.jsx(Qt,{gutter:v.index===0,stickyRight:o&&v.index===r.length-1,stickyLeft:B,width:v.size,left:B?b(v.index):v.start,className:$("dsg-cell-header",k!==void 0&&ue!==void 0&&k<=v.index-1&&ue>=v.index-1&&"dsg-cell-header-active",r[v.index].headerClassName),children:x.jsx("div",{className:"dsg-cell-header-container",children:r[v.index].title})},v.key)})}),ee.getVirtualItems().map(v=>{const B=v.index>=(te??1/0)&&v.index<=(W??-1/0);return x.jsx("div",{className:$("dsg-row",typeof S=="string"?S:null,typeof S=="function"?S({rowData:e[v.index],rowIndex:v.index}):null),style:{height:v.size,top:v.start,width:R?"100%":X.getTotalSize()},children:X.getVirtualItems().map(V=>{const ge=r[V.index].cellClassName,oe=r[V.index].disabled,Be=r[V.index].component,Oe=oe===!0||typeof oe=="function"&&oe({rowData:e[v.index],rowIndex:v.index}),je=O?.row===v.index&&O.col===V.index-1,fe=!!r[V.index].stickyLeft;return x.jsx(Qt,{gutter:V.index===0,stickyRight:o&&V.index===r.length-1,stickyLeft:fe,active:V.index===0&&B,disabled:Oe,className:$(typeof ge=="function"?ge({rowData:e[v.index],rowIndex:v.index,columnId:r[V.index].id}):ge,typeof T=="function"?T({rowData:e[v.index],rowIndex:v.index,columnId:r[V.index].id}):T),width:V.size,left:fe?b(V.index):V.start,children:x.jsx(Be,{rowData:e[v.index],getContextMenuItems:D,disabled:Oe,active:je,columnIndex:V.index-1,rowIndex:v.index,focus:je&&U,deleteRow:q(v.index),duplicateRow:z(v.index),stopEditing:ae,insertRowBelow:Q(v.index),setRowData:ce(v.index),columnData:r[V.index].columnData})},V.key)})},v.key)}),M]})})},Ht=(e,r,t,s)=>[[s,e],[r,e],[r,t],[s,t],[s,e]],en=(e,r,t,s)=>`polygon(evenodd, ${[...Ht(0,"100%","100%",0),...Ht(e,r,t,s)].map(o=>o.map(i=>typeof i=="number"&&i!==0?i+"px":i).join(" ")).join(",")})`,dn=d.memo(({columnWidths:e,columnRights:r,headerRowHeight:t,selection:s,rowHeight:n,activeCell:o,hasStickyRightColumn:i,dataLength:a,viewWidth:f,viewHeight:m,contentWidth:g,edges:R,isCellDisabled:p,editing:O,expandSelection:S,stickyLeftColumns:T,getStickyLeftOffset:M})=>{const U=o?p(o):!1,D=d.useMemo(()=>{if(!s)return U;for(let W=s.min.col;W<=s.max.col;++W)for(let v=s.min.row;v<=s.max.row;++v)if(!p({col:W,row:v}))return!1;return!0},[U,p,s]);if(!e||!r)return null;const A=W=>W<a-1?1:0,L=W=>W<e.length-(i?3:2)?1:0,j=o&&{width:e[o.col+1]+L(o.col),height:n(o.row).height+A(o.row),left:r[o.col],top:n(o.row).top+t},F=s&&{width:e.slice(s.min.col+1,s.max.col+2).reduce((W,v)=>W+v)+L(s.max.col),height:n(s.max.row).top+n(s.max.row).height-n(s.min.row).top+A(s.max.row),left:r[s.min.col],top:n(s.min.row).top+t},ae=o&&T&&M&&T[o.col],se=ae&&M?M(o.col+1):0,ee=s&&T&&M&&(()=>{for(let W=s.min.col;W<=s.max.col;W++)if(!T[W])return!1;return!0})(),X=ee&&s&&M?M(s.min.col+1):0,ce=s?.min||o,q=s?.max||o,z=q&&T&&M&&T[q.col],Q=z&&q&&M?M(q.col+1)+e[q.col+1]:0,b=s&&T&&T[s.min.col]||o&&T&&T[o.col],k=b&&M?M((s?.min.col??o?.col??0)+1):0,ue=q&&S!==null&&{left:r[q.col]+e[q.col+1],top:n(q.row).top+n(q.row).height+t,transform:`translate(-${q.col<e.length-(i?3:2)?50:100}%, -${q.row<a-1?50:100}%)`},te=ce&&q&&S!==null&&{width:e.slice(ce.col+1,q.col+2).reduce((W,v)=>W+v)+L(q.col),height:n(q.row+S).top+n(q.row+S).height-n(q.row+1).top+A(q.row+S)-1,left:r[ce.col],top:n(q.row).top+n(q.row).height+t+1};return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"dsg-scrollable-view-container",style:{height:n(a-1).top+n(a-1).height+t,width:g||"100%"},children:x.jsx("div",{className:$({"dsg-scrollable-view":!0,"dsg-scrollable-view-t":!R.top,"dsg-scrollable-view-r":!R.right,"dsg-scrollable-view-b":!R.bottom,"dsg-scrollable-view-l":!R.left}),style:{top:t,left:e[0],height:m?m-t:0,width:g&&f?f-e[0]-(i?e[e.length-1]:0):`calc(100% - ${e[0]+(i?e[e.length-1]:0)}px)`}})}),(F||j)&&!b&&x.jsx("div",{className:"dsg-selection-col-marker-container",style:{left:F?.left??j?.left,width:F?.width??j?.width,height:n(a-1).top+n(a-1).height+t},children:x.jsx("div",{className:$("dsg-selection-col-marker",D&&"dsg-selection-col-marker-disabled"),style:{top:t}})}),(F||j)&&b&&x.jsx("div",{className:$("dsg-selection-col-marker-container","dsg-selection-col-marker-container-sticky"),style:{position:"sticky",left:k,top:"auto",width:F?.width??j?.width,height:n(a-1).top+n(a-1).height+t},children:x.jsx("div",{className:$("dsg-selection-col-marker",D&&"dsg-selection-col-marker-disabled"),style:{top:t}})}),(F||j)&&x.jsx("div",{className:"dsg-selection-row-marker-container",style:{top:F?.top??j?.top,height:F?.height??j?.height,width:g||"100%"},children:x.jsx("div",{className:$("dsg-selection-row-marker",D&&"dsg-selection-row-marker-disabled"),style:{left:e[0]}})}),j&&o&&!ae&&x.jsx("div",{className:$("dsg-active-cell",{"dsg-active-cell-focus":O,"dsg-active-cell-disabled":U}),style:j}),j&&o&&ae&&x.jsx("div",{style:{position:"absolute",top:j.top,left:0,right:0,height:j.height,pointerEvents:"none"},children:x.jsx("div",{className:$("dsg-active-cell",{"dsg-active-cell-focus":O,"dsg-active-cell-disabled":U,"dsg-active-cell-sticky":!0}),style:{position:"sticky",left:se,width:j.width,height:"100%"}})}),F&&j&&!ee&&x.jsx("div",{className:$("dsg-selection-rect",D&&"dsg-selection-rect-disabled"),style:{...F,clipPath:en(j.top-F.top,j.left-F.left,j.top+j.height-F.top,j.left+j.width-F.left)}}),F&&j&&ee&&x.jsx("div",{style:{position:"absolute",top:F.top,left:0,right:0,height:F.height,pointerEvents:"none"},children:x.jsx("div",{className:$("dsg-selection-rect",D&&"dsg-selection-rect-disabled","dsg-selection-rect-sticky"),style:{position:"sticky",left:X,width:F.width,height:"100%",background:"var(--dsg-selection-background-color)",clipPath:en(j.top-F.top,se-X,j.top+j.height-F.top,se+j.width-X)}})}),te&&!ee&&x.jsx("div",{className:"dsg-expand-rows-rect",style:te}),te&&ee&&x.jsx("div",{style:{position:"absolute",top:te.top,left:0,right:0,height:te.height,pointerEvents:"none"},children:x.jsx("div",{className:$("dsg-expand-rows-rect","dsg-expand-rows-rect-sticky"),style:{position:"sticky",left:X,width:te.width,height:"100%"}})}),ue&&!z&&x.jsx("div",{className:$("dsg-expand-rows-indicator",D&&"dsg-expand-rows-indicator-disabled"),style:ue}),ue&&z&&x.jsx("div",{style:{position:"absolute",top:ue.top,left:0,right:0,height:0,pointerEvents:"none"},children:x.jsx("div",{className:$("dsg-expand-rows-indicator",D&&"dsg-expand-rows-indicator-disabled","dsg-expand-rows-indicator-sticky"),style:{position:"sticky",left:Q,transform:ue.transform,pointerEvents:"auto"}})})]})});dn.displayName="SelectionRect";const Rr=({value:e,rowHeight:r})=>{const t=d.useRef([]),[,s]=d.useState(0);return d.useMemo(()=>{const n=o=>{if(typeof r=="number")return Math.min(e.length-1,Math.max(-1,Math.floor(o/r)));let i=0,a=t.current.length-1;for(;i<=a;){const f=Math.floor((i+a)/2);if(t.current[f].top<o)i=f+1;else if(t.current[f].top>o)a=f-1;else return f}if(a===t.current.length-1&&e.length>t.current.length&&(!t.current.length||o>=t.current[a].top+t.current[a].height)){let f=a===-1?0:t.current[a].top+t.current[a].height;do{a++;const m=r({rowIndex:a,rowData:e[a]});t.current.push({height:m,top:f}),f+=m}while(f<=o&&a<t.current.length-1)}return a};return{resetAfter:o=>{t.current=t.current.slice(0,o),s(i=>i+1)},getRowSize:o=>{if(typeof r=="number")return{height:r,top:r*o};if(o>=e.length)return{height:0,top:0};if(o<t.current.length)return t.current[o];let i=t.current[t.current.length-1].top+t.current[t.current.length-1].height;for(let a=t.current.length;a<=o;a++){const f=r({rowIndex:a,rowData:e[a]});t.current.push({height:f,top:i}),i+=f}return t.current[o]},getRowIndex:n,totalSize:o=>{if(typeof r=="number")return e.length*r;const i=n(o);return t.current[i].top+t.current[i].height}}},[r,e])},Or=[],jr=[],Nr=()=>({}),ke=()=>null,Mr=({rowData:e})=>({...e}),xt=d.memo(d.forwardRef(({value:e=Or,className:r,style:t,height:s=400,onChange:n=ke,columns:o=jr,rowHeight:i=40,headerRowHeight:a=typeof i=="number"?i:40,gutterColumn:f,stickyRightColumn:m,rowKey:g,addRowsComponent:R=ln,createRow:p=Nr,autoAddRow:O=!1,lockRows:S=!1,disableExpandSelection:T=!1,disableSmartDelete:M=!1,duplicateRow:U=Mr,contextMenuComponent:D=cn,disableContextMenu:A=!1,onFocus:L=ke,onBlur:j=ke,onActiveCellChange:F=ke,onSelectionChange:ae=ke,rowClassName:se,cellClassName:ee,onScroll:X,pinFirstColumn:ce=!1},q)=>{const z=d.useRef(null),Q=A||S,b=sr(o,f,m,ce),k=!!m,ue=ce||!!b[1]?.stickyLeft,te=d.useRef(null),W=d.useRef(null),v=d.useRef(null),B=d.useRef(null),[V,ge]=cr(1,100),{getRowSize:oe,totalSize:Be,getRowIndex:Oe}=Rr({value:e,rowHeight:i}),je=Math.min(s,a+Be(s)+V),{width:fe,height:xe}=Jn({targetRef:W,refreshMode:"throttle",refreshRate:100});ge(xe?je-xe:0);const wn=ar(W,fe,xe),{fullWidth:bt,totalWidth:xn,columnWidths:G,columnRights:ie}=An(b,fe),bn=d.useMemo(()=>b.slice(1).map(l=>!!l.stickyLeft),[b]),yn=d.useCallback(l=>{if(!b[l]?.stickyLeft)return 0;if(!G||!G.length){let w=0;for(let h=0;h<l;h++)(b[h].stickyLeft||h===0)&&(w+=b[h].basis||b[h].minWidth||100);return w}let c=0;for(let w=0;w<l;w++)(b[w].stickyLeft||w===0)&&(c+=G[w]);return c},[b,G]),[ye,le]=d.useState(null),[ve,vn]=d.useState([]),[K,Y]=d.useState(!1),[Ee,yt]=d.useState(0),[Se,vt]=d.useState(null),[u,P]=Pe(null),[J,_]=Pe(null),y=d.useMemo(()=>u&&J&&{min:{col:Math.min(u.col,J.col),row:Math.min(u.row,J.row)},max:{col:Math.max(u.col,J.col),row:Math.max(u.row,J.row)}},[u,J]),[de,Ie]=Pe({columns:!1,rows:!1,active:!1}),En=T||K||de.active||u?.row===e?.length-1||y?.max.row===e?.length-1||u&&b.slice((y?.min.col??u.col)+1,(y?.max.col??u.col)+2).every(l=>l.disabled===!0)?null:Ee,Et=Wt(te),St=Wt(W);d.useEffect(()=>{u!==null&&(document.activeElement.blur(),window.getSelection()?.removeAllRanges())},[u!==null]);const be=d.useCallback((l,c=!1,w=!1)=>{const h=Et(c),I=w&&St(c);if(h&&ie&&G){let E=l.clientX-h.left,N=l.clientY-h.top;return I&&(l.clientY-I.top<=a&&(N=0),l.clientX-I.left<=G[0]&&(E=0),ue&&l.clientX-I.left<=G[0]+G[1]&&(E=ie[0]+1),k&&I.right-l.clientX<=G[G.length-1]&&(E=ie[ie.length-2]+1)),{col:ie.findIndex(C=>E<C)-1,row:Oe(N-a)}}return null},[ie,G,e.length,Et,St,a,k,ue,Oe]),ne=d.useRef(e);ne.current=e;const re=d.useCallback(l=>{const c=b[l.col+1].disabled;return!!(typeof c=="function"?c({rowData:ne.current[l.row],rowIndex:l.row}):c)},[b]),he=d.useCallback((l,c=1)=>{S||(_(null),Y(!1),n([...ne.current.slice(0,l+1),...new Array(c).fill(0).map(p),...ne.current.slice(l+1)],[{type:"CREATE",fromRowIndex:l+1,toRowIndex:l+1+c}]),P(w=>({col:w?.col||0,row:l+c,doNotScrollX:!0})))},[p,S,n,P,_]),Ce=d.useCallback((l,c=l)=>{S||(n([...ne.current.slice(0,c+1),...ne.current.slice(l,c+1).map((w,h)=>U({rowData:w,rowIndex:h+l})),...ne.current.slice(c+1)],[{type:"CREATE",fromRowIndex:c+1,toRowIndex:c+2+c-l}]),P({col:0,row:c+1,doNotScrollX:!0}),_({col:b.length-(k?3:2),row:2*c-l+1,doNotScrollX:!0}),Y(!1))},[b.length,U,S,n,P,_,k]),me=d.useCallback(l=>{if(!(!xe||!fe)){if(!l.doNotScrollY){const c=oe(l.row).top,w=oe(l.row).top+oe(l.row).height+a-xe+1,h=W.current.scrollTop;h>c?W.current.scrollTop=c:h<w&&(W.current.scrollTop=w)}if(ie&&G&&W.current&&!l.doNotScrollX){const c=ie[l.col]-ie[0],w=ie[l.col]+G[l.col+1]+(k?G[G.length-1]:0)-fe+1,h=W.current.scrollLeft;h>c?W.current.scrollLeft=c:h<w&&(W.current.scrollLeft=w)}}},[xe,fe,a,ie,G,oe,k]);d.useEffect(()=>{J&&me(J)},[J,me]),d.useEffect(()=>{u&&me(u)},[u,me]);const Sn=d.useCallback((l,c)=>{n([...ne.current?.slice(0,l),c,...ne.current?.slice(l+1)],[{type:"UPDATE",fromRowIndex:l,toRowIndex:l+1}])},[n]),Te=d.useCallback((l,c=l)=>{S||(Y(!1),P(w=>{const h=Math.min(ne.current.length-2-c+l,l);return h<0?null:w&&{col:w.col,row:h}}),_(null),n([...ne.current.slice(0,l),...ne.current.slice(c+1)],[{type:"DELETE",fromRowIndex:l,toRowIndex:c+1}]))},[S,n,P,_]),_e=d.useCallback((l=!0)=>{const c=l&&!M;if(!u)return;const w=y?.min||u,h=y?.max||u;if(e.slice(w.row,h.row+1).every((E,N)=>b.every(C=>C.isCellEmpty({rowData:E,rowIndex:N+w.row})))){c&&Te(w.row,h.row);return}const I=[...e];for(let E=w.row;E<=h.row;++E)for(let N=w.col;N<=h.col;++N)if(!re({col:N,row:E})){const{deleteValue:C=({rowData:Z})=>Z}=b[N+1];I[E]=C({rowData:I[E],rowIndex:E})}if(c&&sn(I,e)){P({col:0,row:w.row,doNotScrollX:!0}),_({col:b.length-(k?3:2),row:h.row,doNotScrollX:!0});return}n(I,[{type:"UPDATE",fromRowIndex:w.row,toRowIndex:h.row+1}])},[u,b,e,Te,re,n,y?.max,y?.min,P,_,k]),Ke=d.useCallback(({nextRow:l=!0}={})=>{u?.row===ne.current.length-1?l&&O?he(u.row):Y(!1):(Y(!1),l&&P(c=>c&&{col:c.col,row:c.row+1}))},[u?.row,O,he,P]),Ne=d.useCallback(async l=>{if(!K&&u){const c=[],w=y?.min||u,h=y?.max||u;for(let C=w.row;C<=h.row;++C){c.push([]);for(let Z=w.col;Z<=h.col;++Z){const{copyValue:H=()=>null}=b[Z+1];c[C-w.row].push(H({rowData:e[C],rowIndex:C}))}}const I=c.map(C=>C.join(" ")).join(`
9
+ `),E=`<table>${c.map(C=>`<tr>${C.map(Z=>`<td>${dr(String(Z??"")).replace(/\n/g,"<br/>")}</td>`).join("")}</tr>`).join("")}</table>`;if(l!==void 0){l.clipboardData?.setData("text/plain",I),l.clipboardData?.setData("text/html",E),l.preventDefault();return}let N=!1;if(navigator.clipboard.write!==void 0){const C=new Blob([I],{type:"text/plain"}),Z=new Blob([E],{type:"text/html"}),H=[new ClipboardItem({"text/plain":C,"text/html":Z})];await navigator.clipboard.write(H).then(()=>{N=!0})}else navigator.clipboard.writeText!==void 0?await navigator.clipboard.writeText(I).then(()=>{N=!0}):document.execCommand!==void 0&&document.execCommand("copy")&&(N=!0);N||alert("This action is unavailable in your browser, but you can still use Ctrl+C for copy or Ctrl+X for cut")}},[u,b,e,K,y]);pe("copy",Ne);const Ue=d.useCallback(l=>{!K&&u&&(Ne(l),_e(!1))},[u,_e,K,Ne]);pe("cut",Ue);const Me=d.useCallback(async l=>{if(!K&&u){const c=y?.min||u,w=y?.max||u,h=await Promise.all(l[0].map((I,E)=>{const N=b[c.col+E+1]?.prePasteValues,C=l.map(Z=>Z[E]);return N?.(C)??C}));if(l=l.map((I,E)=>h.map(N=>N[E])),l.length===1){const I=[...e];for(let E=0;E<l[0].length;E++){const N=b[c.col+E+1]?.pasteValue;if(N)for(let C=c.row;C<=w.row;C++)re({col:E+c.col,row:C})||(I[C]=await N({rowData:I[C],value:l[0][E],rowIndex:C}))}n(I,[{type:"UPDATE",fromRowIndex:c.row,toRowIndex:w.row+1}]),P({col:c.col,row:c.row}),_({col:Math.min(c.col+l[0].length-1,b.length-(k?3:2)),row:w.row})}else{let I=[...e];const E=c.row+l.length-e.length;E>0&&(S?l.splice(l.length-E,E):I=[...I,...new Array(E).fill(0).map(()=>p())]);for(let C=0;C<l[0].length&&c.col+C<b.length-(k?2:1);C++){const Z=b[c.col+C+1]?.pasteValue;if(Z)for(let H=0;H<l.length;H++)re({col:c.col+C,row:c.row+H})||(I[c.row+H]=await Z({rowData:I[c.row+H],value:l[H][C],rowIndex:c.row+H}))}const N=[{type:"UPDATE",fromRowIndex:c.row,toRowIndex:c.row+l.length-(!S&&E>0?E:0)}];E>0&&!S&&N.push({type:"CREATE",fromRowIndex:c.row+l.length-E,toRowIndex:c.row+l.length}),n(I,N),P({col:c.col,row:c.row}),_({col:Math.min(c.col+l[0].length-1,b.length-(k?3:2)),row:c.row+l.length-1})}}},[u,b,p,e,K,k,re,S,n,y?.max,y?.min,P,_]),In=d.useCallback(l=>{if(u&&!K){let c=[[""]];l.clipboardData?.types.includes("text/html")?c=ht(l.clipboardData?.getData("text/html")):l.clipboardData?.types.includes("text/plain")?c=Fe(l.clipboardData?.getData("text/plain")):l.clipboardData?.types.includes("text")&&(c=Fe(l.clipboardData?.getData("text"))),Me(c),l.preventDefault()}},[u,Me,K]);pe("paste",In);const Cn=d.useCallback(l=>{if(ye&&ve.length)return;const c=l.button===2||l.button===0&&l.ctrlKey,w=te.current?.contains(l.target)||!1,h=w?be(l,!0,!0):null;if(!w&&K&&u&&b[u.col+1].keepFocus)return;if(l.target instanceof HTMLElement&&l.target.className.includes("dsg-expand-rows-indicator")){vt(Math.max(u?.row??0,y?.max.row??0));return}const I=h&&u&&u.col===h.col&&u.row===h.row&&!re(u);if(I&&K)return;const E=h?.col===b.length-2&&k,N=c&&y&&h&&h.row>=y.min.row&&h.row<=y.max.row&&h.col>=y.min.col&&h.col<=y.max.col,C=c&&y&&h&&h.row===-1&&h.col>=y.min.col&&h.col<=y.max.col,Z=c&&y&&h&&h.row>=y.min.row&&h.row<=y.max.row&&h.col===-1,H=E&&y&&h&&h.row>=y.min.row&&h.row<=y.max.row;if(c&&!Q&&le({x:l.clientX,y:l.clientY,cursorIndex:h}),(!(l.shiftKey&&u)||c)&&e.length>0&&P(h&&{col:(N||C)&&u?u.col:Math.max(0,E?0:h.col),row:(N||Z||H)&&u?u.row:Math.max(0,h.row),doNotScrollX:!!(N&&u||E||h.col===-1),doNotScrollY:!!(N&&u||h.row===-1)}),I&&!c&&(z.current=u),Y(!!(I&&!c)),Ie(h&&!c?{columns:h.col!==-1&&!E||!!(l.shiftKey&&u),rows:h.row!==-1||!!(l.shiftKey&&u),active:!0}:{columns:!1,rows:!1,active:!1}),l.shiftKey&&u&&!c)_(h&&{col:Math.max(0,h.col-(E?1:0)),row:Math.max(0,h.row)});else if(!N){if(h&&(h?.col===-1||h?.row===-1||E)){let $e=h.col,Ge=h.row,Xe=!1,Ye=!1;(h.col===-1||E)&&($e=b.length-(k?3:2),Xe=!0),h.row===-1&&(Ge=e.length-1,Ye=!0),C&&J&&($e=J.col,Ye=!0),(Z||H)&&J&&(Ge=J.row,Xe=!0),_({col:$e,row:Ge,doNotScrollX:Xe,doNotScrollY:Ye})}else _(null);w&&l.preventDefault()}},[ye,ve.length,be,K,u,b,re,y,k,Q,Ie,P,_,J,e.length]);pe("mousedown",Cn);const Tn=d.useCallback(()=>{if(Se!==null){if(Ee>0&&u){let l=[];const c=y?.min||u,w=y?.max||u;for(let h=c.row;h<=w.row;++h){l.push([]);for(let I=c.col;I<=w.col;++I){const{copyValue:E=()=>null}=b[I+1];l[h-c.row].push(String(E({rowData:e[h],rowIndex:h})??""))}}Promise.all(l[0].map((h,I)=>{const E=b[c.col+I+1]?.prePasteValues,N=l.map(C=>C[I]);return E?.(N)??N})).then(h=>{l=l.map((E,N)=>h.map(C=>C[N]));const I=[...e];for(let E=0;E<l[0].length;E++){const N=b[c.col+E+1]?.pasteValue;if(N)for(let C=w.row+1;C<=w.row+Ee;C++)re({col:E+c.col,row:C})||(I[C]=N({rowData:I[C],value:l[(C-w.row-1)%l.length][E],rowIndex:C}))}n(I,[{type:"UPDATE",fromRowIndex:w.row+1,toRowIndex:w.row+1+Ee}])}),yt(0),P({col:Math.min(u?.col??1/0,y?.min.col??1/0),row:Math.min(u?.row??1/0,y?.min.row??1/0),doNotScrollX:!0,doNotScrollY:!0}),_({col:Math.max(u?.col??0,y?.max.col??0),row:Math.max(u?.row??0,y?.max.row??0)+Ee})}vt(null)}Ie({columns:!1,rows:!1,active:!1})},[Se,Ie,Ee,u,y?.min,y?.max,e,n,P,_,b,re]);pe("mouseup",Tn);const Dn=d.useCallback(l=>{if(Se!==null){const c=be(l);c&&(yt(Math.max(0,c.row-Se)),me({col:c.col,row:Math.max(c.row,Se)}))}if(de.active){const c=be(l),w=b.length-(k?3:2);_(c&&{col:de.columns?Math.max(0,Math.min(w,c.col)):w,row:de.rows?Math.max(0,c.row):e.length-1,doNotScrollX:!de.columns,doNotScrollY:!de.rows}),Y(!1)}},[me,de.active,de.columns,de.rows,be,b.length,k,_,e.length,Se]);pe("mousemove",Dn);const Rn=d.useCallback(l=>{if(u&&!l.isComposing){if(l.key==="Tab"&&!l.shiftKey&&u.col===b.length-(k?3:2)&&!b[u.col+1].disableKeys)if(u.row===e.length-1){if(B.current){l.preventDefault(),P(null),_(null),Y(!1);const c=Kt(),w=c.indexOf(B.current);c[(w+1)%c.length].focus();return}}else{P(c=>({col:0,row:(c?.row??0)+1})),_(null),Y(!1),l.preventDefault();return}if(l.key==="Tab"&&l.shiftKey&&u.col===0&&!b[u.col+1].disableKeys)if(u.row===0){if(v.current){l.preventDefault(),P(null),_(null),Y(!1);const c=Kt(),w=c.indexOf(v.current);c[(w-1+c.length)%c.length].focus();return}}else{P(c=>({col:b.length-(k?3:2),row:(c?.row??1)-1})),_(null),Y(!1),l.preventDefault();return}if(l.key?.startsWith("Arrow")||l.key==="Tab"){if(K&&b[u.col+1].disableKeys||K&&["ArrowLeft","ArrowRight"].includes(l.key))return;const c=([w,h],I)=>I&&{col:Math.max(0,Math.min(b.length-(k?3:2),I.col+w)),row:Math.max(0,Math.min(e.length-1,I.row+h))};if(l.key==="Tab"&&l.shiftKey)P(w=>c([-1,0],w)),_(null);else{const w={ArrowDown:[0,1],ArrowUp:[0,-1],ArrowLeft:[-1,0],ArrowRight:[1,0],Tab:[1,0]}[l.key];(l.ctrlKey||l.metaKey)&&(w[0]*=b.length,w[1]*=e.length),l.shiftKey?_(h=>c(w,h||u)):(P(h=>c(w,h)),_(null))}Y(!1),l.preventDefault()}else l.key==="Escape"?(!K&&!J&&P(null),_(null),Y(!1)):(l.key==="Enter"||l.key==="F2")&&!l.ctrlKey&&!l.metaKey&&!l.altKey&&!l.shiftKey?(_(null),K?b[u.col+1].disableKeys||(Ke(),l.preventDefault()):re(u)||(z.current=u,Y(!0),me(u),l.preventDefault())):l.key==="Enter"&&!l.ctrlKey&&!l.metaKey&&!l.altKey&&l.shiftKey?he(y?.max.row||u.row):l.key==="d"&&(l.ctrlKey||l.metaKey)&&!l.altKey&&!l.shiftKey?(Ce(y?.min.row||u.row,y?.max.row),l.preventDefault()):(hr(l.key)||l.code.match(/Key[A-Z]$/))&&!l.ctrlKey&&!l.metaKey&&!l.altKey?!K&&!re(u)&&(z.current=u,_(null),Y(!0),me(u)):["Backspace","Delete"].includes(l.key)?K||(_e(),l.preventDefault()):l.key==="a"&&(l.ctrlKey||l.metaKey)&&(K||(P({col:0,row:0,doNotScrollY:!0,doNotScrollX:!0}),_({col:b.length-(k?3:2),row:e.length-1,doNotScrollY:!0,doNotScrollX:!0}),l.preventDefault()))}},[u,b,e.length,_e,Ce,K,he,re,me,y?.max.row,y?.min.row,J,P,_,Ke,k]);pe("keydown",Rn);const On=d.useCallback(l=>{const c=te.current?.contains(l.target)||!1,w=c?be(l,!0,!0):null,h=w&&u&&u.col===w.col&&u.row===w.row&&K;c&&!h&&l.preventDefault()},[be,u,K]);pe("contextmenu",On),d.useEffect(()=>{const l=[];u?.row!==void 0&&l.push({type:"COPY",action:()=>{Ne(),le(null)}},{type:"CUT",action:()=>{Ue(),le(null)}},{type:"PASTE",action:async()=>{if(navigator.clipboard.read!==void 0)(await navigator.clipboard.read()).forEach(async w=>{let h=[[""]];if(w.types.includes("text/html")){const I=await w.getType("text/html");h=ht(await I.text())}else if(w.types.includes("text/plain")){const I=await w.getType("text/plain");h=Fe(await I.text())}else if(w.types.includes("text")){const I=await w.getType("text");h=ht(await I.text())}Me(h)});else if(navigator.clipboard.readText!==void 0){const c=await navigator.clipboard.readText();Me(Fe(c))}else alert("This action is unavailable in your browser, but you can still use Ctrl+V for paste");le(null)}}),y?.max.row!==void 0?l.push({type:"INSERT_ROW_BELLOW",action:()=>{le(null),he(y.max.row)}}):u?.row!==void 0&&l.push({type:"INSERT_ROW_BELLOW",action:()=>{le(null),he(u.row)}}),y?.min.row!==void 0&&y.min.row!==y.max.row?l.push({type:"DUPLICATE_ROWS",fromRow:y.min.row+1,toRow:y.max.row+1,action:()=>{le(null),Ce(y.min.row,y.max.row)}}):u?.row!==void 0&&l.push({type:"DUPLICATE_ROW",action:()=>{le(null),Ce(u.row)}}),y?.min.row!==void 0&&y.min.row!==y.max.row?l.push({type:"DELETE_ROWS",fromRow:y.min.row+1,toRow:y.max.row+1,action:()=>{le(null),Te(y.min.row,y.max.row)}}):u?.row!==void 0&&l.push({type:"DELETE_ROW",action:()=>{le(null),Te(u.row)}}),vn(l),l.length||le(null)},[y,u,Te,Ce,he,Ue,Ne,Me]);const It=d.useRef(ve);It.current=ve;const jn=d.useCallback(()=>It.current,[]);d.useImperativeHandle(q,()=>({activeCell:Re(u,b),selection:Bt(y??(u?{min:u,max:u}:null),b),setSelection:l=>{const c=mr(l,b.length-(k?2:1),e.length,b);P(c?.min||null),Y(!1),Ie({columns:!1,active:!1,rows:!1}),_(c?.max||null)},setActiveCell:l=>{const c=pt(l,b.length-(k?2:1),e.length,b);P(c),Y(!1),Ie({columns:!1,active:!1,rows:!1}),_(null)}}));const we=d.useRef({onFocus:L,onBlur:j,onActiveCellChange:F,onSelectionChange:ae});return we.current.onFocus=L,we.current.onBlur=j,we.current.onActiveCellChange=F,we.current.onSelectionChange=ae,d.useEffect(()=>{z.current&&(K?we.current.onFocus({cell:Re(z.current,b)}):we.current.onBlur({cell:Re(z.current,b)}))},[K,b]),d.useEffect(()=>{we.current.onActiveCellChange({cell:Re(u,b)})},[u?.col,u?.row,b]),d.useEffect(()=>{we.current.onSelectionChange({selection:Bt(y??(u?{min:u,max:u}:null),b)})},[y?.min.col??u?.col,y?.min.row??u?.row,y?.max.col??u?.col,y?.max.row??u?.row,u?.col,u?.row,b]),x.jsxs("div",{className:r,style:t,children:[x.jsx("div",{ref:v,tabIndex:o.length&&e.length?0:void 0,onFocus:l=>{l.target.blur(),P({col:0,row:0})}}),x.jsx(Dr,{columns:b,outerRef:W,columnWidths:G,hasStickyRightColumn:k,pinFirstColumn:ce,displayHeight:je,data:e,fullWidth:bt,headerRowHeight:a,activeCell:u,innerRef:te,rowHeight:oe,rowKey:g,selection:y,rowClassName:se,editing:K,getContextMenuItems:jn,setRowData:Sn,deleteRows:Te,insertRowAfter:he,duplicateRows:Ce,stopEditing:Ke,cellClassName:ee,onScroll:X,children:x.jsx(dn,{columnRights:ie,columnWidths:G,activeCell:u,selection:y,headerRowHeight:a,rowHeight:oe,hasStickyRightColumn:k,dataLength:e.length,viewHeight:xe,viewWidth:fe,contentWidth:bt?void 0:xn,edges:wn,editing:K,isCellDisabled:re,expandSelection:En,stickyLeftColumns:bn,getStickyLeftOffset:yn})}),x.jsx("div",{ref:B,tabIndex:o.length&&e.length?0:void 0,onFocus:l=>{l.target.blur(),P({col:b.length-(k?3:2),row:e.length-1})}}),!S&&R&&x.jsx(R,{addRows:l=>he(e.length-1,l)}),ye&&ve.length>0&&x.jsx(D,{clientX:ye.x,clientY:ye.y,cursorIndex:ye.cursorIndex,items:ve,close:()=>le(null)})]})}));xt.displayName="DataSheetGrid";const kr=d.forwardRef(({columns:e,gutterColumn:r,stickyRightColumn:t,addRowsComponent:s,createRow:n,duplicateRow:o,style:i,rowKey:a,onFocus:f,onBlur:m,onActiveCellChange:g,onSelectionChange:R,rowClassName:p,rowHeight:O,...S},T)=>{const[M]=d.useState({columns:e,gutterColumn:r,stickyRightColumn:t,addRowsComponent:s,createRow:n,duplicateRow:o,style:i,rowKey:a,onFocus:f,onBlur:m,onActiveCellChange:g,onSelectionChange:R,rowClassName:p,rowHeight:O});return x.jsx(xt,{...M,...S,rowHeight:typeof O=="number"?O:M.rowHeight,ref:T})}),Ar=()=>{const e=d.useRef(!0),r=e.current;return e.current=!1,r},hn=d.memo(({active:e,focus:r,rowData:t,setRowData:s,columnData:{placeholder:n,alignRight:o,formatInputOnFocus:i,formatBlurredInput:a,parseUserInput:f,continuousUpdates:m}})=>{const g=d.useRef(null),R=Ar(),p=d.useRef({rowData:t,formatInputOnFocus:i,formatBlurredInput:a,setRowData:s,parseUserInput:f,continuousUpdates:m,firstRender:R,focusedAt:0,changedAt:0,escPressed:!1});return p.current={rowData:t,formatInputOnFocus:i,formatBlurredInput:a,setRowData:s,parseUserInput:f,continuousUpdates:m,firstRender:R,focusedAt:p.current.focusedAt,changedAt:p.current.changedAt,escPressed:p.current.escPressed},d.useLayoutEffect(()=>{r?(g.current&&(g.current.value=p.current.formatInputOnFocus(p.current.rowData),g.current.focus(),g.current.select()),p.current.escPressed=!1,p.current.focusedAt=Date.now()):g.current&&(!p.current.escPressed&&!p.current.continuousUpdates&&!p.current.firstRender&&p.current.changedAt>=p.current.focusedAt&&p.current.setRowData(p.current.parseUserInput(g.current.value)),g.current.blur())},[r]),d.useEffect(()=>{!r&&g.current&&(g.current.value=p.current.formatBlurredInput(t))},[r,t]),x.jsx("input",{defaultValue:a(t),className:$("dsg-input",o&&"dsg-input-align-right"),placeholder:e?n:void 0,tabIndex:-1,ref:g,style:{pointerEvents:r?"auto":"none"},onChange:O=>{p.current.changedAt=Date.now(),m&&s(f(O.target.value))},onKeyDown:O=>{O.key==="Escape"&&(p.current.escPressed=!0)}})});hn.displayName="TextComponent";const _r=Ae();function Ae({placeholder:e,alignRight:r=!1,continuousUpdates:t=!0,deletedValue:s=null,parseUserInput:n=m=>m.trim()||null,formatBlurredInput:o=m=>String(m??""),formatInputOnFocus:i=m=>String(m??""),formatForCopy:a=m=>String(m??""),parsePastedValue:f=m=>m.replace(/[\n\r]+/g," ").trim()||null}={}){return{component:hn,columnData:{placeholder:e,alignRight:r,continuousUpdates:t,formatInputOnFocus:i,formatBlurredInput:o,parseUserInput:n},deleteValue:()=>s,copyValue:({rowData:m})=>a(m),pasteValue:({value:m})=>f(m),isCellEmpty:({rowData:m})=>m==null}}const zr=["","false","no","off","disabled","0","n","f","unchecked","undefined","null","wrong","negative"],mn=d.memo(({focus:e,rowData:r,setRowData:t,active:s,stopEditing:n,disabled:o})=>{const i=d.useRef(null);return d.useLayoutEffect(()=>{e&&(t(!r),n({nextRow:!1}))},[e,n]),x.jsx("input",{className:"dsg-checkbox",tabIndex:-1,type:"checkbox",ref:i,disabled:o,checked:!!r,onMouseDown:()=>!s&&t(!r),onChange:()=>null})});mn.displayName="CheckboxComponent";const Fr={component:mn,deleteValue:()=>!1,copyValue:({rowData:e})=>e?"YES":"NO",pasteValue:({value:e})=>!zr.includes(e.toLowerCase()),isCellEmpty:({rowData:e})=>!e},Vr=Ae({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat().format(e):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:r},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:r}}),Pr=Ae({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat().format(e):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:Math.round(r)},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:Math.round(r)}}),Lr=1e12,qr=1e10,Wr=Ae({alignRight:!0,formatBlurredInput:e=>typeof e=="number"?new Intl.NumberFormat(void 0,{style:"percent"}).format(e):"",formatInputOnFocus:e=>typeof e=="number"&&!isNaN(e)?String(Math.round(e*Lr)/qr):"",parseUserInput:e=>{const r=parseFloat(e);return isNaN(r)?null:r/100},parsePastedValue:e=>{const r=parseFloat(e);return isNaN(r)?null:r}}),pn=d.memo(({focus:e,active:r,rowData:t,setRowData:s})=>{const n=d.useRef(null);return d.useLayoutEffect(()=>{e?n.current?.select():n.current?.blur()},[e]),x.jsx("input",{className:$("dsg-input",!r&&"dsg-hide-date-picker"),type:"date",tabIndex:-1,max:"9999-12-31",ref:n,style:{pointerEvents:e?"auto":"none",opacity:t||r?void 0:0},value:t?.toISOString().substr(0,10)??"",onChange:o=>{const i=new Date(o.target.value);s(isNaN(i.getTime())?null:i)}})});pn.displayName="DateComponent";const Br={component:pn,deleteValue:()=>null,copyValue:({rowData:e})=>e?e.toISOString().substr(0,10):null,pasteValue:({value:e})=>{const r=new Date(e.replace(/\.\s?|\//g,"-"));return isNaN(r.getTime())?null:r},minWidth:170,isCellEmpty:({rowData:e})=>!e},gn=d.memo(({focus:e,active:r,rowData:t,setRowData:s})=>{const n=d.useRef(null);return d.useLayoutEffect(()=>{e?n.current?.select():n.current?.blur()},[e]),x.jsx("input",{className:$("dsg-input",!r&&"dsg-hide-date-picker"),type:"date",tabIndex:-1,max:"9999-12-31",ref:n,style:{pointerEvents:e?"auto":"none",opacity:t||r?void 0:0},value:t??"",onChange:o=>{const i=new Date(o.target.value);s(isNaN(i.getTime())?null:i.toISOString().substr(0,10))}})});gn.displayName="IsoDateComponent";const Kr={component:gn,deleteValue:()=>null,copyValue:({rowData:e})=>e,pasteValue:({value:e})=>{const r=new Date(e.replace(/\.\s?|\//g,"-"));return isNaN(r.getTime())?null:r.toISOString().substr(0,10)},minWidth:170,isCellEmpty:({rowData:e})=>!e},Ur=({columnData:{key:e,original:r},rowData:t,setRowData:s,...n})=>{const o=d.useRef(t);o.current=t;const i=d.useCallback(f=>{s({...o.current,[e]:f})},[e,s]);if(!r.component)return x.jsx(x.Fragment,{});const a=r.component;return x.jsx(a,{columnData:r.columnData,setRowData:i,rowData:t[e],...n})},$r=(e,r)=>({id:e,...r,columnData:{key:e,original:r},component:Ur,copyValue:({rowData:t,rowIndex:s})=>r.copyValue?.({rowData:t[e],rowIndex:s})??null,deleteValue:({rowData:t,rowIndex:s})=>({...t,[e]:r.deleteValue?.({rowData:t[e],rowIndex:s})??null}),pasteValue:({rowData:t,value:s,rowIndex:n})=>({...t,[e]:r.pasteValue?.({rowData:t[e],value:s,rowIndex:n})??null}),disabled:typeof r.disabled=="function"?({rowData:t,rowIndex:s})=>typeof r.disabled=="function"?r.disabled({rowData:t[e],rowIndex:s}):r.disabled??!1:r.disabled,cellClassName:typeof r.cellClassName=="function"?({rowData:t,rowIndex:s,columnId:n})=>typeof r.cellClassName=="function"?r.cellClassName({rowData:t[e],rowIndex:s,columnId:n}):r.cellClassName??void 0:r.cellClassName,isCellEmpty:({rowData:t,rowIndex:s})=>r.isCellEmpty?.({rowData:t[e],rowIndex:s})??!1}),Gr=xt,Xr=kr;exports.DataSheetGrid=Xr;exports.DynamicDataSheetGrid=Gr;exports.checkboxColumn=Fr;exports.createAddRowsComponent=on;exports.createContextMenuComponent=an;exports.createTextColumn=Ae;exports.dateColumn=Br;exports.floatColumn=Vr;exports.intColumn=Pr;exports.isoDateColumn=Kr;exports.keyColumn=$r;exports.percentColumn=Wr;exports.renderContextMenuItem=wt;exports.textColumn=_r;
10
10
  //# sourceMappingURL=index.cjs.map