@sheetxl/grid-react 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/cjs/index.cjs +10 -16
- package/browser/esm/index.mjs +8 -3410
- package/licenses/dependencies.txt +2 -2
- package/node/esm/index.mjs +1 -1
- package/package.json +3 -3
package/browser/cjs/index.cjs
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
(function
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
try{if(typeof document != 'undefined'){var elementStyle = document.createElement('style');elementStyle.appendChild(document.createTextNode("/**\n * CSS files with the .module.css suffix will be treated as CSS modules\n * and scoped locally.\n */\n\n._sheetxl-grid_h9wwa_7 {\n position: relative;\n box-sizing: border-box;\n user-select: none;\n}\n\n._sheetxl-grid_h9wwa_7 * {\n box-sizing: border-box !important;\n}\n\n._sheetxl-grid_h9wwa_7 *:focus {\n outline: none;\n}\n\n/*\n.sheetxl-grid :global(.view) > * {\n pointer-events: auto;\n}\n*/\n\n._sheetxl-grid_h9wwa_7 .cell-container {\n position: absolute;\n overflow: visible;\n white-space: pre;\n /* overflow: hidden; */\n /* This is supposed to make rendering faster but instead it is making it blurry */\n /* will-change: transform; */\n}\n\n._sheetxl-grid_h9wwa_7 .cell-container > * {\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n}\n\n\n._sheetxl-grid_h9wwa_7 .sheetxl-stage {\n contain: strict;\n}\n._sheetxl-grid_h9wwa_7 .sheetxl-stage > * {\n contain: strict;\n}"));document.head.appendChild(elementStyle);}}catch(e){console.error('vite-plugin-css-injected-by-js', e);}
|
|
5
|
+
|
|
6
|
+
})();
|
|
7
|
+
/**
|
|
8
|
+
* @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.11
|
|
4
9
|
*
|
|
5
10
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
6
11
|
* 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} {
|
|
15
|
-
to {
|
|
16
|
-
stroke-dashoffset: 0px;
|
|
17
|
-
}
|
|
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&≠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}};
|
|
12
|
+
*/
|
|
13
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom/client"),o=require("react-dom"),r="up",i="down",l="left",s="right",c="tl",a="t",u="l",d="c",h="text/html",f="text/plain",p="image/png",g=Object.freeze({left:0,top:0}),w=Object.freeze({left:0,top:0,bottom:0,right:0}),m=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:m,EmptyRect:w,EmptyTopLeft:g},Symbol.toStringTag,{value:"Module"}));const x="column",y="row",b=Object.freeze({colIndex:0,rowIndex:0}),v=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),S=(e,t)=>e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart,E=(e,t)=>e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart,_=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,C=(e,t)=>e.colEnd===t.colEnd?t.rowEnd-e.rowEnd:t.colEnd-e.colEnd,I=(e,t)=>e.colIndex===t.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex,M=(e,t)=>e.rowIndex===t.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex,R=(e=y,t=!1)=>t?e!==x?_:C:e!==x?E:S,k=(e,t)=>e===t||!(!e||!t)&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,T=(e,t)=>e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd,P=(e,t)=>!(!e||!t||e.colStart>t.colEnd||t.colStart>e.colEnd||e.rowStart>t.rowEnd||t.rowStart>e.rowEnd),O=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!T(e[n],t[n]))return!1;return!0},L=(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},D=(e,t)=>{if(!t||0===t.length)return e;const n={...e};for(let e=0;e<t.length;e++){const o=t[e];P(n,o)&&(n.rowStart=Math.min(n.rowStart,o.rowStart),n.colStart=Math.min(n.colStart,o.colStart),n.rowEnd=Math.max(n.rowEnd,o.rowEnd),n.colEnd=Math.max(n.colEnd,o.colEnd))}return n},z=[null,null],j=(e,t,n)=>{if(e[0].value===e[1].value)return t};function A(e,t=2,n,o=y,r){let i=[...e];if(t<=0||e.length<=1)return i;let l=o===x,s=0,c=!1;do{const e=i.sort(R(l?y:x));i=[],i.push(e[0]);const t=e.length;let a=0,u=e[0],d=u.colStart,h=u.rowStart,f=u.colEnd,p=u.rowEnd;for(let s=1;s<t;s++){const t=e[s];let g=!1;if(g=l?u&&h===t.rowStart&&p===t.rowEnd&&f+1===t.colStart:u&&d===t.colStart&&f===t.colEnd&&p+1===t.rowStart,g){let e={colStart:d,rowStart:h,colEnd:l?t.colEnd:f,rowEnd:l?p:t.rowEnd};if(void 0!==u.value&&(e.value=u.value),n){const i=r??[null,null];i[0]=u,i[1]=t,e=n(i,e,o)}if(e){i[a]=e,c=!0,u=e,d=u.colStart,h=u.rowStart,f=u.colEnd,p=u.rowEnd;continue}}i[++a]=t,u=t,d=u.colStart,h=u.rowStart,f=u.colEnd,p=u.rowEnd}s++,l=!l,1===s&&(c=!0)}while(s<t&&c&&i.length>1);return i}const $=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:b,EmptyRange:v,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:I,columnFirstRangeComparator:S,createCellComparator:(e=y,t=!1)=>t?e!==x?(e,t)=>e.rowIndex===t.rowIndex?t.colIndex-e.colIndex:t.rowIndex-e.rowIndex:(e,t)=>e.colIndex===t.colIndex?t.rowIndex-e.rowIndex:t.colIndex-e.colIndex:e!==x?M:I,createConflatingRanges:(e,t=!1)=>{const n=[];let o,r,i=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;return{append:(s,c,a)=>{let u=!0;const d=void 0!==a;if(d){const n=e?e(r,a,t):r===a?a:void 0;void 0===n?u=!1:a=n}if(u&&c===l+1&&s===i)return t?o.rowEnd=c:o.colEnd=c,l=c,void(r=a);o&&n.push(o);const h=t?s:c,f=t?c:s;o={colStart:h,rowStart:f,colEnd:h,rowEnd:f},d&&(o.value=a),i=s,l=c,r=a},done:e=>(o&&(n.push(o),o=null),e?A(n,3,!0===e?j:e,t?x:y,z):n)}},createRangeComparator:R,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:D,extendRangeToUnionRanges:(e,t)=>{if(!t||0===t.length)return e;let n=e,o=null;for(;!T(n,o);)o=n,n=D(o,t);return n},indexOfCoords:(e,t)=>{const n={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex};for(let e=t.length-1;e>=0;e--)if(P(n,t[e]))return e;return-1},intersectRanges:(e,t,n)=>{if(!e)return n?t:{...t};if(!t)return n?e:{...e};if(!e&&!t)return null;if(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:k,isEqualRanges:T,isEqualRangesArrays:O,isEqualSelectionCoords:(e,t)=>e===t||!(!e||!t)&&e.rangeIndex===t.rangeIndex&&!!k(e.cell,t.cell)&&O(e.ranges,t.ranges),isRangeWithinRange:(e,t)=>!(e.rowStart<t.rowStart||e.rowEnd>t.rowEnd||e.colStart<t.colStart||e.colEnd>t.colEnd),isRangesIntersect:P,isSingleCell:e=>!!e&&e.rowEnd===e.rowStart&&e.colStart===e.colEnd,isValidRange:e=>!(!e||"number"!=typeof e.colStart||e.colStart<0||"number"!=typeof e.colEnd||e.colEnd<e.colStart||"number"!=typeof e.rowStart||e.rowStart<0||"number"!=typeof e.rowEnd||e.rowEnd<e.rowStart),mergeRangedValues:A,rowFirstCellComparator:M,rowFirstRangeComparator:E,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:L,unionRangesArrays:(e,t,n)=>{if(!e||0===e.length)return null;if(1===e.length&&!t)return e[0];let o=e[0];for(let t=1;t<e.length;t++)o=L(o,e[t],n);return t&&(o=L(o,t,n)),o}},Symbol.toStringTag,{value:"Module"}));const B="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function F(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){const t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===B}(e)}(e)}function V(e,t){return!1!==t.clone&&t.isMergeableObject(e)?U((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function W(e,t,n){return e.concat(t).map(function(e){return V(e,n)})}function H(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function N(e,t){try{return t in e}catch(e){return!1}}function U(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||W,n.isMergeableObject=n.isMergeableObject||F,n.cloneUnlessOtherwiseSpecified=V;const o=Array.isArray(t);return o===Array.isArray(e)?o?n.arrayMerge(e,t,n):function(e,t,n){const o={};return n.isMergeableObject(e)&&H(e).forEach(function(t){o[t]=V(e[t],n)}),H(t).forEach(function(r){(function(e,t){return N(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(N(e,r)&&n.isMergeableObject(t[r])?o[r]=function(e,t){if(!t.customMerge)return U;const n=t.customMerge(e);return"function"==typeof n?n:U}(r,n)(e[r],t[r],n):o[r]=V(t[r],n))}),o}(e,t,n):V(t,n)}U.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return U(e,n,t)},{})};const q=Object.freeze([]),K=Object.freeze({}),Y=e=>e,X=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),G=(e,t)=>e===t||!(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)&&e.every((e,n)=>e===t[n]),Z=e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,J=e=>"object"!=typeof e||Array.isArray(e)||null===e?e:(Object.keys(e).forEach(function(t){e[t]&&"object"==typeof e[t]?J(e[t]):null!==e[t]&&void 0!==e[t]||delete e[t],"object"==typeof e[t]&&0===Object.keys(e[t]).length&&delete e[t]}),0===Object.keys(e).length?null:e),Q=(e,t)=>!(e!==t&&!G(e,t)&&!e.isEqual?.(t)),ee=(e,t,n=Q)=>{if(null==e||e===t)return null;if(!e||"object"!=typeof e||Array.isArray(e)||e.isImmutable?.())return n(e,t)?null:e;const o=Object.keys(e);if(0===o.length)return null;let r=!1;for(let i=0;i<o.length;i++){const l=o[i];null===ee(e[l],t?.[l],n)&&(r=!0,delete e[l])}return r&&0===Object.keys(e).length?null:void 0},te="object"==typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now(),ne=e=>null==e,oe=(e,t)=>!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top),re=!("undefined"==typeof window||!window.document||!window.document.createElement),ie={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},le=()=>{if(se())return ie.Node;const e=void 0!==globalThis.navigator&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?ie.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?ie.MacOS:/(iphone|ipad|ipod)/i.test(e)?ie.IOS:/android/.test(e)?ie.Android:/linux/.test(e)?ie.Linux:/^((?!chrome|android|).)*safari/i.test(e)?ie.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?ie.Firefox:ie.Unknown:ie.Unknown};function se(){return"undefined"!=typeof process&&"node"===process.release?.name||("undefined"!=typeof process&&process.browser,!1)}const ce=(e,t=!1)=>(document.hasFocus()||t)&&(e===document.activeElement||e?.contains(document.activeElement)),ae=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:q,EmptyObject:K,OSType:ie,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=(e=>1*e)(e);return Number.isFinite(t)?t:0},camelToPrettyCase:e=>1===e.length?e.toUpperCase():e.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).trim(),canUseDOM:re,cancelTimeout:e=>{cancelAnimationFrame(e.id)},castToString:e=>null==e||void 0===e?"":"string"!=typeof e?""+e:e,cloneObject:e=>ne(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 c(){let a=Date.now()-s;a<t&&a>=0?o=setTimeout(c,t-a):(o=null,n||(l=e.apply(i,r),i=r=null))}null==t&&(t=100);const a=function(){i=globalThis,r=arguments,s=Date.now();var a=n&&!o;return o||(o=setTimeout(c,t)),a&&(l=e.apply(i,r),i=r=null),l};return a.clear=function(){o&&(clearTimeout(o),o=null)},a.flush=function(){o&&(l=e.apply(i,r),i=r=null,clearTimeout(o),o=null)},a},deepEqual:function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){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;0!==r--;)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;0!==r--;)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;0!==r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!==r--;){let o=i[r];if(!("_owner"===o&&t.$$typeof||e(t[o],n[o])))return!1}return!0}return t!=t&&n!=n},deepFreeze:function e(t){return Object.freeze(t),Object.keys(t).forEach(n=>{"object"!=typeof t[n]||null===t[n]||Object.isFrozen(t[n])||e(t[n])}),t},deepMerge:U,diffValues:(e,t)=>{const n={},o=Object.keys(t),r=o.length;for(let i=0;i<r;i++){const r=o[i];e[r]!==t[r]&&(void 0===e[r]?n[r]=t[r]:n[r]=e[r])}return 0===Object.keys(n).length?null:n},findEqualOrGreater:function(e,t,n=Y){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=Y){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"object"==typeof window&&(e=window.devicePixelRatio||1),e},getFromPath:(e,t)=>{const n=t.split(".");let o=e;for(let e=0;e<n.length;e++){const t=n[e];if(!o)return null;let r=o[t];if("function"==typeof r&&(r=r.bind(o)()),!r||!Z(r))return r;o=r}return o??null},getOS:le,hasFocus:ce,isDefined:e=>!(null==e),isEmpty:e=>null==e||""===e,isEqualArrays:G,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:se,isNullOrUndefined:ne,isNumeric:e=>{const t=1*e;return Number.isFinite(t)&&"number"==typeof t},isObject:Z,isPromiseLike:e=>!!e&&"function"==typeof e.then,isRectInsideRect:(e,t)=>e.top>=t.top&&e.bottom<=t.bottom&&e.left>=t.left&&e.right<=t.right,isRectIntersect:oe,mergeContentful:(...e)=>{const t=e.length;if(t>0&&void 0!==e[t-1]&&!Z(e[t-1]))return e[t-1];let n=e[0]||{};for(let o=1;o<t;o++)n=U(n,e[o]||{},{arrayMerge:(e,t)=>[...t]});return n},nextTick:e=>{"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>{e()}):("function"==typeof setImmediate?setImmediate:setTimeout)(()=>{e()})},openFileDialog:(e="*.*")=>new Promise((t,n)=>{if(!re)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(e){t=e,t&&t.persist&&t.persist(),n||(n=!0,requestAnimationFrame(o))}},removeEmptyProperties:J,removeEqualValues:ee,removeListenerAll:e=>{if(!e)return[];for(let t=0;t<e.length;t++)e[t]&&e[t]();return[]},requestTimeout:(e,t)=>{const n=te(),o={id:requestAnimationFrame(function r(){te()-n>=t?e.call(null):o.id=requestAnimationFrame(r)})};return o},roundAccurately:(e,t=0)=>{if(null==e||!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 e=0;r&&e<o.length-1;e++){const t=o[e];let n=r[t];if(null==n&&(n={},r[t]=n),!Z(n))throw new Error("Can not set path to a non object path.");r=n}if("number"!=typeof n&&"boolean"!=typeof n&&"string"!=typeof n&&!Z(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(!oe(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})},c=()=>{t.left>r.left&&t.left<r.right&&(o.push({...r,right:t.left}),r={...r,left:t.left})};return n?(c(),s(),i(),l()):(i(),l(),s(),c()),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(null===t||"object"!=typeof t)return t;if("function"==typeof t.toJSON)return t.toJSON();if(Array.isArray(t))return t.map(t=>e(t));if("function"==typeof t.toString&&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 e=0;e<n;e++)o[e]=Array(t);for(let r=0;r<t;r++)for(let t=0;t<n;t++)o[t][r]=e[r][t];return o},uuidV4:X,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=>{ce(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 ue=e=>{const t=new Uint8Array(e),n=t.byteLength;let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(t[e]);if("undefined"!=typeof window&&"function"==typeof globalThis.btoa)return globalThis.btoa(o);if("undefined"!=typeof Buffer)return Buffer.from(o,"binary").toString("base64");throw new Error("Unsupported environment")},de=e=>new Promise((t,n)=>{if(e)if("undefined"!=typeof FileReader){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{n(o.error)},o.readAsText(e)}else if("undefined"!=typeof Buffer){const o=e=>Buffer.from(e).toString("utf-8");e.arrayBuffer().then(e=>{t(o(e))}).catch(e=>{n(e)})}else n(new Error("Unsupported environment"));else t("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:ue,base64ToArrayBuffer:e=>{const t="undefined"!=typeof window&&"function"==typeof globalThis.atob?globalThis.atob(e):Buffer.from(e,"base64").toString("binary"),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer},blobToString:de},Symbol.toStringTag,{value:"Module"}));const he="data:image/png;base64,",fe="Unable to resolve image.",pe=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(e){o?.src&&URL.revokeObjectURL(o.src)}o||n(fe)}),ge="image/svg+xml";var we,me;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:he,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 e=document.createElement("canvas");e.width=r.naturalWidth,e.height=r.naturalHeight,e.getContext("2d").drawImage(r,0,0);const o=e.toDataURL("image/png",t);n({elemImg:r,dataUrl:o})}catch(t){URL.revokeObjectURL(e),o(t)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(e),o("Invalid Image")},{once:!0}),await r.decode("sync")}catch(e){r?.src&&URL.revokeObjectURL(r.src)}r||o(fe)}),loadImageDetails:async(e,t=null)=>{let n=null;const o=async()=>{try{const o=t??"image/*",r=URL.createObjectURL(new Blob([e],{type:o})),i=await pe(r);n={mimeType:o,naturalDimensions:i,asUrl:r}}catch(e){}},r=async()=>{try{const o=(new TextDecoder).decode(e),r=URL.createObjectURL(new Blob([o],{type:ge})),i=await pe(r);n={mimeType:t??ge,naturalDimensions:i,asUrl:r,asSVGText:o}}catch(e){}};if(t===ge?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"})),(me=we||(we={})).resolveTypedUpdates=(e,t,n,o)=>{if(null===e)return e;if(void 0===e)return o;let r=e;if(t?.shorthand){const o=t?.shorthand(e,n);void 0!==o&&(r=o)}if(null!==r&&t?.getSubType){const e=t.getSubType(r);e&&(t=e)}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);else if(i){const e=Object.keys({...r,...o});s=null;for(let t=0;t<e.length;t++){const l=e[t];let c,a=r[l];if(void 0!==a){const e=i[l];c=e?(0,me.resolveTypedUpdates)(a,e,n,o?.[l]):a}else c=o?.[l];null!=c&&(s=s??{},s[l]=c)}}return s};const xe="The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",ye="You do not have permissions to access the clipboard.\nAll copy and paste operations will be limited to the browser tab.",be={Safari:"The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",Perms:ye,PermsWrite:le()===ie.Safari?xe:ye,PermsRead:le()===ie.Safari?xe:ye},ve=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),Se=async(e,t,n)=>{if(le()===ie.Safari)return await n(new Error(be.Safari));try{const o=async e=>{try{return await e()}catch(e){if(e.message?.includes("Document is not focused"))return!1;throw e}},r=await(globalThis?.navigator?.permissions?.query({name:e,allowWithoutGesture:!0,allowWithoutSanitization:!0}));let i=!1;if("prompt"===r.state&&(i=await o(t)),i||"granted"!==r.state||(i=await t()),!i)return await n(new Error(r.state))}catch(e){if("No valid data on clipboard"===e.message||"DataError"===e.name)return;return await n(e)}},Ee=async e=>{try{return await e.read({unsanitized:[h]})}catch(e){}return await e.read()};if(!globalThis.ClipboardItem){const e=(e,t)=>new Blob([t],{type:e});class t{constructor(t,n){this._items={},this._types=Object.keys(t);const o={},r=Object.keys(t);for(let n=0;n<r.length;n++){const i=r[n];let l=t[i];o[i]="string"==typeof l?e(i,l):l}this._items=o,this._presentationStyle=n?.presentationStyle??"unspecified"}get types(){return this._types}getType(e){return Promise.resolve(this._items[e])}supports(e){return!0}}globalThis.ClipboardItem=t}const _e=async(e,t=h)=>new Promise(async(n,o)=>{try{const o=await(async(e,t)=>{if(!e)return null;const n=await Ee(e);let o=!1;for(let e=0;!o&&n&&e<n.length;e++)if(o=n[e].types.includes(t),o)return await n[e].getType(t);return o?void 0:null})(e,t);if(o){const e=new FileReader;e.onload=()=>{n(e.result)},e.onerror=()=>{n("")},e.readAsText(o)}else n("")}catch(e){o(e)}}),Ce=async(e,t=h)=>{const n=await _e(e,t);if(!n)return null;let o=null;try{o=(new DOMParser).parseFromString(n,h)}catch(e){console.warn("Can't parse html from clipboard.")}return o},Ie="clipboard-uuid",Me="web text/uuid",Re=e=>`<div style="display:none" ${Ie}="${e}"/>`,ke=(e,t)=>{let n=null;try{const o=(new DOMParser).parseFromString(t,h);o.body.firstElementChild.setAttribute(Ie,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(e){console.warn("Can't embed uuid.",e)}return n},Te=(e,t)=>{if(!t||!e)return!1;try{const n=t.querySelectorAll(`[${Ie}="${e}"]`);if(n&&1===n.length)return!0;if(t.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch(e){return!1}};let Pe=class{constructor(e){if(void 0===e?.nativeClipboard||!0===e?.nativeClipboard)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch(t){!0===e?.nativeClipboard&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=!1===e?.nativeClipboard?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await Se("clipboard-read",async()=>{await ve();const e=await _e(this._nativeClipboard,Me);if(!this._state)return!0;if(e&&e===this._state.uuid)return!0;const t=await Ce(this._nativeClipboard,h);return!this._state||(Te(this._state.uuid,t)||this.clear(),!0)},async e=>{"denied"===e?.message||e.message?.includes("Document is not focused")||le()===ie.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 Se("clipboard-read",async()=>{if(await ve(),this._state?.uuid){const t=await _e(this._nativeClipboard,Me);if(t&&t===e._state.uuid)return!0;const n=await Ce(this._nativeClipboard,h);if(Te(e._state?.uuid,n))return!0}return e._state={items:await Ee(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async e=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:X(),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 Se("clipboard-write",async()=>{await ve(),o&&0===r.length&&(r.push(new ClipboardItem({[Me]:new Blob([o],{type:Me})})),r.push(new ClipboardItem({[h]:new Blob([Re(o)],{type:h})})));for(let e=0;e<Math.min(1,r.length);e++){const t=r[e];let i=t.types.indexOf(h),l=null;if(-1!==i){const e=await t.getType(h);l=await de(e),l&&(l=ke(o,l))}if(!l&&t.types.includes(f)){const e=await t.getType(f);if(e){let t=null;"string"==typeof e?(console.warn("text as string",e),t=e):t=await de(e),t&&(l=`<div ${Ie}="${o}">${t}</div>`)}}if(!l&&t.types.includes(p)){const e=await t.getType(p),n=ue(await e.arrayBuffer());l=`<div ${Ie}="${o}"><img src="${he+n}"/></div>`}!l&&o&&(l=Re(o));const s=new Blob([l??""],{type:h}),c={};for(let e=0;e<t.types.length;e++){const n=t.types[e];c[n]=e===i?s:t.getType(n)}l&&-1===i&&(c[h]=s),o&&(c[Me]=new Blob([o],{type:Me})),n.push(new ClipboardItem(c))}try{n&&0!==n.length?await this._nativeClipboard.write(n):await(async e=>{e&&await e.writeText("")})(this._nativeClipboard)}catch(e){e.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",e)}return i(),!0},async e=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const t=await(e.toText?.())??null;t&&(n[f]=new Blob([t??""],{type:f}))}catch(e){t=e}try{const t=await(e.toHtml?.())??null;t&&(n[h]=new Blob([t],{type:h}))}catch(e){t=e,console.warn("export to html",e)}try{const t=await(e.toImage?.())??null;t&&(n[p]=t)}catch(e){t=e,console.warn("export to png",e)}const o=this._write({uuid:X(),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 e=0;!o&&n&&e<n.length;e++)n[e].types.includes(f)&&(o=await n[e].getType(f));if(!o)return void e("");const r=new FileReader;r.onload=()=>{e(r.result)},r.readAsText(o),r.onerror=e=>{t(e)}})}async writeText(e){const t=[new ClipboardItem({[f]:new Blob([e],{type:f})})];return this._write({uuid:X(),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,"boolean"==typeof n?{}:n)}dispatchEvent(e){if(!e)return;const t=t=>{const n=t.get(e.type);n&&n.forEach((t,o)=>{try{"function"==typeof o?o(e):o.handleEvent&&o.handleEvent(e),t.once&&n.delete(o)}catch(e){console.warn(e)}})};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),0===r.size&&o.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}};var Oe;(Oe=Pe||(Pe={})).ErrorMessages=be,Oe.Global=new Oe,function(){try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode("/**\n * CSS files with the .module.css suffix will be treated as CSS modules\n * and scoped locally.\n Note - this isn't working but was meant to enabled default scroll buttons to play nicely with rounded corners\n */\n/* & ::-webkit-scrollbar {\n background: gre;\n } */\n._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button {\n background: transparent;\n }/**\n * Used for fullscreen portals.\n */\n._fullscreen-portal-root_1mjsr_4 {\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n z-index: 1200;\n}\n\n._fullscreen-portal-root_1mjsr_4 > * {\n pointer-events: auto;\n}")),document.head.appendChild(e)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();const Le={Left:"left",Right:"right",Center:"center"},De="shift",ze="alt",je="ctrl",Ae=9,$e=13,Be=27,Fe=37,Ve=38,We=39,He=40,Ne=113,Ue=3,qe={Horizontal:"horizontal",Vertical:"vertical"};function Ke(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Ke(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Ye(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Ke(e))&&(o&&(o+=" "),o+=t);return o}var Xe=function(){},Ge="undefined"!=typeof window,Ze=Ge?t.useLayoutEffect:t.useEffect,Je={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const Qe=Ge&&void 0!==window.ResizeObserver?function(){var e=t.useState(null),n=e[0],o=e[1],r=t.useState(Je),i=r[0],l=r[1],s=t.useMemo(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,o=t.y,r=t.width,i=t.height,s=t.top,c=t.left,a=t.bottom,u=t.right;l({x:n,y:o,width:r,height:i,top:s,left:c,bottom:a,right:u})}})},[]);return Ze(function(){if(n)return s.observe(n),function(){s.disconnect()}},[n]),[o,i]}:function(){return[Xe,Je]},et=(e,n)=>{const o=t.useCallback((...t)=>e?.(...t),n),r=t.useRef(null);r.current=o;const i=t.useCallback((...e)=>r.current?.(...e),[]);if(r.current)return i},tt=t=>{const{style:n,orientation:o=qe.Vertical,...r}=t,i=o===qe.Vertical;return e.jsx("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:i?"0px":"3px",paddingTop:i?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...n},...r,children:e.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${i?"vertical":"horizontal"} single-button start`,children:e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:e.jsx("path",{d:i?"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"})})})})},nt=t=>{const{style:n,orientation:o=qe.Vertical,...r}=t,i=o===qe.Vertical;return e.jsx("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:i?"0px":"3px",paddingBottom:i?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...n},...r,children:e.jsx("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${i?"vertical":"horizontal"} single-button end`,children:e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:e.jsx("path",{d:i?"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"})})})})},ot=(e,t,n,o,r=0)=>{for(let r=0;r<n.length;r++){const i=n[r].getBoundingClientRect();let l=i.left-t,s=l+i.width;if(o){if(l<e&&s>=e)return l}else if(Math.ceil(s)>Math.ceil(e)+2)return s}return r};Object.freeze(Object.defineProperty({__proto__:null,getScrollTo:ot},Symbol.toStringTag,{value:"Module"}));const rt=t.memo(t.forwardRef((n,o)=>{const{offset:r=0,totalSize:i=0,viewportSize:l=0,style:s,className:c,orientation:a=qe.Vertical,onScrollOffset:u,onScroll:d,showCustomScrollButtons:h=!1,scrollButtonIncrement:f=200,scrollButtonInitialRepeatDelay:p=260,scrollButtonAdditionalRepeatDelay:g=120,createScrollStartButton:w=tt,createScrollEndButton:m=nt,...x}=n,y=et(d,[d]),b=t.useRef(null),[v,{width:S,height:E}]=Qe(),[_,{width:C,height:I}]=Qe(),M=a===qe.Vertical,R=M?"top":"left",k=M?"scrollTop":"scrollLeft",T=M?E:S,P=M?I:C,[O,L]=t.useState(null);t.useEffect(()=>{null!==O&&b.current&&b.current.scrollTo({behavior:"smooth",[R]:O})},[O,M]);const D=t.useCallback((e,t=!1)=>{if(!b.current)return 0;const n=b.current.querySelector(".scrollbar-viewport"),o=n.getBoundingClientRect(),r=n.children,i=t?0:ot(e,o[R],r,!0,Math.max(0,e-f));return L(i),Math.max(0,i)},[]),z=t.useCallback((e,t=!1)=>{if(!b.current)return 0;const n=b.current.querySelector(".scrollbar-viewport"),o=n.getBoundingClientRect(),r=n.children,i=Math.ceil(P-T),l=t?i:ot(e,o[R],r,!1,Math.max(0,e+f));return L(l),Math.min(i,l)},[P,T]),j=t.useRef(null),A=t.useCallback(e=>{j.current=r;const t=e.target[k];u(t,l,i),y?.(e)},[u,l,i,r]);t.useEffect(()=>{const e=j.current;j.current=null,r!==e&&(b.current[k]=r)},[r,k]);const $=t.useRef(null),B=t.useRef(null),F=t.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null,B.current=null)},[]),V=t.useCallback((e,t,n,o=p)=>{B.current=e,$.current=setTimeout(()=>{const t=n?D(B.current||e):z(B.current||e);t!==B.current?V(t,!1,n,g):F()},t?0:o)},[D,z,F]);t.useEffect(()=>()=>F(),[F]);const W=r,H=t.useMemo(()=>{if(!h)return null;const e={orientation:a,disabled:Math.floor(W)<=0||0===Math.floor(P-T),onMouseUp:F,onMouseLeave:F,onMouseDown:()=>V(W,!0,!0)};return w?.(e)},[h,a,W,O,P,T]),N=t.useMemo(()=>{if(!h)return null;const e={orientation:a,disabled:Math.floor(P-T)<=Math.ceil(W),onMouseUp:F,onMouseLeave:F,onMouseDown:()=>V(W,!0,!1)};return m?.(e)},[h,a,W,O,P,T]);return e.jsxs("div",{ref:o,style:{display:"flex",flex:"1",flexDirection:M?"column":"row",padding:"0",...s},className:Ye("_sheetxl-scrollbar_eblx4_6",c),...x,children:[H,e.jsx("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:M?"column":"row",justifyContent:"center",alignItems:"center"},ref:v,children:e.jsx("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:M?"scroll":"hidden",overflowX:M?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:A,ref:b,children:e.jsx("div",{ref:_,style:{position:"absolute",height:M?i-l+(E??0):1,width:M?1:i-l+(S??0)},className:"scrollbar-viewport"})})}),N]})}));rt.displayName="Scrollbar";let it=Date.now,lt={},st=1;const ct=e=>{let t=null!==lt[e];return t&&(lt[e]=null),t},at=(e,t,n,o=0,r)=>{let i=it(),l=i,s=0,c=0,a=0,u=st++;if(u%20==0){const e={};for(let t in lt)e[t]=!0;lt=e}const d=function(h){let f=!0!==h,p=it(),g=!0;try{g=(!t||t(u))??!0}catch(e){g=!1}if(!lt[u]||!g)return lt[u]=null,void n?.(60-c/((p-i)/1e3),u,!1);if(f){a=Math.round((p-l)/16.666666666666668)-1;for(let e=0;e<Math.min(a,4);e++)d(!0),c++}o&&(s=(p-i)/o,s>1&&(s=1));let w=r?r(s):s,m=!1;try{m=e(w,p,f)}catch(e){m=!1}!1!==m&&1!==s||!f?f&&(l=p,requestAnimationFrame(d)):(lt[u]=null,n?.(60-c/((p-i)/1e3),u,1===s||null==o))};return lt[u]=!0,requestAnimationFrame(d),u},ut=function(e){return Math.pow(e-1,3)+1},dt=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)};class ht{constructor(e,t){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=e,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,...t}}setDimensions(e,t,n,o){null!==e&&(this.__clientWidth=e),null!==t&&(this.__clientHeight=t),null!==n&&(this.__contentWidth=n),null!==o&&(this.__contentHeight=o),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)}setPosition(e,t){this.__clientLeft=e||0,this.__clientTop=t||0}setSnapSize(e,t){this.__snapWidth=e,this.__snapHeight=t}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(e,t){const n=this.getValues();return{left:e/n.zoom,top:t/n.zoom}}getScrollMax(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}}zoomTo(e,t=!1,n,o,r){if(!this.options.zooming)throw new Error("Zooming is not enabled!");r&&(this.__zoomComplete=r),this.__isDecelerating&&(ct(this.__isDecelerating),this.__isDecelerating=0);const i=this.__zoomLevel;void 0===n&&(n=this.__clientWidth/2),void 0===o&&(o=this.__clientHeight/2),e=Math.max(Math.min(e,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(e);const l=e/i;let s=l*(this.__scrollLeft+n)-n,c=l*(this.__scrollTop+o)-o;s>this.__maxScrollLeft?s=this.__maxScrollLeft:s<0&&(s=0),c>this.__maxScrollTop?c=this.__maxScrollTop:c<0&&(c=0),this.__publish(s,c,e,t)}zoomBy(e,t=!1,n=0,o=0,r){this.zoomTo(this.__zoomLevel*e,t,n,o,r)}scrollTo(e,t,n=!1,o=1){if(this.__isDecelerating&&(ct(this.__isDecelerating),this.__isDecelerating=0),void 0!==o&&o!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");e*=o,t*=o,this.__computeScrollMax(o)}else o=this.__zoomLevel;this.options.scrollingX?this.options.paging?e=Math.round(e/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(e=Math.round(e/this.__snapWidth)*this.__snapWidth):e=this.__scrollLeft,this.options.scrollingY?this.options.paging?t=Math.round(t/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(t=Math.round(t/this.__snapHeight)*this.__snapHeight):t=this.__scrollTop,e=Math.max(Math.min(this.__maxScrollLeft,e),0),t=Math.max(Math.min(this.__maxScrollTop,t),0),e===this.__scrollLeft&&t===this.__scrollTop&&(n=!1),this.__publish(e,t,o,n)}scrollBy(e=0,t=0,n=!1){const o=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,r=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(o+(e||0),r+(t||0),n)}doMouseZoom(e,t,n,o){const r=e>0?.97:1.03;return this.zoomTo(this.__zoomLevel*r,!1,n-this.__clientLeft,o-this.__clientTop)}doTouchStart(e,t){if(void 0===e.length)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),"number"!=typeof t)throw new Error("Invalid timestamp value: "+t);let n,o;this.__interruptedAnimation=!0,this.__isDecelerating&&(ct(this.__isDecelerating),this.__isDecelerating=0,this.__interruptedAnimation=!0),this.__isAnimating&&(ct(this.__isAnimating),this.__isAnimating=0,this.__interruptedAnimation=!0);let r=1===e.length;r?(n=e[0].pageX,o=e[0].pageY):(n=Math.abs(e[0].pageX+e[1].pageX)/2,o=Math.abs(e[0].pageY+e[1].pageY)/2),this.__initialTouchLeft=n,this.__initialTouchTop=o,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=n,this.__lastTouchTop=o,this.__lastTouchMove=t,this.__lastScale=1,this.__enableScrollX=!r&&this.options.scrollingX,this.__enableScrollY=!r&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!r,this.__isSingleTouch=r,this.__positions=[]}doTouchMove(e,t,n=1){if(void 0===e.length)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),"number"!=typeof t)throw new Error("Invalid timestamp value: "+t);if(!this.__isTracking)return;let o,r;2===e.length?(o=Math.abs(e[0].pageX+e[1].pageX)/2,r=Math.abs(e[0].pageY+e[1].pageY)/2):(o=e[0].pageX,r=e[0].pageY);let i=this.__positions;if(this.__isDragging){let e=o-this.__lastTouchLeft,l=r-this.__lastTouchTop,s=this.__scrollLeft,c=this.__scrollTop,a=this.__zoomLevel;if(void 0!==n&&this.options.zooming){let e=a;if(a=a/this.__lastScale*n,a=Math.max(Math.min(a,this.options.maxZoom),this.options.minZoom),e!==a){let t=o-this.__clientLeft,n=r-this.__clientTop;s=(t+s)*a/e-t,c=(n+c)*a/e-n,this.__computeScrollMax(a)}}if(this.__enableScrollX){s-=e*this.options.speedMultiplier;let t=this.__maxScrollLeft;(s>t||s<0)&&(this.options.bouncing?s+=e/2*this.options.speedMultiplier:s=s>t?t:0)}if(this.__enableScrollY){c-=l*this.options.speedMultiplier;const e=this.__maxScrollTop;(c>e||c<0)&&(this.options.bouncing?c+=l/2*this.options.speedMultiplier:c=c>e?e:0)}i.length>60&&i.splice(0,30),i.push(s,c,t),this.__publish(s,c,a)}else{let e=this.options.locking?3:0,n=5,l=Math.abs(o-this.__initialTouchLeft),s=Math.abs(r-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&l>=e,this.__enableScrollY=this.options.scrollingY&&s>=e,i.push(this.__scrollLeft,this.__scrollTop,t),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(l>=n||s>=n),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=t,this.__lastScale=n}doTouchEnd(e){if(e instanceof Date&&(e=e.valueOf()),"number"!=typeof e)throw new Error("Invalid timestamp value: "+e);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&e-this.__lastTouchMove<=100){let t=this.__positions,n=t.length-1,o=n;for(let e=n;e>0&&t[e]>this.__lastTouchMove-100;e-=3)o=e;if(o!==n){const r=t[n]-t[o],i=this.__scrollLeft-t[o-2],l=this.__scrollTop-t[o-1];this.__decelerationVelocityX=i/r*(1e3/60),this.__decelerationVelocityY=l/r*(1e3/60);const s=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>s||Math.abs(this.__decelerationVelocityY)>s)&&this.__startDeceleration(e)}else this.options.scrollingComplete?.()}else e-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(e,t,n,o=!1){const r=this.__isAnimating;if(r&&(ct(r),this.__isAnimating=0),o&&this.options.animating){this.__scheduledLeft=e,this.__scheduledTop=t,this.__scheduledZoom=n;const o=this.__scrollLeft,i=this.__scrollTop,l=this.__zoomLevel,s=e-o,c=t-i,a=n-l,u=function(e,t,n){n&&(this.__scrollLeft=o+s*e,this.__scrollTop=i+c*e,this.__zoomLevel=l+a*e,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),d=function(e){return this.__isAnimating===e}.bind(this),h=function(e,t,n){t===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||n)&&this.options.scrollingComplete?.(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=at(u,d,h,this.options.animationDuration,r?ut:dt)}else this.__scheduledLeft=this.__scrollLeft=e,this.__scheduledTop=this.__scrollTop=t,this.__scheduledZoom=this.__zoomLevel=n,this.__callback&&this.__callback(e,t,n),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}__computeScrollMax(e=this.__zoomLevel){this.__maxScrollLeft=Math.max(this.__contentWidth*e-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*e-this.__clientHeight,0)}__startDeceleration(e){if(this.options.paging){const e=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),t=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),n=this.__clientWidth,o=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(e/n)*n,this.__minDecelerationScrollTop=Math.floor(t/o)*o,this.__maxDecelerationScrollLeft=Math.ceil(e/n)*n,this.__maxDecelerationScrollTop=Math.ceil(t/o)*o}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;const t=function(e,t,n){this.__stepThroughDeceleration(n)}.bind(this),n=this.options.snapping?4:.1,o=function(){const e=Math.abs(this.__decelerationVelocityX)>=n||Math.abs(this.__decelerationVelocityY)>=n;return e||(this.__didDecelerationComplete=!0),e}.bind(this),r=function(e,t,n){this.__isDecelerating=0,this.__didDecelerationComplete&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=at(t,o,r)}__stepThroughDeceleration(e){let t=this.__scrollLeft+this.__decelerationVelocityX,n=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){const e=Math.max(Math.min(this.__maxDecelerationScrollLeft,t),this.__minDecelerationScrollLeft);e!==t&&(t=e,this.__decelerationVelocityX=0);const o=Math.max(Math.min(this.__maxDecelerationScrollTop,n),this.__minDecelerationScrollTop);o!==n&&(n=o,this.__decelerationVelocityY=0)}if(e?this.__publish(t,n,this.__zoomLevel):(this.__scrollLeft=t,this.__scrollTop=n),!this.options.paging){const e=.95;this.__decelerationVelocityX*=e,this.__decelerationVelocityY*=e}if(this.options.bouncing){let e=0,o=0,r=this.options.penetrationDeceleration,i=this.options.penetrationAcceleration;t<this.__minDecelerationScrollLeft?e=this.__minDecelerationScrollLeft-t:t>this.__maxDecelerationScrollLeft&&(e=this.__maxDecelerationScrollLeft-t),n<this.__minDecelerationScrollTop?o=this.__minDecelerationScrollTop-n:n>this.__maxDecelerationScrollTop&&(o=this.__maxDecelerationScrollTop-n),0!==e&&(e*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=e*r:this.__decelerationVelocityX=e*i),0!==o&&(o*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=o*r:this.__decelerationVelocityY=o*i)}}}var ft="undefined"!=typeof window?window:{screen:{},navigator:{}},pt=(ft.matchMedia||function(){return{matches:!1}}).bind(ft),gt=!1,wt={get passive(){return gt=!0}},mt=function(){};ft.addEventListener&&ft.addEventListener("p",mt,wt),ft.removeEventListener&&ft.removeEventListener("p",mt,!1);var xt=gt,yt="PointerEvent"in ft,bt="ontouchstart"in ft,vt=bt||"TouchEvent"in ft&&pt("(any-pointer: coarse)").matches,St=(ft.navigator.maxTouchPoints||0)>0||vt,Et=ft.navigator.userAgent||"",_t=pt("(pointer: coarse)").matches&&/iPad|Macintosh/.test(Et)&&Math.min(ft.screen.width||0,ft.screen.height||0)>=768,Ct=(pt("(pointer: coarse)").matches||!pt("(pointer: fine)").matches&&bt)&&!/Windows.*Firefox/.test(Et),It=pt("(any-pointer: fine)").matches||pt("(any-hover: hover)").matches||_t||!bt,Mt=!St||!It&&Ct?St?"touchOnly":"mouseOnly":"hybrid",Rt="mouseOnly"===Mt?"mouse":"touchOnly"===Mt||Ct?"touch":"mouse";const kt=Object.freeze(Object.defineProperty({__proto__:null,deviceType:Mt,primaryInput:Rt,supportsPassiveEvents:xt,supportsPointerEvents:yt,supportsTouchEvents:vt},Symbol.toStringTag,{value:"Module"})),Tt=new Set(["INPUT","TEXTAREA","SELECT"]),Pt={};function Ot(){return kt}const Lt=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:Pt,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:Ot,focusableNodeNames:Tt,toPrettyKeyCode:e=>"BracketLeft"===e?"[":"BracketRight"===e?"]":ae.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),Dt=[];function zt(e,n,o=Dt){const r=t.useRef(null);return t.useImperativeHandle(e,()=>{if(!r.current)return;const e=r.current,t=n?.();if(!t||"object"!=typeof t)throw new Error("attributes must return a plain object of values");const o=Object.keys(t),i=o.length;for(let n=0;n<i;n++){const r=o[n],i=t[r];Object.defineProperty(e,r,{value:i,writable:!0,configurable:!0,enumerable:!0})}return e},o),r}const jt=t=>e.jsx(rt,{...t}),At=({width:t,height:n})=>e.jsx("div",{className:"corner",style:{minWidth:`${t}px`,width:`${t}px`,minHeight:`${n}px`,height:`${n}px`}}),$t=t.memo(t.forwardRef((n,o)=>{const{children:r,viewport:i,onScrollViewport:l,showHorizontalScrollbar:s=!0,showVerticalScrollbar:c=!0,createScrollCorner:a=At,createHorizontalScrollbar:u=jt,createVerticalScrollbar:d=jt,style:h,touchElement:f,disableTouch:p,...g}=n,w=et(l,[l]),m=zt(o,()=>({isScrollPane:()=>!0}),[]),x=t.useRef(null);t.useEffect(()=>{x.current&&(x.current.__scrollTop===i?.top&&x.current.__scrollLeft===i?.left||x.current.__isDecelerating||x.current?.scrollTo(i?.left,i?.top,!1))},[i?.left,i?.top,f]);const y=t.useCallback((e,t)=>{w?.({left:e,top:t})},[]),b=t.useCallback(e=>{x.current?.doTouchStart(e.touches,e.timeStamp)},[]),v=t.useCallback(e=>{e.preventDefault(),x.current?.doTouchMove(e.touches,e.timeStamp)},[]),S=t.useCallback(e=>{x.current?.doTouchEnd(e.timeStamp)},[]),E=t.useCallback(({containerWidth:e,containerHeight:t,totalWidth:n,totalHeight:o})=>{x.current.setDimensions(e,t,n,o)},[]);t.useEffect(()=>{const e=f??m.current;if(!p&&Ot().supportsTouchEvents&&e&&i){if(!x.current){const e={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};x.current=new ht(y,e)}Ot().supportsTouchEvents&&(e.addEventListener("touchstart",b),e.addEventListener("touchend",S),e.addEventListener("touchmove",v)),E({containerWidth:i?.width,containerHeight:i?.height,totalWidth:i?.totalWidth,totalHeight:i?.totalHeight})}return()=>{e?.removeEventListener("touchstart",b),e?.removeEventListener("touchend",S),e?.removeEventListener("touchmove",v)}},[i?.width,i?.height,i?.totalWidth,i?.totalHeight,p,f]);const[_,{width:C}]=Qe(),[I,{height:M}]=Qe(),R=t.useMemo(()=>{const t=d({orientation:qe.Vertical,offset:i?.top,viewportSize:i?.height,totalSize:i?.totalHeight,onScrollOffset:e=>{w?.({top:e})}});return e.jsx("div",{style:{display:"flex",flex:"0"},ref:_,children:t})},[d,i?.top,i?.height,i?.totalHeight]),k=t.useMemo(()=>{const t=u({orientation:qe.Horizontal,offset:i?.left,viewportSize:i?.width,totalSize:i?.totalWidth,onScrollOffset:e=>w?.({left:e})});return e.jsxs("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[e.jsx("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${C}px)`},children:e.jsx("div",{ref:I,className:"sizer",children:t})}),c?a({width:C,height:M}):e.jsx(e.Fragment,{})]})},[u,i?.left,i?.width,i?.totalWidth,c,a,C,M]);return e.jsx("div",{style:{position:"relative",display:"flex",minWidth:c?`${C}px`:void 0,minHeight:s?`${M}px`:void 0,...h},...g,ref:m,children:e.jsxs("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[e.jsxs("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:r}),c?R:e.jsx(e.Fragment,{})]}),s?k:e.jsx(e.Fragment,{})]})})}));$t.displayName="ScrollPane";const Bt=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let Ft=0;function Vt(){return t.useEffect(()=>{function e(){const e=document.fullscreenElement;if(!e)return;let t=e.querySelector(".fullscreen-portal-root");t||(t=document.createElement("div"),t.className="fullscreen-portal-root _fullscreen-portal-root_1mjsr_4",e.appendChild(t))}return Ft++,e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),Ft--,Ft<=0&&(document.querySelectorAll(".fullscreen-portal-root").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),Ft=0)}},[]),{getPortalContainer:Bt}}const Wt=100,Ht=100,Nt=1e6,Ut=100,qt=50,Kt=t.memo(t.forwardRef((n,o)=>{const{offset:r=0,viewportSize:i=0,totalSize:l=0,minSize:s=0,endGap:c=Wt,endScrollIncrement:a=Ht,style:u=Pt,onMouseDown:d,onScrollOffset:h,onScroll:f,scaleLimit:p=Nt,scaleFactor:g=Ut,precisionFactor:w=qt,...m}=n;f&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const x=et(d,[d]),y=()=>({offset:r,totalSize:0===p?l:Math.min(l??0,Math.max(s??0,(r??0)+(i??0))+(c??0))}),[b,v]=t.useState(y),S=0!==p&&b.totalSize>p?g:1,E=S/w,_=Math.ceil(b.totalSize/S),C=Math.ceil(b.offset/S),I=Math.ceil(i/S),M=t.useCallback(e=>{},[]),[R,k]=t.useState(!1),T=t.useRef(null);t.useLayoutEffect(()=>{if(!R){T.current={propTotalSize:l,propViewportSize:i,propOffset:r};const e=y();v(e)}},[l,i,r,R,s,c,a]);const P=et((e,t,n)=>{const o=T.current;T.current=null,o&&o.propTotalSize===l&&o.propViewportSize===i&&o.propOffset===r||(Math.abs(e-C)<E&&(e=C),h?.(e*S,C,I))},[h,S,E,C,I]),O=t.useCallback(e=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",O),k(!1)},[]),L=t.useCallback(e=>{x?.(e),k(!0),document.addEventListener("mousemove",M,{passive:!0}),document.addEventListener("mouseup",O,{passive:!0})},[M,O]);return e.jsx(rt,{ref:o,style:{...u},...m,offset:C,totalSize:_,viewportSize:I,onMouseDown:L,onScrollOffset:P})}));function Yt(e,t){if("function"==typeof e)return e(t);e&&(e.current=t)}Kt.displayName="VirtualScrollbar";var Xt=parseInt(t.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const e=Yt(o,t),r="function"==typeof e;n.push(r?e:()=>Yt(o,null))}return()=>{for(const e of n)e()}}}:function(e){return t=>{for(const n of e)Yt(n,t)}};t.memo(t.forwardRef((n,o)=>{const{refFocusStart:r,...i}=n,l=t.useRef(null),s=t.useCallback(()=>{if(r)return void r?.current?.focus();const e=l.current.parentElement.children;let t=[];for(let n=0;n<e.length&&e[n]!==l.current;n++){const o=e[n].getAttribute("tabindex");if(null==o||"-1"===o)continue;if("true"===e[n].getAttribute("disabled"))continue;const r=e[n];r.focus&&t.push({tabindex:parseInt(o),child:r})}0!==t.length&&(t.sort(function(e,t){return e.tabindex-t.tabindex}),t[0].child.focus())},[r]);return e.jsx("div",{tabIndex:0,ref:Xt([l,o]),onFocus:s,...i})})),t.memo(t.forwardRef((n,o)=>{const{className:r,style:i,children:l,radius:s=4,strokeWidth:c=1,strokeColor:a="grey",...u}=n,[d,{width:h,height:f}]=Qe(),p=t.useRef(null),g=(e,t=0)=>{const n=e/2,o=f-n+t;return function(e,t,n=!1){if(0===t)return e;function o(e,t,n){let o=t.x-e.x,i=t.y-e.y,l=Math.sqrt(o*o+i*i);return r(e,t,Math.min(1,n/l))}function r(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function i(e,t){e.length>2&&(e[e.length-2]=t.x,e[e.length-1]=t.y)}function l(e){return{x:parseFloat(e[e.length-2]),y:parseFloat(e[e.length-1])}}let s=e.split(/[,\s]/).reduce(function(e,t){let n=t.match("([a-zA-Z])(.+)");return n?(e.push(n[1]),e.push(n[2])):e.push(t),e},[]).reduce(function(e,t){return parseFloat(t)==t&&e.length?e[e.length-1].push(t):e.push([t]),e},[]),c=[];if(s.length>1){let e=l(s[0]),a=null;"Z"===s[s.length-1][0]&&s[0].length>2&&(a=["L",e.x,e.y],s[s.length-1]=a),c.push(s[0]);for(let e=1;e<s.length;e++){let u=c[c.length-1],d=s[e],h=d===a?s[1]:s[e+1];if(h&&u&&u.length>2&&"L"===d[0]&&h.length>2&&"L"===h[0]){let e,s,a=l(u),f=l(d),p=l(h);n?(e=r(f,u.origPoint||a,t),s=r(f,h.origPoint||p,t)):(e=o(f,a,t),s=o(f,p,t)),i(d,e),d.origPoint=f,c.push(d);let g=r(e,f,.5),w=r(f,s,.5),m=["C",g.x,g.y,w.x,w.y,s.x,s.y];m.origPoint=f,c.push(m)}else c.push(d)}if(a){let e=l(c[c.length-1]);c.push(["Z"]),i(c[0],e)}}else c=s;return c.reduce(function(e,t){return e+t.join(" ")+" "},"")}(`M 0 ${n} L ${s-.5} ${n} L ${s-.5} ${o} L ${2*s} ${o} L ${h-2*s} ${o} M ${h-2*s} ${o} L ${h-s} ${o} L ${h-s} ${n} L ${h} ${n}`,s)},w=t.useMemo(()=>g(c),[h,f,s,c]),m=t.useMemo(()=>{if(0===s)return;const e=s/2;return g(s)+`L ${h} 0 L 0 0 L 0 ${e}`},[w,s,c]),x=t.useMemo(()=>({style:{clipPath:`path('${m}')`}}),[m]);return e.jsxs("div",{className:r,style:{display:"flex",flexDirection:"row",...i},...u,ref:Xt([p,d,o]),children:[t.isValidElement(l)?t.cloneElement(l,x):e.jsx(e.Fragment,{}),e.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:h,height:f,viewBox:`0 0 ${h} ${f}`,children:e.jsx("path",{d:w,stroke:a,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:c})})]})}));const Gt={},Zt=t=>{const{onPointerDown:n,style:o,splitDirection:r,paddingBefore:i=0,paddingAfter:l=0,disabled:s,key:c,hitAreaProps:a=Gt,...u}=t,d="row"===r,{style:h,className:f,...p}=a;return e.jsx("div",{style:{...o,position:"relative"},...u,children:e.jsx("div",{className:Ye("hit-box",f),style:{left:(d?-i:0)+"px",width:`calc(100% + ${d?i+l:0}px)`,top:(d?0:-i)+"px",height:`calc(100% + ${d?0:i+l}px)`,position:"absolute",...h},onPointerDown:s?void 0:n,...p})},c)},Jt={},Qt=(e,t,n=!0)=>null===e?null:null!==e.pixels?n?e.pixels:t-e.pixels:(n?e.percent:100-e.percent)/100*t,en=(e,t=!0)=>e?.percent?`${t?e.percent:100-e.percent}%`:e?.pixels?`${e.pixels}px`:void 0,tn=(e,t)=>{if(null==e)return null;const n={percent:null,pixels:null};let o=t;return"string"==typeof e&&((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 nn(e){if(!e)throw new Error("must have a PointerHandlerOptions");const{onPointerDown:n,onPointerUp:o,onPointerMoveOrWait:r,processTouch:i=!1,consumeTouch:l=!0}=e,s=et(n,[n]),c=et(o,[o]),a=et(r,[r]),u=t.useRef(!1),d=e?.timerInitial??230,h=e?.timerContinuous??d/2,f=t.useRef(null),p=t.useRef(null),g=t.useRef(null),w=t.useRef(null),m=t.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),x=t.useCallback(e=>{w.current=setTimeout(()=>{window.requestAnimationFrame(()=>{!1!==u.current&&a?.(p.current,g.current,f.current)}),x(h)},e??d)},[]);t.useEffect(()=>()=>m(),[]);const y=i?"pointer":"mouse",b=t.useCallback(e=>{e.stopPropagation(),e.stopImmediatePropagation(),e.preventDefault()},[]),v=et(e=>{document.removeEventListener(`${y}move`,_),document.removeEventListener(`${y}up`,v),document.removeEventListener("keydown",C),document.removeEventListener("keyup",I),document.removeEventListener("touchstart",b,{capture:!0}),document.removeEventListener("touchmove",b,{capture:!0}),window.removeEventListener("blur",S),m(),window.requestAnimationFrame(()=>{!1!==u.current&&(u.current=!1,c?.(e,g.current,f.current),g.current=null)})},[]),S=t.useCallback(()=>{!1!==u.current&&(u.current=!1,v(p.current))},[]),E=et(()=>{m(),x(h),window.requestAnimationFrame(()=>{!1!==u.current&&a?.(p.current,g.current,f.current)})},[h]),_=et(e=>{p.current=e,E()},[]),C=et(e=>{g.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},E()},[]),I=et(e=>{g.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},E()},[h]);return et(e=>{e.isDefaultPrevented()||(g.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},!1!==s(e,g.current)&&(f.current=e,p.current=e.nativeEvent,document.addEventListener(`${y}up`,v,{passive:!1}),document.addEventListener(`${y}move`,_,{passive:!1}),document.addEventListener("keydown",C,{passive:!1}),document.addEventListener("keyup",I,{passive:!1}),window.addEventListener("blur",S,{passive:!0}),i&&l&&(document.addEventListener("touchstart",b,{passive:!1,capture:!0}),document.addEventListener("touchmove",b,{passive:!1,capture:!0})),u.current=!0,x(d)))},[d,i])}t.memo(t.forwardRef((n,o)=>{const{elementBefore:r,elementAfter:i,splitDirection:l="row",fixedPane:s=null,position:c,onPositionChange:a,minBefore:u,maxBefore:d,minAfter:h,maxAfter:f,children:p,className:g,style:w,disabled:m=!1,onDragStart:x,onDragResize:y,onDragFinish:b,resizerProps:v=Jt,paneProps:S=Jt,paneBeforeProps:E=Jt,paneAfterProps:_=Jt,createResizer:C=Zt}=n;if(p)throw new Error("Use elementBefore and elementAfter instead of children.");const I=t.useMemo(()=>t.isValidElement(i)&&t.isValidElement(r),[i,r]),M=t.useMemo(()=>{let e=null;s&&("before"===s?e=0:"after"===s&&(e=1));const t=null===e;return{fixedPaneOffset:e,isPercent:t,minBefore:tn(u,t),maxBefore:tn(d,t),minAfter:tn(h,t),maxAfter:tn(f,t)}},[u,d,h,f]),R=et(a,[a]),[k,T]=t.useState(()=>tn(c,null===s));t.useEffect(()=>{T(tn(c,null===s))},[c,s]);const[P,{width:O,height:L}]=Qe(),[D,{width:z,height:j}]=Qe(),A="row"===l?z:j,$="row"===l?O:L,B=t.useMemo(()=>((e,t,n,o)=>{const r=[null,null],i=[null,null];if(e||(e={percent:null===o.fixedPaneOffset?50:null,pixels:null===o.fixedPaneOffset?null:0}),0===t)return null!=e?.pixels?1!==o.fixedPaneOffset?(r[0]=e?.pixels,i[1]=100):(r[1]=e?.pixels-n,i[0]=100):null!=e?.percent&&(1!==o.fixedPaneOffset?(i[0]=e?.percent,i[1]=100-e?.percent):(i[1]=e?.percent,i[0]=100-e?.percent)),{percents:i,pixels:r,minBefore:en(o.minBefore,!0),maxBefore:en(o.maxBefore,!0),minAfter:en(o.minAfter),maxAfter:en(o.maxAfter)};let l=Qt(e,t,1!==o.fixedPaneOffset),s=t-n,c=Qt(o.minBefore,s,!0)??0,a=Qt(o.maxBefore,s,!0)??s,u=0,d=0,h=0,f=s;u=(Qt(o.maxAfter,t,!1)??n)-n,d=Qt(o.minAfter,t,!1)??t,h=Math.max(c,u),f=Math.min(a,d),l=Math.max(h,Math.min(l,f)),d=Math.min(s-l,Qt(o.maxAfter,s-l,!0)??s),u=Math.min(s-l,Qt(o.minAfter,s-l,!0)??s),r[0]=l,r[1]=s-r[0];const p=Math.max(0,Math.min(100,l/s*100));return i[0]=p,i[1]=100-i[0],{percents:i,pixels:r,minBefore:`${c}px`,minAfter:`${u}px`,maxBefore:`${r[0]}px`,maxAfter:`${r[1]}px`}})(k,$,A,M),[M,k,$,A,l]),[F,V]=t.useState(!1),W=et(x,[x]),H=et(y,[y]),N=et(b,[b]),U=t.useRef(null),q=t.useRef(null),K=t.useRef(null),{style:Y,className:X,...G}=S,Z={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...Y},{className:J,style:Q,...ee}=E,{className:te,style:ne,...oe}=_,re={flex:"1 1 100%",width:"100%",...w,flexDirection:l,display:"flex"},{className:ie,style:le,onPointerDown:se,...ce}=v,ae=et(e=>{const t=tn(e,null===s);T(t)},[s]),ue=et(e=>{if(m||!F)return;const t=fe.current?.getBoundingClientRect();let n=0;n="row"===l?(e.clientX??e.touches?.[0]?.clientX)-t.x:(e.clientY??e.touches?.[0]?.clientY)-t.y,n=Math.max(0,Math.min($,n)),1===M.fixedPaneOffset&&(n=$-n),c&&k.pixels===n||T({pixels:n,percent:null}),H?.(n),e.stopPropagation(),e.preventDefault()},[M,l,m,F,k,$]),de=et(e=>{if(document.removeEventListener("pointermove",ue),document.removeEventListener("touchmove",ue),document.removeEventListener("pointerup",de),F&&(V(!1),k)){if(N(k.pixels),!tn(c,null===s)||k.pixels!==c){const e={...k};null===e.percent&&(e.percent=e.pixels/$*100),R(e)}e.stopPropagation(),e.preventDefault()}},[k,F,c,s,$]),he=et(e=>{se?.(e),e.defaultPrevented||m||F||(V(!0),W(),document.addEventListener("pointermove",ue,{passive:!1}),document.addEventListener("touchmove",ue,{passive:!1}),document.addEventListener("pointerup",de,{passive:!1}))},[se]),fe=zt(o,()=>({setPosition:ae,isSplitPane:()=>!0}),[]),pe=t.useMemo(()=>I?C?.({key:"resizer",ref:Xt([D,q]),className:Ye("resizer",ie),onPointerDownCapture:he,style:{cursor:m?void 0:"row"===l?"ew-resize":"ns-resize",minWidth:"row"===l?"2px":void 0,minHeight:"row"!==l?"2px":void 0,boxSizing:"border-box",pointerEvents:"all",zIndex:1,...le},splitDirection:l,disabled:m,...ce}):null,[I,ie,ce,l,le,m]),ge="row"===l?"Width":"Height",we={...Z,...Q,flex:0===M.fixedPaneOffset&&null!==B?.pixels[0]?`0 0 ${Math.round(B?.pixels[0])}px`:`1 1 ${Math.round(B?.percents[0]??100)}%`,[`min${ge}`]:B?.minBefore,[`max${ge}`]:i?B?.maxBefore:"100%"},me={...Z,...ne,flex:1===M.fixedPaneOffset&&null!==B?.pixels[1]?`0 0 ${Math.round(B?.pixels[1])}px`:`1 1 ${Math.round(B?.percents[1]??100)}%`,[`min${ge}`]:B?.minAfter,[`max${ge}`]:r?B?.maxAfter:"100%"},xe=t.useMemo(()=>r?e.jsx("div",{ref:U,className:Ye("before",X,J),style:we,...G,...ee,children:r},"before"):null,[r,S,E,M,B]),ye=t.useMemo(()=>i?e.jsx("div",{ref:K,className:Ye("after",X,te),style:me,...G,...oe,children:i},"after"):null,[i,S,_,M,B]);return e.jsxs("div",{ref:Xt([P,fe]),className:Ye("splitPane","row"===l?"vertical":"horizontal",{dragging:F},g),style:re,children:[xe,pe,ye]})}));const on=({initValue:e,useHookBody:n,applyStateChange:o})=>{const r=t.useRef(e);if("function"!=typeof n)throw new Error("function expected as hook body parameter. got "+typeof n);const i=n();return t.useLayoutEffect(()=>{r.current!==i&&(r.current=i,o(i))},[o,i]),null},rn=e=>{console&&console.warn&&console.warn(e)},ln="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||void 0;let sn=1,cn=!1,an=!1;const un=[],dn=[],hn=()=>{dn.forEach(e=>e())},fn=({automaticContainerInternalUseOnly:n})=>{const[o,r]=t.useState([]),i=t.useRef([]);return i.current=o,n||!1!==cn||(an=!0),t.useEffect(()=>{let e=!0;function t(){if(e)return dn[0]!==t?(n||!0!==cn||rn("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."),void r(e=>[])):void r([...un])}return dn.push(t),hn(),()=>{e=!1,i.current?.length>0&&rn("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"),dn.splice(dn.indexOf(t),1),hn()}},[n]),e.jsx(e.Fragment,{children:o.map(({hook:e,key:n})=>t.createElement(on,{...e,key:n}))})},pn=(r,i,l={})=>{let s,c,a=!1,u=!1,d=[],{unmountIfNoConsumers:h=!1}=l;const f=e=>{c=e,o.unstable_batchedUpdates(()=>d.forEach(t=>t(e)))},p=()=>(u||(c="function"==typeof r?r():r,u=!0),c);return()=>{const[o,l]=t.useState(p);return t.useEffect(()=>(a||(a=!0,s=(t=>{const o=sn++;return un.push({hook:t,key:o}),0===dn.length&&!1===an&&(cn=!0,(t=>{if(ln.document&&ln.document.createElement){const o=ln.document.createElement("div");n.createRoot(o).render(e.jsx(t,{automaticContainerInternalUseOnly:!0}))}else rn("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")})(fn)),hn(),()=>{un.splice(un.findIndex(e=>e.key===o),1),hn()}})({initValue:r,useHookBody:i,applyStateChange:f})),d.push(l),c!==o&&l(c),()=>{d.splice(d.indexOf(l),1),0===d.length&&h&&(s(),a=!1)}),[]),o}};pn(null,()=>{const[e,n]=t.useState(null);return e});class gn{constructor(e,t,n,o){this._listenersProperties=new Set,this._listenersExecute=new Set,this._key=e,this._target=t,this._applyProps(n||{}),this._callback=o,void 0===o&&(this._callback=()=>{console.log(`implement: ${this.label()} : ${this.description()}`)})}key(){return this._key}_resolve(e,t){if("function"==typeof e){const n=t??this._context;return e("function"==typeof n?n():n)}return e}target(){return"function"==typeof this._target?this._target():this._target}label(e,t){const n=this._scopedLabels?.[e]||this._label;let o=null;if("function"==typeof n){const e=t??this._context;o=n("function"==typeof e?e():e)}else o=n;return o}description(e){return this._resolve(this._description,e)}tags(e){return this._resolve(this._tags,e)}icon(e){return this._resolve(this._icon,e)}shortcut(){return this._resolve(this._shortcut)}disabled(){return this._resolve(this._disabled)||!this._callback}state(){return this._resolve(this._state)}context(){return"function"==typeof this._context?this._context():this._context}async execute(e,t){if(!this.disabled()&&this._callback){try{let n=!0;if(t?.beforeExecute&&(n=t?.beforeExecute(this,e)),!1===await Promise.resolve(n))return!1;const o=this._callback.bind(this)(e,this);if(!1===await Promise.resolve(o))return!1;t?.onExecute?.(this,e),this._notifyExecute(e)}catch(n){return console.warn(n),t?.onError(this,n,e),this._notifyError(e,n),!1}return!0}}addPropertyListener(e,t=!1){if(!e)throw new Error("listener must be specified");const n=this._listenersProperties;return n.add(e),t&&e({},this),()=>{n.delete(e)}}addExecuteListener(e){if(!e)throw new Error("listener must be specified");const t=this._listenersExecute;return t.add(e),function(){t.delete(e)}}_notifyExecute(e){const t=this;this._listenersExecute.forEach(n=>{n.onExecute(t,e)})}_notifyError(e,t){const n=this;this._listenersExecute.forEach(o=>{o.onError?.(n,e,t)})}updateCallback(e){return this._callback=e||null,this}update(e){if(!e)return;const t=this._applyProps(e);return Object.keys(t).length>0&&this._notifyPropertyChange(t),this}_notifyPropertyChange(e){const t=this;this._listenersProperties.forEach(n=>{n(e,t)})}_applyProps(e){let t={},n=this;return Object.keys(e).forEach(o=>{let r=e[o];n["_"+o]!==r&&(n["_"+o]=t[o]=r)}),t}}class wn extends gn{}ae.getOS()===ae.OSType.MacOS||(ae.getOS(),ae.OSType.IOS),ae.getOS()===ae.OSType.MacOS||(ae.getOS(),ae.OSType.IOS),pn({setClipboard:e=>{throw new Error("This is only available via the useClipboard.")},getClipboard:()=>Pe.Global,refNativeCopy:{current:null},refNativeLastKey:{current:null}},()=>{const[e,n]=t.useState(Pe.Global);return{setClipboard:e=>n(e),getClipboard:()=>e,refNativeCopy:t.useRef(null),refNativeLastKey:t.useRef(null)}});let mn=!1,xn=0;var yn="undefined"!=typeof document?t.useLayoutEffect:t.useEffect;const bn=()=>"sheetxl-ui-"+xn++,vn=t["useId".toString()],Sn=null!=vn?vn:function(){const[e,n]=t.useState(()=>mn?bn():void 0);return yn(()=>{null==e&&n(bn())},[]),t.useEffect(()=>{mn||(mn=!0)},[]),e},En=({itemType:e,index:t,itemSize:n,instanceProps:o,scale:r=1})=>{let i,l,s;"column"===e?(i=o.columnMetadataMap,l=o.lastMeasuredColumnIndex,s=o.recalcColumnIndices):(i=o.rowMetadataMap,l=o.lastMeasuredRowIndex,s=o.recalcRowIndices);const c=s.length>0;if(t>l){let a=0;if(l>=0){const e=i[l];a=e.offset+e.size}for(let e=l+1;e<=t;e++){let t=c?s.includes(e)?n(e)*r:i[e]?.size||n(e)*r:n(e)*r;i[e]={offset:a,size:t},a+=t}"column"===e?o.lastMeasuredColumnIndex=t:o.lastMeasuredRowIndex=t}return i[t],i[t]},_n=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,offset:r,scale:i})=>{let l,s;"column"===e?(l=o.columnMetadataMap,s=o.lastMeasuredColumnIndex):(l=o.rowMetadataMap,s=o.lastMeasuredRowIndex);let c=0;return c=(s>0?l[s].offset:0)>=r?Cn({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):In({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),c=Math.min(c,n),c},Cn=({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),c=En({itemType:e,itemSize:t,index:s,instanceProps:n,scale:l}).offset;if(c===i)return s;c<i?r=s+1:c>i&&(o=s-1)}return r>0?r-1:0},In=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:r,offset:i,scale:l})=>{let s=1;for(;r<n&&En({itemType:e,itemSize:t,index:r,instanceProps:o,scale:l}).offset<i;)r+=s,s*=2;return Cn({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},Mn=e=>{const{rowCount:n,columnCount:o,defaultRowHeight:r,getRowHeight:i,defaultColumnWidth:l,getColumnWidth:s}=e||{},c=t.useRef({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),a=et(e=>_n({itemType:"row",itemCount:n,itemSize:i??(()=>r??20),instanceProps:c.current,offset:e}),[n,i,r]),u=et(e=>-1===e?0:En({itemType:"row",index:e,itemSize:i??(()=>r??20),instanceProps:c.current}).offset,[i,r]),d=et(e=>En({itemType:"row",index:e,itemSize:i??(()=>r??20),instanceProps:c.current}).size,[i,r]),h=et(e=>_n({itemType:"column",itemCount:o,itemSize:s??(()=>l??75),instanceProps:c.current,offset:e}),[o,s,l]),f=et(e=>-1===e?0:En({itemType:"column",index:e,itemSize:s??(()=>l??75),instanceProps:c.current}).offset,[s,l]),p=et(e=>En({itemType:"column",index:e,itemSize:s??(()=>l??75),instanceProps:c.current}).size,[s,l]),[g,w]=t.useReducer(e=>e+1,0),m=()=>({getRowOffset:u,getColOffset:f,getRowIndex:a,getColIndex:h}),[x,y]=t.useState(()=>e?m():null);return t.useEffect(()=>{y(e?m():null)},[g,n,o,l,r,d,p]),x},Rn="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",kn=e=>{if(!e)return null;if("start"===e.eventType)return{type:e.eventType};if("submit"===e.eventType)return{type:e.eventType};if("cancel"===e.eventType)return{type:e.eventType};if("keyboard"===e.eventType)return{type:e.eventType,key:e.event.key};if("pointer"===e.eventType)return{type:e.eventType};if("coordsChange"===e.eventType){const t={type:e.eventType};return e.activeCoords&&(t.activeCoords=e.activeCoords),t}return{type:e.eventType??"unknown"}},Tn=e=>!0,Pn=e=>!!e&&(!(e.ctrlKey||e.metaKey||e.altKey||e.isComposing)&&(!(e.shiftKey||"F2"!==e.key&&" "!==e.key&&"Backspace"!==e.key)||(!e.shiftKey||" "!==e.key)&&-1!==Rn.indexOf(e.key))),On=e=>!!e&&("dblclick"===e.type&&{editMode:!0}),Ln=n=>{const{session:o,refLatestCoords:r,handleSubmitEdit:i,handleCancelEdit:l,cellBounds:s,isInBounds:c,getCellEditor:a,propsEditor:u,borderStrokeFill:d="rgb(33, 115, 70)",borderStrokeWidth:h=2,alignment:f=Le.Left,style:p,...g}=n,w=t.useRef(null),m=t.useRef(null),[x,y]=t.useState(!1),b=o.coords,v=t.useCallback(async e=>{const t=w.current?.getBoundingClientRect();if(t){if("keyboard"===e.eventType){const t=e.event,n=new KeyboardEvent(t.type,{bubbles:!0,cancelable:!0,view:window,key:t.key,code:t.code,location:t.location,repeat:t.repeat,isComposing:t.isComposing,charCode:t.charCode,keyCode:t.keyCode,which:t.which,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey});n.isSynthetic=!0,n.key,m.current?.dispatchEvent(n)}else"pointer"===e.eventType||console.warn("unsupported event type",e);await new Promise(e=>requestAnimationFrame(e))}},[]);t.useEffect(()=>{const e=m.current;y(!0),m.current.startEdit?.(o.startEvent);return(async()=>{o.editorRefs.push(e),o.editorRefsDispatchEditorEvent.push(v);const t=[...o.events];for(let e=0;e<t.length;e++)await v(t[e]);o.onMount(e)})(),()=>{const t=o.editorRefs.indexOf(e);-1!==t&&o.editorRefs.splice(t,1),o.onUnmount(e)}},[]);const S=t.useCallback(()=>i(o),[]),E=t.useCallback(()=>{l(o)},[]),_=r.current&&$.isEqualCells(r.current,b),C=c&&_&&x,I=a({autoFocus:!!o.startEvent?.autoFocus,...u,onSubmitEdit:S,onCancelEdit:E,ref:m},b),M=s.x+Lt.boundPixel(-h/2),R=Lt.boundPixel(s.width+h/2,!0);return e.jsx("div",{tabIndex:0,ref:w,style:{background:void 0,...p,opacity:C?p?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${s.y+Lt.boundPixel(-h/2)}px`,height:Lt.boundPixel(s.height+h/2,!0),left:`${M}px`,width:R},...g,children:e.jsx("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${Lt.boundPixel(1)}px`,top:`${Lt.boundPixel(1)}px`,width:Lt.boundPixel(s.width-2,!0),height:Lt.boundPixel(s.height-2,!0),outline:`${h}px ${d} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:I})})},Dn=(e,t,n)=>{if(!e)return t;let o=t;const r=n===s||n===i;for(;;){const t=e(o,!r);if(0===t)return o;r?o+=t:o-=t}},zn=(e,t,n)=>{const o=[];let r=t;for(;r<=n;){const t=Math.max(0,e(r));0===t?(o.push(r),r++):r+=t}return o},jn=(e,t,n,o,c,a)=>{if(!t)return a;let{rowIndex:u,colIndex:d}=e;switch(o){case i:{u=Dn(n,Math.min(u+1,a),o);let e=t({rowIndex:u,colIndex:d});for(;!e&&u<a;)u=Dn(n,Math.min(++u,a),o),e=t({rowIndex:u,colIndex:d});return u}case r:{u=Dn(n,Math.max(u-1,a),o);let e=t({rowIndex:u,colIndex:d});for(;!e&&u>a;)u=Dn(n,Math.max(--u,a),o),e=t({rowIndex:u,colIndex:d});return u}case s:{d=Dn(n,Math.min(d+1,a),o);let e=t({rowIndex:u,colIndex:d});for(;!e&&d<a;)d=Dn(n,Math.min(++d,a),o),e=t({rowIndex:u,colIndex:d});return d}case l:{d=Dn(n,Math.max(d-1,a),o);let e=t({rowIndex:u,colIndex:d});for(;!e&&d>a;)d=Dn(n,Math.max(--d,a),o),e=t({rowIndex:u,colIndex:d});return d}default:return a}},An=(e,t=()=>!0,n,o,c,a)=>{let{rowIndex:u,colIndex:d}=e;switch(o){case i:{u=Dn(n,Math.min(u+1,a),o);let e=t?.({rowIndex:u,colIndex:d});for(;e&&u<a;)u=Dn(n,Math.min(++u,a),o),e=t?.({rowIndex:u,colIndex:d});return t?.({rowIndex:u,colIndex:d})?u:u-1}case r:{u=Dn(n,Math.max(u-1,a),o);let e=t?.({rowIndex:u,colIndex:d});for(;e&&u>a;)u=Dn(n,Math.max(--u,a),o),e=t?.({rowIndex:u,colIndex:d});return t?.({rowIndex:u,colIndex:d})?u:u+1}case s:{d=Dn(n,Math.min(d+1,a),o);let e=t?.({rowIndex:u,colIndex:d});for(;e&&d<a;)d=Dn(n,Math.min(++d,a),o),e=t?.({rowIndex:u,colIndex:d});return t?.({rowIndex:u,colIndex:d})?d:d-1}case l:{d=Dn(n,Math.max(d-1,a),o);let e=t?.({rowIndex:u,colIndex:d});for(;e&&d>a;)d=Dn(n,Math.max(--d,a),o),e=t?.({rowIndex:u,colIndex:d});return t?.({rowIndex:u,colIndex:d})?d:d+1}default:return null}},$n=(e,t,n,o,c,a)=>{if(!t)return a;let u,{rowIndex:d,colIndex:h}=e;o===i?u={rowIndex:d+1,colIndex:h}:o===r?u={rowIndex:d-1,colIndex:h}:o===s?u={rowIndex:d,colIndex:h+1}:o===l&&(u={rowIndex:d,colIndex:h-1});const f=t(e),p=t(u);var g,w;return(w=p,!(g=f)&&!w||!g&&w||g&&!w?jn:An)(e,t,n,o,!1,a)??a},Bn=(e,t)=>`${e}:${t}`,Fn=(e,t,n,o,r,i)=>{if(n-t>=r-o)return o;let l=o;if("nearest"===e&&(o-t>0?e="start":n-r>0&&(e="end")),"start"===e)l=t;else if("end"===e)l=n-(r-o);else if("center"===e){l=t+(n-t)/2-(r-o)/2}return Math.max(0,Math.min(l,i-(r-o)))},Vn=(e,t,n,o)=>(console.log("todo: implement convertToVisibleRanges"),e),Wn=(e,t=s,n,o,c,a=null)=>{if(a&&$.isEqualSelectionCoords(a,e))return e;const u=e.ranges[e.rangeIndex];if(!$.isRangesIntersect({rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},u))return e;let d={...e.cell},h=e.rangeIndex;switch(t){case s:d.colIndex=Dn(c,d.colIndex+1,t);break;case l:d.colIndex=Dn(c,d.colIndex-1,t);break;case i:d.rowIndex=Dn(o,d.rowIndex+1,t);break;case r:d.rowIndex=Dn(o,d.rowIndex-1,t)}const f=t=>{if(t){h=e.rangeIndex>=e.ranges.length-1?0:e.rangeIndex+1;const t=e.ranges[h];d={colIndex:t.colStart,rowIndex:t.rowStart}}else{h=e.rangeIndex<=0?e.ranges.length-1:e.rangeIndex-1;const t=e.ranges[h];d={colIndex:t.colEnd,rowIndex:t.rowEnd}}};if(t===s&&d.colIndex>u.colEnd&&d.rowIndex===u.rowEnd)f(!0);else if(t===l&&d.colIndex<u.colStart&&d.rowIndex===u.rowStart)f(!1);else if(t===i&&d.colIndex===u.colEnd&&d.rowIndex>u.rowEnd)f(!0);else if(t===r&&d.colIndex===u.colStart&&d.rowIndex<u.rowStart)f(!1);else{let e=d.rowIndex,n=d.colIndex;switch(t){case s:n>u.colEnd&&(e=Dn(o,e+1,t),n=u.colStart,e>u.rowEnd&&(e=u.rowStart));break;case l:n<u.colStart&&(e=Dn(o,e-1,t),n=u.colEnd,e<u.rowStart&&(e=u.rowEnd));break;case i:e>u.rowEnd&&(n=Dn(c,n+1,t),e=u.rowStart,n>u.colEnd&&(n=u.colStart));break;case r:e<u.rowStart&&(n=Dn(c,n-1,t),e=u.rowEnd,n<u.colStart&&(n=u.colEnd))}d={rowIndex:e,colIndex:n}}let p=n(d);if(!$.isRangeWithinRange(p,u)){const e=$.intersectRanges(p,u);e&&(p=e)}let g={rowStart:Dn(o,p.rowStart,i),colStart:Dn(c,p.colStart,s),rowEnd:Dn(o,p.rowEnd,r),colEnd:Dn(c,p.colEnd,l)};if(g.rowStart!==d.rowIndex||g.colStart!==d.colIndex){switch(t){case s:e.ranges[h].colStart===g.colStart&&e.ranges[h].colEnd===g.colEnd&&(d.rowIndex=g.rowEnd),d.colIndex=g.colEnd;break;case l:e.ranges[h].colStart===g.colStart&&e.ranges[h].colEnd===g.colEnd&&(d.rowIndex=g.rowStart),d.rowIndex===g.rowStart?d.colIndex=g.colStart+1:d.colIndex=g.colStart;break;case i:e.ranges[h].rowStart===g.rowStart&&e.ranges[h].rowEnd===g.rowEnd&&(d.colIndex=g.colEnd),d.rowIndex=g.rowEnd;break;case r:e.ranges[h].rowStart===g.rowStart&&e.ranges[h].rowEnd===g.rowEnd&&(d.colIndex=g.colStart),d.colIndex===g.colStart?d.rowIndex=g.rowStart+1:d.rowIndex=g.rowStart}return Wn({cell:d,ranges:e.ranges,rangeIndex:h},t,n,o,c,a??e)}return{ranges:e.ranges,cell:d,rangeIndex:h}},Hn=(e,t)=>{let n,o=0,c=0;return t.colStart<e.colStart?(n=l,o=e.colStart-t.colStart,c=t.colStart):t.colEnd>e.colEnd?(n=s,o=t.colEnd-e.colEnd,c=t.colEnd):t.rowStart<e.rowStart?(n=r,o=e.rowStart-t.rowStart,c=t.rowStart):t.rowEnd>e.rowEnd&&(n=i,o=t.rowEnd-e.rowEnd,c=t.rowEnd),{direction:n,amount:o,index:c}},Nn=(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),c=e+(r?2:-1),a=0;for(;(s-l)*i<=0;){if(r&&c-1>o+1||!r&&c+1<o)return a;l=s,s=n(c),c+=i,a++}return a},Un=(e,t,n,o,r)=>{const i={};let l=null,s=null;for(let c=0;c<=n.length&&n[c]<=r;c++){const r=n[c];if(r<o)continue;const a=l===r?s:t?e.getColOffset(r):e.getRowOffset(r),u=t?e.getColOffset(r+1):e.getRowOffset(r+1);l=r+1,s=u,i[r]=Object.freeze({offset:a,size:u-a,spanIndex:c})}return Object.freeze(i)},qn=(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}},Kn=(e,t,n)=>!!n&&(!(e<n.x||e>n.x+n.width)&&!(t<n.y||t>n.y+n.height)),Yn=(e,t=!0)=>`M ${Lt.boundPixel(e.left)} ${Lt.boundPixel(e.top)} L ${Lt.boundPixel(e.right,!0)} ${Lt.boundPixel(e.top)} L ${Lt.boundPixel(e.right,!0)} ${Lt.boundPixel(e.bottom,!0)} L ${Lt.boundPixel(e.left)} ${Lt.boundPixel(e.bottom,!0)} L ${Lt.boundPixel(e.left)} ${Lt.boundPixel(e.top)} ${t?"Z":""}`,Xn=t=>{const{linePoints:n,bounds:o,pathProps:r,style:i,...l}=t;return e.jsx("svg",{width:`${Lt.boundPixel(o.width,!0)}`,height:`${Lt.boundPixel(o.height,!0)}`,viewBox:`0 0 ${Lt.boundPixel(o.width,!0)} ${Lt.boundPixel(o.height,!0)}`,style:{position:"absolute",left:`${Lt.boundPixel(o.x)}px`,top:`${Lt.boundPixel(o.y)}px`,width:`${Lt.boundPixel(o.width,!0)}px`,height:`${Lt.boundPixel(o.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...i},...l,children:e.jsx("path",{d:`M ${Lt.boundPixel(n[0])} ${Lt.boundPixel(n[1])} L ${Lt.boundPixel(n[2])} ${Lt.boundPixel(n[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...r})})},Gn=t=>{const{x:n=0,y:o=0,width:r=0,height:i=0,fill:l,stroke:s,strokeWidth:c=0,strokeDasharray:a,strokeDashoffset:u,clipPath:d,pathBounds:h,pathProps:f,style:p,...g}=t,w=o,m=n,x=r,y=i;let b=null;if(l){let t=Yn({top:0,left:0,bottom:y,right:x});h&&(t=t+" "+Yn({top:h.y-w,left:h.x-m,bottom:h.height+h.y-w,right:h.width+h.x-m})),b=[e.jsx("path",{d:t,fill:l,stroke:"none",fillRule:"evenodd"},"fill")]}return e.jsxs("svg",{width:`${Lt.boundPixel(r,!0)}`,height:`${Lt.boundPixel(i,!0)}`,viewBox:`0 0 ${Lt.boundPixel(r,!0)} ${Lt.boundPixel(i,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${Lt.boundPixel(n)}px`,top:`${Lt.boundPixel(o)}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",...p},...g,children:[b,e.jsx("path",{d:Yn({top:0,left:0,right:x,bottom:y}),fill:"none",strokeDasharray:a,strokeDashoffset:u,stroke:s,vectorEffect:"non-scaling-stroke",strokeWidth:c,...f})]})},Zn=t=>{const{key:n,...o}=t;return e.jsx(Jn,{...o},n)},Jn=t.memo(n=>{const{stroke:o,fill:r,x:i=0,y:l=0,width:s=0,height:c=0,style:a,isAnimatedStroke:u,animatedStrokeProps:d,range:h,cell:f,...p}=n,g=u||!!d,w={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...d};let m=w.dashGap+w.dashLength;const x=w.speed*m,y=Sn().replaceAll(":",""),b=`${w.name}-${y}`;let v;return t.useEffect(()=>{if(!g)return;const e=`@keyframes ${b} {\n to {\n stroke-dashoffset: 0px;\n }\n }`,t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.head.appendChild(t);return t.sheet.insertRule(e,0),()=>{document.head.removeChild(t)}},[g]),g&&(v={strokeDasharray:`${w.dashLength}px ${w.dashGap}px`,strokeDashoffset:`${m}px`,animation:`${b} ${x}ms linear infinite`,willChange:"stroke-dashoffset"}),e.jsx(Gn,{x:i,y:l,width:s,height:c,stroke:o,fill:r,shapeRendering:"crispEdges",style:{...v,...a},...p})});function Qn(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Qn(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function eo(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Qn(e))&&(o&&(o+=" "),o+=t);return o}Jn.displayName="Selection";const to=t.memo(t.forwardRef((t,n)=>{const{x:o=0,y:r=0,borderWidth:i=1,size:l=6,borderStroke:s,corner:c,style:a,className:u,background:d,...h}=t;if(0===o||0===r)return null;let f=!0,p=!0,g=!0,w=!0;switch(c){case"tl":f=!1,p=!1;break;case"bl":f=!1,w=!1;break;case"br":g=!1,w=!1;break;case"tr":p=!1,g=!1}return e.jsx("div",{className:eo("fill-handle",u),style:{position:"absolute",left:o-(l+(f?i:0))/2,top:r-(l+(p?i:0))/2,width:l,height:l,borderLeft:f?`${i}px ${s}`:void 0,borderTop:p?`${i}px ${s}`:void 0,borderRight:g?`${i}px ${s}`:void 0,borderBottom:w?`${i}px ${s}`:void 0,background:d,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...a},tabIndex:-1,...h})}));to.displayName="FillHandle";var no=function(){},oo="undefined"!=typeof window,ro=oo?t.useLayoutEffect:t.useEffect,io={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const lo=oo&&void 0!==window.ResizeObserver?function(){var e=t.useState(null),n=e[0],o=e[1],r=t.useState(io),i=r[0],l=r[1],s=t.useMemo(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,o=t.y,r=t.width,i=t.height,s=t.top,c=t.left,a=t.bottom,u=t.right;l({x:n,y:o,width:r,height:i,top:s,left:c,bottom:a,right:u})}})},[]);return ro(function(){if(n)return s.observe(n),function(){s.disconnect()}},[n]),[o,i]}:function(){return[no,io]};function so(e,t){if("function"==typeof e)return e(t);e&&(e.current=t)}var co=parseInt(t.version.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const e=so(o,t),r="function"==typeof e;n.push(r?e:()=>so(o,null))}return()=>{for(const e of n)e()}}}:function(e){return t=>{for(const n of e)so(n,t)}};const ao=t.memo(t.forwardRef((n,r)=>{const{range:i,view:l,anchor:s,borderStroke:c="rgb(33, 115, 70)",background:a="white",borderWidth:u=1.5,size:d=22,style:h,className:f,selectionTouchPointerHandler:p,onTouchSelectStart:g,onTouchSelectEnd:w,currentTouchAnchor:m,scrollableElement:x,scrollableRoot:y=document.body,...b}=n,v=et(g,[g]),S=et(w,[w]),{bounds:E,coordsPivot:_,key:C}=t.useMemo(()=>{if(!i||!l)return null;let e=null,t=null;switch(s){case"tl":e={colIndex:i.colEnd,rowIndex:i.rowEnd},t={colIndex:i.colStart,rowIndex:i.rowStart};break;case"br":e={colIndex:i.colStart,rowIndex:i.rowStart},t={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"t":case"l":e={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"b":e={colIndex:i.colStart,rowIndex:i.rowStart};break;case"r":e={colIndex:i.colStart,rowIndex:i.rowEnd}}let n=l.getRangeCoordsBounds(t?{rowStart:t.rowIndex,colStart:t.colIndex,rowEnd:t.rowIndex,colEnd:t.colIndex}:i);const o=l.getBounds(),r=l.getViewportSize(),c=o.x,a=o.y,u=r.width,d=r.height;switch(s){case"tl":break;case"br":n.x=n.x+n.width,n.y=n.y+n.height;break;case"t":n.x=u/2-c;break;case"b":n.x=u/2-c,n.y=n.y+n.height;break;case"l":n.y=d/2-a;break;case"r":n.x=n.x+n.width,n.y=d/2-a}const h=l.toClipBounds(n,0);return!h||h.width<=0||h.height<=0||n.x<0||n.y<0||n.x>u||n.y>d?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:n,coordsAnchor:null,coordsPivot:e,key:"touchSelect-"+l.getAnchor()+"-"+s}},[i,l,s]),I=t.useRef(null),M=nn(t.useMemo(()=>{const e=e=>"t"===s||"b"===s?{...e,colIndex:void 0}:"l"===s||"r"===s?{...e,rowIndex:void 0}:e;return{processTouch:!0,consumeTouch:!0,onPointerDown:(t,n)=>{const o=e(l.getCellCoordsFromClient(t.clientX,t.clientY));return I.current={coordsPivot:_},v?.(s),p.onSelectionPointerDown(t,n,l,o,_,!1,!0)},onPointerMoveOrWait:(t,n,o)=>{const r=e(l.getCellCoordsFromClient(t.clientX,t.clientY));return p.onSelectionPointerMoveOrWait(t,n,o,l,r,I.current?.coordsPivot,!0,!0)},onPointerUp:(e,t,n)=>(I.current=null,S?.(s),p.onPointerUp(e,t,n))}},[p,i,l,s])),[R,{y:k,x:T}]=lo(),P=t.useRef(null),{getPortalContainer:O}=Vt(),[L,D]=t.useState(null);return t.useEffect(()=>{const t=P.current?.getBoundingClientRect();if(!t||!E)return void D(null);let n=0,i=0,l=x;for(;l;)n+=l.scrollLeft,i+=l.scrollTop,l=y&&l===y.parentElement?null:l.parentElement;D(o.createPortal(e.jsx("div",{className:eo("touch-select-handle",f),ref:r,style:{position:"absolute",left:n+(t?.x??0)-(d+u)/2,top:i+(t?.y??0)-(d+u)/2,width:d,height:d,borderWidth:`${u}px`,border:c,borderRadius:"50%",background:a,boxShadow:`0 0 0 1.5px ${a}`,cursor:"grab",pointerEvents:"all",opacity:m?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...h},tabIndex:-1,onPointerDown:M,...b}),y??O(),C))},[k,T,E?.x,E?.y,E?.width,E?.height,f,m,a,d,u,c,x]),E?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:co([R,P]),style:{position:"absolute",left:E.x,top:E.y,opacity:0}}),L]}):null}));ao.displayName="TouchSelectHandle";const uo=-10,ho=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),fo=Object.freeze({colIndex:0,rowIndex:0}),po=Object.freeze([]),go=e=>{if(e&&e.cell&&e.ranges&&e.rangeIndex>-1&&e.rangeIndex<=e.ranges.length)return e;const t={cell:null,ranges:e?.ranges??po};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=fo),$.isEqualSelectionCoords(t,e)?e:t},wo=(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(d)),!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(d)),e.scrollCellCoordsIntoView(t)},mo=()=>!1;function xo(e,t){if(!e)throw new Error("Invariant failed")}const yo={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},bo=Object.freeze({top:0,left:0}),vo=Object.freeze({bottom:-4,right:-4}),So=Object.freeze({horizontal:!0,vertical:!0}),Eo=[c,a,u,d],_o=3e3,Co={},Io=t.memo(t.forwardRef((n,o)=>{const{width:h,height:f,rowCount:p=1,columnCount:g=1,defaultRowHeight:w,defaultColumnWidth:m,getRowHeight:x,getColumnWidth:y,layout:b,onViewportScroll:v,onImmediateScroll:S,showGridLines:E=!0,gridLineColor:_="rgb(224, 224, 224)",gridLineRowsProps:C,gridLineColumnsProps:I,clipCells:M=!0,cursor:R,freezeLeft:k=0,freezeTop:T=0,freezeLeftProps:P,freezeTopProps:O,cellRenderer:L,onViewportChange:D,onFirstRender:z,overlayRenderer:j,overlayProps:A,overlays:B,overlaysProps:F,allowOverlaysOverflow:V=!1,stageProps:W,stageWrapper:H=null,hiddenRowsAt:N,hiddenColumnsAt:U,hiddenCellAt:q,getVisibleCells:K,zoom:Y=1,enableMouseWheel:X=!0,onWheelScroll:G,getCellCoordsAsRangeCoords:Z=$.cellToRange,scrollPoint:J=bo,style:Q={},...ee}=n;xo(L),xo(!n?.children);const te=et(S,[S]),ne=et(D,[D]),oe=et(v,[v]),re=et(G,[G]),ie=et(z,[z]),le=t.useRef(null),se=t.useRef(null),ce=t.useRef(null),[ue,de]=t.useReducer(e=>e+1,0),[he,fe]=t.useState({left:J?.left??0,top:J?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),pe=t.useRef(null),ge=t.useRef(he),{top:we,left:me,verticalScrollDirection:xe,horizontalScrollDirection:ye}=he,be=t.useRef(!1),ve=Mn({rowCount:p,columnCount:g,defaultRowHeight:w,defaultColumnWidth:m,getRowHeight:x,getColumnWidth:y}),Se=t.useRef(null),Ee=t.useMemo(()=>{const e=b||ve;return Se.current=null,{getColOffset:t=>e.getColOffset(t)*Y,getColIndex:t=>e.getColIndex(t/Y),getRowOffset:t=>e.getRowOffset(t)*Y,getRowIndex:t=>e.getRowIndex(t/Y)}},[ve,b,Y]),_e=(e,t,n)=>{const o=(t?.left??0)+0,r=(t?.top??0)+0;return{getColOffset:t=>e.getColOffset(t)-o,getColIndex:t=>e.getColIndex(t+o),getRowOffset:t=>e.getRowOffset(t)-r,getRowIndex:t=>e.getRowIndex(t+r)}},Ce=t.useCallback((e,t=!1)=>Nn(e,t,Ee.getRowOffset,t?0:p),[p,Ee?.getRowOffset]),Ie=et(N??Ce,[N]),Me=t.useCallback((e,t=!1)=>Nn(e,t,Ee.getColOffset,t?g:0),[g,Ee?.getColOffset]),Re=et(U??Me,[U]),ke=t.useMemo(()=>Math.min(h??800,Ee.getColOffset(g)),[Ee.getColOffset,g,h]),Te=t.useMemo(()=>Math.min(f??600,Ee.getRowOffset(p)),[Ee.getRowOffset,p,f]),Pe=t.useCallback(e=>{ae.canUseDOM&&setTimeout(()=>{le.current?.focus({preventScroll:!0,...e})},0)},[]),Oe=t.useCallback(e=>le.current?.contains(e)||se.current?.contains(e),[]);t.useEffect(()=>{be.current&&(pe.current&&pe.current.left!==ge.current?.left&&pe.current.top!==ge.current?.top||(pe.current=null,oe?.({left:me,top:we})))},[me,we]);const Le=et(()=>({top:we,left:me}),[we,me]),De=t.useMemo(()=>{const e=[];let t=0,n=0;"number"==typeof T?t=T:(t=T.index??0,n=(T.scrollOffset??0)*Y);const o=n,r=Ee.getRowOffset(t),i=r-o;if(t>0){const l=_e(Ee,{top:n+Ee.getRowOffset(0)}),s=Ee.getRowIndex(o),c=Ee.getRowIndex(r-1);let a;e[1]={minIndex:s,maxIndex:c,minCoord:0,maxCoord:t-1,minBounds:0,maxBounds:i,visibleIndices:()=>a||(a=Object.freeze(zn(Ie,s,c)),a),layout:l,maxVirtualBounds:r,scrollOffset:n,freezeOffset:n}}const l=Math.max(0,Te-i),s=_e(Ee,{top:we+i}),c=s.getRowIndex(0),a=s.getRowIndex(l);let u;return e[0]={minIndex:c,maxIndex:a,minCoord:t,maxCoord:p-1,minBounds:i,maxBounds:l,visibleIndices:()=>u||(u=Object.freeze(zn(Ie,c,a)),u),layout:s,maxVirtualBounds:Ee.getRowOffset(p),scrollOffset:we,freezeOffset:(t>0?Ee.getRowOffset(t):0)-n},e},[Ee.getRowIndex,Ee.getRowOffset,Ie,Te,p,T,we,Y]),ze=t.useMemo(()=>{const e=[];let t=0,n=0;"number"==typeof k?t=k:(t=k.index??0,n=(k.scrollOffset??0)*Y);const o=n,r=Ee.getColOffset(t),i=r-o;if(t>0){const l=_e(Ee,{left:n+Ee.getColOffset(0)}),s=Ee.getColIndex(o),c=Ee.getColIndex(r-1);let a;e[1]={minIndex:s,maxIndex:c,minCoord:0,maxCoord:t-1,minBounds:0,maxBounds:i,visibleIndices:()=>a||(a=Object.freeze(zn(Re,s,c)),a),layout:l,maxVirtualBounds:r,scrollOffset:n,freezeOffset:n}}const l=Math.max(0,ke-i),s=_e(Ee,{left:me+i}),c=s.getColIndex(0),a=s.getColIndex(l);let u;return e[0]={minIndex:c,maxIndex:a,minCoord:t,maxCoord:g-1,minBounds:i,maxBounds:l,visibleIndices:()=>u||(u=Object.freeze(zn(Re,c,a)),u),layout:s,maxVirtualBounds:Ee.getColOffset(g),scrollOffset:me,freezeOffset:(t>0?Ee.getColOffset(t):0)-n},e},[Ee.getColIndex,Ee.getColOffset,Re,ke,g,k,me,Y]),je=t.useRef({}),Ae=t.useRef([]),$e=t.useMemo(()=>{let e={};const t=(t,n,o,r,i)=>{const l={vertical:r?.vertical||!1,horizontal:r?.horizontal||!1};if(t>=ze.length||n>=De.length)return null;const s={rowStart:De[n].minIndex,colStart:ze[t].minIndex,rowEnd:De[n].maxIndex,colEnd:ze[t].maxIndex};if(s.rowStart>s.rowEnd||s.colStart>s.colEnd)return null;const c={getColIndex:e=>ze[t].layout.getColIndex(e),getColOffset:e=>ze[t].layout.getColOffset(e),getRowIndex:e=>De[n].layout.getRowIndex(e),getRowOffset:e=>De[n].layout.getRowOffset(e)},a=Object.freeze({left:i?.left??0,top:i?.top??0,right:i?.right??0,bottom:i?.bottom??0}),u=Object.freeze({x:ze[t].minBounds,y:De[n].minBounds,width:ze[t].maxBounds,height:De[n].maxBounds}),d=(e,t)=>qn(c,e??s,t),h={width:ze[t].maxVirtualBounds,height:De[n].maxVirtualBounds},f={left:ze[t].scrollOffset,top:De[n].scrollOffset},p={left:ze[t].freezeOffset,top:De[n].freezeOffset},g={width:ke,height:Te};let w=null,m=null;const x=(p.top+(r.vertical?f.top:0))/Y,y=(p.left+(r.horizontal?f.left:0))/Y;return{getStage:()=>le.current??null,getVisibleRangeCoords:()=>s,toClipBounds:(e,t)=>{let n,o=0;return void 0===t||"number"==typeof t?(n=d(s),o=t):n=t,((e,t,n=0)=>{if(e.x>t.width||e.y>t.height)return null;const o={left:e.x,top:e.y,bottom:e.height+e.y,right:e.width+e.x},r={left:t.x+n,top:t.y+n,bottom:t.height-2*n+t.y,right:t.width-2*n+t.x},i={left:Math.max(o.left,r.left),top:Math.max(o.top,r.top),bottom:Math.min(o.bottom,r.bottom),right:Math.min(o.right,r.right)},l={x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top};return l.height<0||l.width<0?null:l})(e??{x:0,y:0,width:u.width,height:u.height},n,o)},toViewBounds:e=>0===y&&0===x&&1===Y?e:{x:(e.x-y)*Y,y:(e.y-x)*Y,width:e.width*Y,height:e.height*Y},toAbsoluteBounds:e=>0===y&&0===x&&1===Y?e:{x:e.x/Y+y,y:e.y/Y+x,width:e.width/Y,height:e.height/Y},getRelativePointFromClient:(e,t)=>{const n=Ne(e,t);return{x:n.x-u.x,y:n.y-u.y}},getLayout:()=>c,getCellCoordsAsRangeCoords:Z,getVisibleColumns:()=>ze[t].visibleIndices(),getVisibleRows:()=>De[n].visibleIndices(),getVisibleColumnOffsets:()=>(w||(w=Un(ze[t].layout,!0,ze[t].visibleIndices(),s.colStart,s.colEnd)),w),getVisibleRowOffsets:()=>(m||(m=Un(De[n].layout,!1,De[n].visibleIndices(),s.rowStart,s.rowEnd)),m),getTotalRangeCoords:()=>({colStart:ze[t].minCoord,colEnd:ze[t].maxCoord,rowStart:De[n].minCoord,rowEnd:De[n].maxCoord}),getRangeCoordsBounds:d,scrollCellCoordsIntoView:(e,t)=>tt(e,t,o),getCellCoordsFromClient:(e,t,n=!1)=>{const o=Ne(e,t);if(!o)return null;const r=c.getColIndex(o.x-u.x),i={rowIndex:c.getRowIndex(o.y-u.y),colIndex:r};if(n)return i;const l=Z(i);return{rowIndex:l.rowStart,colIndex:l.colStart}},getZoom:()=>Y,getAnchor:()=>o,getBounds:()=>u,getInsets:()=>a,getTotalSize:()=>h,getViewportSize:()=>g,getScrollTopLeft:()=>f,getFreezeTopLeft:()=>p,getScrollOrientation:()=>l,allViews:()=>e}};let n=e[d]=t(0,0,d,So,vo);return n&&(e[d]=n),n=t(0,1,a,{horizontal:!0}),n&&(e[a]=n),n=t(1,0,u,{vertical:!0}),n&&(e[u]=n),n=t(1,1,c,{}),n&&(e[c]=n),je.current=null,e=Object.freeze(e)},[De,ze,Z]),Be=Object.keys($e),Fe=ze[0]?.maxVirtualBounds??0,Ve=De[0]?.maxVirtualBounds??0,We=t.useMemo(()=>({left:ze[1]?ze[1].layout.getColOffset(ze[1].maxIndex+1):0,top:De[1]?De[1].layout.getRowOffset(De[1].maxIndex+1):0}),[$e]);t.useEffect(()=>{if(Ae.current.length>0){for(let e=0;e<Ae.current.length;e++)Ae.current[e]();Ae.current=[]}},[$e]);const He=et(()=>({containerWidth:ke,containerHeight:Te,totalWidth:Fe,totalHeight:Ve}),[ke,Te,Ee]);t.useEffect(()=>{!pe.current&&be.current&&ne({top:we,left:me,width:ke,height:Te,totalWidth:Fe,totalHeight:Ve})},[we,me,Fe,Ve]),t.useEffect(()=>{be.current&&ne({top:we,left:me,width:ke,height:Te,totalWidth:Fe,totalHeight:Ve})},[ke,Te]);const Ne=t.useCallback((e,t)=>{xo("number"==typeof e&&"number"==typeof t);const n=le.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),Ue=et(e=>$e[e]||null,[$e]),qe=et((e,t)=>{if(1===Object.keys($e).length)return $e[d];const n=Ne(e,t);if(!n)return null;const{x:o,y:r}=n;let i=null;const l=Eo;for(let e=0;!i&&e<l.length;e++){const t=$e[l[e]];t&&Kn(o,r,t.getBounds())&&(i=t)}return i||(i=$e[d]),i},[$e,Z]),Ke=et(()=>$e[d].getVisibleRangeCoords(),[$e[d]]),Ye=t.useRef(null),Xe=t.useCallback(()=>{null!==Ye.current&&ae.cancelTimeout(Ye.current),Ye.current=ae.requestTimeout(Ge,150)},[]),Ge=t.useCallback(()=>{Ye.current=null,fe(e=>{const t={...e,verticalScrollDirection:null,horizontalScrollDirection:null};return ge.current=t,t})},[]),Ze=et(e=>{const t=e?.left??e?.[0],n=e?.top??e?.[1],o=void 0!==t?Math.min(Fe-ke,Math.max(ze?.[1]?.scrollOffset??0,t)):ge.current.left,c=void 0!==n?Math.min(Ve-Te,Math.max(De?.[1]?.scrollOffset??0,n)):ge.current.top;if(ge.current.left===o&&ge.current.top===c)return;let a=null,u=null;ge.current.left>o?a=l:ge.current.left<o&&(a=s),ge.current.top>c?u=r:ge.current.top<c&&(u=i),ae.throttle(()=>{fe(e=>{const t={...e,left:o,top:c,horizontalScrollDirection:a,verticalScrollDirection:u};return ge.current=t,t})},17)(),pe.current?.top===c&&pe.current?.left===o||(pe.current={left:o,top:c},te({left:o,top:c}),ne({left:o,top:c,width:ke,height:Te,totalWidth:Fe,totalHeight:Ve})),Xe()},[Fe,Ve,De,ze]);t.useEffect(()=>{pe.current||Ze({left:me,top:we})},[Fe,ke,Ve,Te]),t.useLayoutEffect(()=>{pe.current={left:J?.left,top:J?.top},Ze(pe.current)},[J?.left,J?.top]);const Je=et(e=>{const t=e?.left??e?.[0],n=e?.top??e?.[1],o=e?.behavior??"auto",r={left:ge.current.left+(t??0),top:ge.current.top+(n??0)};o&&(r.behavior=o),Ze(r)},[Fe,ke,Ve,Te]),Qe=t.useCallback(e=>{let t=null;if(Object.keys($e).length>1){const n=Eo;for(let o=0;!t&&o<n.length;o++){const r=$e[n[o]];r&&$.isCellWithinRange(e,r.getVisibleRangeCoords())&&(t=r)}}return t||(t=$e[d]),t},[$e]),tt=et((e,t={inline:"nearest",block:"nearest"},n=null)=>{const o={rowIndex:0,colIndex:0,...e};let r=null;if(null!==n){if(r=$e[n],null===r)return new Promise((e,t)=>{t("Invalid view")})}else r=Qe(o);const i=Z(o),l=r.getLayout(),s=l.getColOffset(i.colStart),c=l.getRowOffset(i.rowStart),a=l.getColOffset(i.colEnd+1),u=l.getRowOffset(i.rowEnd+1),d=r.getBounds(),h=r.getTotalSize(),f=r.getScrollTopLeft(),p=((e,t,n=!0)=>(n=!0===n?{block:"start",inline:"end"}:!1===n?{block:"end",inline:"end"}:{block:"end",inline:"end",...n},{left:Fn(n.inline,e.x,e.x+e.width,t.left,t.left+t.width,t.totalWidth),top:Fn(n.block,e.y,e.y+e.height,t.top,t.top+t.height,t.totalHeight)}))({x:s+f.left,y:c+f.top,width:a-s,height:u-c},{left:f.left,top:f.top,width:d.width,height:d.height,totalWidth:h.width,totalHeight:h.height},t),g={...p};g.left>me?g.left+=20:g.left<me&&(g.left-=0),g.top>we?g.top+=20:g.top<we&&(g.top-=0);const w=r.getScrollOrientation();return w.horizontal&&void 0!==e.colIndex||delete g.left,w.vertical&&void 0!==e.rowIndex||delete g.top,new Promise((e,t)=>{try{Ze(g),e(g)}catch(e){t(e)}})},[Fe,Ve,$e,Z]),nt=et(e=>{const t=e.shiftKey;e.preventDefault();const{deltaX:n,deltaY:o,deltaMode:r}=e;if(ce.current)return;let i=re?.(e);if(!1===i)return;let l=t?o:n,s=o;const c=t||Math.abs(l)>Math.abs(s);1===r&&(s*=0),ce.current=window.requestAnimationFrame(()=>{ce.current=null,Je(c?{left:l}:{top:s})})},[Fe,ke,Ve,Te,re]),ot=t.useCallback((e=null)=>{Se.current=null,je.current=null,de()},[]);t.useLayoutEffect(()=>{ot()},[L]);const rt=zt(o,()=>({stage:le.current,focus:Pe,contains:Oe,invalidate:ot,scrollTo:Ze,scrollBy:Je,scrollCellCoordsIntoView:tt,getScrollPosition:Le,getDimensions:He,getViewport:Ke,handleWheel:nt,rowCount:p,columnCount:g,getLayout:()=>Ee,getRelativePointFromClient:Ne,getViewFromClient:qe,getViewFromCellCoords:Qe,getViewFromLocation:Ue,onViewChangeOnce:e=>{Ae.current.push(e)}}),[p,g,$e]);t.useEffect(()=>(X&&rt.current?.addEventListener("wheel",nt,{passive:!1}),be.current=!0,pe.current=null,()=>{rt.current?.removeEventListener("wheel",nt)}),[X]);const it=t.useRef([]),lt=(t,n)=>{if(!t||!j)return;it.current=[];n.push(((t,o)=>{const r=`view:${t.getAnchor()}:overlay:${n.length}`,i=j?.({key:r,view:t},e=>it.current[o]=e);if(!i)return null;const l=t.getBounds();return e.jsx("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${l.width}px`,height:`${l.height}px`,overflow:"hidden"},children:i},`overlay-${t.getAnchor()}-${o}`)})(t,0))},st=t.useMemo(()=>{const e={},t=Object.keys($e);for(let n=0;n<t.length;n++){const o=t[n],r=[];lt($e[o],r),e[o]={overlays:r}}return e},[ue,j,p,g,De,ze]),ct=(t,n,o,r,i,l,s)=>{if(!t)return;const c=t.getVisibleColumns(),a=t.getVisibleRows();if(0===c.length||0===a.length)return;let u=null;if(K)u=K(t);else{u=[];for(let e=0;e<a.length;e++)for(let t=0;t<c.length;t++){const n={rowIndex:a[e],colIndex:c[t]};if(q?.(n))continue;const o={coords:n,range:Z(n)};u.push(o)}}const d=t.getVisibleColumnOffsets(),h=t.getVisibleRowOffsets(),f=t.getScrollTopLeft(),p=t.getFreezeTopLeft(),g=f.left+p.left,w=f.top+p.top,m=Math.trunc(g/_o),x=Math.trunc(w/_o),y={},b=(e,t,n,o,r)=>{const i=`view:${e.getAnchor()}:cell:${Bn(t.rowIndex,t.colIndex)}`,c=o.x,a=o.y,u=Math.trunc((g+c)/_o)-m,d=Math.trunc((w+a)/_o)-x;y[d]||(y[d]={});let h=y[d][u];h||(h=y[d][u]=[]);let f=l?.get(i);if(!f){const l=(g+c)%_o,s=(w+a)%_o;f=L({key:i,coords:t,bounds:o,zoom:Y,range:n,view:e,value:r,style:{left:Lt.boundPixel(l),top:Lt.boundPixel(s),width:Lt.boundPixel(o.width,!0),height:Lt.boundPixel(o.height,!0)}})}s?.set(i,f),h.push(f)};for(let e=0;u&&e<u.length;e++){const n=u[e],l=n?.coords??n;if(!l)continue;const s=n?.range??{rowStart:l.rowIndex,colStart:l.colIndex,rowEnd:l.rowIndex,colEnd:l.colIndex},c=t.getVisibleRangeCoords();if(!$.isRangesIntersect(s,c)&&!$.isRangeWithinRange(s,c))continue;const a=s&&!$.isSingleCell(s);if(!a&&q?.(l))continue;const f=l.rowIndex,p=l.colIndex,g=h[f],w=d[p];let m=null;g&&w&&(m={x:w.offset,y:g.offset,width:w.size,height:g.size});const x=Bn(s.rowStart,s.colStart);if(a){if(i.has(x))continue;i.add(x),s.rowEnd-s.rowStart>0&&o.push(s),s.colEnd-s.colStart>0&&r.push(s)}if(a&&(m=qn(t.getLayout(),s)),!m){console.warn("no bounds for cell",x);continue}const y=n?.value;b(t,l,s,m,y)}const v=g%_o,S=w%_o,E=Object.keys(y);for(let o=0;o<E.length;o++){const r=y[E[o]];if(!r)continue;const i=Object.keys(r);for(let l=0;l<i.length;l++){const s=r[i[l]];if(!s)continue;const c=parseInt(E[o]),a=parseInt(i[l]),u=c+x,d=a+m,h=`view:${t.getAnchor()}:segment:${d}:${u}`;n.push(e.jsx("div",{className:"cell-container",style:{transform:`translate(${Lt.boundPixel(a*_o-v,!0)}px, ${Lt.boundPixel(c*_o-S,!0)}px)`,willChange:"transform"},children:s},h))}}},at=t.useMemo(()=>{const e=Se.current,t=new Map,n={},o=Object.keys($e);for(let r=0;r<o.length;r++){const i=o[r],l=[],s=[],c=[];ct($e[i],c,l,s,new Set,e,t),n[i]={cells:c,rangesH:l,rangesV:s}}return Se.current=t,n},[ue,p,g,De,ze,E,Q,M,q,K,Z]),ut=(n,o,r,i,l)=>{if(n)if(o){const e=`view:${n.getAnchor()}:hl:`,o=n.getVisibleRows();if(!o||0===o.length)return;const s=0,c=n.getBounds().width;let a=[];const u=l.sort($.rowFirstRangeComparator),d=n.getVisibleRangeCoords();for(let l=0;l<o.length&&o[l]<=d.rowEnd;l++){const h=o[l];if(h<d.rowStart)continue;let f=!1;for(;u.length>0&&u[0].rowStart<=h;){const e=u.shift();e.rowEnd>h&&(a.push(e),f=!0)}f&&(a=a.sort($.columnFirstRangeComparator));const p=n.getLayout(),g=p.getRowOffset(h+1);let w=s;for(let n=0;n<a.length+1;n++){let o=w,l=c;const s=a[n];n<a.length&&(l=Math.min(c,p.getColOffset(s.colStart)),w=Math.min(c,p.getColOffset(s.colEnd+1))),i.push(t.createElement("path",{d:`M ${Lt.boundPixel(o)} ${Lt.boundPixel(g,!1,r)} L ${Lt.boundPixel(l)} ${Lt.boundPixel(g,!1,r)}`,stroke:_,strokeWidth:1,vectorEffect:"non-scaling-stroke",...C,key:e+h+":"+n}))}for(let e=a.length-1;e>=0;e--)a[e].rowEnd<=o[l+1]&&a.splice(e,1)}}else{const t=`view:${n.getAnchor()}:vl:`,o=n.getVisibleColumns();if(!o||0===o.length)return;const s=0,c=n.getBounds().height;let a=[];const u=l.sort($.columnFirstRangeComparator),d=n.getVisibleRangeCoords();for(let l=0;l<o.length&&o[l]<=d.colEnd;l++){const h=o[l];if(h<d.colStart)continue;let f=!1;for(;u.length>0&&u[0].colStart<=h;){const e=u.shift();e.colEnd>h&&(a.push(e),f=!0)}f&&(a=a.sort($.rowFirstRangeComparator));const p=n.getLayout(),g=p.getColOffset(h+1);let w=s;for(let n=0;n<a.length+1;n++){let o=w,l=c;const s=a[n];n<a.length&&(l=Math.min(c,p.getRowOffset(s.rowStart)),w=Math.min(c,p.getRowOffset(s.rowEnd+1)));let u=_;i.push(e.jsx("path",{d:`M ${Lt.boundPixel(g,!1,r)} ${Lt.boundPixel(o)} L ${Lt.boundPixel(g,!1,r)} ${Lt.boundPixel(l)}`,stroke:u,strokeWidth:1,vectorEffect:"non-scaling-stroke",...I},t+h+":"+n))}for(let e=a.length-1;e>=0;e--)a[e].colEnd<=o[l+1]&&a.splice(e,1)}}},dt=t=>{if(!at)return;const n={};for(let o=0;o<Be.length;o++){const r=Be[o],i=$e[r],l=[];ut(i,t,0,l,t?at[r].rangesH:at[r].rangesV);const s=i.getRangeCoordsBounds(),c=Math.ceil(s.width),a=Math.ceil(s.height);n[r]=e.jsx("svg",{width:`${c}`,height:`${a}`,viewBox:`0 0 ${c} ${a}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:l})}return n},ht=t.useMemo(()=>!0===E||!0===E?.horizontal?dt(!0):null,[ue,E,De,T,k,_,C,p,g,ke,Fe,at]),ft=t.useMemo(()=>!0===E||!0===E?.vertical?dt(!1):null,[ue,E,ze,T,k,_,I,p,g,Te,Ve,at]),pt=t.useMemo(()=>0===We.left?null:e.jsx(Xn,{linePoints:[0,0,0,Te+1],bounds:{x:We.left,y:0,width:1,height:Te+1},...P}),[ue,We.left,Te,P]),gt=t.useMemo(()=>0===We.top?null:e.jsx(Xn,{linePoints:[0,0,ke+1,0],bounds:{x:0,y:We.top,width:ke+1,height:1},...O}),[ue,We.top,ke,O]),wt=t.useMemo(()=>{const t=[],n=t=>{if(!t||!$e[t])return;const n=$e[t].getBounds();return e.jsxs("div",{style:{position:"absolute",pointerEvents:"none",left:n.x,top:n.y,width:n.width,height:n.height,clip:`rect(0, ${n.width+1}px, ${n.height+1}px, 0)`},className:`view view-${t}`,children:[ht?.[t],ft?.[t],at?.[t].cells]},`view:${t}`)};for(let e=0;e<Be.length;e++)t.push(n(Be[e]));return e.jsx(e.Fragment,{children:t})},[$e,ht,ft,at]),mt=t.useMemo(()=>{if(!o)return;const t=(e,t,n,o)=>{if(!o||0===o.length)return;const r=[];for(let i=0;i<o.length;i++){const l=o[i];let s=e?.get(l);s!==Co&&(s=l(n)??Co),t.set(l,s),s&&s!==Co&&r.push(s)}return r},n=(n,o,r)=>{if(!r)return;const i=r.getBounds(),l=r.getInsets(),s=r.getAnchor();return e.jsxs("div",{className:eo("view",`view-${s}`,yo.view),style:{position:"absolute",pointerEvents:"none",left:i.x-l.left,top:i.y-l.top,width:i.width-(l.left+l.right),height:i.height-(l.top+l.bottom),clipPath:V?"inset(-2px)":"inset(0px)"},children:[t(n,o,r,B),st?.[s].overlays]},`view:${s}`)},r=je.current,i={},l=[],s=Object.keys($e);for(let e=0;e<s.length;e++){const t=s[e],o=r?.[t],c=i[t]=new Map;l.push(n(o,c,$e[t]))}return je.current=i,l},[ue,$e,V,B]),xt=t.useMemo(()=>{const{style:t,...n}=W??{};return e.jsx("div",{style:{width:ke,height:Te,...t},className:"sheetxl-stage",tabIndex:0,ref:le,...n,...ee,children:H?H(wt):wt})},[ke,Te,wt,W,H]),yt=t.useRef(!1);return t.useEffect(()=>{!yt.current&&at&&(yt.current=!0,ie?.(rt.current))},[at]),e.jsxs("div",{className:eo("sheetxl-grid",yo["sheetxl-grid"]),style:{overflow:"visible",cursor:R,maxWidth:ke,maxHeight:Te,width:ke,height:Te,...Q},ref:rt,children:[xt,e.jsxs("div",{className:eo("sheetxl-overlays"),ref:se,...F,children:[mt,pt,gt]})]})}));Io.displayName="BaseGrid";const Mo=t.memo(t.forwardRef((t,n)=>{const{width:o,height:r,style:i={},className:l,...s}=t,[c,{width:a,height:u}]=lo(),d=o??a,h=r??u;return e.jsx("div",{className:l,style:{...i},children:e.jsx("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:c,children:e.jsx(Io,{ref:n,width:d,height:h,...s})})})}));Mo.displayName="Grid";const Ro=t.memo(t.forwardRef((n,o)=>{const{showVerticalScrollbar:r,showHorizontalScrollbar:i,createHorizontalScrollbar:l,createVerticalScrollbar:s,createScrollCorner:c,viewport:a,onScrollViewport:u,style:d={},className:h,onScroll:f,...p}=n,[g,w]=t.useState(null),m=t.useRef(null),x=t.useRef(null);xo(!a),t.useImperativeHandle(o,()=>x.current&&m.current?Object.assign(x.current,m.current):null);const y=t.useCallback(e=>{x.current?.scrollTo(e),u?.(e)},[]);return e.jsx($t,{className:h,style:d,ref:m,showVerticalScrollbar:r,showHorizontalScrollbar:i,createHorizontalScrollbar:l,createVerticalScrollbar:s,createScrollCorner:c,viewport:g,onScrollViewport:y,children:e.jsx(Mo,{style:{width:"100%",height:"100%"},...p,onViewportChange:e=>w(e),ref:x})})}));Ro.displayName="ScrollableGrid";const ko=()=>!1,To=t.memo(n=>{const{index:o,value:r,zoom:i,zoomScale:l=100,headerText:s=e=>`${e}`,headerStyle:c,headerStyleSelect:a=c,headerStyleSelectAll:u=a,headerStyleHover:d=u,verticalPadding:h=0,horizontalPadding:f=0,isSelected:p=ko,isSelectedAll:g=ko,coords:w,bounds:m,range:b,orientation:v,view:S,style:E,..._}=n,C=l/100,I=t.useRef(null),[M,R]=t.useState(!1),k=p?.(o)||!1,T=g?.(o)||!1?u:k?a:c;let P=T;if(M){let e=d;"function"==typeof d&&(e=d(T)),P=ae.mergeContentful(T,e)}return e.jsx("div",{ref:I,style:{background:P.fill,color:P.text?.fill,fontFamily:P.text?.fontFamily??c.text?.fontFamily,fontSize:96*(P.text?.fontSize??11)/72*C,fontStyle:P.text?.fontStyle,fontWeight:P.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${C}px`,...E,left:E.left-(v===x?1:0),top:E.top-(v===y?1:0),width:E.width+1,height:E.height+1,overflow:"hidden"},..._,onMouseMove:e=>{"touch"!==Lt.detectIt().primaryInput&&0===e.buttons&&R(!0)},onMouseOut:e=>{R(!1)},children:s(o)})});To.displayName="HeaderRenderer";const Po="ew-resize",Oo="ns-resize",Lo=t.memo(t.forwardRef((t,n)=>{const{orientation:o,view:r,index:i,className:l,style:s,disabled:c=!1,disabledResize:a=!1,isNextHidden:u,isHidden:d,isSelected:h,isSelectedAll:f,showTouchDivider:p,headerStyle:g,headerStyleSelect:w,headerStyleSelectAll:m,headerStyleHover:y,bounds:b,onPointerDown:v,onAutoFit:S,...E}=t,_=o===x;let C=g;h&&w&&(C=w),f&&m&&(C=m);const I="touch"===Lt.detectIt().primaryInput;let M=_?14:8,R=M/2,k=0;u&&(k=-2),d&&(k=2),d&&(M=M/2+k,R=2*k);let T=C.dividerStrokeFill??C.strokeFill;return!(h||f)&&0===k&&(T=`linear-gradient(${_?180:90}deg, ${C.fill}, ${T} 55%, ${T} 100%)`),e.jsxs("div",{className:eo("header-divider",{disabled:c},l,`index-${i}`),ref:n,onPointerDown:I?void 0:v,onDoubleClick:I?void 0:()=>S?.(),style:{top:(_?0:-M/2+(k-1))+"px",left:(_?-M/2+(k-1):0)+"px",width:_?M:"calc(100% + 1px)",height:_?"calc(100% + 1px)":M,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:c||a||I?void 0:_?Po:Oo,...s},...E,children:[e.jsx("div",{style:{position:"relative",top:`${_?0:R}px`,left:`${_?R:0}px`,width:_?1:"100%",height:_?"100%":1,background:T},onDoubleClick:()=>S?.()}),p&&I?e.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:C.fill,border:`${m.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${g.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:v,children:e.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(w.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]})})),Do=(t,n)=>e.jsx(Lo,{...t,ref:n}),zo=t.memo(t.forwardRef((n,r)=>{const{orientation:i,view:l,index:s,disabled:c=!1,disabledResize:a=!1,resizeThreshold:u=1,dividerRenderer:d=Do,onDividerMouseDown:h,onDividerResizeStart:f,onDividerResize:p,onDividerResizeEnd:g,onDividerMouseUp:w,onDividerAutoFit:m,onPointerDown:y,...b}=n,v=et(y,[y]),S=et(m,[m]),E=i===x;let _=E?l.getVisibleColumns():l.getVisibleRows(),C=null;_.length>0&&(E?C=l.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:_[0],colEnd:_[_.length-1]}):l.getRangeCoordsBounds({rowStart:_[0],rowEnd:_[_.length-1],colStart:0,colEnd:0}),C=l.toClipBounds(C,uo));const I=t.useRef(null),[M,R]=t.useState(null),k=(e,t)=>E?e.clientX-t.clientX:e.clientY-t.clientY,T=l.getLayout(),P=E?T.getColOffset(s+1):T.getRowOffset(s+1),O=nn({processTouch:!0,onPointerDown:e=>{if(v?.(e),!c&&!a){const e=E?T.getColOffset(s):T.getRowOffset(s),t=P-e;I.current={isResizing:!1,startSize:t,index:s,view:l,orientation:i,onDividerMouseDown:h,onDividerResizeStart:f,onDividerResize:p,onDividerResizeEnd:g,onDividerMouseUp:w},R(I.current),h?.(s,t)}e.stopPropagation(),e.preventDefault()},onPointerUp:(e,t,n)=>{if(!I.current)return;I.current.isResizing&&I.current.onDividerResizeEnd?.(I.current.index,Math.max(0,I.current.startSize+k(e,n)),I.current.startSize);const o=I.current;I.current=null,R(I.current),o.onDividerMouseUp?.(o.index)},onPointerMoveOrWait:(e,t,n)=>{if(!I.current)return;const o=k(e,n);I.current.isResizing?I.current.onDividerResize?.(I.current.index,Math.max(0,I.current.startSize+o),I.current.startSize):Math.abs(o)>Math.max(1,u)&&(I.current={...I.current,isResizing:!0},R(I.current),I.current.onDividerResizeStart?.(I.current.index,Math.max(0,I.current.startSize+o))),e.stopPropagation(),e.preventDefault()}}),L=et(()=>{S?.(s)},[s]);if(!C)return;const D=d({bounds:C,orientation:i,view:l,index:s,disabled:c,disabledResize:a,onAutoFit:L,onPointerDown:O,...b},r);if(!D)return;const{getPortalContainer:z}=Vt();let j=null;return M&&M.isResizing&&M.index===s&&(j=o.createPortal(e.jsx("div",{style:{position:"absolute",cursor:E?Po:Oo,left:0,top:0,width:"100%",height:"100%"}}),z(),"divider:"+s)),e.jsxs(e.Fragment,{children:[j,e.jsx("div",{className:eo("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${E?C.y:P}px`,left:`${E?P:C.x}px`,width:(E?0:C.width-1)+"px",height:(E?C.height-1:0)+"px",display:"flex"},tabIndex:-1,children:D})]})}));class jo{naturalDimensions(e,t={}){const n=document.createElement("div");let o=t?.lineHeight??"1";!t?.lineHeight&&t.paintableText?.fontSize&&(o=Math.ceil(1.2*t.paintableText.fontSize)+"px");const r=document.createElement("div");r.style.visibility="hidden",r.style.position="absolute",r.style.textRendering="geometricprecision",r.style.display="inline-grid",r.style.overflowWrap="break-word",r.style.maxWidth=t.maxWidth?t.maxWidth+"px":"100%",r.style.lineHeight=o,r.style.letterSpacing=(t.paintableText?.letterSpacing??0)+"px",r.style.fontSize=t.paintableText?.fontSize?t.paintableText.fontSize+"px":"unset",r.style.fontFamily=t.paintableText?.fontSize?t.paintableText.fontFamily:"unset",r.style.fontWeight=t.paintableText?.fontWeight?""+t.paintableText.fontWeight:"400",r.style.fontStyle=t.paintableText?.fontStyle?t.paintableText.fontStyle:"normal",r.style.whiteSpace="wrap"===t.paintableText?.wrap?"break-spaces":"pre",n.appendChild(r);const i=e.split("\n");for(let e=0;e<i.length;e++){let t=document.createElement("span");r.appendChild(t),t.textContent=i[e]}0!==i.length&&0!==i[i.length-1].length||r.appendChild(document.createElement("br")),document.body.appendChild(r);let l=r.getBoundingClientRect();return r.remove(),{width:l.width,height:l.height,maxLineHeight:1.2*(t.paintableText?.fontSize||1056/72)}}}const Ao=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),$o=Ao(),Bo=t.memo(t.forwardRef((n,o)=>{const{editState:c=$o,defaultTextStyle:a,onStartEdit:u,onChangeEdit:d,onSubmitEdit:h,onCancelEdit:f,onDoneEdit:p,containerBounds:g,setNaturalDimensions:w,onNavigate:m,textProperties:x,style:y,autoFocus:b,...v}=n,S=t.useRef(null),{width:E=0}=g??{},[_,C]=t.useState(()=>c);t.useEffect(()=>{C(c)},[c]);const I=x?.align||"left",M=x?.vAlign||"middle",R=x?.fill||"#040404",k=x?.wrap||"wrap",T=x?.fontFamily||"Calibri",P=x?.fontSize||11,O=x?.fontWeight||400,L=x?.fontStyle||"normal",D=_.dirty??_.clean??"";let z=2;const j=96*P/72,A=1.2*j;"right"===M&&(z+=1);const $=t.useMemo(()=>(new jo).naturalDimensions(D,{maxWidth:"wrap"===k?E-z:void 0,lineHeight:`${A}px`,paintableText:{fontStyle:L,wrap:k,letterSpacing:-.25}}),[D,k,z,j,T,O,L,w,E]),B=t.useCallback(()=>$.maxLineHeight?$.maxLineHeight+"px":"1.2",[$]),[F,V]=t.useState(B);t.useLayoutEffect(()=>{V(B())},[g,$]),t.useLayoutEffect(()=>{w?.({width:"wrap"===k?void 0:$.width+z,height:$.height})},[$,w]);const W=et(d,[d]),H=et(e=>{if(_.dirty===e)return;const t={..._};t.dirty=e,S.current,C(t),W?.(t)},[_]),N=et(e=>{if(_.editMode===e)return;const t={..._};t.editMode=e,C(t),W?.(t)},[_]),U=et(()=>{try{return h?.(_),p?.(),!0}catch(e){return!1}},[h,_]),q=et(()=>{C(c),f?.(),p?.()},[f,c]),K=et(e=>{if(!S.current)return;if(e.isDefaultPrevented(),!(e.isTrusted||e.nativeEvent.ctrlKey||e.nativeEvent.metaKey||e.nativeEvent.altKey||e.nativeEvent.isComposing)&&-1!==Rn.indexOf(e.nativeEvent.key)){const t={..._};return t.dirty="Backspace"===e.nativeEvent.key?"":(t.dirty??"")+e.key,C(t),W?.(t),void e.preventDefault()}const t=e.nativeEvent.shiftKey;if(e.which===Be)return e.preventDefault(),void q();if(e.which===Ne)return N(!0),void e.preventDefault();if(e.which===$e&&(e.preventDefault(),U()&&m?.(t?r:i)),e.which===Ae)return e.preventDefault(),void(U()&&m?.(t?l:s));if(!_.editMode){let t=null;switch(e.which){case Fe:t=l;break;case We:t=s;break;case Ve:t=r;break;case He:t=i}if(t)return void U()}},[_,m]),[Y,X]=t.useState(!b);t.useEffect(()=>{X(!1)},[]);const G=zt(o,()=>({startEdit(e){let t=e?.initialSelection;if(!t){const e=S.current.value.length??0;t={start:e,end:e,direction:"forward"}}S.current?.setSelectionRange(t.start,t.end,t.direction);const n={...c,editMode:e?.editMode??!1};void 0!==e?.text&&(n.dirty=e.text),n.editMode===c.editMode&&n.dirty===c.dirty||(C(n),W?.(n))},submitEdit:()=>U(),cancelEdit(){q()},autoFocus(){S.current?.focus()},getLineHeight:()=>$?.maxLineHeight??A,dispatchEvent:e=>S.current.dispatchEvent(e)}),[c,u]);return e.jsx("div",{ref:G,...v,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:$.height,maxWidth:"100%",maxHeight:"100%",...y},children:e.jsx("textarea",{spellCheck:"false",ref:S,value:D,autoFocus:!1,disabled:Y,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${j}px`,fontFamily:`${T}`,fontWeight:`${O}`,fontStyle:`${L}`,padding:"0px",marginRight:"right"===I?"3px":"0px",marginLeft:"left"===I?"2px":"0px",lineHeight:F,height:$.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:I,background:"transparent",color:R,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:"wrap"===k?"break-spaces":"pre",wordWrap:"break-word"},onChange:e=>{H(e.target.value)},onDoubleClick:e=>{e.isTrusted},onMouseDown:e=>{N(!0)},onKeyDown:K})})})),Fo=t.memo(t=>{const{value:n,view:o,bounds:r,range:i,zoom:l,children:s,style:c,...a}=t,u=c?.fontSize||1056/72;return e.jsx("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:u,...c},...a,children:n})});exports.BaseGrid=Io,exports.DefaultCellEditor=Bo,exports.DefaultCellRenderer=Fo,exports.DefaultHeaderDivider=Lo,exports.FillHandle=to,exports.Grid=Mo,exports.HeaderDivider=zo,exports.HeaderRenderer=To,exports.RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL=150,exports.SELECTION_CLIP_INSETS=uo,exports.STANDARD_KEY_CHARS=Rn,exports.SVGLine=Xn,exports.SVGRect=Gn,exports.ScrollableGrid=Ro,exports.Selection=Jn,exports.TouchSelectHandle=ao,exports.defaultSelectionRenderer=Zn,exports.getDefaultStringEditState=Ao,exports.safeSelectionCoords=go,exports.useCellLayout=Mn,exports.useHeaderSelection=({gridRef:e,gridMainRef:n,orientation:o=y,headerCount:r,selectionPolicy:i="multiple",newSelectionMode:l="clear",alwaysScrollToActiveCoords:s=!0,onDragStart:c,onDragEnd:a,pointerDownInterceptor:u,pointerMoveInterceptor:d,onPointerUp:h,newSelection:f,modifySelection:p,appendSelection:g,clearSelections:w})=>{const m=r??((o===y?e.current?.rowCount:e.current?.columnCount)||0),b=t.useRef(null),v=t.useRef(null),S=t.useRef(!1),E=t.useRef(null),_=t.useCallback(e=>o===x?{rowIndex:0,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:0},[o]),C=t.useCallback(e=>o===x?{rowIndex:n.current?n.current.rowCount-1:0,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:n.current?n.current.columnCount-1:0},[o]),I=e=>{v.current=C(e),p(v.current,b.current)},M=t.useCallback((t,r)=>{if(!e.current)return;const i=e.current.getViewFromClient(t,r)?.getCellCoordsFromClient(t,r);return i?(o===x?i.rowIndex=n.current.getViewport().rowStart:i.colIndex=n.current.getViewport().colStart,i):void 0},[]),R=t.useCallback((e,t=!1)=>{let r=e;return t||(r={...e},o===y?delete r.colIndex:delete r.rowIndex),n.current?.scrollCellCoordsIntoView(r)},[o]),k=et(a,[a]),T=et(c,[c]),P=t.useMemo(()=>({onPointerDown:t=>{if(!e||!e.current)return;if(t.nativeEvent.defaultPrevented)return;const r=M(t.nativeEvent.clientX,t.nativeEvent.clientY);if(!r)return;t.nativeEvent.which;const i=t.nativeEvent.shiftKey,l=t.nativeEvent.ctrlKey||t.nativeEvent.metaKey;if(!1===u?.(t,r))return;T?.(),S.current=!0;const c=n.current?.getViewFromClient(t.nativeEvent.clientX,t.nativeEvent.clientY),a=((e,t)=>o===x?{...e,rowIndex:t.rowStart}:{...e,colIndex:t.colStart})(r,c.getVisibleRangeCoords());if(i)I(r);else{if(l)return((e,t=e,n)=>{b.current=_(e),v.current=C(t),g(b.current,v.current,n)})(r,r,a),void(s&&R(a,!0));((e,t=e,n)=>{b.current=_(e),v.current=C(t),f(b.current,v.current,n)})(r,r,a),I(r),s&&R(a,!0)}},onPointerMoveOrWait:ae.throttle(t=>{if(!S.current||!e?.current)return;const n=M(t.clientX,t.clientY);if(n&&!1!==d?.(t,n)){if($.isEqualCells(E.current,n))return w();I(n),R(n)}},60),onPointerUp:e=>{S.current=!1,k?.(),h?.(e)},processTouch:!0,consumeTouch:!0}),[i,s,m,l,w,u,h]);return{onPointerDown:et(nn(P),[]),getCellCoordsFromClient:M}},exports.useKeyboardEditorOverlay=n=>{const{view:o,canEdit:r=Tn,getCellEditor:i,onBeforeStartEdit:l,onStartEdit:s,onSubmitEdit:c,onCancelEdit:a,onDoneEdit:u,isEditorStartKeyEvent:d=Pn,isEditorStartPointerEvent:h=On,containerProps:f,borderStrokeFill:p,borderStrokeWidth:g=2,getRangeCoords:w=null,activeCoords:m,alignment:x=Le.Left}=n,[y,b]=t.useState(!1),[v,S]=t.useState(void 0),E=et((e,t,n,o,r,i)=>{if(!t)return null;const l=r?.(t,e),s=e.getRangeCoordsBounds(l),c=e.toClipBounds(s),a=s,u=e.getZoom();if(!c)return null;n&&(n*=u),o&&(o*=u);let d=a,h=!1;if(void 0!==n){let t={...l},o=0;for(;!h&&d.width<=n&&o<20;){o++,o>19&&console.warn("max width reached");const r=e.getTotalRangeCoords(),l=e.getLayout();i===Le.Left?t.colEnd+1<r.colEnd?t.colEnd=l.getColIndex(d.x+n):h=!0:i===Le.Right?t.colStart-1>=0?t.colStart=l.getColIndex(d.x-(n-d.width)):h=!0:i===Le.Center&&t.colEnd+1<r.colEnd&&t.colStart-1>=0?(t.colStart=l.getColIndex(d.x-(n-d.width)/2),t.colEnd=l.getColIndex(d.x+d.width+(n-d.width)/2)):h=!0,h||(d=e.getRangeCoordsBounds(t))}}d.height=a.height,void 0!==o&&(d.height=Math.max(o+1,a.height));const{width:f,height:p}=e.getViewportSize();return{x:d.x??0,y:d.y??0,height:Math.min(p-d.y,d.height)+1,width:Math.min(f-d.x,d.width)+1}},[x]),_=et(r,[r]),C=t.useCallback(()=>{o?.getStage()?.focus()},[o]),I=t.useRef(null),M=et(e=>{l?.(e),B(),b(!0),I.current=null},[l]),R=et(e=>{s?.(e.coords)},[s]),k=et(e=>{e.isSubmitted||e.isCancelled||(O.current.isEditorClosed=!0,C(),e.isCancelled=!0,a?.(e.coords),B())},[a]),T=et(e=>{if(e.isSubmitted||e.isCancelled)return!1;try{return I.current=e.coords,e.isEditorClosing=!0,e.isSubmitted=!0,e.isEditorSubmitted||(e.isEditorSubmitted=!0,e.editorRefs[0]?.submitEdit?.()),e.coords,c?.(e.coords),e.isEditorClosed=!0,C(),B(),!0}catch(t){throw e.isEditorClosing=!1,e.isSubmitted=!1,t}},[c]),P=et(e=>{b(!1),u?.(e.coords),B()},[u]),O=t.useRef(null),L=t.useRef(null),D=t.useRef(null),z=t.useRef([]),[j,A]=t.useReducer(e=>e+1,0),B=t.useCallback(e=>{e&&z.current.push(e),A()},[]),F=et(e=>{if(e.defaultPrevented||e.isSynthetic)return;if(!o)return;const t=o?.getCellCoordsFromClient(e.clientX,e.clientY);if(!t)return;B({eventType:"pointer",event:e,coords:t})},[o]),V=et(e=>{const t=e.nativeEvent;F(t)},[o]),W=et(e=>{if(e.defaultPrevented||e.isSynthetic)return;if(!o?.getStage())return;const t=L.current;d(e,t)&&(e.stopPropagation(),e.preventDefault()),e.key;B({eventType:"keyboard",event:e,coords:t})},[o]);t.useLayoutEffect(()=>{const e=(e,t)=>{const n=t?.cell??e;if(!n)return null;const r=n;if(!_(n))return null;M?.(n);const i=ae.uuidV4();t=Object.freeze({autoFocus:!0,...t}),D.current=n;const l={coords:r,startEvent:t,uuid:i,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:e=>{l.isMounted||(l.isMounted=!0,B())},onUnmount:e=>{if(0===l.editorRefs.length){const e=()=>{l.isMounted=!1,B()};if(document.activeElement!==document.body)e();else{const t=e=>{e.defaultPrevented||e.target!==document.body||W(e)};window.addEventListener("keydown",t,!0),o.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",t),e()},{once:!0}),C()}}}};return l};if(z.current.length<=0&&!O.current)return;const t=z.current[0];kn(t),(e=>{const t=[],n=e?.length??0;for(let o=0;o<n;o++){const n=e[o];t.push(kn(n))}})(z.current),O.current,O.current;let n=O.current;if(O.current)if(O.current.isDone)O.current=null;else if(O.current.isSubmitted||O.current.isCancelled){if(O.current.isMounted)return;O.current.isDone||(P(O.current),O.current.isDone=!0)}if(t)if("start"===t.eventType){const n=t,o=n.startEvent?.cell??L.current;O.current&&$.isEqualCells(O.current.coords,o)||(O.current=e(o,n.startEvent))}else if("keyboard"===t.eventType){const n=t.event;if(O.current){let e=!1;switch(n.which){case Fe:case We:case Ve:case He:case $e:case Ae:e=!0}if(!e){O.current.events.push(t);for(let e=0;e<O.current.editorRefsDispatchEditorEvent.length;e++)O.current.editorRefsDispatchEditorEvent[e](t)}}else{if(d(n,t.coords)){let n;const o=e(n?.cell??L.current,n);o&&o.events.push(t),O.current=o}}}else if("pointer"===t.eventType){const n=t.event;if(O.current){O.current.events.push(t);for(let e=0;e<O.current.editorRefsDispatchEditorEvent.length;e++)O.current.editorRefsDispatchEditorEvent[e](t)}else{const o=t?.coords??L.current,r=h(n,o);if(r){let n;"boolean"!=typeof n&&(n=r);const i=e(o,n);i&&i.events.push(t),O.current=i}}}else if("submit"===t.eventType){if(O.current&&!O.current.isSubmitted&&!O.current.isCancelled){if(!O.current.isMounted)return;T(O.current)}}else if("cancel"===t.eventType){if(O.current&&!O.current.isSubmitted&&!O.current.isCancelled){if(!O.current.isMounted)return;k(O.current)}}else if("coordsChange"===t.eventType){const e=t;if(L.current=e.activeCoords,O.current,O.current&&!O.current.isSubmitted&&!O.current.isCancelled){if(!O.current.isMounted)return;try{T(O.current)}catch(e){}}}z.current.length>0&&(z.current.shift(),B()),0===z.current.length&&(!O.current||O.current.isEditorClosing||O.current.isEditorClosed?!O.current&&n&&C():O.current.isMounted&&!O.current.isStarted&&(O.current.isStarted=!0,O.current.startEvent.autoFocus&&("string"==typeof O.current.startEvent.autoFocus?O.current.editorRefs[0]?.autoFocus(O.current.startEvent.autoFocus):O.current.editorRefs[0]?.autoFocus()),R?.(O.current),requestAnimationFrame(()=>{o&&O.current?.coords&&o.scrollCellCoordsIntoView(O.current.coords)})))},[j]),t.useEffect(()=>{D.current=m;const e=O.current?.coords;if(!$.isEqualCells(e,m)){O.current&&(O.current.isEditorClosing=!0);B({eventType:"coordsChange",activeCoords:m})}},[m]);const H=t.useCallback(e=>{W(e.nativeEvent)},[]),{width:N=0,height:U=0}=v??{width:0,height:0},q=et(i,[i]);return{overlay:et(t=>{if(!O.current||O.current.isEditorClosed)return O.current,null;O.current.coords;let n=E(t,O.current.coords,N,U,w,x),o=!0;n&&0!==n.width&&0!==n.height||(n={x:0,y:0,width:N,height:N},o=!1);const r=t.getZoom(),i={containerBounds:{x:0,y:0,width:n.width/r,height:n.height/r},setNaturalDimensions:S,zoom:r};return e.jsx(Ln,{session:O.current,refLatestCoords:D,handleSubmitEdit:T,handleCancelEdit:k,cellBounds:n,borderStrokeWidth:g,borderStrokeFill:p,isInBounds:o,getCellEditor:q,propsEditor:i,alignment:x,...f},"editor:"+O.current.uuid)},[i,w,j,N,U,x,g,p]),startEdit:t.useCallback(e=>{B({eventType:"start",startEvent:e})},[]),submitEdit:t.useCallback(()=>{B({eventType:"submit"})},[]),cancelEdit:t.useCallback(()=>{B({eventType:"cancel"})},[]),onKeyboardEvent:H,onPointerEvent:V,onKeyboardEventNative:W,onPointerEventNative:F,isEditing:y}},exports.useSelection=({gridRef:n,commands:o,layout:h,selection:f,onSelectionChange:p,onSelectionDragStart:g,onSelectionDragEnd:w,selectionPolicy:m="multiple",newSelectionMode:x="clear",allowDeselectSelection:y=!0,onFillPreview:b,onFillCancel:v,onFillDone:S,onFill:E,disableFillDrag:_=!E,fillHandleBorderColor:C="white",hiddenRowsAt:I,hiddenColumnsAt:M,isContentfulCell:R,contentfulCellFinder:k=$n,getDataCoords:T,alwaysScrollToActiveCoords:P=!1,selectionBounds:O,pointerDownInterceptor:L,pointerMoveInterceptor:D,mergedRanges:z,canSelectionSpanMergedCells:j=mo,onMoveDragStart:A,onMoveDragUpdate:B,onMoveDragEnd:F,onMoveDragDone:V,selectionRenderer:W=Zn,disableMoveDrag:H=!F,getCellCoordsAsRangeCoords:N=$.cellToRange,moveDragHitSize:U=6,moveDragOutlineSize:q=4,selectionBackgroundColor:K="rgba(16, 124, 65, 0.1)",selectionBorderColor:Y="rgb(33, 115, 70)",selectionRemoveBorderColor:X="rgb(255, 0, 0)",selectionRemoveBackgroundColor:G="rgba(250, 10, 10, 0.1)",disableTouchSelection:Z=!1,touchSelectHandleProps:J})=>{const Q=t.useCallback(()=>({top:O?.top??0,left:O?.left??0,bottom:n.current?.rowCount-1||0,right:n.current?.columnCount-1||0}),[]),ee=et(E,[E]),te=et(b,[b]),ne=et(v,[v]),oe=et(S,[S]),re=et(R,[R]),ie=et(W,[W]),le=et((e,t=!1)=>Nn(e,t,h.getRowOffset,t?Q().bottom:Q().top),[h?.getRowOffset]),se=et(I??le,[I]),ce=et((e,t=!1)=>Nn(e,t,h.getColOffset,t?Q().right:Q().left),[h?.getColOffset]),ue=et(M??ce,[M]),[de,he]=t.useState(()=>go(f)),fe=t.useMemo(()=>go(de),[de]),pe=t.useRef(fe),ge=t.useRef(!0);t.useLayoutEffect(ae.throttle(()=>{he(e=>{ge.current=!0;const t=go(f);return $.isEqualSelectionCoords(t,e)?e:t})},0),[f]),t.useLayoutEffect(()=>{pe.current=fe},[fe]),t.useEffect(()=>{ge.current||!p||$.isEqualSelectionCoords(f,fe)||p(fe)},[fe]);const we=t.useCallback(e=>{he(t=>{ge.current=!1,t=go(t);let n="function"==typeof e?e(t.ranges):e??po;if($.isEqualRangesArrays(n,t.ranges))return t;let o=Math.max(n.length?0:-1,Math.min(t.rangeIndex,n.length-1)),r=t.cell;-1===o||$.isCellWithinRange(r,n[o])||(r={rowIndex:n[o].rowStart,colIndex:n[o].colStart}),1===n.length&&$.isSingleCell(n[0])&&$.isCellWithinRange(r,n[0])&&(n=[],o=-1);const i={cell:r,ranges:n,rangeIndex:o};return $.isEqualSelectionCoords(i,t)?t:i})},[]),me=et(e=>{he(t=>{ge.current=!1,t=go(t);const n=e??fo,o=N(n);if(!$.isSingleCell(o)&&0===t.ranges.length)return{ranges:[o],rangeIndex:0,cell:n};if($.isEqualCells(n,t.cell))return t;let r=t.ranges,i=t.rangeIndex;1===t.ranges.length&&($.isSingleCell(t.ranges[0])&&$.isCellWithinRange(n,t.ranges[0])||!$.isCellWithinRange(n,t.ranges[0]))&&(r=[],i=-1);const l={ranges:r,rangeIndex:i,cell:n};return $.isEqualSelectionCoords(l,t)?t:l})},[N]),[xe,ye]=t.useState(null),[be,ve]=t.useState(null),Se=t.useRef(null),[Ee,_e]=t.useState(null),Ce=t.useRef(null),Ie=t.useRef(null),[Me,Re]=t.useState(null),ke=t.useRef(null),Te=t.useRef(null),Pe=t.useRef(z);t.useEffect(()=>{Pe.current=z},[z]);const Oe=et((e,t={inline:"nearest",block:"nearest"})=>{let{rowIndex:o,colIndex:r}=e;void 0===o&&fe?.cell&&(o=fe.cell.rowIndex),void 0===r&&fe?.cell&&(r=fe.cell.colIndex),void 0!==o&&void 0!==r&&n.current?.scrollCellCoordsIntoView({rowIndex:o,colIndex:r},t)},[fe]),Le=t.useCallback(e=>{const t=Q();return e.rowIndex<t.top||e.colIndex<t.left||e.colIndex>t.right||e.rowIndex>t.bottom},[]),Ae=et((e,t)=>{if(!n?.current)return null;const o={rowStart:Math.min(e.rowIndex,t.rowIndex),colStart:Math.min(e.colIndex,t.colIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex),colEnd:Math.max(e.colIndex,t.colIndex)},r=j?.(o);if(r)return o;const i=N(e),l=N(t),s={rowStart:Math.min(i.rowStart,l.rowStart),colStart:Math.min(i.colStart,l.colStart),rowEnd:Math.max(i.rowEnd,l.rowEnd),colEnd:Math.max(i.colEnd,l.colEnd)};let c;return"function"==typeof Pe.current?c=Pe.current(s):z&&(c=z),c?$.extendRangeToUnionRanges(s,c):s},[j,N]),$e=et((e,t,n)=>{const o=e.ranges.length>0?e.ranges[e.rangeIndex]:{rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},r={rowStart:Math.min(t.rowIndex??o.rowStart,n.rowIndex??o.rowStart),colStart:Math.min(t.colIndex??o.colStart,n.colIndex??o.colStart),rowEnd:Math.max(t.rowIndex??o.rowEnd,n.rowIndex??o.rowEnd),colEnd:Math.max(t.colIndex??o.colEnd,n.colIndex??o.colEnd)},i={rowIndex:r.rowStart,colIndex:r.colStart},l={rowIndex:r.rowEnd,colIndex:r.colEnd};if(Le(i)||Le(l))return;return Ae(i,l)},[Ae]),Be=et((e,t,n)=>{if("single"===m)return;if(!pe.current)return;const o=$e(pe.current,e,t??pe.current.cell);if(!o)return;const r=pe.current.rangeIndex;we(e=>e.length?e.map((e,t)=>r===t?o:e):[o]),n&&o&&me({colIndex:o.colStart,rowIndex:o.rowStart})},[]),Fe=t.useCallback((e,t,n)=>{if(!pe.current)return;e={...pe.current?.cell,...e},t=t??e;const o=$e(pe.current,e,t);if(!o)return;const r={rowIndex:o.rowStart,colIndex:o.colStart},i={...r,...n};"clear"===x?(ke.current=i,We()):"modify"===x?Be(r):Ve(r),me(i)},[]),Ve=t.useCallback((e,t=e,n)=>{"multiple"!==m||!e||Le(e)||Le(t)||he(o=>{ge.current=!1,o=go(o);const r=Ae(e,t);if(!r)return o;let i=o.ranges.length>0?[...o.ranges]:[Ae(o.cell,o.cell)];i.push(r);const l={ranges:i,cell:{rowIndex:r.rowStart,colIndex:r.colStart,...n},rangeIndex:i.length-1};return $.isEqualSelectionCoords(l,o)?o:l})},[]),We=()=>{we(po)},He="touch"===Lt.detectIt().primaryInput,Ne=t.useRef(null),qe=t.useRef(null),Ke=t.useRef(null),Ye=t.useMemo(()=>({onPointerDown:e=>{if(!n||!n.current)return!1;const t=e.nativeEvent,o=n.current.getViewFromClient(t.clientX,t.clientY);if("touch"===t.pointerType||"touchstart"===t.type)return qe.current={topLeft:o.getScrollTopLeft(),point:{x:t.clientX,y:t.clientY}},!0;const r=o.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!r)return!1;Ne.current={anchor:o.getAnchor(),coords:r},Te.current=null;const i=e.nativeEvent.which===Ue;if(i){if(-1!==$.indexOfCoords(r,fe.ranges))return!1}const l=e.nativeEvent.shiftKey,s=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,c=s,a=y,u=fe.ranges.length>0,d=s&&a;if(!1===L?.(e,r,fe))return!1;g?.(pe.current,e.nativeEvent);const h=!i&&"single"!==m;if(l)return Be(r),h;const f=$.isEqualCells(r,fe.cell);if(c){if(f&&(!d||!u))return h;if(s){if(-1!==$.indexOfCoords(r,fe.ranges)&&a){Ce.current=r;const e=Ae(r,r);return Ie.current=e,_e(e),h}}return Ve(r),h}P&&Oe(r),f&&0===fe.ranges.length||Fe(r)},onPointerMoveOrWait:ae.throttle((e,t)=>{if(!n?.current)return;if("touch"===e.pointerType||"touchmove"===e.type)return;if(!Ne.current)return;const o=Ne.current.anchor;let r=n.current.getViewFromLocation(o),i=r.getCellCoordsFromClient(e.clientX,e.clientY);if(!$.isEqualCells(i,Ne.current?.coords)&&(Ne.current={anchor:o,coords:i},i&&!1!==D?.(e,i,pe.current))){if(Ce.current){const e={rowStart:Math.min(i.rowIndex,Ce.current.rowIndex),colStart:Math.min(i.colIndex,Ce.current.colIndex),rowEnd:Math.max(i.rowIndex,Ce.current.rowIndex),colEnd:Math.max(i.colIndex,Ce.current.colIndex)},t={rowIndex:e.rowStart,colIndex:e.colStart},n={rowIndex:e.rowEnd,colIndex:e.colEnd};if(Le(t)||Le(n))return;const o=Ae(t,n);Ie.current=o,_e(o)}else Be(i);Ke.current=t,wo(r,i,n)}},60),onPointerUp:e=>{if(Ne.current=null,"touch"===e.pointerType||"touchend"===e.type){if(qe.current){const e=n.current.getViewFromClient(qe.current.point.x,qe.current.point.y),t=e.getScrollTopLeft();if(t.left===qe.current.topLeft.left&&t.top===qe.current.topLeft.top){const t=e.getCellCoordsFromClient(qe.current.point.x,qe.current.point.y);Fe(t)}}return qe.current=null,void(Ne.current=null)}try{w?.(pe.current,e)}catch(e){console.warn(e)}if(!Ce.current)return;const t=Ie.current;Ce.current=null,Ie.current=null,_e(null),he(e=>{if(ge.current=!1,0===(e=go(e)).ranges.length)return e;let n=[],o=-1,r=e.cell;for(let i=0;i<e.ranges.length;i++){const l=e.ranges[i];if($.isRangesIntersect(l,t)){const r=ae.subtractRect({top:l.rowStart,left:l.colStart,bottom:l.rowEnd+1,right:l.colEnd+1},{top:t.rowStart,left:t.colStart,bottom:t.rowEnd+1,right:t.colEnd+1});for(let t=0;t<r.length;t++){const i={rowStart:r[t].top,colStart:r[t].left,rowEnd:r[t].bottom-1,colEnd:r[t].right-1};n.push(i),$.isCellWithinRange(e.cell,i)&&(o=n.length-1)}}else n.push(l);n.length>0&&-1===o&&$.isCellWithinRange(e.cell,l)&&(o=n.length-1,r={rowIndex:n[n.length-1].rowStart,colIndex:n[n.length-1].colStart})}const i={cell:r,rangeIndex:o,ranges:n};return $.isEqualSelectionCoords(i,e)?e:i})},processTouch:!0,consumeTouch:!1}),[fe,m,y,P,x]),Xe=et(nn(Ye),[]),Ge=t.useMemo(()=>({onSelectionPointerDown:(e,t,o,r,i=fe.cell,l=P,s=e.nativeEvent.shiftKey,c=!1)=>{if(!n||!n.current)return!1;e.stopPropagation(),e.preventDefault(),e.nativeEvent.stopImmediatePropagation();const a=o??n.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),u=r??a.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!u)return!1;Ne.current={anchor:a.getAnchor(),coords:u},Te.current=null;const d=e.nativeEvent.which===Ue;if(d){if(-1!==$.indexOfCoords(u,fe.ranges))return!1}const h=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,f=h,p=y,w=fe.ranges.length>0,x=h&&p;if(!1===L?.(e,u,fe))return!1;g?.(pe.current,e.nativeEvent);const b=!d&&"single"!==m;if(s)return Be(u,i,c),b;const v=$.isEqualCells(u,i);if(f){if(v&&(!x||!w))return b;if(x){if(-1!==$.indexOfCoords(u,fe.ranges)&&p){Ce.current=u;const e=Ae(u,u);return Ie.current=e,_e(e),b}}return Ve(u),b}l&&Oe(u),v&&0===fe.ranges.length||Fe(u)},onSelectionPointerMoveOrWait:(e,t,o,r,i,l=fe.cell,s=!0,c=!1)=>{if(!n?.current)return;if(e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation(),!Ne.current)return;const a=Ne.current.anchor;let u=r??n.current.getViewFromLocation(a),d=i??u.getCellCoordsFromClient(e.clientX,e.clientY);if(!$.isEqualCells(d,Ne.current?.coords)&&(Ne.current={anchor:a,coords:d},d&&!1!==D?.(e,d,pe.current))){if(Ce.current){const e={rowStart:Math.min(d.rowIndex,Ce.current.rowIndex),colStart:Math.min(d.colIndex,Ce.current.colIndex),rowEnd:Math.max(d.rowIndex,Ce.current.rowIndex),colEnd:Math.max(d.colIndex,Ce.current.colIndex)},t={rowIndex:e.rowStart,colIndex:e.colStart},n={rowIndex:e.rowEnd,colIndex:e.colEnd};if(Le(t)||Le(n))return;const o=Ae(t,n);Ie.current=o,_e(o)}else Be(d,l,c);s&&wo(u,d,n)}},onPointerUp:e=>{Ne.current=null,e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation();try{w?.(pe.current,e)}catch(e){console.warn(e)}if(!Ce.current)return;const t=Ie.current;Ce.current=null,Ie.current=null,_e(null),he(e=>{if(ge.current=!1,0===(e=go(e)).ranges.length)return e;let n=[],o=-1,r=e.cell;for(let i=0;i<e.ranges.length;i++){const l=e.ranges[i];if($.isRangesIntersect(l,t)){const r=ae.subtractRect({top:l.rowStart,left:l.colStart,bottom:l.rowEnd+1,right:l.colEnd+1},{top:t.rowStart,left:t.colStart,bottom:t.rowEnd+1,right:t.colEnd+1});for(let t=0;t<r.length;t++){const i={rowStart:r[t].top,colStart:r[t].left,rowEnd:r[t].bottom-1,colEnd:r[t].right-1};n.push(i),$.isCellWithinRange(e.cell,i)&&(o=n.length-1)}}else n.push(l);n.length>0&&-1===o&&$.isCellWithinRange(e.cell,l)&&(o=n.length-1,r={rowIndex:n[n.length-1].rowStart,colIndex:n[n.length-1].colStart})}const i={cell:r,rangeIndex:o,ranges:n};return $.isEqualSelectionCoords(i,e)?e:i})}}),[fe,m,y,P,x]),Ze=et((e,t=!1,o=!1,c=0)=>{if(!n.current||!fe.cell)return;let a=fe.cell,u=fe.cell;if(t&&fe.ranges.length>0){const t=fe.ranges[fe.rangeIndex],n=fe.cell;switch(e){case r:u={rowIndex:n.rowIndex===t.rowStart?t.rowEnd:t.rowStart,colIndex:t.colEnd},a={rowIndex:n.rowIndex===t.rowStart?t.rowStart:t.rowEnd,colIndex:t.colStart};break;case i:u={rowIndex:n.rowIndex===t.rowEnd?t.rowStart:t.rowEnd,colIndex:t.colEnd},a={rowIndex:n.rowIndex===t.rowEnd?t.rowEnd:t.rowStart,colIndex:t.colStart};break;case l:u={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colStart?t.colEnd:t.colStart},a={rowIndex:t.rowStart,colIndex:n.colIndex===t.colStart?t.colStart:t.colEnd};break;case s:u={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colEnd?t.colStart:t.colEnd},a={rowIndex:t.rowStart,colIndex:n.colIndex===t.colEnd?t.colEnd:t.colStart}}}const d=N(u);let{rowStart:f,colStart:p}=d;const g=Q();if(Te.current)switch(e){case r:case i:Te.current.colIndex>=d.colStart&&Te.current.colIndex<=d.colEnd&&(p=Te.current.colIndex);break;case l:case s:Te.current.rowIndex>=d.rowStart&&Te.current.rowIndex<=d.rowEnd&&(f=Te.current.rowIndex)}if(!c){switch(e){case r:f=Dn(se,Math.max(d.rowStart-1,g.top),e);break;case i:f=Dn(se,Math.min(d.rowEnd+1,g.bottom),e);break;case l:p=Dn(ue,Math.max(d.colStart-1,g.left),e);break;case s:p=Dn(ue,Math.min(d.colEnd+1,g.right),e)}if(o)switch(e){case r:f=k({...u,colIndex:fe.cell.colIndex},re,se,e,!1,Math.max(g.top,se(g.top,!1)));break;case i:f=k({...u,colIndex:fe.cell.colIndex},re,se,e,!1,Math.min(g.bottom,g.bottom-se(g.bottom,!0)));break;case l:p=k({...u,rowIndex:fe.cell.rowIndex},re,ue,e,!1,Math.max(g.left,ue(g.left,!1)));break;case s:p=k({...u,rowIndex:fe.cell.rowIndex},re,ue,e,!1,Math.min(g.right,g.right-ue(g.right,!0)))}}let w=null;if(c){let t=0;switch(e){case r:t=h.getRowOffset(f+1),f=Math.max(g.top,h.getRowIndex(t-c)),w={top:h.getRowOffset(f+1)-(t-n.current.getScrollPosition().top)};break;case i:t=h.getRowOffset(f),f=Math.min(g.bottom,h.getRowIndex(t+c)),w={top:h.getRowOffset(f)-(t-n.current.getScrollPosition().top)};break;case l:t=h.getColOffset(p+1),p=Math.max(g.left,h.getColIndex(t-c)),w={left:h.getColOffset(p+1)-(t-n.current.getScrollPosition().left)};break;case s:t=h.getColOffset(p),p=Math.min(g.right,h.getColIndex(t+c)),w={left:h.getColOffset(p)-(t-n.current.getScrollPosition().left)}}}const m={rowIndex:f,colIndex:p},x=N(m),y={rowIndex:x.rowStart,colIndex:x.colStart};t||(Te.current=m);const b=$.isEqualCells(ke.current,y)&&$.isEqualCells(ke.current,a);if(t&&!b?Be(y,a):Fe(y),w)n.current.scrollTo(w);else{if(t&&ke.current){const t=Q();if(e===s&&ke.current.colIndex===t.left||e===l&&ke.current.colIndex===t.right||e===r&&ke.current.rowIndex===t.bottom||e===i&&ke.current.rowIndex===t.top)return}e===l||e===s?Oe({colIndex:m.colIndex}):e!==r&&e!==i||Oe({rowIndex:m.rowIndex})}},[fe,N]),Je=et(e=>{if(!n.current)return;if(0===fe.ranges.length)return void Ze(e);const t=N(fe.cell);if($.isEqualRangesArrays([t],fe.ranges))return void Ze(e);const o=Wn(fe,e,N,se,ue);he(e=>{ge.current=!1,e=go(e);const t={...e,cell:o.cell,rangeIndex:o.rangeIndex};return $.isEqualSelectionCoords(t,e)?e:t}),o.cell&&Oe(o.cell)},[fe,N]),Qe=t.useCallback(()=>{const e=Q();Be({rowIndex:e.top},{rowIndex:e.bottom})},[]),tt=t.useCallback(()=>{const e=Q();Be({colIndex:e.left},{colIndex:e.right})},[]),nt=et(()=>{fe.cell&&n?.current&&Oe(fe.cell)},[fe.cell]),ot=t.useCallback((e=!1)=>{const t={rowIndex:Q().top};e?Be(t):Fe(t),Oe(t)},[]),rt=t.useCallback((e=!1)=>{const t={rowIndex:Q().bottom};e?Be(t):Fe(t),Oe(t)},[]),it=t.useCallback((e=!1)=>{const t={colIndex:Q().left};e?Be(t):Fe(t),Oe(t)},[]),lt=t.useCallback((e=!1)=>{const t=Q(),n={rowIndex:t.top,colIndex:t.left};e?Be(n):Fe(n),Oe(n)},[]),st=t.useCallback((e=!1)=>{const t=Q(),n={colIndex:T?.()?.colEnd??t.right};e?Be(n):Fe(n),Oe(n)},[T]),ct=t.useCallback((e=!1)=>{const t=Q(),n={rowIndex:T?.()?.rowEnd??t.bottom,colIndex:T?.()?.colEnd??t.right};e?Be(n):Fe(n),Oe(n)},[T]),at=et(e=>{if(!n.current)return;if(fe.ranges.length<=1)return;const t=e===l||e===r;let o=fe.rangeIndex+(t?-1:1);o<0?o=fe.ranges.length-1:o>fe.ranges.length-1&&(o=0);const i=fe.ranges[o],c=Wn({cell:{rowIndex:i.rowEnd,colIndex:i.colEnd},rangeIndex:0,ranges:[i]},s,N,se,ue);he(e=>{ge.current=!1,e=go(e);const t={...e,cell:c.cell,rangeIndex:o};return $.isEqualSelectionCoords(t,e)?e:t}),c.cell&&Oe(c.cell)},[fe,N]),ut=et(()=>{const e=Vn(fe);he(t=>{ge.current=!1,t=go(t);const n={...t,visibleSelection:e};return $.isEqualSelectionCoords(n,t)?t:n}),e.cell&&Oe(e.cell)},[fe,N]),dt=et(()=>{if(!n.current)return;if(0===fe.ranges.length)return;const e=fe.cell,t=fe.ranges[fe.rangeIndex],o=Vn({cell:e,rangeIndex:0,ranges:[t]}),r=o.ranges[o.rangeIndex];let i;i=r.rowStart===e.rowIndex&&r.colStart===e.colIndex?{rowIndex:r.rowStart,colIndex:r.colEnd}:r.rowStart===e.rowIndex&&r.colEnd===e.colIndex?{rowIndex:r.rowEnd,colIndex:r.colStart}:r.rowEnd===e.rowIndex&&r.colStart===e.colIndex?{rowIndex:r.rowEnd,colIndex:r.colEnd}:{rowIndex:r.rowStart,colIndex:r.colStart},he(e=>{e=go(e);const t={...e,cell:i};return $.isEqualSelectionCoords(t,e)?e:t}),i&&Oe(i)},[fe,N]),ht=t.useCallback((e=!1)=>{Ze(i,e,!1,n.current.getDimensions().containerHeight)},[]),ft=t.useCallback((e=!1)=>{Ze(r,e,!1,n.current.getDimensions().containerHeight)},[]),pt=t.useCallback((e=!1)=>{Ze(s,e,!1,n.current.getDimensions().containerWidth)},[]),gt=t.useCallback((e=!1)=>{Ze(l,e,!1,n.current.getDimensions().containerWidth)},[]),wt=t.useCallback(()=>{Je(l)},[]),mt=t.useCallback(()=>{Je(s)},[]),xt=t.useCallback(()=>{Je(r)},[]),yt=t.useCallback(()=>{Je(i)},[]),bt=t.useCallback(()=>{at(l)},[]),vt=t.useCallback(()=>{at(s)},[]),St=t.useCallback(()=>{dt()},[]),Et=t.useCallback(()=>{Ze(l,!1,!1)},[]),_t=t.useCallback(()=>{Ze(l,!0,!1)},[]),Ct=t.useCallback(()=>{Ze(l,!1,!0)},[]),It=t.useCallback(()=>{Ze(l,!0,!0)},[]),Mt=t.useCallback(()=>{Ze(s,!1,!1)},[]),Rt=t.useCallback(()=>{Ze(s,!0,!1)},[]),kt=t.useCallback(()=>{Ze(s,!1,!0)},[]),Tt=t.useCallback(()=>{Ze(s,!0,!0)},[]),Pt=t.useCallback(()=>{Ze(r,!1,!1)},[]),Ot=t.useCallback(()=>{Ze(r,!0,!1)},[]),Dt=t.useCallback(()=>{Ze(r,!1,!0)},[]),zt=t.useCallback(()=>{Ze(r,!0,!0)},[]),jt=t.useCallback(()=>{Ze(i,!1,!1)},[]),At=t.useCallback(()=>{Ze(i,!0,!1)},[]),$t=t.useCallback(()=>{Ze(i,!1,!0)},[]),Bt=t.useCallback(()=>{Ze(i,!0,!0)},[]),Ft=t.useCallback(()=>{we(e=>e.slice(0,-1))},[]),Vt=t.useMemo(()=>{const e=Q();return((e,t,n,o,r)=>{for(let i=0;i<e.length;i++){const l=e[i];if(l.rowStart===t&&l.colStart===n&&l.rowEnd===o&&l.colEnd===r)return!0}return!1})(fe.ranges,e.top,e.left,e.bottom,e.right)},[O,fe.ranges]),Wt=t.useCallback((e,t=!0)=>{ke.current=e,me(e),t&&e&&n?.current&&Oe(e)},[]),Ht=et((e=!0)=>{const t=Se.current;if(!pe.current?.cell)return;const n=pe.current?.ranges,o=pe.current?.cell;if(!o||!t)return;if(!t)return;let r=null;if(r=n.length>0?n[n.length-1]:N(o),r.colEnd>=r.colStart&&r.rowEnd>=r.rowStart){const n=Hn(r,t);let o=e?ee:te;try{o?.(r,t,n.direction)}catch(e){console.warn(e)}finally{e&&oe?.()}}},[N]),Nt=t.useRef(null),Ut=t.useMemo(()=>({onPointerDown:(e,t)=>{if(Ke.current=t,!n||!n.current)return!1;const o=n.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),r=o?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);r&&(e.stopPropagation(),ye("crosshair"),Nt.current={anchor:o.getAnchor(),coords:r})},onPointerMoveOrWait:(e,t)=>{if(_||!n?.current||!pe.current||!Nt.current)return;const o=Nt.current.anchor;let c=n.current.getViewFromLocation(o),a=c.getCellCoordsFromClient(e.clientX,e.clientY);if(!a)return;Nt.current={anchor:o,coords:a};const u=pe.current.ranges;let d=Ae(pe.current.cell,a);if(!d)return;const h=u.length>0,f=h?u[u.length-1]:N(pe.current.cell);if(!d)return;const p=d.rowStart<f.rowStart?r:d.rowEnd>f.rowEnd?i:d.colEnd>f.colEnd?s:l,g=Q();p===l&&(d={...f,colStart:Math.max(g.left,d.colStart)}),p===r&&(d={...f,rowStart:Math.max(g.top,d.rowStart)}),p===s&&(d={...f,colEnd:Math.min(g.right,d.colEnd)}),p===i&&(d={...f,rowEnd:Math.min(g.bottom,d.rowEnd)});const w=Hn(f,d);if(!j?.(f)){let e;"function"==typeof Pe.current?e=Pe.current(f):z&&(e=z),d=((e,t,n,o,c,a)=>{const u={...t};if(0===n.length)return u;if(c===l){const t=e.colEnd+1-e.colStart;u.colStart=e.colStart-Math.ceil(a/t)*t,u.colStart<o.left&&(u.colStart=u.colStart+Math.ceil((o.left-u.colStart)/t)*t)}else if(c===s){const t=e.colEnd+1-e.colStart;u.colEnd=e.colEnd+Math.ceil(a/t)*t,u.colEnd>o.right&&(u.colEnd=u.colEnd-Math.ceil((o.right-u.colEnd)/t)*t)}else if(c===r){const t=e.rowEnd+1-e.rowStart;u.rowStart=e.rowStart-Math.ceil(a/t)*t,u.rowStart<o.top&&(u.rowStart=u.rowStart+Math.ceil((o.top-u.rowStart)/t)*t)}else if(c===i){const t=e.rowEnd+1-e.rowStart;u.rowEnd=e.rowEnd+Math.ceil(a/t)*t,u.rowEnd>o.bottom&&(u.rowEnd=u.rowEnd-Math.ceil((o.bottom-u.rowEnd)/t)*t)}return u})(f,d,e,g,w.direction,w.amount)}if(h&&$.isRangeWithinRange(d,f)&&(d=null),!$.isEqualRanges(d,Se.current)){if(ve(d),Se.current=d,!d){try{ne?.()}catch(e){}return void oe?.()}Ht(!1)}Ke.current=t,wo(c,a,n)},onPointerUp:(e,t)=>{Ke.current=t,Promise.resolve(Ht(!0)).finally(()=>{oe?.(),ve(null),Se.current=null,Nt.current=null,ye(null),n.current?.focus()})}}),[N]),qt=nn(Ut),Kt=t.useMemo(()=>({onPointerDown:qt}),[qt]),[Yt,Xt]=t.useState(null),Gt=t.useRef(null),Zt=t.useMemo(()=>({onPointerDown:(e,t)=>{if(Ke.current=t,!n||!n.current)return!1;const o=n.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),r=o?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!r)return;if(!1===L?.(e,r,fe))return!1;e.stopPropagation(),ye("default");const i=o.getRelativePointFromClient(0,0),l=pe.current?.ranges[pe.current?.ranges.length-1]??$.cellToRange(pe.current?.cell),s=o.toClipBounds(o.getRangeCoordsBounds(l)),c={x:0,y:0};s.x-i.x>e.nativeEvent.clientX?c.x=e.nativeEvent.clientX-(s.x-i.x):e.nativeEvent.clientX>=s.x-i.x+s.width&&(c.x=Math.max(0,e.nativeEvent.clientX-(s.x-i.x+s.width))+1),s.y-i.y>e.nativeEvent.clientY?c.y=e.nativeEvent.clientY-(s.y-i.y):e.nativeEvent.clientY>=s.y-i.y+s.height&&(c.y=Math.max(0,e.nativeEvent.clientY-(s.y-i.y+s.height))+1),A?.(l,e.nativeEvent,t),Gt.current={range:l,anchor:o.getAnchor(),cell:r,isMoving:!1,extrusion:c}},onPointerMoveOrWait:(e,t,o)=>{if(H||!n?.current||!pe.current||!Gt.current)return;const r=e.clientX-o.clientX,i=e.clientY-o.clientY;if(Gt.current.isMoving=Gt.current.isMoving||Math.abs(r)>Math.max(1,2)||Math.abs(i)>Math.max(1,2)||performance.now()-o.timeStamp>500,!Gt.current.isMoving)return;const l=Gt.current.anchor,s=Gt.current.extrusion;let c=n.current.getViewFromLocation(l),a=c.getCellCoordsFromClient(e.clientX-s.x,e.clientY-s.y,!0);if(!a)return;const u=Gt.current.cell,d=Gt.current.range,h=Q(),f=d.colEnd-d.colStart+1,p=Math.min(Math.max(0,u.colIndex-d.colStart),f-1),g=Math.min(h.right-f+1,Math.max(h.left,a.colIndex-p)),w=d.rowEnd-d.rowStart+1,m=Math.min(Math.max(0,u.rowIndex-d.rowStart),w-1),x=Math.min(h.bottom-w+1,Math.max(h.top,a.rowIndex-m)),y={colStart:g,colEnd:g+f-1,rowStart:x,rowEnd:x+w-1};$.isEqualRanges(Yt,y)&&!(e=>!e||!Ke.current||Ke.current.ctrlKey!==e.ctrlKey||Ke.current.shiftKey!==e.shiftKey||Ke.current.altKey!==e.altKey||Ke.current.metaKey!==e.metaKey)(e)||(Xt(y),B?.(y,e,t)),Ke.current=t,wo(c,a,n)},onPointerUp:(e,t)=>{Ke.current=t;const o=()=>{Xt(null),Gt.current=null,ye(null),n.current?.focus()};if(!Gt.current)return void o();const r=Gt.current.range,i=Yt;F?.(r,e,t),Promise.resolve(r&&i&&V?.(r,i,e,t)).finally(()=>{o()})}}),[Yt]),Jt=nn(Zt),Qt=t.useMemo(()=>({onPointerDown:Jt}),[Jt]),en=t.useRef(null),tn=t.useMemo(()=>{const e=$.isEqualSelectionCoords(fe,en.current)?en.current:fe;return en.current=e,e},[fe]),on=t.useCallback(o=>{let r=null,i="br";const l=[],s={stroke:C,fill:K,strokeWidth:.5},h=(e,t,n)=>{const r=o.toClipBounds(o.getRangeCoordsBounds(e),uo);if(!r)return;r.x=r.width>0?r.x:r.x-s.strokeWidth/2,r.y=r.height>0?r.y:r.y-s.strokeWidth/2,r.width=Math.max(r.width,s.strokeWidth),r.height=Math.max(r.height,s.strokeWidth);const i={key:`selection-fill-${t}`,range:e,...r,...s};if(n){const e=o.getCellCoordsAsRangeCoords(n);i.cell=n,i.pathBounds=o.toClipBounds(o.getRangeCoordsBounds(e),uo),i.pathBounds&&(i.pathBounds.width<=0||i.pathBounds.height<=0)&&(delete i.pathBounds,delete i.cell)}return ie(i)};let f=fe?go(fe):null;const p=f?.cell?o.getCellCoordsAsRangeCoords(f?.cell):ho;!f||f.ranges&&0!==f.ranges.length||(f={ranges:[p],rangeIndex:0,cell:f.cell});for(let e=0;f&&e<f.ranges.length;e++){const t=f.ranges[e],n=h(t,e,e===f.rangeIndex?f.cell:null);n&&l.push(n);const s=2,p=.5,g=o.toClipBounds(o.getRangeCoordsBounds(t,{top:0,left:0,right:0,bottom:0}),uo);if(g){const n=(f.ranges.length,4);l.push(ie({range:t,key:`selection-inside-edge-${e}`,x:g.x-1,y:g.y-1,width:Math.max(g.width+1,0),height:Math.max(g.height+1,0),style:{overflow:"hidden"},stroke:C,strokeWidth:n}))}if(1===f.ranges.length){const n=o.toClipBounds(o.getRangeCoordsBounds(t),uo);if(n){H||l.push(ie({range:t,key:`move-selection-hit-box-${e}`,x:n.width>1?n.x:n.x-(U/2+1),y:n.height>1?n.y:n.y-(U/2+1),width:Math.max(n.width+2,1),height:Math.max(n.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:Yt?void 0:"move",pointerEvents:"stroke"},strokeWidth:U,...Qt}));const o=s;l.push(ie({range:t,key:`selection-single-${e}`,x:n.x-o/2,y:n.y-o/2,width:Math.max(n.width+o/2,1),height:Math.max(n.height+o/2,1),stroke:Y,strokeWidth:o}))}}else{const n=o.toClipBounds(o.getRangeCoordsBounds(t,{top:-1,left:-1,right:-2,bottom:-2}),uo);n&&l.push(ie({range:t,key:`selection-multi-${e}`,x:n.width>1?n.x:n.x-p/2,y:n.height>1?n.y:n.y-p/2,width:Math.max(n.width,p)+1,height:Math.max(n.height,p)+1,stroke:Y,style:{overflow:"hidden"},strokeWidth:2}))}if(f.ranges.length>1&&e===f.rangeIndex){const n=o.getCellCoordsAsRangeCoords(f.cell),r=o.toClipBounds(o.getRangeCoordsBounds(n,{top:1,left:1,right:-1,bottom:-1}),uo);r&&l.push(ie({range:t,key:`selection-anchor-${e}`,x:r.x,y:r.y,width:Math.max(r.width,p),height:Math.max(r.height,p),stroke:Y,style:{overflow:"hidden"},strokeWidth:2}))}if(e===f.ranges.length-1){r=null,i=null;const e=t.rowStart===Q().top&&t.rowEnd===Q().bottom,n=t.colStart===Q().left&&t.colEnd===Q().right,l=o.getRangeCoordsBounds(t);let h=null;if(e||n){if(h=o.toClipBounds(l,uo),Object.keys(o.allViews()).length>1){const r=o.getVisibleRangeCoords(),i=o.allViews()[c],l=o.allViews()[a],s=o.allViews()[u],f=o.getAnchor();(n&&(f===a&&i||f===d&&s||!$.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd},r)&&!$.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd+1},r))||e&&(f===u&&i||f===d&&l||!$.isCellWithinRange({colIndex:t.colEnd,rowIndex:t.rowStart},r)&&!$.isCellWithinRange({colIndex:t.colEnd+1,rowIndex:t.rowStart},r)))&&(h=null)}}else h=o.toClipBounds(l,uo);if(!h||0===h.width||0===h.height)continue;r={x:h.x+h.width+1,y:h.y+h.height+1},0===h.width||0===h.height||t.rowStart===Q().top&&t.colStart===Q().left&&t.rowEnd===Q().bottom&&t.colEnd===Q().right||(e?(r.y=s,i="tr"):n&&(r.x=s,i="bl"))}}let g=null;if(Ee){const e=o.toClipBounds(o.getRangeCoordsBounds(Ee,{top:0,left:0,right:0,bottom:0}),uo);if(e){const t=2;g=ie({...s,range:Ee,key:"remove-selection",x:e.x,y:e.y,width:e.width,height:e.height,strokeWidth:t,stroke:X,fill:G})}}let w=null;if(be){const e=o.toClipBounds(o.getRangeCoordsBounds(be,{top:0,left:0,right:0,bottom:0}),uo);if(e){const t=2;w=ie({range:be,key:"selection-fill-outline",x:e.x-t/2,y:e.y-t/2,width:e.width+t/2,height:e.height+t/2,strokeWidth:t,stroke:Y,strokeDasharray:"3 2"})}}let m=null;!_&&r&&!Yt&&(m=t.createElement(to,{...r,corner:i,size:7.5,borderStroke:`${C} solid`,style:{borderRadius:1},background:Y,...Kt,key:"fillHandle"}));const x=[...l];if(g&&x.push(g),w&&x.push(w),m&&x.push(m),!Z&&He&&1===f?.ranges.length&&f.ranges[f.ranges.length-1]){const t=f.ranges[f.ranges.length-1],r=t.rowStart===Q().top&&t.rowEnd===Q().bottom,i=t.colStart===Q().left&&t.colEnd===Q().right,l={view:o,range:t,borderStroke:`${Y} solid`,background:C,selectionTouchPointerHandler:Ge,...J,onTouchSelectStart:e=>Re(e),onTouchSelectEnd:()=>Re(null),currentTouchAnchor:Me};x.push(e.jsx(ao,{anchor:i?"b":r?"r":"br",scrollableElement:n.current,...l},"touch-select-handle-after")),x.push(e.jsx(ao,{anchor:i?"t":r?"l":"tl",scrollableElement:n.current,...l},"touch-select-handle-before"))}if(Yt){const e=o.toClipBounds(o.getRangeCoordsBounds(Yt,{top:1,left:1,right:1,bottom:1}),uo);e&&x.push(ie({range:Yt,key:"selection-move-outline",x:e.x-q/2,y:e.y-q/2,width:Math.max(e.width+q/2,1),height:Math.max(e.height+q/2,1),stroke:Y,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:q}))}return e.jsx("div",{children:x},"selection")},[tn,Ee,_,be,H,Yt,Q,C,Y,K,X,G,Z,J,Me]),rn=t.useMemo(()=>{const e=()=>n.current;return[new wn("moveToPageDown",e,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>ht(!1)),new wn("selectToPageDown",e,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[De]}]},()=>ht(!0)),new wn("moveToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[ze]}]},()=>pt(!1)),new wn("selectToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[ze,De]}]},()=>pt(!0)),new wn("moveToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>ft(!1)),new wn("selectToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[De]}]},()=>ft(!0)),new wn("moveToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[ze]}]},()=>gt(!1)),new wn("selectToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[ze,De]}]},()=>gt(!0)),new wn("selectColumn",e,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[je]}},Qe),new wn("selectRow",e,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[De]}},tt),new wn("selectToColumnStart",e,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>ot(!0)),new wn("selectToColumnEnd",e,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>rt(!0)),new wn("moveToRowStart",e,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>it(!1)),new wn("selectToRowStart",e,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[De]}]},()=>it(!0)),new wn("moveToSheetStart",e,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[je]}]},()=>lt(!1)),new wn("selectToSheetStart",e,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[je,De]}]},()=>lt(!0)),new wn("moveToRowEnd",e,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>st(!1)),new wn("selectToRowEnd",e,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[De]}]},()=>st(!0)),new wn("moveToSheetEnd",e,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[je]}]},()=>ct(!1)),new wn("selectToSheetEnd",e,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[je,De]}]},()=>ct(!0)),new wn("scrollToActiveCoords",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[je]}},nt),new wn("scrollToActiveCoordsClearSelection",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[De]}},()=>{We(),Wt(fe.cell,!0)}),new wn("traverseSelectionRight",e,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},mt),new wn("traverseSelectionLeft",e,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[De]}},wt),new wn("traverseSelectionDown",e,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},yt),new wn("traverseSelectionUp",e,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[De]},{key:"NumpadEnter",modifiers:[De]}]},xt),new wn("moveLeft",e,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},Et),new wn("selectLeft",e,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[De]}]},_t),new wn("moveContentfulLeft",e,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[je]}]},Ct),new wn("selectContentfulLeft",e,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[je,De]}]},It),new wn("moveRight",e,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},Mt),new wn("selectRight",e,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[De]}]},Rt),new wn("moveContentfulRight",e,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[je]}]},kt),new wn("selectContentfulRight",e,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[je,De]}]},Tt),new wn("moveUp",e,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},Pt),new wn("selectUp",e,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[De]}]},Ot),new wn("moveContentfulUp",e,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[je]}]},Dt),new wn("selectContentfulUp",e,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[je,De]}]},zt),new wn("moveDown",e,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},jt),new wn("selectDown",e,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[De]}]},At),new wn("moveContentfulDown",e,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[je]}]},$t),new wn("selectContentfulDown",e,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[je,De]}]},Bt),new wn("selectVisible",e,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[ze]}},ut),new wn("traverseSelectionPreviousRange",e,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[je,ze]}},bt),new wn("traverseSelectionNextRange",e,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[je,ze]}},vt),new wn("traverseSelectionCorners",e,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[je]}},St)]},[]);return t.useMemo(()=>{o?.addCommands(rn,!0)},[o]),{selection:tn,setSelectionCell:Wt,setSelectionRanges:we,overlay:on,cursor:xe,onPointerDown:Xe,clearLastSelection:Ft,newSelection:Fe,modifySelection:Be,appendSelection:Ve,clearSelections:We,isEntire:Vt,navigate:Ze,navigateSelection:Je}};
|