@sheetxl/grid-react 0.4.20 → 0.4.22

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,19 +1,12 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
2
  "use strict";/**
3
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.20
3
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.22
4
4
  *
5
5
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
6
6
  * License: The license can be found at https://www.sheetxl.com/license.
7
- */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),c=require("react"),Ti=require("react-dom/client"),No=require("react-dom"),nt="up",ot="down",et="left",Ne="right",to="tl",Ln="t",Dn="l",Ht="c",Dt="text/html",rn="text/plain",xo="image/png",Pi=Object.freeze({left:0,top:0}),Oi=Object.freeze({left:0,top:0,bottom:0,right:0}),Li=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Li,EmptyRect:Oi,EmptyTopLeft:Pi},Symbol.toStringTag,{value:"Module"}));const Bt="column",en="row",Di=Object.freeze({colIndex:0,rowIndex:0}),zi=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),Fr=(e,t)=>e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart,Vr=(e,t)=>e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart,ji=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,Ai=(e,t)=>e.colEnd===t.colEnd?t.rowEnd-e.rowEnd:t.colEnd-e.colEnd,Jo=(e,t)=>e.colIndex===t.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex,Qo=(e,t)=>e.rowIndex===t.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex,Wr=(e=en,t=!1)=>t?e!==Bt?ji:Ai:e!==Bt?Vr:Fr,er=(e,t)=>e===t||!(!e||!t)&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,Po=(e,t)=>e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd,Oo=(e,t)=>!(!e||!t||e.colStart>t.colEnd||t.colStart>e.colEnd||e.rowStart>t.rowEnd||t.rowStart>e.rowEnd),tr=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Po(e[n],t[n]))return!1;return!0},yo=(e,t,n)=>{if(!e&&!t)return null;if(!e)return n?t:{...t};if(!t)return n?e:{...e};const o=Math.min(e.colStart,t.colStart),r=Math.min(e.rowStart,t.rowStart),i=Math.max(e.colEnd,t.colEnd),l=Math.max(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},nr=(e,t)=>{if(!t||t.length===0)return e;const n={...e};for(let o=0;o<t.length;o++){const r=t[o];Oo(n,r)&&(n.rowStart=Math.min(n.rowStart,r.rowStart),n.colStart=Math.min(n.colStart,r.colStart),n.rowEnd=Math.max(n.rowEnd,r.rowEnd),n.colEnd=Math.max(n.colEnd,r.colEnd))}return n},$i=[null,null],Bi=(e,t,n)=>{if(e[0].value===e[1].value)return t};function or(e,t=2,n,o=en,r){let i=[...e];if(t<=0||e.length<=1)return i;let l=o===Bt,s=0,u=!1;do{const d=i.sort(Wr(l?en:Bt));i=[],i.push(d[0]);const p=d.length;let x=0,h=d[0],y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd;for(let J=1;J<p;J++){const O=d[J];let I=!1;if(I=l?h&&R===O.rowStart&&L===O.rowEnd&&C+1===O.colStart:h&&y===O.colStart&&C===O.colEnd&&L+1===O.rowStart,I){let j={colStart:y,rowStart:R,colEnd:l?O.colEnd:C,rowEnd:l?L:O.rowEnd};if(h.value!==void 0&&(j.value=h.value),n){const le=r??[null,null];le[0]=h,le[1]=O,j=n(le,j,o)}if(j){i[x]=j,u=!0,h=j,y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd;continue}}i[++x]=O,h=O,y=h.colStart,R=h.rowStart,C=h.colEnd,L=h.rowEnd}s++,l=!l,s===1&&(u=!0)}while(s<t&&u&&i.length>1);return i}const G=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:Di,EmptyRange:zi,cellToRange:(e,t)=>{if(!e)return null;let n=t;return n||(n={...e},delete n.colIndex,delete n.rowIndex),n.colStart=e.colIndex??0,n.rowStart=e.rowIndex??0,n.colEnd=e.colIndex??0,n.rowEnd=e.rowIndex??0,n},columnFirstCellComparator:Jo,columnFirstRangeComparator:Fr,createCellComparator:(e=en,t=!1)=>t?e!==Bt?(n,o)=>n.rowIndex===o.rowIndex?o.colIndex-n.colIndex:o.rowIndex-n.rowIndex:(n,o)=>n.colIndex===o.colIndex?o.rowIndex-n.rowIndex:o.colIndex-n.colIndex:e!==Bt?Qo:Jo,createConflatingRanges:(e,t=!1)=>{const n=[];let o,r,i=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;return{append:(s,u,d)=>{let p=!0;const x=d!==void 0;if(x){const R=e?e(r,d,t):r===d?d:void 0;R===void 0?p=!1:d=R}if(p&&u===l+1&&s===i)return t?o.rowEnd=u:o.colEnd=u,l=u,void(r=d);o&&n.push(o);const h=t?s:u,y=t?u:s;o={colStart:h,rowStart:y,colEnd:h,rowEnd:y},x&&(o.value=d),i=s,l=u,r=d},done:s=>(o&&(n.push(o),o=null),s?or(n,3,s===!0?Bi:s,t?Bt:en,$i):n)}},createRangeComparator:Wr,defaultRange:(e,t,n)=>e?n?(n.colStart=e.colStart??t.colStart,n.rowStart=e.rowStart??t.rowStart,n.colEnd=e.colEnd??t.colEnd,n.rowEnd=e.rowEnd??t.rowEnd,n):{colStart:e.colStart??t.colStart,rowStart:e.rowStart??t.rowStart,colEnd:e.colEnd??t.colEnd,rowEnd:e.rowEnd??t.rowEnd}:t,extendRangeToIntersectingRanges:nr,extendRangeToUnionRanges:(e,t)=>{if(!t||t.length===0)return e;let n=e,o=null;for(;!Po(n,o);)o=n,n=nr(o,t);return n},indexOfCoords:(e,t)=>{const n={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex};for(let o=t.length-1;o>=0;o--)if(Oo(n,t[o]))return o;return-1},intersectRanges:(e,t,n)=>{if(!e)return n?t:{...t};if(!t)return n?e:{...e};if(!e&&!t||e.rowStart>t.rowEnd||e.rowEnd<t.rowStart||e.colStart>t.colEnd||e.colEnd<t.colStart)return null;const o=Math.max(e.colStart,t.colStart),r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.colEnd,t.colEnd),l=Math.min(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},isCellWithinRange:(e,t)=>!(!e||!t||e.rowIndex<t.rowStart||e.rowIndex>t.rowEnd||e.colIndex<t.colStart||e.colIndex>t.colEnd),isEqualCells:er,isEqualRanges:Po,isEqualRangesArrays:tr,isEqualSelectionCoords:(e,t)=>e===t||!(!e||!t)&&e.rangeIndex===t.rangeIndex&&!!er(e.cell,t.cell)&&tr(e.ranges,t.ranges),isRangeWithinRange:(e,t)=>!(e.rowStart<t.rowStart||e.rowEnd>t.rowEnd||e.colStart<t.colStart||e.colEnd>t.colEnd),isRangesIntersect:Oo,isSingleCell:e=>!!e&&e.rowEnd===e.rowStart&&e.colStart===e.colEnd,isValidRange:e=>!(!e||typeof e.colStart!="number"||e.colStart<0||typeof e.colEnd!="number"||e.colEnd<e.colStart||typeof e.rowStart!="number"||e.rowStart<0||typeof e.rowEnd!="number"||e.rowEnd<e.rowStart),mergeRangedValues:or,rowFirstCellComparator:Qo,rowFirstRangeComparator:Vr,sanitizeRange:e=>e?{colStart:e.colIndex??e.colStart??0,rowStart:e.rowIndex??e.rowStart??0,colEnd:e.colIndex??e.colEnd??0,rowEnd:e.rowIndex??e.rowEnd??0}:null,translateRange:(e,t=-e.rowStart,n=-e.colStart,o)=>o?(o.colStart=e.colStart+n,o.rowStart=e.rowStart+t,o.colEnd=e.colEnd+n,o.rowEnd=e.rowEnd+t,o):{colStart:e.colStart+n,rowStart:e.rowStart+t,colEnd:e.colEnd+n,rowEnd:e.rowEnd+t},unionRanges:yo,unionRangesArrays:(e,t,n)=>{if(!e||e.length===0)return null;if(e.length===1&&!t)return e[0];let o=e[0];for(let r=1;r<e.length;r++)o=yo(o,e[r],n);return t&&(o=yo(o,t,n)),o}},Symbol.toStringTag,{value:"Module"})),Fi=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function Vi(e){return function(t){return!!t&&typeof t=="object"}(e)&&!function(t){const n=Object.prototype.toString.call(t);return n==="[object RegExp]"||n==="[object Date]"||t.$$typeof===Fi}(e)}function Pn(e,t){return t.clone!==!1&&t.isMergeableObject(e)?pn((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function Wi(e,t,n){return e.concat(t).map(function(o){return Pn(o,n)})}function rr(e){return Object.keys(e).concat((t=e,Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(n){return Object.propertyIsEnumerable.call(t,n)}):[]));var t}function ir(e,t){try{return t in e}catch{return!1}}function pn(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||Wi,n.isMergeableObject=n.isMergeableObject||Vi,n.cloneUnlessOtherwiseSpecified=Pn;const o=Array.isArray(t);return o===Array.isArray(e)?o?n.arrayMerge(e,t,n):function(r,i,l){const s={};return l.isMergeableObject(r)&&rr(r).forEach(function(u){s[u]=Pn(r[u],l)}),rr(i).forEach(function(u){var d,p;ir(d=r,p=u)&&(!Object.hasOwnProperty.call(d,p)||!Object.propertyIsEnumerable.call(d,p))||(ir(r,u)&&l.isMergeableObject(i[u])?s[u]=function(x,h){if(!h.customMerge)return pn;const y=h.customMerge(x);return typeof y=="function"?y:pn}(u,l)(r[u],i[u],l):s[u]=Pn(i[u],l))}),s}(e,t,n):Pn(t,n)}pn.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,o){return pn(n,o,t)},{})};const Hi=Object.freeze([]),Ni=Object.freeze({}),lr=e=>e,Zn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return(e==="x"?t:3&t|8).toString(16)}),Hr=(e,t)=>e===t||!(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)&&e.every((n,o)=>n===t[o]),kn=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null,Nr=e=>typeof e!="object"||Array.isArray(e)||e===null?e:(Object.keys(e).forEach(function(t){e[t]&&typeof e[t]=="object"?Nr(e[t]):e[t]!==null&&e[t]!==void 0||delete e[t],typeof e[t]=="object"&&Object.keys(e[t]).length===0&&delete e[t]}),Object.keys(e).length===0?null:e),Ui=(e,t)=>!(e!==t&&!Hr(e,t)&&!e.isEqual?.(t)),Ur=(e,t,n=Ui)=>{if(e==null||e===t)return null;if(!e||typeof e!="object"||Array.isArray(e)||e.isImmutable?.())return n(e,t)?null:e;const o=Object.keys(e);if(o.length===0)return null;let r=!1;for(let i=0;i<o.length;i++){const l=o[i];Ur(e[l],t?.[l],n)===null&&(r=!0,delete e[l])}return r&&Object.keys(e).length===0?null:void 0},sr=typeof performance=="object"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),cr=e=>e==null,ar=(e,t)=>!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top),ur=!(typeof window>"u"||!window.document||!window.document.createElement),zt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},zn=()=>{if(Kr())return zt.Node;const e=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?zt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?zt.MacOS:/(iphone|ipad|ipod)/i.test(e)?zt.IOS:/android/.test(e)?zt.Android:/linux/.test(e)?zt.Linux:/^((?!chrome|android|).)*safari/i.test(e)?zt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?zt.Firefox:zt.Unknown:zt.Unknown};function Kr(){return typeof process<"u"&&process.release?.name==="node"||(typeof process<"u"&&process.browser,!1)}const dr=(e,t=!1)=>(document.hasFocus()||t)&&(e===document.activeElement||e?.contains(document.activeElement)),St=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:Hi,EmptyObject:Ni,OSType:zt,arrayMove:function(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o},asNumber:e=>{const t=(n=>1*n)(e);return Number.isFinite(t)?t:0},camelToPrettyCase:e=>e.length===1?e.toUpperCase():e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).trim(),canUseDOM:ur,cancelTimeout:e=>{cancelAnimationFrame(e.id)},castToString:e=>e==null||e===void 0?"":typeof e!="string"?""+e:e,cloneObject:e=>cr(e)?e:JSON.parse(JSON.stringify(e)),consoleWithNoSource:(...e)=>new Promise(t=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,e),t()})}),debounce:function(e,t=300,n=!1){let o,r,i,l,s=0;function u(){let p=Date.now()-s;p<t&&p>=0?o=setTimeout(u,t-p):(o=null,n||(l=e.apply(i,r),i=r=null))}t==null&&(t=100);const d=function(){i=globalThis,r=arguments,s=Date.now();var p=n&&!o;return o||(o=setTimeout(u,t)),p&&(l=e.apply(i,r),i=r=null),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=e.apply(i,r),i=r=null,clearTimeout(o),o=null)},d},deepEqual:function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;let o,r,i;if(Array.isArray(t)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(o=t.length,o!=n.length)return!1;for(r=o;r--!==0;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),o=i.length,o!==Object.keys(n).length)return!1;for(r=o;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;r--!==0;){let l=i[r];if(!(l==="_owner"&&t.$$typeof||e(t[l],n[l])))return!1}return!0}return t!=t&&n!=n},deepFreeze:function e(t){return Object.freeze(t),Object.keys(t).forEach(n=>{typeof t[n]!="object"||t[n]===null||Object.isFrozen(t[n])||e(t[n])}),t},deepMerge:pn,diffValues:(e,t)=>{const n={},o=Object.keys(t),r=o.length;for(let i=0;i<r;i++){const l=o[i];e[l]!==t[l]&&(e[l]===void 0?n[l]=t[l]:n[l]=e[l])}return Object.keys(n).length===0?null:n},findEqualOrGreater:function(e,t,n=lr){let o=0,r=e.length-1;for(;o<=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l<t?o=i+1:r=i-1}return o},findEqualOrLesser:function(e,t,n=lr){let o=e.length-1,r=0;for(;o>=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l>t?o=i-1:r=i+1}return o},findNextStep:(e,t=!0,n=15,o=10,r=400)=>{const i=Math.max(e-o,0)+(t?1:-1);return Math.min(r,Math[t?"ceil":"floor"](i/n)*n+o)},getDPI:()=>{let e=1;return typeof window=="object"&&(e=window.devicePixelRatio||1),e},getFromPath:(e,t)=>{const n=t.split(".");let o=e;for(let r=0;r<n.length;r++){const i=n[r];if(!o)return null;let l=o[i];if(typeof l=="function"&&(l=l.bind(o)()),!l||!kn(l))return l;o=l}return o??null},getOS:zn,hasFocus:dr,isDefined:e=>e!=null,isEmpty:e=>e==null||e==="",isEqualArrays:Hr,isEqualBounds:(e,t)=>e===t||!(e&&!t||t&&!e)&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,isEqualObjectKeys:(e,t)=>{if(e===t)return!0;if(e&&!t||t&&!e)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(e[n[o]]!==t[n[o]])return!1;return!0},isNode:Kr,isNullOrUndefined:cr,isNumeric:e=>{const t=1*e;return Number.isFinite(t)&&typeof t=="number"},isObject:kn,isPromiseLike:e=>!!e&&typeof e.then=="function",isRectInsideRect:(e,t)=>e.top>=t.top&&e.bottom<=t.bottom&&e.left>=t.left&&e.right<=t.right,isRectIntersect:ar,mergeContentful:(...e)=>{const t=e.length;if(t>0&&e[t-1]!==void 0&&!kn(e[t-1]))return e[t-1];let n=e[0]||{};for(let o=1;o<t;o++)n=pn(n,e[o]||{},{arrayMerge:(r,i)=>[...i]});return n},nextTick:e=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>{e()}):(typeof setImmediate=="function"?setImmediate:setTimeout)(()=>{e()})},openFileDialog:(e="*.*")=>new Promise((t,n)=>{if(!ur)return void n("Unable to open dialog with no dom.");const o=document.createElement("input");o.type="file",o.accept=e;let r=null,i=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||i||(i=!0,t(null))},1e3)},{once:!0,passive:!0}),o.onchange=()=>{if(r=o.files[0],r){if(i)return void console.warn("File open detected after faux cancel.",r);t(r)}},o.autofocus=!0,o.click()}),rafThrottle:e=>{let t,n=!1,o=function(){n=!1,e(t)};return function(r){t=r,t&&t.persist&&t.persist(),n||(n=!0,requestAnimationFrame(o))}},removeEmptyProperties:Nr,removeEqualValues:Ur,removeListenerAll:e=>{if(!e)return[];for(let t=0;t<e.length;t++)e[t]&&e[t]();return[]},requestTimeout:(e,t)=>{const n=sr(),o={id:requestAnimationFrame(function r(){sr()-n>=t?e.call(null):o.id=requestAnimationFrame(r)})};return o},roundAccurately:(e,t=0)=>{if(e==null||!isFinite(e))return null;const n=10**t;return Number(Math.round(e*n)/n)},setToPath:(e,t,n)=>{const o=t.split(".");let r=e;if(!r)throw new Error("Can not set path to a null path.");for(let i=0;r&&i<o.length-1;i++){const l=o[i];let s=r[l];if(s==null&&(s={},r[l]=s),!kn(s))throw new Error("Can not set path to a non object path.");r=s}if(typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"&&!kn(n))throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);return r[o[o.length-1]]=n,e},splitNumber:e=>{let t=Math.abs(e);if(isNaN(t)||!isFinite(e))return null;let n=0|t,o=t-n,r=0,i=0,l=1;if(o>5e-8)for(;i<8&&Math.abs(r/l-o)>5e-8;)i++,l*=10,r=Math.round(o*l);return{ip:Math.trunc(e),fp:r,ipLength:Math.ceil(Math.log10(n+1)),fpLength:i}},subtractRect:(e,t,n=!1)=>{if(!t)return[e];if(!ar(e,t))return[];const o=[];let r=e;const i=()=>{t.top>r.top&&t.top<r.bottom&&(o.push({...r,bottom:t.top}),r={...r,top:t.top})},l=()=>{t.bottom>r.top&&t.bottom<r.bottom&&(o.push({...r,top:t.bottom}),r={...r,bottom:t.bottom})},s=()=>{t.right>r.left&&t.right<r.right&&(o.push({...r,left:t.right}),r={...r,right:t.right})},u=()=>{t.left>r.left&&t.left<r.right&&(o.push({...r,right:t.left}),r={...r,left:t.left})};return n?(u(),s(),i(),l()):(i(),l(),s(),u()),o},textToKey:e=>e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(e,t){let n=null;return(...o)=>{const r=Date.now();(!n||r-n>=t)&&(n=r,e(...o))}},toSafeJSON:function e(t){if(t===null||typeof t!="object")return t;if(typeof t.toJSON=="function")return t.toJSON();if(Array.isArray(t))return t.map(o=>e(o));if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString();const n={};for(const o in t)t.hasOwnProperty(o)&&(n[o]=e(t[o]));return n},transpose:e=>{if(!e)return e;const t=e.length,n=e[0].length,o=[];for(let r=0;r<n;r++)o[r]=Array(t);for(let r=0;r<t;r++)for(let i=0;i<n;i++)o[i][r]=e[r][i];return o},uuidV4:Zn,validEnumValue:(e,t)=>{if(!Object.values(e).includes(t))throw new Error(`Invalid type: ${t??"null"}. Must be one of: ${Object.values(t).join(", ")}.`)},whenFocus:async(e,t=!1)=>new Promise(n=>{dr(e,t)?n(!0):e.addEventListener("focusin",()=>{n(!0)},{once:!0}),e.focus()})},Symbol.toStringTag,{value:"Module"}));Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:e=>`Invalid argument: '${e}'.`},Symbol.toStringTag,{value:"Module"}));const qr=e=>{const t=new Uint8Array(e),n=t.byteLength;let o="";for(let r=0;r<n;r++)o+=String.fromCharCode(t[r]);if(typeof window<"u"&&typeof globalThis.btoa=="function")return globalThis.btoa(o);if(typeof Buffer<"u")return Buffer.from(o,"binary").toString("base64");throw new Error("Unsupported environment")},Lo=e=>new Promise((t,n)=>{if(e)if(typeof FileReader<"u"){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{n(o.error)},o.readAsText(e)}else if(typeof Buffer<"u"){const o=r=>Buffer.from(r).toString("utf-8");e.arrayBuffer().then(r=>{t(o(r))}).catch(r=>{n(r)})}else n(new Error("Unsupported environment"));else t("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:qr,base64ToArrayBuffer:e=>{const t=typeof window<"u"&&typeof globalThis.atob=="function"?globalThis.atob(e):Buffer.from(e,"base64").toString("binary"),n=t.length,o=new Uint8Array(n);for(let r=0;r<n;r++)o[r]=t.charCodeAt(r);return o.buffer},blobToString:Lo},Symbol.toStringTag,{value:"Module"}));const Xr="data:image/png;base64,",Yr="Unable to resolve image.",hr=e=>new Promise(async(t,n)=>{let o=null;try{o=new Image,o.src=e,o.addEventListener("load",function(){t({width:o.naturalWidth,height:o.naturalHeight})},{once:!0}),o.addEventListener("error",function(){URL.revokeObjectURL(e),n("Invalid Image")},{once:!0}),await o.decode("sync")}catch{o?.src&&URL.revokeObjectURL(o.src)}o||n(Yr)}),bo="image/svg+xml";var fr,pr;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Xr,getImageDataUrl:(e,t=1)=>new Promise(async(n,o)=>{let r=null;try{r=new Image,r.src=e,r.addEventListener("load",function(){try{const i=document.createElement("canvas");i.width=r.naturalWidth,i.height=r.naturalHeight,i.getContext("2d").drawImage(r,0,0);const l=i.toDataURL("image/png",t);n({elemImg:r,dataUrl:l})}catch(i){URL.revokeObjectURL(e),o(i)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(e),o("Invalid Image")},{once:!0}),await r.decode("sync")}catch{r?.src&&URL.revokeObjectURL(r.src)}r||o(Yr)}),loadImageDetails:async(e,t=null)=>{let n=null;const o=async()=>{try{const i=t??"image/*",l=URL.createObjectURL(new Blob([e],{type:i})),s=await hr(l);n={mimeType:i,naturalDimensions:s,asUrl:l}}catch{}},r=async()=>{try{const i=new TextDecoder().decode(e),l=URL.createObjectURL(new Blob([i],{type:bo})),s=await hr(l);n={mimeType:t??bo,naturalDimensions:s,asUrl:l,asSVGText:i}}catch{}};if(t===bo?await r():t.startsWith("image/")?await o():(await o(),n||await r()),!n)throw new Error("Failed to load image");return n}},Symbol.toStringTag,{value:"Module"})),(pr=fr||(fr={})).resolveTypedUpdates=(e,t,n,o)=>{if(e===null)return e;if(e===void 0)return o;let r=e;if(t?.shorthand){const u=t?.shorthand(e,n);u!==void 0&&(r=u)}if(r!==null&&t?.getSubType){const u=t.getSubType(r);u&&(t=u)}const i=t?.properties,l=t?.arrayType??!1;let s=r;if(t&&t.merge&&s&&o)s=t.merge(s,o,n);else if(!l&&i){const u=Object.keys({...r,...o});s=null;for(let d=0;d<u.length;d++){const p=u[d];let x,h=r[p];if(h!==void 0){const y=i[p];x=y?(0,pr.resolveTypedUpdates)(h,y,n,o?.[p]):h}else x=o?.[p];x!=null&&(s=s??{},s[p]=x)}}return s};const gr=`The Safari browser does not support advanced copy and paste.
8
- Copy and paste will be limited to within the browser tab.
9
-
10
- Please use Chrome or Edge if external copy and paste is required.`,vo=`You do not have permissions to access the clipboard.
11
- All copy and paste operations will be limited to the browser tab.`,Gr={Safari:`The Safari browser does not support advanced copy and paste.
12
- Copy and paste will be limited to within the browser tab.
13
-
14
- Please use Chrome or Edge if external copy and paste is required.`,Perms:vo,PermsWrite:zn()===zt.Safari?gr:vo,PermsRead:zn()===zt.Safari?gr:vo},So=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),Eo=async(e,t,n)=>{if(zn()===zt.Safari)return await n(new Error(Gr.Safari));try{const o=async l=>{try{return await l()}catch(s){if(s.message?.includes("Document is not focused"))return!1;throw s}},r=await globalThis?.navigator?.permissions?.query({name:e,allowWithoutGesture:!0,allowWithoutSanitization:!0});let i=!1;if(r.state==="prompt"&&(i=await o(t)),i||r.state!=="granted"||(i=await t()),!i)return await n(new Error(r.state))}catch(o){return o.message==="No valid data on clipboard"||o.name==="DataError"?void 0:await n(o)}},Zr=async e=>{try{return await e.read({unsanitized:[Dt]})}catch{}return await e.read()};if(!globalThis.ClipboardItem){const e=(n,o)=>new Blob([o],{type:n});class t{constructor(o,r){this._items={},this._types=Object.keys(o);const i={},l=Object.keys(o);for(let s=0;s<l.length;s++){const u=l[s];let d=o[u];i[u]=typeof d=="string"?e(u,d):d}this._items=i,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(o){return Promise.resolve(this._items[o])}supports(o){return!0}}globalThis.ClipboardItem=t}const Do=async(e,t=Dt)=>new Promise(async(n,o)=>{try{const r=await(async(i,l)=>{if(!i)return null;const s=await Zr(i);let u=!1;for(let d=0;!u&&s&&d<s.length;d++)if(u=s[d].types.includes(l),u)return await s[d].getType(l);return u?void 0:null})(e,t);if(r){const i=new FileReader;i.onload=()=>{n(i.result)},i.onerror=()=>{n("")},i.readAsText(r)}else n("")}catch(r){o(r)}}),wr=async(e,t=Dt)=>{const n=await Do(e,t);if(!n)return null;let o=null;try{o=new DOMParser().parseFromString(n,Dt)}catch{console.warn("Can't parse html from clipboard.")}return o},jn="clipboard-uuid",xn="web text/uuid",mr=e=>`<div style="display:none" ${jn}="${e}"/>`,Ki=(e,t)=>{let n=null;try{const o=new DOMParser().parseFromString(t,Dt);o.body.firstElementChild.setAttribute(jn,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(o){console.warn("Can't embed uuid.",o)}return n},xr=(e,t)=>{if(!t||!e)return!1;try{const n=t.querySelectorAll(`[${jn}="${e}"]`);if(n&&n.length===1)return!0;if(t.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};let no=class{constructor(e){if(e?.nativeClipboard===void 0||e?.nativeClipboard===!0)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{e?.nativeClipboard===!0&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=e?.nativeClipboard===!1?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await Eo("clipboard-read",async()=>{await So();const e=await Do(this._nativeClipboard,xn);if(!this._state||e&&e===this._state.uuid)return!0;const t=await wr(this._nativeClipboard,Dt);return!this._state||(xr(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||zn()===zt.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await Eo("clipboard-read",async()=>{if(await So(),this._state?.uuid){const t=await Do(this._nativeClipboard,xn);if(t&&t===e._state.uuid)return!0;const n=await wr(this._nativeClipboard,Dt);if(xr(e._state?.uuid,n))return!0}return e._state={items:await Zr(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:Zn(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],o=e.uuid;let r=e.items??[];const i=()=>{t._state={uuid:o,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await Eo("clipboard-write",async()=>{await So(),o&&r.length===0&&(r.push(new ClipboardItem({[xn]:new Blob([o],{type:xn})})),r.push(new ClipboardItem({[Dt]:new Blob([mr(o)],{type:Dt})})));for(let l=0;l<Math.min(1,r.length);l++){const s=r[l];let u=s.types.indexOf(Dt),d=null;if(u!==-1){const h=await s.getType(Dt);d=await Lo(h),d&&(d=Ki(o,d))}if(!d&&s.types.includes(rn)){const h=await s.getType(rn);if(h){let y=null;typeof h=="string"?(console.warn("text as string",h),y=h):y=await Lo(h),y&&(d=`<div ${jn}="${o}">${y}</div>`)}}if(!d&&s.types.includes(xo)){const h=await s.getType(xo),y=qr(await h.arrayBuffer());d=`<div ${jn}="${o}"><img src="${Xr+y}"/></div>`}!d&&o&&(d=mr(o));const p=new Blob([d??""],{type:Dt}),x={};for(let h=0;h<s.types.length;h++){const y=s.types[h];x[y]=h===u?p:s.getType(y)}d&&u===-1&&(x[Dt]=p),o&&(x[xn]=new Blob([o],{type:xn})),n.push(new ClipboardItem(x))}try{n&&n.length!==0?await this._nativeClipboard.write(n):await(async l=>{l&&await l.writeText("")})(this._nativeClipboard)}catch(l){l.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",l)}return i(),!0},async l=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const r=await e.toText?.()??null;r&&(n[rn]=new Blob([r??""],{type:rn}))}catch(r){t=r}try{const r=await e.toHtml?.()??null;r&&(n[Dt]=new Blob([r],{type:Dt}))}catch(r){t=r,console.warn("export to html",r)}try{const r=await e.toImage?.()??null;r&&(n[xo]=r)}catch(r){t=r,console.warn("export to png",r)}const o=this._write({uuid:Zn(),ref:e,items:Object.keys(n).length>0?[new ClipboardItem(n)]:null});if(t)throw t;return o}clear(e=!1){this._state&&(this._state=null,e&&this._write({uuid:null,ref:null,items:null}),this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")))}async readReference(){return await this.read(),this._state?.ref??null}readText(){return new Promise(async(e,t)=>{const n=await this.read();let o=null;for(let i=0;!o&&n&&i<n.length;i++)n[i].types.includes(rn)&&(o=await n[i].getType(rn));if(!o)return void e("");const r=new FileReader;r.onload=()=>{e(r.result)},r.readAsText(o),r.onerror=i=>{t(i)}})}async writeText(e){const t=[new ClipboardItem({[rn]:new Blob([e],{type:rn})})];return this._write({uuid:Zn(),items:t,ref:null})}addEventListener(e,t,n={}){const o=n?.capture?this._listenersCapture:this._listeners;let r=o.get(e);r||(r=new Map,o.set(e,r)),r.set(t,typeof n=="boolean"?{}:n)}dispatchEvent(e){if(!e)return;const t=n=>{const o=n.get(e.type);o&&o.forEach((r,i)=>{try{typeof i=="function"?i(e):i.handleEvent&&i.handleEvent(e),r.once&&o.delete(i)}catch(l){console.warn(l)}})};return t(this._listenersCapture),t(this._listeners),!0}removeEventListener(e,t,n){const o=n?.capture?this._listenersCapture:this._listeners,r=o.get(e);r&&(r.delete(t),r.size===0&&o.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}};var _o;(_o=no||(no={})).ErrorMessages=Gr,_o.Global=new _o,function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();const On={Left:"left",Right:"right",Center:"center"},vt="shift",dn="alt",Pt="ctrl",Jr=9,Qr=13,qi=27,ei=37,ti=38,ni=39,oi=40,Xi=113,yr=3,cn={Horizontal:"horizontal",Vertical:"vertical"};function ri(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=ri(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function yn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=ri(e))&&(o&&(o+=" "),o+=t);return o}var Yi=function(){},ii=typeof window<"u",Gi=ii?c.useLayoutEffect:c.useEffect,br={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const gn=ii&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(br),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,p=u.y,x=u.width,h=u.height,y=u.top,R=u.left,C=u.bottom,L=u.right;i({x:d,y:p,width:x,height:h,top:y,left:R,bottom:C,right:L})}})},[]);return Gi(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[Yi,br]},T=(e,t)=>{const n=c.useCallback((...i)=>e?.(...i),t),o=c.useRef(null);o.current=n;const r=c.useCallback((...i)=>o.current?.(...i),[]);if(o.current)return r},Zi=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return P.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:r?"0px":"3px",paddingTop:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:P.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button start`,children:P.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:P.jsx("path",{d:r?"m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z":"m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z"})})})})},Ji=e=>{const{style:t,orientation:n=cn.Vertical,...o}=e,r=n===cn.Vertical;return P.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:r?"0px":"3px",paddingBottom:r?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...t},...o,children:P.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${r?"vertical":"horizontal"} single-button end`,children:P.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:P.jsx("path",{d:r?"M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z":"m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z"})})})})},zo=(e,t,n,o,r=0)=>{for(let i=0;i<n.length;i++){const l=n[i].getBoundingClientRect();let s=l.left-t,u=s+l.width;if(o){if(s<e&&u>=e)return s}else if(Math.ceil(u)>Math.ceil(e)+2)return u}return r};Object.freeze(Object.defineProperty({__proto__:null,getScrollTo:zo},Symbol.toStringTag,{value:"Module"}));const Uo=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,totalSize:o=0,viewportSize:r=0,style:i,className:l,orientation:s=cn.Vertical,onScrollOffset:u,onScroll:d,showCustomScrollButtons:p=!1,scrollButtonIncrement:x=200,scrollButtonInitialRepeatDelay:h=260,scrollButtonAdditionalRepeatDelay:y=120,createScrollStartButton:R=Zi,createScrollEndButton:C=Ji,...L}=e,J=T(d,[d]),O=c.useRef(null),[I,{width:j,height:le}]=gn(),[B,{width:oe,height:be}]=gn(),U=s===cn.Vertical,N=U?"top":"left",Y=U?"scrollTop":"scrollLeft",k=U?le:j,E=U?be:oe,[g,Z]=c.useState(null);c.useEffect(()=>{g!==null&&O.current&&O.current.scrollTo({behavior:"smooth",[N]:g})},[g,U]);const q=c.useCallback((Ke,$=!1)=>{if(!O.current)return 0;const _=O.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=$?0:zo(Ke,Ce[N],ue,!0,Math.max(0,Ke-x));return Z(we),Math.max(0,we)},[]),z=c.useCallback((Ke,$=!1)=>{if(!O.current)return 0;const _=O.current.querySelector(".scrollbar-viewport"),Ce=_.getBoundingClientRect(),ue=_.children,we=Math.ceil(E-k),ze=$?we:zo(Ke,Ce[N],ue,!1,Math.max(0,Ke+x));return Z(ze),Math.min(we,ze)},[E,k]),K=c.useRef(null),ee=c.useCallback(Ke=>{K.current=n;const $=Ke.target[Y];u($,r,o),J?.(Ke)},[u,r,o,n]);c.useEffect(()=>{const Ke=K.current;K.current=null,n!==Ke&&(O.current[Y]=n)},[n,Y]);const te=c.useRef(null),X=c.useRef(null),Ve=c.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null,X.current=null)},[]),Be=c.useCallback((Ke,$,_,Ce=h)=>{X.current=Ke,te.current=setTimeout(()=>{const ue=_?q(X.current||Ke):z(X.current||Ke);ue!==X.current?Be(ue,!1,_,y):Ve()},$?0:Ce)},[q,z,Ve]);c.useEffect(()=>()=>Ve(),[Ve]);const We=n,it=c.useMemo(()=>{if(!p)return null;const Ke={orientation:s,disabled:Math.floor(We)<=0||Math.floor(E-k)===0,onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!0)};return R?.(Ke)},[p,s,We,g,E,k]),ve=c.useMemo(()=>{if(!p)return null;const Ke={orientation:s,disabled:Math.floor(E-k)<=Math.ceil(We),onMouseUp:Ve,onMouseLeave:Ve,onMouseDown:()=>Be(We,!0,!1)};return C?.(Ke)},[p,s,We,g,E,k]);return P.jsxs("div",{ref:t,style:{display:"flex",flex:"1",flexDirection:U?"column":"row",padding:"0",...i},className:yn("_sheetxl-scrollbar_eblx4_6",l),...L,children:[it,P.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:U?"column":"row",justifyContent:"center",alignItems:"center"},ref:I,children:P.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:U?"scroll":"hidden",overflowX:U?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:ee,ref:O,children:P.jsx("div",{ref:B,style:{position:"absolute",height:U?o-r+(le??0):1,width:U?1:o-r+(j??0)},className:"scrollbar-viewport"})})}),ve]})}));Uo.displayName="Scrollbar";let vr=Date.now,sn={},Qi=1;const Tn=e=>{let t=sn[e]!==null;return t&&(sn[e]=null),t},Sr=(e,t,n,o=0,r)=>{let i=vr(),l=i,s=0,u=0,d=0,p=Qi++;if(p%20==0){const h={};for(let y in sn)h[y]=!0;sn=h}const x=function(h){let y=h!==!0,R=vr(),C=!0;try{C=(!t||t(p))??!0}catch{C=!1}if(!sn[p]||!C)return sn[p]=null,void n?.(60-u/((R-i)/1e3),p,!1);if(y){d=Math.round((R-l)/16.666666666666668)-1;for(let O=0;O<Math.min(d,4);O++)x(!0),u++}o&&(s=(R-i)/o,s>1&&(s=1));let L=r?r(s):s,J=!1;try{J=e(L,R,y)}catch{J=!1}J!==!1&&s!==1||!y?y&&(l=R,requestAnimationFrame(x)):(sn[p]=null,n?.(60-u/((R-i)/1e3),p,s===1||o==null))};return sn[p]=!0,requestAnimationFrame(x),p},el=function(e){return Math.pow(e-1,3)+1},tl=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)};class nl{constructor(t,n){this.__isSingleTouch=!1,this.__isTracking=!1,this.__didDecelerationComplete=!1,this.__isGesturing=!1,this.__isDragging=!1,this.__isDecelerating=0,this.__isAnimating=0,this.__interruptedAnimation=!1,this.__lastScale=1,this.__enableScrollX=!0,this.__enableScrollY=!0,this.__clientLeft=0,this.__clientTop=0,this.__clientWidth=0,this.__clientHeight=0,this.__contentWidth=0,this.__contentHeight=0,this.__snapWidth=100,this.__snapHeight=100,this.__zoomLevel=1,this.__scrollLeft=0,this.__scrollTop=0,this.__maxScrollLeft=0,this.__maxScrollTop=0,this.__scheduledLeft=0,this.__scheduledTop=0,this.__scheduledZoom=0,this.__lastTouchLeft=0,this.__lastTouchTop=0,this.__lastTouchMove=0,this.__positions=[],this.__initialTouchLeft=0,this.__initialTouchTop=0,this.__zoomLevelStart=1,this.__minDecelerationScrollLeft=null,this.__minDecelerationScrollTop=null,this.__maxDecelerationScrollLeft=null,this.__maxDecelerationScrollTop=null,this.__decelerationVelocityX=null,this.__decelerationVelocityY=0,this.__callback=t,this.options={scrollingX:!0,scrollingY:!0,animating:!0,animationDuration:250,bouncing:!0,locking:!0,paging:!1,snapping:!1,zooming:!1,minZoom:.5,maxZoom:3,speedMultiplier:1,scrollingComplete:void 0,penetrationDeceleration:.03,penetrationAcceleration:.08,...n}}setDimensions(t,n,o,r){t!==null&&(this.__clientWidth=t),n!==null&&(this.__clientHeight=n),o!==null&&(this.__contentWidth=o),r!==null&&(this.__contentHeight=r),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)}setPosition(t,n){this.__clientLeft=t||0,this.__clientTop=n||0}setSnapSize(t,n){this.__snapWidth=t,this.__snapHeight=n}getValues(){return{left:this.__scrollLeft,top:this.__scrollTop,right:this.__scrollLeft+this.__clientWidth/this.__zoomLevel,bottom:this.__scrollTop+this.__clientHeight/this.__zoomLevel,zoom:this.__zoomLevel}}getPoint(t,n){const o=this.getValues();return{left:t/o.zoom,top:n/o.zoom}}getScrollMax(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}}zoomTo(t,n=!1,o,r,i){if(!this.options.zooming)throw new Error("Zooming is not enabled!");i&&(this.__zoomComplete=i),this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0);const l=this.__zoomLevel;o===void 0&&(o=this.__clientWidth/2),r===void 0&&(r=this.__clientHeight/2),t=Math.max(Math.min(t,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(t);const s=t/l;let u=s*(this.__scrollLeft+o)-o,d=s*(this.__scrollTop+r)-r;u>this.__maxScrollLeft?u=this.__maxScrollLeft:u<0&&(u=0),d>this.__maxScrollTop?d=this.__maxScrollTop:d<0&&(d=0),this.__publish(u,d,t,n)}zoomBy(t,n=!1,o=0,r=0,i){this.zoomTo(this.__zoomLevel*t,n,o,r,i)}scrollTo(t,n,o=!1,r=1){if(this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0),r!==void 0&&r!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");t*=r,n*=r,this.__computeScrollMax(r)}else r=this.__zoomLevel;this.options.scrollingX?this.options.paging?t=Math.round(t/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(t=Math.round(t/this.__snapWidth)*this.__snapWidth):t=this.__scrollLeft,this.options.scrollingY?this.options.paging?n=Math.round(n/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(n=Math.round(n/this.__snapHeight)*this.__snapHeight):n=this.__scrollTop,t=Math.max(Math.min(this.__maxScrollLeft,t),0),n=Math.max(Math.min(this.__maxScrollTop,n),0),t===this.__scrollLeft&&n===this.__scrollTop&&(o=!1),this.__publish(t,n,r,o)}scrollBy(t=0,n=0,o=!1){const r=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,i=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(r+(t||0),i+(n||0),o)}doMouseZoom(t,n,o,r){const i=t>0?.97:1.03;return this.zoomTo(this.__zoomLevel*i,!1,o-this.__clientLeft,r-this.__clientTop)}doTouchStart(t,n){if(t.length===void 0)throw new Error("Invalid touch list: "+t);if(n instanceof Date&&(n=n.valueOf()),typeof n!="number")throw new Error("Invalid timestamp value: "+n);let o,r;this.__interruptedAnimation=!0,this.__isDecelerating&&(Tn(this.__isDecelerating),this.__isDecelerating=0,this.__interruptedAnimation=!0),this.__isAnimating&&(Tn(this.__isAnimating),this.__isAnimating=0,this.__interruptedAnimation=!0);let i=t.length===1;i?(o=t[0].pageX,r=t[0].pageY):(o=Math.abs(t[0].pageX+t[1].pageX)/2,r=Math.abs(t[0].pageY+t[1].pageY)/2),this.__initialTouchLeft=o,this.__initialTouchTop=r,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=n,this.__lastScale=1,this.__enableScrollX=!i&&this.options.scrollingX,this.__enableScrollY=!i&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!i,this.__isSingleTouch=i,this.__positions=[]}doTouchMove(t,n,o=1){if(t.length===void 0)throw new Error("Invalid touch list: "+t);if(n instanceof Date&&(n=n.valueOf()),typeof n!="number")throw new Error("Invalid timestamp value: "+n);if(!this.__isTracking)return;let r,i;t.length===2?(r=Math.abs(t[0].pageX+t[1].pageX)/2,i=Math.abs(t[0].pageY+t[1].pageY)/2):(r=t[0].pageX,i=t[0].pageY);let l=this.__positions;if(this.__isDragging){let s=r-this.__lastTouchLeft,u=i-this.__lastTouchTop,d=this.__scrollLeft,p=this.__scrollTop,x=this.__zoomLevel;if(o!==void 0&&this.options.zooming){let h=x;if(x=x/this.__lastScale*o,x=Math.max(Math.min(x,this.options.maxZoom),this.options.minZoom),h!==x){let y=r-this.__clientLeft,R=i-this.__clientTop;d=(y+d)*x/h-y,p=(R+p)*x/h-R,this.__computeScrollMax(x)}}if(this.__enableScrollX){d-=s*this.options.speedMultiplier;let h=this.__maxScrollLeft;(d>h||d<0)&&(this.options.bouncing?d+=s/2*this.options.speedMultiplier:d=d>h?h:0)}if(this.__enableScrollY){p-=u*this.options.speedMultiplier;const h=this.__maxScrollTop;(p>h||p<0)&&(this.options.bouncing?p+=u/2*this.options.speedMultiplier:p=p>h?h:0)}l.length>60&&l.splice(0,30),l.push(d,p,n),this.__publish(d,p,x)}else{let s=this.options.locking?3:0,u=5,d=Math.abs(r-this.__initialTouchLeft),p=Math.abs(i-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&d>=s,this.__enableScrollY=this.options.scrollingY&&p>=s,l.push(this.__scrollLeft,this.__scrollTop,n),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(d>=u||p>=u),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=r,this.__lastTouchTop=i,this.__lastTouchMove=n,this.__lastScale=o}doTouchEnd(t){if(t instanceof Date&&(t=t.valueOf()),typeof t!="number")throw new Error("Invalid timestamp value: "+t);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&t-this.__lastTouchMove<=100){let n=this.__positions,o=n.length-1,r=o;for(let i=o;i>0&&n[i]>this.__lastTouchMove-100;i-=3)r=i;if(r!==o){const i=n[o]-n[r],l=this.__scrollLeft-n[r-2],s=this.__scrollTop-n[r-1];this.__decelerationVelocityX=l/i*(1e3/60),this.__decelerationVelocityY=s/i*(1e3/60);const u=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>u||Math.abs(this.__decelerationVelocityY)>u)&&this.__startDeceleration(t)}else this.options.scrollingComplete?.()}else t-this.__lastTouchMove>100&&this.options.scrollingComplete?.();this.__isDecelerating||((this.__interruptedAnimation||this.__isDragging)&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0,this.__zoomLevel)),this.__positions.length=0}}__publish(t,n,o,r=!1){const i=this.__isAnimating;if(i&&(Tn(i),this.__isAnimating=0),r&&this.options.animating){this.__scheduledLeft=t,this.__scheduledTop=n,this.__scheduledZoom=o;const l=this.__scrollLeft,s=this.__scrollTop,u=this.__zoomLevel,d=t-l,p=n-s,x=o-u,h=function(C,L,J){J&&(this.__scrollLeft=l+d*C,this.__scrollTop=s+p*C,this.__zoomLevel=u+x*C,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),y=function(C){return this.__isAnimating===C}.bind(this),R=function(C,L,J){L===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||J)&&this.options.scrollingComplete?.(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=Sr(h,y,R,this.options.animationDuration,i?el:tl)}else this.__scheduledLeft=this.__scrollLeft=t,this.__scheduledTop=this.__scrollTop=n,this.__scheduledZoom=this.__zoomLevel=o,this.__callback&&this.__callback(t,n,o),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}__computeScrollMax(t=this.__zoomLevel){this.__maxScrollLeft=Math.max(this.__contentWidth*t-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*t-this.__clientHeight,0)}__startDeceleration(t){if(this.options.paging){const l=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),s=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),u=this.__clientWidth,d=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(l/u)*u,this.__minDecelerationScrollTop=Math.floor(s/d)*d,this.__maxDecelerationScrollLeft=Math.ceil(l/u)*u,this.__maxDecelerationScrollTop=Math.ceil(s/d)*d}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;const n=function(l,s,u){this.__stepThroughDeceleration(u)}.bind(this),o=this.options.snapping?4:.1,r=function(){const l=Math.abs(this.__decelerationVelocityX)>=o||Math.abs(this.__decelerationVelocityY)>=o;return l||(this.__didDecelerationComplete=!0),l}.bind(this),i=function(l,s,u){this.__isDecelerating=0,this.__didDecelerationComplete&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=Sr(n,r,i)}__stepThroughDeceleration(t){let n=this.__scrollLeft+this.__decelerationVelocityX,o=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){const r=Math.max(Math.min(this.__maxDecelerationScrollLeft,n),this.__minDecelerationScrollLeft);r!==n&&(n=r,this.__decelerationVelocityX=0);const i=Math.max(Math.min(this.__maxDecelerationScrollTop,o),this.__minDecelerationScrollTop);i!==o&&(o=i,this.__decelerationVelocityY=0)}if(t?this.__publish(n,o,this.__zoomLevel):(this.__scrollLeft=n,this.__scrollTop=o),!this.options.paging&&(this.__decelerationVelocityX*=.95,this.__decelerationVelocityY*=.95),this.options.bouncing){let r=0,i=0,l=this.options.penetrationDeceleration,s=this.options.penetrationAcceleration;n<this.__minDecelerationScrollLeft?r=this.__minDecelerationScrollLeft-n:n>this.__maxDecelerationScrollLeft&&(r=this.__maxDecelerationScrollLeft-n),o<this.__minDecelerationScrollTop?i=this.__minDecelerationScrollTop-o:o>this.__maxDecelerationScrollTop&&(i=this.__maxDecelerationScrollTop-o),r!==0&&(r*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=r*l:this.__decelerationVelocityX=r*s),i!==0&&(i*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=i*l:this.__decelerationVelocityY=i*s)}}}var Nt=typeof window<"u"?window:{screen:{},navigator:{}},En=(Nt.matchMedia||function(){return{matches:!1}}).bind(Nt),li=!1,ol={get passive(){return li=!0}},Er=function(){};Nt.addEventListener&&Nt.addEventListener("p",Er,ol),Nt.removeEventListener&&Nt.removeEventListener("p",Er,!1);var rl=li,il="PointerEvent"in Nt,Ko="ontouchstart"in Nt,si=Ko||"TouchEvent"in Nt&&En("(any-pointer: coarse)").matches,_r=(Nt.navigator.maxTouchPoints||0)>0||si,ci=Nt.navigator.userAgent||"",ll=En("(pointer: coarse)").matches&&/iPad|Macintosh/.test(ci)&&Math.min(Nt.screen.width||0,Nt.screen.height||0)>=768,ai=(En("(pointer: coarse)").matches||!En("(pointer: fine)").matches&&Ko)&&!/Windows.*Firefox/.test(ci),sl=En("(any-pointer: fine)").matches||En("(any-hover: hover)").matches||ll||!Ko,jo=!_r||!sl&&ai?_r?"touchOnly":"mouseOnly":"hybrid",cl=jo==="mouseOnly"?"mouse":jo==="touchOnly"||ai?"touch":"mouse";const al=Object.freeze(Object.defineProperty({__proto__:null,deviceType:jo,primaryInput:cl,supportsPassiveEvents:rl,supportsPointerEvents:il,supportsTouchEvents:si},Symbol.toStringTag,{value:"Module"})),ul=new Set(["INPUT","TEXTAREA","SELECT"]),ui={};function Ao(){return al}const ge=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:ui,boundPixel:function(e,t=!1,n=0){return e},createSyntheticEvent:e=>{let t=!1,n=!1;return{nativeEvent:e,currentTarget:e.currentTarget,target:e.target,bubbles:e.bubbles,cancelable:e.cancelable,defaultPrevented:e.defaultPrevented,eventPhase:e.eventPhase,isTrusted:e.isTrusted,preventDefault:()=>{t=!0,e.preventDefault()},isDefaultPrevented:()=>t,stopPropagation:()=>{n=!0,e.stopPropagation()},isPropagationStopped:()=>n,persist:()=>{},timeStamp:e.timeStamp,type:e.type}},detectIt:Ao,focusableNodeNames:ul,toPrettyKeyCode:e=>e==="BracketLeft"?"[":e==="BracketRight"?"]":St.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),dl=[];function lo(e,t,n=dl){const o=c.useRef(null);return c.useImperativeHandle(e,()=>{if(!o.current)return;const r=o.current,i=t?.();if(!i||typeof i!="object")throw new Error("attributes must return a plain object of values");const l=Object.keys(i),s=l.length;for(let u=0;u<s;u++){const d=l[u],p=i[d];Object.defineProperty(r,d,{value:p,writable:!0,configurable:!0,enumerable:!0})}return r},n),o}const Cr=e=>P.jsx(Uo,{...e}),hl=({width:e,height:t})=>P.jsx("div",{className:"corner",style:{minWidth:`${e}px`,width:`${e}px`,minHeight:`${t}px`,height:`${t}px`}}),di=c.memo(c.forwardRef((e,t)=>{const{children:n,viewport:o,onScrollViewport:r,showHorizontalScrollbar:i=!0,showVerticalScrollbar:l=!0,createScrollCorner:s=hl,createHorizontalScrollbar:u=Cr,createVerticalScrollbar:d=Cr,style:p,touchElement:x,disableTouch:h,...y}=e,R=T(r,[r]),C=lo(t,()=>({isScrollPane:()=>!0}),[]),L=c.useRef(null);c.useEffect(()=>{L.current&&(L.current.__scrollTop===o?.top&&L.current.__scrollLeft===o?.left||L.current.__isDecelerating||L.current?.scrollTo(o?.left,o?.top,!1))},[o?.left,o?.top,x]);const J=c.useCallback((k,E)=>{R?.({left:k,top:E})},[]),O=c.useCallback(k=>{L.current?.doTouchStart(k.touches,k.timeStamp)},[]),I=c.useCallback(k=>{k.preventDefault(),L.current?.doTouchMove(k.touches,k.timeStamp)},[]),j=c.useCallback(k=>{L.current?.doTouchEnd(k.timeStamp)},[]),le=c.useCallback(({containerWidth:k,containerHeight:E,totalWidth:g,totalHeight:Z})=>{L.current.setDimensions(k,E,g,Z)},[]);c.useEffect(()=>{const k=x??C.current;if(!h&&Ao().supportsTouchEvents&&k&&o){if(!L.current){const E={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};L.current=new nl(J,E)}Ao().supportsTouchEvents&&(k.addEventListener("touchstart",O),k.addEventListener("touchend",j),k.addEventListener("touchmove",I)),le({containerWidth:o?.width,containerHeight:o?.height,totalWidth:o?.totalWidth,totalHeight:o?.totalHeight})}return()=>{k?.removeEventListener("touchstart",O),k?.removeEventListener("touchend",j),k?.removeEventListener("touchmove",I)}},[o?.width,o?.height,o?.totalWidth,o?.totalHeight,h,x]);const[B,{width:oe}]=gn(),[be,{height:U}]=gn(),N=c.useMemo(()=>{const k=d({orientation:cn.Vertical,offset:o?.top,viewportSize:o?.height,totalSize:o?.totalHeight,onScrollOffset:E=>{R?.({top:E})}});return P.jsx("div",{style:{display:"flex",flex:"0"},ref:B,children:k})},[d,o?.top,o?.height,o?.totalHeight]),Y=c.useMemo(()=>{const k=u({orientation:cn.Horizontal,offset:o?.left,viewportSize:o?.width,totalSize:o?.totalWidth,onScrollOffset:E=>R?.({left:E})});return P.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[P.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${oe}px)`},children:P.jsx("div",{ref:be,className:"sizer",children:k})}),l?s({width:oe,height:U}):P.jsx(P.Fragment,{})]})},[u,o?.left,o?.width,o?.totalWidth,l,s,oe,U]);return P.jsx("div",{style:{position:"relative",display:"flex",minWidth:l?`${oe}px`:void 0,minHeight:i?`${U}px`:void 0,...p},...y,ref:C,children:P.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[P.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[P.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:n}),l?N:P.jsx(P.Fragment,{})]}),i?Y:P.jsx(P.Fragment,{})]})})}));di.displayName="ScrollPane";const fl=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let Kn=0;function hi(){return c.useEffect(()=>{function e(){const t=document.fullscreenElement;if(!t)return;let n=t.querySelector(".fullscreen-portal-root");n||(n=document.createElement("div"),n.className="fullscreen-portal-root _fullscreen-portal-root_1mjsr_4",t.appendChild(n))}return Kn++,e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),Kn--,Kn<=0&&(document.querySelectorAll(".fullscreen-portal-root").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),Kn=0)}},[]),{getPortalContainer:fl}}const pl=100,gl=100,wl=1e6,ml=100,xl=50,yl=c.memo(c.forwardRef((e,t)=>{const{offset:n=0,viewportSize:o=0,totalSize:r=0,minSize:i=0,endGap:l=pl,endScrollIncrement:s=gl,style:u=ui,onMouseDown:d,onScrollOffset:p,onScroll:x,scaleLimit:h=wl,scaleFactor:y=ml,precisionFactor:R=xl,...C}=e;x&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const L=T(d,[d]),J=()=>({offset:n,totalSize:h===0?r:Math.min(r??0,Math.max(i??0,(n??0)+(o??0))+(l??0))}),[O,I]=c.useState(J),j=h!==0&&O.totalSize>h?y:1,le=j/R,B=Math.ceil(O.totalSize/j),oe=Math.ceil(O.offset/j),be=Math.ceil(o/j),U=c.useCallback(q=>{},[]),[N,Y]=c.useState(!1),k=c.useRef(null);c.useLayoutEffect(()=>{if(!N){k.current={propTotalSize:r,propViewportSize:o,propOffset:n};const q=J();I(q)}},[r,o,n,N,i,l,s]);const E=T((q,z,K)=>{const ee=k.current;k.current=null,ee&&ee.propTotalSize===r&&ee.propViewportSize===o&&ee.propOffset===n||(Math.abs(q-oe)<le&&(q=oe),p?.(q*j,oe,be))},[p,j,le,oe,be]),g=c.useCallback(q=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",g),Y(!1)},[]),Z=c.useCallback(q=>{L?.(q),Y(!0),document.addEventListener("mousemove",U,{passive:!0}),document.addEventListener("mouseup",g,{passive:!0})},[U,g]);return P.jsx(Uo,{ref:t,style:{...u},...C,offset:oe,totalSize:B,viewportSize:be,onMouseDown:Z,onScrollOffset:E})}));function Co(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}yl.displayName="VirtualScrollbar";var oo=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=Co(o,t),i=typeof r=="function";n.push(i?r:()=>Co(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)Co(n,t)}};c.memo(c.forwardRef((e,t)=>{const{refFocusStart:n,...o}=e,r=c.useRef(null),i=c.useCallback(()=>{if(n)return void n?.current?.focus();const l=r.current.parentElement.children;let s=[];for(let u=0;u<l.length&&l[u]!==r.current;u++){const d=l[u].getAttribute("tabindex");if(d==null||d==="-1"||l[u].getAttribute("disabled")==="true")continue;const p=l[u];p.focus&&s.push({tabindex:parseInt(d),child:p})}s.length!==0&&(s.sort(function(u,d){return u.tabindex-d.tabindex}),s[0].child.focus())},[n]);return P.jsx("div",{tabIndex:0,ref:oo([r,t]),onFocus:i,...o})})),c.memo(c.forwardRef((e,t)=>{const{className:n,style:o,children:r,radius:i=4,strokeWidth:l=1,strokeColor:s="grey",...u}=e,[d,{width:p,height:x}]=gn(),h=c.useRef(null),y=(J,O=0)=>{const I=J/2,j=x-I+O;return function(le,B,oe=!1){if(B===0)return le;function be(g,Z,q){let z=Z.x-g.x,K=Z.y-g.y,ee=Math.sqrt(z*z+K*K);return U(g,Z,Math.min(1,q/ee))}function U(g,Z,q){return{x:g.x+(Z.x-g.x)*q,y:g.y+(Z.y-g.y)*q}}function N(g,Z){g.length>2&&(g[g.length-2]=Z.x,g[g.length-1]=Z.y)}function Y(g){return{x:parseFloat(g[g.length-2]),y:parseFloat(g[g.length-1])}}let k=le.split(/[,\s]/).reduce(function(g,Z){let q=Z.match("([a-zA-Z])(.+)");return q?(g.push(q[1]),g.push(q[2])):g.push(Z),g},[]).reduce(function(g,Z){return parseFloat(Z)==Z&&g.length?g[g.length-1].push(Z):g.push([Z]),g},[]),E=[];if(k.length>1){let g=Y(k[0]),Z=null;k[k.length-1][0]==="Z"&&k[0].length>2&&(Z=["L",g.x,g.y],k[k.length-1]=Z),E.push(k[0]);for(let q=1;q<k.length;q++){let z=E[E.length-1],K=k[q],ee=K===Z?k[1]:k[q+1];if(ee&&z&&z.length>2&&K[0]==="L"&&ee.length>2&&ee[0]==="L"){let te,X,Ve=Y(z),Be=Y(K),We=Y(ee);oe?(te=U(Be,z.origPoint||Ve,B),X=U(Be,ee.origPoint||We,B)):(te=be(Be,Ve,B),X=be(Be,We,B)),N(K,te),K.origPoint=Be,E.push(K);let it=U(te,Be,.5),ve=U(Be,X,.5),Ke=["C",it.x,it.y,ve.x,ve.y,X.x,X.y];Ke.origPoint=Be,E.push(Ke)}else E.push(K)}if(Z){let q=Y(E[E.length-1]);E.push(["Z"]),N(E[0],q)}}else E=k;return E.reduce(function(g,Z){return g+Z.join(" ")+" "},"")}(`M 0 ${I} L ${i-.5} ${I} L ${i-.5} ${j} L ${2*i} ${j} L ${p-2*i} ${j} M ${p-2*i} ${j} L ${p-i} ${j} L ${p-i} ${I} L ${p} ${I}`,i)},R=c.useMemo(()=>y(l),[p,x,i,l]),C=c.useMemo(()=>{if(i===0)return;const J=i/2;return y(i)+`L ${p} 0 L 0 0 L 0 ${J}`},[R,i,l]),L=c.useMemo(()=>({style:{clipPath:`path('${C}')`}}),[C]);return P.jsxs("div",{className:n,style:{display:"flex",flexDirection:"row",...o},...u,ref:oo([h,d,t]),children:[c.isValidElement(r)?c.cloneElement(r,L):P.jsx(P.Fragment,{}),P.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:p,height:x,viewBox:`0 0 ${p} ${x}`,children:P.jsx("path",{d:R,stroke:s,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:l})})]})}));const bl={},vl=e=>{const{onPointerDown:t,style:n,splitDirection:o,paddingBefore:r=0,paddingAfter:i=0,disabled:l,key:s,hitAreaProps:u=bl,...d}=e,p=o==="row",{style:x,className:h,...y}=u;return P.jsx("div",{style:{...n,position:"relative"},...d,children:P.jsx("div",{className:yn("hit-box",h),style:{left:(p?-r:0)+"px",width:`calc(100% + ${p?r+i:0}px)`,top:(p?0:-r)+"px",height:`calc(100% + ${p?0:r+i}px)`,position:"absolute",...x},onPointerDown:l?void 0:t,...y})},s)},qn={},hn=(e,t,n=!0)=>e===null?null:e.pixels!==null?n?e.pixels:t-e.pixels:(n?e.percent:100-e.percent)/100*t,Xn=(e,t=!0)=>e?.percent?`${t?e.percent:100-e.percent}%`:e?.pixels?`${e.pixels}px`:void 0,ln=(e,t)=>{if(e==null)return null;const n={percent:null,pixels:null};let o=t;return typeof e=="string"&&((e=e.trim().toLowerCase()).endsWith("px")?(e=e.substring(0,e.length-2),o=!1):e.endsWith("%")&&(e=e.substring(0,e.length-1),o=!0),e=parseFloat(e)),o?n.percent=e:n.pixels=e,Object.freeze(n)};function bn(e){if(!e)throw new Error("must have a PointerHandlerOptions");const{onPointerDown:t,onPointerUp:n,onPointerMoveOrWait:o,processTouch:r=!1,consumeTouch:i=!0}=e,l=T(t,[t]),s=T(n,[n]),u=T(o,[o]),d=c.useRef(!1),p=e?.timerInitial??230,x=e?.timerContinuous??p/2,h=c.useRef(null),y=c.useRef(null),R=c.useRef(null),C=c.useRef(null),L=c.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),J=c.useCallback(N=>{C.current=setTimeout(()=>{window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,R.current,h.current)}),J(x)},N??p)},[]);c.useEffect(()=>()=>L(),[]);const O=r?"pointer":"mouse",I=c.useCallback(N=>{N.stopPropagation(),N.stopImmediatePropagation(),N.preventDefault()},[]),j=T(N=>{document.removeEventListener(`${O}move`,oe),document.removeEventListener(`${O}up`,j),document.removeEventListener("keydown",be),document.removeEventListener("keyup",U),document.removeEventListener("touchstart",I,{capture:!0}),document.removeEventListener("touchmove",I,{capture:!0}),window.removeEventListener("blur",le),L(),window.requestAnimationFrame(()=>{d.current!==!1&&(d.current=!1,s?.(N,R.current,h.current),R.current=null)})},[]),le=c.useCallback(()=>{d.current!==!1&&(d.current=!1,j(y.current))},[]),B=T(()=>{L(),J(x),window.requestAnimationFrame(()=>{d.current!==!1&&u?.(y.current,R.current,h.current)})},[x]),oe=T(N=>{y.current=N,B()},[]),be=T(N=>{R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[]),U=T(N=>{R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},B()},[x]);return T(N=>{N.isDefaultPrevented()||(R.current={ctrlKey:N.ctrlKey,shiftKey:N.shiftKey,altKey:N.altKey,metaKey:N.metaKey},l(N,R.current)!==!1&&(h.current=N,y.current=N.nativeEvent,document.addEventListener(`${O}up`,j,{passive:!1}),document.addEventListener(`${O}move`,oe,{passive:!1}),document.addEventListener("keydown",be,{passive:!1}),document.addEventListener("keyup",U,{passive:!1}),window.addEventListener("blur",le,{passive:!0}),r&&i&&(document.addEventListener("touchstart",I,{passive:!1,capture:!0}),document.addEventListener("touchmove",I,{passive:!1,capture:!0})),d.current=!0,J(p)))},[p,r])}c.memo(c.forwardRef((e,t)=>{const{elementBefore:n,elementAfter:o,splitDirection:r="row",fixedPane:i=null,position:l,onPositionChange:s,minBefore:u,maxBefore:d,minAfter:p,maxAfter:x,children:h,className:y,style:R,disabled:C=!1,onDragStart:L,onDragResize:J,onDragFinish:O,resizerProps:I=qn,paneProps:j=qn,paneBeforeProps:le=qn,paneAfterProps:B=qn,createResizer:oe=vl}=e;if(h)throw new Error("Use elementBefore and elementAfter instead of children.");const be=c.useMemo(()=>c.isValidElement(o)&&c.isValidElement(n),[o,n]),U=c.useMemo(()=>{let Q=null;i&&(i==="before"?Q=0:i==="after"&&(Q=1));const Ze=Q===null;return{fixedPaneOffset:Q,isPercent:Ze,minBefore:ln(u,Ze),maxBefore:ln(d,Ze),minAfter:ln(p,Ze),maxAfter:ln(x,Ze)}},[u,d,p,x]),N=T(s,[s]),[Y,k]=c.useState(()=>ln(l,i===null));c.useEffect(()=>{k(ln(l,i===null))},[l,i]);const[E,{width:g,height:Z}]=gn(),[q,{width:z,height:K}]=gn(),ee=r==="row"?z:K,te=r==="row"?g:Z,X=c.useMemo(()=>((Q,Ze,He,ct)=>{const Ee=[null,null],Te=[null,null];if(Q||(Q={percent:ct.fixedPaneOffset===null?50:null,pixels:ct.fixedPaneOffset===null?null:0}),Ze===0)return Q?.pixels!=null?ct.fixedPaneOffset!==1?(Ee[0]=Q?.pixels,Te[1]=100):(Ee[1]=Q?.pixels-He,Te[0]=100):Q?.percent!=null&&(ct.fixedPaneOffset!==1?(Te[0]=Q?.percent,Te[1]=100-Q?.percent):(Te[1]=Q?.percent,Te[0]=100-Q?.percent)),{percents:Te,pixels:Ee,minBefore:Xn(ct.minBefore,!0),maxBefore:Xn(ct.maxBefore,!0),minAfter:Xn(ct.minAfter),maxAfter:Xn(ct.maxAfter)};let tt=hn(Q,Ze,ct.fixedPaneOffset!==1),Je=Ze-He,Le=hn(ct.minBefore,Je,!0)??0,Gt=hn(ct.maxBefore,Je,!0)??Je,_t=0,Qe=0,Ct=0,Rt=Je;_t=(hn(ct.maxAfter,Ze,!1)??He)-He,Qe=hn(ct.minAfter,Ze,!1)??Ze,Ct=Math.max(Le,_t),Rt=Math.min(Gt,Qe),tt=Math.max(Ct,Math.min(tt,Rt)),Qe=Math.min(Je-tt,hn(ct.maxAfter,Je-tt,!0)??Je),_t=Math.min(Je-tt,hn(ct.minAfter,Je-tt,!0)??Je),Ee[0]=tt,Ee[1]=Je-Ee[0];const on=Math.max(0,Math.min(100,tt/Je*100));return Te[0]=on,Te[1]=100-Te[0],{percents:Te,pixels:Ee,minBefore:`${Le}px`,minAfter:`${_t}px`,maxBefore:`${Ee[0]}px`,maxAfter:`${Ee[1]}px`}})(Y,te,ee,U),[U,Y,te,ee,r]),[Ve,Be]=c.useState(!1),We=T(L,[L]),it=T(J,[J]),ve=T(O,[O]),Ke=c.useRef(null),$=c.useRef(null),_=c.useRef(null),{style:Ce,className:ue,...we}=j,ze={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...Ce},{className:lt,style:It,...st}=le,{className:Ut,style:xt,...M}=B,xe={flex:"1 1 100%",width:"100%",...R,flexDirection:r,display:"flex"},{className:Ye,style:ft,onPointerDown:Ge,...Qt}=I,Yt=T(Q=>{const Ze=ln(Q,i===null);k(Ze)},[i]),Et=T(Q=>{if(C||!Ve)return;const Ze=Oe.current?.getBoundingClientRect();let He=0;He=r==="row"?(Q.clientX??Q.touches?.[0]?.clientX)-Ze.x:(Q.clientY??Q.touches?.[0]?.clientY)-Ze.y,He=Math.max(0,Math.min(te,He)),U.fixedPaneOffset===1&&(He=te-He),l&&Y.pixels===He||k({pixels:He,percent:null}),it?.(He),Q.stopPropagation(),Q.preventDefault()},[U,r,C,Ve,Y,te]),tn=T(Q=>{if(document.removeEventListener("pointermove",Et),document.removeEventListener("touchmove",Et),document.removeEventListener("pointerup",tn),Ve&&(Be(!1),Y)){if(ve(Y.pixels),!ln(l,i===null)||Y.pixels!==l){const Ze={...Y};Ze.percent===null&&(Ze.percent=Ze.pixels/te*100),N(Ze)}Q.stopPropagation(),Q.preventDefault()}},[Y,Ve,l,i,te]),Xt=T(Q=>{Ge?.(Q),Q.defaultPrevented||C||Ve||(Be(!0),We(),document.addEventListener("pointermove",Et,{passive:!1}),document.addEventListener("touchmove",Et,{passive:!1}),document.addEventListener("pointerup",tn,{passive:!1}))},[Ge]),Oe=lo(t,()=>({setPosition:Yt,isSplitPane:()=>!0}),[]),Ft=c.useMemo(()=>be?oe?.({key:"resizer",ref:oo([q,$]),className:yn("resizer",Ye),onPointerDownCapture:Xt,style:{cursor:C?void 0:r==="row"?"ew-resize":"ns-resize",minWidth:r==="row"?"2px":void 0,minHeight:r!=="row"?"2px":void 0,boxSizing:"border-box",pointerEvents:"all",zIndex:1,...ft},splitDirection:r,disabled:C,...Qt}):null,[be,Ye,Qt,r,ft,C]),pt=r==="row"?"Width":"Height",jt={...ze,...It,flex:U.fixedPaneOffset===0&&X?.pixels[0]!==null?`0 0 ${Math.round(X?.pixels[0])}px`:`1 1 ${Math.round(X?.percents[0]??100)}%`,[`min${pt}`]:X?.minBefore,[`max${pt}`]:o?X?.maxBefore:"100%"},wn={...ze,...xt,flex:U.fixedPaneOffset===1&&X?.pixels[1]!==null?`0 0 ${Math.round(X?.pixels[1])}px`:`1 1 ${Math.round(X?.percents[1]??100)}%`,[`min${pt}`]:X?.minAfter,[`max${pt}`]:n?X?.maxAfter:"100%"},nn=c.useMemo(()=>n?P.jsx("div",{ref:Ke,className:yn("before",ue,lt),style:jt,...we,...st,children:n},"before"):null,[n,j,le,U,X]),Fe=c.useMemo(()=>o?P.jsx("div",{ref:_,className:yn("after",ue,Ut),style:wn,...we,...M,children:o},"after"):null,[o,j,B,U,X]);return P.jsxs("div",{ref:oo([E,Oe]),className:yn("splitPane",r==="row"?"vertical":"horizontal",{dragging:Ve},y),style:xe,children:[nn,Ft,Fe]})}));const Sl=({initValue:e,useHookBody:t,applyStateChange:n})=>{const o=c.useRef(e);if(typeof t!="function")throw new Error("function expected as hook body parameter. got "+typeof t);const r=t();return c.useLayoutEffect(()=>{o.current!==r&&(o.current=r,n(r))},[n,r]),null},$o=e=>{console&&console.warn&&console.warn(e)},Io=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||void 0;let El=1,Bo=!1,fi=!1;const Jn=[],vn=[],ro=()=>{vn.forEach(e=>e())},_l=({automaticContainerInternalUseOnly:e})=>{const[t,n]=c.useState([]),o=c.useRef([]);return o.current=t,e||Bo!==!1||(fi=!0),c.useEffect(()=>{let r=!0;function i(){if(r)return vn[0]!==i?(e||Bo!==!0||$o("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."),void n(l=>[])):void n([...Jn])}return vn.push(i),ro(),()=>{r=!1,o.current?.length>0&&$o("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"),vn.splice(vn.indexOf(i),1),ro()}},[e]),P.jsx(P.Fragment,{children:t.map(({hook:r,key:i})=>c.createElement(Sl,{...r,key:i}))})},pi=(e,t,n={})=>{let o,r,i=!1,l=!1,s=[],{unmountIfNoConsumers:u=!1}=n;const d=x=>{r=x,No.unstable_batchedUpdates(()=>s.forEach(h=>h(x)))},p=()=>(l||(r=typeof e=="function"?e():e,l=!0),r);return()=>{const[x,h]=c.useState(p);return c.useEffect(()=>(i||(i=!0,o=(y=>{const R=El++;return Jn.push({hook:y,key:R}),vn.length===0&&fi===!1&&(Bo=!0,(C=>{if(Io.document&&Io.document.createElement){const L=Io.document.createElement("div");Ti.createRoot(L).render(P.jsx(C,{automaticContainerInternalUseOnly:!0}))}else $o("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")})(_l)),ro(),()=>{Jn.splice(Jn.findIndex(C=>C.key===R),1),ro()}})({initValue:e,useHookBody:t,applyStateChange:d})),s.push(h),r!==x&&h(r),()=>{s.splice(s.indexOf(h),1),s.length===0&&u&&(o(),i=!1)}),[]),x}};pi(null,()=>{const[e,t]=c.useState(null);return e});class Cl{constructor(t,n,o,r){this._listenersProperties=new Set,this._listenersExecute=new Set,this._key=t,this._target=n,this._applyProps(o||{}),this._callback=r,r===void 0&&(this._callback=()=>{console.log(`implement: ${this.label()} : ${this.description()}`)})}key(){return this._key}_resolve(t,n){if(typeof t=="function"){const o=n??this._context;return t(typeof o=="function"?o():o)}return t}target(){return typeof this._target=="function"?this._target():this._target}label(t,n){const o=this._scopedLabels?.[t]||this._label;let r=null;if(typeof o=="function"){const i=n??this._context;r=o(typeof i=="function"?i():i)}else r=o;return r}description(t){return this._resolve(this._description,t)}tags(t){return this._resolve(this._tags,t)}icon(t){return this._resolve(this._icon,t)}shortcut(){return this._resolve(this._shortcut)}disabled(){return this._resolve(this._disabled)||!this._callback}state(){return this._resolve(this._state)}context(){return typeof this._context=="function"?this._context():this._context}async execute(t,n){if(!this.disabled()&&this._callback){try{let o=!0;if(n?.beforeExecute&&(o=n?.beforeExecute(this,t)),await Promise.resolve(o)===!1)return!1;const r=this._callback.bind(this)(t,this);if(await Promise.resolve(r)===!1)return!1;n?.onExecute?.(this,t),this._notifyExecute(t)}catch(o){return console.warn(o),n?.onError(this,o,t),this._notifyError(t,o),!1}return!0}}addPropertyListener(t,n=!1){if(!t)throw new Error("listener must be specified");const o=this._listenersProperties;return o.add(t),n&&t({},this),()=>{o.delete(t)}}addExecuteListener(t){if(!t)throw new Error("listener must be specified");const n=this._listenersExecute;return n.add(t),function(){n.delete(t)}}_notifyExecute(t){const n=this;this._listenersExecute.forEach(o=>{o.onExecute(n,t)})}_notifyError(t,n){const o=this;this._listenersExecute.forEach(r=>{r.onError?.(o,t,n)})}updateCallback(t){return this._callback=t||null,this}update(t){if(!t)return;const n=this._applyProps(t);return Object.keys(n).length>0&&this._notifyPropertyChange(n),this}_notifyPropertyChange(t){const n=this;this._listenersProperties.forEach(o=>{o(t,n)})}_applyProps(t){let n={},o=this;return Object.keys(t).forEach(r=>{let i=t[r];o["_"+r]!==i&&(o["_"+r]=n[r]=i)}),n}}class Se extends Cl{}St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),St.getOS()===St.OSType.MacOS||(St.getOS(),St.OSType.IOS),pi({setClipboard:e=>{throw new Error("This is only available via the useClipboard.")},getClipboard:()=>no.Global,refNativeCopy:{current:null},refNativeLastKey:{current:null}},()=>{const[e,t]=c.useState(no.Global);return{setClipboard:n=>t(n),getClipboard:()=>e,refNativeCopy:c.useRef(null),refNativeLastKey:c.useRef(null)}});let Mo=!1,Il=0;var Ml=typeof document<"u"?c.useLayoutEffect:c.useEffect;const Ir=()=>"sheetxl-ui-"+Il++,Rl=c.useId??function(){const[e,t]=c.useState(()=>Mo?Ir():void 0);return Ml(()=>{e==null&&t(Ir())},[]),c.useEffect(()=>{Mo||(Mo=!0)},[]),e},Sn=({itemType:e,index:t,itemSize:n,instanceProps:o,scale:r=1})=>{let i,l,s;e==="column"?(i=o.columnMetadataMap,l=o.lastMeasuredColumnIndex,s=o.recalcColumnIndices):(i=o.rowMetadataMap,l=o.lastMeasuredRowIndex,s=o.recalcRowIndices);const u=s.length>0;if(t>l){let d=0;if(l>=0){const p=i[l];d=p.offset+p.size}for(let p=l+1;p<=t;p++){let x=u?s.includes(p)?n(p)*r:i[p]?.size||n(p)*r:n(p)*r;i[p]={offset:d,size:x},d+=x}e==="column"?o.lastMeasuredColumnIndex=t:o.lastMeasuredRowIndex=t}return i[t],i[t]},Mr=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,offset:r,scale:i})=>{let l,s;e==="column"?(l=o.columnMetadataMap,s=o.lastMeasuredColumnIndex):(l=o.rowMetadataMap,s=o.lastMeasuredRowIndex);let u=0;return u=(s>0?l[s].offset:0)>=r?gi({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):kl({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),u=Math.min(u,n),u},gi=({itemType:e,itemSize:t,instanceProps:n,high:o,low:r,offset:i,scale:l})=>{for(;r<=o;){const s=r+Math.floor((o-r)/2),u=Sn({itemType:e,itemSize:t,index:s,instanceProps:n,scale:l}).offset;if(u===i)return s;u<i?r=s+1:u>i&&(o=s-1)}return r>0?r-1:0},kl=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:r,offset:i,scale:l})=>{let s=1;for(;r<n&&Sn({itemType:e,itemSize:t,index:r,instanceProps:o,scale:l}).offset<i;)r+=s,s*=2;return gi({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},wi=e=>{const{rowCount:t,columnCount:n,defaultRowHeight:o,getRowHeight:r,defaultColumnWidth:i,getColumnWidth:l}=e||{},s=c.useRef({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),u=T(I=>Mr({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:s.current,offset:I}),[t,r,o]),d=T(I=>I===-1?0:Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).offset,[r,o]),p=T(I=>Sn({itemType:"row",index:I,itemSize:r??(()=>o??20),instanceProps:s.current}).size,[r,o]),x=T(I=>Mr({itemType:"column",itemCount:n,itemSize:l??(()=>i??75),instanceProps:s.current,offset:I}),[n,l,i]),h=T(I=>I===-1?0:Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).offset,[l,i]),y=T(I=>Sn({itemType:"column",index:I,itemSize:l??(()=>i??75),instanceProps:s.current}).size,[l,i]),[R,C]=c.useReducer(I=>I+1,0),L=()=>({getRowOffset:d,getColOffset:h,getRowIndex:u,getColIndex:x}),[J,O]=c.useState(()=>e?L():null);return c.useEffect(()=>{O(e?L():null)},[R,t,n,i,o,p,y]),J},qo="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",Rr=e=>{if(!e)return null;if(e.eventType==="start")return{type:e.eventType};if(e.eventType==="submit")return{type:e.eventType};if(e.eventType==="cancel")return{type:e.eventType};if(e.eventType==="keyboard")return{type:e.eventType,key:e.event.key};if(e.eventType==="pointer")return{type:e.eventType};if(e.eventType==="coordsChange"){const t={type:e.eventType};return e.activeCoords&&(t.activeCoords=e.activeCoords),t}return{type:e.eventType??"unknown"}},Tl=e=>!0,Pl=e=>!!e&&!(e.ctrlKey||e.metaKey||e.altKey||e.isComposing)&&(!(e.shiftKey||e.key!=="F2"&&e.key!==" "&&e.key!=="Backspace")||(!e.shiftKey||e.key!==" ")&&qo.indexOf(e.key)!==-1),Ol=e=>!!e&&e.type==="dblclick"&&{editMode:!0},Ll=e=>{const{session:t,refLatestCoords:n,handleSubmitEdit:o,handleCancelEdit:r,cellBounds:i,isInBounds:l,getCellEditor:s,propsEditor:u,borderStrokeFill:d="rgb(33, 115, 70)",borderStrokeWidth:p=2,alignment:x=On.Left,style:h,...y}=e,R=c.useRef(null),C=c.useRef(null),[L,J]=c.useState(!1),O=t.coords,I=c.useCallback(async Y=>{if(R.current?.getBoundingClientRect()){if(Y.eventType==="keyboard"){const E=Y.event,g=new KeyboardEvent(E.type,{bubbles:!0,cancelable:!0,view:window,key:E.key,code:E.code,location:E.location,repeat:E.repeat,isComposing:E.isComposing,charCode:E.charCode,keyCode:E.keyCode,which:E.which,ctrlKey:E.ctrlKey,shiftKey:E.shiftKey,altKey:E.altKey,metaKey:E.metaKey});g.isSynthetic=!0,g.key,C.current?.dispatchEvent(g)}else Y.eventType==="pointer"||console.warn("unsupported event type",Y);await new Promise(E=>requestAnimationFrame(E))}},[]);c.useEffect(()=>{const Y=C.current;return J(!0),C.current.startEdit?.(t.startEvent),(async()=>{t.editorRefs.push(Y),t.editorRefsDispatchEditorEvent.push(I);const k=[...t.events];for(let E=0;E<k.length;E++)await I(k[E]);t.onMount(Y)})(),()=>{const k=t.editorRefs.indexOf(Y);k!==-1&&t.editorRefs.splice(k,1),t.onUnmount(Y)}},[]);const j=c.useCallback(()=>o(t),[]),le=c.useCallback(()=>{r(t)},[]),B=n.current&&G.isEqualCells(n.current,O),oe=l&&B&&L,be=s({autoFocus:!!t.startEvent?.autoFocus,...u,onSubmitEdit:j,onCancelEdit:le,ref:C},O),U=i.x+ge.boundPixel(-p/2),N=ge.boundPixel(i.width+p/2,!0);return P.jsx("div",{tabIndex:0,ref:R,style:{background:void 0,...h,opacity:oe?h?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${i.y+ge.boundPixel(-p/2)}px`,height:ge.boundPixel(i.height+p/2,!0),left:`${U}px`,width:N},...y,children:P.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${ge.boundPixel(1)}px`,top:`${ge.boundPixel(1)}px`,width:ge.boundPixel(i.width-2,!0),height:ge.boundPixel(i.height-2,!0),outline:`${p}px ${d} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:be})})},Ue=(e,t,n)=>{if(!e)return t;let o=t;const r=n===Ne||n===ot;for(;;){const i=e(o,!r);if(i===0)return o;r?o+=i:o-=i}},Yn=(e,t,n)=>{const o=[];let r=t;for(;r<=n;){const i=Math.max(0,e(r));i===0?(o.push(r),r++):r+=i}return o},Dl=(e,t,n,o,r,i)=>{if(!t)return i;let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ue(n,Math.min(l+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t({rowIndex:l,colIndex:s});return l}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t({rowIndex:l,colIndex:s});return l}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t({rowIndex:l,colIndex:s});return s}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t({rowIndex:l,colIndex:s});for(;!u&&s>i;)s=Ue(n,Math.max(--s,i),o),u=t({rowIndex:l,colIndex:s});return s}default:return i}},zl=(e,t=()=>!0,n,o,r,i)=>{let{rowIndex:l,colIndex:s}=e;switch(o){case ot:{l=Ue(n,Math.min(l+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l<i;)l=Ue(n,Math.min(++l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case nt:{l=Ue(n,Math.max(l-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&l>i;)l=Ue(n,Math.max(--l,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case Ne:{s=Ue(n,Math.min(s+1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s<i;)s=Ue(n,Math.min(++s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case et:{s=Ue(n,Math.max(s-1,i),o);let u=t?.({rowIndex:l,colIndex:s});for(;u&&s>i;)s=Ue(n,Math.max(--s,i),o),u=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s+1}default:return null}},jl=(e,t,n,o,r,i)=>{if(!t)return i;let l,{rowIndex:s,colIndex:u}=e;o===ot?l={rowIndex:s+1,colIndex:u}:o===nt?l={rowIndex:s-1,colIndex:u}:o===Ne?l={rowIndex:s,colIndex:u+1}:o===et&&(l={rowIndex:s,colIndex:u-1});const d=t(e),p=t(l);var x,h;return(h=p,!(x=d)&&!h||!x&&h||x&&!h?Dl:zl)(e,t,n,o,!1,i)??i},kr=(e,t)=>`${e}:${t}`,Tr=(e,t,n,o,r,i)=>{if(n-t>=r-o)return o;let l=o;return e==="nearest"&&(o-t>0?e="start":n-r>0&&(e="end")),e==="start"?l=t:e==="end"?l=n-(r-o):e==="center"&&(l=t+(n-t)/2-(r-o)/2),Math.max(0,Math.min(l,i-(r-o)))},Pr=(e,t,n,o)=>(console.log("todo: implement convertToVisibleRanges"),e),Fo=(e,t=Ne,n,o,r,i=null)=>{if(i&&G.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!G.isRangesIntersect({rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},l))return e;let s={...e.cell},u=e.rangeIndex;switch(t){case Ne:s.colIndex=Ue(r,s.colIndex+1,t);break;case et:s.colIndex=Ue(r,s.colIndex-1,t);break;case ot:s.rowIndex=Ue(o,s.rowIndex+1,t);break;case nt:s.rowIndex=Ue(o,s.rowIndex-1,t)}const d=h=>{if(h){u=e.rangeIndex>=e.ranges.length-1?0:e.rangeIndex+1;const y=e.ranges[u];s={colIndex:y.colStart,rowIndex:y.rowStart}}else{u=e.rangeIndex<=0?e.ranges.length-1:e.rangeIndex-1;const y=e.ranges[u];s={colIndex:y.colEnd,rowIndex:y.rowEnd}}};if(t===Ne&&s.colIndex>l.colEnd&&s.rowIndex===l.rowEnd)d(!0);else if(t===et&&s.colIndex<l.colStart&&s.rowIndex===l.rowStart)d(!1);else if(t===ot&&s.colIndex===l.colEnd&&s.rowIndex>l.rowEnd)d(!0);else if(t===nt&&s.colIndex===l.colStart&&s.rowIndex<l.rowStart)d(!1);else{let h=s.rowIndex,y=s.colIndex;switch(t){case Ne:y>l.colEnd&&(h=Ue(o,h+1,t),y=l.colStart,h>l.rowEnd&&(h=l.rowStart));break;case et:y<l.colStart&&(h=Ue(o,h-1,t),y=l.colEnd,h<l.rowStart&&(h=l.rowEnd));break;case ot:h>l.rowEnd&&(y=Ue(r,y+1,t),h=l.rowStart,y>l.colEnd&&(y=l.colStart));break;case nt:h<l.rowStart&&(y=Ue(r,y-1,t),h=l.rowEnd,y<l.colStart&&(y=l.colEnd))}s={rowIndex:h,colIndex:y}}let p=n(s);if(!G.isRangeWithinRange(p,l)){const h=G.intersectRanges(p,l);h&&(p=h)}let x={rowStart:Ue(o,p.rowStart,ot),colStart:Ue(r,p.colStart,Ne),rowEnd:Ue(o,p.rowEnd,nt),colEnd:Ue(r,p.colEnd,et)};if(x.rowStart!==s.rowIndex||x.colStart!==s.colIndex){switch(t){case Ne:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowEnd),s.colIndex=x.colEnd;break;case et:e.ranges[u].colStart===x.colStart&&e.ranges[u].colEnd===x.colEnd&&(s.rowIndex=x.rowStart),s.rowIndex===x.rowStart?s.colIndex=x.colStart+1:s.colIndex=x.colStart;break;case ot:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colEnd),s.rowIndex=x.rowEnd;break;case nt:e.ranges[u].rowStart===x.rowStart&&e.ranges[u].rowEnd===x.rowEnd&&(s.colIndex=x.colStart),s.colIndex===x.colStart?s.rowIndex=x.rowStart+1:s.rowIndex=x.rowStart}return Fo({cell:s,ranges:e.ranges,rangeIndex:u},t,n,o,r,i??e)}return{ranges:e.ranges,cell:s,rangeIndex:u}},Or=(e,t)=>{let n,o=0,r=0;return t.colStart<e.colStart?(n=et,o=e.colStart-t.colStart,r=t.colStart):t.colEnd>e.colEnd?(n=Ne,o=t.colEnd-e.colEnd,r=t.colEnd):t.rowStart<e.rowStart?(n=nt,o=e.rowStart-t.rowStart,r=t.rowStart):t.rowEnd>e.rowEnd&&(n=ot,o=t.rowEnd-e.rowEnd,r=t.rowEnd),{direction:n,amount:o,index:r}},io=(e,t=!1,n,o)=>{if(!n)return 0;const r=!t,i=r?1:-1;let l=n(r?e:e+1),s=n(r?e+1:e),u=e+(r?2:-1),d=0;for(;(s-l)*i<=0;){if(r&&u-1>o+1||!r&&u+1<o)return d;l=s,s=n(u),u+=i,d++}return d},Lr=(e,t,n,o,r)=>{const i={};let l=null,s=null;for(let u=0;u<=n.length&&n[u]<=r;u++){const d=n[u];if(d<o)continue;const p=l===d?s:t?e.getColOffset(d):e.getRowOffset(d),x=t?e.getColOffset(d+1):e.getRowOffset(d+1);l=d+1,s=x,i[d]=Object.freeze({offset:p,size:x-p,spanIndex:u})}return Object.freeze(i)},Dr=(e,t,n)=>{const o=e.getColOffset(t.colStart)+(n?.left??0),r=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:o,y:r,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-o,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-r}},Al=(e,t,n)=>!!n&&!(e<n.x||e>n.x+n.width)&&!(t<n.y||t>n.y+n.height),Ro=(e,t=!0)=>`M ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.top)} L ${ge.boundPixel(e.right,!0)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.bottom,!0)} L ${ge.boundPixel(e.left)} ${ge.boundPixel(e.top)} ${t?"Z":""}`,Vo=e=>{const{linePoints:t,bounds:n,pathProps:o,style:r,...i}=e;return P.jsx("svg",{width:`${ge.boundPixel(n.width,!0)}`,height:`${ge.boundPixel(n.height,!0)}`,viewBox:`0 0 ${ge.boundPixel(n.width,!0)} ${ge.boundPixel(n.height,!0)}`,style:{position:"absolute",left:`${ge.boundPixel(n.x)}px`,top:`${ge.boundPixel(n.y)}px`,width:`${ge.boundPixel(n.width,!0)}px`,height:`${ge.boundPixel(n.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...r},...i,children:P.jsx("path",{d:`M ${ge.boundPixel(t[0])} ${ge.boundPixel(t[1])} L ${ge.boundPixel(t[2])} ${ge.boundPixel(t[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...o})})},mi=e=>{const{x:t=0,y:n=0,width:o=0,height:r=0,fill:i,stroke:l,strokeWidth:s=0,strokeDasharray:u,strokeDashoffset:d,clipPath:p,pathBounds:x,pathProps:h,style:y,...R}=e,C=n,L=t,J=o,O=r;let I=null;if(i){let j=Ro({top:0,left:0,bottom:O,right:J});x&&(j=j+" "+Ro({top:x.y-C,left:x.x-L,bottom:x.height+x.y-C,right:x.width+x.x-L})),I=[P.jsx("path",{d:j,fill:i,stroke:"none",fillRule:"evenodd"},"fill")]}return P.jsxs("svg",{width:`${ge.boundPixel(o,!0)}`,height:`${ge.boundPixel(r,!0)}`,viewBox:`0 0 ${ge.boundPixel(o,!0)} ${ge.boundPixel(r,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${ge.boundPixel(t)}px`,top:`${ge.boundPixel(n)}px`,pointerEvents:"none",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",boxShadow:"rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px",overflow:"visible",...y},...R,children:[I,P.jsx("path",{d:Ro({top:0,left:0,right:J,bottom:O}),fill:"none",strokeDasharray:u,strokeDashoffset:d,stroke:l,vectorEffect:"non-scaling-stroke",strokeWidth:s,...h})]})},zr=e=>{const{key:t,...n}=e;return P.jsx(Xo,{...n},t)},Xo=c.memo(e=>{const{stroke:t,fill:n,x:o=0,y:r=0,width:i=0,height:l=0,style:s,isAnimatedStroke:u,animatedStrokeProps:d,range:p,cell:x,...h}=e,y=u||!!d,R={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let C=R.dashGap+R.dashLength;const L=R.speed*C,J=Rl().replaceAll(":",""),O=`${R.name}-${J}`;let I;return c.useEffect(()=>{if(!y)return;const j=`@keyframes ${O} {
7
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("react/jsx-runtime"),o=require("@sheetxl/utils-react"),l=require("react"),n=require("@sheetxl/utils"),Zo=require("react-dom"),Yt=({itemType:t,index:r,itemSize:i,instanceProps:c,scale:d=1})=>{let h,a,s;t==="column"?(h=c.columnMetadataMap,a=c.lastMeasuredColumnIndex,s=c.recalcColumnIndices):(h=c.rowMetadataMap,a=c.lastMeasuredRowIndex,s=c.recalcRowIndices);const w=s.length>0;if(r>a){let P=0;if(a>=0){const z=h[a];P=z.offset+z.size}for(let z=a+1;z<=r;z++){let M=w?s.includes(z)?i(z)*d:h[z]?.size||i(z)*d:i(z)*d;h[z]={offset:P,size:M},P+=M}t==="column"?c.lastMeasuredColumnIndex=r:c.lastMeasuredRowIndex=r}return h[r],h[r]},Bo=({itemType:t,itemSize:r,itemCount:i,instanceProps:c,offset:d,scale:h})=>{let a,s;t==="column"?(a=c.columnMetadataMap,s=c.lastMeasuredColumnIndex):(a=c.rowMetadataMap,s=c.lastMeasuredRowIndex);let w=0;return w=(s>0?a[s].offset:0)>=d?Jo({itemType:t,itemSize:r,instanceProps:c,high:s,low:0,offset:d,scale:h}):gn({itemType:t,itemSize:r,itemCount:i,instanceProps:c,index:Math.max(0,s),offset:d,scale:h}),w=Math.min(w,i),w},Jo=({itemType:t,itemSize:r,instanceProps:i,high:c,low:d,offset:h,scale:a})=>{for(;d<=c;){const s=d+Math.floor((c-d)/2),w=Yt({itemType:t,itemSize:r,index:s,instanceProps:i,scale:a}).offset;if(w===h)return s;w<h?d=s+1:w>h&&(c=s-1)}return d>0?d-1:0},gn=({itemType:t,itemSize:r,itemCount:i,instanceProps:c,index:d,offset:h,scale:a})=>{let s=1;for(;d<i&&Yt({itemType:t,itemSize:r,index:d,instanceProps:c,scale:a}).offset<h;)d+=s,s*=2;return Jo({itemType:t,itemSize:r,instanceProps:c,high:Math.min(d,i-1),low:Math.floor(d/2),offset:h,scale:a})},Qo=t=>{const{rowCount:r,columnCount:i,defaultRowHeight:c,getRowHeight:d,defaultColumnWidth:h,getColumnWidth:a}=t||{},s=l.useRef({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),w=o.useCallbackRef(U=>Bo({itemType:"row",itemCount:r,itemSize:d??(()=>c??20),instanceProps:s.current,offset:U}),[r,d,c]),P=o.useCallbackRef(U=>U===-1?0:Yt({itemType:"row",index:U,itemSize:d??(()=>c??20),instanceProps:s.current}).offset,[d,c]),z=o.useCallbackRef(U=>Yt({itemType:"row",index:U,itemSize:d??(()=>c??20),instanceProps:s.current}).size,[d,c]),M=o.useCallbackRef(U=>Bo({itemType:"column",itemCount:i,itemSize:a??(()=>h??75),instanceProps:s.current,offset:U}),[i,a,h]),T=o.useCallbackRef(U=>U===-1?0:Yt({itemType:"column",index:U,itemSize:a??(()=>h??75),instanceProps:s.current}).offset,[a,h]),O=o.useCallbackRef(U=>Yt({itemType:"column",index:U,itemSize:a??(()=>h??75),instanceProps:s.current}).size,[a,h]),[ie,Z]=l.useReducer(U=>U+1,0),oe=()=>({getRowOffset:P,getColOffset:T,getRowIndex:w,getColIndex:M}),[Pe,Q]=l.useState(()=>t?oe():null);return l.useEffect(()=>{Q(t?oe():null)},[ie,r,i,h,c,z,O]),Pe},Lo="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",Ko=t=>{if(!t)return null;if(t.eventType==="start")return{type:t.eventType};if(t.eventType==="submit")return{type:t.eventType};if(t.eventType==="cancel")return{type:t.eventType};if(t.eventType==="keyboard")return{type:t.eventType,key:t.event.key};if(t.eventType==="pointer")return{type:t.eventType};if(t.eventType==="coordsChange"){const r={type:t.eventType};return t.activeCoords&&(r.activeCoords=t.activeCoords),r}return{type:t.eventType??"unknown"}},wn=t=>!0,xn=t=>!!t&&!(t.ctrlKey||t.metaKey||t.altKey||t.isComposing)&&(!(t.shiftKey||t.key!=="F2"&&t.key!==" "&&t.key!=="Backspace")||(!t.shiftKey||t.key!==" ")&&Lo.indexOf(t.key)!==-1),pn=t=>!!t&&t.type==="dblclick"&&{editMode:!0},mn=t=>{const{session:r,refLatestCoords:i,handleSubmitEdit:c,handleCancelEdit:d,cellBounds:h,isInBounds:a,getCellEditor:s,propsEditor:w,borderStrokeFill:P="rgb(33, 115, 70)",borderStrokeWidth:z=2,alignment:M=o.HorizontalAlignment.Left,style:T,...O}=t,ie=l.useRef(null),Z=l.useRef(null),[oe,Pe]=l.useState(!1),Q=r.coords,U=l.useCallback(async ae=>{if(ie.current?.getBoundingClientRect()){if(ae.eventType==="keyboard"){const L=ae.event,C=new KeyboardEvent(L.type,{bubbles:!0,cancelable:!0,view:window,key:L.key,code:L.code,location:L.location,repeat:L.repeat,isComposing:L.isComposing,charCode:L.charCode,keyCode:L.keyCode,which:L.which,ctrlKey:L.ctrlKey,shiftKey:L.shiftKey,altKey:L.altKey,metaKey:L.metaKey});C.isSynthetic=!0,C.key,Z.current?.dispatchEvent(C)}else ae.eventType==="pointer"||console.warn("unsupported event type",ae);await new Promise(L=>requestAnimationFrame(L))}},[]);l.useEffect(()=>{const ae=Z.current;return Pe(!0),Z.current.startEdit?.(r.startEvent),(async()=>{r.editorRefs.push(ae),r.editorRefsDispatchEditorEvent.push(U);const Ce=[...r.events];for(let L=0;L<Ce.length;L++)await U(Ce[L]);r.onMount(ae)})(),()=>{const Ce=r.editorRefs.indexOf(ae);Ce!==-1&&r.editorRefs.splice(Ce,1),r.onUnmount(ae)}},[]);const _=l.useCallback(()=>c(r),[]),xe=l.useCallback(()=>{d(r)},[]),$=i.current&&n.CoordUtils.isEqualCells(i.current,Q),ge=a&&$&&oe,Le=s({autoFocus:!!r.startEvent?.autoFocus,...w,onSubmitEdit:_,onCancelEdit:xe,ref:Z},Q),Ie=h.x+o.ReactUtils.boundPixel(-z/2),Oe=o.ReactUtils.boundPixel(h.width+z/2,!0);return te.jsx("div",{tabIndex:0,ref:ie,style:{background:void 0,...T,opacity:ge?T?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${h.y+o.ReactUtils.boundPixel(-z/2)}px`,height:o.ReactUtils.boundPixel(h.height+z/2,!0),left:`${Ie}px`,width:Oe},...O,children:te.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${o.ReactUtils.boundPixel(1)}px`,top:`${o.ReactUtils.boundPixel(1)}px`,width:o.ReactUtils.boundPixel(h.width-2,!0),height:o.ReactUtils.boundPixel(h.height-2,!0),outline:`${z}px ${P} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:Le})})},Te=(t,r,i)=>{if(!t)return r;let c=r;const d=i===n.Direction.Right||i===n.Direction.Down;for(;;){const h=t(c,!d);if(h===0)return c;d?c+=h:c-=h}},uo=(t,r,i)=>{const c=[];let d=r;for(;d<=i;){const h=Math.max(0,t(d));h===0?(c.push(d),d++):d+=h}return c},Cn=(t,r,i,c,d,h)=>{if(!r)return h;let{rowIndex:a,colIndex:s}=t;switch(c){case n.Direction.Down:{a=Te(i,Math.min(a+1,h),c);let w=r({rowIndex:a,colIndex:s});for(;!w&&a<h;)a=Te(i,Math.min(++a,h),c),w=r({rowIndex:a,colIndex:s});return a}case n.Direction.Up:{a=Te(i,Math.max(a-1,h),c);let w=r({rowIndex:a,colIndex:s});for(;!w&&a>h;)a=Te(i,Math.max(--a,h),c),w=r({rowIndex:a,colIndex:s});return a}case n.Direction.Right:{s=Te(i,Math.min(s+1,h),c);let w=r({rowIndex:a,colIndex:s});for(;!w&&s<h;)s=Te(i,Math.min(++s,h),c),w=r({rowIndex:a,colIndex:s});return s}case n.Direction.Left:{s=Te(i,Math.max(s-1,h),c);let w=r({rowIndex:a,colIndex:s});for(;!w&&s>h;)s=Te(i,Math.max(--s,h),c),w=r({rowIndex:a,colIndex:s});return s}default:return h}},Sn=(t,r=()=>!0,i,c,d,h)=>{let{rowIndex:a,colIndex:s}=t;switch(c){case n.Direction.Down:{a=Te(i,Math.min(a+1,h),c);let w=r?.({rowIndex:a,colIndex:s});for(;w&&a<h;)a=Te(i,Math.min(++a,h),c),w=r?.({rowIndex:a,colIndex:s});return r?.({rowIndex:a,colIndex:s})?a:a-1}case n.Direction.Up:{a=Te(i,Math.max(a-1,h),c);let w=r?.({rowIndex:a,colIndex:s});for(;w&&a>h;)a=Te(i,Math.max(--a,h),c),w=r?.({rowIndex:a,colIndex:s});return r?.({rowIndex:a,colIndex:s})?a:a+1}case n.Direction.Right:{s=Te(i,Math.min(s+1,h),c);let w=r?.({rowIndex:a,colIndex:s});for(;w&&s<h;)s=Te(i,Math.min(++s,h),c),w=r?.({rowIndex:a,colIndex:s});return r?.({rowIndex:a,colIndex:s})?s:s-1}case n.Direction.Left:{s=Te(i,Math.max(s-1,h),c);let w=r?.({rowIndex:a,colIndex:s});for(;w&&s>h;)s=Te(i,Math.max(--s,h),c),w=r?.({rowIndex:a,colIndex:s});return r?.({rowIndex:a,colIndex:s})?s:s+1}default:return null}},bn=(t,r,i,c,d,h)=>{if(!r)return h;let a,{rowIndex:s,colIndex:w}=t;c===n.Direction.Down?a={rowIndex:s+1,colIndex:w}:c===n.Direction.Up?a={rowIndex:s-1,colIndex:w}:c===n.Direction.Right?a={rowIndex:s,colIndex:w+1}:c===n.Direction.Left&&(a={rowIndex:s,colIndex:w-1});const P=r(t),z=r(a);var M,T;return(T=z,!(M=P)&&!T||!M&&T||M&&!T?Cn:Sn)(t,r,i,c,!1,h)??h},Fo=(t,r)=>`${t}:${r}`,Wo=(t,r,i,c,d,h)=>{if(i-r>=d-c)return c;let a=c;return t==="nearest"&&(c-r>0?t="start":i-d>0&&(t="end")),t==="start"?a=r:t==="end"?a=i-(d-c):t==="center"&&(a=r+(i-r)/2-(d-c)/2),Math.max(0,Math.min(a,h-(d-c)))},Vo=(t,r,i,c)=>(console.log("todo: implement convertToVisibleRanges"),t),Do=(t,r=n.Direction.Right,i,c,d,h=null)=>{if(h&&n.CoordUtils.isEqualSelectionCoords(h,t))return t;const a=t.ranges[t.rangeIndex];if(!n.CoordUtils.isRangesIntersect({rowStart:t.cell.rowIndex,colStart:t.cell.colIndex,rowEnd:t.cell.rowIndex,colEnd:t.cell.colIndex},a))return t;let s={...t.cell},w=t.rangeIndex;switch(r){case n.Direction.Right:s.colIndex=Te(d,s.colIndex+1,r);break;case n.Direction.Left:s.colIndex=Te(d,s.colIndex-1,r);break;case n.Direction.Down:s.rowIndex=Te(c,s.rowIndex+1,r);break;case n.Direction.Up:s.rowIndex=Te(c,s.rowIndex-1,r)}const P=T=>{if(T){w=t.rangeIndex>=t.ranges.length-1?0:t.rangeIndex+1;const O=t.ranges[w];s={colIndex:O.colStart,rowIndex:O.rowStart}}else{w=t.rangeIndex<=0?t.ranges.length-1:t.rangeIndex-1;const O=t.ranges[w];s={colIndex:O.colEnd,rowIndex:O.rowEnd}}};if(r===n.Direction.Right&&s.colIndex>a.colEnd&&s.rowIndex===a.rowEnd)P(!0);else if(r===n.Direction.Left&&s.colIndex<a.colStart&&s.rowIndex===a.rowStart)P(!1);else if(r===n.Direction.Down&&s.colIndex===a.colEnd&&s.rowIndex>a.rowEnd)P(!0);else if(r===n.Direction.Up&&s.colIndex===a.colStart&&s.rowIndex<a.rowStart)P(!1);else{let T=s.rowIndex,O=s.colIndex;switch(r){case n.Direction.Right:O>a.colEnd&&(T=Te(c,T+1,r),O=a.colStart,T>a.rowEnd&&(T=a.rowStart));break;case n.Direction.Left:O<a.colStart&&(T=Te(c,T-1,r),O=a.colEnd,T<a.rowStart&&(T=a.rowEnd));break;case n.Direction.Down:T>a.rowEnd&&(O=Te(d,O+1,r),T=a.rowStart,O>a.colEnd&&(O=a.colStart));break;case n.Direction.Up:T<a.rowStart&&(O=Te(d,O-1,r),T=a.rowEnd,O<a.colStart&&(O=a.colEnd))}s={rowIndex:T,colIndex:O}}let z=i(s);if(!n.CoordUtils.isRangeWithinRange(z,a)){const T=n.CoordUtils.intersectRanges(z,a);T&&(z=T)}let M={rowStart:Te(c,z.rowStart,n.Direction.Down),colStart:Te(d,z.colStart,n.Direction.Right),rowEnd:Te(c,z.rowEnd,n.Direction.Up),colEnd:Te(d,z.colEnd,n.Direction.Left)};if(M.rowStart!==s.rowIndex||M.colStart!==s.colIndex){switch(r){case n.Direction.Right:t.ranges[w].colStart===M.colStart&&t.ranges[w].colEnd===M.colEnd&&(s.rowIndex=M.rowEnd),s.colIndex=M.colEnd;break;case n.Direction.Left:t.ranges[w].colStart===M.colStart&&t.ranges[w].colEnd===M.colEnd&&(s.rowIndex=M.rowStart),s.rowIndex===M.rowStart?s.colIndex=M.colStart+1:s.colIndex=M.colStart;break;case n.Direction.Down:t.ranges[w].rowStart===M.rowStart&&t.ranges[w].rowEnd===M.rowEnd&&(s.colIndex=M.colEnd),s.rowIndex=M.rowEnd;break;case n.Direction.Up:t.ranges[w].rowStart===M.rowStart&&t.ranges[w].rowEnd===M.rowEnd&&(s.colIndex=M.colStart),s.colIndex===M.colStart?s.rowIndex=M.rowStart+1:s.rowIndex=M.rowStart}return Do({cell:s,ranges:t.ranges,rangeIndex:w},r,i,c,d,h??t)}return{ranges:t.ranges,cell:s,rangeIndex:w}},Ho=(t,r)=>{let i,c=0,d=0;return r.colStart<t.colStart?(i=n.Direction.Left,c=t.colStart-r.colStart,d=r.colStart):r.colEnd>t.colEnd?(i=n.Direction.Right,c=r.colEnd-t.colEnd,d=r.colEnd):r.rowStart<t.rowStart?(i=n.Direction.Up,c=t.rowStart-r.rowStart,d=r.rowStart):r.rowEnd>t.rowEnd&&(i=n.Direction.Down,c=r.rowEnd-t.rowEnd,d=r.rowEnd),{direction:i,amount:c,index:d}},wo=(t,r=!1,i,c)=>{if(!i)return 0;const d=!r,h=d?1:-1;let a=i(d?t:t+1),s=i(d?t+1:t),w=t+(d?2:-1),P=0;for(;(s-a)*h<=0;){if(d&&w-1>c+1||!d&&w+1<c)return P;a=s,s=i(w),w+=h,P++}return P},jo=(t,r,i,c,d)=>{const h={};let a=null,s=null;for(let w=0;w<=i.length&&i[w]<=d;w++){const P=i[w];if(P<c)continue;const z=a===P?s:r?t.getColOffset(P):t.getRowOffset(P),M=r?t.getColOffset(P+1):t.getRowOffset(P+1);a=P+1,s=M,h[P]=Object.freeze({offset:z,size:M-z,spanIndex:w})}return Object.freeze(h)},No=(t,r,i)=>{const c=t.getColOffset(r.colStart)+(i?.left??0),d=t.getRowOffset(r.rowStart)+(i?.top??0);return{x:c,y:d,width:t.getColOffset(r.colEnd+1)+(i?.right??0)-(i?.left??0)-c,height:t.getRowOffset(r.rowEnd+1)+(i?.bottom??0)-(i?.top??0)-d}},yn=(t,r,i)=>!!i&&!(t<i.x||t>i.x+i.width)&&!(r<i.y||r>i.y+i.height),Io=(t,r=!0)=>`M ${o.ReactUtils.boundPixel(t.left)} ${o.ReactUtils.boundPixel(t.top)} L ${o.ReactUtils.boundPixel(t.right,!0)} ${o.ReactUtils.boundPixel(t.top)} L ${o.ReactUtils.boundPixel(t.right,!0)} ${o.ReactUtils.boundPixel(t.bottom,!0)} L ${o.ReactUtils.boundPixel(t.left)} ${o.ReactUtils.boundPixel(t.bottom,!0)} L ${o.ReactUtils.boundPixel(t.left)} ${o.ReactUtils.boundPixel(t.top)} ${r?"Z":""}`,Po=t=>{const{linePoints:r,bounds:i,pathProps:c,style:d,...h}=t;return te.jsx("svg",{width:`${o.ReactUtils.boundPixel(i.width,!0)}`,height:`${o.ReactUtils.boundPixel(i.height,!0)}`,viewBox:`0 0 ${o.ReactUtils.boundPixel(i.width,!0)} ${o.ReactUtils.boundPixel(i.height,!0)}`,style:{position:"absolute",left:`${o.ReactUtils.boundPixel(i.x)}px`,top:`${o.ReactUtils.boundPixel(i.y)}px`,width:`${o.ReactUtils.boundPixel(i.width,!0)}px`,height:`${o.ReactUtils.boundPixel(i.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...d},...h,children:te.jsx("path",{d:`M ${o.ReactUtils.boundPixel(r[0])} ${o.ReactUtils.boundPixel(r[1])} L ${o.ReactUtils.boundPixel(r[2])} ${o.ReactUtils.boundPixel(r[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...c})})},en=t=>{const{x:r=0,y:i=0,width:c=0,height:d=0,fill:h,stroke:a,strokeWidth:s=0,strokeDasharray:w,strokeDashoffset:P,clipPath:z,pathBounds:M,pathProps:T,style:O,...ie}=t,Z=i,oe=r,Pe=c,Q=d;let U=null;if(h){let _=Io({top:0,left:0,bottom:Q,right:Pe});M&&(_=_+" "+Io({top:M.y-Z,left:M.x-oe,bottom:M.height+M.y-Z,right:M.width+M.x-oe})),U=[te.jsx("path",{d:_,fill:h,stroke:"none",fillRule:"evenodd"},"fill")]}return te.jsxs("svg",{width:`${o.ReactUtils.boundPixel(c,!0)}`,height:`${o.ReactUtils.boundPixel(d,!0)}`,viewBox:`0 0 ${o.ReactUtils.boundPixel(c,!0)} ${o.ReactUtils.boundPixel(d,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${o.ReactUtils.boundPixel(r)}px`,top:`${o.ReactUtils.boundPixel(i)}px`,pointerEvents:"none",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",boxShadow:"rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px",overflow:"visible",...O},...ie,children:[U,te.jsx("path",{d:Io({top:0,left:0,right:Pe,bottom:Q}),fill:"none",strokeDasharray:w,strokeDashoffset:P,stroke:a,vectorEffect:"non-scaling-stroke",strokeWidth:s,...T})]})},qo=t=>{const{key:r,...i}=t;return te.jsx(Oo,{...i},r)},Oo=l.memo(t=>{const{stroke:r,fill:i,x:c=0,y:d=0,width:h=0,height:a=0,style:s,isAnimatedStroke:w,animatedStrokeProps:P,range:z,cell:M,...T}=t,O=w||!!P,ie={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...P};let Z=ie.dashGap+ie.dashLength;const oe=ie.speed*Z,Pe=o.useId().replaceAll(":",""),Q=`${ie.name}-${Pe}`;let U;return l.useEffect(()=>{if(!O)return;const _=`@keyframes ${Q} {
15
8
  to {
16
9
  stroke-dashoffset: 0px;
17
10
  }
18
- }`,le=document.createElement("style");return le.appendChild(document.createTextNode(j)),document.head.appendChild(le),le.sheet.insertRule(j,0),()=>{document.head.removeChild(le)}},[y]),y&&(I={strokeDasharray:`${R.dashLength}px ${R.dashGap}px`,strokeDashoffset:`${C}px`,animation:`${O} ${L}ms linear infinite`,willChange:"stroke-dashoffset"}),P.jsx(mi,{x:o,y:r,width:i,height:l,stroke:t,fill:n,shapeRendering:"crispEdges",style:{...I,...s},...h})});function xi(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=xi(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function fn(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=xi(e))&&(o&&(o+=" "),o+=t);return o}Xo.displayName="Selection";const Wo=c.memo(c.forwardRef((e,t)=>{const{x:n=0,y:o=0,borderWidth:r=1,size:i=6,borderStroke:l,corner:s,style:u,className:d,background:p,...x}=e;if(n===0||o===0)return null;let h=!0,y=!0,R=!0,C=!0;switch(s){case"tl":h=!1,y=!1;break;case"bl":h=!1,C=!1;break;case"br":R=!1,C=!1;break;case"tr":y=!1,R=!1}return P.jsx("div",{className:fn("fill-handle",d),style:{position:"absolute",left:n-(i+(h?r:0))/2,top:o-(i+(y?r:0))/2,width:i,height:i,borderLeft:h?`${r}px ${l}`:void 0,borderTop:y?`${r}px ${l}`:void 0,borderRight:R?`${r}px ${l}`:void 0,borderBottom:C?`${r}px ${l}`:void 0,background:p,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...u},tabIndex:-1,...x})}));Wo.displayName="FillHandle";var $l=function(){},yi=typeof window<"u",Bl=yi?c.useLayoutEffect:c.useEffect,jr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const bi=yi&&window.ResizeObserver!==void 0?function(){var e=c.useState(null),t=e[0],n=e[1],o=c.useState(jr),r=o[0],i=o[1],l=c.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var u=s[0].contentRect,d=u.x,p=u.y,x=u.width,h=u.height,y=u.top,R=u.left,C=u.bottom,L=u.right;i({x:d,y:p,width:x,height:h,top:y,left:R,bottom:C,right:L})}})},[]);return Bl(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[$l,jr]};function ko(e,t){if(typeof e=="function")return e(t);e&&(e.current=t)}var Fl=parseInt(c.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const r=ko(o,t),i=typeof r=="function";n.push(i?r:()=>ko(o,null))}return()=>{for(const o of n)o()}}}:function(e){return t=>{for(const n of e)ko(n,t)}};const Qn=c.memo(c.forwardRef((e,t)=>{const{range:n,view:o,anchor:r,borderStroke:i="rgb(33, 115, 70)",background:l="white",borderWidth:s=1.5,size:u=22,style:d,className:p,selectionTouchPointerHandler:x,onTouchSelectStart:h,onTouchSelectEnd:y,currentTouchAnchor:R,scrollableElement:C,scrollableRoot:L=document.body,...J}=e,O=T(h,[h]),I=T(y,[y]),{bounds:j,coordsPivot:le,key:B}=c.useMemo(()=>{if(!n||!o)return null;let q=null,z=null;switch(r){case"tl":q={colIndex:n.colEnd,rowIndex:n.rowEnd},z={colIndex:n.colStart,rowIndex:n.rowStart};break;case"br":q={colIndex:n.colStart,rowIndex:n.rowStart},z={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"t":case"l":q={colIndex:n.colEnd,rowIndex:n.rowEnd};break;case"b":q={colIndex:n.colStart,rowIndex:n.rowStart};break;case"r":q={colIndex:n.colStart,rowIndex:n.rowEnd}}let K=o.getRangeCoordsBounds(z?{rowStart:z.rowIndex,colStart:z.colIndex,rowEnd:z.rowIndex,colEnd:z.colIndex}:n);const ee=o.getBounds(),te=o.getViewportSize(),X=ee.x,Ve=ee.y,Be=te.width,We=te.height;switch(r){case"tl":break;case"br":K.x=K.x+K.width,K.y=K.y+K.height;break;case"t":K.x=Be/2-X;break;case"b":K.x=Be/2-X,K.y=K.y+K.height;break;case"l":K.y=We/2-Ve;break;case"r":K.x=K.x+K.width,K.y=We/2-Ve}const it=o.toClipBounds(K,0);return!it||it.width<=0||it.height<=0||K.x<0||K.y<0||K.x>Be||K.y>We?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:K,coordsAnchor:null,coordsPivot:q,key:"touchSelect-"+o.getAnchor()+"-"+r}},[n,o,r]),oe=c.useRef(null),be=bn(c.useMemo(()=>{const q=z=>r==="t"||r==="b"?{...z,colIndex:void 0}:r==="l"||r==="r"?{...z,rowIndex:void 0}:z;return{processTouch:!0,consumeTouch:!0,onPointerDown:(z,K)=>{const ee=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return oe.current={coordsPivot:le},O?.(r),x.onSelectionPointerDown(z,K,o,ee,le,!1,!0)},onPointerMoveOrWait:(z,K,ee)=>{const te=q(o.getCellCoordsFromClient(z.clientX,z.clientY));return x.onSelectionPointerMoveOrWait(z,K,ee,o,te,oe.current?.coordsPivot,!0,!0)},onPointerUp:(z,K,ee)=>(oe.current=null,I?.(r),x.onPointerUp(z,K,ee))}},[x,n,o,r])),[U,{y:N,x:Y}]=bi(),k=c.useRef(null),{getPortalContainer:E}=hi(),[g,Z]=c.useState(null);return c.useEffect(()=>{const q=k.current?.getBoundingClientRect();if(!q||!j)return void Z(null);let z=0,K=0,ee=C;for(;ee;)z+=ee.scrollLeft,K+=ee.scrollTop,ee=L&&ee===L.parentElement?null:ee.parentElement;Z(No.createPortal(P.jsx("div",{className:fn("touch-select-handle",p),ref:t,style:{position:"absolute",left:z+(q?.x??0)-(u+s)/2,top:K+(q?.y??0)-(u+s)/2,width:u,height:u,borderWidth:`${s}px`,border:i,borderRadius:"50%",background:l,boxShadow:`0 0 0 1.5px ${l}`,cursor:"grab",pointerEvents:"all",opacity:R?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...d},tabIndex:-1,onPointerDown:be,...J}),L??E(),B))},[N,Y,j?.x,j?.y,j?.width,j?.height,p,R,l,u,s,i,C]),j?P.jsxs(P.Fragment,{children:[P.jsx("div",{ref:Fl([U,k]),style:{position:"absolute",left:j.x,top:j.y,opacity:0}}),g]}):null}));Qn.displayName="TouchSelectHandle";const Wt=-10,Vl=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),vi=Object.freeze({colIndex:0,rowIndex:0}),Ho=Object.freeze([]),$t=e=>{if(e&&e.cell&&e.ranges&&e.rangeIndex>-1&&e.rangeIndex<=e.ranges.length)return e;const t={cell:null,ranges:e?.ranges??Ho};return t.rangeIndex=e?.rangeIndex??t.ranges.length-1,t.cell=e?.cell,!t.cell&&t.ranges.length>0&&(t.cell={rowIndex:t.ranges[t.rangeIndex].rowStart,colIndex:t.ranges[t.rangeIndex].colStart}),t.cell||(t.cell=vi),G.isEqualSelectionCoords(t,e)?e:t},Gn=(e,t,n)=>{const o=e.getVisibleRangeCoords(),r=e.getScrollOrientation();!r.horizontal&&(t.colIndex>o.colEnd||t.colIndex<o.colStart)&&(t={...t,colIndex:t.colIndex>o.colEnd?o.colEnd+1:o.colEnd-1},e=n.current.getViewFromLocation(Ht)),!r.vertical&&(t.rowIndex>o.rowEnd||t.rowIndex<o.rowStart)&&(t={...t,rowIndex:t.rowIndex>o.rowEnd?o.rowEnd+1:o.rowEnd-1},e=n.current.getViewFromLocation(Ht)),e.scrollCellCoordsIntoView(t)},Wl=()=>!1;function eo(e,t){if(!e)throw new Error("Invariant failed")}const Ar={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},Hl=Object.freeze({top:0,left:0}),Nl=Object.freeze({bottom:-4,right:-4}),Ul=Object.freeze({horizontal:!0,vertical:!0}),$r=[to,Ln,Dn,Ht],Jt=3e3,To={},Yo=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,rowCount:r=1,columnCount:i=1,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d,layout:p,onViewportScroll:x,onImmediateScroll:h,showGridLines:y=!0,gridLineColor:R="rgb(224, 224, 224)",gridLineRowsProps:C,gridLineColumnsProps:L,clipCells:J=!0,cursor:O,freezeLeft:I=0,freezeTop:j=0,freezeLeftProps:le,freezeTopProps:B,cellRenderer:oe,onViewportChange:be,onFirstRender:U,overlayRenderer:N,overlayProps:Y,overlays:k,overlaysProps:E,allowOverlaysOverflow:g=!1,stageProps:Z,stageWrapper:q=null,hiddenRowsAt:z,hiddenColumnsAt:K,hiddenCellAt:ee,getVisibleCells:te,zoom:X=1,enableMouseWheel:Ve=!0,onWheelScroll:Be,getCellCoordsAsRangeCoords:We=G.cellToRange,scrollPoint:it=Hl,style:ve={},...Ke}=e;eo(oe),eo(!e?.children);const $=T(h,[h]),_=T(be,[be]),Ce=T(x,[x]),ue=T(Be,[Be]),we=T(U,[U]),ze=c.useRef(null),lt=c.useRef(null),It=c.useRef(null),[st,Ut]=c.useReducer(b=>b+1,0),[xt,M]=c.useState({left:it?.left??0,top:it?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),xe=c.useRef(null),Ye=c.useRef(xt),{top:ft,left:Ge,verticalScrollDirection:Qt,horizontalScrollDirection:Yt}=xt,Et=c.useRef(!1),tn=wi({rowCount:r,columnCount:i,defaultRowHeight:l,defaultColumnWidth:s,getRowHeight:u,getColumnWidth:d}),Xt=c.useRef(null),Oe=c.useMemo(()=>{const b=p||tn;return Xt.current=null,{getColOffset:D=>b.getColOffset(D)*X,getColIndex:D=>b.getColIndex(D/X),getRowOffset:D=>b.getRowOffset(D)*X,getRowIndex:D=>b.getRowIndex(D/X)}},[tn,p,X]),Ft=(b,D,A)=>{const V=(D?.left??0)+0,W=(D?.top??0)+0;return{getColOffset:he=>b.getColOffset(he)-V,getColIndex:he=>b.getColIndex(he+V),getRowOffset:he=>b.getRowOffset(he)-W,getRowIndex:he=>b.getRowIndex(he+W)}},pt=c.useCallback((b,D=!1)=>io(b,D,Oe.getRowOffset,D?0:r),[r,Oe?.getRowOffset]),jt=T(z??pt,[z]),wn=c.useCallback((b,D=!1)=>io(b,D,Oe.getColOffset,D?i:0),[i,Oe?.getColOffset]),nn=T(K??wn,[K]),Fe=c.useMemo(()=>Math.min(n??800,Oe.getColOffset(i)),[Oe.getColOffset,i,n]),Q=c.useMemo(()=>Math.min(o??600,Oe.getRowOffset(r)),[Oe.getRowOffset,r,o]),Ze=c.useCallback(b=>{St.canUseDOM&&setTimeout(()=>{ze.current?.focus({preventScroll:!0,...b})},0)},[]),He=c.useCallback(b=>ze.current?.contains(b)||lt.current?.contains(b),[]);c.useEffect(()=>{Et.current&&(xe.current&&xe.current.left!==Ye.current?.left&&xe.current.top!==Ye.current?.top||(xe.current=null,Ce?.({left:Ge,top:ft})))},[Ge,ft]);const ct=T(()=>({top:ft,left:Ge}),[ft,Ge]),Ee=c.useMemo(()=>{const b=[];let D=0,A=0;typeof j=="number"?D=j:(D=j.index??0,A=(j.scrollOffset??0)*X);const V=A,W=Oe.getRowOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{top:A+Oe.getRowOffset(0)}),je=Oe.getRowIndex(V),Ae=Oe.getRowIndex(W-1);let dt;b[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(jt,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const se=Math.max(0,Q-he),me=Ft(Oe,{top:ft+he}),ye=me.getRowIndex(0),ce=me.getRowIndex(se);let $e;return b[0]={minIndex:ye,maxIndex:ce,minCoord:D,maxCoord:r-1,minBounds:he,maxBounds:se,visibleIndices:()=>$e||($e=Object.freeze(Yn(jt,ye,ce)),$e),layout:me,maxVirtualBounds:Oe.getRowOffset(r),scrollOffset:ft,freezeOffset:(D>0?Oe.getRowOffset(D):0)-A},b},[Oe.getRowIndex,Oe.getRowOffset,jt,Q,r,j,ft,X]),Te=c.useMemo(()=>{const b=[];let D=0,A=0;typeof I=="number"?D=I:(D=I.index??0,A=(I.scrollOffset??0)*X);const V=A,W=Oe.getColOffset(D),he=W-V;if(D>0){const at=Ft(Oe,{left:A+Oe.getColOffset(0)}),je=Oe.getColIndex(V),Ae=Oe.getColIndex(W-1);let dt;b[1]={minIndex:je,maxIndex:Ae,minCoord:0,maxCoord:D-1,minBounds:0,maxBounds:he,visibleIndices:()=>dt||(dt=Object.freeze(Yn(nn,je,Ae)),dt),layout:at,maxVirtualBounds:W,scrollOffset:A,freezeOffset:A}}const se=Math.max(0,Fe-he),me=Ft(Oe,{left:Ge+he}),ye=me.getColIndex(0),ce=me.getColIndex(se);let $e;return b[0]={minIndex:ye,maxIndex:ce,minCoord:D,maxCoord:i-1,minBounds:he,maxBounds:se,visibleIndices:()=>$e||($e=Object.freeze(Yn(nn,ye,ce)),$e),layout:me,maxVirtualBounds:Oe.getColOffset(i),scrollOffset:Ge,freezeOffset:(D>0?Oe.getColOffset(D):0)-A},b},[Oe.getColIndex,Oe.getColOffset,nn,Fe,i,I,Ge,X]),tt=c.useRef({}),Je=c.useRef([]),Le=c.useMemo(()=>{let b={};const D=(V,W,he,se,me)=>{const ye={vertical:se?.vertical||!1,horizontal:se?.horizontal||!1};if(V>=Te.length||W>=Ee.length)return null;const ce={rowStart:Ee[W].minIndex,colStart:Te[V].minIndex,rowEnd:Ee[W].maxIndex,colEnd:Te[V].maxIndex};if(ce.rowStart>ce.rowEnd||ce.colStart>ce.colEnd)return null;const $e={getColIndex:_e=>Te[V].layout.getColIndex(_e),getColOffset:_e=>Te[V].layout.getColOffset(_e),getRowIndex:_e=>Ee[W].layout.getRowIndex(_e),getRowOffset:_e=>Ee[W].layout.getRowOffset(_e)},at=Object.freeze({left:me?.left??0,top:me?.top??0,right:me?.right??0,bottom:me?.bottom??0}),je=Object.freeze({x:Te[V].minBounds,y:Ee[W].minBounds,width:Te[V].maxBounds,height:Ee[W].maxBounds}),Ae=(_e,Xe)=>Dr($e,_e??ce,Xe),dt={width:Te[V].maxVirtualBounds,height:Ee[W].maxVirtualBounds},qe={left:Te[V].scrollOffset,top:Ee[W].scrollOffset},kt={left:Te[V].freezeOffset,top:Ee[W].freezeOffset},gt={width:Fe,height:Q};let fe=null,ht=null;const Ot=(kt.top+(se.vertical?qe.top:0))/X,At=(kt.left+(se.horizontal?qe.left:0))/X;return{getStage:()=>ze.current??null,getVisibleRangeCoords:()=>ce,toClipBounds:(_e,Xe)=>{let De,rt=0;return Xe===void 0||typeof Xe=="number"?(De=Ae(ce),rt=Xe):De=Xe,((ke,yt,wt=0)=>{if(ke.x>yt.width||ke.y>yt.height)return null;const Lt={left:ke.x,top:ke.y,bottom:ke.height+ke.y,right:ke.width+ke.x},Vt={left:yt.x+wt,top:yt.y+wt,bottom:yt.height-2*wt+yt.y,right:yt.width-2*wt+yt.x},Tt={left:Math.max(Lt.left,Vt.left),top:Math.max(Lt.top,Vt.top),bottom:Math.min(Lt.bottom,Vt.bottom),right:Math.min(Lt.right,Vt.right)},a={x:Tt.left,y:Tt.top,width:Tt.right-Tt.left,height:Tt.bottom-Tt.top};return a.height<0||a.width<0?null:a})(_e??{x:0,y:0,width:je.width,height:je.height},De,rt)},toViewBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:(_e.x-At)*X,y:(_e.y-Ot)*X,width:_e.width*X,height:_e.height*X},toAbsoluteBounds:_e=>At===0&&Ot===0&&X===1?_e:{x:_e.x/X+At,y:_e.y/X+Ot,width:_e.width/X,height:_e.height/X},getRelativePointFromClient:(_e,Xe)=>{const De=on(_e,Xe);return{x:De.x-je.x,y:De.y-je.y}},getLayout:()=>$e,getCellCoordsAsRangeCoords:We,getVisibleColumns:()=>Te[V].visibleIndices(),getVisibleRows:()=>Ee[W].visibleIndices(),getVisibleColumnOffsets:()=>(fe||(fe=Lr(Te[V].layout,!0,Te[V].visibleIndices(),ce.colStart,ce.colEnd)),fe),getVisibleRowOffsets:()=>(ht||(ht=Lr(Ee[W].layout,!1,Ee[W].visibleIndices(),ce.rowStart,ce.rowEnd)),ht),getTotalRangeCoords:()=>({colStart:Te[V].minCoord,colEnd:Te[V].maxCoord,rowStart:Ee[W].minCoord,rowEnd:Ee[W].maxCoord}),getRangeCoordsBounds:Ae,scrollCellCoordsIntoView:(_e,Xe)=>_n(_e,Xe,he),getCellCoordsFromClient:(_e,Xe,De=!1)=>{const rt=on(_e,Xe);if(!rt)return null;const ke=$e.getColIndex(rt.x-je.x),yt={rowIndex:$e.getRowIndex(rt.y-je.y),colIndex:ke};if(De)return yt;const wt=We(yt);return{rowIndex:wt.rowStart,colIndex:wt.colStart}},getZoom:()=>X,getAnchor:()=>he,getBounds:()=>je,getInsets:()=>at,getTotalSize:()=>dt,getViewportSize:()=>gt,getScrollTopLeft:()=>qe,getFreezeTopLeft:()=>kt,getScrollOrientation:()=>ye,allViews:()=>b}};let A=b[Ht]=D(0,0,Ht,Ul,Nl);return A&&(b[Ht]=A),A=D(0,1,Ln,{horizontal:!0}),A&&(b[Ln]=A),A=D(1,0,Dn,{vertical:!0}),A&&(b[Dn]=A),A=D(1,1,to,{}),A&&(b[to]=A),tt.current=null,b=Object.freeze(b)},[Ee,Te,We]),Gt=Object.keys(Le),_t=Te[0]?.maxVirtualBounds??0,Qe=Ee[0]?.maxVirtualBounds??0,Ct=c.useMemo(()=>({left:Te[1]?Te[1].layout.getColOffset(Te[1].maxIndex+1):0,top:Ee[1]?Ee[1].layout.getRowOffset(Ee[1].maxIndex+1):0}),[Le]);c.useEffect(()=>{if(Je.current.length>0){for(let b=0;b<Je.current.length;b++)Je.current[b]();Je.current=[]}},[Le]);const Rt=T(()=>({containerWidth:Fe,containerHeight:Q,totalWidth:_t,totalHeight:Qe}),[Fe,Q,Oe]);c.useEffect(()=>{!xe.current&&Et.current&&_({top:ft,left:Ge,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})},[ft,Ge,_t,Qe]),c.useEffect(()=>{Et.current&&_({top:ft,left:Ge,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})},[Fe,Q]);const on=c.useCallback((b,D)=>{eo(typeof b=="number"&&typeof D=="number");const A=ze.current?.getBoundingClientRect();return A?{x:b-A.x,y:D-A.y}:{x:b,y:D}},[]),so=T(b=>Le[b]||null,[Le]),co=T((b,D)=>{if(Object.keys(Le).length===1)return Le[Ht];const A=on(b,D);if(!A)return null;const{x:V,y:W}=A;let he=null;const se=$r;for(let me=0;!he&&me<se.length;me++){const ye=Le[se[me]];ye&&Al(V,W,ye.getBounds())&&(he=ye)}return he||(he=Le[Ht]),he},[Le,We]),ut=T(()=>Le[Ht].getVisibleRangeCoords(),[Le[Ht]]),Zt=c.useRef(null),ao=c.useCallback(()=>{Zt.current!==null&&St.cancelTimeout(Zt.current),Zt.current=St.requestTimeout(uo,150)},[]),uo=c.useCallback(()=>{Zt.current=null,M(b=>{const D={...b,verticalScrollDirection:null,horizontalScrollDirection:null};return Ye.current=D,D})},[]),an=T(b=>{const D=b?.left??b?.[0],A=b?.top??b?.[1],V=D!==void 0?Math.min(_t-Fe,Math.max(Te?.[1]?.scrollOffset??0,D)):Ye.current.left,W=A!==void 0?Math.min(Qe-Q,Math.max(Ee?.[1]?.scrollOffset??0,A)):Ye.current.top;if(Ye.current.left===V&&Ye.current.top===W)return;let he=null,se=null;Ye.current.left>V?he=et:Ye.current.left<V&&(he=Ne),Ye.current.top>W?se=nt:Ye.current.top<W&&(se=ot),St.throttle(()=>{M(me=>{const ye={...me,left:V,top:W,horizontalScrollDirection:he,verticalScrollDirection:se};return Ye.current=ye,ye})},17)(),xe.current?.top===W&&xe.current?.left===V||(xe.current={left:V,top:W},$({left:V,top:W}),_({left:V,top:W,width:Fe,height:Q,totalWidth:_t,totalHeight:Qe})),ao()},[_t,Qe,Ee,Te]);c.useEffect(()=>{xe.current||an({left:Ge,top:ft})},[_t,Fe,Qe,Q]),c.useLayoutEffect(()=>{xe.current={left:it?.left,top:it?.top},an(xe.current)},[it?.left,it?.top]);const An=T(b=>{const D=b?.left??b?.[0],A=b?.top??b?.[1],V=b?.behavior??"auto",W={left:Ye.current.left+(D??0),top:Ye.current.top+(A??0)};V&&(W.behavior=V),an(W)},[_t,Fe,Qe,Q]),$n=c.useCallback(b=>{let D=null;if(Object.keys(Le).length>1){const A=$r;for(let V=0;!D&&V<A.length;V++){const W=Le[A[V]];W&&G.isCellWithinRange(b,W.getVisibleRangeCoords())&&(D=W)}}return D||(D=Le[Ht]),D},[Le]),_n=T((b,D={inline:"nearest",block:"nearest"},A=null)=>{const V={rowIndex:0,colIndex:0,...b};let W=null;if(A!==null){if(W=Le[A],W===null)return new Promise((gt,fe)=>{fe("Invalid view")})}else W=$n(V);const he=We(V),se=W.getLayout(),me=se.getColOffset(he.colStart),ye=se.getRowOffset(he.rowStart),ce=se.getColOffset(he.colEnd+1),$e=se.getRowOffset(he.rowEnd+1),at=W.getBounds(),je=W.getTotalSize(),Ae=W.getScrollTopLeft(),dt=((gt,fe,ht=!0)=>(ht=ht===!0?{block:"start",inline:"end"}:ht===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",...ht},{left:Tr(ht.inline,gt.x,gt.x+gt.width,fe.left,fe.left+fe.width,fe.totalWidth),top:Tr(ht.block,gt.y,gt.y+gt.height,fe.top,fe.top+fe.height,fe.totalHeight)}))({x:me+Ae.left,y:ye+Ae.top,width:ce-me,height:$e-ye},{left:Ae.left,top:Ae.top,width:at.width,height:at.height,totalWidth:je.width,totalHeight:je.height},D),qe={...dt};qe.left>Ge?qe.left+=20:qe.left<Ge&&(qe.left-=0),qe.top>ft?qe.top+=20:qe.top<ft&&(qe.top-=0);const kt=W.getScrollOrientation();return kt.horizontal&&b.colIndex!==void 0||delete qe.left,kt.vertical&&b.rowIndex!==void 0||delete qe.top,new Promise((gt,fe)=>{try{an(qe),gt(qe)}catch(ht){fe(ht)}})},[_t,Qe,Le,We]),mn=T(b=>{const D=b.shiftKey;b.preventDefault();const{deltaX:A,deltaY:V,deltaMode:W}=b;if(It.current||ue?.(b)===!1)return;let se=D?V:A,me=V;const ye=D||Math.abs(se)>Math.abs(me);W===1&&(me*=0),It.current=window.requestAnimationFrame(()=>{It.current=null,An(ye?{left:se}:{top:me})})},[_t,Fe,Qe,Q,ue]),Cn=c.useCallback((b=null)=>{Xt.current=null,tt.current=null,Ut()},[]);c.useLayoutEffect(()=>{Cn()},[oe]);const un=lo(t,()=>({stage:ze.current,focus:Ze,contains:He,invalidate:Cn,scrollTo:an,scrollBy:An,scrollCellCoordsIntoView:_n,getScrollPosition:ct,getDimensions:Rt,getViewport:ut,handleWheel:mn,rowCount:r,columnCount:i,getLayout:()=>Oe,getRelativePointFromClient:on,getViewFromClient:co,getViewFromCellCoords:$n,getViewFromLocation:so,onViewChangeOnce:b=>{Je.current.push(b)}}),[r,i,Le]);c.useEffect(()=>(Ve&&un.current?.addEventListener("wheel",mn,{passive:!1}),Et.current=!0,xe.current=null,()=>{un.current?.removeEventListener("wheel",mn)}),[Ve]);const In=c.useRef([]),ho=(b,D)=>{!b||!N||(In.current=[],D.push(((A,V)=>{const W=`view:${A.getAnchor()}:overlay:${D.length}`,he=N?.({key:W,view:A},me=>In.current[V]=me);if(!he)return null;const se=A.getBounds();return P.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${se.width}px`,height:`${se.height}px`,overflow:"hidden"},children:he},`overlay-${A.getAnchor()}-${V}`)})(b,0)))},fo=c.useMemo(()=>{const b={},D=Object.keys(Le);for(let A=0;A<D.length;A++){const V=D[A],W=[];ho(Le[V],W),b[V]={overlays:W}}return b},[st,N,r,i,Ee,Te]),Bn=(b,D,A,V,W,he,se)=>{if(!b)return;const me=b.getVisibleColumns(),ye=b.getVisibleRows();if(me.length===0||ye.length===0)return;let ce=null;if(te)ce=te(b);else{ce=[];for(let Xe=0;Xe<ye.length;Xe++)for(let De=0;De<me.length;De++){const rt={rowIndex:ye[Xe],colIndex:me[De]};if(ee?.(rt))continue;const ke={coords:rt,range:We(rt)};ce.push(ke)}}const $e=b.getVisibleColumnOffsets(),at=b.getVisibleRowOffsets(),je=b.getScrollTopLeft(),Ae=b.getFreezeTopLeft(),dt=je.left+Ae.left,qe=je.top+Ae.top,kt=Math.trunc(dt/Jt),gt=Math.trunc(qe/Jt),fe={},ht=(Xe,De,rt,ke,yt)=>{const wt=`view:${Xe.getAnchor()}:cell:${kr(De.rowIndex,De.colIndex)}`,Lt=ke.x,Vt=ke.y,Tt=Math.trunc((dt+Lt)/Jt)-kt,a=Math.trunc((qe+Vt)/Jt)-gt;fe[a]||(fe[a]={});let f=fe[a][Tt];f||(f=fe[a][Tt]=[]);let m=he?.get(wt);if(!m){const w=(dt+Lt)%Jt,v=(qe+Vt)%Jt;m=oe({key:wt,coords:De,bounds:ke,zoom:X,range:rt,view:Xe,value:yt,style:{left:ge.boundPixel(w),top:ge.boundPixel(v),width:ge.boundPixel(ke.width,!0),height:ge.boundPixel(ke.height,!0)}})}se?.set(wt,m),f.push(m)};for(let Xe=0;ce&&Xe<ce.length;Xe++){const De=ce[Xe],rt=De?.coords??De;if(!rt)continue;const ke=De?.range??{rowStart:rt.rowIndex,colStart:rt.colIndex,rowEnd:rt.rowIndex,colEnd:rt.colIndex},yt=b.getVisibleRangeCoords();if(!G.isRangesIntersect(ke,yt)&&!G.isRangeWithinRange(ke,yt))continue;const wt=ke&&!G.isSingleCell(ke);if(!wt&&ee?.(rt))continue;const Lt=rt.rowIndex,Vt=rt.colIndex,Tt=at[Lt],a=$e[Vt];let f=null;Tt&&a&&(f={x:a.offset,y:Tt.offset,width:a.size,height:Tt.size});const m=kr(ke.rowStart,ke.colStart);if(wt){if(W.has(m))continue;W.add(m),ke.rowEnd-ke.rowStart>0&&A.push(ke),ke.colEnd-ke.colStart>0&&V.push(ke)}if(wt&&(f=Dr(b.getLayout(),ke)),!f){console.warn("no bounds for cell",m);continue}const w=De?.value;ht(b,rt,ke,f,w)}const Ot=dt%Jt,At=qe%Jt,_e=Object.keys(fe);for(let Xe=0;Xe<_e.length;Xe++){const De=fe[_e[Xe]];if(!De)continue;const rt=Object.keys(De);for(let ke=0;ke<rt.length;ke++){const yt=De[rt[ke]];if(!yt)continue;const wt=parseInt(_e[Xe]),Lt=parseInt(rt[ke]),Vt=wt+gt,Tt=Lt+kt,a=`view:${b.getAnchor()}:segment:${Tt}:${Vt}`;D.push(P.jsx("div",{className:"cell-container",style:{transform:`translate(${ge.boundPixel(Lt*Jt-Ot,!0)}px, ${ge.boundPixel(wt*Jt-At,!0)}px)`,willChange:"transform"},children:yt},a))}}},Kt=c.useMemo(()=>{const b=Xt.current,D=new Map,A={},V=Object.keys(Le);for(let W=0;W<V.length;W++){const he=V[W],se=[],me=[],ye=[];Bn(Le[he],ye,se,me,new Set,b,D),A[he]={cells:ye,rangesH:se,rangesV:me}}return Xt.current=D,A},[st,r,i,Ee,Te,y,ve,J,ee,te,We]),Fn=(b,D,A,V,W)=>{if(b)if(D){const he=`view:${b.getAnchor()}:hl:`,se=b.getVisibleRows();if(!se||se.length===0)return;const me=0,ye=b.getBounds().width;let ce=[];const $e=W.sort(G.rowFirstRangeComparator),at=b.getVisibleRangeCoords();for(let je=0;je<se.length&&se[je]<=at.rowEnd;je++){const Ae=se[je];if(Ae<at.rowStart)continue;let dt=!1;for(;$e.length>0&&$e[0].rowStart<=Ae;){const fe=$e.shift();fe.rowEnd>Ae&&(ce.push(fe),dt=!0)}dt&&(ce=ce.sort(G.columnFirstRangeComparator));const qe=b.getLayout(),kt=qe.getRowOffset(Ae+1);let gt=me;for(let fe=0;fe<ce.length+1;fe++){let ht=gt,Ot=ye;const At=ce[fe];fe<ce.length&&(Ot=Math.min(ye,qe.getColOffset(At.colStart)),gt=Math.min(ye,qe.getColOffset(At.colEnd+1))),V.push(c.createElement("path",{d:`M ${ge.boundPixel(ht)} ${ge.boundPixel(kt,!1,A)} L ${ge.boundPixel(Ot)} ${ge.boundPixel(kt,!1,A)}`,stroke:R,strokeWidth:1,vectorEffect:"non-scaling-stroke",...C,key:he+Ae+":"+fe}))}for(let fe=ce.length-1;fe>=0;fe--)ce[fe].rowEnd<=se[je+1]&&ce.splice(fe,1)}}else{const he=`view:${b.getAnchor()}:vl:`,se=b.getVisibleColumns();if(!se||se.length===0)return;const me=0,ye=b.getBounds().height;let ce=[];const $e=W.sort(G.columnFirstRangeComparator),at=b.getVisibleRangeCoords();for(let je=0;je<se.length&&se[je]<=at.colEnd;je++){const Ae=se[je];if(Ae<at.colStart)continue;let dt=!1;for(;$e.length>0&&$e[0].colStart<=Ae;){const fe=$e.shift();fe.colEnd>Ae&&(ce.push(fe),dt=!0)}dt&&(ce=ce.sort(G.rowFirstRangeComparator));const qe=b.getLayout(),kt=qe.getColOffset(Ae+1);let gt=me;for(let fe=0;fe<ce.length+1;fe++){let ht=gt,Ot=ye;const At=ce[fe];fe<ce.length&&(Ot=Math.min(ye,qe.getRowOffset(At.rowStart)),gt=Math.min(ye,qe.getRowOffset(At.rowEnd+1)));let _e=R;V.push(P.jsx("path",{d:`M ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(ht)} L ${ge.boundPixel(kt,!1,A)} ${ge.boundPixel(Ot)}`,stroke:_e,strokeWidth:1,vectorEffect:"non-scaling-stroke",...L},he+Ae+":"+fe))}for(let fe=ce.length-1;fe>=0;fe--)ce[fe].colEnd<=se[je+1]&&ce.splice(fe,1)}}},Mn=b=>{if(!Kt)return;const D={};for(let A=0;A<Gt.length;A++){const V=Gt[A],W=Le[V],he=[];Fn(W,b,0,he,b?Kt[V].rangesH:Kt[V].rangesV);const se=W.getRangeCoordsBounds(),me=Math.ceil(se.width),ye=Math.ceil(se.height);D[V]=P.jsx("svg",{width:`${me}`,height:`${ye}`,viewBox:`0 0 ${me} ${ye}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:he})}return D},Vn=c.useMemo(()=>y===!0||y?.horizontal===!0?Mn(!0):null,[st,y,Ee,j,I,R,C,r,i,Fe,_t,Kt]),Wn=c.useMemo(()=>y===!0||y?.vertical===!0?Mn(!1):null,[st,y,Te,j,I,R,L,r,i,Q,Qe,Kt]),po=c.useMemo(()=>Ct.left===0?null:P.jsx(Vo,{linePoints:[0,0,0,Q+1],bounds:{x:Ct.left,y:0,width:1,height:Q+1},...le}),[st,Ct.left,Q,le]),go=c.useMemo(()=>Ct.top===0?null:P.jsx(Vo,{linePoints:[0,0,Fe+1,0],bounds:{x:0,y:Ct.top,width:Fe+1,height:1},...B}),[st,Ct.top,Fe,B]),Rn=c.useMemo(()=>{const b=[],D=A=>{if(!A||!Le[A])return;const V=Le[A].getBounds();return P.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:V.x,top:V.y,width:V.width,height:V.height,clip:`rect(0, ${V.width+1}px, ${V.height+1}px, 0)`},className:`view view-${A}`,children:[Vn?.[A],Wn?.[A],Kt?.[A].cells]},`view:${A}`)};for(let A=0;A<Gt.length;A++)b.push(D(Gt[A]));return P.jsx(P.Fragment,{children:b})},[Le,Vn,Wn,Kt]),wo=c.useMemo(()=>{if(!t)return;const b=(se,me,ye,ce)=>{if(!ce||ce.length===0)return;const $e=[];for(let at=0;at<ce.length;at++){const je=ce[at];let Ae=se?.get(je);Ae!==To&&(Ae=je(ye)??To),me.set(je,Ae),Ae&&Ae!==To&&$e.push(Ae)}return $e},D=(se,me,ye)=>{if(!ye)return;const ce=ye.getBounds(),$e=ye.getInsets(),at=ye.getAnchor();return P.jsxs("div",{className:fn("view",`view-${at}`,Ar.view),style:{position:"absolute",pointerEvents:"none",left:ce.x-$e.left,top:ce.y-$e.top,width:ce.width-($e.left+$e.right),height:ce.height-($e.top+$e.bottom),clipPath:g?"inset(-2px)":"inset(0px)"},children:[b(se,me,ye,k),fo?.[at].overlays]},`view:${at}`)},A=tt.current,V={},W=[],he=Object.keys(Le);for(let se=0;se<he.length;se++){const me=he[se],ye=A?.[me],ce=V[me]=new Map;W.push(D(ye,ce,Le[me]))}return tt.current=V,W},[st,Le,g,k]),mo=c.useMemo(()=>{const{style:b,...D}=Z??{};return P.jsx("div",{style:{width:Fe,height:Q,...b},className:"sheetxl-stage",tabIndex:0,ref:ze,...D,...Ke,children:q?q(Rn):Rn})},[Fe,Q,Rn,Z,q]),Hn=c.useRef(!1);return c.useEffect(()=>{!Hn.current&&Kt&&(Hn.current=!0,we?.(un.current))},[Kt]),P.jsxs("div",{className:fn("sheetxl-grid",Ar["sheetxl-grid"]),style:{overflow:"visible",cursor:O,maxWidth:Fe,maxHeight:Q,width:Fe,height:Q,...ve},ref:un,children:[mo,P.jsxs("div",{className:fn("sheetxl-overlays"),ref:lt,...E,children:[wo,po,go]})]})}));Yo.displayName="BaseGrid";const Go=c.memo(c.forwardRef((e,t)=>{const{width:n,height:o,style:r={},className:i,...l}=e,[s,{width:u,height:d}]=bi(),p=n??u,x=o??d;return P.jsx("div",{className:i,style:{...r},children:P.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:P.jsx(Yo,{ref:t,width:p,height:x,...l})})})}));Go.displayName="Grid";const Si=c.memo(c.forwardRef((e,t)=>{const{showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:s,onScrollViewport:u,style:d={},className:p,onScroll:x,...h}=e,[y,R]=c.useState(null),C=c.useRef(null),L=c.useRef(null);eo(!s),c.useImperativeHandle(t,()=>L.current&&C.current?Object.assign(L.current,C.current):null);const J=c.useCallback(O=>{L.current?.scrollTo(O),u?.(O)},[]);return P.jsx(di,{className:p,style:d,ref:C,showVerticalScrollbar:n,showHorizontalScrollbar:o,createHorizontalScrollbar:r,createVerticalScrollbar:i,createScrollCorner:l,viewport:y,onScrollViewport:J,children:P.jsx(Go,{style:{width:"100%",height:"100%"},...h,onViewportChange:O=>R(O),ref:L})})}));Si.displayName="ScrollableGrid";const Br=()=>!1,Ei=c.memo(e=>{const{index:t,value:n,zoom:o,zoomScale:r=100,headerText:i=k=>`${k}`,headerStyle:l,headerStyleSelect:s=l,headerStyleSelectAll:u=s,headerStyleHover:d=u,verticalPadding:p=0,horizontalPadding:x=0,isSelected:h=Br,isSelectedAll:y=Br,coords:R,bounds:C,range:L,orientation:J,view:O,style:I,...j}=e,le=r/100,B=c.useRef(null),[oe,be]=c.useState(!1),U=h?.(t)||!1,N=y?.(t)?u:U?s:l;let Y=N;if(oe){let k=d;typeof d=="function"&&(k=d(N)),Y=St.mergeContentful(N,k)}return P.jsx("div",{ref:B,style:{background:Y.fill,color:Y.text?.fill,fontFamily:Y.text?.fontFamily??l.text?.fontFamily,fontSize:96*(Y.text?.fontSize??11)/72*le,fontStyle:Y.text?.fontStyle,fontWeight:Y.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${le}px`,...I,left:I.left-(J===Bt?1:0),top:I.top-(J===en?1:0),width:I.width+1,height:I.height+1,overflow:"hidden"},...j,onMouseMove:k=>{ge.detectIt().primaryInput!=="touch"&&k.buttons===0&&be(!0)},onMouseOut:k=>{be(!1)},children:i(t)})});Ei.displayName="HeaderRenderer";const _i="ew-resize",Ci="ns-resize",Ii=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,className:i,style:l,disabled:s=!1,disabledResize:u=!1,isNextHidden:d,isHidden:p,isSelected:x,isSelectedAll:h,showTouchDivider:y,headerStyle:R,headerStyleSelect:C,headerStyleSelectAll:L,headerStyleHover:J,bounds:O,onPointerDown:I,onAutoFit:j,...le}=e,B=n===Bt;let oe=R;x&&C&&(oe=C),h&&L&&(oe=L);const be=ge.detectIt().primaryInput==="touch";let U=B?14:8,N=U/2,Y=0;d&&(Y=-2),p&&(Y=2),p&&(U=U/2+Y,N=2*Y);let k=oe.dividerStrokeFill??oe.strokeFill;return!(x||h)&&Y===0&&(k=`linear-gradient(${B?180:90}deg, ${oe.fill}, ${k} 55%, ${k} 100%)`),P.jsxs("div",{className:fn("header-divider",{disabled:s},i,`index-${r}`),ref:t,onPointerDown:be?void 0:I,onDoubleClick:be?void 0:()=>j?.(),style:{top:(B?0:-U/2+(Y-1))+"px",left:(B?-U/2+(Y-1):0)+"px",width:B?U:"calc(100% + 1px)",height:B?"calc(100% + 1px)":U,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||u||be?void 0:B?_i:Ci,...l},...le,children:[P.jsx("div",{style:{position:"relative",top:`${B?0:N}px`,left:`${B?N:0}px`,width:B?1:"100%",height:B?"100%":1,background:k},onDoubleClick:()=>j?.()}),y&&be?P.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:B?"-6px":"2px",bottom:B?"2px":"-9px",height:"24px",width:B?"24px":"18px",maxHeight:B?"calc(100% - 4px)":void 0,maxWidth:B?void 0:"calc(100% - 4px)",background:oe.fill,border:`${L.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${R.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:I,children:P.jsx("div",{style:{width:"6.4px",height:"12px",backgroundImage:`url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(C.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`,backgroundRepeat:"no-repeat",backgroundPosition:"center",transform:B?void 0:"rotate(90deg)"}})}):null]})})),Kl=(e,t)=>P.jsx(Ii,{...e,ref:t}),ql=c.memo(c.forwardRef((e,t)=>{const{orientation:n,view:o,index:r,disabled:i=!1,disabledResize:l=!1,resizeThreshold:s=1,dividerRenderer:u=Kl,onDividerMouseDown:d,onDividerResizeStart:p,onDividerResize:x,onDividerResizeEnd:h,onDividerMouseUp:y,onDividerAutoFit:R,onPointerDown:C,...L}=e,J=T(C,[C]),O=T(R,[R]),I=n===Bt;let j=I?o.getVisibleColumns():o.getVisibleRows(),le=null;j.length>0&&(I?le=o.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:j[0],colEnd:j[j.length-1]}):o.getRangeCoordsBounds({rowStart:j[0],rowEnd:j[j.length-1],colStart:0,colEnd:0}),le=o.toClipBounds(le,Wt));const B=c.useRef(null),[oe,be]=c.useState(null),U=(z,K)=>I?z.clientX-K.clientX:z.clientY-K.clientY,N=o.getLayout(),Y=I?N.getColOffset(r+1):N.getRowOffset(r+1),k=bn({processTouch:!0,onPointerDown:z=>{if(J?.(z),!i&&!l){const K=I?N.getColOffset(r):N.getRowOffset(r),ee=Y-K;B.current={isResizing:!1,startSize:ee,index:r,view:o,orientation:n,onDividerMouseDown:d,onDividerResizeStart:p,onDividerResize:x,onDividerResizeEnd:h,onDividerMouseUp:y},be(B.current),d?.(r,ee)}z.stopPropagation(),z.preventDefault()},onPointerUp:(z,K,ee)=>{if(!B.current)return;B.current.isResizing&&B.current.onDividerResizeEnd?.(B.current.index,Math.max(0,B.current.startSize+U(z,ee)),B.current.startSize);const te=B.current;B.current=null,be(B.current),te.onDividerMouseUp?.(te.index)},onPointerMoveOrWait:(z,K,ee)=>{if(!B.current)return;const te=U(z,ee);B.current.isResizing?B.current.onDividerResize?.(B.current.index,Math.max(0,B.current.startSize+te),B.current.startSize):Math.abs(te)>Math.max(1,s)&&(B.current={...B.current,isResizing:!0},be(B.current),B.current.onDividerResizeStart?.(B.current.index,Math.max(0,B.current.startSize+te))),z.stopPropagation(),z.preventDefault()}}),E=T(()=>{O?.(r)},[r]);if(!le)return;const g=u({bounds:le,orientation:n,view:o,index:r,disabled:i,disabledResize:l,onAutoFit:E,onPointerDown:k,...L},t);if(!g)return;const{getPortalContainer:Z}=hi();let q=null;return oe&&oe.isResizing&&oe.index===r&&(q=No.createPortal(P.jsx("div",{style:{position:"absolute",cursor:I?_i:Ci,left:0,top:0,width:"100%",height:"100%"}}),Z(),"divider:"+r)),P.jsxs(P.Fragment,{children:[q,P.jsx("div",{className:fn("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${I?le.y:Y}px`,left:`${I?Y:le.x}px`,width:(I?0:le.width-1)+"px",height:(I?le.height-1:0)+"px",display:"flex"},tabIndex:-1,children:g})]})}));class Xl{naturalDimensions(t,n={}){const o=document.createElement("div");let r=n?.lineHeight??"1";!n?.lineHeight&&n.paintableText?.fontSize&&(r=Math.ceil(1.2*n.paintableText.fontSize)+"px");const i=document.createElement("div");i.style.visibility="hidden",i.style.position="absolute",i.style.textRendering="geometricprecision",i.style.display="inline-grid",i.style.overflowWrap="break-word",i.style.maxWidth=n.maxWidth?n.maxWidth+"px":"100%",i.style.lineHeight=r,i.style.letterSpacing=(n.paintableText?.letterSpacing??0)+"px",i.style.fontSize=n.paintableText?.fontSize?n.paintableText.fontSize+"px":"unset",i.style.fontFamily=n.paintableText?.fontSize?n.paintableText.fontFamily:"unset",i.style.fontWeight=n.paintableText?.fontWeight?""+n.paintableText.fontWeight:"400",i.style.fontStyle=n.paintableText?.fontStyle?n.paintableText.fontStyle:"normal",i.style.whiteSpace=n.paintableText?.wrap==="wrap"?"break-spaces":"pre",o.appendChild(i);const l=t.split(`
19
- `);for(let u=0;u<l.length;u++){let d=document.createElement("span");i.appendChild(d),d.textContent=l[u]}l.length!==0&&l[l.length-1].length!==0||i.appendChild(document.createElement("br")),document.body.appendChild(i);let s=i.getBoundingClientRect();return i.remove(),{width:s.width,height:s.height,maxLineHeight:1.2*(n.paintableText?.fontSize||1056/72)}}}const Mi=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),Yl=Mi(),Gl=c.memo(c.forwardRef((e,t)=>{const{editState:n=Yl,defaultTextStyle:o,onStartEdit:r,onChangeEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,containerBounds:d,setNaturalDimensions:p,onNavigate:x,textProperties:h,style:y,autoFocus:R,...C}=e,L=c.useRef(null),{width:J=0}=d??{},[O,I]=c.useState(()=>n);c.useEffect(()=>{I(n)},[n]);const j=h?.align||"left",le=h?.vAlign||"middle",B=h?.fill||"#040404",oe=h?.wrap||"wrap",be=h?.fontFamily||"Calibri",U=h?.fontSize||11,N=h?.fontWeight||400,Y=h?.fontStyle||"normal",k=O.dirty??O.clean??"";let E=2;const g=96*U/72,Z=1.2*g;le==="right"&&(E+=1);const q=c.useMemo(()=>new Xl().naturalDimensions(k,{maxWidth:oe==="wrap"?J-E:void 0,lineHeight:`${Z}px`,paintableText:{fontStyle:Y,wrap:oe,letterSpacing:-.25}}),[k,oe,E,g,be,N,Y,p,J]),z=c.useCallback(()=>q.maxLineHeight?q.maxLineHeight+"px":"1.2",[q]),[K,ee]=c.useState(z);c.useLayoutEffect(()=>{ee(z())},[d,q]),c.useLayoutEffect(()=>{p?.({width:oe==="wrap"?void 0:q.width+E,height:q.height})},[q,p]);const te=T(i,[i]),X=T(_=>{if(O.dirty===_)return;const Ce={...O};Ce.dirty=_,L.current,I(Ce),te?.(Ce)},[O]),Ve=T(_=>{if(O.editMode===_)return;const Ce={...O};Ce.editMode=_,I(Ce),te?.(Ce)},[O]),Be=T(()=>{try{return l?.(O),u?.(),!0}catch{return!1}},[l,O]),We=T(()=>{I(n),s?.(),u?.()},[s,n]),it=T(_=>{if(!L.current)return;if(_.isDefaultPrevented(),!(_.isTrusted||_.nativeEvent.ctrlKey||_.nativeEvent.metaKey||_.nativeEvent.altKey||_.nativeEvent.isComposing)&&qo.indexOf(_.nativeEvent.key)!==-1){const ue={...O};return ue.dirty=_.nativeEvent.key==="Backspace"?"":(ue.dirty??"")+_.key,I(ue),te?.(ue),void _.preventDefault()}const Ce=_.nativeEvent.shiftKey;if(_.which===qi)return _.preventDefault(),void We();if(_.which===Xi)return Ve(!0),void _.preventDefault();if(_.which===Qr&&(_.preventDefault(),Be()&&x?.(Ce?nt:ot)),_.which===Jr)return _.preventDefault(),void(Be()&&x?.(Ce?et:Ne));if(!O.editMode){let ue=null;switch(_.which){case ei:ue=et;break;case ni:ue=Ne;break;case ti:ue=nt;break;case oi:ue=ot}if(ue)return void Be()}},[O,x]),[ve,Ke]=c.useState(!R);c.useEffect(()=>{Ke(!1)},[]);const $=lo(t,()=>({startEdit(_){let Ce=_?.initialSelection;if(!Ce){const we=L.current.value.length??0;Ce={start:we,end:we,direction:"forward"}}L.current?.setSelectionRange(Ce.start,Ce.end,Ce.direction);const ue={...n,editMode:_?.editMode??!1};_?.text!==void 0&&(ue.dirty=_.text),ue.editMode===n.editMode&&ue.dirty===n.dirty||(I(ue),te?.(ue))},submitEdit:()=>Be(),cancelEdit(){We()},autoFocus(){L.current?.focus()},getLineHeight:()=>q?.maxLineHeight??Z,dispatchEvent:_=>L.current.dispatchEvent(_)}),[n,r]);return P.jsx("div",{ref:$,...C,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:q.height,maxWidth:"100%",maxHeight:"100%",...y},children:P.jsx("textarea",{spellCheck:"false",ref:L,value:k,autoFocus:!1,disabled:ve,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${g}px`,fontFamily:`${be}`,fontWeight:`${N}`,fontStyle:`${Y}`,padding:"0px",marginRight:j==="right"?"3px":"0px",marginLeft:j==="left"?"2px":"0px",lineHeight:K,height:q.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:j,background:"transparent",color:B,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:oe==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:_=>{X(_.target.value)},onDoubleClick:_=>{_.isTrusted},onMouseDown:_=>{Ve(!0)},onKeyDown:it})})})),Zl=c.memo(e=>{const{value:t,view:n,bounds:o,range:r,zoom:i,children:l,style:s,...u}=e,d=s?.fontSize||1056/72;return P.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:d,...s},...u,children:t})});exports.BaseGrid=Yo,exports.DefaultCellEditor=Gl,exports.DefaultCellRenderer=Zl,exports.DefaultHeaderDivider=Ii,exports.FillHandle=Wo,exports.Grid=Go,exports.HeaderDivider=ql,exports.HeaderRenderer=Ei,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=Wt,exports.STANDARD_KEY_CHARS=qo,exports.SVGLine=Vo,exports.SVGRect=mi,exports.ScrollableGrid=Si,exports.Selection=Xo,exports.TouchSelectHandle=Qn,exports.defaultSelectionRenderer=zr,exports.getDefaultStringEditState=Mi,exports.safeSelectionCoords=$t,exports.useCellLayout=wi,exports.useHeaderSelection=({gridRef:e,gridMainRef:t,orientation:n=en,headerCount:o,selectionPolicy:r="multiple",newSelectionMode:i="clear",alwaysScrollToActiveCoords:l=!0,onDragStart:s,onDragEnd:u,pointerDownInterceptor:d,pointerMoveInterceptor:p,onPointerUp:x,newSelection:h,modifySelection:y,appendSelection:R,clearSelections:C})=>{const L=o??((n===en?e.current?.rowCount:e.current?.columnCount)||0),J=c.useRef(null),O=c.useRef(null),I=c.useRef(!1),j=c.useRef(null),le=c.useCallback(E=>n===Bt?{rowIndex:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:0},[n]),B=c.useCallback(E=>n===Bt?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:E.colIndex}:{rowIndex:E.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),oe=E=>{O.current=B(E),y(O.current,J.current)},be=c.useCallback((E,g)=>{if(!e.current)return;const Z=e.current.getViewFromClient(E,g)?.getCellCoordsFromClient(E,g);return Z?(n===Bt?Z.rowIndex=t.current.getViewport().rowStart:Z.colIndex=t.current.getViewport().colStart,Z):void 0},[]),U=c.useCallback((E,g=!1)=>{let Z=E;return g||(Z={...E},n===en?delete Z.colIndex:delete Z.rowIndex),t.current?.scrollCellCoordsIntoView(Z)},[n]),N=T(u,[u]),Y=T(s,[s]),k=c.useMemo(()=>({onPointerDown:E=>{if(!e||!e.current||E.nativeEvent.defaultPrevented)return;const g=be(E.nativeEvent.clientX,E.nativeEvent.clientY);if(!g)return;E.nativeEvent.which;const Z=E.nativeEvent.shiftKey,q=E.nativeEvent.ctrlKey||E.nativeEvent.metaKey;if(d?.(E,g)===!1)return;Y?.(),I.current=!0;const z=t.current?.getViewFromClient(E.nativeEvent.clientX,E.nativeEvent.clientY),K=((ee,te)=>n===Bt?{...ee,rowIndex:te.rowStart}:{...ee,colIndex:te.colStart})(g,z.getVisibleRangeCoords());if(Z)oe(g);else{if(q)return((ee,te=ee,X)=>{J.current=le(ee),O.current=B(te),R(J.current,O.current,X)})(g,g,K),void(l&&U(K,!0));((ee,te=ee,X)=>{J.current=le(ee),O.current=B(te),h(J.current,O.current,X)})(g,g,K),oe(g),l&&U(K,!0)}},onPointerMoveOrWait:St.throttle(E=>{if(!I.current||!e?.current)return;const g=be(E.clientX,E.clientY);if(g&&p?.(E,g)!==!1){if(G.isEqualCells(j.current,g))return C();oe(g),U(g)}},60),onPointerUp:E=>{I.current=!1,N?.(),x?.(E)},processTouch:!0,consumeTouch:!0}),[r,l,L,i,C,d,x]);return{onPointerDown:T(bn(k),[]),getCellCoordsFromClient:be}},exports.useKeyboardEditorOverlay=e=>{const{view:t,canEdit:n=Tl,getCellEditor:o,onBeforeStartEdit:r,onStartEdit:i,onSubmitEdit:l,onCancelEdit:s,onDoneEdit:u,isEditorStartKeyEvent:d=Pl,isEditorStartPointerEvent:p=Ol,containerProps:x,borderStrokeFill:h,borderStrokeWidth:y=2,getRangeCoords:R=null,activeCoords:C,alignment:L=On.Left}=e,[J,O]=c.useState(!1),[I,j]=c.useState(void 0),le=T(($,_,Ce,ue,we,ze)=>{if(!_)return null;const lt=we?.(_,$),It=$.getRangeCoordsBounds(lt),st=$.toClipBounds(It),Ut=It,xt=$.getZoom();if(!st)return null;Ce&&(Ce*=xt),ue&&(ue*=xt);let M=Ut,xe=!1;if(Ce!==void 0){let Ge={...lt},Qt=0;for(;!xe&&M.width<=Ce&&Qt<20;){Qt++,Qt>19&&console.warn("max width reached");const Yt=$.getTotalRangeCoords(),Et=$.getLayout();ze===On.Left?Ge.colEnd+1<Yt.colEnd?Ge.colEnd=Et.getColIndex(M.x+Ce):xe=!0:ze===On.Right?Ge.colStart-1>=0?Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)):xe=!0:ze===On.Center&&Ge.colEnd+1<Yt.colEnd&&Ge.colStart-1>=0?(Ge.colStart=Et.getColIndex(M.x-(Ce-M.width)/2),Ge.colEnd=Et.getColIndex(M.x+M.width+(Ce-M.width)/2)):xe=!0,xe||(M=$.getRangeCoordsBounds(Ge))}}M.height=Ut.height,ue!==void 0&&(M.height=Math.max(ue+1,Ut.height));const{width:Ye,height:ft}=$.getViewportSize();return{x:M.x??0,y:M.y??0,height:Math.min(ft-M.y,M.height)+1,width:Math.min(Ye-M.x,M.width)+1}},[L]),B=T(n,[n]),oe=c.useCallback(()=>{t?.getStage()?.focus()},[t]),be=c.useRef(null),U=T($=>{r?.($),te(),O(!0),be.current=null},[r]),N=T($=>{i?.($.coords)},[i]),Y=T($=>{$.isSubmitted||$.isCancelled||(g.current.isEditorClosed=!0,oe(),$.isCancelled=!0,s?.($.coords),te())},[s]),k=T($=>{if($.isSubmitted||$.isCancelled)return!1;try{return be.current=$.coords,$.isEditorClosing=!0,$.isSubmitted=!0,$.isEditorSubmitted||($.isEditorSubmitted=!0,$.editorRefs[0]?.submitEdit?.()),$.coords,l?.($.coords),$.isEditorClosed=!0,oe(),te(),!0}catch(_){throw $.isEditorClosing=!1,$.isSubmitted=!1,_}},[l]),E=T($=>{O(!1),u?.($.coords),te()},[u]),g=c.useRef(null),Z=c.useRef(null),q=c.useRef(null),z=c.useRef([]),[K,ee]=c.useReducer($=>$+1,0),te=c.useCallback($=>{$&&z.current.push($),ee()},[]),X=T($=>{if($.defaultPrevented||$.isSynthetic||!t)return;const _=t?.getCellCoordsFromClient($.clientX,$.clientY);_&&te({eventType:"pointer",event:$,coords:_})},[t]),Ve=T($=>{const _=$.nativeEvent;X(_)},[t]),Be=T($=>{if($.defaultPrevented||$.isSynthetic||!t?.getStage())return;const _=Z.current;d($,_)&&($.stopPropagation(),$.preventDefault()),$.key,te({eventType:"keyboard",event:$,coords:_})},[t]);c.useLayoutEffect(()=>{const $=(ue,we)=>{const ze=we?.cell??ue;if(!ze)return null;const lt=ze;if(!B(ze))return null;U?.(ze);const It=St.uuidV4();we=Object.freeze({autoFocus:!0,...we}),q.current=ze;const st={coords:lt,startEvent:we,uuid:It,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:Ut=>{st.isMounted||(st.isMounted=!0,te())},onUnmount:Ut=>{if(st.editorRefs.length===0){const xt=()=>{st.isMounted=!1,te()};if(document.activeElement!==document.body)xt();else{const M=xe=>{xe.defaultPrevented||xe.target!==document.body||Be(xe)};window.addEventListener("keydown",M,!0),t.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",M),xt()},{once:!0}),oe()}}}};return st};if(z.current.length<=0&&!g.current)return;const _=z.current[0];Rr(_),(ue=>{const we=[],ze=ue?.length??0;for(let lt=0;lt<ze;lt++){const It=ue[lt];we.push(Rr(It))}})(z.current),g.current,g.current;let Ce=g.current;if(g.current){if(g.current.isDone)g.current=null;else if(g.current.isSubmitted||g.current.isCancelled){if(g.current.isMounted)return;g.current.isDone||(E(g.current),g.current.isDone=!0)}}if(_){if(_.eventType==="start"){const ue=_,we=ue.startEvent?.cell??Z.current;g.current&&G.isEqualCells(g.current.coords,we)||(g.current=$(we,ue.startEvent))}else if(_.eventType==="keyboard"){const ue=_.event;if(g.current){let we=!1;switch(ue.which){case ei:case ni:case ti:case oi:case Qr:case Jr:we=!0}if(!we){g.current.events.push(_);for(let ze=0;ze<g.current.editorRefsDispatchEditorEvent.length;ze++)g.current.editorRefsDispatchEditorEvent[ze](_)}}else if(d(ue,_.coords)){let we;const ze=$(we?.cell??Z.current,we);ze&&ze.events.push(_),g.current=ze}}else if(_.eventType==="pointer"){const ue=_.event;if(g.current){g.current.events.push(_);for(let we=0;we<g.current.editorRefsDispatchEditorEvent.length;we++)g.current.editorRefsDispatchEditorEvent[we](_)}else{const we=_?.coords??Z.current,ze=p(ue,we);if(ze){let lt;typeof lt!="boolean"&&(lt=ze);const It=$(we,lt);It&&It.events.push(_),g.current=It}}}else if(_.eventType==="submit"){if(g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;k(g.current)}}else if(_.eventType==="cancel"){if(g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;Y(g.current)}}else if(_.eventType==="coordsChange"){const ue=_;if(Z.current=ue.activeCoords,g.current,g.current&&!g.current.isSubmitted&&!g.current.isCancelled){if(!g.current.isMounted)return;try{k(g.current)}catch{}}}}z.current.length>0&&(z.current.shift(),te()),z.current.length===0&&(!g.current||g.current.isEditorClosing||g.current.isEditorClosed?!g.current&&Ce&&oe():g.current.isMounted&&!g.current.isStarted&&(g.current.isStarted=!0,g.current.startEvent.autoFocus&&(typeof g.current.startEvent.autoFocus=="string"?g.current.editorRefs[0]?.autoFocus(g.current.startEvent.autoFocus):g.current.editorRefs[0]?.autoFocus()),N?.(g.current),requestAnimationFrame(()=>{t&&g.current?.coords&&t.scrollCellCoordsIntoView(g.current.coords)})))},[K]),c.useEffect(()=>{q.current=C;const $=g.current?.coords;G.isEqualCells($,C)||(g.current&&(g.current.isEditorClosing=!0),te({eventType:"coordsChange",activeCoords:C}))},[C]);const We=c.useCallback($=>{Be($.nativeEvent)},[]),{width:it=0,height:ve=0}=I??{width:0,height:0},Ke=T(o,[o]);return{overlay:T($=>{if(!g.current||g.current.isEditorClosed)return g.current,null;g.current.coords;let _=le($,g.current.coords,it,ve,R,L),Ce=!0;_&&_.width!==0&&_.height!==0||(_={x:0,y:0,width:it,height:it},Ce=!1);const ue=$.getZoom(),we={containerBounds:{x:0,y:0,width:_.width/ue,height:_.height/ue},setNaturalDimensions:j,zoom:ue};return P.jsx(Ll,{session:g.current,refLatestCoords:q,handleSubmitEdit:k,handleCancelEdit:Y,cellBounds:_,borderStrokeWidth:y,borderStrokeFill:h,isInBounds:Ce,getCellEditor:Ke,propsEditor:we,alignment:L,...x},"editor:"+g.current.uuid)},[o,R,K,it,ve,L,y,h]),startEdit:c.useCallback($=>{te({eventType:"start",startEvent:$})},[]),submitEdit:c.useCallback(()=>{te({eventType:"submit"})},[]),cancelEdit:c.useCallback(()=>{te({eventType:"cancel"})},[]),onKeyboardEvent:We,onPointerEvent:Ve,onKeyboardEventNative:Be,onPointerEventNative:X,isEditing:J}},exports.useSelection=({gridRef:e,commands:t,layout:n,selection:o,onSelectionChange:r,onSelectionDragStart:i,onSelectionDragEnd:l,selectionPolicy:s="multiple",newSelectionMode:u="clear",allowDeselectSelection:d=!0,onFillPreview:p,onFillCancel:x,onFillDone:h,onFill:y,disableFillDrag:R=!y,fillHandleBorderColor:C="white",hiddenRowsAt:L,hiddenColumnsAt:J,isContentfulCell:O,contentfulCellFinder:I=jl,getDataCoords:j,alwaysScrollToActiveCoords:le=!1,selectionBounds:B,pointerDownInterceptor:oe,pointerMoveInterceptor:be,mergedRanges:U,canSelectionSpanMergedCells:N=Wl,onMoveDragStart:Y,onMoveDragUpdate:k,onMoveDragEnd:E,onMoveDragDone:g,selectionRenderer:Z=zr,disableMoveDrag:q=!E,getCellCoordsAsRangeCoords:z=G.cellToRange,moveDragHitSize:K=6,moveDragOutlineSize:ee=4,selectionBackgroundColor:te="rgba(16, 124, 65, 0.1)",selectionBorderColor:X="rgb(33, 115, 70)",selectionRemoveBorderColor:Ve="rgb(255, 0, 0)",selectionRemoveBackgroundColor:Be="rgba(250, 10, 10, 0.1)",disableTouchSelection:We=!1,touchSelectHandleProps:it})=>{const ve=c.useCallback(()=>({top:B?.top??0,left:B?.left??0,bottom:e.current?.rowCount-1||0,right:e.current?.columnCount-1||0}),[]),Ke=T(y,[y]),$=T(p,[p]),_=T(x,[x]),Ce=T(h,[h]),ue=T(O,[O]),we=T(Z,[Z]),ze=T((a,f=!1)=>io(a,f,n.getRowOffset,f?ve().bottom:ve().top),[n?.getRowOffset]),lt=T(L??ze,[L]),It=T((a,f=!1)=>io(a,f,n.getColOffset,f?ve().right:ve().left),[n?.getColOffset]),st=T(J??It,[J]),[Ut,xt]=c.useState(()=>$t(o)),M=c.useMemo(()=>$t(Ut),[Ut]),xe=c.useRef(M),Ye=c.useRef(!0);c.useLayoutEffect(St.throttle(()=>{xt(a=>{Ye.current=!0;const f=$t(o);return G.isEqualSelectionCoords(f,a)?a:f})},0),[o]),c.useLayoutEffect(()=>{xe.current=M},[M]),c.useEffect(()=>{Ye.current||!r||G.isEqualSelectionCoords(o,M)||r(M)},[M]);const ft=c.useCallback(a=>{xt(f=>{Ye.current=!1,f=$t(f);let m=typeof a=="function"?a(f.ranges):a??Ho;if(G.isEqualRangesArrays(m,f.ranges))return f;let w=Math.max(m.length?0:-1,Math.min(f.rangeIndex,m.length-1)),v=f.cell;w===-1||G.isCellWithinRange(v,m[w])||(v={rowIndex:m[w].rowStart,colIndex:m[w].colStart}),m.length===1&&G.isSingleCell(m[0])&&G.isCellWithinRange(v,m[0])&&(m=[],w=-1);const H={cell:v,ranges:m,rangeIndex:w};return G.isEqualSelectionCoords(H,f)?f:H})},[]),Ge=T(a=>{xt(f=>{Ye.current=!1,f=$t(f);const m=a??vi,w=z(m);if(!G.isSingleCell(w)&&f.ranges.length===0)return{ranges:[w],rangeIndex:0,cell:m};if(G.isEqualCells(m,f.cell))return f;let v=f.ranges,H=f.rangeIndex;f.ranges.length===1&&(G.isSingleCell(f.ranges[0])&&G.isCellWithinRange(m,f.ranges[0])||!G.isCellWithinRange(m,f.ranges[0]))&&(v=[],H=-1);const S={ranges:v,rangeIndex:H,cell:m};return G.isEqualSelectionCoords(S,f)?f:S})},[z]),[Qt,Yt]=c.useState(null),[Et,tn]=c.useState(null),Xt=c.useRef(null),[Oe,Ft]=c.useState(null),pt=c.useRef(null),jt=c.useRef(null),[wn,nn]=c.useState(null),Fe=c.useRef(null),Q=c.useRef(null),Ze=c.useRef(U);c.useEffect(()=>{Ze.current=U},[U]);const He=T((a,f={inline:"nearest",block:"nearest"})=>{let{rowIndex:m,colIndex:w}=a;m===void 0&&M?.cell&&(m=M.cell.rowIndex),w===void 0&&M?.cell&&(w=M.cell.colIndex),m!==void 0&&w!==void 0&&e.current?.scrollCellCoordsIntoView({rowIndex:m,colIndex:w},f)},[M]),ct=c.useCallback(a=>{const f=ve();return a.rowIndex<f.top||a.colIndex<f.left||a.colIndex>f.right||a.rowIndex>f.bottom},[]),Ee=T((a,f)=>{if(!e?.current)return null;const m={rowStart:Math.min(a.rowIndex,f.rowIndex),colStart:Math.min(a.colIndex,f.colIndex),rowEnd:Math.max(a.rowIndex,f.rowIndex),colEnd:Math.max(a.colIndex,f.colIndex)};if(N?.(m))return m;const v=z(a),H=z(f),S={rowStart:Math.min(v.rowStart,H.rowStart),colStart:Math.min(v.colStart,H.colStart),rowEnd:Math.max(v.rowEnd,H.rowEnd),colEnd:Math.max(v.colEnd,H.colEnd)};let de;return typeof Ze.current=="function"?de=Ze.current(S):U&&(de=U),de?G.extendRangeToUnionRanges(S,de):S},[N,z]),Te=T((a,f,m)=>{const w=a.ranges.length>0?a.ranges[a.rangeIndex]:{rowStart:a.cell.rowIndex,colStart:a.cell.colIndex,rowEnd:a.cell.rowIndex,colEnd:a.cell.colIndex},v={rowStart:Math.min(f.rowIndex??w.rowStart,m.rowIndex??w.rowStart),colStart:Math.min(f.colIndex??w.colStart,m.colIndex??w.colStart),rowEnd:Math.max(f.rowIndex??w.rowEnd,m.rowIndex??w.rowEnd),colEnd:Math.max(f.colIndex??w.colEnd,m.colIndex??w.colEnd)},H={rowIndex:v.rowStart,colIndex:v.colStart},S={rowIndex:v.rowEnd,colIndex:v.colEnd};if(!(ct(H)||ct(S)))return Ee(H,S)},[Ee]),tt=T((a,f,m)=>{if(s==="single"||!xe.current)return;const w=Te(xe.current,a,f??xe.current.cell);if(!w)return;const v=xe.current.rangeIndex;ft(H=>H.length?H.map((S,de)=>v===de?w:S):[w]),m&&w&&Ge({colIndex:w.colStart,rowIndex:w.rowStart})},[]),Je=c.useCallback((a,f,m)=>{if(!xe.current)return;a={...xe.current?.cell,...a},f=f??a;const w=Te(xe.current,a,f);if(!w)return;const v={rowIndex:w.rowStart,colIndex:w.colStart},H={...v,...m};u==="clear"?(Fe.current=H,Gt()):u==="modify"?tt(v):Le(v),Ge(H)},[]),Le=c.useCallback((a,f=a,m)=>{s!=="multiple"||!a||ct(a)||ct(f)||xt(w=>{Ye.current=!1,w=$t(w);const v=Ee(a,f);if(!v)return w;let H=w.ranges.length>0?[...w.ranges]:[Ee(w.cell,w.cell)];H.push(v);const S={ranges:H,cell:{rowIndex:v.rowStart,colIndex:v.colStart,...m},rangeIndex:H.length-1};return G.isEqualSelectionCoords(S,w)?w:S})},[]),Gt=()=>{ft(Ho)},_t=ge.detectIt().primaryInput==="touch",Qe=c.useRef(null),Ct=c.useRef(null),Rt=c.useRef(null),on=c.useMemo(()=>({onPointerDown:a=>{if(!e||!e.current)return!1;const f=a.nativeEvent,m=e.current.getViewFromClient(f.clientX,f.clientY);if(f.pointerType==="touch"||f.type==="touchstart")return Ct.current={topLeft:m.getScrollTopLeft(),point:{x:f.clientX,y:f.clientY}},!0;const w=m.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!w)return!1;Qe.current={anchor:m.getAnchor(),coords:w},Q.current=null;const v=a.nativeEvent.which===yr;if(v&&G.indexOfCoords(w,M.ranges)!==-1)return!1;const H=a.nativeEvent.shiftKey,S=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,de=S,ne=d,re=M.ranges.length>0,pe=S&&ne;if(oe?.(a,w,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Pe=!v&&s!=="single";if(H)return tt(w),Pe;const ae=G.isEqualCells(w,M.cell);if(de){if(ae&&(!pe||!re))return Pe;if(S&&G.indexOfCoords(w,M.ranges)!==-1&&ne){pt.current=w;const ie=Ee(w,w);return jt.current=ie,Ft(ie),Pe}return Le(w),Pe}le&&He(w),ae&&M.ranges.length===0||Je(w)},onPointerMoveOrWait:St.throttle((a,f)=>{if(!e?.current||a.pointerType==="touch"||a.type==="touchmove"||!Qe.current)return;const m=Qe.current.anchor;let w=e.current.getViewFromLocation(m),v=w.getCellCoordsFromClient(a.clientX,a.clientY);if(!G.isEqualCells(v,Qe.current?.coords)&&(Qe.current={anchor:m,coords:v},v&&be?.(a,v,xe.current)!==!1)){if(pt.current){const H={rowStart:Math.min(v.rowIndex,pt.current.rowIndex),colStart:Math.min(v.colIndex,pt.current.colIndex),rowEnd:Math.max(v.rowIndex,pt.current.rowIndex),colEnd:Math.max(v.colIndex,pt.current.colIndex)},S={rowIndex:H.rowStart,colIndex:H.colStart},de={rowIndex:H.rowEnd,colIndex:H.colEnd};if(ct(S)||ct(de))return;const ne=Ee(S,de);jt.current=ne,Ft(ne)}else tt(v);Rt.current=f,Gn(w,v,e)}},60),onPointerUp:a=>{if(Qe.current=null,a.pointerType==="touch"||a.type==="touchend"){if(Ct.current){const m=e.current.getViewFromClient(Ct.current.point.x,Ct.current.point.y),w=m.getScrollTopLeft();if(w.left===Ct.current.topLeft.left&&w.top===Ct.current.topLeft.top){const v=m.getCellCoordsFromClient(Ct.current.point.x,Ct.current.point.y);Je(v)}}return Ct.current=null,void(Qe.current=null)}try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const f=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let w=[],v=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const ne=m.ranges[de];if(G.isRangesIntersect(ne,f)){const re=St.subtractRect({top:ne.rowStart,left:ne.colStart,bottom:ne.rowEnd+1,right:ne.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let pe=0;pe<re.length;pe++){const Pe={rowStart:re[pe].top,colStart:re[pe].left,rowEnd:re[pe].bottom-1,colEnd:re[pe].right-1};w.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(v=w.length-1)}}else w.push(ne);w.length>0&&v===-1&&G.isCellWithinRange(m.cell,ne)&&(v=w.length-1,H={rowIndex:w[w.length-1].rowStart,colIndex:w[w.length-1].colStart})}const S={cell:H,rangeIndex:v,ranges:w};return G.isEqualSelectionCoords(S,m)?m:S})},processTouch:!0,consumeTouch:!1}),[M,s,d,le,u]),so=T(bn(on),[]),co=c.useMemo(()=>({onSelectionPointerDown:(a,f,m,w,v=M.cell,H=le,S=a.nativeEvent.shiftKey,de=!1)=>{if(!e||!e.current)return!1;a.stopPropagation(),a.preventDefault(),a.nativeEvent.stopImmediatePropagation();const ne=m??e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),re=w??ne.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!re)return!1;Qe.current={anchor:ne.getAnchor(),coords:re},Q.current=null;const pe=a.nativeEvent.which===yr;if(pe&&G.indexOfCoords(re,M.ranges)!==-1)return!1;const Pe=a.nativeEvent.ctrlKey||a.nativeEvent.metaKey,ae=Pe,ie=d,bt=M.ranges.length>0,F=Pe&&ie;if(oe?.(a,re,M)===!1)return!1;i?.(xe.current,a.nativeEvent);const Re=!pe&&s!=="single";if(S)return tt(re,v,de),Re;const Mt=G.isEqualCells(re,v);if(ae){if(Mt&&(!F||!bt))return Re;if(F&&G.indexOfCoords(re,M.ranges)!==-1&&ie){pt.current=re;const Me=Ee(re,re);return jt.current=Me,Ft(Me),Re}return Le(re),Re}H&&He(re),Mt&&M.ranges.length===0||Je(re)},onSelectionPointerMoveOrWait:(a,f,m,w,v,H=M.cell,S=!0,de=!1)=>{if(!e?.current||(a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation(),!Qe.current))return;const ne=Qe.current.anchor;let re=w??e.current.getViewFromLocation(ne),pe=v??re.getCellCoordsFromClient(a.clientX,a.clientY);if(!G.isEqualCells(pe,Qe.current?.coords)&&(Qe.current={anchor:ne,coords:pe},pe&&be?.(a,pe,xe.current)!==!1)){if(pt.current){const Pe={rowStart:Math.min(pe.rowIndex,pt.current.rowIndex),colStart:Math.min(pe.colIndex,pt.current.colIndex),rowEnd:Math.max(pe.rowIndex,pt.current.rowIndex),colEnd:Math.max(pe.colIndex,pt.current.colIndex)},ae={rowIndex:Pe.rowStart,colIndex:Pe.colStart},ie={rowIndex:Pe.rowEnd,colIndex:Pe.colEnd};if(ct(ae)||ct(ie))return;const bt=Ee(ae,ie);jt.current=bt,Ft(bt)}else tt(pe,H,de);S&&Gn(re,pe,e)}},onPointerUp:a=>{Qe.current=null,a.stopPropagation(),a.preventDefault(),a.stopImmediatePropagation();try{l?.(xe.current,a)}catch(m){console.warn(m)}if(!pt.current)return;const f=jt.current;pt.current=null,jt.current=null,Ft(null),xt(m=>{if(Ye.current=!1,(m=$t(m)).ranges.length===0)return m;let w=[],v=-1,H=m.cell;for(let de=0;de<m.ranges.length;de++){const ne=m.ranges[de];if(G.isRangesIntersect(ne,f)){const re=St.subtractRect({top:ne.rowStart,left:ne.colStart,bottom:ne.rowEnd+1,right:ne.colEnd+1},{top:f.rowStart,left:f.colStart,bottom:f.rowEnd+1,right:f.colEnd+1});for(let pe=0;pe<re.length;pe++){const Pe={rowStart:re[pe].top,colStart:re[pe].left,rowEnd:re[pe].bottom-1,colEnd:re[pe].right-1};w.push(Pe),G.isCellWithinRange(m.cell,Pe)&&(v=w.length-1)}}else w.push(ne);w.length>0&&v===-1&&G.isCellWithinRange(m.cell,ne)&&(v=w.length-1,H={rowIndex:w[w.length-1].rowStart,colIndex:w[w.length-1].colStart})}const S={cell:H,rangeIndex:v,ranges:w};return G.isEqualSelectionCoords(S,m)?m:S})}}),[M,s,d,le,u]),ut=T((a,f=!1,m=!1,w=0)=>{if(!e.current||!M.cell)return;let v=M.cell,H=M.cell;if(f&&M.ranges.length>0){const F=M.ranges[M.rangeIndex],Re=M.cell;switch(a){case nt:H={rowIndex:Re.rowIndex===F.rowStart?F.rowEnd:F.rowStart,colIndex:F.colEnd},v={rowIndex:Re.rowIndex===F.rowStart?F.rowStart:F.rowEnd,colIndex:F.colStart};break;case ot:H={rowIndex:Re.rowIndex===F.rowEnd?F.rowStart:F.rowEnd,colIndex:F.colEnd},v={rowIndex:Re.rowIndex===F.rowEnd?F.rowEnd:F.rowStart,colIndex:F.colStart};break;case et:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colStart?F.colEnd:F.colStart},v={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colStart?F.colStart:F.colEnd};break;case Ne:H={rowIndex:F.rowEnd,colIndex:Re.colIndex===F.colEnd?F.colStart:F.colEnd},v={rowIndex:F.rowStart,colIndex:Re.colIndex===F.colEnd?F.colEnd:F.colStart}}}const S=z(H);let{rowStart:de,colStart:ne}=S;const re=ve();if(Q.current)switch(a){case nt:case ot:Q.current.colIndex>=S.colStart&&Q.current.colIndex<=S.colEnd&&(ne=Q.current.colIndex);break;case et:case Ne:Q.current.rowIndex>=S.rowStart&&Q.current.rowIndex<=S.rowEnd&&(de=Q.current.rowIndex)}if(!w){switch(a){case nt:de=Ue(lt,Math.max(S.rowStart-1,re.top),a);break;case ot:de=Ue(lt,Math.min(S.rowEnd+1,re.bottom),a);break;case et:ne=Ue(st,Math.max(S.colStart-1,re.left),a);break;case Ne:ne=Ue(st,Math.min(S.colEnd+1,re.right),a)}if(m)switch(a){case nt:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.max(re.top,lt(re.top,!1)));break;case ot:de=I({...H,colIndex:M.cell.colIndex},ue,lt,a,!1,Math.min(re.bottom,re.bottom-lt(re.bottom,!0)));break;case et:ne=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.max(re.left,st(re.left,!1)));break;case Ne:ne=I({...H,rowIndex:M.cell.rowIndex},ue,st,a,!1,Math.min(re.right,re.right-st(re.right,!0)))}}let pe=null;if(w){let F=0;switch(a){case nt:F=n.getRowOffset(de+1),de=Math.max(re.top,n.getRowIndex(F-w)),pe={top:n.getRowOffset(de+1)-(F-e.current.getScrollPosition().top)};break;case ot:F=n.getRowOffset(de),de=Math.min(re.bottom,n.getRowIndex(F+w)),pe={top:n.getRowOffset(de)-(F-e.current.getScrollPosition().top)};break;case et:F=n.getColOffset(ne+1),ne=Math.max(re.left,n.getColIndex(F-w)),pe={left:n.getColOffset(ne+1)-(F-e.current.getScrollPosition().left)};break;case Ne:F=n.getColOffset(ne),ne=Math.min(re.right,n.getColIndex(F+w)),pe={left:n.getColOffset(ne)-(F-e.current.getScrollPosition().left)}}}const Pe={rowIndex:de,colIndex:ne},ae=z(Pe),ie={rowIndex:ae.rowStart,colIndex:ae.colStart};f||(Q.current=Pe);const bt=G.isEqualCells(Fe.current,ie)&&G.isEqualCells(Fe.current,v);if(f&&!bt?tt(ie,v):Je(ie),pe)e.current.scrollTo(pe);else{if(f&&Fe.current){const F=ve();if(a===Ne&&Fe.current.colIndex===F.left||a===et&&Fe.current.colIndex===F.right||a===nt&&Fe.current.rowIndex===F.bottom||a===ot&&Fe.current.rowIndex===F.top)return}a===et||a===Ne?He({colIndex:Pe.colIndex}):a!==nt&&a!==ot||He({rowIndex:Pe.rowIndex})}},[M,z]),Zt=T(a=>{if(!e.current)return;if(M.ranges.length===0)return void ut(a);const f=z(M.cell);if(G.isEqualRangesArrays([f],M.ranges))return void ut(a);const m=Fo(M,a,z,lt,st);xt(w=>{Ye.current=!1,w=$t(w);const v={...w,cell:m.cell,rangeIndex:m.rangeIndex};return G.isEqualSelectionCoords(v,w)?w:v}),m.cell&&He(m.cell)},[M,z]),ao=c.useCallback(()=>{const a=ve();tt({rowIndex:a.top},{rowIndex:a.bottom})},[]),uo=c.useCallback(()=>{const a=ve();tt({colIndex:a.left},{colIndex:a.right})},[]),an=T(()=>{M.cell&&e?.current&&He(M.cell)},[M.cell]),An=c.useCallback((a=!1)=>{const f={rowIndex:ve().top};a?tt(f):Je(f),He(f)},[]),$n=c.useCallback((a=!1)=>{const f={rowIndex:ve().bottom};a?tt(f):Je(f),He(f)},[]),_n=c.useCallback((a=!1)=>{const f={colIndex:ve().left};a?tt(f):Je(f),He(f)},[]),mn=c.useCallback((a=!1)=>{const f=ve(),m={rowIndex:f.top,colIndex:f.left};a?tt(m):Je(m),He(m)},[]),Cn=c.useCallback((a=!1)=>{const f=ve(),m={colIndex:j?.()?.colEnd??f.right};a?tt(m):Je(m),He(m)},[j]),un=c.useCallback((a=!1)=>{const f=ve(),m={rowIndex:j?.()?.rowEnd??f.bottom,colIndex:j?.()?.colEnd??f.right};a?tt(m):Je(m),He(m)},[j]),In=T(a=>{if(!e.current||M.ranges.length<=1)return;const f=a===et||a===nt;let m=M.rangeIndex+(f?-1:1);m<0?m=M.ranges.length-1:m>M.ranges.length-1&&(m=0);const w=M.ranges[m],v=Fo({cell:{rowIndex:w.rowEnd,colIndex:w.colEnd},rangeIndex:0,ranges:[w]},Ne,z,lt,st);xt(H=>{Ye.current=!1,H=$t(H);const S={...H,cell:v.cell,rangeIndex:m};return G.isEqualSelectionCoords(S,H)?H:S}),v.cell&&He(v.cell)},[M,z]),ho=T(()=>{const a=Pr(M);xt(f=>{Ye.current=!1,f=$t(f);const m={...f,visibleSelection:a};return G.isEqualSelectionCoords(m,f)?f:m}),a.cell&&He(a.cell)},[M,z]),fo=T(()=>{if(!e.current||M.ranges.length===0)return;const a=M.cell,f=M.ranges[M.rangeIndex],m=Pr({cell:a,rangeIndex:0,ranges:[f]}),w=m.ranges[m.rangeIndex];let v;v=w.rowStart===a.rowIndex&&w.colStart===a.colIndex?{rowIndex:w.rowStart,colIndex:w.colEnd}:w.rowStart===a.rowIndex&&w.colEnd===a.colIndex?{rowIndex:w.rowEnd,colIndex:w.colStart}:w.rowEnd===a.rowIndex&&w.colStart===a.colIndex?{rowIndex:w.rowEnd,colIndex:w.colEnd}:{rowIndex:w.rowStart,colIndex:w.colStart},xt(H=>{H=$t(H);const S={...H,cell:v};return G.isEqualSelectionCoords(S,H)?H:S}),v&&He(v)},[M,z]),Bn=c.useCallback((a=!1)=>{ut(ot,a,!1,e.current.getDimensions().containerHeight)},[]),Kt=c.useCallback((a=!1)=>{ut(nt,a,!1,e.current.getDimensions().containerHeight)},[]),Fn=c.useCallback((a=!1)=>{ut(Ne,a,!1,e.current.getDimensions().containerWidth)},[]),Mn=c.useCallback((a=!1)=>{ut(et,a,!1,e.current.getDimensions().containerWidth)},[]),Vn=c.useCallback(()=>{Zt(et)},[]),Wn=c.useCallback(()=>{Zt(Ne)},[]),po=c.useCallback(()=>{Zt(nt)},[]),go=c.useCallback(()=>{Zt(ot)},[]),Rn=c.useCallback(()=>{In(et)},[]),wo=c.useCallback(()=>{In(Ne)},[]),mo=c.useCallback(()=>{fo()},[]),Hn=c.useCallback(()=>{ut(et,!1,!1)},[]),b=c.useCallback(()=>{ut(et,!0,!1)},[]),D=c.useCallback(()=>{ut(et,!1,!0)},[]),A=c.useCallback(()=>{ut(et,!0,!0)},[]),V=c.useCallback(()=>{ut(Ne,!1,!1)},[]),W=c.useCallback(()=>{ut(Ne,!0,!1)},[]),he=c.useCallback(()=>{ut(Ne,!1,!0)},[]),se=c.useCallback(()=>{ut(Ne,!0,!0)},[]),me=c.useCallback(()=>{ut(nt,!1,!1)},[]),ye=c.useCallback(()=>{ut(nt,!0,!1)},[]),ce=c.useCallback(()=>{ut(nt,!1,!0)},[]),$e=c.useCallback(()=>{ut(nt,!0,!0)},[]),at=c.useCallback(()=>{ut(ot,!1,!1)},[]),je=c.useCallback(()=>{ut(ot,!0,!1)},[]),Ae=c.useCallback(()=>{ut(ot,!1,!0)},[]),dt=c.useCallback(()=>{ut(ot,!0,!0)},[]),qe=c.useCallback(()=>{ft(a=>a.slice(0,-1))},[]),kt=c.useMemo(()=>{const a=ve();return((f,m,w,v,H)=>{for(let S=0;S<f.length;S++){const de=f[S];if(de.rowStart===m&&de.colStart===w&&de.rowEnd===v&&de.colEnd===H)return!0}return!1})(M.ranges,a.top,a.left,a.bottom,a.right)},[B,M.ranges]),gt=c.useCallback((a,f=!0)=>{Fe.current=a,Ge(a),f&&a&&e?.current&&He(a)},[]),fe=T((a=!0)=>{const f=Xt.current;if(!xe.current?.cell)return;const m=xe.current?.ranges,w=xe.current?.cell;if(!w||!f||!f)return;let v=null;if(v=m.length>0?m[m.length-1]:z(w),v.colEnd>=v.colStart&&v.rowEnd>=v.rowStart){const H=Or(v,f);let S=a?Ke:$;try{S?.(v,f,H.direction)}catch(de){console.warn(de)}finally{a&&Ce?.()}}},[z]),ht=c.useRef(null),Ot=bn(c.useMemo(()=>({onPointerDown:(a,f)=>{if(Rt.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),w=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);w&&(a.stopPropagation(),Yt("crosshair"),ht.current={anchor:m.getAnchor(),coords:w})},onPointerMoveOrWait:(a,f)=>{if(R||!e?.current||!xe.current||!ht.current)return;const m=ht.current.anchor;let w=e.current.getViewFromLocation(m),v=w.getCellCoordsFromClient(a.clientX,a.clientY);if(!v)return;ht.current={anchor:m,coords:v};const H=xe.current.ranges;let S=Ee(xe.current.cell,v);if(!S)return;const de=H.length>0,ne=de?H[H.length-1]:z(xe.current.cell);if(!S)return;const re=S.rowStart<ne.rowStart?nt:S.rowEnd>ne.rowEnd?ot:S.colEnd>ne.colEnd?Ne:et,pe=ve();re===et&&(S={...ne,colStart:Math.max(pe.left,S.colStart)}),re===nt&&(S={...ne,rowStart:Math.max(pe.top,S.rowStart)}),re===Ne&&(S={...ne,colEnd:Math.min(pe.right,S.colEnd)}),re===ot&&(S={...ne,rowEnd:Math.min(pe.bottom,S.rowEnd)});const Pe=Or(ne,S);if(!N?.(ne)){let ae;typeof Ze.current=="function"?ae=Ze.current(ne):U&&(ae=U),S=((ie,bt,F,Re,Mt,Me)=>{const Ie={...bt};if(F.length===0)return Ie;if(Mt===et){const mt=ie.colEnd+1-ie.colStart;Ie.colStart=ie.colStart-Math.ceil(Me/mt)*mt,Ie.colStart<Re.left&&(Ie.colStart=Ie.colStart+Math.ceil((Re.left-Ie.colStart)/mt)*mt)}else if(Mt===Ne){const mt=ie.colEnd+1-ie.colStart;Ie.colEnd=ie.colEnd+Math.ceil(Me/mt)*mt,Ie.colEnd>Re.right&&(Ie.colEnd=Ie.colEnd-Math.ceil((Re.right-Ie.colEnd)/mt)*mt)}else if(Mt===nt){const mt=ie.rowEnd+1-ie.rowStart;Ie.rowStart=ie.rowStart-Math.ceil(Me/mt)*mt,Ie.rowStart<Re.top&&(Ie.rowStart=Ie.rowStart+Math.ceil((Re.top-Ie.rowStart)/mt)*mt)}else if(Mt===ot){const mt=ie.rowEnd+1-ie.rowStart;Ie.rowEnd=ie.rowEnd+Math.ceil(Me/mt)*mt,Ie.rowEnd>Re.bottom&&(Ie.rowEnd=Ie.rowEnd-Math.ceil((Re.bottom-Ie.rowEnd)/mt)*mt)}return Ie})(ne,S,ae,pe,Pe.direction,Pe.amount)}if(de&&G.isRangeWithinRange(S,ne)&&(S=null),!G.isEqualRanges(S,Xt.current)){if(tn(S),Xt.current=S,!S){try{_?.()}catch{}return void Ce?.()}fe(!1)}Rt.current=f,Gn(w,v,e)},onPointerUp:(a,f)=>{Rt.current=f,Promise.resolve(fe(!0)).finally(()=>{Ce?.(),tn(null),Xt.current=null,ht.current=null,Yt(null),e.current?.focus()})}}),[z])),At=c.useMemo(()=>({onPointerDown:Ot}),[Ot]),[_e,Xe]=c.useState(null),De=c.useRef(null),rt=c.useMemo(()=>({onPointerDown:(a,f)=>{if(Rt.current=f,!e||!e.current)return!1;const m=e.current.getViewFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY),w=m?.getCellCoordsFromClient(a.nativeEvent.clientX,a.nativeEvent.clientY);if(!w)return;if(oe?.(a,w,M)===!1)return!1;a.stopPropagation(),Yt("default");const v=m.getRelativePointFromClient(0,0),H=xe.current?.ranges[xe.current?.ranges.length-1]??G.cellToRange(xe.current?.cell),S=m.toClipBounds(m.getRangeCoordsBounds(H)),de={x:0,y:0};S.x-v.x>a.nativeEvent.clientX?de.x=a.nativeEvent.clientX-(S.x-v.x):a.nativeEvent.clientX>=S.x-v.x+S.width&&(de.x=Math.max(0,a.nativeEvent.clientX-(S.x-v.x+S.width))+1),S.y-v.y>a.nativeEvent.clientY?de.y=a.nativeEvent.clientY-(S.y-v.y):a.nativeEvent.clientY>=S.y-v.y+S.height&&(de.y=Math.max(0,a.nativeEvent.clientY-(S.y-v.y+S.height))+1),Y?.(H,a.nativeEvent,f),De.current={range:H,anchor:m.getAnchor(),cell:w,isMoving:!1,extrusion:de}},onPointerMoveOrWait:(a,f,m)=>{if(q||!e?.current||!xe.current||!De.current)return;const w=a.clientX-m.clientX,v=a.clientY-m.clientY;if(De.current.isMoving=De.current.isMoving||Math.abs(w)>Math.max(1,2)||Math.abs(v)>Math.max(1,2)||performance.now()-m.timeStamp>500,!De.current.isMoving)return;const H=De.current.anchor,S=De.current.extrusion;let de=e.current.getViewFromLocation(H),ne=de.getCellCoordsFromClient(a.clientX-S.x,a.clientY-S.y,!0);if(!ne)return;const re=De.current.cell,pe=De.current.range,Pe=ve(),ae=pe.colEnd-pe.colStart+1,ie=Math.min(Math.max(0,re.colIndex-pe.colStart),ae-1),bt=Math.min(Pe.right-ae+1,Math.max(Pe.left,ne.colIndex-ie)),F=pe.rowEnd-pe.rowStart+1,Re=Math.min(Math.max(0,re.rowIndex-pe.rowStart),F-1),Mt=Math.min(Pe.bottom-F+1,Math.max(Pe.top,ne.rowIndex-Re)),Me={colStart:bt,colEnd:bt+ae-1,rowStart:Mt,rowEnd:Mt+F-1};G.isEqualRanges(_e,Me)&&!(Ie=>!Ie||!Rt.current||Rt.current.ctrlKey!==Ie.ctrlKey||Rt.current.shiftKey!==Ie.shiftKey||Rt.current.altKey!==Ie.altKey||Rt.current.metaKey!==Ie.metaKey)(a)||(Xe(Me),k?.(Me,a,f)),Rt.current=f,Gn(de,ne,e)},onPointerUp:(a,f)=>{Rt.current=f;const m=()=>{Xe(null),De.current=null,Yt(null),e.current?.focus()};if(!De.current)return void m();const w=De.current.range,v=_e;E?.(w,a,f),Promise.resolve(w&&v&&g?.(w,v,a,f)).finally(()=>{m()})}}),[_e]),ke=bn(rt),yt=c.useMemo(()=>({onPointerDown:ke}),[ke]),wt=c.useRef(null),Lt=c.useMemo(()=>{const a=G.isEqualSelectionCoords(M,wt.current)?wt.current:M;return wt.current=a,a},[M]),Vt=c.useCallback(a=>{let f=null,m="br";const w=[],v={stroke:C,fill:te,strokeWidth:.5},H=(ae,ie,bt)=>{const F=a.toClipBounds(a.getRangeCoordsBounds(ae),Wt);if(!F)return;F.x=F.width>0?F.x:F.x-v.strokeWidth/2,F.y=F.height>0?F.y:F.y-v.strokeWidth/2,F.width=Math.max(F.width,v.strokeWidth),F.height=Math.max(F.height,v.strokeWidth);const Re={key:`selection-fill-${ie}`,range:ae,...F,...v};if(bt){const Mt=a.getCellCoordsAsRangeCoords(bt);Re.cell=bt,Re.pathBounds=a.toClipBounds(a.getRangeCoordsBounds(Mt),Wt),Re.pathBounds&&(Re.pathBounds.width<=0||Re.pathBounds.height<=0)&&(delete Re.pathBounds,delete Re.cell)}return we(Re)};let S=M?$t(M):null;const de=S?.cell?a.getCellCoordsAsRangeCoords(S?.cell):Vl;!S||S.ranges&&S.ranges.length!==0||(S={ranges:[de],rangeIndex:0,cell:S.cell});for(let ae=0;S&&ae<S.ranges.length;ae++){const ie=S.ranges[ae],bt=H(ie,ae,ae===S.rangeIndex?S.cell:null);bt&&w.push(bt);const F=2,Re=.5,Mt=a.toClipBounds(a.getRangeCoordsBounds(ie,{top:0,left:0,right:0,bottom:0}),Wt);if(Mt){const Me=(S.ranges.length,4);w.push(we({range:ie,key:`selection-inside-edge-${ae}`,x:Mt.x-1,y:Mt.y-1,width:Math.max(Mt.width+1,0),height:Math.max(Mt.height+1,0),style:{overflow:"hidden"},stroke:C,strokeWidth:Me}))}if(S.ranges.length===1){const Me=a.toClipBounds(a.getRangeCoordsBounds(ie),Wt);if(Me){q||w.push(we({range:ie,key:`move-selection-hit-box-${ae}`,x:Me.width>1?Me.x:Me.x-(K/2+1),y:Me.height>1?Me.y:Me.y-(K/2+1),width:Math.max(Me.width+2,1),height:Math.max(Me.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:_e?void 0:"move",pointerEvents:"stroke"},strokeWidth:K,...yt}));const Ie=F;w.push(we({range:ie,key:`selection-single-${ae}`,x:Me.x-Ie/2,y:Me.y-Ie/2,width:Math.max(Me.width+Ie/2,1),height:Math.max(Me.height+Ie/2,1),stroke:X,strokeWidth:Ie}))}}else{const Me=a.toClipBounds(a.getRangeCoordsBounds(ie,{top:-1,left:-1,right:-2,bottom:-2}),Wt);Me&&w.push(we({range:ie,key:`selection-multi-${ae}`,x:Me.width>1?Me.x:Me.x-Re/2,y:Me.height>1?Me.y:Me.y-Re/2,width:Math.max(Me.width,Re)+1,height:Math.max(Me.height,Re)+1,stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(S.ranges.length>1&&ae===S.rangeIndex){const Me=a.getCellCoordsAsRangeCoords(S.cell),Ie=a.toClipBounds(a.getRangeCoordsBounds(Me,{top:1,left:1,right:-1,bottom:-1}),Wt);Ie&&w.push(we({range:ie,key:`selection-anchor-${ae}`,x:Ie.x,y:Ie.y,width:Math.max(Ie.width,Re),height:Math.max(Ie.height,Re),stroke:X,style:{overflow:"hidden"},strokeWidth:2}))}if(ae===S.ranges.length-1){f=null,m=null;const Me=ie.rowStart===ve().top&&ie.rowEnd===ve().bottom,Ie=ie.colStart===ve().left&&ie.colEnd===ve().right,mt=a.getRangeCoordsBounds(ie);let qt=null;if(Me||Ie){if(qt=a.toClipBounds(mt,Wt),Object.keys(a.allViews()).length>1){const Nn=a.getVisibleRangeCoords(),Zo=a.allViews()[to],Ri=a.allViews()[Ln],ki=a.allViews()[Dn],Un=a.getAnchor();(Ie&&(Un===Ln&&Zo||Un===Ht&&ki||!G.isCellWithinRange({colIndex:ie.colStart,rowIndex:ie.rowEnd},Nn)&&!G.isCellWithinRange({colIndex:ie.colStart,rowIndex:ie.rowEnd+1},Nn))||Me&&(Un===Dn&&Zo||Un===Ht&&Ri||!G.isCellWithinRange({colIndex:ie.colEnd,rowIndex:ie.rowStart},Nn)&&!G.isCellWithinRange({colIndex:ie.colEnd+1,rowIndex:ie.rowStart},Nn)))&&(qt=null)}}else qt=a.toClipBounds(mt,Wt);if(!qt||qt.width===0||qt.height===0)continue;f={x:qt.x+qt.width+1,y:qt.y+qt.height+1},qt.width===0||qt.height===0||ie.rowStart===ve().top&&ie.colStart===ve().left&&ie.rowEnd===ve().bottom&&ie.colEnd===ve().right||(Me?(f.y=F,m="tr"):Ie&&(f.x=F,m="bl"))}}let ne=null;if(Oe){const ae=a.toClipBounds(a.getRangeCoordsBounds(Oe,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(ne=we({...v,range:Oe,key:"remove-selection",x:ae.x,y:ae.y,width:ae.width,height:ae.height,strokeWidth:2,stroke:Ve,fill:Be}))}let re=null;if(Et){const ae=a.toClipBounds(a.getRangeCoordsBounds(Et,{top:0,left:0,right:0,bottom:0}),Wt);ae&&(re=we({range:Et,key:"selection-fill-outline",x:ae.x-2/2,y:ae.y-2/2,width:ae.width+2/2,height:ae.height+2/2,strokeWidth:2,stroke:X,strokeDasharray:"3 2"}))}let pe=null;!R&&f&&!_e&&(pe=c.createElement(Wo,{...f,corner:m,size:7.5,borderStroke:`${C} solid`,style:{borderRadius:1},background:X,...At,key:"fillHandle"}));const Pe=[...w];if(ne&&Pe.push(ne),re&&Pe.push(re),pe&&Pe.push(pe),!We&&_t&&S?.ranges.length===1&&S.ranges[S.ranges.length-1]){const ae=S.ranges[S.ranges.length-1],ie=ae.rowStart===ve().top&&ae.rowEnd===ve().bottom,bt=ae.colStart===ve().left&&ae.colEnd===ve().right,F={view:a,range:ae,borderStroke:`${X} solid`,background:C,selectionTouchPointerHandler:co,...it,onTouchSelectStart:Re=>nn(Re),onTouchSelectEnd:()=>nn(null),currentTouchAnchor:wn};Pe.push(P.jsx(Qn,{anchor:bt?"b":ie?"r":"br",scrollableElement:e.current,...F},"touch-select-handle-after")),Pe.push(P.jsx(Qn,{anchor:bt?"t":ie?"l":"tl",scrollableElement:e.current,...F},"touch-select-handle-before"))}if(_e){const ae=a.toClipBounds(a.getRangeCoordsBounds(_e,{top:1,left:1,right:1,bottom:1}),Wt);ae&&Pe.push(we({range:_e,key:"selection-move-outline",x:ae.x-ee/2,y:ae.y-ee/2,width:Math.max(ae.width+ee/2,1),height:Math.max(ae.height+ee/2,1),stroke:X,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:ee}))}return P.jsx("div",{children:Pe},"selection")},[Lt,Oe,R,Et,q,_e,ve,C,X,te,Ve,Be,We,it,wn]),Tt=c.useMemo(()=>{const a=()=>e.current;return[new Se("moveToPageDown",a,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>Bn(!1)),new Se("selectToPageDown",a,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[vt]}]},()=>Bn(!0)),new Se("moveToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn]}]},()=>Fn(!1)),new Se("selectToPageRight",a,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[dn,vt]}]},()=>Fn(!0)),new Se("moveToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>Kt(!1)),new Se("selectToPageUp",a,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[vt]}]},()=>Kt(!0)),new Se("moveToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn]}]},()=>Mn(!1)),new Se("selectToPageLeft",a,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[dn,vt]}]},()=>Mn(!0)),new Se("selectColumn",a,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[Pt]}},ao),new Se("selectRow",a,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[vt]}},uo),new Se("selectToColumnStart",a,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>An(!0)),new Se("selectToColumnEnd",a,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>$n(!0)),new Se("moveToRowStart",a,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>_n(!1)),new Se("selectToRowStart",a,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[vt]}]},()=>_n(!0)),new Se("moveToSheetStart",a,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt]}]},()=>mn(!1)),new Se("selectToSheetStart",a,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Pt,vt]}]},()=>mn(!0)),new Se("moveToRowEnd",a,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>Cn(!1)),new Se("selectToRowEnd",a,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[vt]}]},()=>Cn(!0)),new Se("moveToSheetEnd",a,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt]}]},()=>un(!1)),new Se("selectToSheetEnd",a,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[Pt,vt]}]},()=>un(!0)),new Se("scrollToActiveCoords",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[Pt]}},an),new Se("scrollToActiveCoordsClearSelection",a,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[vt]}},()=>{Gt(),gt(M.cell,!0)}),new Se("traverseSelectionRight",a,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},Wn),new Se("traverseSelectionLeft",a,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[vt]}},Vn),new Se("traverseSelectionDown",a,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},go),new Se("traverseSelectionUp",a,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[vt]},{key:"NumpadEnter",modifiers:[vt]}]},po),new Se("moveLeft",a,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Hn),new Se("selectLeft",a,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[vt]}]},b),new Se("moveContentfulLeft",a,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt]}]},D),new Se("selectContentfulLeft",a,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Pt,vt]}]},A),new Se("moveRight",a,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},V),new Se("selectRight",a,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[vt]}]},W),new Se("moveContentfulRight",a,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt]}]},he),new Se("selectContentfulRight",a,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Pt,vt]}]},se),new Se("moveUp",a,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},me),new Se("selectUp",a,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[vt]}]},ye),new Se("moveContentfulUp",a,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt]}]},ce),new Se("selectContentfulUp",a,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Pt,vt]}]},$e),new Se("moveDown",a,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},at),new Se("selectDown",a,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[vt]}]},je),new Se("moveContentfulDown",a,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt]}]},Ae),new Se("selectContentfulDown",a,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Pt,vt]}]},dt),new Se("selectVisible",a,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[dn]}},ho),new Se("traverseSelectionPreviousRange",a,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[Pt,dn]}},Rn),new Se("traverseSelectionNextRange",a,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[Pt,dn]}},wo),new Se("traverseSelectionCorners",a,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[Pt]}},mo)]},[]);return c.useMemo(()=>{t?.addCommands(Tt,!0)},[t]),{selection:Lt,setSelectionCell:gt,setSelectionRanges:ft,overlay:Vt,cursor:Qt,onPointerDown:so,clearLastSelection:qe,newSelection:Je,modifySelection:tt,appendSelection:Le,clearSelections:Gt,isEntire:kt,navigate:ut,navigateSelection:Zt}};
11
+ }`,xe=document.createElement("style");return xe.appendChild(document.createTextNode(_)),document.head.appendChild(xe),xe.sheet.insertRule(_,0),()=>{document.head.removeChild(xe)}},[O]),O&&(U={strokeDasharray:`${ie.dashLength}px ${ie.dashGap}px`,strokeDashoffset:`${Z}px`,animation:`${Q} ${oe}ms linear infinite`,willChange:"stroke-dashoffset"}),te.jsx(en,{x:c,y:d,width:h,height:a,stroke:r,fill:i,shapeRendering:"crispEdges",style:{...U,...s},...T})});function tn(t){var r,i,c="";if(typeof t=="string"||typeof t=="number")c+=t;else if(typeof t=="object")if(Array.isArray(t)){var d=t.length;for(r=0;r<d;r++)t[r]&&(i=tn(t[r]))&&(c&&(c+=" "),c+=i)}else for(i in t)t[i]&&(c&&(c+=" "),c+=i);return c}function Vt(){for(var t,r,i=0,c="",d=arguments.length;i<d;i++)(t=arguments[i])&&(r=tn(t))&&(c&&(c+=" "),c+=r);return c}Oo.displayName="Selection";const Uo=l.memo(l.forwardRef((t,r)=>{const{x:i=0,y:c=0,borderWidth:d=1,size:h=6,borderStroke:a,corner:s,style:w,className:P,background:z,...M}=t;if(i===0||c===0)return null;let T=!0,O=!0,ie=!0,Z=!0;switch(s){case"tl":T=!1,O=!1;break;case"bl":T=!1,Z=!1;break;case"br":ie=!1,Z=!1;break;case"tr":O=!1,ie=!1}return te.jsx("div",{className:Vt("fill-handle",P),style:{position:"absolute",left:i-(h+(T?d:0))/2,top:c-(h+(O?d:0))/2,width:h,height:h,borderLeft:T?`${d}px ${a}`:void 0,borderTop:O?`${d}px ${a}`:void 0,borderRight:ie?`${d}px ${a}`:void 0,borderBottom:Z?`${d}px ${a}`:void 0,background:z,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...w},tabIndex:-1,...M})}));Uo.displayName="FillHandle";var vn=function(){},on=typeof window<"u",Rn=on?l.useLayoutEffect:l.useEffect,Yo={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const nn=on&&window.ResizeObserver!==void 0?function(){var t=l.useState(null),r=t[0],i=t[1],c=l.useState(Yo),d=c[0],h=c[1],a=l.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var w=s[0].contentRect,P=w.x,z=w.y,M=w.width,T=w.height,O=w.top,ie=w.left,Z=w.bottom,oe=w.right;h({x:P,y:z,width:M,height:T,top:O,left:ie,bottom:Z,right:oe})}})},[]);return Rn(function(){if(r)return a.observe(r),function(){a.disconnect()}},[r]),[i,d]}:function(){return[vn,Yo]};function ko(t,r){if(typeof t=="function")return t(r);t&&(t.current=r)}var En=parseInt(l.version.split(".")[0],10)>=19?function(t){return r=>{const i=[];for(const c of t){const d=ko(c,r),h=typeof d=="function";i.push(h?d:()=>ko(c,null))}return()=>{for(const c of i)c()}}}:function(t){return r=>{for(const i of t)ko(i,r)}};const fo=l.memo(l.forwardRef((t,r)=>{const{range:i,view:c,anchor:d,borderStroke:h="rgb(33, 115, 70)",background:a="white",borderWidth:s=1.5,size:w=22,style:P,className:z,selectionTouchPointerHandler:M,onTouchSelectStart:T,onTouchSelectEnd:O,currentTouchAnchor:ie,scrollableElement:Z,scrollableRoot:oe=document.body,...Pe}=t,Q=o.useCallbackRef(T,[T]),U=o.useCallbackRef(O,[O]),{bounds:_,coordsPivot:xe,key:$}=l.useMemo(()=>{if(!i||!c)return null;let A=null,ne=null;switch(d){case"tl":A={colIndex:i.colEnd,rowIndex:i.rowEnd},ne={colIndex:i.colStart,rowIndex:i.rowStart};break;case"br":A={colIndex:i.colStart,rowIndex:i.rowStart},ne={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"t":case"l":A={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"b":A={colIndex:i.colStart,rowIndex:i.rowStart};break;case"r":A={colIndex:i.colStart,rowIndex:i.rowEnd}}let K=c.getRangeCoordsBounds(ne?{rowStart:ne.rowIndex,colStart:ne.colIndex,rowEnd:ne.rowIndex,colEnd:ne.colIndex}:i);const Y=c.getBounds(),ce=c.getViewportSize(),Et=Y.x,dt=Y.y,tt=ce.width,ot=ce.height;switch(d){case"tl":break;case"br":K.x=K.x+K.width,K.y=K.y+K.height;break;case"t":K.x=tt/2-Et;break;case"b":K.x=tt/2-Et,K.y=K.y+K.height;break;case"l":K.y=ot/2-dt;break;case"r":K.x=K.x+K.width,K.y=ot/2-dt}const de=c.toClipBounds(K,0);return!de||de.width<=0||de.height<=0||K.x<0||K.y<0||K.x>tt||K.y>ot?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:K,coordsAnchor:null,coordsPivot:A,key:"touchSelect-"+c.getAnchor()+"-"+d}},[i,c,d]),ge=l.useRef(null),Le=l.useMemo(()=>{const A=ne=>d==="t"||d==="b"?{...ne,colIndex:void 0}:d==="l"||d==="r"?{...ne,rowIndex:void 0}:ne;return{processTouch:!0,consumeTouch:!0,onPointerDown:(ne,K)=>{const Y=A(c.getCellCoordsFromClient(ne.clientX,ne.clientY));return ge.current={coordsPivot:xe},Q?.(d),M.onSelectionPointerDown(ne,K,c,Y,xe,!1,!0)},onPointerMoveOrWait:(ne,K,Y)=>{const ce=A(c.getCellCoordsFromClient(ne.clientX,ne.clientY));return M.onSelectionPointerMoveOrWait(ne,K,Y,c,ce,ge.current?.coordsPivot,!0,!0)},onPointerUp:(ne,K,Y)=>(ge.current=null,U?.(d),M.onPointerUp(ne,K,Y))}},[M,i,c,d]),Ie=o.useSynchronizedPointerHandler(Le),[Oe,{y:ae,x:Ce}]=nn(),L=l.useRef(null),{getPortalContainer:C}=o.useFullscreenPortal(),[Be,Ke]=l.useState(null);return l.useEffect(()=>{const A=L.current?.getBoundingClientRect();if(!A||!_)return void Ke(null);let ne=0,K=0,Y=Z;for(;Y;)ne+=Y.scrollLeft,K+=Y.scrollTop,Y=oe&&Y===oe.parentElement?null:Y.parentElement;Ke(Zo.createPortal(te.jsx("div",{className:Vt("touch-select-handle",z),ref:r,style:{position:"absolute",left:ne+(A?.x??0)-(w+s)/2,top:K+(A?.y??0)-(w+s)/2,width:w,height:w,borderWidth:`${s}px`,border:h,borderRadius:"50%",background:a,boxShadow:`0 0 0 1.5px ${a}`,cursor:"grab",pointerEvents:"all",opacity:ie?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...P},tabIndex:-1,onPointerDown:Ie,...Pe}),oe??C(),$))},[ae,Ce,_?.x,_?.y,_?.width,_?.height,z,ie,a,w,s,h,Z]),_?te.jsxs(te.Fragment,{children:[te.jsx("div",{ref:En([Oe,L]),style:{position:"absolute",left:_.x,top:_.y,opacity:0}}),Be]}):null}));fo.displayName="TouchSelectHandle";const It=-10,In=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),rn=Object.freeze({colIndex:0,rowIndex:0}),To=Object.freeze([]),Rt=t=>{if(t&&t.cell&&t.ranges&&t.rangeIndex>-1&&t.rangeIndex<=t.ranges.length)return t;const r={cell:null,ranges:t?.ranges??To};return r.rangeIndex=t?.rangeIndex??r.ranges.length-1,r.cell=t?.cell,!r.cell&&r.ranges.length>0&&(r.cell={rowIndex:r.ranges[r.rangeIndex].rowStart,colIndex:r.ranges[r.rangeIndex].colStart}),r.cell||(r.cell=rn),n.CoordUtils.isEqualSelectionCoords(r,t)?t:r},ho=(t,r,i)=>{const c=t.getVisibleRangeCoords(),d=t.getScrollOrientation();!d.horizontal&&(r.colIndex>c.colEnd||r.colIndex<c.colStart)&&(r={...r,colIndex:r.colIndex>c.colEnd?c.colEnd+1:c.colEnd-1},t=i.current.getViewFromLocation(n.AnchorLocation.Center)),!d.vertical&&(r.rowIndex>c.rowEnd||r.rowIndex<c.rowStart)&&(r={...r,rowIndex:r.rowIndex>c.rowEnd?c.rowEnd+1:c.rowEnd-1},t=i.current.getViewFromLocation(n.AnchorLocation.Center)),t.scrollCellCoordsIntoView(r)},kn=()=>!1;function go(t,r){if(!t)throw new Error("Invariant failed")}const Xo={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},Mn=Object.freeze({top:0,left:0}),Dn=Object.freeze({bottom:-4,right:-4}),Pn=Object.freeze({horizontal:!0,vertical:!0}),Go=[n.AnchorLocation.TopLeft,n.AnchorLocation.Top,n.AnchorLocation.Left,n.AnchorLocation.Center],Ot=3e3,Mo={},zo=l.memo(l.forwardRef((t,r)=>{const{width:i,height:c,rowCount:d=1,columnCount:h=1,defaultRowHeight:a,defaultColumnWidth:s,getRowHeight:w,getColumnWidth:P,layout:z,onViewportScroll:M,onImmediateScroll:T,showGridLines:O=!0,gridLineColor:ie="rgb(224, 224, 224)",gridLineRowsProps:Z,gridLineColumnsProps:oe,clipCells:Pe=!0,cursor:Q,freezeLeft:U=0,freezeTop:_=0,freezeLeftProps:xe,freezeTopProps:$,cellRenderer:ge,onViewportChange:Le,onFirstRender:Ie,overlayRenderer:Oe,overlayProps:ae,overlays:Ce,overlaysProps:L,allowOverlaysOverflow:C=!1,stageProps:Be,stageWrapper:Ke=null,hiddenRowsAt:A,hiddenColumnsAt:ne,hiddenCellAt:K,getVisibleCells:Y,zoom:ce=1,enableMouseWheel:Et=!0,onWheelScroll:dt,getCellCoordsAsRangeCoords:tt=n.CoordUtils.cellToRange,scrollPoint:ot=Mn,style:de={},...Bt}=t;go(ge),go(!t?.children);const D=o.useCallbackRef(T,[T]),y=o.useCallbackRef(Le,[Le]),Re=o.useCallbackRef(M,[M]),re=o.useCallbackRef(dt,[dt]),he=o.useCallbackRef(Ie,[Ie]),ze=l.useRef(null),Ye=l.useRef(null),gt=l.useRef(null),[Xe,Ut]=l.useReducer(x=>x+1,0),[it,S]=l.useState({left:ot?.left??0,top:ot?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),le=l.useRef(null),Ve=l.useRef(it),{top:nt,left:He,verticalScrollDirection:Ht,horizontalScrollDirection:$t}=it,Ct=l.useRef(!1),Xt=Qo({rowCount:d,columnCount:h,defaultRowHeight:a,defaultColumnWidth:s,getRowHeight:w,getColumnWidth:P}),zt=l.useRef(null),ke=l.useMemo(()=>{const x=z||Xt;return zt.current=null,{getColOffset:b=>x.getColOffset(b)*ce,getColIndex:b=>x.getColIndex(b/ce),getRowOffset:b=>x.getRowOffset(b)*ce,getRowIndex:b=>x.getRowIndex(b/ce)}},[Xt,z,ce]),Pt=(x,b,v)=>{const E=(b?.left??0)+0,I=(b?.top??0)+0;return{getColOffset:q=>x.getColOffset(q)-E,getColIndex:q=>x.getColIndex(q+E),getRowOffset:q=>x.getRowOffset(q)-I,getRowIndex:q=>x.getRowIndex(q+I)}},ct=l.useCallback((x,b=!1)=>wo(x,b,ke.getRowOffset,b?0:d),[d,ke?.getRowOffset]),kt=o.useCallbackRef(A??ct,[A]),eo=l.useCallback((x,b=!1)=>wo(x,b,ke.getColOffset,b?h:0),[h,ke?.getColOffset]),jt=o.useCallbackRef(ne??eo,[ne]),$e=l.useMemo(()=>Math.min(i??800,ke.getColOffset(h)),[ke.getColOffset,h,i]),Ue=l.useMemo(()=>Math.min(c??600,ke.getRowOffset(d)),[ke.getRowOffset,d,c]),Kt=l.useCallback(x=>{n.CommonUtils.canUseDOM&&setTimeout(()=>{ze.current?.focus({preventScroll:!0,...x})},0)},[]),st=l.useCallback(x=>ze.current?.contains(x)||Ye.current?.contains(x),[]);l.useEffect(()=>{Ct.current&&(le.current&&le.current.left!==Ve.current?.left&&le.current.top!==Ve.current?.top||(le.current=null,Re?.({left:He,top:nt})))},[He,nt]);const Tt=o.useCallbackRef(()=>({top:nt,left:He}),[nt,He]),Me=l.useMemo(()=>{const x=[];let b=0,v=0;typeof _=="number"?b=_:(b=_.index??0,v=(_.scrollOffset??0)*ce);const E=v,I=ke.getRowOffset(b),q=I-E;if(b>0){const Ne=Pt(ke,{top:v+ke.getRowOffset(0)}),be=ke.getRowIndex(E),ye=ke.getRowIndex(I-1);let Ge;x[1]={minIndex:be,maxIndex:ye,minCoord:0,maxCoord:b-1,minBounds:0,maxBounds:q,visibleIndices:()=>Ge||(Ge=Object.freeze(uo(kt,be,ye)),Ge),layout:Ne,maxVirtualBounds:I,scrollOffset:v,freezeOffset:v}}const V=Math.max(0,Ue-q),J=Pt(ke,{top:nt+q}),ee=J.getRowIndex(0),H=J.getRowIndex(V);let Ee;return x[0]={minIndex:ee,maxIndex:H,minCoord:b,maxCoord:d-1,minBounds:q,maxBounds:V,visibleIndices:()=>Ee||(Ee=Object.freeze(uo(kt,ee,H)),Ee),layout:J,maxVirtualBounds:ke.getRowOffset(d),scrollOffset:nt,freezeOffset:(b>0?ke.getRowOffset(b):0)-v},x},[ke.getRowIndex,ke.getRowOffset,kt,Ue,d,_,nt,ce]),Fe=l.useMemo(()=>{const x=[];let b=0,v=0;typeof U=="number"?b=U:(b=U.index??0,v=(U.scrollOffset??0)*ce);const E=v,I=ke.getColOffset(b),q=I-E;if(b>0){const Ne=Pt(ke,{left:v+ke.getColOffset(0)}),be=ke.getColIndex(E),ye=ke.getColIndex(I-1);let Ge;x[1]={minIndex:be,maxIndex:ye,minCoord:0,maxCoord:b-1,minBounds:0,maxBounds:q,visibleIndices:()=>Ge||(Ge=Object.freeze(uo(jt,be,ye)),Ge),layout:Ne,maxVirtualBounds:I,scrollOffset:v,freezeOffset:v}}const V=Math.max(0,$e-q),J=Pt(ke,{left:He+q}),ee=J.getColIndex(0),H=J.getColIndex(V);let Ee;return x[0]={minIndex:ee,maxIndex:H,minCoord:b,maxCoord:h-1,minBounds:q,maxBounds:V,visibleIndices:()=>Ee||(Ee=Object.freeze(uo(jt,ee,H)),Ee),layout:J,maxVirtualBounds:ke.getColOffset(h),scrollOffset:He,freezeOffset:(b>0?ke.getColOffset(b):0)-v},x},[ke.getColIndex,ke.getColOffset,jt,$e,h,U,He,ce]),rt=l.useRef({}),ut=l.useRef([]),De=l.useMemo(()=>{let x={};const b=(E,I,q,V,J)=>{const ee={vertical:V?.vertical||!1,horizontal:V?.horizontal||!1};if(E>=Fe.length||I>=Me.length)return null;const H={rowStart:Me[I].minIndex,colStart:Fe[E].minIndex,rowEnd:Me[I].maxIndex,colEnd:Fe[E].maxIndex};if(H.rowStart>H.rowEnd||H.colStart>H.colEnd)return null;const Ee={getColIndex:ve=>Fe[E].layout.getColIndex(ve),getColOffset:ve=>Fe[E].layout.getColOffset(ve),getRowIndex:ve=>Me[I].layout.getRowIndex(ve),getRowOffset:ve=>Me[I].layout.getRowOffset(ve)},Ne=Object.freeze({left:J?.left??0,top:J?.top??0,right:J?.right??0,bottom:J?.bottom??0}),be=Object.freeze({x:Fe[E].minBounds,y:Me[I].minBounds,width:Fe[E].maxBounds,height:Me[I].maxBounds}),ye=(ve,Se)=>No(Ee,ve??H,Se),Ge={width:Fe[E].maxVirtualBounds,height:Me[I].maxVirtualBounds},Ae={left:Fe[E].scrollOffset,top:Me[I].scrollOffset},ht={left:Fe[E].freezeOffset,top:Me[I].freezeOffset},Ze={width:$e,height:Ue};let X=null,_e=null;const yt=(ht.top+(V.vertical?Ae.top:0))/ce,mt=(ht.left+(V.horizontal?Ae.left:0))/ce;return{getStage:()=>ze.current??null,getVisibleRangeCoords:()=>H,toClipBounds:(ve,Se)=>{let We,pe=0;return Se===void 0||typeof Se=="number"?(We=ye(H),pe=Se):We=Se,((we,Je,lt=0)=>{if(we.x>Je.width||we.y>Je.height)return null;const xt={left:we.x,top:we.y,bottom:we.height+we.y,right:we.width+we.x},vt={left:Je.x+lt,top:Je.y+lt,bottom:Je.height-2*lt+Je.y,right:Je.width-2*lt+Je.x},ft={left:Math.max(xt.left,vt.left),top:Math.max(xt.top,vt.top),bottom:Math.min(xt.bottom,vt.bottom),right:Math.min(xt.right,vt.right)},pt={x:ft.left,y:ft.top,width:ft.right-ft.left,height:ft.bottom-ft.top};return pt.height<0||pt.width<0?null:pt})(ve??{x:0,y:0,width:be.width,height:be.height},We,pe)},toViewBounds:ve=>mt===0&&yt===0&&ce===1?ve:{x:(ve.x-mt)*ce,y:(ve.y-yt)*ce,width:ve.width*ce,height:ve.height*ce},toAbsoluteBounds:ve=>mt===0&&yt===0&&ce===1?ve:{x:ve.x/ce+mt,y:ve.y/ce+yt,width:ve.width/ce,height:ve.height/ce},getRelativePointFromClient:(ve,Se)=>{const We=Nt(ve,Se);return{x:We.x-be.x,y:We.y-be.y}},getLayout:()=>Ee,getCellCoordsAsRangeCoords:tt,getVisibleColumns:()=>Fe[E].visibleIndices(),getVisibleRows:()=>Me[I].visibleIndices(),getVisibleColumnOffsets:()=>(X||(X=jo(Fe[E].layout,!0,Fe[E].visibleIndices(),H.colStart,H.colEnd)),X),getVisibleRowOffsets:()=>(_e||(_e=jo(Me[I].layout,!1,Me[I].visibleIndices(),H.rowStart,H.rowEnd)),_e),getTotalRangeCoords:()=>({colStart:Fe[E].minCoord,colEnd:Fe[E].maxCoord,rowStart:Me[I].minCoord,rowEnd:Me[I].maxCoord}),getRangeCoordsBounds:ye,scrollCellCoordsIntoView:(ve,Se)=>Gt(ve,Se,q),getCellCoordsFromClient:(ve,Se,We=!1)=>{const pe=Nt(ve,Se);if(!pe)return null;const we=Ee.getColIndex(pe.x-be.x),Je={rowIndex:Ee.getRowIndex(pe.y-be.y),colIndex:we};if(We)return Je;const lt=tt(Je);return{rowIndex:lt.rowStart,colIndex:lt.colStart}},getZoom:()=>ce,getAnchor:()=>q,getBounds:()=>be,getInsets:()=>Ne,getTotalSize:()=>Ge,getViewportSize:()=>Ze,getScrollTopLeft:()=>Ae,getFreezeTopLeft:()=>ht,getScrollOrientation:()=>ee,allViews:()=>x}};let v=x[n.AnchorLocation.Center]=b(0,0,n.AnchorLocation.Center,Pn,Dn);return v&&(x[n.AnchorLocation.Center]=v),v=b(0,1,n.AnchorLocation.Top,{horizontal:!0}),v&&(x[n.AnchorLocation.Top]=v),v=b(1,0,n.AnchorLocation.Left,{vertical:!0}),v&&(x[n.AnchorLocation.Left]=v),v=b(1,1,n.AnchorLocation.TopLeft,{}),v&&(x[n.AnchorLocation.TopLeft]=v),rt.current=null,x=Object.freeze(x)},[Me,Fe,tt]),At=Object.keys(De),St=Fe[0]?.maxVirtualBounds??0,je=Me[0]?.maxVirtualBounds??0,wt=l.useMemo(()=>({left:Fe[1]?Fe[1].layout.getColOffset(Fe[1].maxIndex+1):0,top:Me[1]?Me[1].layout.getRowOffset(Me[1].maxIndex+1):0}),[De]);l.useEffect(()=>{if(ut.current.length>0){for(let x=0;x<ut.current.length;x++)ut.current[x]();ut.current=[]}},[De]);const bt=o.useCallbackRef(()=>({containerWidth:$e,containerHeight:Ue,totalWidth:St,totalHeight:je}),[$e,Ue,ke]);l.useEffect(()=>{!le.current&&Ct.current&&y({top:nt,left:He,width:$e,height:Ue,totalWidth:St,totalHeight:je})},[nt,He,St,je]),l.useEffect(()=>{Ct.current&&y({top:nt,left:He,width:$e,height:Ue,totalWidth:St,totalHeight:je})},[$e,Ue]);const Nt=l.useCallback((x,b)=>{go(typeof x=="number"&&typeof b=="number");const v=ze.current?.getBoundingClientRect();return v?{x:x-v.x,y:b-v.y}:{x,y:b}},[]),xo=o.useCallbackRef(x=>De[x]||null,[De]),po=o.useCallbackRef((x,b)=>{if(Object.keys(De).length===1)return De[n.AnchorLocation.Center];const v=Nt(x,b);if(!v)return null;const{x:E,y:I}=v;let q=null;const V=Go;for(let J=0;!q&&J<V.length;J++){const ee=De[V[J]];ee&&yn(E,I,ee.getBounds())&&(q=ee)}return q||(q=De[n.AnchorLocation.Center]),q},[De,tt]),qe=o.useCallbackRef(()=>De[n.AnchorLocation.Center].getVisibleRangeCoords(),[De[n.AnchorLocation.Center]]),Lt=l.useRef(null),mo=l.useCallback(()=>{Lt.current!==null&&n.CommonUtils.cancelTimeout(Lt.current),Lt.current=n.CommonUtils.requestTimeout(Co,150)},[]),Co=l.useCallback(()=>{Lt.current=null,S(x=>{const b={...x,verticalScrollDirection:null,horizontalScrollDirection:null};return Ve.current=b,b})},[]),Ft=o.useCallbackRef(x=>{const b=x?.left??x?.[0],v=x?.top??x?.[1],E=b!==void 0?Math.min(St-$e,Math.max(Fe?.[1]?.scrollOffset??0,b)):Ve.current.left,I=v!==void 0?Math.min(je-Ue,Math.max(Me?.[1]?.scrollOffset??0,v)):Ve.current.top;if(Ve.current.left===E&&Ve.current.top===I)return;let q=null,V=null;Ve.current.left>E?q=n.Direction.Left:Ve.current.left<E&&(q=n.Direction.Right),Ve.current.top>I?V=n.Direction.Up:Ve.current.top<I&&(V=n.Direction.Down),n.CommonUtils.throttle(()=>{S(J=>{const ee={...J,left:E,top:I,horizontalScrollDirection:q,verticalScrollDirection:V};return Ve.current=ee,ee})},17)(),le.current?.top===I&&le.current?.left===E||(le.current={left:E,top:I},D({left:E,top:I}),y({left:E,top:I,width:$e,height:Ue,totalWidth:St,totalHeight:je})),mo()},[St,je,Me,Fe]);l.useEffect(()=>{le.current||Ft({left:He,top:nt})},[St,$e,je,Ue]),l.useLayoutEffect(()=>{le.current={left:ot?.left,top:ot?.top},Ft(le.current)},[ot?.left,ot?.top]);const to=o.useCallbackRef(x=>{const b=x?.left??x?.[0],v=x?.top??x?.[1],E=x?.behavior??"auto",I={left:Ve.current.left+(b??0),top:Ve.current.top+(v??0)};E&&(I.behavior=E),Ft(I)},[St,$e,je,Ue]),oo=l.useCallback(x=>{let b=null;if(Object.keys(De).length>1){const v=Go;for(let E=0;!b&&E<v.length;E++){const I=De[v[E]];I&&n.CoordUtils.isCellWithinRange(x,I.getVisibleRangeCoords())&&(b=I)}}return b||(b=De[n.AnchorLocation.Center]),b},[De]),Gt=o.useCallbackRef((x,b={inline:"nearest",block:"nearest"},v=null)=>{const E={rowIndex:0,colIndex:0,...x};let I=null;if(v!==null){if(I=De[v],I===null)return new Promise((Ze,X)=>{X("Invalid view")})}else I=oo(E);const q=tt(E),V=I.getLayout(),J=V.getColOffset(q.colStart),ee=V.getRowOffset(q.rowStart),H=V.getColOffset(q.colEnd+1),Ee=V.getRowOffset(q.rowEnd+1),Ne=I.getBounds(),be=I.getTotalSize(),ye=I.getScrollTopLeft(),Ge=((Ze,X,_e=!0)=>(_e=_e===!0?{block:"start",inline:"end"}:_e===!1?{block:"end",inline:"end"}:{block:"end",inline:"end",..._e},{left:Wo(_e.inline,Ze.x,Ze.x+Ze.width,X.left,X.left+X.width,X.totalWidth),top:Wo(_e.block,Ze.y,Ze.y+Ze.height,X.top,X.top+X.height,X.totalHeight)}))({x:J+ye.left,y:ee+ye.top,width:H-J,height:Ee-ee},{left:ye.left,top:ye.top,width:Ne.width,height:Ne.height,totalWidth:be.width,totalHeight:be.height},b),Ae={...Ge};Ae.left>He?Ae.left+=20:Ae.left<He&&(Ae.left-=0),Ae.top>nt?Ae.top+=20:Ae.top<nt&&(Ae.top-=0);const ht=I.getScrollOrientation();return ht.horizontal&&x.colIndex!==void 0||delete Ae.left,ht.vertical&&x.rowIndex!==void 0||delete Ae.top,new Promise((Ze,X)=>{try{Ft(Ae),Ze(Ae)}catch(_e){X(_e)}})},[St,je,De,tt]),qt=o.useCallbackRef(x=>{const b=x.shiftKey;x.preventDefault();const{deltaX:v,deltaY:E,deltaMode:I}=x;if(gt.current||re?.(x)===!1)return;let V=b?E:v,J=E;const ee=b||Math.abs(V)>Math.abs(J);I===1&&(J*=0),gt.current=window.requestAnimationFrame(()=>{gt.current=null,to(ee?{left:V}:{top:J})})},[St,$e,je,Ue,re]),_t=l.useCallback((x=null)=>{zt.current=null,rt.current=null,Ut()},[]);l.useLayoutEffect(()=>{_t()},[ge]);const Wt=o.useImperativeElement(r,()=>({stage:ze.current,focus:Kt,contains:st,invalidate:_t,scrollTo:Ft,scrollBy:to,scrollCellCoordsIntoView:Gt,getScrollPosition:Tt,getDimensions:bt,getViewport:qe,handleWheel:qt,rowCount:d,columnCount:h,getLayout:()=>ke,getRelativePointFromClient:Nt,getViewFromClient:po,getViewFromCellCoords:oo,getViewFromLocation:xo,onViewChangeOnce:x=>{ut.current.push(x)}}),[d,h,De]);l.useEffect(()=>(Et&&Wt.current?.addEventListener("wheel",qt,{passive:!1}),Ct.current=!0,le.current=null,()=>{Wt.current?.removeEventListener("wheel",qt)}),[Et]);const Zt=l.useRef([]),So=(x,b)=>{!x||!Oe||(Zt.current=[],b.push(((v,E)=>{const I=`view:${v.getAnchor()}:overlay:${b.length}`,q=Oe?.({key:I,view:v},J=>Zt.current[E]=J);if(!q)return null;const V=v.getBounds();return te.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${V.width}px`,height:`${V.height}px`,overflow:"hidden"},children:q},`overlay-${v.getAnchor()}-${E}`)})(x,0)))},bo=l.useMemo(()=>{const x={},b=Object.keys(De);for(let v=0;v<b.length;v++){const E=b[v],I=[];So(De[E],I),x[E]={overlays:I}}return x},[Xe,Oe,d,h,Me,Fe]),no=(x,b,v,E,I,q,V)=>{if(!x)return;const J=x.getVisibleColumns(),ee=x.getVisibleRows();if(J.length===0||ee.length===0)return;let H=null;if(Y)H=Y(x);else{H=[];for(let Se=0;Se<ee.length;Se++)for(let We=0;We<J.length;We++){const pe={rowIndex:ee[Se],colIndex:J[We]};if(K?.(pe))continue;const we={coords:pe,range:tt(pe)};H.push(we)}}const Ee=x.getVisibleColumnOffsets(),Ne=x.getVisibleRowOffsets(),be=x.getScrollTopLeft(),ye=x.getFreezeTopLeft(),Ge=be.left+ye.left,Ae=be.top+ye.top,ht=Math.trunc(Ge/Ot),Ze=Math.trunc(Ae/Ot),X={},_e=(Se,We,pe,we,Je)=>{const lt=`view:${Se.getAnchor()}:cell:${Fo(We.rowIndex,We.colIndex)}`,xt=we.x,vt=we.y,ft=Math.trunc((Ge+xt)/Ot)-ht,pt=Math.trunc((Ae+vt)/Ot)-Ze;X[pt]||(X[pt]={});let e=X[pt][ft];e||(e=X[pt][ft]=[]);let u=q?.get(lt);if(!u){const g=(Ge+xt)%Ot,f=(Ae+vt)%Ot;u=ge({key:lt,coords:We,bounds:we,zoom:ce,range:pe,view:Se,value:Je,style:{left:o.ReactUtils.boundPixel(g),top:o.ReactUtils.boundPixel(f),width:o.ReactUtils.boundPixel(we.width,!0),height:o.ReactUtils.boundPixel(we.height,!0)}})}V?.set(lt,u),e.push(u)};for(let Se=0;H&&Se<H.length;Se++){const We=H[Se],pe=We?.coords??We;if(!pe)continue;const we=We?.range??{rowStart:pe.rowIndex,colStart:pe.colIndex,rowEnd:pe.rowIndex,colEnd:pe.colIndex},Je=x.getVisibleRangeCoords();if(!n.CoordUtils.isRangesIntersect(we,Je)&&!n.CoordUtils.isRangeWithinRange(we,Je))continue;const lt=we&&!n.CoordUtils.isSingleCell(we);if(!lt&&K?.(pe))continue;const xt=pe.rowIndex,vt=pe.colIndex,ft=Ne[xt],pt=Ee[vt];let e=null;ft&&pt&&(e={x:pt.offset,y:ft.offset,width:pt.size,height:ft.size});const u=Fo(we.rowStart,we.colStart);if(lt){if(I.has(u))continue;I.add(u),we.rowEnd-we.rowStart>0&&v.push(we),we.colEnd-we.colStart>0&&E.push(we)}if(lt&&(e=No(x.getLayout(),we)),!e){console.warn("no bounds for cell",u);continue}const g=We?.value;_e(x,pe,we,e,g)}const yt=Ge%Ot,mt=Ae%Ot,ve=Object.keys(X);for(let Se=0;Se<ve.length;Se++){const We=X[ve[Se]];if(!We)continue;const pe=Object.keys(We);for(let we=0;we<pe.length;we++){const Je=We[pe[we]];if(!Je)continue;const lt=parseInt(ve[Se]),xt=parseInt(pe[we]),vt=lt+Ze,ft=xt+ht,pt=`view:${x.getAnchor()}:segment:${ft}:${vt}`;b.push(te.jsx("div",{className:"cell-container",style:{transform:`translate(${o.ReactUtils.boundPixel(xt*Ot-yt,!0)}px, ${o.ReactUtils.boundPixel(lt*Ot-mt,!0)}px)`,willChange:"transform"},children:Je},pt))}}},Mt=l.useMemo(()=>{const x=zt.current,b=new Map,v={},E=Object.keys(De);for(let I=0;I<E.length;I++){const q=E[I],V=[],J=[],ee=[];no(De[q],ee,V,J,new Set,x,b),v[q]={cells:ee,rangesH:V,rangesV:J}}return zt.current=b,v},[Xe,d,h,Me,Fe,O,de,Pe,K,Y,tt]),ro=(x,b,v,E,I)=>{if(x)if(b){const q=`view:${x.getAnchor()}:hl:`,V=x.getVisibleRows();if(!V||V.length===0)return;const J=0,ee=x.getBounds().width;let H=[];const Ee=I.sort(n.CoordUtils.rowFirstRangeComparator),Ne=x.getVisibleRangeCoords();for(let be=0;be<V.length&&V[be]<=Ne.rowEnd;be++){const ye=V[be];if(ye<Ne.rowStart)continue;let Ge=!1;for(;Ee.length>0&&Ee[0].rowStart<=ye;){const X=Ee.shift();X.rowEnd>ye&&(H.push(X),Ge=!0)}Ge&&(H=H.sort(n.CoordUtils.columnFirstRangeComparator));const Ae=x.getLayout(),ht=Ae.getRowOffset(ye+1);let Ze=J;for(let X=0;X<H.length+1;X++){let _e=Ze,yt=ee;const mt=H[X];X<H.length&&(yt=Math.min(ee,Ae.getColOffset(mt.colStart)),Ze=Math.min(ee,Ae.getColOffset(mt.colEnd+1))),E.push(l.createElement("path",{d:`M ${o.ReactUtils.boundPixel(_e)} ${o.ReactUtils.boundPixel(ht,!1,v)} L ${o.ReactUtils.boundPixel(yt)} ${o.ReactUtils.boundPixel(ht,!1,v)}`,stroke:ie,strokeWidth:1,vectorEffect:"non-scaling-stroke",...Z,key:q+ye+":"+X}))}for(let X=H.length-1;X>=0;X--)H[X].rowEnd<=V[be+1]&&H.splice(X,1)}}else{const q=`view:${x.getAnchor()}:vl:`,V=x.getVisibleColumns();if(!V||V.length===0)return;const J=0,ee=x.getBounds().height;let H=[];const Ee=I.sort(n.CoordUtils.columnFirstRangeComparator),Ne=x.getVisibleRangeCoords();for(let be=0;be<V.length&&V[be]<=Ne.colEnd;be++){const ye=V[be];if(ye<Ne.colStart)continue;let Ge=!1;for(;Ee.length>0&&Ee[0].colStart<=ye;){const X=Ee.shift();X.colEnd>ye&&(H.push(X),Ge=!0)}Ge&&(H=H.sort(n.CoordUtils.rowFirstRangeComparator));const Ae=x.getLayout(),ht=Ae.getColOffset(ye+1);let Ze=J;for(let X=0;X<H.length+1;X++){let _e=Ze,yt=ee;const mt=H[X];X<H.length&&(yt=Math.min(ee,Ae.getRowOffset(mt.rowStart)),Ze=Math.min(ee,Ae.getRowOffset(mt.rowEnd+1)));let ve=ie;E.push(te.jsx("path",{d:`M ${o.ReactUtils.boundPixel(ht,!1,v)} ${o.ReactUtils.boundPixel(_e)} L ${o.ReactUtils.boundPixel(ht,!1,v)} ${o.ReactUtils.boundPixel(yt)}`,stroke:ve,strokeWidth:1,vectorEffect:"non-scaling-stroke",...oe},q+ye+":"+X))}for(let X=H.length-1;X>=0;X--)H[X].colEnd<=V[be+1]&&H.splice(X,1)}}},Jt=x=>{if(!Mt)return;const b={};for(let v=0;v<At.length;v++){const E=At[v],I=De[E],q=[];ro(I,x,0,q,x?Mt[E].rangesH:Mt[E].rangesV);const V=I.getRangeCoordsBounds(),J=Math.ceil(V.width),ee=Math.ceil(V.height);b[E]=te.jsx("svg",{width:`${J}`,height:`${ee}`,viewBox:`0 0 ${J} ${ee}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:q})}return b},lo=l.useMemo(()=>O===!0||O?.horizontal===!0?Jt(!0):null,[Xe,O,Me,_,U,ie,Z,d,h,$e,St,Mt]),io=l.useMemo(()=>O===!0||O?.vertical===!0?Jt(!1):null,[Xe,O,Fe,_,U,ie,oe,d,h,Ue,je,Mt]),yo=l.useMemo(()=>wt.left===0?null:te.jsx(Po,{linePoints:[0,0,0,Ue+1],bounds:{x:wt.left,y:0,width:1,height:Ue+1},...xe}),[Xe,wt.left,Ue,xe]),vo=l.useMemo(()=>wt.top===0?null:te.jsx(Po,{linePoints:[0,0,$e+1,0],bounds:{x:0,y:wt.top,width:$e+1,height:1},...$}),[Xe,wt.top,$e,$]),Qt=l.useMemo(()=>{const x=[],b=v=>{if(!v||!De[v])return;const E=De[v].getBounds();return te.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:E.x,top:E.y,width:E.width,height:E.height,clip:`rect(0, ${E.width+1}px, ${E.height+1}px, 0)`},className:`view view-${v}`,children:[lo?.[v],io?.[v],Mt?.[v].cells]},`view:${v}`)};for(let v=0;v<At.length;v++)x.push(b(At[v]));return te.jsx(te.Fragment,{children:x})},[De,lo,io,Mt]),Ro=l.useMemo(()=>{if(!r)return;const x=(V,J,ee,H)=>{if(!H||H.length===0)return;const Ee=[];for(let Ne=0;Ne<H.length;Ne++){const be=H[Ne];let ye=V?.get(be);ye!==Mo&&(ye=be(ee)??Mo),J.set(be,ye),ye&&ye!==Mo&&Ee.push(ye)}return Ee},b=(V,J,ee)=>{if(!ee)return;const H=ee.getBounds(),Ee=ee.getInsets(),Ne=ee.getAnchor();return te.jsxs("div",{className:Vt("view",`view-${Ne}`,Xo.view),style:{position:"absolute",pointerEvents:"none",left:H.x-Ee.left,top:H.y-Ee.top,width:H.width-(Ee.left+Ee.right),height:H.height-(Ee.top+Ee.bottom),clipPath:C?"inset(-2px)":"inset(0px)"},children:[x(V,J,ee,Ce),bo?.[Ne].overlays]},`view:${Ne}`)},v=rt.current,E={},I=[],q=Object.keys(De);for(let V=0;V<q.length;V++){const J=q[V],ee=v?.[J],H=E[J]=new Map;I.push(b(ee,H,De[J]))}return rt.current=E,I},[Xe,De,C,Ce]),Eo=l.useMemo(()=>{const{style:x,...b}=Be??{};return te.jsx("div",{style:{width:$e,height:Ue,...x},className:"sheetxl-stage",tabIndex:0,ref:ze,...b,...Bt,children:Ke?Ke(Qt):Qt})},[$e,Ue,Qt,Be,Ke]),co=l.useRef(!1);return l.useEffect(()=>{!co.current&&Mt&&(co.current=!0,he?.(Wt.current))},[Mt]),te.jsxs("div",{className:Vt("sheetxl-grid",Xo["sheetxl-grid"]),style:{overflow:"visible",cursor:Q,maxWidth:$e,maxHeight:Ue,width:$e,height:Ue,...de},ref:Wt,children:[Eo,te.jsxs("div",{className:Vt("sheetxl-overlays"),ref:Ye,...L,children:[Ro,yo,vo]})]})}));zo.displayName="BaseGrid";const $o=l.memo(l.forwardRef((t,r)=>{const{width:i,height:c,style:d={},className:h,...a}=t,[s,{width:w,height:P}]=nn(),z=i??w,M=c??P;return te.jsx("div",{className:h,style:{...d},children:te.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:s,children:te.jsx(zo,{ref:r,width:z,height:M,...a})})})}));$o.displayName="Grid";const ln=l.memo(l.forwardRef((t,r)=>{const{showVerticalScrollbar:i,showHorizontalScrollbar:c,createHorizontalScrollbar:d,createVerticalScrollbar:h,createScrollCorner:a,viewport:s,onScrollViewport:w,style:P={},className:z,onScroll:M,...T}=t,[O,ie]=l.useState(null),Z=l.useRef(null),oe=l.useRef(null);go(!s),l.useImperativeHandle(r,()=>oe.current&&Z.current?Object.assign(oe.current,Z.current):null);const Pe=l.useCallback(Q=>{oe.current?.scrollTo(Q),w?.(Q)},[]);return te.jsx(o.ScrollPane,{className:z,style:P,ref:Z,showVerticalScrollbar:i,showHorizontalScrollbar:c,createHorizontalScrollbar:d,createVerticalScrollbar:h,createScrollCorner:a,viewport:O,onScrollViewport:Pe,children:te.jsx($o,{style:{width:"100%",height:"100%"},...T,onViewportChange:Q=>ie(Q),ref:oe})})}));ln.displayName="ScrollableGrid";const _o=()=>!1,cn=l.memo(t=>{const{index:r,value:i,zoom:c,zoomScale:d=100,headerText:h=Ce=>`${Ce}`,headerStyle:a,headerStyleSelect:s=a,headerStyleSelectAll:w=s,headerStyleHover:P=w,verticalPadding:z=0,horizontalPadding:M=0,isSelected:T=_o,isSelectedAll:O=_o,coords:ie,bounds:Z,range:oe,orientation:Pe,view:Q,style:U,..._}=t,xe=d/100,$=l.useRef(null),[ge,Le]=l.useState(!1),Ie=T?.(r)||!1,Oe=O?.(r)?w:Ie?s:a;let ae=Oe;if(ge){let Ce=P;typeof P=="function"&&(Ce=P(Oe)),ae=n.CommonUtils.mergeContentful(Oe,Ce)}return te.jsx("div",{ref:$,style:{background:ae.fill,color:ae.text?.fill,fontFamily:ae.text?.fontFamily??a.text?.fontFamily,fontSize:96*(ae.text?.fontSize??11)/72*xe,fontStyle:ae.text?.fontStyle,fontWeight:ae.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${xe}px`,...U,left:U.left-(Pe===n.RangeOrientation.Column?1:0),top:U.top-(Pe===n.RangeOrientation.Row?1:0),width:U.width+1,height:U.height+1,overflow:"hidden"},..._,onMouseMove:Ce=>{o.ReactUtils.detectIt().primaryInput!=="touch"&&Ce.buttons===0&&Le(!0)},onMouseOut:Ce=>{Le(!1)},children:h(r)})});cn.displayName="HeaderRenderer";const sn="ew-resize",an="ns-resize",dn=l.memo(l.forwardRef((t,r)=>{const{orientation:i,view:c,index:d,className:h,style:a,disabled:s=!1,disabledResize:w=!1,isNextHidden:P,isHidden:z,isSelected:M,isSelectedAll:T,showTouchDivider:O,headerStyle:ie,headerStyleSelect:Z,headerStyleSelectAll:oe,headerStyleHover:Pe,bounds:Q,onPointerDown:U,onAutoFit:_,...xe}=t,$=i===n.RangeOrientation.Column;let ge=ie;M&&Z&&(ge=Z),T&&oe&&(ge=oe);const Le=o.ReactUtils.detectIt().primaryInput==="touch";let Ie=$?14:8,Oe=Ie/2,ae=0;P&&(ae=-2),z&&(ae=2),z&&(Ie=Ie/2+ae,Oe=2*ae);let Ce=ge.dividerStrokeFill??ge.strokeFill;return!(M||T)&&ae===0&&(Ce=`linear-gradient(${$?180:90}deg, ${ge.fill}, ${Ce} 55%, ${Ce} 100%)`),te.jsxs("div",{className:Vt("header-divider",{disabled:s},h,`index-${d}`),ref:r,onPointerDown:Le?void 0:U,onDoubleClick:Le?void 0:()=>_?.(),style:{top:($?0:-Ie/2+(ae-1))+"px",left:($?-Ie/2+(ae-1):0)+"px",width:$?Ie:"calc(100% + 1px)",height:$?"calc(100% + 1px)":Ie,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:s||w||Le?void 0:$?sn:an,...a},...xe,children:[te.jsx("div",{style:{position:"relative",top:`${$?0:Oe}px`,left:`${$?Oe:0}px`,width:$?1:"100%",height:$?"100%":1,background:Ce},onDoubleClick:()=>_?.()}),O&&Le?te.jsx("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:$?"-6px":"2px",bottom:$?"2px":"-9px",height:"24px",width:$?"24px":"18px",maxHeight:$?"calc(100% - 4px)":void 0,maxWidth:$?void 0:"calc(100% - 4px)",background:ge.fill,border:`${oe.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${ie.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:U,children:te.jsx("div",{style:{width:"6.4px",height:"12px",backgroundImage:`url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(Z.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`,backgroundRepeat:"no-repeat",backgroundPosition:"center",transform:$?void 0:"rotate(90deg)"}})}):null]})})),Un=(t,r)=>te.jsx(dn,{...t,ref:r}),Tn=l.memo(l.forwardRef((t,r)=>{const{orientation:i,view:c,index:d,disabled:h=!1,disabledResize:a=!1,resizeThreshold:s=1,dividerRenderer:w=Un,onDividerMouseDown:P,onDividerResizeStart:z,onDividerResize:M,onDividerResizeEnd:T,onDividerMouseUp:O,onDividerAutoFit:ie,onPointerDown:Z,...oe}=t,Pe=o.useCallbackRef(Z,[Z]),Q=o.useCallbackRef(ie,[ie]),U=i===n.RangeOrientation.Column;let _=U?c.getVisibleColumns():c.getVisibleRows(),xe=null;_.length>0&&(U?xe=c.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:_[0],colEnd:_[_.length-1]}):c.getRangeCoordsBounds({rowStart:_[0],rowEnd:_[_.length-1],colStart:0,colEnd:0}),xe=c.toClipBounds(xe,It));const $=l.useRef(null),[ge,Le]=l.useState(null),Ie=(A,ne)=>U?A.clientX-ne.clientX:A.clientY-ne.clientY,Oe=c.getLayout(),ae=U?Oe.getColOffset(d+1):Oe.getRowOffset(d+1),Ce=o.useSynchronizedPointerHandler({processTouch:!0,onPointerDown:A=>{if(Pe?.(A),!h&&!a){const ne=U?Oe.getColOffset(d):Oe.getRowOffset(d),K=ae-ne;$.current={isResizing:!1,startSize:K,index:d,view:c,orientation:i,onDividerMouseDown:P,onDividerResizeStart:z,onDividerResize:M,onDividerResizeEnd:T,onDividerMouseUp:O},Le($.current),P?.(d,K)}A.stopPropagation(),A.preventDefault()},onPointerUp:(A,ne,K)=>{if(!$.current)return;$.current.isResizing&&$.current.onDividerResizeEnd?.($.current.index,Math.max(0,$.current.startSize+Ie(A,K)),$.current.startSize);const Y=$.current;$.current=null,Le($.current),Y.onDividerMouseUp?.(Y.index)},onPointerMoveOrWait:(A,ne,K)=>{if(!$.current)return;const Y=Ie(A,K);$.current.isResizing?$.current.onDividerResize?.($.current.index,Math.max(0,$.current.startSize+Y),$.current.startSize):Math.abs(Y)>Math.max(1,s)&&($.current={...$.current,isResizing:!0},Le($.current),$.current.onDividerResizeStart?.($.current.index,Math.max(0,$.current.startSize+Y))),A.stopPropagation(),A.preventDefault()}}),L=o.useCallbackRef(()=>{Q?.(d)},[d]);if(!xe)return;const C=w({bounds:xe,orientation:i,view:c,index:d,disabled:h,disabledResize:a,onAutoFit:L,onPointerDown:Ce,...oe},r);if(!C)return;const{getPortalContainer:Be}=o.useFullscreenPortal();let Ke=null;return ge&&ge.isResizing&&ge.index===d&&(Ke=Zo.createPortal(te.jsx("div",{style:{position:"absolute",cursor:U?sn:an,left:0,top:0,width:"100%",height:"100%"}}),Be(),"divider:"+d)),te.jsxs(te.Fragment,{children:[Ke,te.jsx("div",{className:Vt("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${U?xe.y:ae}px`,left:`${U?ae:xe.x}px`,width:(U?0:xe.width-1)+"px",height:(U?xe.height-1:0)+"px",display:"flex"},tabIndex:-1,children:C})]})}));class Ln{naturalDimensions(r,i={}){const c=document.createElement("div");let d=i?.lineHeight??"1";!i?.lineHeight&&i.paintableText?.fontSize&&(d=Math.ceil(1.2*i.paintableText.fontSize)+"px");const h=document.createElement("div");h.style.visibility="hidden",h.style.position="absolute",h.style.textRendering="geometricprecision",h.style.display="inline-grid",h.style.overflowWrap="break-word",h.style.maxWidth=i.maxWidth?i.maxWidth+"px":"100%",h.style.lineHeight=d,h.style.letterSpacing=(i.paintableText?.letterSpacing??0)+"px",h.style.fontSize=i.paintableText?.fontSize?i.paintableText.fontSize+"px":"unset",h.style.fontFamily=i.paintableText?.fontSize?i.paintableText.fontFamily:"unset",h.style.fontWeight=i.paintableText?.fontWeight?""+i.paintableText.fontWeight:"400",h.style.fontStyle=i.paintableText?.fontStyle?i.paintableText.fontStyle:"normal",h.style.whiteSpace=i.paintableText?.wrap==="wrap"?"break-spaces":"pre",c.appendChild(h);const a=r.split(`
12
+ `);for(let w=0;w<a.length;w++){let P=document.createElement("span");h.appendChild(P),P.textContent=a[w]}a.length!==0&&a[a.length-1].length!==0||h.appendChild(document.createElement("br")),document.body.appendChild(h);let s=h.getBoundingClientRect();return h.remove(),{width:s.width,height:s.height,maxLineHeight:1.2*(i.paintableText?.fontSize||1056/72)}}}const un=(t=void 0)=>Object.freeze({clean:t,dirty:void 0,editMode:!1}),On=un(),zn=l.memo(l.forwardRef((t,r)=>{const{editState:i=On,defaultTextStyle:c,onStartEdit:d,onChangeEdit:h,onSubmitEdit:a,onCancelEdit:s,onDoneEdit:w,containerBounds:P,setNaturalDimensions:z,onNavigate:M,textProperties:T,style:O,autoFocus:ie,...Z}=t,oe=l.useRef(null),{width:Pe=0}=P??{},[Q,U]=l.useState(()=>i);l.useEffect(()=>{U(i)},[i]);const _=T?.align||"left",xe=T?.vAlign||"middle",$=T?.fill||"#040404",ge=T?.wrap||"wrap",Le=T?.fontFamily||"Calibri",Ie=T?.fontSize||11,Oe=T?.fontWeight||400,ae=T?.fontStyle||"normal",Ce=Q.dirty??Q.clean??"";let L=2;const C=96*Ie/72,Be=1.2*C;xe==="right"&&(L+=1);const Ke=l.useMemo(()=>new Ln().naturalDimensions(Ce,{maxWidth:ge==="wrap"?Pe-L:void 0,lineHeight:`${Be}px`,paintableText:{fontStyle:ae,wrap:ge,letterSpacing:-.25}}),[Ce,ge,L,C,Le,Oe,ae,z,Pe]),A=l.useCallback(()=>Ke.maxLineHeight?Ke.maxLineHeight+"px":"1.2",[Ke]),[ne,K]=l.useState(A);l.useLayoutEffect(()=>{K(A())},[P,Ke]),l.useLayoutEffect(()=>{z?.({width:ge==="wrap"?void 0:Ke.width+L,height:Ke.height})},[Ke,z]);const Y=o.useCallbackRef(h,[h]),ce=o.useCallbackRef(y=>{if(Q.dirty===y)return;const Re={...Q};Re.dirty=y,oe.current,U(Re),Y?.(Re)},[Q]),Et=o.useCallbackRef(y=>{if(Q.editMode===y)return;const Re={...Q};Re.editMode=y,U(Re),Y?.(Re)},[Q]),dt=o.useCallbackRef(()=>{try{return a?.(Q),w?.(),!0}catch{return!1}},[a,Q]),tt=o.useCallbackRef(()=>{U(i),s?.(),w?.()},[s,i]),ot=o.useCallbackRef(y=>{if(!oe.current)return;if(y.isDefaultPrevented(),!(y.isTrusted||y.nativeEvent.ctrlKey||y.nativeEvent.metaKey||y.nativeEvent.altKey||y.nativeEvent.isComposing)&&Lo.indexOf(y.nativeEvent.key)!==-1){const re={...Q};return re.dirty=y.nativeEvent.key==="Backspace"?"":(re.dirty??"")+y.key,U(re),Y?.(re),void y.preventDefault()}const Re=y.nativeEvent.shiftKey;if(y.which===o.KeyCodes.Escape)return y.preventDefault(),void tt();if(y.which===o.KeyCodes.F2)return Et(!0),void y.preventDefault();if(y.which===o.KeyCodes.Enter&&(y.preventDefault(),dt()&&M?.(Re?n.Direction.Up:n.Direction.Down)),y.which===o.KeyCodes.Tab)return y.preventDefault(),void(dt()&&M?.(Re?n.Direction.Left:n.Direction.Right));if(!Q.editMode){let re=null;switch(y.which){case o.KeyCodes.Left:re=n.Direction.Left;break;case o.KeyCodes.Right:re=n.Direction.Right;break;case o.KeyCodes.Up:re=n.Direction.Up;break;case o.KeyCodes.Down:re=n.Direction.Down}if(re)return void dt()}},[Q,M]),[de,Bt]=l.useState(!ie);l.useEffect(()=>{Bt(!1)},[]);const D=o.useImperativeElement(r,()=>({startEdit(y){let Re=y?.initialSelection;if(!Re){const he=oe.current.value.length??0;Re={start:he,end:he,direction:"forward"}}oe.current?.setSelectionRange(Re.start,Re.end,Re.direction);const re={...i,editMode:y?.editMode??!1};y?.text!==void 0&&(re.dirty=y.text),re.editMode===i.editMode&&re.dirty===i.dirty||(U(re),Y?.(re))},submitEdit:()=>dt(),cancelEdit(){tt()},autoFocus(){oe.current?.focus()},getLineHeight:()=>Ke?.maxLineHeight??Be,dispatchEvent:y=>oe.current.dispatchEvent(y)}),[i,d]);return te.jsx("div",{ref:D,...Z,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:Ke.height,maxWidth:"100%",maxHeight:"100%",...O},children:te.jsx("textarea",{spellCheck:"false",ref:oe,value:Ce,autoFocus:!1,disabled:de,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${C}px`,fontFamily:`${Le}`,fontWeight:`${Oe}`,fontStyle:`${ae}`,padding:"0px",marginRight:_==="right"?"3px":"0px",marginLeft:_==="left"?"2px":"0px",lineHeight:ne,height:Ke.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:_,background:"transparent",color:$,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:ge==="wrap"?"break-spaces":"pre",wordWrap:"break-word"},onChange:y=>{ce(y.target.value)},onDoubleClick:y=>{y.isTrusted},onMouseDown:y=>{Et(!0)},onKeyDown:ot})})})),$n=l.memo(t=>{const{value:r,view:i,bounds:c,range:d,zoom:h,children:a,style:s,...w}=t,P=s?.fontSize||1056/72;return te.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:P,...s},...w,children:r})});exports.BaseGrid=zo,exports.DefaultCellEditor=zn,exports.DefaultCellRenderer=$n,exports.DefaultHeaderDivider=dn,exports.FillHandle=Uo,exports.Grid=$o,exports.HeaderDivider=Tn,exports.HeaderRenderer=cn,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=It,exports.STANDARD_KEY_CHARS=Lo,exports.SVGLine=Po,exports.SVGRect=en,exports.ScrollableGrid=ln,exports.Selection=Oo,exports.TouchSelectHandle=fo,exports.defaultSelectionRenderer=qo,exports.getDefaultStringEditState=un,exports.safeSelectionCoords=Rt,exports.useCellLayout=Qo,exports.useHeaderSelection=({gridRef:t,gridMainRef:r,orientation:i=n.RangeOrientation.Row,headerCount:c,selectionPolicy:d="multiple",newSelectionMode:h="clear",alwaysScrollToActiveCoords:a=!0,onDragStart:s,onDragEnd:w,pointerDownInterceptor:P,pointerMoveInterceptor:z,onPointerUp:M,newSelection:T,modifySelection:O,appendSelection:ie,clearSelections:Z})=>{const oe=c??((i===n.RangeOrientation.Row?t.current?.rowCount:t.current?.columnCount)||0),Pe=l.useRef(null),Q=l.useRef(null),U=l.useRef(!1),_=l.useRef(null),xe=l.useCallback(L=>i===n.RangeOrientation.Column?{rowIndex:0,colIndex:L.colIndex}:{rowIndex:L.rowIndex,colIndex:0},[i]),$=l.useCallback(L=>i===n.RangeOrientation.Column?{rowIndex:r.current?r.current.rowCount-1:0,colIndex:L.colIndex}:{rowIndex:L.rowIndex,colIndex:r.current?r.current.columnCount-1:0},[i]),ge=L=>{Q.current=$(L),O(Q.current,Pe.current)},Le=l.useCallback((L,C)=>{if(!t.current)return;const Be=t.current.getViewFromClient(L,C)?.getCellCoordsFromClient(L,C);return Be?(i===n.RangeOrientation.Column?Be.rowIndex=r.current.getViewport().rowStart:Be.colIndex=r.current.getViewport().colStart,Be):void 0},[]),Ie=l.useCallback((L,C=!1)=>{let Be=L;return C||(Be={...L},i===n.RangeOrientation.Row?delete Be.colIndex:delete Be.rowIndex),r.current?.scrollCellCoordsIntoView(Be)},[i]),Oe=o.useCallbackRef(w,[w]),ae=o.useCallbackRef(s,[s]),Ce=l.useMemo(()=>({onPointerDown:L=>{if(!t||!t.current||L.nativeEvent.defaultPrevented)return;const C=Le(L.nativeEvent.clientX,L.nativeEvent.clientY);if(!C)return;L.nativeEvent.which,o.MouseButtonCodes.Right;const Be=L.nativeEvent.shiftKey,Ke=L.nativeEvent.ctrlKey||L.nativeEvent.metaKey;if(P?.(L,C)===!1)return;ae?.(),U.current=!0;const A=r.current?.getViewFromClient(L.nativeEvent.clientX,L.nativeEvent.clientY),ne=((K,Y)=>i===n.RangeOrientation.Column?{...K,rowIndex:Y.rowStart}:{...K,colIndex:Y.colStart})(C,A.getVisibleRangeCoords());if(Be)ge(C);else{if(Ke)return((K,Y=K,ce)=>{Pe.current=xe(K),Q.current=$(Y),ie(Pe.current,Q.current,ce)})(C,C,ne),void(a&&Ie(ne,!0));((K,Y=K,ce)=>{Pe.current=xe(K),Q.current=$(Y),T(Pe.current,Q.current,ce)})(C,C,ne),ge(C),a&&Ie(ne,!0)}},onPointerMoveOrWait:n.CommonUtils.throttle(L=>{if(!U.current||!t?.current)return;const C=Le(L.clientX,L.clientY);if(C&&z?.(L,C)!==!1){if(n.CoordUtils.isEqualCells(_.current,C))return Z();ge(C),Ie(C)}},60),onPointerUp:L=>{U.current=!1,Oe?.(),M?.(L)},processTouch:!0,consumeTouch:!0}),[d,a,oe,h,Z,P,M]);return{onPointerDown:o.useCallbackRef(o.useSynchronizedPointerHandler(Ce),[]),getCellCoordsFromClient:Le}},exports.useKeyboardEditorOverlay=t=>{const{view:r,canEdit:i=wn,getCellEditor:c,onBeforeStartEdit:d,onStartEdit:h,onSubmitEdit:a,onCancelEdit:s,onDoneEdit:w,isEditorStartKeyEvent:P=xn,isEditorStartPointerEvent:z=pn,containerProps:M,borderStrokeFill:T,borderStrokeWidth:O=2,getRangeCoords:ie=null,activeCoords:Z,alignment:oe=o.HorizontalAlignment.Left}=t,[Pe,Q]=l.useState(!1),[U,_]=l.useState(void 0),xe=o.useCallbackRef((D,y,Re,re,he,ze)=>{if(!y)return null;const Ye=he?.(y,D),gt=D.getRangeCoordsBounds(Ye),Xe=D.toClipBounds(gt),Ut=gt,it=D.getZoom();if(!Xe)return null;Re&&(Re*=it),re&&(re*=it);let S=Ut,le=!1;if(Re!==void 0){let He={...Ye},Ht=0;for(;!le&&S.width<=Re&&Ht<20;){Ht++,Ht>19&&console.warn("max width reached");const $t=D.getTotalRangeCoords(),Ct=D.getLayout();ze===o.HorizontalAlignment.Left?He.colEnd+1<$t.colEnd?He.colEnd=Ct.getColIndex(S.x+Re):le=!0:ze===o.HorizontalAlignment.Right?He.colStart-1>=0?He.colStart=Ct.getColIndex(S.x-(Re-S.width)):le=!0:ze===o.HorizontalAlignment.Center&&He.colEnd+1<$t.colEnd&&He.colStart-1>=0?(He.colStart=Ct.getColIndex(S.x-(Re-S.width)/2),He.colEnd=Ct.getColIndex(S.x+S.width+(Re-S.width)/2)):le=!0,le||(S=D.getRangeCoordsBounds(He))}}S.height=Ut.height,re!==void 0&&(S.height=Math.max(re+1,Ut.height));const{width:Ve,height:nt}=D.getViewportSize();return{x:S.x??0,y:S.y??0,height:Math.min(nt-S.y,S.height)+1,width:Math.min(Ve-S.x,S.width)+1}},[oe]),$=o.useCallbackRef(i,[i]),ge=l.useCallback(()=>{r?.getStage()?.focus()},[r]),Le=l.useRef(null),Ie=o.useCallbackRef(D=>{d?.(D),Y(),Q(!0),Le.current=null},[d]),Oe=o.useCallbackRef(D=>{h?.(D.coords)},[h]),ae=o.useCallbackRef(D=>{D.isSubmitted||D.isCancelled||(C.current.isEditorClosed=!0,ge(),D.isCancelled=!0,s?.(D.coords),Y())},[s]),Ce=o.useCallbackRef(D=>{if(D.isSubmitted||D.isCancelled)return!1;try{return Le.current=D.coords,D.isEditorClosing=!0,D.isSubmitted=!0,D.isEditorSubmitted||(D.isEditorSubmitted=!0,D.editorRefs[0]?.submitEdit?.()),D.coords,a?.(D.coords),D.isEditorClosed=!0,ge(),Y(),!0}catch(y){throw D.isEditorClosing=!1,D.isSubmitted=!1,y}},[a]),L=o.useCallbackRef(D=>{Q(!1),w?.(D.coords),Y()},[w]),C=l.useRef(null),Be=l.useRef(null),Ke=l.useRef(null),A=l.useRef([]),[ne,K]=l.useReducer(D=>D+1,0),Y=l.useCallback(D=>{D&&A.current.push(D),K()},[]),ce=o.useCallbackRef(D=>{if(D.defaultPrevented||D.isSynthetic||!r)return;const y=r?.getCellCoordsFromClient(D.clientX,D.clientY);y&&Y({eventType:"pointer",event:D,coords:y})},[r]),Et=o.useCallbackRef(D=>{const y=D.nativeEvent;ce(y)},[r]),dt=o.useCallbackRef(D=>{if(D.defaultPrevented||D.isSynthetic||!r?.getStage())return;const y=Be.current;P(D,y)&&(D.stopPropagation(),D.preventDefault()),D.key,Y({eventType:"keyboard",event:D,coords:y})},[r]);l.useLayoutEffect(()=>{const D=(re,he)=>{const ze=he?.cell??re;if(!ze)return null;const Ye=ze;if(!$(ze))return null;Ie?.(ze);const gt=n.CommonUtils.uuidV4();he=Object.freeze({autoFocus:!0,...he}),Ke.current=ze;const Xe={coords:Ye,startEvent:he,uuid:gt,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:Ut=>{Xe.isMounted||(Xe.isMounted=!0,Y())},onUnmount:Ut=>{if(Xe.editorRefs.length===0){const it=()=>{Xe.isMounted=!1,Y()};if(document.activeElement!==document.body)it();else{const S=le=>{le.defaultPrevented||le.target!==document.body||dt(le)};window.addEventListener("keydown",S,!0),r.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",S),it()},{once:!0}),ge()}}}};return Xe};if(A.current.length<=0&&!C.current)return;const y=A.current[0];Ko(y),(re=>{const he=[],ze=re?.length??0;for(let Ye=0;Ye<ze;Ye++){const gt=re[Ye];he.push(Ko(gt))}})(A.current),C.current,C.current;let Re=C.current;if(C.current){if(C.current.isDone)C.current=null;else if(C.current.isSubmitted||C.current.isCancelled){if(C.current.isMounted)return;C.current.isDone||(L(C.current),C.current.isDone=!0)}}if(y){if(y.eventType==="start"){const re=y,he=re.startEvent?.cell??Be.current;C.current&&n.CoordUtils.isEqualCells(C.current.coords,he)||(C.current=D(he,re.startEvent))}else if(y.eventType==="keyboard"){const re=y.event;if(C.current){let he=!1;switch(re.which){case o.KeyCodes.Left:case o.KeyCodes.Right:case o.KeyCodes.Up:case o.KeyCodes.Down:case o.KeyCodes.Enter:case o.KeyCodes.Tab:he=!0}if(!he){C.current.events.push(y);for(let ze=0;ze<C.current.editorRefsDispatchEditorEvent.length;ze++)C.current.editorRefsDispatchEditorEvent[ze](y)}}else if(P(re,y.coords)){let he;const ze=D(he?.cell??Be.current,he);ze&&ze.events.push(y),C.current=ze}}else if(y.eventType==="pointer"){const re=y.event;if(C.current){C.current.events.push(y);for(let he=0;he<C.current.editorRefsDispatchEditorEvent.length;he++)C.current.editorRefsDispatchEditorEvent[he](y)}else{const he=y?.coords??Be.current,ze=z(re,he);if(ze){let Ye;typeof Ye!="boolean"&&(Ye=ze);const gt=D(he,Ye);gt&&gt.events.push(y),C.current=gt}}}else if(y.eventType==="submit"){if(C.current&&!C.current.isSubmitted&&!C.current.isCancelled){if(!C.current.isMounted)return;Ce(C.current)}}else if(y.eventType==="cancel"){if(C.current&&!C.current.isSubmitted&&!C.current.isCancelled){if(!C.current.isMounted)return;ae(C.current)}}else if(y.eventType==="coordsChange"){const re=y;if(Be.current=re.activeCoords,C.current,C.current&&!C.current.isSubmitted&&!C.current.isCancelled){if(!C.current.isMounted)return;try{Ce(C.current)}catch{}}}}A.current.length>0&&(A.current.shift(),Y()),A.current.length===0&&(!C.current||C.current.isEditorClosing||C.current.isEditorClosed?!C.current&&Re&&ge():C.current.isMounted&&!C.current.isStarted&&(C.current.isStarted=!0,C.current.startEvent.autoFocus&&(typeof C.current.startEvent.autoFocus=="string"?C.current.editorRefs[0]?.autoFocus(C.current.startEvent.autoFocus):C.current.editorRefs[0]?.autoFocus()),Oe?.(C.current),requestAnimationFrame(()=>{r&&C.current?.coords&&r.scrollCellCoordsIntoView(C.current.coords)})))},[ne]),l.useEffect(()=>{Ke.current=Z;const D=C.current?.coords;n.CoordUtils.isEqualCells(D,Z)||(C.current&&(C.current.isEditorClosing=!0),Y({eventType:"coordsChange",activeCoords:Z}))},[Z]);const tt=l.useCallback(D=>{dt(D.nativeEvent)},[]),{width:ot=0,height:de=0}=U??{width:0,height:0},Bt=o.useCallbackRef(c,[c]);return{overlay:o.useCallbackRef(D=>{if(!C.current||C.current.isEditorClosed)return C.current,null;C.current.coords;let y=xe(D,C.current.coords,ot,de,ie,oe),Re=!0;y&&y.width!==0&&y.height!==0||(y={x:0,y:0,width:ot,height:ot},Re=!1);const re=D.getZoom(),he={containerBounds:{x:0,y:0,width:y.width/re,height:y.height/re},setNaturalDimensions:_,zoom:re};return te.jsx(mn,{session:C.current,refLatestCoords:Ke,handleSubmitEdit:Ce,handleCancelEdit:ae,cellBounds:y,borderStrokeWidth:O,borderStrokeFill:T,isInBounds:Re,getCellEditor:Bt,propsEditor:he,alignment:oe,...M},"editor:"+C.current.uuid)},[c,ie,ne,ot,de,oe,O,T]),startEdit:l.useCallback(D=>{Y({eventType:"start",startEvent:D})},[]),submitEdit:l.useCallback(()=>{Y({eventType:"submit"})},[]),cancelEdit:l.useCallback(()=>{Y({eventType:"cancel"})},[]),onKeyboardEvent:tt,onPointerEvent:Et,onKeyboardEventNative:dt,onPointerEventNative:ce,isEditing:Pe}},exports.useSelection=({gridRef:t,commands:r,layout:i,selection:c,onSelectionChange:d,onSelectionDragStart:h,onSelectionDragEnd:a,selectionPolicy:s="multiple",newSelectionMode:w="clear",allowDeselectSelection:P=!0,onFillPreview:z,onFillCancel:M,onFillDone:T,onFill:O,disableFillDrag:ie=!O,fillHandleBorderColor:Z="white",hiddenRowsAt:oe,hiddenColumnsAt:Pe,isContentfulCell:Q,contentfulCellFinder:U=bn,getDataCoords:_,alwaysScrollToActiveCoords:xe=!1,selectionBounds:$,pointerDownInterceptor:ge,pointerMoveInterceptor:Le,mergedRanges:Ie,canSelectionSpanMergedCells:Oe=kn,onMoveDragStart:ae,onMoveDragUpdate:Ce,onMoveDragEnd:L,onMoveDragDone:C,selectionRenderer:Be=qo,disableMoveDrag:Ke=!L,getCellCoordsAsRangeCoords:A=n.CoordUtils.cellToRange,moveDragHitSize:ne=6,moveDragOutlineSize:K=4,selectionBackgroundColor:Y="rgba(16, 124, 65, 0.1)",selectionBorderColor:ce="rgb(33, 115, 70)",selectionRemoveBorderColor:Et="rgb(255, 0, 0)",selectionRemoveBackgroundColor:dt="rgba(250, 10, 10, 0.1)",disableTouchSelection:tt=!1,touchSelectHandleProps:ot})=>{const de=l.useCallback(()=>({top:$?.top??0,left:$?.left??0,bottom:t.current?.rowCount-1||0,right:t.current?.columnCount-1||0}),[]),Bt=o.useCallbackRef(O,[O]),D=o.useCallbackRef(z,[z]),y=o.useCallbackRef(M,[M]),Re=o.useCallbackRef(T,[T]),re=o.useCallbackRef(Q,[Q]),he=o.useCallbackRef(Be,[Be]),ze=o.useCallbackRef((e,u=!1)=>wo(e,u,i.getRowOffset,u?de().bottom:de().top),[i?.getRowOffset]),Ye=o.useCallbackRef(oe??ze,[oe]),gt=o.useCallbackRef((e,u=!1)=>wo(e,u,i.getColOffset,u?de().right:de().left),[i?.getColOffset]),Xe=o.useCallbackRef(Pe??gt,[Pe]),[Ut,it]=l.useState(()=>Rt(c)),S=l.useMemo(()=>Rt(Ut),[Ut]),le=l.useRef(S),Ve=l.useRef(!0);l.useLayoutEffect(n.CommonUtils.throttle(()=>{it(e=>{Ve.current=!0;const u=Rt(c);return n.CoordUtils.isEqualSelectionCoords(u,e)?e:u})},0),[c]),l.useLayoutEffect(()=>{le.current=S},[S]),l.useEffect(()=>{Ve.current||!d||n.CoordUtils.isEqualSelectionCoords(c,S)||d(S)},[S]);const nt=l.useCallback(e=>{it(u=>{Ve.current=!1,u=Rt(u);let g=typeof e=="function"?e(u.ranges):e??To;if(n.CoordUtils.isEqualRangesArrays(g,u.ranges))return u;let f=Math.max(g.length?0:-1,Math.min(u.rangeIndex,g.length-1)),m=u.cell;f===-1||n.CoordUtils.isCellWithinRange(m,g[f])||(m={rowIndex:g[f].rowStart,colIndex:g[f].colStart}),g.length===1&&n.CoordUtils.isSingleCell(g[0])&&n.CoordUtils.isCellWithinRange(m,g[0])&&(g=[],f=-1);const k={cell:m,ranges:g,rangeIndex:f};return n.CoordUtils.isEqualSelectionCoords(k,u)?u:k})},[]),He=o.useCallbackRef(e=>{it(u=>{Ve.current=!1,u=Rt(u);const g=e??rn,f=A(g);if(!n.CoordUtils.isSingleCell(f)&&u.ranges.length===0)return{ranges:[f],rangeIndex:0,cell:g};if(n.CoordUtils.isEqualCells(g,u.cell))return u;let m=u.ranges,k=u.rangeIndex;u.ranges.length===1&&(n.CoordUtils.isSingleCell(u.ranges[0])&&n.CoordUtils.isCellWithinRange(g,u.ranges[0])||!n.CoordUtils.isCellWithinRange(g,u.ranges[0]))&&(m=[],k=-1);const p={ranges:m,rangeIndex:k,cell:g};return n.CoordUtils.isEqualSelectionCoords(p,u)?u:p})},[A]),[Ht,$t]=l.useState(null),[Ct,Xt]=l.useState(null),zt=l.useRef(null),[ke,Pt]=l.useState(null),ct=l.useRef(null),kt=l.useRef(null),[eo,jt]=l.useState(null),$e=l.useRef(null),Ue=l.useRef(null),Kt=l.useRef(Ie);l.useEffect(()=>{Kt.current=Ie},[Ie]);const st=o.useCallbackRef((e,u={inline:"nearest",block:"nearest"})=>{let{rowIndex:g,colIndex:f}=e;g===void 0&&S?.cell&&(g=S.cell.rowIndex),f===void 0&&S?.cell&&(f=S.cell.colIndex),g!==void 0&&f!==void 0&&t.current?.scrollCellCoordsIntoView({rowIndex:g,colIndex:f},u)},[S]),Tt=l.useCallback(e=>{const u=de();return e.rowIndex<u.top||e.colIndex<u.left||e.colIndex>u.right||e.rowIndex>u.bottom},[]),Me=o.useCallbackRef((e,u)=>{if(!t?.current)return null;const g={rowStart:Math.min(e.rowIndex,u.rowIndex),colStart:Math.min(e.colIndex,u.colIndex),rowEnd:Math.max(e.rowIndex,u.rowIndex),colEnd:Math.max(e.colIndex,u.colIndex)};if(Oe?.(g))return g;const m=A(e),k=A(u),p={rowStart:Math.min(m.rowStart,k.rowStart),colStart:Math.min(m.colStart,k.colStart),rowEnd:Math.max(m.rowEnd,k.rowEnd),colEnd:Math.max(m.colEnd,k.colEnd)};let N;return typeof Kt.current=="function"?N=Kt.current(p):Ie&&(N=Ie),N?n.CoordUtils.extendRangeToUnionRanges(p,N):p},[Oe,A]),Fe=o.useCallbackRef((e,u,g)=>{const f=e.ranges.length>0?e.ranges[e.rangeIndex]:{rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},m={rowStart:Math.min(u.rowIndex??f.rowStart,g.rowIndex??f.rowStart),colStart:Math.min(u.colIndex??f.colStart,g.colIndex??f.colStart),rowEnd:Math.max(u.rowIndex??f.rowEnd,g.rowIndex??f.rowEnd),colEnd:Math.max(u.colIndex??f.colEnd,g.colIndex??f.colEnd)},k={rowIndex:m.rowStart,colIndex:m.colStart},p={rowIndex:m.rowEnd,colIndex:m.colEnd};if(!(Tt(k)||Tt(p)))return Me(k,p)},[Me]),rt=o.useCallbackRef((e,u,g)=>{if(s==="single"||!le.current)return;const f=Fe(le.current,e,u??le.current.cell);if(!f)return;const m=le.current.rangeIndex;nt(k=>k.length?k.map((p,N)=>m===N?f:p):[f]),g&&f&&He({colIndex:f.colStart,rowIndex:f.rowStart})},[]),ut=l.useCallback((e,u,g)=>{if(!le.current)return;e={...le.current?.cell,...e},u=u??e;const f=Fe(le.current,e,u);if(!f)return;const m={rowIndex:f.rowStart,colIndex:f.colStart},k={...m,...g};w==="clear"?($e.current=k,At()):w==="modify"?rt(m):De(m),He(k)},[]),De=l.useCallback((e,u=e,g)=>{s!=="multiple"||!e||Tt(e)||Tt(u)||it(f=>{Ve.current=!1,f=Rt(f);const m=Me(e,u);if(!m)return f;let k=f.ranges.length>0?[...f.ranges]:[Me(f.cell,f.cell)];k.push(m);const p={ranges:k,cell:{rowIndex:m.rowStart,colIndex:m.colStart,...g},rangeIndex:k.length-1};return n.CoordUtils.isEqualSelectionCoords(p,f)?f:p})},[]),At=()=>{nt(To)},St=o.ReactUtils.detectIt().primaryInput==="touch",je=l.useRef(null),wt=l.useRef(null),bt=l.useRef(null),Nt=l.useMemo(()=>({onPointerDown:e=>{if(!t||!t.current)return!1;const u=e.nativeEvent,g=t.current.getViewFromClient(u.clientX,u.clientY);if(u.pointerType==="touch"||u.type==="touchstart")return wt.current={topLeft:g.getScrollTopLeft(),point:{x:u.clientX,y:u.clientY}},!0;const f=g.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!f)return!1;je.current={anchor:g.getAnchor(),coords:f},Ue.current=null;const m=e.nativeEvent.which===o.MouseButtonCodes.Right;if(m&&n.CoordUtils.indexOfCoords(f,S.ranges)!==-1)return!1;const k=e.nativeEvent.shiftKey,p=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,N=p,B=P,F=S.ranges.length>0,G=p&&B;if(ge?.(e,f,S)===!1)return!1;h?.(le.current,e.nativeEvent);const me=!m&&s!=="single";if(k)return rt(f),me;const j=n.CoordUtils.isEqualCells(f,S.cell);if(N){if(j&&(!G||!F))return me;if(p&&n.CoordUtils.indexOfCoords(f,S.ranges)!==-1&&B){ct.current=f;const W=Me(f,f);return kt.current=W,Pt(W),me}return De(f),me}xe&&st(f),j&&S.ranges.length===0||ut(f)},onPointerMoveOrWait:n.CommonUtils.throttle((e,u)=>{if(!t?.current||e.pointerType==="touch"||e.type==="touchmove"||!je.current)return;const g=je.current.anchor;let f=t.current.getViewFromLocation(g),m=f.getCellCoordsFromClient(e.clientX,e.clientY);if(!n.CoordUtils.isEqualCells(m,je.current?.coords)&&(je.current={anchor:g,coords:m},m&&Le?.(e,m,le.current)!==!1)){if(ct.current){const k={rowStart:Math.min(m.rowIndex,ct.current.rowIndex),colStart:Math.min(m.colIndex,ct.current.colIndex),rowEnd:Math.max(m.rowIndex,ct.current.rowIndex),colEnd:Math.max(m.colIndex,ct.current.colIndex)},p={rowIndex:k.rowStart,colIndex:k.colStart},N={rowIndex:k.rowEnd,colIndex:k.colEnd};if(Tt(p)||Tt(N))return;const B=Me(p,N);kt.current=B,Pt(B)}else rt(m);bt.current=u,ho(f,m,t)}},60),onPointerUp:e=>{if(je.current=null,e.pointerType==="touch"||e.type==="touchend"){if(wt.current){const g=t.current.getViewFromClient(wt.current.point.x,wt.current.point.y),f=g.getScrollTopLeft();if(f.left===wt.current.topLeft.left&&f.top===wt.current.topLeft.top){const m=g.getCellCoordsFromClient(wt.current.point.x,wt.current.point.y);ut(m)}}return wt.current=null,void(je.current=null)}try{a?.(le.current,e)}catch(g){console.warn(g)}if(!ct.current)return;const u=kt.current;ct.current=null,kt.current=null,Pt(null),it(g=>{if(Ve.current=!1,(g=Rt(g)).ranges.length===0)return g;let f=[],m=-1,k=g.cell;for(let N=0;N<g.ranges.length;N++){const B=g.ranges[N];if(n.CoordUtils.isRangesIntersect(B,u)){const F=n.CommonUtils.subtractRect({top:B.rowStart,left:B.colStart,bottom:B.rowEnd+1,right:B.colEnd+1},{top:u.rowStart,left:u.colStart,bottom:u.rowEnd+1,right:u.colEnd+1});for(let G=0;G<F.length;G++){const me={rowStart:F[G].top,colStart:F[G].left,rowEnd:F[G].bottom-1,colEnd:F[G].right-1};f.push(me),n.CoordUtils.isCellWithinRange(g.cell,me)&&(m=f.length-1)}}else f.push(B);f.length>0&&m===-1&&n.CoordUtils.isCellWithinRange(g.cell,B)&&(m=f.length-1,k={rowIndex:f[f.length-1].rowStart,colIndex:f[f.length-1].colStart})}const p={cell:k,rangeIndex:m,ranges:f};return n.CoordUtils.isEqualSelectionCoords(p,g)?g:p})},processTouch:!0,consumeTouch:!1}),[S,s,P,xe,w]),xo=o.useCallbackRef(o.useSynchronizedPointerHandler(Nt),[]),po=l.useMemo(()=>({onSelectionPointerDown:(e,u,g,f,m=S.cell,k=xe,p=e.nativeEvent.shiftKey,N=!1)=>{if(!t||!t.current)return!1;e.stopPropagation(),e.preventDefault(),e.nativeEvent.stopImmediatePropagation();const B=g??t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),F=f??B.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!F)return!1;je.current={anchor:B.getAnchor(),coords:F},Ue.current=null;const G=e.nativeEvent.which===o.MouseButtonCodes.Right;if(G&&n.CoordUtils.indexOfCoords(F,S.ranges)!==-1)return!1;const me=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,j=me,W=P,et=S.ranges.length>0,R=me&&W;if(ge?.(e,F,S)===!1)return!1;h?.(le.current,e.nativeEvent);const fe=!G&&s!=="single";if(p)return rt(F,m,N),fe;const at=n.CoordUtils.isEqualCells(F,m);if(j){if(at&&(!R||!et))return fe;if(R&&n.CoordUtils.indexOfCoords(F,S.ranges)!==-1&&W){ct.current=F;const ue=Me(F,F);return kt.current=ue,Pt(ue),fe}return De(F),fe}k&&st(F),at&&S.ranges.length===0||ut(F)},onSelectionPointerMoveOrWait:(e,u,g,f,m,k=S.cell,p=!0,N=!1)=>{if(!t?.current||(e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation(),!je.current))return;const B=je.current.anchor;let F=f??t.current.getViewFromLocation(B),G=m??F.getCellCoordsFromClient(e.clientX,e.clientY);if(!n.CoordUtils.isEqualCells(G,je.current?.coords)&&(je.current={anchor:B,coords:G},G&&Le?.(e,G,le.current)!==!1)){if(ct.current){const me={rowStart:Math.min(G.rowIndex,ct.current.rowIndex),colStart:Math.min(G.colIndex,ct.current.colIndex),rowEnd:Math.max(G.rowIndex,ct.current.rowIndex),colEnd:Math.max(G.colIndex,ct.current.colIndex)},j={rowIndex:me.rowStart,colIndex:me.colStart},W={rowIndex:me.rowEnd,colIndex:me.colEnd};if(Tt(j)||Tt(W))return;const et=Me(j,W);kt.current=et,Pt(et)}else rt(G,k,N);p&&ho(F,G,t)}},onPointerUp:e=>{je.current=null,e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation();try{a?.(le.current,e)}catch(g){console.warn(g)}if(!ct.current)return;const u=kt.current;ct.current=null,kt.current=null,Pt(null),it(g=>{if(Ve.current=!1,(g=Rt(g)).ranges.length===0)return g;let f=[],m=-1,k=g.cell;for(let N=0;N<g.ranges.length;N++){const B=g.ranges[N];if(n.CoordUtils.isRangesIntersect(B,u)){const F=n.CommonUtils.subtractRect({top:B.rowStart,left:B.colStart,bottom:B.rowEnd+1,right:B.colEnd+1},{top:u.rowStart,left:u.colStart,bottom:u.rowEnd+1,right:u.colEnd+1});for(let G=0;G<F.length;G++){const me={rowStart:F[G].top,colStart:F[G].left,rowEnd:F[G].bottom-1,colEnd:F[G].right-1};f.push(me),n.CoordUtils.isCellWithinRange(g.cell,me)&&(m=f.length-1)}}else f.push(B);f.length>0&&m===-1&&n.CoordUtils.isCellWithinRange(g.cell,B)&&(m=f.length-1,k={rowIndex:f[f.length-1].rowStart,colIndex:f[f.length-1].colStart})}const p={cell:k,rangeIndex:m,ranges:f};return n.CoordUtils.isEqualSelectionCoords(p,g)?g:p})}}),[S,s,P,xe,w]),qe=o.useCallbackRef((e,u=!1,g=!1,f=0)=>{if(!t.current||!S.cell)return;let m=S.cell,k=S.cell;if(u&&S.ranges.length>0){const R=S.ranges[S.rangeIndex],fe=S.cell;switch(e){case n.Direction.Up:k={rowIndex:fe.rowIndex===R.rowStart?R.rowEnd:R.rowStart,colIndex:R.colEnd},m={rowIndex:fe.rowIndex===R.rowStart?R.rowStart:R.rowEnd,colIndex:R.colStart};break;case n.Direction.Down:k={rowIndex:fe.rowIndex===R.rowEnd?R.rowStart:R.rowEnd,colIndex:R.colEnd},m={rowIndex:fe.rowIndex===R.rowEnd?R.rowEnd:R.rowStart,colIndex:R.colStart};break;case n.Direction.Left:k={rowIndex:R.rowEnd,colIndex:fe.colIndex===R.colStart?R.colEnd:R.colStart},m={rowIndex:R.rowStart,colIndex:fe.colIndex===R.colStart?R.colStart:R.colEnd};break;case n.Direction.Right:k={rowIndex:R.rowEnd,colIndex:fe.colIndex===R.colEnd?R.colStart:R.colEnd},m={rowIndex:R.rowStart,colIndex:fe.colIndex===R.colEnd?R.colEnd:R.colStart}}}const p=A(k);let{rowStart:N,colStart:B}=p;const F=de();if(Ue.current)switch(e){case n.Direction.Up:case n.Direction.Down:Ue.current.colIndex>=p.colStart&&Ue.current.colIndex<=p.colEnd&&(B=Ue.current.colIndex);break;case n.Direction.Left:case n.Direction.Right:Ue.current.rowIndex>=p.rowStart&&Ue.current.rowIndex<=p.rowEnd&&(N=Ue.current.rowIndex)}if(!f){switch(e){case n.Direction.Up:N=Te(Ye,Math.max(p.rowStart-1,F.top),e);break;case n.Direction.Down:N=Te(Ye,Math.min(p.rowEnd+1,F.bottom),e);break;case n.Direction.Left:B=Te(Xe,Math.max(p.colStart-1,F.left),e);break;case n.Direction.Right:B=Te(Xe,Math.min(p.colEnd+1,F.right),e)}if(g)switch(e){case n.Direction.Up:N=U({...k,colIndex:S.cell.colIndex},re,Ye,e,!1,Math.max(F.top,Ye(F.top,!1)));break;case n.Direction.Down:N=U({...k,colIndex:S.cell.colIndex},re,Ye,e,!1,Math.min(F.bottom,F.bottom-Ye(F.bottom,!0)));break;case n.Direction.Left:B=U({...k,rowIndex:S.cell.rowIndex},re,Xe,e,!1,Math.max(F.left,Xe(F.left,!1)));break;case n.Direction.Right:B=U({...k,rowIndex:S.cell.rowIndex},re,Xe,e,!1,Math.min(F.right,F.right-Xe(F.right,!0)))}}let G=null;if(f){let R=0;switch(e){case n.Direction.Up:R=i.getRowOffset(N+1),N=Math.max(F.top,i.getRowIndex(R-f)),G={top:i.getRowOffset(N+1)-(R-t.current.getScrollPosition().top)};break;case n.Direction.Down:R=i.getRowOffset(N),N=Math.min(F.bottom,i.getRowIndex(R+f)),G={top:i.getRowOffset(N)-(R-t.current.getScrollPosition().top)};break;case n.Direction.Left:R=i.getColOffset(B+1),B=Math.max(F.left,i.getColIndex(R-f)),G={left:i.getColOffset(B+1)-(R-t.current.getScrollPosition().left)};break;case n.Direction.Right:R=i.getColOffset(B),B=Math.min(F.right,i.getColIndex(R+f)),G={left:i.getColOffset(B)-(R-t.current.getScrollPosition().left)}}}const me={rowIndex:N,colIndex:B},j=A(me),W={rowIndex:j.rowStart,colIndex:j.colStart};u||(Ue.current=me);const et=n.CoordUtils.isEqualCells($e.current,W)&&n.CoordUtils.isEqualCells($e.current,m);if(u&&!et?rt(W,m):ut(W),G)t.current.scrollTo(G);else{if(u&&$e.current){const R=de();if(e===n.Direction.Right&&$e.current.colIndex===R.left||e===n.Direction.Left&&$e.current.colIndex===R.right||e===n.Direction.Up&&$e.current.rowIndex===R.bottom||e===n.Direction.Down&&$e.current.rowIndex===R.top)return}e===n.Direction.Left||e===n.Direction.Right?st({colIndex:me.colIndex}):e!==n.Direction.Up&&e!==n.Direction.Down||st({rowIndex:me.rowIndex})}},[S,A]),Lt=o.useCallbackRef(e=>{if(!t.current)return;if(S.ranges.length===0)return void qe(e);const u=A(S.cell);if(n.CoordUtils.isEqualRangesArrays([u],S.ranges))return void qe(e);const g=Do(S,e,A,Ye,Xe);it(f=>{Ve.current=!1,f=Rt(f);const m={...f,cell:g.cell,rangeIndex:g.rangeIndex};return n.CoordUtils.isEqualSelectionCoords(m,f)?f:m}),g.cell&&st(g.cell)},[S,A]),mo=l.useCallback(()=>{const e=de();rt({rowIndex:e.top},{rowIndex:e.bottom})},[]),Co=l.useCallback(()=>{const e=de();rt({colIndex:e.left},{colIndex:e.right})},[]),Ft=o.useCallbackRef(()=>{S.cell&&t?.current&&st(S.cell)},[S.cell]),to=l.useCallback((e=!1)=>{const u={rowIndex:de().top};e?rt(u):ut(u),st(u)},[]),oo=l.useCallback((e=!1)=>{const u={rowIndex:de().bottom};e?rt(u):ut(u),st(u)},[]),Gt=l.useCallback((e=!1)=>{const u={colIndex:de().left};e?rt(u):ut(u),st(u)},[]),qt=l.useCallback((e=!1)=>{const u=de(),g={rowIndex:u.top,colIndex:u.left};e?rt(g):ut(g),st(g)},[]),_t=l.useCallback((e=!1)=>{const u=de(),g={colIndex:_?.()?.colEnd??u.right};e?rt(g):ut(g),st(g)},[_]),Wt=l.useCallback((e=!1)=>{const u=de(),g={rowIndex:_?.()?.rowEnd??u.bottom,colIndex:_?.()?.colEnd??u.right};e?rt(g):ut(g),st(g)},[_]),Zt=o.useCallbackRef(e=>{if(!t.current||S.ranges.length<=1)return;const u=e===n.Direction.Left||e===n.Direction.Up;let g=S.rangeIndex+(u?-1:1);g<0?g=S.ranges.length-1:g>S.ranges.length-1&&(g=0);const f=S.ranges[g],m=Do({cell:{rowIndex:f.rowEnd,colIndex:f.colEnd},rangeIndex:0,ranges:[f]},n.Direction.Right,A,Ye,Xe);it(k=>{Ve.current=!1,k=Rt(k);const p={...k,cell:m.cell,rangeIndex:g};return n.CoordUtils.isEqualSelectionCoords(p,k)?k:p}),m.cell&&st(m.cell)},[S,A]),So=o.useCallbackRef(()=>{const e=Vo(S);it(u=>{Ve.current=!1,u=Rt(u);const g={...u,visibleSelection:e};return n.CoordUtils.isEqualSelectionCoords(g,u)?u:g}),e.cell&&st(e.cell)},[S,A]),bo=o.useCallbackRef(()=>{if(!t.current||S.ranges.length===0)return;const e=S.cell,u=S.ranges[S.rangeIndex],g=Vo({cell:e,rangeIndex:0,ranges:[u]}),f=g.ranges[g.rangeIndex];let m;m=f.rowStart===e.rowIndex&&f.colStart===e.colIndex?{rowIndex:f.rowStart,colIndex:f.colEnd}:f.rowStart===e.rowIndex&&f.colEnd===e.colIndex?{rowIndex:f.rowEnd,colIndex:f.colStart}:f.rowEnd===e.rowIndex&&f.colStart===e.colIndex?{rowIndex:f.rowEnd,colIndex:f.colEnd}:{rowIndex:f.rowStart,colIndex:f.colStart},it(k=>{k=Rt(k);const p={...k,cell:m};return n.CoordUtils.isEqualSelectionCoords(p,k)?k:p}),m&&st(m)},[S,A]),no=l.useCallback((e=!1)=>{qe(n.Direction.Down,e,!1,t.current.getDimensions().containerHeight)},[]),Mt=l.useCallback((e=!1)=>{qe(n.Direction.Up,e,!1,t.current.getDimensions().containerHeight)},[]),ro=l.useCallback((e=!1)=>{qe(n.Direction.Right,e,!1,t.current.getDimensions().containerWidth)},[]),Jt=l.useCallback((e=!1)=>{qe(n.Direction.Left,e,!1,t.current.getDimensions().containerWidth)},[]),lo=l.useCallback(()=>{Lt(n.Direction.Left)},[]),io=l.useCallback(()=>{Lt(n.Direction.Right)},[]),yo=l.useCallback(()=>{Lt(n.Direction.Up)},[]),vo=l.useCallback(()=>{Lt(n.Direction.Down)},[]),Qt=l.useCallback(()=>{Zt(n.Direction.Left)},[]),Ro=l.useCallback(()=>{Zt(n.Direction.Right)},[]),Eo=l.useCallback(()=>{bo()},[]),co=l.useCallback(()=>{qe(n.Direction.Left,!1,!1)},[]),x=l.useCallback(()=>{qe(n.Direction.Left,!0,!1)},[]),b=l.useCallback(()=>{qe(n.Direction.Left,!1,!0)},[]),v=l.useCallback(()=>{qe(n.Direction.Left,!0,!0)},[]),E=l.useCallback(()=>{qe(n.Direction.Right,!1,!1)},[]),I=l.useCallback(()=>{qe(n.Direction.Right,!0,!1)},[]),q=l.useCallback(()=>{qe(n.Direction.Right,!1,!0)},[]),V=l.useCallback(()=>{qe(n.Direction.Right,!0,!0)},[]),J=l.useCallback(()=>{qe(n.Direction.Up,!1,!1)},[]),ee=l.useCallback(()=>{qe(n.Direction.Up,!0,!1)},[]),H=l.useCallback(()=>{qe(n.Direction.Up,!1,!0)},[]),Ee=l.useCallback(()=>{qe(n.Direction.Up,!0,!0)},[]),Ne=l.useCallback(()=>{qe(n.Direction.Down,!1,!1)},[]),be=l.useCallback(()=>{qe(n.Direction.Down,!0,!1)},[]),ye=l.useCallback(()=>{qe(n.Direction.Down,!1,!0)},[]),Ge=l.useCallback(()=>{qe(n.Direction.Down,!0,!0)},[]),Ae=l.useCallback(()=>{nt(e=>e.slice(0,-1))},[]),ht=l.useMemo(()=>{const e=de();return((u,g,f,m,k)=>{for(let p=0;p<u.length;p++){const N=u[p];if(N.rowStart===g&&N.colStart===f&&N.rowEnd===m&&N.colEnd===k)return!0}return!1})(S.ranges,e.top,e.left,e.bottom,e.right)},[$,S.ranges]),Ze=l.useCallback((e,u=!0)=>{$e.current=e,He(e),u&&e&&t?.current&&st(e)},[]),X=o.useCallbackRef((e=!0)=>{const u=zt.current;if(!le.current?.cell)return;const g=le.current?.ranges,f=le.current?.cell;if(!f||!u||!u)return;let m=null;if(m=g.length>0?g[g.length-1]:A(f),m.colEnd>=m.colStart&&m.rowEnd>=m.rowStart){const k=Ho(m,u);let p=e?Bt:D;try{p?.(m,u,k.direction)}catch(N){console.warn(N)}finally{e&&Re?.()}}},[A]),_e=l.useRef(null),yt=l.useMemo(()=>({onPointerDown:(e,u)=>{if(bt.current=u,!t||!t.current)return!1;const g=t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),f=g?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);f&&(e.stopPropagation(),$t("crosshair"),_e.current={anchor:g.getAnchor(),coords:f})},onPointerMoveOrWait:(e,u)=>{if(ie||!t?.current||!le.current||!_e.current)return;const g=_e.current.anchor;let f=t.current.getViewFromLocation(g),m=f.getCellCoordsFromClient(e.clientX,e.clientY);if(!m)return;_e.current={anchor:g,coords:m};const k=le.current.ranges;let p=Me(le.current.cell,m);if(!p)return;const N=k.length>0,B=N?k[k.length-1]:A(le.current.cell);if(!p)return;const F=p.rowStart<B.rowStart?n.Direction.Up:p.rowEnd>B.rowEnd?n.Direction.Down:p.colEnd>B.colEnd?n.Direction.Right:n.Direction.Left,G=de();F===n.Direction.Left&&(p={...B,colStart:Math.max(G.left,p.colStart)}),F===n.Direction.Up&&(p={...B,rowStart:Math.max(G.top,p.rowStart)}),F===n.Direction.Right&&(p={...B,colEnd:Math.min(G.right,p.colEnd)}),F===n.Direction.Down&&(p={...B,rowEnd:Math.min(G.bottom,p.rowEnd)});const me=Ho(B,p);if(!Oe?.(B)){let j;typeof Kt.current=="function"?j=Kt.current(B):Ie&&(j=Ie),p=((W,et,R,fe,at,ue)=>{const se={...et};if(R.length===0)return se;if(at===n.Direction.Left){const Qe=W.colEnd+1-W.colStart;se.colStart=W.colStart-Math.ceil(ue/Qe)*Qe,se.colStart<fe.left&&(se.colStart=se.colStart+Math.ceil((fe.left-se.colStart)/Qe)*Qe)}else if(at===n.Direction.Right){const Qe=W.colEnd+1-W.colStart;se.colEnd=W.colEnd+Math.ceil(ue/Qe)*Qe,se.colEnd>fe.right&&(se.colEnd=se.colEnd-Math.ceil((fe.right-se.colEnd)/Qe)*Qe)}else if(at===n.Direction.Up){const Qe=W.rowEnd+1-W.rowStart;se.rowStart=W.rowStart-Math.ceil(ue/Qe)*Qe,se.rowStart<fe.top&&(se.rowStart=se.rowStart+Math.ceil((fe.top-se.rowStart)/Qe)*Qe)}else if(at===n.Direction.Down){const Qe=W.rowEnd+1-W.rowStart;se.rowEnd=W.rowEnd+Math.ceil(ue/Qe)*Qe,se.rowEnd>fe.bottom&&(se.rowEnd=se.rowEnd-Math.ceil((fe.bottom-se.rowEnd)/Qe)*Qe)}return se})(B,p,j,G,me.direction,me.amount)}if(N&&n.CoordUtils.isRangeWithinRange(p,B)&&(p=null),!n.CoordUtils.isEqualRanges(p,zt.current)){if(Xt(p),zt.current=p,!p){try{y?.()}catch{}return void Re?.()}X(!1)}bt.current=u,ho(f,m,t)},onPointerUp:(e,u)=>{bt.current=u,Promise.resolve(X(!0)).finally(()=>{Re?.(),Xt(null),zt.current=null,_e.current=null,$t(null),t.current?.focus()})}}),[A]),mt=o.useSynchronizedPointerHandler(yt),ve=l.useMemo(()=>({onPointerDown:mt}),[mt]),[Se,We]=l.useState(null),pe=l.useRef(null),we=l.useMemo(()=>({onPointerDown:(e,u)=>{if(bt.current=u,!t||!t.current)return!1;const g=t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),f=g?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!f)return;if(ge?.(e,f,S)===!1)return!1;e.stopPropagation(),$t("default");const m=g.getRelativePointFromClient(0,0),k=le.current?.ranges[le.current?.ranges.length-1]??n.CoordUtils.cellToRange(le.current?.cell),p=g.toClipBounds(g.getRangeCoordsBounds(k)),N={x:0,y:0};p.x-m.x>e.nativeEvent.clientX?N.x=e.nativeEvent.clientX-(p.x-m.x):e.nativeEvent.clientX>=p.x-m.x+p.width&&(N.x=Math.max(0,e.nativeEvent.clientX-(p.x-m.x+p.width))+1),p.y-m.y>e.nativeEvent.clientY?N.y=e.nativeEvent.clientY-(p.y-m.y):e.nativeEvent.clientY>=p.y-m.y+p.height&&(N.y=Math.max(0,e.nativeEvent.clientY-(p.y-m.y+p.height))+1),ae?.(k,e.nativeEvent,u),pe.current={range:k,anchor:g.getAnchor(),cell:f,isMoving:!1,extrusion:N}},onPointerMoveOrWait:(e,u,g)=>{if(Ke||!t?.current||!le.current||!pe.current)return;const f=e.clientX-g.clientX,m=e.clientY-g.clientY;if(pe.current.isMoving=pe.current.isMoving||Math.abs(f)>Math.max(1,2)||Math.abs(m)>Math.max(1,2)||performance.now()-g.timeStamp>500,!pe.current.isMoving)return;const k=pe.current.anchor,p=pe.current.extrusion;let N=t.current.getViewFromLocation(k),B=N.getCellCoordsFromClient(e.clientX-p.x,e.clientY-p.y,!0);if(!B)return;const F=pe.current.cell,G=pe.current.range,me=de(),j=G.colEnd-G.colStart+1,W=Math.min(Math.max(0,F.colIndex-G.colStart),j-1),et=Math.min(me.right-j+1,Math.max(me.left,B.colIndex-W)),R=G.rowEnd-G.rowStart+1,fe=Math.min(Math.max(0,F.rowIndex-G.rowStart),R-1),at=Math.min(me.bottom-R+1,Math.max(me.top,B.rowIndex-fe)),ue={colStart:et,colEnd:et+j-1,rowStart:at,rowEnd:at+R-1};n.CoordUtils.isEqualRanges(Se,ue)&&!(se=>!se||!bt.current||bt.current.ctrlKey!==se.ctrlKey||bt.current.shiftKey!==se.shiftKey||bt.current.altKey!==se.altKey||bt.current.metaKey!==se.metaKey)(e)||(We(ue),Ce?.(ue,e,u)),bt.current=u,ho(N,B,t)},onPointerUp:(e,u)=>{bt.current=u;const g=()=>{We(null),pe.current=null,$t(null),t.current?.focus()};if(!pe.current)return void g();const f=pe.current.range,m=Se;L?.(f,e,u),Promise.resolve(f&&m&&C?.(f,m,e,u)).finally(()=>{g()})}}),[Se]),Je=o.useSynchronizedPointerHandler(we),lt=l.useMemo(()=>({onPointerDown:Je}),[Je]),xt=l.useRef(null),vt=l.useMemo(()=>{const e=n.CoordUtils.isEqualSelectionCoords(S,xt.current)?xt.current:S;return xt.current=e,e},[S]),ft=l.useCallback(e=>{let u=null,g="br";const f=[],m={stroke:Z,fill:Y,strokeWidth:.5},k=(j,W,et)=>{const R=e.toClipBounds(e.getRangeCoordsBounds(j),It);if(!R)return;R.x=R.width>0?R.x:R.x-m.strokeWidth/2,R.y=R.height>0?R.y:R.y-m.strokeWidth/2,R.width=Math.max(R.width,m.strokeWidth),R.height=Math.max(R.height,m.strokeWidth);const fe={key:`selection-fill-${W}`,range:j,...R,...m};if(et){const at=e.getCellCoordsAsRangeCoords(et);fe.cell=et,fe.pathBounds=e.toClipBounds(e.getRangeCoordsBounds(at),It),fe.pathBounds&&(fe.pathBounds.width<=0||fe.pathBounds.height<=0)&&(delete fe.pathBounds,delete fe.cell)}return he(fe)};let p=S?Rt(S):null;const N=p?.cell?e.getCellCoordsAsRangeCoords(p?.cell):In;!p||p.ranges&&p.ranges.length!==0||(p={ranges:[N],rangeIndex:0,cell:p.cell});for(let j=0;p&&j<p.ranges.length;j++){const W=p.ranges[j],et=k(W,j,j===p.rangeIndex?p.cell:null);et&&f.push(et);const R=2,fe=.5,at=e.toClipBounds(e.getRangeCoordsBounds(W,{top:0,left:0,right:0,bottom:0}),It);if(at){const ue=(p.ranges.length,4);f.push(he({range:W,key:`selection-inside-edge-${j}`,x:at.x-1,y:at.y-1,width:Math.max(at.width+1,0),height:Math.max(at.height+1,0),style:{overflow:"hidden"},stroke:Z,strokeWidth:ue}))}if(p.ranges.length===1){const ue=e.toClipBounds(e.getRangeCoordsBounds(W),It);if(ue){Ke||f.push(he({range:W,key:`move-selection-hit-box-${j}`,x:ue.width>1?ue.x:ue.x-(ne/2+1),y:ue.height>1?ue.y:ue.y-(ne/2+1),width:Math.max(ue.width+2,1),height:Math.max(ue.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:Se?void 0:"move",pointerEvents:"stroke"},strokeWidth:ne,...lt}));const se=R;f.push(he({range:W,key:`selection-single-${j}`,x:ue.x-se/2,y:ue.y-se/2,width:Math.max(ue.width+se/2,1),height:Math.max(ue.height+se/2,1),stroke:ce,strokeWidth:se}))}}else{const ue=e.toClipBounds(e.getRangeCoordsBounds(W,{top:-1,left:-1,right:-2,bottom:-2}),It);ue&&f.push(he({range:W,key:`selection-multi-${j}`,x:ue.width>1?ue.x:ue.x-fe/2,y:ue.height>1?ue.y:ue.y-fe/2,width:Math.max(ue.width,fe)+1,height:Math.max(ue.height,fe)+1,stroke:ce,style:{overflow:"hidden"},strokeWidth:2}))}if(p.ranges.length>1&&j===p.rangeIndex){const ue=e.getCellCoordsAsRangeCoords(p.cell),se=e.toClipBounds(e.getRangeCoordsBounds(ue,{top:1,left:1,right:-1,bottom:-1}),It);se&&f.push(he({range:W,key:`selection-anchor-${j}`,x:se.x,y:se.y,width:Math.max(se.width,fe),height:Math.max(se.height,fe),stroke:ce,style:{overflow:"hidden"},strokeWidth:2}))}if(j===p.ranges.length-1){u=null,g=null;const ue=W.rowStart===de().top&&W.rowEnd===de().bottom,se=W.colStart===de().left&&W.colEnd===de().right,Qe=e.getRangeCoordsBounds(W);let Dt=null;if(ue||se){if(Dt=e.toClipBounds(Qe,It),Object.keys(e.allViews()).length>1){const so=e.getVisibleRangeCoords(),Ao=e.allViews()[n.AnchorLocation.TopLeft],hn=e.allViews()[n.AnchorLocation.Top],fn=e.allViews()[n.AnchorLocation.Left],ao=e.getAnchor();(se&&(ao===n.AnchorLocation.Top&&Ao||ao===n.AnchorLocation.Center&&fn||!n.CoordUtils.isCellWithinRange({colIndex:W.colStart,rowIndex:W.rowEnd},so)&&!n.CoordUtils.isCellWithinRange({colIndex:W.colStart,rowIndex:W.rowEnd+1},so))||ue&&(ao===n.AnchorLocation.Left&&Ao||ao===n.AnchorLocation.Center&&hn||!n.CoordUtils.isCellWithinRange({colIndex:W.colEnd,rowIndex:W.rowStart},so)&&!n.CoordUtils.isCellWithinRange({colIndex:W.colEnd+1,rowIndex:W.rowStart},so)))&&(Dt=null)}}else Dt=e.toClipBounds(Qe,It);if(!Dt||Dt.width===0||Dt.height===0)continue;u={x:Dt.x+Dt.width+1,y:Dt.y+Dt.height+1},Dt.width===0||Dt.height===0||W.rowStart===de().top&&W.colStart===de().left&&W.rowEnd===de().bottom&&W.colEnd===de().right||(ue?(u.y=R,g="tr"):se&&(u.x=R,g="bl"))}}let B=null;if(ke){const j=e.toClipBounds(e.getRangeCoordsBounds(ke,{top:0,left:0,right:0,bottom:0}),It);j&&(B=he({...m,range:ke,key:"remove-selection",x:j.x,y:j.y,width:j.width,height:j.height,strokeWidth:2,stroke:Et,fill:dt}))}let F=null;if(Ct){const j=e.toClipBounds(e.getRangeCoordsBounds(Ct,{top:0,left:0,right:0,bottom:0}),It);j&&(F=he({range:Ct,key:"selection-fill-outline",x:j.x-2/2,y:j.y-2/2,width:j.width+2/2,height:j.height+2/2,strokeWidth:2,stroke:ce,strokeDasharray:"3 2"}))}let G=null;!ie&&u&&!Se&&(G=l.createElement(Uo,{...u,corner:g,size:7.5,borderStroke:`${Z} solid`,style:{borderRadius:1},background:ce,...ve,key:"fillHandle"}));const me=[...f];if(B&&me.push(B),F&&me.push(F),G&&me.push(G),!tt&&St&&p?.ranges.length===1&&p.ranges[p.ranges.length-1]){const j=p.ranges[p.ranges.length-1],W=j.rowStart===de().top&&j.rowEnd===de().bottom,et=j.colStart===de().left&&j.colEnd===de().right,R={view:e,range:j,borderStroke:`${ce} solid`,background:Z,selectionTouchPointerHandler:po,...ot,onTouchSelectStart:fe=>jt(fe),onTouchSelectEnd:()=>jt(null),currentTouchAnchor:eo};me.push(te.jsx(fo,{anchor:et?"b":W?"r":"br",scrollableElement:t.current,...R},"touch-select-handle-after")),me.push(te.jsx(fo,{anchor:et?"t":W?"l":"tl",scrollableElement:t.current,...R},"touch-select-handle-before"))}if(Se){const j=e.toClipBounds(e.getRangeCoordsBounds(Se,{top:1,left:1,right:1,bottom:1}),It);j&&me.push(he({range:Se,key:"selection-move-outline",x:j.x-K/2,y:j.y-K/2,width:Math.max(j.width+K/2,1),height:Math.max(j.height+K/2,1),stroke:ce,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:K}))}return te.jsx("div",{children:me},"selection")},[vt,ke,ie,Ct,Ke,Se,de,Z,ce,Y,Et,dt,tt,ot,eo]),pt=l.useMemo(()=>{const e=()=>t.current;return[new o.SimpleCommand("moveToPageDown",e,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>no(!1)),new o.SimpleCommand("selectToPageDown",e,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[o.KeyModifiers.Shift]}]},()=>no(!0)),new o.SimpleCommand("moveToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[o.KeyModifiers.Alt]}]},()=>ro(!1)),new o.SimpleCommand("selectToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[o.KeyModifiers.Alt,o.KeyModifiers.Shift]}]},()=>ro(!0)),new o.SimpleCommand("moveToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>Mt(!1)),new o.SimpleCommand("selectToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[o.KeyModifiers.Shift]}]},()=>Mt(!0)),new o.SimpleCommand("moveToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[o.KeyModifiers.Alt]}]},()=>Jt(!1)),new o.SimpleCommand("selectToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[o.KeyModifiers.Alt,o.KeyModifiers.Shift]}]},()=>Jt(!0)),new o.SimpleCommand("selectColumn",e,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[o.KeyModifiers.Ctrl]}},mo),new o.SimpleCommand("selectRow",e,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[o.KeyModifiers.Shift]}},Co),new o.SimpleCommand("selectToColumnStart",e,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>to(!0)),new o.SimpleCommand("selectToColumnEnd",e,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>oo(!0)),new o.SimpleCommand("moveToRowStart",e,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>Gt(!1)),new o.SimpleCommand("selectToRowStart",e,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[o.KeyModifiers.Shift]}]},()=>Gt(!0)),new o.SimpleCommand("moveToSheetStart",e,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[o.KeyModifiers.Ctrl]}]},()=>qt(!1)),new o.SimpleCommand("selectToSheetStart",e,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},()=>qt(!0)),new o.SimpleCommand("moveToRowEnd",e,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>_t(!1)),new o.SimpleCommand("selectToRowEnd",e,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[o.KeyModifiers.Shift]}]},()=>_t(!0)),new o.SimpleCommand("moveToSheetEnd",e,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[o.KeyModifiers.Ctrl]}]},()=>Wt(!1)),new o.SimpleCommand("selectToSheetEnd",e,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},()=>Wt(!0)),new o.SimpleCommand("scrollToActiveCoords",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[o.KeyModifiers.Ctrl]}},Ft),new o.SimpleCommand("scrollToActiveCoordsClearSelection",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[o.KeyModifiers.Shift]}},()=>{At(),Ze(S.cell,!0)}),new o.SimpleCommand("traverseSelectionRight",e,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},io),new o.SimpleCommand("traverseSelectionLeft",e,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[o.KeyModifiers.Shift]}},lo),new o.SimpleCommand("traverseSelectionDown",e,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},vo),new o.SimpleCommand("traverseSelectionUp",e,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[o.KeyModifiers.Shift]},{key:"NumpadEnter",modifiers:[o.KeyModifiers.Shift]}]},yo),new o.SimpleCommand("moveLeft",e,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},co),new o.SimpleCommand("selectLeft",e,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[o.KeyModifiers.Shift]}]},x),new o.SimpleCommand("moveContentfulLeft",e,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[o.KeyModifiers.Ctrl]}]},b),new o.SimpleCommand("selectContentfulLeft",e,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},v),new o.SimpleCommand("moveRight",e,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},E),new o.SimpleCommand("selectRight",e,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[o.KeyModifiers.Shift]}]},I),new o.SimpleCommand("moveContentfulRight",e,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[o.KeyModifiers.Ctrl]}]},q),new o.SimpleCommand("selectContentfulRight",e,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},V),new o.SimpleCommand("moveUp",e,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},J),new o.SimpleCommand("selectUp",e,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[o.KeyModifiers.Shift]}]},ee),new o.SimpleCommand("moveContentfulUp",e,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[o.KeyModifiers.Ctrl]}]},H),new o.SimpleCommand("selectContentfulUp",e,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},Ee),new o.SimpleCommand("moveDown",e,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},Ne),new o.SimpleCommand("selectDown",e,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[o.KeyModifiers.Shift]}]},be),new o.SimpleCommand("moveContentfulDown",e,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[o.KeyModifiers.Ctrl]}]},ye),new o.SimpleCommand("selectContentfulDown",e,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Shift]}]},Ge),new o.SimpleCommand("selectVisible",e,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[o.KeyModifiers.Alt]}},So),new o.SimpleCommand("traverseSelectionPreviousRange",e,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Alt]}},Qt),new o.SimpleCommand("traverseSelectionNextRange",e,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[o.KeyModifiers.Ctrl,o.KeyModifiers.Alt]}},Ro),new o.SimpleCommand("traverseSelectionCorners",e,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[o.KeyModifiers.Ctrl]}},Eo)]},[]);return l.useMemo(()=>{r?.addCommands(pt,!0)},[r]),{selection:vt,setSelectionCell:Ze,setSelectionRanges:nt,overlay:ft,cursor:Ht,onPointerDown:xo,clearLastSelection:Ae,newSelection:ut,modifySelection:rt,appendSelection:De,clearSelections:At,isEntire:ht,navigate:qe,navigateSelection:Lt}};