/*
    *
    * Wijmo Library 5.20183.550
    * 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/
    *
    */
"use strict";function tryGetModuleWijmoGrid(){var e;return(e=__glob.wijmo)&&e.grid}function tryGetModuleWijmoGridMultirow(){var e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.multirow}function tryGetModuleWijmoGridSheet(){var e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.sheet}function tryGetModuleWijmoOlap(){var e;return(e=__glob.wijmo)&&e.olap}function tryGetModuleWijmoGridDetail(){var e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.detail}function _merge(e,t,r){if(void 0===r&&(r=!1),!e&&t&&(e={}),t&&e)for(var o in t){var n=t[o],i=e[o];if(wjcCore.isObject(n)){if(void 0===i||!wjcCore.isObject(i)&&r){if(wjcCore.isFunction(n.clone)){e[o]=i=n.clone();continue}e[o]=i={}}wjcCore.isObject(i)&&_merge(e[o],n,r)}else(void 0===i||r&&void 0!==n)&&(e[o]=n)}return e}function getFakeCell(){return _fc||((_fc=document.createElement("div")).setAttribute(tryGetModuleWijmoGrid().FlexGrid._WJS_MEASURE,"true"),document&&document.body&&document.body.appendChild(_fc)),_fc.className="",_fc.innerHTML="",_fc.style.cssText="",_fc.style.visibility="hidden",_fc}function _removeFakeCell(){_fc&&(wjcCore.removeChild(_fc),_fc=null)}function bufToStr(e){for(var t=new Uint16Array(e),r="",o=0,n=t.length;o<n;o++)r+=String.fromCharCode(t[o]);return r}function strToBuf(e){for(var t=new ArrayBuffer(2*e.length),r=new Uint16Array(t),o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t}function blobToBuf(e,t){wjcCore.asFunction(t);var r=new FileReader;r.onload=function(e){t(e.target.result)},r.readAsArrayBuffer(e)}var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wjcPdf=require("wijmo/wijmo.pdf"),wjcCore=require("wijmo/wijmo"),__glob="undefined"!=typeof window?window:self,wjcSelfRef=require("wijmo/wijmo.grid.pdf"),wjcSelf=wjcSelfRef||exports;__glob.wijmo=__glob.wijmo||{},__glob.wijmo.grid=__glob.wijmo.grid||{},__glob.wijmo.grid.pdf=wjcSelf;var ScaleMode;!function(e){e[e.ActualSize=0]="ActualSize",e[e.PageWidth=1]="PageWidth",e[e.SinglePage=2]="SinglePage"}(ScaleMode=exports.ScaleMode||(exports.ScaleMode={}));var ExportMode;!function(e){e[e.All=0]="All",e[e.Selection=1]="Selection"}(ExportMode=exports.ExportMode||(exports.ExportMode={}));var _CellType;!function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.TopLeft=4]="TopLeft",e[e.ColumnFooter=5]="ColumnFooter",e[e.BottomLeft=6]="BottomLeft"}(_CellType=exports._CellType||(exports._CellType={}));var PdfFormatItemEventArgs=function(e){function t(t,r,o,n,i,l,s,a,u){var c=e.call(this)||this;return c.cancelBorders=!1,c._p=t,c._rng=r,c._cell=wjcCore.asType(o,HTMLElement,!0),c._canvas=n,c._clientRect=i,c._contentRect=l,c._textTop=s,c._style=a,c._getFormattedCell=u,c}return __extends(t,e),Object.defineProperty(t.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"range",{get:function(){return this._rng.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"row",{get:function(){return this._rng.row},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"col",{get:function(){return this._rng.col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0}),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 wjcCore.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}(wjcCore.CancelEventArgs);exports.PdfFormatItemEventArgs=PdfFormatItemEventArgs,exports._merge=_merge;var _FlexGridPdfConverterCore=function(){function e(){}return e.draw=function(e,t,r,o,n,i){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The doc argument cannot be null."),null==(i=this._applyDefaultDrawSettings(i)).scaleMode&&(i.scaleMode=null==o?ScaleMode.ActualSize:null==n?ScaleMode.PageWidth:ScaleMode.SinglePage),this._drawInternal(e,t,r,o,n,i)},e._applyDefaultDrawSettings=function(t){return _merge(_merge({},t),e.DefaultDrawSettings)},e._drawInternal=function(e,t,r,o,n,i){var l=null!=r,s=new wjcCore.Size(t.width,t.height);r||(r=new wjcCore.Point(0,t.y)),wjcCore.isArray(i.embeddedFonts)&&i.embeddedFonts.forEach(function(e){t.registerFont(e)});var a=this._getRowsToRender(e,i),u=new FlexGridRenderer(e,i,a,this.BorderWidth,!0),c=new wjcCore.Rect(r.x||0,r.y||0,o||s.width,n||s.height),d=this._getScaleFactor(u,i.scaleMode,c),p=this._getPages(u,a,c,i,l,d),f=(i.progress?this._getCellsCount(e,i,p):0)/i._progressMax,h=0,g=0,w=i.progress?function(){++h-g>=50&&(g=h,i.progress(h/f))}:null;i.progress&&i.progress(0);for(var b=0;b<p.length;b++){b>0&&t.addPage();var _=p[b],m=0===_.pageCol?c.left:0,y=0===_.pageRow?c.top:0;t.saveState(),t.paths.rect(0,0,s.width,s.height).clip(),t.scale(d,d,new wjcCore.Point(m,y)),t.translate(m,y);var C=new FlexGridRenderer(e,i,_.range,this.BorderWidth,b===p.length-1);C.render(t,w),t.restoreState(),t.x=m,t.y=y+C.renderSize.height*d}i.progress&&0<i._progressMax&&i.progress(i._progressMax)},e._getCellsCount=function(e,t,r){for(var o=0,n=0;n<r.length;n++)o+=new FlexGridRenderer(e,t,r[n].range,0,!1).getCellsCount();return o},e._getRowsToRender=function(e,t){var r=[];t.exportMode===ExportMode.All?r.push(new _CellRange(null,0,0,e.rows.length-1,e.columns.length-1)):r=e.getSelection();var o=new RowRange(r);if(!t.drawDetailRows){var n=[];o.forEach(e.cells,function(t,r,o){if(!e.isDetailRow(t)){var i=n.length;i&&n[i-1].bottomRow+1===o?n[i-1].row2++:n.push(new _CellRange(null,o,r.col,o,r.col2))}}),o=new RowRange(n)}return o},e._getScaleFactor=function(e,t,r){var o=1;if(t===ScaleMode.ActualSize)return o;var n=e.renderSize;if(t===ScaleMode.SinglePage)(i=Math.min(r.width/n.width,r.height/n.height))<1&&(o=i);else{var i=r.width/n.width;i<1&&(o=i)}return o},e._getPages=function(e,t,r,o,n,i){var l=this,s=[],a=[],u=wjcPdf.pxToPt,c=e.flex,d=e.showColumnHeader,p=e.showColumnFooter,f=e.showRowHeader,h=d?u(c.columnHeaders.height):0,g=p?u(c.columnFooters.height):0,w=f?u(c.rowHeaders.width):0,b=o.scaleMode===ScaleMode.ActualSize||o.scaleMode===ScaleMode.PageWidth,_=o.scaleMode===ScaleMode.ActualSize,m=(r.width-r.left)*(1/i),y=(r.height-r.top)*(1/i),C=r.width*(1/i),R=r.height*(1/i),v=h+g,x=w,P=n&&o.scaleMode==ScaleMode.ActualSize;if(b){var j=0;t.forEach(c.cells,function(t,r,o,n){var i=s.length?R:y;if(e.isRenderableRow(t)){var a=u(t.renderHeight);j++,v+=a,(d||j>1)&&(v-=l.BorderWidth),v>i&&(h+a>i||P?(s.push(n),v=h):(s.push(n-1),v=h+a),d&&(v-=l.BorderWidth))}})}var S=t.length()-1;if(S<0&&(S=0),s.length&&s[s.length-1]===S||s.push(S),_)for(var G=0,M=t.leftCol;M<=t.rightCol;M++){var T=c.columns[M];if(T.isVisible){var W=u(T.renderWidth),O=a.length?C:m;G++,x+=W,(f||G>1)&&(x-=this.BorderWidth),x>O&&(w+W>O||P?(a.push(M),x=w):(a.push(M-1),x=w+W),f&&(x-=this.BorderWidth))}}a.length&&a[a.length-1]===t.rightCol||a.push(t.rightCol);for(var F=[],H=!1,A=1,z=n&&o.maxPages>0?1:o.maxPages,M=0;M<s.length&&!H;M++)for(var D=0;D<a.length&&!H;D++,A++)if(!(H=A>z)){var L=0==M?0:s[M-1]+1,E=0==D?t.leftCol:a[D-1]+1;F.push(new PdfPageRowRange(t.subrange(L,s[M]-L+1,E,a[D]),D,M))}return F},e.BorderWidth=1,e.DefFont=new wjcPdf.PdfFont,e.DefaultDrawSettings={customCellContent:!1,drawDetailRows:!1,exportMode:ExportMode.All,maxPages:Number.MAX_VALUE,repeatMergedValuesAcrossPages:!0,recalculateStarWidths:!0,styles:{cellStyle:{font:{family:e.DefFont.family,size:e.DefFont.size,style:e.DefFont.style,weight:e.DefFont.weight},padding:1.5,verticalAlign:"middle"},headerCellStyle:{font:{weight:"bold"}}},_progressMax:1},e}();exports._FlexGridPdfConverterCore=_FlexGridPdfConverterCore;var FlexGridRenderer=function(){function e(e,t,r,o,n){this._flex=e,this._borderWidth=o,this._lastPage=n,this._settings=t||{},this._topLeft=new PanelSectionRenderer(this,e.topLeftCells,new RowRange(this.showRowHeader&&this.showColumnHeader?[new _CellRange(null,0,0,e.topLeftCells.rows.length-1,e.topLeftCells.columns.length-1)]:[]),o),this._rowHeader=new PanelSectionRenderer(this,e.rowHeaders,this.showRowHeader?r.clone(0,e.rowHeaders.columns.length-1):new RowRange([]),o),this._columnHeader=new PanelSectionRenderer(this,e.columnHeaders,new RowRange(this.showColumnHeader?[new _CellRange(null,0,r.leftCol,e.columnHeaders.rows.length-1,r.rightCol)]:[]),o),this._cells=new PanelSectionRenderer(this,e.cells,r,o),this._bottomLeft=new PanelSectionRenderer(this,e.bottomLeftCells,new RowRange(this.showRowHeader&&this.showColumnFooter?[new _CellRange(null,0,0,e.bottomLeftCells.rows.length-1,e.bottomLeftCells.columns.length-1)]:[]),o),this._columnFooter=new PanelSectionRenderer(this,e.columnFooters,new RowRange(this.showColumnFooter?[new _CellRange(null,0,r.leftCol,e.columnFooters.rows.length-1,r.rightCol)]:[]),o)}return Object.defineProperty(e.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),e.prototype.isRenderableRow=function(e){return e.isVisible&&!this._flex.isNewRow(e)},e.prototype.getCellsCount=function(){return this._topLeft.getCellsCount()+this._rowHeader.getCellsCount()+this._columnHeader.getCellsCount()+this._cells.getCellsCount()+this._bottomLeft.getCellsCount()+this._columnFooter.getCellsCount()},e.prototype.render=function(e,t){var r=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,t),this._rowHeader.render(e,0,o,t),this._columnHeader.render(e,r,0,t),this._cells.render(e,r,o,t),o=Math.max(0,o+this._cells.renderSize.height-this._borderWidth),this._bottomLeft.render(e,0,o,t),this._columnFooter.render(e,r,o,t)},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 wjcCore.Size(t,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnHeader",{get:function(){return this._flex.showColumnHeader},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showRowHeader",{get:function(){return this._flex.showRowHeader},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnFooter",{get:function(){return this._lastPage&&this._flex.showColumnFooter},enumerable:!0,configurable:!0}),e.prototype.alignMergedTextToTheTopRow=function(e){return this._flex.alignMergedTextToTheTopRow(e)},e.prototype.getColumn=function(e,t,r){return this._flex.getColumn(e,t,r)},e.prototype.isAlternatingRow=function(e){return this._flex.isAlternatingRow(e)},e.prototype.isGroupRow=function(e){return this._flex.isGroupRow(e)},e.prototype.isNewRow=function(e){return this._flex.isNewRow(e)},e.prototype.isExpandableGroupRow=function(e){return this._flex.isExpandableGroupRow(e)},e.prototype.isBooleanCell=function(e,t,r){return this._flex.isBooleanCell(e,t,r)},e.prototype.getCellStyle=function(e,t,r){return this._flex.getCellStyle(e,t,r)},e}(),PanelSection=function(){function e(e,t){this._panel=e,this._range=t.clone()}return 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 wjcCore.Size(wjcPdf.pxToPt(e.width),wjcPdf.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(e){return e.isVisible},e}(),PanelSectionRenderer=function(e){function t(t,r,o,n){var i=e.call(this,r,o)||this;return i._gr=t,i._borderWidth=n,i}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,o=0,n=this.panel,i=e;i<=t;i++){var l=n.columns[i];l.isVisible&&(o++,r+=l.renderWidth)}return r=wjcPdf.pxToPt(r),o>1&&(r-=this._borderWidth*(o-1)),r},t.prototype.getRangeHeight=function(e,t){for(var r=0,o=0,n=this.panel,i=e;i<=t;i++){var l=n.rows[i];this.isRenderableRow(l)&&(o++,r+=l.renderHeight)}return r=wjcPdf.pxToPt(r),o>1&&(r-=this._borderWidth*(o-1)),r},t.prototype.getCellsCount=function(){var e=this,t=0,r=this.range,o=this.panel,n=new GetMergedRangeProxy(this._gr.flex);return r.isValid?(r.forEach(o,function(i,l,s){if(e.isRenderableRow(i))for(var a=r.leftCol;a<=r.rightCol;a++){var u=!1,c=void 0;if(e.gr.getColumn(o,s,a).isVisible){var d=null;(d=n.getMergedRange(o,s,a))?d.topRow!==d.bottomRow?d.firstVisibleRow!==s&&s!==l.topRow||(u=!0):(u=!0,c=Math.min(r.rightCol,d.rightCol)):u=!0,u&&t++,c&&(a=c)}}}),t):t},t.prototype.render=function(e,t,r,o){var n=this,i=this.range,l=this.panel,s=new GetMergedRangeProxy(this._gr.flex),a=new _CellRange(l,0,0,0,0),u=new CellRenderer(this,e,this._borderWidth);if(i.isValid){for(var c={},d=i.leftCol;d<=i.rightCol;d++)c[d]=r;i.forEach(l,function(e,r,d){if(n.isRenderableRow(e))for(var p=t,f=i.leftCol;f<=i.rightCol;f++){var h,g=n.gr.getColumn(l,d,f),w=void 0,b=void 0,_=!1,m=void 0;if(g.isVisible){var y=n._gr.flex.getCellContent(n.panel,e,g,f),C=null;if(C=s.getMergedRange(l,d,f))if(a.copyFrom(C),C.topRow!==C.bottomRow)C.firstVisibleRow===d||d===r.topRow?(_=!0,h=n.gr.settings.repeatMergedValuesAcrossPages?y:C.firstVisibleRow===d?y:"",w=n.getRangeHeight(d,Math.min(C.bottomRow,r.bottomRow)),b=n.getRangeWidth(f,f)):b=n.getRangeWidth(f,f);else{_=!0,h=n.gr.settings.repeatMergedValuesAcrossPages?y:f===C.leftCol?y:"",w=n.getRangeHeight(d,d),b=n.getRangeWidth(Math.max(i.leftCol,C.leftCol),Math.min(i.rightCol,C.rightCol)),m=Math.min(i.rightCol,C.rightCol);for(var R=f+1;R<=m;R++)c[R]+=w-n._borderWidth}else a.setRange(d,f,d,f),_=!0,h=y,w=n.getRangeHeight(d,d),b=n.getRangeWidth(f,f);_&&(u.renderCell(h,e,g,a,new wjcCore.Rect(p,c[f],b,w)),o&&o()),w&&(c[f]+=w-n._borderWidth),b&&(p+=b-n._borderWidth),m&&(f=m)}}})}},t.prototype.isRenderableRow=function(e){return this._gr.isRenderableRow(e)},t}(PanelSection),CellRenderer=function(){function e(e,t,r){this._pr=e,this._area=t,this._borderWidth=r}return e.prototype.renderCell=function(e,t,r,o,n){var i,l=this._pr.gr.flex,s=this._pr.panel,a=function(){return l.getCell(s,o.topRow,o.leftCol)},u=null,c=this._pr.gr.getCellStyle(s,t,r);if(this._pr.gr.settings.customCellContent){var d=l.getComputedStyle(u=a());c.color=d.color,c.backgroundColor=d.backgroundColor,c.borderColor=d.borderColor||d.borderRightColor||d.borderBottomColor||d.borderLeftColor||d.borderTopColor,c.font=new wjcPdf.PdfFont(d.fontFamily,wjcPdf._asPt(d.fontSize,!0,void 0),d.fontStyle,d.fontWeight),c.textAlign=d.textAlign}if(c.font&&!(c.font instanceof wjcPdf.PdfFont)){var p=c.font;c.font=new wjcPdf.PdfFont(p.family,p.size,p.style,p.weight)}if(c.boxSizing="border-box",c.borderWidth=this._borderWidth,c.borderStyle="solid",c.textAlign||l.isGroupRow(t)&&!r.aggregate||(c.textAlign=r.getAlignment()),s.cellType===_CellType.Cell&&l.rows.maxGroupLevel>=0&&o.leftCol===l.columns.firstVisibleIndex){var f=l.isGroupRow(t)?Math.max(t.level,0):l.rows.maxGroupLevel+1,h=wjcPdf._asPt(c.paddingLeft||c.padding),g=wjcPdf.pxToPt(f*l.treeIndent);console.log(f),c.paddingLeft=h+g}var w,b=this._measureCell(e,s,t,r,c,n),_=o.rowSpan>1&&o.visibleRowsCount>1&&this._pr.gr.alignMergedTextToTheTopRow(s);_&&(w=new wjcCore.Rect(b.contentRect.left,b.contentRect.top,b.contentRect.width,b.contentRect.height/(o.visibleRowsCount||1)),b.textRect=this._calculateTextRect(e,s,t,r,w,c)),wjcCore.isFunction(this._pr.gr.settings.formatItem)&&((i=new PdfFormatItemEventArgs(s,o,u,this._area,b.rect,b.contentRect,b.textRect.top,c,function(){return u||a()})).data=e,this._pr.gr.settings.formatItem(i),i.data!==e&&(e=wjcCore.asString(i.data),b.textRect=this._calculateTextRect(e,s,t,r,_?w:b.contentRect,c))),this._renderCell(e,t,r,o,b,c,!i||!i.cancel,!i||!i.cancelBorders)},e.prototype._renderCell=function(e,t,r,o,n,i,l,s){(l||s)&&(this._isBooleanCellAndValue(e,this._pr.panel,t,r)?this._renderBooleanCell(e,n,i,l,s):this._renderTextCell(e,n,i,l,s))},e.prototype._isBooleanCellAndValue=function(e,t,r,o){return this._pr.gr.isBooleanCell(t,r,o)&&this._isBoolean(e)},e.prototype._isBoolean=function(e){var t=wjcCore.isString(e)&&e.toLowerCase();return"true"===t||"false"===t||!0===e||!1===e},e.prototype._measureCell=function(e,t,r,o,n,i){this._decompositeStyle(n);var l=i.left,s=i.top,a=i.height,u=i.width,c=this._parseBorder(n),d=c.left.width,p=c.top.width,f=c.bottom.width,h=c.right.width,g=this._parsePadding(n),w=0,b=0,_=0,m=0;if("content-box"===n.boxSizing||void 0===n.boxSizing)w=g.top+a+g.bottom,b=g.left+u+g.right,_=a,m=u;else{if("border-box"!==n.boxSizing)throw"Invalid value: "+n.boxSizing;wjcPdf._IE&&n instanceof CSSStyleDeclaration?(w=g.top+g.bottom+a,b=g.left+g.right+u):(w=a-p-f,b=u-d-h),_=w-g.top-g.bottom,m=b-g.left-g.right}var i=new wjcCore.Rect(l,s,u,a),y=new wjcCore.Rect(l+d,s+p,b,w),C=new wjcCore.Rect(l+d+g.left,s+p+g.top,m,_);return{rect:i,clientRect:y,contentRect:C,textRect:this._calculateTextRect(e,t,r,o,C,n)}},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:wjcPdf._asPt(e.borderLeftWidth),style:e.borderLeftStyle,color:e.borderLeftColor}),"none"!==e.borderTopStyle&&(t.top={width:wjcPdf._asPt(e.borderTopWidth),style:e.borderTopStyle,color:e.borderTopColor}),"none"!==e.borderBottomStyle&&(t.bottom={width:wjcPdf._asPt(e.borderBottomWidth),style:e.borderBottomStyle,color:e.borderBottomColor}),"none"!==e.borderRightStyle&&(t.right={width:wjcPdf._asPt(e.borderRightWidth),style:e.borderRightStyle,color:e.borderRightColor}),t},e.prototype._parsePadding=function(e){return{left:wjcPdf._asPt(e.paddingLeft),top:wjcPdf._asPt(e.paddingTop),bottom:wjcPdf._asPt(e.paddingBottom),right:wjcPdf._asPt(e.paddingRight)}},e.prototype._renderEmptyCell=function(e,t,r,o){var n=e.rect.left,i=e.rect.top,l=e.clientRect.width,s=e.clientRect.height,a=e.clientRect.left-e.rect.left,u=e.clientRect.top-e.rect.top,c=e.rect.top+e.rect.height-(e.clientRect.top+e.clientRect.height),d=e.rect.left+e.rect.width-(e.clientRect.left+e.clientRect.width);if(o&&(a||d||c||u)){var p=t.borderLeftColor||t.borderColor,f=t.borderRightColor||t.borderColor,h=t.borderTopColor||t.borderColor,g=t.borderBottomColor||t.borderColor;if(a&&u&&c&&d&&a===d&&a===c&&a===u&&p===f&&p===g&&p===h){var w=a,b=w/2;this._area.paths.rect(n+b,i+b,l+w,s+w).stroke(new wjcPdf.PdfPen(p,w))}else a&&this._area.paths.polygon([[n,i],[n+a,i+u],[n+a,i+u+s],[n,i+u+s+c]]).fill(p),u&&this._area.paths.polygon([[n,i],[n+a,i+u],[n+a+l,i+u],[n+a+l+d,i]]).fill(h),d&&this._area.paths.polygon([[n+a+l+d,i],[n+a+l,i+u],[n+a+l,i+u+s],[n+a+l+d,i+u+s+c]]).fill(f),c&&this._area.paths.polygon([[n,i+u+s+c],[n+a,i+u+s],[n+a+l,i+u+s],[n+a+l+d,i+u+s+c]]).fill(g)}r&&t.backgroundColor&&l>0&&s>0&&this._area.paths.rect(n+a,i+u,l,s).fill(t.backgroundColor)},e.prototype._renderBooleanCell=function(e,t,r,o,n){if(this._renderEmptyCell(t,r,o,n),o){var i=t.textRect.left,l=t.textRect.top,s=t.textRect.height;if(this._area.paths.rect(i,l,s,s).fillAndStroke(wjcCore.Color.fromRgba(255,255,255),new wjcPdf.PdfPen(void 0,.5)),!0===wjcCore.changeType(e,wjcCore.DataType.Boolean,"")){var a=s/20,u=s-.5-2*a,c=s/8;this._area.document.saveState(),this._area.translate(i+.25+a,l+.25+a).paths.moveTo(c/2,.6*u).lineTo(u-.6*u,u-c).lineTo(u-c/2,c/2).stroke(new wjcPdf.PdfPen(void 0,c)),this._area.document.restoreState()}}},e.prototype._renderTextCell=function(e,t,r,o,n){this._renderEmptyCell(t,r,o,n),o&&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?wjcPdf.PdfTextHorizontalAlign.Center:"right"===r.textAlign?wjcPdf.PdfTextHorizontalAlign.Right:"justify"===r.textAlign?wjcPdf.PdfTextHorizontalAlign.Justify:wjcPdf.PdfTextHorizontalAlign.Left})},e.prototype._calculateTextRect=function(e,t,r,o,n,i){var l=n.clone();if(this._isBooleanCellAndValue(e,t,r,o)){var s=this._getTextLineHeight(i.font);switch(i.verticalAlign){case"middle":l.top=n.top+n.height/2-s/2;break;case"bottom":l.top=n.top+n.height-s}switch(i.textAlign){case"justify":case"center":l.left=n.left+n.width/2-s/2;break;case"right":l.left=n.left+n.width-s}l.height=l.width=s}else if(l.height>0&&l.width>0){switch(i.verticalAlign){case"bottom":(a=this._area.measureText(e,i.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,i.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)}o.wordWrap||(l.height=this._getTextLineHeight(i.font))}return l},e.prototype._extractCheckboxValue=function(e){var t=e.querySelector("input.wj-cell-check[type=checkbox]");if(t){var r=window.getComputedStyle(t);if("none"!==r.display&&"hidden"!==r.visibility)return t.checked}},e.prototype._getTextLineHeight=function(e){return this._area.lineHeight(e)},e}(),GetMergedRangeProxy=function(){function e(e){this._columns={},this._flex=e}return e.prototype.getMergedRange=function(e,t,r){var o=this._columns[r];if(o&&t>=o.topRow&&t<=o.bottomRow)return o;var n=this._flex.getMergedRange(e,t,r);return this._columns[r]=n?new _CellRange(e,n):null},e}(),_CellRange=function(){function e(e,t,r,o,n){if("number"==typeof t?(this._row=t,this._col=r,this._row2=o,this._col2=n):(this._row=t.row,this._col=t.col,this._row2=t.row2,this._col2=t.col2),this.firstVisibleRow=-1,this.visibleRowsCount=0,e){var i=this.topRow,l=this.bottomRow,s=e.rows.length;if(s>0)for(var a=i;a<=l&&a<s;a++)e.rows[a].isVisible&&(this.firstVisibleRow<0&&(this.firstVisibleRow=a),this.visibleRowsCount++)}}return Object.defineProperty(e.prototype,"row",{get:function(){return this._row},set:function(e){this._row=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},set:function(e){this._col=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row2",{get:function(){return this._row2},set:function(e){this._row2=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col2",{get:function(){return this._col2},set:function(e){this._col2=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topRow",{get:function(){return Math.min(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomRow",{get:function(){return Math.max(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftCol",{get:function(){return Math.min(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightCol",{get:function(){return Math.max(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rowSpan",{get:function(){return Math.abs(this._row2-this._row)+1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1},enumerable:!0,configurable:!0}),e.prototype.copyFrom=function(e){this.setRange(e.row,e.col,e.row2,e.col2),this.firstVisibleRow=e.firstVisibleRow,this.visibleRowsCount=e.visibleRowsCount},e.prototype.clone=function(){return new e(null,this._row,this._col,this._row2,this._col2)},e.prototype.getRenderSize=function(e){var t=new wjcCore.Size(0,0);if(this.isValid){for(var r=this.topRow;r<=this.bottomRow;r++)t.height+=e.rows[r].renderHeight;for(var o=this.leftCol;o<=this.rightCol;o++)t.width+=e.columns[o].renderWidth}return t},e.prototype.setRange=function(e,t,r,o){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=e),void 0===o&&(o=t),this._row=wjcCore.asInt(e),this._col=wjcCore.asInt(t),this._row2=wjcCore.asInt(r),this._col2=wjcCore.asInt(o)},e}();exports._CellRange=_CellRange;var RowRange=function(){function e(e){this._ranges=e||[]}return e.prototype.length=function(){for(var e=0,t=0;t<this._ranges.length;t++){var r=this._ranges[t];r.isValid&&(e+=r.bottomRow-r.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,r){for(var o=[],n=0;n<this._ranges.length;n++){var i=this._ranges[n].clone();arguments.length>0&&(i.col=t),arguments.length>1&&(i.col2=r),o.push(i)}return new e(o)},e.prototype.getRenderSize=function(e){for(var t=new wjcCore.Size(0,0),r=0;r<this._ranges.length;r++){var o=this._ranges[r].getRenderSize(e);t.width=Math.max(t.width,o.width),t.height+=o.height}return t},e.prototype.forEach=function(e,t){for(var r=0,o=0;o<this._ranges.length;o++){var n=this._ranges[o];if(n.isValid)for(var i=n.topRow;i<=n.bottomRow;i++)t(e.rows[i],n,i,r++)}},e.prototype.subrange=function(t,r,o,n){var i=[];if(t>=0&&r>0)for(var l=0,s=0,a=0;a<this._ranges.length&&r>0;a++,l=s+1){var u=this._ranges[a];if(s=l+(u.bottomRow-u.topRow),!(t>s)){var c=t>l?u.topRow+(t-l):u.topRow,d=Math.min(u.bottomRow,c+r-1),p=arguments.length>2?o:u.leftCol,f=arguments.length>2?n:u.rightCol;i.push(new _CellRange(null,c,p,d,f)),r-=d-c+1}}return new e(i)},e}(),PdfPageRowRange=function(){function e(e,t,r){this._col=t,this._row=r,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}(),_fc;exports._removeFakeCell=_removeFakeCell;var FlexGridPdfConverter=function(){function e(){}return e.draw=function(e,t,r,o,n){this.drawToPosition(e,t,null,r,o,n)},e.drawToPosition=function(e,t,r,o,n,i){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The doc argument cannot be null.");var l=void 0!==tryGetModuleWijmoGrid().FlexGrid&&e instanceof tryGetModuleWijmoGrid().FlexGrid;try{i=_FlexGridPdfConverterCore._applyDefaultDrawSettings(i);var s=e;l&&(i&&i.recalculateStarWidths&&e.columns._updateStarSizes(wjcPdf.ptToPx(t.width)),s=this._getFlexGridAdapter(e,i)),_FlexGridPdfConverterCore.draw(s,t,r,o,n,i)}finally{_removeFakeCell(),l&&i&&i.recalculateStarWidths&&e.invalidate(!0)}},e.export=function(e,t,r){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The fileName argument cannot be empty.");var o=(r=this._applyDefaultExportSettings(r)).documentOptions.ended;r.documentOptions.ended=function(e,i){r.progress&&r.progress(1),o&&!1===o.apply(n,[e,i])||wjcPdf.saveBlob(i.blob,t),e.dispose()};var n=new wjcPdf.PdfDocument(r.documentOptions);this.drawToPosition(e,n,null,null,null,r),n.end()},e._getFlexGridAdapter=function(e,t){return new(tryGetModuleWijmoGridMultirow()&&e instanceof tryGetModuleWijmoGridMultirow().MultiRow&&MultiRowAdapter||tryGetModuleWijmoGridSheet()&&e instanceof tryGetModuleWijmoGridSheet().FlexSheet&&FlexSheetAdapter||tryGetModuleWijmoOlap()&&e instanceof tryGetModuleWijmoOlap().PivotGrid&&PivotGridAdapter||FlexGridAdapter)(e,t)},e._applyDefaultExportSettings=function(e){return _merge(_merge({},e),this._DefaultExportSettings)},e._DefaultExportSettings=_merge({scaleMode:ScaleMode.PageWidth,documentOptions:{compress:!1,pageSettings:{margins:{left:36,right:36,top:18,bottom:18}}},_progressMax:.9},_FlexGridPdfConverterCore.DefaultDrawSettings),e}();exports.FlexGridPdfConverter=FlexGridPdfConverter;var FlexGridAdapter=function(){function e(e,t){this._flex=e,this._settings=t}return Object.defineProperty(e.prototype,"flex",{get:function(){return this._flex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._flex.columns},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._flex.rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomLeftCells",{get:function(){return this._flex.bottomLeftCells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cells",{get:function(){return this._flex.cells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnFooters",{get:function(){return this._flex.columnFooters},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnHeaders",{get:function(){return this._flex.columnHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rowHeaders",{get:function(){return this._flex.rowHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topLeftCells",{get:function(){return this._flex.topLeftCells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"treeIndent",{get:function(){return this._flex.treeIndent},enumerable:!0,configurable:!0}),e.prototype.getSelection=function(){var e=[],t=this._flex.selection;switch(this._flex.selectionMode){case tryGetModuleWijmoGrid().SelectionMode.None:break;case tryGetModuleWijmoGrid().SelectionMode.Cell:case tryGetModuleWijmoGrid().SelectionMode.CellRange:e.push(t);break;case tryGetModuleWijmoGrid().SelectionMode.Row:e.push(new(tryGetModuleWijmoGrid().CellRange)(t.topRow,0,t.topRow,this._flex.cells.columns.length-1));break;case tryGetModuleWijmoGrid().SelectionMode.RowRange:e.push(new(tryGetModuleWijmoGrid().CellRange)(t.topRow,0,t.bottomRow,this._flex.cells.columns.length-1));break;case tryGetModuleWijmoGrid().SelectionMode.ListBox:for(var r=-1,o=0;o<this._flex.rows.length;o++)this._flex.rows[o].isSelected?(r<0&&(r=o),o===this._flex.rows.length-1&&e.push(new(tryGetModuleWijmoGrid().CellRange)(r,0,o,this._flex.cells.columns.length-1))):(r>=0&&e.push(new(tryGetModuleWijmoGrid().CellRange)(r,0,o-1,this._flex.cells.columns.length-1)),r=-1)}return e},e.prototype.getCell=function(e,t,r){var o=e.getCellElement(t,r);return o||(o=getFakeCell(),this._flex.cellFactory.updateCell(e,t,r,o)),o},e.prototype.getComputedStyle=function(e){return e.className=e.className.replace("wj-state-selected",""),e.className=e.className.replace("wj-state-multi-selected",""),window.getComputedStyle(e)},e.prototype.getMergedRange=function(e,t,r){return this._flex.getMergedRange(e,t,r,!1)},Object.defineProperty(e.prototype,"showColumnHeader",{get:function(){return!!(this._flex.headersVisibility&tryGetModuleWijmoGrid().HeadersVisibility.Column)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showRowHeader",{get:function(){return!!(this._flex.headersVisibility&tryGetModuleWijmoGrid().HeadersVisibility.Row)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnFooter",{get:function(){return this._flex.columnFooters.rows.length>0},enumerable:!0,configurable:!0}),e.prototype.alignMergedTextToTheTopRow=function(e){return!1},e.prototype.getCellData=function(e,t,r){return e.getCellData(r,t,!0)},e.prototype.getCellContent=function(e,t,r,o){var n=this.getCellData(e,o,t.index),i=r.isContentHtml;if(!n&&e.cellType===tryGetModuleWijmoGrid().CellType.Cell){var l=t;l instanceof tryGetModuleWijmoGrid().GroupRow&&l.dataItem&&l.dataItem.groupDescription&&r.index===e.columns.firstVisibleIndex&&(i=!0,n=l.getGroupHeader())}if(i)(s=getFakeCell()).innerHTML=n,n=s.textContent.trim();else if(this.settings.customCellContent){var s=this.getCell(e,t.index,o);!(n=s.textContent.trim())&&this.isBooleanCell(e,t,r)&&(n=this._extractCheckboxValue(s)+"")}return n},e.prototype.isBooleanCell=function(e,t,r){return r.dataType===wjcCore.DataType.Boolean&&e.cellType===tryGetModuleWijmoGrid().CellType.Cell&&!this.isExpandableGroupRow(t)},e.prototype.getColumn=function(e,t,r){return e.columns[r]},e.prototype.isAlternatingRow=function(e){return e.index%2!=0},e.prototype.isGroupRow=function(e){return e instanceof tryGetModuleWijmoGrid().GroupRow},e.prototype.isNewRow=function(e){return e instanceof tryGetModuleWijmoGrid()._NewRowTemplate},e.prototype.isDetailRow=function(e){return tryGetModuleWijmoGridDetail()&&e instanceof tryGetModuleWijmoGridDetail().DetailRow},e.prototype.isExpandableGroupRow=function(e){return e instanceof tryGetModuleWijmoGrid().GroupRow&&e.hasChildren},e.prototype.getCellStyle=function(e,t,r){var o=this.settings.styles,n=_merge({},o.cellStyle),i=this._flex;switch(e.cellType){case tryGetModuleWijmoGrid().CellType.Cell:this.isExpandableGroupRow(t)?_merge(n,o.groupCellStyle,!0):this.isAlternatingRow(t)&&_merge(n,o.altCellStyle,!0);break;case tryGetModuleWijmoGrid().CellType.ColumnHeader:case tryGetModuleWijmoGrid().CellType.RowHeader:case tryGetModuleWijmoGrid().CellType.TopLeft:case tryGetModuleWijmoGrid().CellType.BottomLeft:_merge(n,o.headerCellStyle,!0);break;case tryGetModuleWijmoGrid().CellType.ColumnFooter:_merge(n,o.headerCellStyle,!0),_merge(n,o.footerCellStyle,!0)}return!this.settings.customCellContent&&i._getShowErrors()&&i._getError(e,t.index,r.index)&&_merge(n,o.errorCellStyle,!0),n},e.prototype._extractCheckboxValue=function(e){var t=e.querySelector("input.wj-cell-check[type=checkbox]");if(t){var r=window.getComputedStyle(t);if("none"!==r.display&&"hidden"!==r.visibility)return t.checked}},e}(),FlexSheetAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getCellData=function(t,r,o){return t.cellType===tryGetModuleWijmoGrid().CellType.Cell?t.rows[o]instanceof tryGetModuleWijmoGridSheet().HeaderRow?this.flex.columnHeaders.getCellData(o,r,!0):this.flex.getCellValue(o,r,!0):e.prototype.getCellData.call(this,t,r,o)},t.prototype.getCellStyle=function(t,r,o){var n=e.prototype.getCellStyle.call(this,t,r,o),i=this.flex.selectedSheet.findTable(r.index,o.index);if(i){var l=i.getRange(),s=r.index-l.topRow,a=o.index-l.leftCol,u=i._getTableCellAppliedStyles(s,a);u&&(u.font=new wjcPdf.PdfFont(u.fontFamily,wjcPdf._asPt(u.fontSize,!0,void 0),u.fontStyle,u.fontWeight)),_merge(n,u,!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}(FlexGridAdapter),MultiRowAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getColumn=function(e,t,r){return this.flex.getBindingColumn(e,t,r)},t.prototype.isAlternatingRow=function(t){return t instanceof tryGetModuleWijmoGridMultirow()._MultiRow?t.dataIndex%2!=0:e.prototype.isAlternatingRow.call(this,t)},t}(FlexGridAdapter),PivotGridAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.alignMergedTextToTheTopRow=function(e){return!this.flex.centerHeadersVertically&&(e.cellType===tryGetModuleWijmoGrid().CellType.ColumnHeader||e.cellType===tryGetModuleWijmoGrid().CellType.RowHeader)},t}(FlexGridAdapter),PdfWebWorkerResponseStatus;!function(e){e[e.Done=1]="Done",e[e.Progress=2]="Progress"}(PdfWebWorkerResponseStatus||(PdfWebWorkerResponseStatus={}));var DefGridName="",PdfWebWorkerExportDoneEventArgs=function(e){function t(t){var r=e.call(this)||this;return r._buf=t,r}return __extends(t,e),Object.defineProperty(t.prototype,"blob",{get:function(){return this._blob||(this._blob=new Blob([new Uint8Array(this._buf)],{type:"application/pdf"})),this._blob},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buffer",{get:function(){return this._buf},enumerable:!0,configurable:!0}),t}(wjcCore.EventArgs);exports.PdfWebWorkerExportDoneEventArgs=PdfWebWorkerExportDoneEventArgs;var PdfWebWorkerClient=function(){function e(){}return e.exportGrid=function(e,t,r,o,n,i){(o=_merge({},o)).progress=o.progress||i,this.addGrid(e,t,DefGridName,o),this.export(e,o.documentOptions,function(e){wjcCore.isFunction(n)&&!1===n(e)||wjcPdf.saveBlob(e.blob,r)},i)},e.export=function(e,t,r,o){e.addEventListener("message",function t(n){var i=n.data;switch(i.status){case PdfWebWorkerResponseStatus.Done:e.removeEventListener("message",t),wjcCore.isFunction(r)&&r(new PdfWebWorkerExportDoneEventArgs(i.data));break;case PdfWebWorkerResponseStatus.Progress:o&&o(i.data);break;default:throw"Unknown status: "+i.status}});var n=this._clientDataToArrayBuffer(e);e.postMessage({content:n,settings:t},[n]),this._clearClientData(e)},e.addGrid=function(e,t,r,o){var n=this._gridToJson(t,o);this._addClientData(e,JSON.stringify(n),r,o,!0)},e.addImage=function(e,t,r,o){var n=wjcCore.isString(t)&&t.indexOf("data:image/svg")>=0?t:wjcPdf._PdfImageHelper.getDataUri(t);this._addClientData(e,n,r,o)},e.addString=function(e,t,r){this._addClientData(e,t,r,null)},e.serializeGrid=function(e,t){var r=this._gridToJson(e,t);return strToBuf(JSON.stringify(r))},e._addClientData=function(e,t,r,o,n){void 0===n&&(n=!1),wjcCore.asType(e,Worker),wjcCore.asString(r),wjcCore.asString(t,!0);var i=e;i.clientData=i.clientData||{},i.clientData[r]={content:t,settings:o?JSON.stringify(o):null};var l=i.clientData[r];n&&(l.isGrid=!0,l.progressMessaging=wjcCore.isFunction(o.progress))},e._clearClientData=function(e){delete e.clientData},e._clientDataToArrayBuffer=function(e){var t=e;return strToBuf(JSON.stringify(t.clientData||{}))},e._gridToJson=function(e,t){t=FlexGridPdfConverter._applyDefaultExportSettings(t);var r;try{r=new wjcPdf.PdfDocument(t.documentOptions),t&&t.recalculateStarWidths&&e.columns._updateStarSizes(wjcPdf.ptToPx(r.width));var o=this._getJsonConverter(e,t).convert();strToBuf(JSON.stringify(o));return o}finally{_removeFakeCell(),t&&t.recalculateStarWidths&&e.invalidate(!0),null!=r&&(r.dispose(),r=null)}},e._getJsonConverter=function(e,t){return new(tryGetModuleWijmoGridMultirow()&&e instanceof tryGetModuleWijmoGridMultirow().MultiRow&&MultiRowJsonConverter||tryGetModuleWijmoOlap()&&e instanceof tryGetModuleWijmoOlap().PivotGrid&&PivotGridJsonConverter||FlexGridJsonConverter)(e,FlexGridPdfConverter._getFlexGridAdapter(e,t))},e}();exports.PdfWebWorkerClient=PdfWebWorkerClient;var PdfWebWorker=function(){function e(){}return e.initExportGrid=function(){var e=this;this.initExport(function(t,r){var o=r[DefGridName];o.progressMessaging&&(o.settings._progressMax=FlexGridPdfConverter._DefaultExportSettings._progressMax,o.settings.progress=function(t){e.sendExportProgress(t)},t.ended.addHandler(function(){e.sendExportProgress(1)})),FlexGridPdfConverter.draw(o.content,t,null,null,o.settings),t.end()})},e.initExport=function(t){self.addEventListener("message",function r(o){self.removeEventListener("message",r);var n=o.data,i=JSON.parse(bufToStr(n.content)),l=n.settings||{};l.ended=function(e,t){blobToBuf(t.blob,function(e){self.postMessage({data:e,status:PdfWebWorkerResponseStatus.Done},[e])})};var s=new wjcPdf.PdfDocument(l);Object.keys(i).forEach(function(t){var r=i[t];r.settings&&(r.settings=JSON.parse(r.settings)),r.isGrid&&(r.settings&&e._disableUnsupportedFeatures(r.settings),r.content=e._deserializeGridFromString(r.content,r.settings))}),t(s,i)})},e.sendExportProgress=function(e){e=wjcCore.clamp(e,0,1),self.postMessage({data:e,status:PdfWebWorkerResponseStatus.Progress})},e.deserializeGrid=function(e,t){return this._deserializeGridFromString(bufToStr(e),t)},e._deserializeGridFromString=function(e,t){return this._getJsonAdapter(JSON.parse(e),FlexGridPdfConverter._applyDefaultExportSettings(t))},e._disableUnsupportedFeatures=function(e){e.customCellContent=!1},e._getJsonAdapter=function(e,t){switch(e.typeName){case"MultiRow":return new MultiRowJsonAdapter(e,t);case"PivotGrid":return new PivotGridJsonAdapter(e,t);default:return new FlexGridJsonAdapter(e,t)}},e}();exports.PdfWebWorker=PdfWebWorker;var RowState;!function(e){e[e.None=0]="None",e[e.Alternate=1]="Alternate",e[e.Group=2]="Group",e[e.ExpandableGroup=4]="ExpandableGroup",e[e.New=8]="New",e[e.Visible=16]="Visible",e[e.Detail=32]="Detail"}(RowState||(RowState={}));var ColState;!function(e){e[e.None=0]="None",e[e.Visible=1]="Visible"}(ColState||(ColState={}));var FlexGridJsonConverter=function(){function e(e,t){this._flex=e,this._adapter=t}return e.prototype.convert=function(){var e={};return e.typeName=this._getTypeName(this._flex),e.selection=this._serializeSelection(),e.showColumnFooter=this.adapter.showColumnFooter,e.showColumnHeader=this.adapter.showColumnHeader,e.showRowHeader=this.adapter.showRowHeader,e.treeIndent=this._flex.treeIndent,e.bottomLeftCells=this._serializePanel(this._flex.bottomLeftCells),e.cells=this._serializePanel(this._flex.cells),e.columnFooters=this._serializePanel(this._flex.columnFooters),e.columnHeaders=this._serializePanel(this._flex.columnHeaders),e.rowHeaders=this._serializePanel(this._flex.rowHeaders),e.topLeftCells=this._serializePanel(this._flex.topLeftCells),e},Object.defineProperty(e.prototype,"adapter",{get:function(){return this._adapter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flex",{get:function(){return this._flex},enumerable:!0,configurable:!0}),e.prototype._getTypeName=function(e){return e.constructor.toString().match(/function\s*(\w+)/)[1]},e.prototype._getRowState=function(e){var t=RowState.None;return this.adapter.isAlternatingRow(e)&&(t|=RowState.Alternate),e instanceof tryGetModuleWijmoGrid().GroupRow&&(t|=RowState.Group),this.adapter.isDetailRow(e)&&(t|=RowState.Detail),this.adapter.isExpandableGroupRow(e)&&(t|=RowState.ExpandableGroup),e instanceof tryGetModuleWijmoGrid()._NewRowTemplate&&(t|=RowState.New),e.isVisible&&(t|=RowState.Visible),t},e.prototype._getColumnState=function(e){var t=ColState.None;return e.isVisible&&(t|=ColState.Visible),t},e.prototype._serializeSelection=function(){for(var e=this.adapter.getSelection(),t=[],r=0;r<e.length;r++){var o=e[r];t.push([o.row,o.col,o.row2,o.col2])}return t},e.prototype._serializeColumns=function(e){for(var t=[],r=0,o=(e||[]).length;r<o;r++){var n=e[r],i={aggregate:n.aggregate,alignment:n.getAlignment(),dataType:n.dataType,renderWidth:n.renderWidth,wordWrap:n.wordWrap},l=this._getColumnState(n);l!=ColState.None&&(i.state=l),t.push(i)}return t},e.prototype._serializePanel=function(e){var t={cellType:e.cellType,height:e.height,width:e.width};t.mergedRanges=this._serializeMergedRanges(e),t.columns=this._serializeColumns(e.columns),t.columnsFirstVisibleIndex=e.columns.firstVisibleIndex,t.rows=[],t.rowsMaxGroupLevel=e.rows.maxGroupLevel;for(var r=0,o=e.rows.length,n=e.columns.length;r<o;r++){var i=e.rows[r],l={renderHeight:i.renderHeight};t.rows.push(l),i instanceof tryGetModuleWijmoGrid().GroupRow&&(l.level=i.level);var s=this._getRowState(i);s!=RowState.None&&(l.state=s),l.cells=[];for(var a=0;a<n;a++)l.cells[a]=this._adapter.getCellContent(e,e.rows[r],e.columns[a],a)}return t},e.prototype._serializeMergedRanges=function(e){for(var t=[],r=[],o=0;o<e.columns.length;o++)r[o]=0;for(var n=0;n<e.rows.length;n++)for(var i=0;i<e.columns.length;i++)if(!(n<r[i])){var l=e.grid.getMergedRange(e,n,i);if(null!=l&&!l.isSingleCell){t.push([l.row,l.col,l.row2,l.col2]);for(var s=l.col;s<=l.col2;s++)r[s]=l.row2+1;l.col==l.col2||(i=l.col2)}}return t},e}(),MultiRowJsonConverter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.convert=function(){var t=e.prototype.convert.call(this);return t.rowsPerItem=this.flex.rowsPerItem,t},t.prototype._serializePanel=function(t){var r=e.prototype._serializePanel.call(this,t);return r.cellGroups=this._serializeCellGroup(t),r},t.prototype._serializeCellGroup=function(e){var t=[],r=[],o=this.flex.rowsPerItem;e.cellType!=tryGetModuleWijmoGrid().CellType.TopLeft&&e.cellType!=tryGetModuleWijmoGrid().CellType.ColumnHeader||(o=e.rows.length);for(var n=0;n<o;n++){r[n]=[];for(var i=0;i<e.columns.length;i++){var l=this.flex.getBindingColumn(e,n,i),s=t.indexOf(l);r[n][i]=s<0?t.push(l)-1:s}}return{bindingColumns:this._serializeColumns(t),mappings:r}},t}(FlexGridJsonConverter),PivotGridJsonConverter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.convert=function(){var t=e.prototype.convert.call(this);return t.centerHeadersVertically=this.flex.centerHeadersVertically,t},t}(FlexGridJsonConverter),RowJson=function(){function e(e,t){this._index=t,this._level=e.level,this._renderHeight=e.renderHeight,this._state=e.state,this._cells=e.cells}return Object.defineProperty(e.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAlternatingRow",{get:function(){return(this._state&RowState.Alternate)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isGroupRow",{get:function(){return(this._state&RowState.Group)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDetailRow",{get:function(){return(this._state&RowState.Detail)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isExpandableGroupRow",{get:function(){return(this._state&RowState.ExpandableGroup)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isNewRow",{get:function(){return(this._state&RowState.New)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return(this._state&RowState.Visible)!=RowState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"level",{get:function(){return this._level},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderHeight",{get:function(){return this._renderHeight},enumerable:!0,configurable:!0}),e}(),ColumnJson=function(){function e(e,t){this._aggregate=e.aggregate,this._alignment=e.alignment,this._dataType=e.dataType,this._index=t,this._renderWidth=e.renderWidth,this._state=e.state,this._wordWrap=e.wordWrap}return Object.defineProperty(e.prototype,"aggregate",{get:function(){return this._aggregate},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataType",{get:function(){return this._dataType},enumerable:!0,configurable:!0}),e.prototype.getAlignment=function(){return this._alignment},Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return(this._state&ColState.Visible)!=ColState.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderWidth",{get:function(){return this._renderWidth},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._wordWrap},enumerable:!0,configurable:!0}),e}(),RowJsonCollection=function(){function e(e,t){void 0===t&&(t=-1),this._maxGroupLevel=t,this._length=e.length;for(var r=0;r<e.length;r++)this[r]=new RowJson(e[r],r)}return Object.defineProperty(e.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxGroupLevel",{get:function(){return this._maxGroupLevel},enumerable:!0,configurable:!0}),e}(),ColumnJsonCollection=function(){function e(e,t){void 0===t&&(t=-1),this._firstVisibleIndex=t,this._length=e.length;for(var r=0;r<e.length;r++)this[r]=new ColumnJson(e[r],r)}return Object.defineProperty(e.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"firstVisibleIndex",{get:function(){return this._firstVisibleIndex},enumerable:!0,configurable:!0}),e}(),GridJsonPanel=function(){function e(e){this._height=e.height,this._width=e.width,this._cellType=e.cellType,this._columns=new ColumnJsonCollection(e.columns,e.columnsFirstVisibleIndex),this._rows=new RowJsonCollection(e.rows,e.rowsMaxGroupLevel),this._mergedRanges=this._deserializeMergedRanges(e.mergedRanges)}return Object.defineProperty(e.prototype,"cellType",{get:function(){return this._cellType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._columns},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),e.prototype.getMergedRange=function(e,t){var r=this._mergedRanges[e];if(r)for(var o=0,n=r.length;o<n;o++){var i=r[o];if(t>=i.col&&t<=i.col2)return i}return null},e.prototype._deserializeMergedRanges=function(e){var t=[];e=e||[];for(var r=0,o=this._rows.length;r<o;r++)t[r]=[];for(var r=0,o=e.length;r<o;r++)for(var n=e[r],i=new _CellRange(null,n[0],n[1],n[2],n[3]),l=i.row;l<=i.row2;l++)t[l].push(i);return t},e}(),FlexGridJsonAdapter=function(){function e(e,t){this._settings=t,this._bottomLeftCells=this.deserializePanel(e.bottomLeftCells),this._cells=this.deserializePanel(e.cells),this._columnFooters=this.deserializePanel(e.columnFooters),this._columnHeaders=this.deserializePanel(e.columnHeaders),this._rowHeaders=this.deserializePanel(e.rowHeaders),this._topLeftCells=this.deserializePanel(e.topLeftCells),this._treeIndent=e.treeIndent,this._showColumnFooter=e.showColumnFooter,this._showColumnHeader=e.showColumnHeader,this._showRowHeader=e.showRowHeader,this._selection=[];for(var r=0;r<e.selection.length;r++){var o=e.selection[r];this._selection.push(new _CellRange(null,o[0],o[1],o[2],o[3]))}}return Object.defineProperty(e.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._cells.columns},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._cells.rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomLeftCells",{get:function(){return this._bottomLeftCells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnFooters",{get:function(){return this._columnFooters},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnHeaders",{get:function(){return this._columnHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rowHeaders",{get:function(){return this._rowHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topLeftCells",{get:function(){return this._topLeftCells},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"treeIndent",{get:function(){return this._treeIndent},enumerable:!0,configurable:!0}),e.prototype.getSelection=function(){return this._selection},e.prototype.getCell=function(e,t,r){throw"Not implemented"},e.prototype.getComputedStyle=function(e){throw"Not implemented"},e.prototype.getMergedRange=function(e,t,r){return e.getMergedRange(t,r)},Object.defineProperty(e.prototype,"showColumnFooter",{get:function(){return this._showColumnFooter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showColumnHeader",{get:function(){return this._showColumnHeader},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showRowHeader",{get:function(){return this._showRowHeader},enumerable:!0,configurable:!0}),e.prototype.alignMergedTextToTheTopRow=function(e){return!1},e.prototype.getCellData=function(e,t,r){return e.rows[r].cells[t]},e.prototype.getCellContent=function(e,t,r,o){return this.getCellData(e,o,t.index)},e.prototype.isBooleanCell=function(e,t,r){return r.dataType===wjcCore.DataType.Boolean&&e.cellType===_CellType.Cell&&!this.isExpandableGroupRow(t)},e.prototype.getColumn=function(e,t,r){return e.columns[r]},e.prototype.isAlternatingRow=function(e){return e.isAlternatingRow},e.prototype.isGroupRow=function(e){return e.isGroupRow},e.prototype.isNewRow=function(e){return e.isNewRow},e.prototype.isDetailRow=function(e){return e.isDetailRow},e.prototype.isExpandableGroupRow=function(e){return e.isExpandableGroupRow},e.prototype.getCellStyle=function(e,t,r){var o=this.settings.styles,n=_merge({},o.cellStyle);switch(e.cellType){case _CellType.Cell:this.isExpandableGroupRow(t)?_merge(n,o.groupCellStyle,!0):this.isAlternatingRow(t)&&_merge(n,o.altCellStyle,!0);break;case _CellType.ColumnHeader:case _CellType.RowHeader:case _CellType.TopLeft:case _CellType.BottomLeft:_merge(n,o.headerCellStyle,!0);break;case _CellType.ColumnFooter:_merge(n,o.headerCellStyle,!0),_merge(n,o.footerCellStyle,!0)}return n},e.prototype.deserializePanel=function(e){return new GridJsonPanel(e)},e}(),PivotGridJsonAdapter=function(e){function t(t,r){var o=e.call(this,t,r)||this;return o._centerHeadersVertically=t.centerHeadersVertically,o}return __extends(t,e),t.prototype.alignMergedTextToTheTopRow=function(e){return!this._centerHeadersVertically&&(e.cellType===_CellType.ColumnHeader||e.cellType===_CellType.RowHeader)},t}(FlexGridJsonAdapter),MultiRowJsonPanel=function(e){function t(t){var r=e.call(this,t)||this;return t.cellGroups&&(r._cellGroups={bindingColumns:new ColumnJsonCollection(t.cellGroups.bindingColumns),mappings:t.cellGroups.mappings}),r}return __extends(t,e),t.prototype.getColumn=function(e,t,r){return this._cellGroups?(this.cellType!==_CellType.ColumnHeader&&this.cellType!==_CellType.BottomLeft&&(e%=r),this._cellGroups.bindingColumns[this._cellGroups.mappings[e][t]]):this.columns[t]},t}(GridJsonPanel),MultiRowJsonAdapter=function(e){function t(t,r){var o=e.call(this,t,r)||this;return o._rowsPerItem=t.rowsPerItem,o}return __extends(t,e),t.prototype.deserializePanel=function(e){return new MultiRowJsonPanel(e)},t.prototype.getColumn=function(e,t,r){return e.getColumn(t,r,this._rowsPerItem)},t}(FlexGridJsonAdapter);