/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();define(["require","exports","wijmo/wijmo.pdf","wijmo/wijmo.grid","wijmo/wijmo","wijmo/wijmo.grid.pdf"],function(e,t,o,r,i,n){"use strict";function l(){var e,t;return(e=window.wijmo)&&(t=e.grid)&&t.multirow}function s(){var e,t;return(e=window.wijmo)&&(t=e.grid)&&t.sheet}function a(){var e;return(e=window.wijmo)&&e.olap}function h(e,t,o){if(void 0===o&&(o=!1),t&&e)for(var r in t){var n=t[r],l=e[r];if(i.isObject(n)){if(void 0===l||!i.isObject(l)&&o){if(i.isFunction(n.clone)){e[r]=l=n.clone();continue}e[r]=l={}}i.isObject(l)&&h(e[r],n,o)}else(void 0===l||o&&void 0!==n)&&(e[r]=n)}return e}Object.defineProperty(t,"__esModule",{value:!0});var d=n||t;window.wijmo=window.wijmo||{},window.wijmo.grid=window.wijmo.grid||{},window.wijmo.grid.pdf=d;var c;!function(e){e[e.ActualSize=0]="ActualSize",e[e.PageWidth=1]="PageWidth",e[e.SinglePage=2]="SinglePage"}(c=t.ScaleMode||(t.ScaleMode={}));var u;!function(e){e[e.All=0]="All",e[e.Selection=1]="Selection"}(u=t.ExportMode||(t.ExportMode={}));var g=function(e){function t(t,o,r,n,l,s,a,h,d){var c=e.call(this,t,o)||this;return c.cancelBorders=!1,c._cell=i.asType(r,HTMLElement,!0),c._canvas=n,c._clientRect=l,c._contentRect=s,c._textTop=a,c._style=h,c._getFormattedCell=d,c}return __extends(t,e),Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clientRect",{get:function(){return this._clientRect},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentRect",{get:function(){return this._contentRect},enumerable:!0,configurable:!0}),t.prototype.getFormattedCell=function(){return i.asFunction(this._getFormattedCell)()},Object.defineProperty(t.prototype,"style",{get:function(){return this._style},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textTop",{get:function(){return this._textTop},enumerable:!0,configurable:!0}),t}(r.CellRangeEventArgs);t.PdfFormatItemEventArgs=g;var p,f=function(){function e(){}return e.draw=function(e,t,r,n,l){i.assert(!!e,"The flex argument cannot be null."),i.assert(!!t,"The doc argument cannot be null.");var s=h({},l);h(s,this.DefaultDrawSettings),s.scaleMode=null==r?c.ActualSize:null==n?c.PageWidth:c.SinglePage;try{s.recalculateStarWidths&&e.columns._updateStarSizes(o.ptToPx(t.width)),this._draw(e,t,null,r,n,s)}finally{s.recalculateStarWidths&&e.invalidate(!0)}},e.drawToPosition=function(e,t,r,n,l,s){i.assert(!!e,"The flex argument cannot be null."),i.assert(!!t,"The doc argument cannot be null."),i.assert(!!r,"The point argument cannot be null.");var a=h({},s);h(a,this.DefaultDrawSettings),a.scaleMode=null==n?c.ActualSize:null==l?c.PageWidth:c.SinglePage;try{a.recalculateStarWidths&&e.columns._updateStarSizes(o.ptToPx(t.width)),this._draw(e,t,r,n,l,a)}finally{a.recalculateStarWidths&&e.invalidate(!0)}},e.export=function(e,t,r){i.assert(!!e,"The flex argument cannot be null."),i.assert(!!t,"The fileName argument cannot be empty."),h(r=h({},r),this.DefaultExportSettings);var n=r.documentOptions.ended;r.documentOptions.ended=function(e,r){n&&!1===n.apply(l,[e,r])||o.saveBlob(r.blob,t),e.dispose()};var l=new o.PdfDocument(r.documentOptions);try{r.recalculateStarWidths&&e.columns._updateStarSizes(o.ptToPx(l.width)),this._draw(e,l,null,null,null,r),l.end()}finally{r.recalculateStarWidths&&e.invalidate(!0)}},e._draw=function(e,t,o,n,l,s){var a=null!=o,h=new i.Size(t.width,t.height);o||(o=new i.Point(0,t.y)),i.isArray(s.embeddedFonts)&&s.embeddedFonts.forEach(function(e){t.registerFont(e)});var d=x.getSelection(e,s.exportMode),c=this._getGridRenderer(e,s,d,this.BorderWidth,!0),u=new i.Rect(o.x||0,o.y||0,n||h.width,l||h.height),g=this._getScaleFactor(c,s.scaleMode,u),f=this._getPages(c,d,u,s,a,g);(p=document.createElement("div")).setAttribute(r.FlexGrid._WJS_MEASURE,"true"),p.style.visibility="hidden",e.hostElement.appendChild(p);try{for(var w=0;w<f.length;w++){w>0&&t.addPage();var b=f[w],_=0===b.pageCol?u.left:0,m=0===b.pageRow?u.top:0;t.saveState(),t.paths.rect(0,0,h.width,h.height).clip(),t.scale(g,g,new i.Point(_,m)),t.translate(_,m);var y=this._getGridRenderer(e,s,b.range,this.BorderWidth,w===f.length-1);y.render(t),t.restoreState(),t.x=_,t.y=m+y.renderSize.height*g}}finally{p&&(i.removeChild(p),p=null)}},e._getScaleFactor=function(e,t,o){var r=1;if(t===c.ActualSize)return r;var i=e.renderSize;if(t===c.SinglePage)(n=Math.min(o.width/i.width,o.height/i.height))<1&&(r=n);else{var n=o.width/i.width;n<1&&(r=n)}return r},e._getPages=function(e,t,r,i,n,l){var s=this,a=[],h=[],d=o.pxToPt,u=e.flex,g=e.showColumnHeader,p=e.showColumnFooter,f=e.showRowHeader,w=g?d(u.columnHeaders.height):0,b=p?d(u.columnFooters.height):0,_=f?d(u.rowHeaders.width):0,m=i.scaleMode===c.ActualSize||i.scaleMode===c.PageWidth,C=i.scaleMode===c.ActualSize,R=(r.width-r.left)*(1/l),v=(r.height-r.top)*(1/l),S=r.width*(1/l),x=r.height*(1/l),P=w+b,z=_,W=n&&i.scaleMode==c.ActualSize;if(m){var H=0;t.forEach(u.cells,function(e,t,o,r){var i=a.length?x:v;if(y.isRenderableRow(e)){var n=d(e.renderHeight);H++,P+=n,(g||H>1)&&(P-=s.BorderWidth),P>i&&(w+n>i||W?(a.push(r),P=w):(a.push(r-1),P=w+n),g&&(P-=s.BorderWidth))}})}var M=t.length()-1;if(M<0&&(M=0),a.length&&a[a.length-1]===M||a.push(M),C)for(var j=0,A=t.leftCol;A<=t.rightCol;A++){var L=u.columns[A];if(L.isVisible){var B=d(L.renderWidth),V=h.length?S:R;j++,z+=B,(f||j>1)&&(z-=this.BorderWidth),z>V&&(_+B>V||W?(h.push(A),z=_):(h.push(A-1),z=_+B),f&&(z-=this.BorderWidth))}}h.length&&h[h.length-1]===t.rightCol||h.push(t.rightCol);for(var O=[],F=!1,E=1,k=n&&i.maxPages>0?1:i.maxPages,A=0;A<a.length&&!F;A++)for(var D=0;D<h.length&&!F;D++,E++)if(!(F=E>k)){var G=0==A?0:a[A-1]+1,I=0==D?t.leftCol:h[D-1]+1;O.push(new T(t.subrange(G,a[A]-G+1,I,h[D]),D,A))}return O},e._getGridRenderer=function(e,t,o,r,i){return new(l()&&e instanceof l().MultiRow&&_||s()&&e instanceof s().FlexSheet&&b||a()&&e instanceof a().PivotGrid&&m||w)(e,t,o,r,i)},e.BorderWidth=1,e.DefaultDrawSettings={maxPages:Number.MAX_VALUE,exportMode:u.All,repeatMergedValuesAcrossPages:!0,recalculateStarWidths:!0,styles:{cellStyle:{font:new o.PdfFont,padding:1.5,verticalAlign:"middle"},headerCellStyle:{font:{weight:"bold"}}}},e.DefaultExportSettings=h({scaleMode:c.PageWidth,documentOptions:{compress:!1,pageSettings:{margins:{left:36,right:36,top:18,bottom:18}}}},e.DefaultDrawSettings),e}();t.FlexGridPdfConverter=f;var w=function(){function e(e,t,o,i,n){this._flex=e,this._borderWidth=i,this._lastPage=n,this._settings=t||{},this._topLeft=new C(this,e.topLeftCells,this.showRowHeader&&this.showColumnHeader?new x(e,[new r.CellRange(0,0,e.topLeftCells.rows.length-1,e.topLeftCells.columns.length-1)]):new x(e,[]),i),this._rowHeader=new C(this,e.rowHeaders,this.showRowHeader?o.clone(0,e.rowHeaders.columns.length-1):new x(e,[]),i),this._columnHeader=new C(this,e.columnHeaders,this.showColumnHeader?new x(e,[new r.CellRange(0,o.leftCol,e.columnHeaders.rows.length-1,o.rightCol)]):new x(e,[]),i),this._cells=new C(this,e.cells,o,i),this._bottomLeft=new C(this,e.bottomLeftCells,this.showRowHeader&&this.showColumnFooter?new x(e,[new r.CellRange(0,0,e.bottomLeftCells.rows.length-1,e.bottomLeftCells.columns.length-1)]):new x(e,[]),i),this._columnFooter=new C(this,e.columnFooters,this.showColumnFooter?new x(e,[new r.CellRange(0,o.leftCol,e.columnFooters.rows.length-1,o.rightCol)]):new x(e,[]),i)}return Object.defineProperty(e.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),e.prototype.render=function(e){var t=Math.max(0,Math.max(this._topLeft.renderSize.width,this._rowHeader.renderSize.width)-this._borderWidth),o=Math.max(0,Math.max(this._topLeft.renderSize.height,this._columnHeader.renderSize.height)-this._borderWidth);this._topLeft.render(e,0,0),this._rowHeader.render(e,0,o),this._columnHeader.render(e,t,0),this._cells.render(e,t,o),o=Math.max(0,o+this._cells.renderSize.height-this._borderWidth),this._bottomLeft.render(e,0,o),this._columnFooter.render(e,t,o)},Object.defineProperty(e.prototype,"flex",{get:function(){return this._flex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderSize",{get:function(){var e=Math.max(this._topLeft.renderSize.height,this._columnHeader.renderSize.height)+Math.max(this._rowHeader.renderSize.height,this._cells.renderSize.height)+Math.max(this._bottomLeft.renderSize.height,this._columnFooter.renderSize.height),t=Math.max(this._topLeft.renderSize.width,this._rowHeader.renderSize.width)+Math.max(this._columnHeader.renderSize.width,this._cells.renderSize.width);return this._columnHeader.visibleRows>0&&(e-=this._borderWidth),this._columnFooter.visibleRows>0&&(e-=this._borderWidth),this._rowHeader.visibleColumns>0&&(t-=this._borderWidth),new i.Size(t,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnHeader",{get:function(){return!!(this._flex.headersVisibility&r.HeadersVisibility.Column)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showRowHeader",{get:function(){return!!(this._flex.headersVisibility&r.HeadersVisibility.Row)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnFooter",{get:function(){return this._lastPage&&this._flex.columnFooters.rows.length>0},enumerable:!0,configurable:!0}),e.prototype.alignMergedTextToTheTopRow=function(e){return!1},e.prototype.getCellValue=function(e,t,o){return e.getCellData(o,t,!0)},e.prototype.getColumn=function(e,t,o){return e.columns[t]},e.prototype.isAlternatingRow=function(e){return e.index%2!=0},e.prototype.isGroupRow=function(e){return e instanceof r.GroupRow&&e.hasChildren},e.prototype.isMergeableCell=function(e,t){return!0},e.prototype.getCellStyle=function(e,t,o){var i=this.settings.styles,n=h({},i.cellStyle),l=this._flex;switch(e.cellType){case r.CellType.Cell:this.isGroupRow(t)?h(n,i.groupCellStyle,!0):this.isAlternatingRow(t)&&h(n,i.altCellStyle,!0);break;case r.CellType.ColumnHeader:case r.CellType.RowHeader:case r.CellType.TopLeft:case r.CellType.BottomLeft:h(n,i.headerCellStyle,!0);break;case r.CellType.ColumnFooter:h(n,i.headerCellStyle,!0),h(n,i.footerCellStyle,!0)}return!this.settings.customCellContent&&l._getShowErrors()&&l._getError(e,t.index,o.index)&&h(n,i.errorCellStyle,!0),n},e}(),b=function(e){function t(t,o,r,i,n){return e.call(this,t,o,r,i,n)||this}return __extends(t,e),t.prototype.getCellValue=function(t,o,i){return t.cellType===r.CellType.Cell?t.rows[i]instanceof s().HeaderRow?this.flex.columnHeaders.getCellData(i,o,!0):this.flex.getCellValue(i,o,!0):e.prototype.getCellValue.call(this,t,o,i)},t.prototype.getCellStyle=function(t,r,i){var n=e.prototype.getCellStyle.call(this,t,r,i),l=this.flex.selectedSheet.findTable(r.index,i.index);if(l){var s=l.getRange(),a=r.index-s.topRow,d=i.index-s.leftCol,c=l._getTableCellAppliedStyles(a,d);c&&(c.font=new o.PdfFont(c.fontFamily,o._asPt(c.fontSize,!0,void 0),c.fontStyle,c.fontWeight)),h(n,c,!0)}return n},Object.defineProperty(t.prototype,"showColumnHeader",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showRowHeader",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showColumnFooter",{get:function(){return!1},enumerable:!0,configurable:!0}),t}(w),_=function(e){function t(t,o,r,i,n){return e.call(this,t,o,r,i,n)||this}return __extends(t,e),t.prototype.getColumn=function(e,t,o){return this.flex.getBindingColumn(e,o,t)},t.prototype.isAlternatingRow=function(t){return t instanceof l()._MultiRow?t.dataIndex%2!=0:e.prototype.isAlternatingRow.call(this,t)},t.prototype.isMergeableCell=function(e,t){return!0},t}(w),m=function(e){function t(t,o,r,i,n){return e.call(this,t,o,r,i,n)||this}return __extends(t,e),t.prototype.alignMergedTextToTheTopRow=function(e){return!this.flex.centerHeadersVertically&&(e.cellType===r.CellType.ColumnHeader||e.cellType===r.CellType.RowHeader)},t}(w),y=function(){function e(e,t){this._panel=e,this._range=t.clone()}return e.isRenderableRow=function(e){return e.isVisible&&!(e instanceof r._NewRowTemplate)},Object.defineProperty(e.prototype,"visibleRows",{get:function(){var e=this;return null==this._visibleRows&&(this._visibleRows=0,this._range.forEach(this._panel,function(t){e.isRenderableRow(t)&&e._visibleRows++})),this._visibleRows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visibleColumns",{get:function(){if(null==this._visibleColumns&&(this._visibleColumns=0,this._range.isValid))for(var e=this._range.leftCol;e<=this._range.rightCol;e++)this._panel.columns[e].isVisible&&this._visibleColumns++;return this._visibleColumns},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){if(null==this._size){var e=this._range.getRenderSize(this._panel);this._size=new i.Size(o.pxToPt(e.width),o.pxToPt(e.height))}return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"range",{get:function(){return this._range},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"panel",{get:function(){return this._panel},enumerable:!0,configurable:!0}),e.prototype.isRenderableRow=function(t){return e.isRenderableRow(t)},e}(),C=function(e){function t(t,o,r,i){var n=e.call(this,o,r)||this;return n._gr=t,n._borderWidth=i,n}return __extends(t,e),Object.defineProperty(t.prototype,"gr",{get:function(){return this._gr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderSize",{get:function(){return null==this._renderSize&&(this._renderSize=this.size.clone(),this.visibleColumns>1&&(this._renderSize.width-=this._borderWidth*(this.visibleColumns-1)),this.visibleRows>1&&(this._renderSize.height-=this._borderWidth*(this.visibleRows-1))),this._renderSize},enumerable:!0,configurable:!0}),t.prototype.getRangeWidth=function(e,t){for(var r=0,i=0,n=this.panel,l=e;l<=t;l++){var s=n.columns[l];s.isVisible&&(i++,r+=s.renderWidth)}return r=o.pxToPt(r),i>1&&(r-=this._borderWidth*(i-1)),r},t.prototype.getRangeHeight=function(e,t){for(var r=0,i=0,n=this.panel,l=e;l<=t;l++){var s=n.rows[l];this.isRenderableRow(s)&&(i++,r+=s.renderHeight)}return r=o.pxToPt(r),i>1&&(r-=this._borderWidth*(i-1)),r},t.prototype.render=function(e,t,o){var r=this,n=this.range,l=this.panel,s=new v(this._gr.flex),a=new S(l,0,0,0,0),h=new R(this,e,this._borderWidth);if(n.isValid){for(var d={},c=n.leftCol;c<=n.rightCol;c++)d[c]=o;n.forEach(l,function(e,o,c){if(r.isRenderableRow(e))for(var u=t,g=n.leftCol;g<=n.rightCol;g++){var p,f=r.gr.getColumn(l,g,c),w=void 0,b=void 0,_=!1,m=void 0;if(f.isVisible){var y=r._getCellValue(g,c),C=null;if(r.gr.isMergeableCell(f,e)&&(C=s.getMergedRange(l,c,g)))if(a.copyFrom(C),C.topRow!==C.bottomRow)C.firstVisibleRow===c||c===o.topRow?(_=!0,p=r.gr.settings.repeatMergedValuesAcrossPages?y:C.firstVisibleRow===c?y:"",w=r.getRangeHeight(c,Math.min(C.bottomRow,o.bottomRow)),b=r.getRangeWidth(g,g)):b=r.getRangeWidth(g,g);else{_=!0,p=r.gr.settings.repeatMergedValuesAcrossPages?y:g===C.leftCol?y:"",w=r.getRangeHeight(c,c),b=r.getRangeWidth(Math.max(n.leftCol,C.leftCol),Math.min(n.rightCol,C.rightCol)),m=Math.min(n.rightCol,C.rightCol);for(var R=g+1;R<=m;R++)d[R]+=w-r._borderWidth}else a.setRange(c,g,c,g),_=!0,p=y,w=r.getRangeHeight(c,c),b=r.getRangeWidth(g,g);_&&h.renderCell(p,e,f,a,new i.Rect(u,d[g],b,w)),w&&(d[g]+=w-r._borderWidth),b&&(u+=b-r._borderWidth),m&&(g=m)}}})}},t.prototype._getCellValue=function(e,t){var o=this.panel,i=this.gr.getCellValue(o,e,t),n=o.columns[e].isContentHtml;if(!i&&o.cellType===r.CellType.Cell){var l=o.rows[t];l instanceof r.GroupRow&&l.dataItem&&l.dataItem.groupDescription&&e===o.columns.firstVisibleIndex&&(n=!0,i=l.getGroupHeader())}return n&&(this._cvtHtml||(this._cvtHtml=document.createElement("div")),this._cvtHtml.innerHTML=i,i=this._cvtHtml.textContent),i},t}(y),R=function(){function e(e,t,o){this._pr=e,this._area=t,this._borderWidth=o}return e.prototype.renderCell=function(e,t,n,l,s){var a,h=t.grid,d=this._pr.panel,c=function(){var e=l.topRow,t=l.leftCol,o=d.getCellElement(e,t);return o||(p.innerHTML=p.className=p.style.cssText="",h.cellFactory.updateCell(d,e,t,p)),o||p},u=!!this._pr.gr.settings.customCellContent,f=null,w=this._pr.gr.getCellStyle(d,t,n);if(u&&(f=c()),u&&!(e=f.textContent.trim())&&this._isBooleanCell(n,t,d)&&(e=this._extractCheckboxValue(f)+""),u){var b=function(e){return e.className=e.className.replace("wj-state-selected",""),e.className=e.className.replace("wj-state-multi-selected",""),window.getComputedStyle(e)}(f);w.color=b.color,w.backgroundColor=b.backgroundColor,w.borderColor=b.borderColor||b.borderRightColor||b.borderBottomColor||b.borderLeftColor||b.borderTopColor,w.font=new o.PdfFont(b.fontFamily,o._asPt(b.fontSize,!0,void 0),b.fontStyle,b.fontWeight),w.textAlign=b.textAlign}if(w.boxSizing="border-box",w.borderWidth=this._borderWidth,w.borderStyle="solid",w.textAlign||t instanceof r.GroupRow&&!n.aggregate||(w.textAlign=n.getAlignment()),d.cellType===r.CellType.Cell&&h.rows.maxGroupLevel>=0&&l.leftCol===h.columns.firstVisibleIndex){var _=t instanceof r.GroupRow?Math.max(t.level,0):h.rows.maxGroupLevel+1,m=o._asPt(w.paddingLeft||w.padding),y=o.pxToPt(_*h.treeIndent);w.paddingLeft=m+y}var C,R=this._measureCell(e,n,t,d,w,s),v=l.rowSpan>1&&l.visibleRowsCount>1&&this._pr.gr.alignMergedTextToTheTopRow(d);v&&(C=new i.Rect(R.contentRect.left,R.contentRect.top,R.contentRect.width,R.contentRect.height/(l.visibleRowsCount||1)),R.textRect=this._calculateTextRect(e,n,t,d,C,w)),i.isFunction(this._pr.gr.settings.formatItem)&&((a=new g(d,l,f,this._area,R.rect,R.contentRect,R.textRect.top,w,function(){return f||c()})).data=e,this._pr.gr.settings.formatItem(a),a.data!==e&&(e=i.asString(a.data),R.textRect=this._calculateTextRect(e,n,t,d,v?C:R.contentRect,w))),this._renderCell(e,t,n,l,R,w,!a||!a.cancel,!a||!a.cancelBorders)},e.prototype._renderCell=function(e,t,o,r,i,n,l,s){(l||s)&&(this._isBooleanCellAndValue(e,o,t,this._pr.panel)?this._renderBooleanCell(e,i,n,l,s):this._renderTextCell(e,i,n,l,s))},e.prototype._isBooleanCellAndValue=function(e,t,o,r){return this._isBooleanCell(t,o,r)&&this._isBoolean(e)},e.prototype._isBooleanCell=function(e,t,o){return e.dataType===i.DataType.Boolean&&o.cellType===r.CellType.Cell&&!this._pr.gr.isGroupRow(t)},e.prototype._isBoolean=function(e){var t=i.isString(e)&&e.toLowerCase();return"true"===t||"false"===t||!0===e||!1===e},e.prototype._measureCell=function(e,t,r,n,l,s){this._decompositeStyle(l);var a=s.left,h=s.top,d=s.height,c=s.width,u=this._parseBorder(l),g=u.left.width,p=u.top.width,f=u.bottom.width,w=u.right.width,b=this._parsePadding(l),_=0,m=0,y=0,C=0;if("content-box"===l.boxSizing||void 0===l.boxSizing)_=b.top+d+b.bottom,m=b.left+c+b.right,y=d,C=c;else{if("border-box"!==l.boxSizing)throw"Invalid value: "+l.boxSizing;o._IE&&l instanceof CSSStyleDeclaration?(_=b.top+b.bottom+d,m=b.left+b.right+c):(_=d-p-f,m=c-g-w),y=_-b.top-b.bottom,C=m-b.left-b.right}var s=new i.Rect(a,h,c,d),R=new i.Rect(a+g,h+p,m,_),v=new i.Rect(a+g+b.left,h+p+b.top,C,y);return{rect:s,clientRect:R,contentRect:v,textRect:this._calculateTextRect(e,t,r,n,v,l)}},e.prototype._decompositeStyle=function(e){if(e){var t;(t=e.borderColor)&&(e.borderLeftColor||(e.borderLeftColor=t),e.borderRightColor||(e.borderRightColor=t),e.borderTopColor||(e.borderTopColor=t),e.borderBottomColor||(e.borderBottomColor=t)),(t=e.borderWidth)&&(e.borderLeftWidth||(e.borderLeftWidth=t),e.borderRightWidth||(e.borderRightWidth=t),e.borderTopWidth||(e.borderTopWidth=t),e.borderBottomWidth||(e.borderBottomWidth=t)),(t=e.borderStyle)&&(e.borderLeftStyle||(e.borderLeftStyle=t),e.borderRightStyle||(e.borderRightStyle=t),e.borderTopStyle||(e.borderTopStyle=t),e.borderBottomStyle||(e.borderBottomStyle=t)),(t=e.padding)&&(e.paddingLeft||(e.paddingLeft=t),e.paddingRight||(e.paddingRight=t),e.paddingTop||(e.paddingTop=t),e.paddingBottom||(e.paddingBottom=t))}},e.prototype._parseBorder=function(e){var t={left:{width:0},top:{width:0},bottom:{width:0},right:{width:0}};return"none"!==e.borderLeftStyle&&(t.left={width:o._asPt(e.borderLeftWidth),style:e.borderLeftStyle,color:e.borderLeftColor}),"none"!==e.borderTopStyle&&(t.top={width:o._asPt(e.borderTopWidth),style:e.borderTopStyle,color:e.borderTopColor}),"none"!==e.borderBottomStyle&&(t.bottom={width:o._asPt(e.borderBottomWidth),style:e.borderBottomStyle,color:e.borderBottomColor}),"none"!==e.borderRightStyle&&(t.right={width:o._asPt(e.borderRightWidth),style:e.borderRightStyle,color:e.borderRightColor}),t},e.prototype._parsePadding=function(e){return{left:o._asPt(e.paddingLeft),top:o._asPt(e.paddingTop),bottom:o._asPt(e.paddingBottom),right:o._asPt(e.paddingRight)}},e.prototype._renderEmptyCell=function(e,t,r,i){var n=e.rect.left,l=e.rect.top,s=e.clientRect.width,a=e.clientRect.height,h=e.clientRect.left-e.rect.left,d=e.clientRect.top-e.rect.top,c=e.rect.top+e.rect.height-(e.clientRect.top+e.clientRect.height),u=e.rect.left+e.rect.width-(e.clientRect.left+e.clientRect.width);if(i&&(h||u||c||d)){var g=t.borderLeftColor||t.borderColor,p=t.borderRightColor||t.borderColor,f=t.borderTopColor||t.borderColor,w=t.borderBottomColor||t.borderColor;if(h&&d&&c&&u&&h===u&&h===c&&h===d&&g===p&&g===w&&g===f){var b=h,_=b/2;this._area.paths.rect(n+_,l+_,s+b,a+b).stroke(new o.PdfPen(g,b))}else h&&this._area.paths.polygon([[n,l],[n+h,l+d],[n+h,l+d+a],[n,l+d+a+c]]).fill(g),d&&this._area.paths.polygon([[n,l],[n+h,l+d],[n+h+s,l+d],[n+h+s+u,l]]).fill(f),u&&this._area.paths.polygon([[n+h+s+u,l],[n+h+s,l+d],[n+h+s,l+d+a],[n+h+s+u,l+d+a+c]]).fill(p),c&&this._area.paths.polygon([[n,l+d+a+c],[n+h,l+d+a],[n+h+s,l+d+a],[n+h+s+u,l+d+a+c]]).fill(w)}r&&t.backgroundColor&&s>0&&a>0&&this._area.paths.rect(n+h,l+d,s,a).fill(t.backgroundColor)},e.prototype._renderBooleanCell=function(e,t,r,n,l){if(this._renderEmptyCell(t,r,n,l),n){var s=t.textRect.left,a=t.textRect.top,h=t.textRect.height;if(this._area.paths.rect(s,a,h,h).fillAndStroke(i.Color.fromRgba(255,255,255),new o.PdfPen(void 0,.5)),!0===i.changeType(e,i.DataType.Boolean,"")){var d=h/20,c=h-.5-2*d,u=h/8;this._area._pdfdoc.saveState(),this._area.translate(s+.25+d,a+.25+d).paths.moveTo(u/2,.6*c).lineTo(c-.6*c,c-u).lineTo(c-u/2,u/2).stroke(new o.PdfPen(void 0,u)),this._area._pdfdoc.restoreState()}}},e.prototype._renderTextCell=function(e,t,r,i,n){this._renderEmptyCell(t,r,i,n),i&&e&&this._area.drawText(e,t.textRect.left,t.textRect.top,{brush:r.color,font:r.font,height:t.textRect.height,width:t.textRect.width,align:"center"===r.textAlign?o.PdfTextHorizontalAlign.Center:"right"===r.textAlign?o.PdfTextHorizontalAlign.Right:"justify"===r.textAlign?o.PdfTextHorizontalAlign.Justify:o.PdfTextHorizontalAlign.Left})},e.prototype._calculateTextRect=function(e,t,o,r,i,n){var l=i.clone();if(this._isBooleanCellAndValue(e,t,o,r)){var s=this._getTextLineHeight(n.font);switch(n.verticalAlign){case"middle":l.top=i.top+i.height/2-s/2;break;case"bottom":l.top=i.top+i.height-s}switch(n.textAlign){case"justify":case"center":l.left=i.left+i.width/2-s/2;break;case"right":l.left=i.left+i.width-s}l.height=l.width=s}else if(l.height>0&&l.width>0){switch(n.verticalAlign){case"bottom":(a=this._area.measureText(e,n.font,{height:l.height,width:l.width})).size.height<l.height&&(l.top+=l.height-a.size.height,l.height=a.size.height);break;case"middle":var a=this._area.measureText(e,n.font,{height:l.height,width:l.width});a.size.height<l.height&&(l.top+=l.height/2-a.size.height/2,l.height=a.size.height)}t.wordWrap||(l.height=this._getTextLineHeight(n.font))}return l},e.prototype._extractCheckboxValue=function(e){var t=e.querySelector("input.wj-cell-check[type=checkbox]");if(t){var o=window.getComputedStyle(t);if("none"!==o.display&&"hidden"!==o.visibility)return t.checked}},e.prototype._getTextLineHeight=function(e){return this._area.lineHeight(e)},e}(),v=function(){function e(e){this._columns={},this._flex=e}return e.prototype.getMergedRange=function(e,t,o){var r=this._columns[o];if(r&&t>=r.topRow&&t<=r.bottomRow)return r;var i=this._flex.getMergedRange(e,t,o,!1);return this._columns[o]=i?new S(e,i):null},e}(),S=function(e){function t(t,o,i,n,l){var s=this;(s=o instanceof r.CellRange?e.call(this,o.row,o.col,o.row2,o.col2)||this:e.call(this,o,i,n,l)||this).firstVisibleRow=-1,s.visibleRowsCount=0;var a=s.topRow,h=s.bottomRow,d=t.rows.length;if(d>0)for(var c=a;c<=h&&c<d;c++)t.rows[c].isVisible&&(s.firstVisibleRow<0&&(s.firstVisibleRow=c),s.visibleRowsCount++);return s}return __extends(t,e),t.prototype.copyFrom=function(e){this.setRange(e.row,e.col,e.row2,e.col2),this.firstVisibleRow=e.firstVisibleRow,this.visibleRowsCount=e.visibleRowsCount},t}(r.CellRange),x=function(){function e(e,t){this._flex=e,this._ranges=t||[]}return e.getSelection=function(t,o){var i=[];if(o===u.All)i.push(new r.CellRange(0,0,t.rows.length-1,t.columns.length-1));else{var n=t.selection;switch(t.selectionMode){case r.SelectionMode.None:break;case r.SelectionMode.Cell:case r.SelectionMode.CellRange:i.push(n);break;case r.SelectionMode.Row:i.push(new r.CellRange(n.topRow,0,n.topRow,t.cells.columns.length-1));break;case r.SelectionMode.RowRange:i.push(new r.CellRange(n.topRow,0,n.bottomRow,t.cells.columns.length-1));break;case r.SelectionMode.ListBox:for(var l=-1,s=0;s<t.rows.length;s++)t.rows[s].isSelected?(l<0&&(l=s),s===t.rows.length-1&&i.push(new r.CellRange(l,0,s,t.cells.columns.length-1))):(l>=0&&i.push(new r.CellRange(l,0,s-1,t.cells.columns.length-1)),l=-1)}}return new e(t,i)},e.prototype.length=function(){for(var e=0,t=0;t<this._ranges.length;t++){var o=this._ranges[t];o.isValid&&(e+=o.bottomRow-o.topRow+1)}return e},Object.defineProperty(e.prototype,"isValid",{get:function(){return this._ranges.length&&this._ranges[0].isValid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftCol",{get:function(){return this._ranges.length?this._ranges[0].leftCol:-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightCol",{get:function(){return this._ranges.length?this._ranges[0].rightCol:-1},enumerable:!0,configurable:!0}),e.prototype.clone=function(t,o){for(var r=[],i=0;i<this._ranges.length;i++){var n=this._ranges[i].clone();arguments.length>0&&(n.col=t),arguments.length>1&&(n.col2=o),r.push(n)}return new e(this._flex,r)},e.prototype.getRenderSize=function(e){for(var t=new i.Size(0,0),o=0;o<this._ranges.length;o++){var r=this._ranges[o].getRenderSize(e);t.width=Math.max(t.width,r.width),t.height+=r.height}return t},e.prototype.forEach=function(e,t){for(var o=0,r=0;r<this._ranges.length;r++){var i=this._ranges[r];if(i.isValid)for(var n=i.topRow;n<=i.bottomRow;n++)t(e.rows[n],i,n,o++)}},e.prototype.subrange=function(t,o,i,n){var l=[];if(t>=0&&o>0)for(var s=0,a=0,h=0;h<this._ranges.length&&o>0;h++,s=a+1){var d=this._ranges[h];if(a=s+(d.bottomRow-d.topRow),!(t>a)){var c=t>s?d.topRow+(t-s):d.topRow,u=Math.min(d.bottomRow,c+o-1),g=arguments.length>2?i:d.leftCol,p=arguments.length>2?n:d.rightCol;l.push(new r.CellRange(c,g,u,p)),o-=u-c+1}}return new e(this._flex,l)},e}(),T=function(){function e(e,t,o){this._col=t,this._row=o,this._range=e}return Object.defineProperty(e.prototype,"range",{get:function(){return this._range},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pageCol",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pageRow",{get:function(){return this._row},enumerable:!0,configurable:!0}),e}()});