import{__exports as e}from"../../../../_virtual/spanningCellManager.mjs";import{__require as n}from"./alignSpanningCell.mjs";import{__require as r}from"./calculateSpanningCellWidth.mjs";import{__require as t}from"./makeRangeConfig.mjs";import{__require as o}from"./utils.mjs";var a;function i(){if(a)return e;a=1,Object.defineProperty(e,"__esModule",{value:!0}),e.createSpanningCellManager=void 0;const i=n(),l=r(),s=t(),g=o(),u=(e,n)=>n.find(n=>(0,g.isCellInRange)(e,n)),p=(e,n)=>{const r=(0,l.calculateSpanningCellWidth)(e,n),t=(0,i.wrapRangeContent)(e,r,n),o=(0,i.alignVerticalRangeContent)(e,t,n);return{...e,extractBorderContent:r=>{const{topLeft:t}=e,a=(0,g.sumArray)(n.rowHeights.slice(t.row,r))+(r-t.row-1);return o[a]},extractCellContent:r=>{const{topLeft:t}=e,{drawHorizontalLine:a,rowHeights:i}=n,l=r-t.row,s=(0,g.sequence)(t.row+1,r).filter(e=>!(null==a?void 0:a(e,i.length))).length,u=(0,g.sumArray)(i.slice(t.row,r))+l-s;return o.slice(u,u+i[r])},height:t.length,width:r}};return e.createSpanningCellManager=e=>{const{spanningCellConfigs:n,columnsConfig:r}=e,t=n.map(e=>(0,s.makeRangeConfig)(e,r)),o={};let a=[],i=[];return{getContainingRange:(n,r)=>{var l;const s=(null==r?void 0:r.mapped)?i[n.row]:n.row,g=u({...n,row:s},t);if(!g)return;if(0===a.length)return p(g,{...e,rowHeights:a});const c=(e=>{const{row:n,col:r}=e.topLeft;return`${n}/${r}`})(g);return null!==(l=o[c])&&void 0!==l||(o[c]=p(g,{...e,rowHeights:a})),o[c]},inSameRange:(e,n)=>((e,n,r)=>{const t=u(e,r),o=u(n,r);return!(!t||!o)&&(0,g.areCellEqual)(t.topLeft,o.topLeft)})(e,n,t),rowHeights:a,rowIndexMapping:i,setRowHeights:e=>{a=e},setRowIndexMapping:e=>{i=(0,g.flatten)(e.map((e,n)=>Array.from({length:e},()=>n)))}}},e}export{i as __require};