import{__exports as r}from"../../../../_virtual/drawBorder.mjs";import{__require as o}from"./drawContent.mjs";var e;function t(){return e||(e=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.createTableBorderGetter=r.drawBorderBottom=r.drawBorderJoin=r.drawBorderTop=r.drawBorder=r.createSeparatorGetter=r.drawBorderSegments=void 0;const e=o();r.drawBorderSegments=(r,o)=>{const{separator:e,horizontalBorderIndex:t,spanningCellManager:n}=o;return r.map((r,o)=>{const i=e.body.repeat(r);if(void 0===t)return i;const d=null==n?void 0:n.getContainingRange({col:o,row:t});if(!d)return i;const{topLeft:a}=d;return t===a.row?i:o!==a.col?"":d.extractBorderContent(t)})};r.createSeparatorGetter=r=>{const{separator:o,spanningCellManager:e,horizontalBorderIndex:t,rowCount:n}=r;return(r,i)=>{const d=null==e?void 0:e.inSameRange;if(void 0!==t&&d){const e={col:r,row:t-1},a={col:r-1,row:t},l={col:r-1,row:t-1},s={col:r,row:t},w=[[l,e],[e,s],[s,a],[a,l]];if(0===r)return d(s,e)&&o.bodyJoinOuter?o.bodyJoinOuter:o.left;if(r===i)return d(l,a)&&o.bodyJoinOuter?o.bodyJoinOuter:o.right;if(0===t)return d(s,a)?o.body:o.join;if(t===n)return d(e,l)?o.body:o.join;const p=w.map(r=>d(...r)).filter(Boolean).length;if(0===p)return o.join;if(4===p)return"";if(2===p)return d(...w[1])&&d(...w[3])&&o.bodyJoinInner?o.bodyJoinInner:o.body;if(1===p){if(!(o.joinRight&&o.joinLeft&&o.joinUp&&o.joinDown))throw new Error(`Can not get border separator for position [${t}, ${r}]`);return d(...w[0])?o.joinDown:d(...w[1])?o.joinLeft:d(...w[2])?o.joinUp:o.joinRight}throw new Error("Invalid case")}return 0===r?o.left:r===i?o.right:o.join}};r.drawBorder=(o,t)=>{const n=(0,r.drawBorderSegments)(o,t),{drawVerticalLine:i,horizontalBorderIndex:d,spanningCellManager:a}=t;return(0,e.drawContent)({contents:n,drawSeparator:i,elementType:"border",rowIndex:d,separatorGetter:(0,r.createSeparatorGetter)(t),spanningCellManager:a})+"\n"};r.drawBorderTop=(o,e)=>{const{border:t}=e,n=(0,r.drawBorder)(o,{...e,separator:{body:t.topBody,join:t.topJoin,left:t.topLeft,right:t.topRight}});return"\n"===n?"":n};r.drawBorderJoin=(o,e)=>{const{border:t}=e;return(0,r.drawBorder)(o,{...e,separator:{body:t.joinBody,bodyJoinInner:t.bodyJoin,bodyJoinOuter:t.bodyLeft,join:t.joinJoin,joinDown:t.joinMiddleDown,joinLeft:t.joinMiddleLeft,joinRight:t.joinMiddleRight,joinUp:t.joinMiddleUp,left:t.joinLeft,right:t.joinRight}})};r.drawBorderBottom=(o,e)=>{const{border:t}=e;return(0,r.drawBorder)(o,{...e,separator:{body:t.bottomBody,join:t.bottomJoin,left:t.bottomLeft,right:t.bottomRight}})};r.createTableBorderGetter=(o,e)=>(t,n)=>{const i={...e,horizontalBorderIndex:t};return 0===t?(0,r.drawBorderTop)(o,i):t===n?(0,r.drawBorderBottom)(o,i):(0,r.drawBorderJoin)(o,i)}}(r)),r}export{t as __require};