/*
    *
    * 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/
    *
    */
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)}}();define(["require","exports","wijmo/wijmo.pdf","wijmo/wijmo","wijmo/wijmo.grid.pdf"],function(e,t,r,o,n){"use strict";function i(){var e;return(e=b.wijmo)&&e.grid}function l(){var e,t;return(e=b.wijmo)&&(t=e.grid)&&t.multirow}function s(){var e,t;return(e=b.wijmo)&&(t=e.grid)&&t.sheet}function a(){var e;return(e=b.wijmo)&&e.olap}function u(){var e,t;return(e=b.wijmo)&&(t=e.grid)&&t.detail}function c(e,t,r){if(void 0===r&&(r=!1),!e&&t&&(e={}),t&&e)for(var n in t){var i=t[n],l=e[n];if(o.isObject(i)){if(void 0===l||!o.isObject(l)&&r){if(o.isFunction(i.clone)){e[n]=l=i.clone();continue}e[n]=l={}}o.isObject(l)&&c(e[n],i,r)}else(void 0===l||r&&void 0!==i)&&(e[n]=i)}return e}function h(){return j||((j=document.createElement("div")).setAttribute(i().FlexGrid._WJS_MEASURE,"true"),document&&document.body&&document.body.appendChild(j)),j.className="",j.innerHTML="",j.style.cssText="",j.style.visibility="hidden",j}function p(){j&&(o.removeChild(j),j=null)}function f(e){for(var t=new Uint16Array(e),r="",o=0,n=t.length;o<n;o++)r+=String.fromCharCode(t[o]);return r}function d(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 g(e,t){o.asFunction(t);var r=new FileReader;r.onload=function(e){t(e.target.result)},r.readAsArrayBuffer(e)}Object.defineProperty(t,"__esModule",{value:!0});var b="undefined"!=typeof window?window:self,w=n||t;b.wijmo=b.wijmo||{},b.wijmo.grid=b.wijmo.grid||{},b.wijmo.grid.pdf=w;var _;!function(e){e[e.ActualSize=0]="ActualSize",e[e.PageWidth=1]="PageWidth",e[e.SinglePage=2]="SinglePage"}(_=t.ScaleMode||(t.ScaleMode={}));var y;!function(e){e[e.All=0]="All",e[e.Selection=1]="Selection"}(y=t.ExportMode||(t.ExportMode={}));var m;!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"}(m=t._CellType||(t._CellType={}));var C=function(e){function t(t,r,n,i,l,s,a,u,c){var h=e.call(this)||this;return h.cancelBorders=!1,h._p=t,h._rng=r,h._cell=o.asType(n,HTMLElement,!0),h._canvas=i,h._clientRect=l,h._contentRect=s,h._textTop=a,h._style=u,h._getFormattedCell=c,h}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 o.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}(o.CancelEventArgs);t.PdfFormatItemEventArgs=C,t._merge=c;var v=function(){function e(){}return e.draw=function(e,t,r,n,i,l){o.assert(!!e,"The flex argument cannot be null."),o.assert(!!t,"The doc argument cannot be null."),null==(l=this._applyDefaultDrawSettings(l)).scaleMode&&(l.scaleMode=null==n?_.ActualSize:null==i?_.PageWidth:_.SinglePage),this._drawInternal(e,t,r,n,i,l)},e._applyDefaultDrawSettings=function(t){return c(c({},t),e.DefaultDrawSettings)},e._drawInternal=function(e,t,r,n,i,l){var s=null!=r,a=new o.Size(t.width,t.height);r||(r=new o.Point(0,t.y)),o.isArray(l.embeddedFonts)&&l.embeddedFonts.forEach(function(e){t.registerFont(e)});var u=this._getRowsToRender(e,l),c=new R(e,l,u,this.BorderWidth,!0),h=new o.Rect(r.x||0,r.y||0,n||a.width,i||a.height),p=this._getScaleFactor(c,l.scaleMode,h),f=this._getPages(c,u,h,l,s,p),d=(l.progress?this._getCellsCount(e,l,f):0)/l._progressMax,g=0,b=0,w=l.progress?function(){++g-b>=50&&(b=g,l.progress(g/d))}:null;l.progress&&l.progress(0);for(var _=0;_<f.length;_++){_>0&&t.addPage();var y=f[_],m=0===y.pageCol?h.left:0,C=0===y.pageRow?h.top:0;t.saveState(),t.paths.rect(0,0,a.width,a.height).clip(),t.scale(p,p,new o.Point(m,C)),t.translate(m,C);var v=new R(e,l,y.range,this.BorderWidth,_===f.length-1);v.render(t,w),t.restoreState(),t.x=m,t.y=C+v.renderSize.height*p}l.progress&&0<l._progressMax&&l.progress(l._progressMax)},e._getCellsCount=function(e,t,r){for(var o=0,n=0;n<r.length;n++)o+=new R(e,t,r[n].range,0,!1).getCellsCount();return o},e._getRowsToRender=function(e,t){var r=[];t.exportMode===y.All?r.push(new T(null,0,0,e.rows.length-1,e.columns.length-1)):r=e.getSelection();var o=new O(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 T(null,o,r.col,o,r.col2))}}),o=new O(n)}return o},e._getScaleFactor=function(e,t,r){var o=1;if(t===_.ActualSize)return o;var n=e.renderSize;if(t===_.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,o,n,i,l){var s=this,a=[],u=[],c=r.pxToPt,h=e.flex,p=e.showColumnHeader,f=e.showColumnFooter,d=e.showRowHeader,g=p?c(h.columnHeaders.height):0,b=f?c(h.columnFooters.height):0,w=d?c(h.rowHeaders.width):0,y=n.scaleMode===_.ActualSize||n.scaleMode===_.PageWidth,m=n.scaleMode===_.ActualSize,C=(o.width-o.left)*(1/l),v=(o.height-o.top)*(1/l),R=o.width*(1/l),x=o.height*(1/l),P=g+b,S=w,T=i&&n.scaleMode==_.ActualSize;if(y){var j=0;t.forEach(h.cells,function(t,r,o,n){var i=a.length?x:v;if(e.isRenderableRow(t)){var l=c(t.renderHeight);j++,P+=l,(p||j>1)&&(P-=s.BorderWidth),P>i&&(g+l>i||T?(a.push(n),P=g):(a.push(n-1),P=g+l),p&&(P-=s.BorderWidth))}})}var O=t.length()-1;if(O<0&&(O=0),a.length&&a[a.length-1]===O||a.push(O),m)for(var z=0,M=t.leftCol;M<=t.rightCol;M++){var F=h.columns[M];if(F.isVisible){var L=c(F.renderWidth),W=u.length?R:C;z++,S+=L,(d||z>1)&&(S-=this.BorderWidth),S>W&&(w+L>W||T?(u.push(M),S=w):(u.push(M-1),S=w+L),d&&(S-=this.BorderWidth))}}u.length&&u[u.length-1]===t.rightCol||u.push(t.rightCol);for(var A=[],D=!1,G=1,V=i&&n.maxPages>0?1:n.maxPages,M=0;M<a.length&&!D;M++)for(var E=0;E<u.length&&!D;E++,G++)if(!(D=G>V)){var B=0==M?0:a[M-1]+1,N=0==E?t.leftCol:u[E-1]+1;A.push(new H(t.subrange(B,a[M]-B+1,N,u[E]),E,M))}return A},e.BorderWidth=1,e.DefFont=new r.PdfFont,e.DefaultDrawSettings={customCellContent:!1,drawDetailRows:!1,exportMode:y.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}();t._FlexGridPdfConverterCore=v;var R=function(){function e(e,t,r,o,n){this._flex=e,this._borderWidth=o,this._lastPage=n,this._settings=t||{},this._topLeft=new x(this,e.topLeftCells,new O(this.showRowHeader&&this.showColumnHeader?[new T(null,0,0,e.topLeftCells.rows.length-1,e.topLeftCells.columns.length-1)]:[]),o),this._rowHeader=new x(this,e.rowHeaders,this.showRowHeader?r.clone(0,e.rowHeaders.columns.length-1):new O([]),o),this._columnHeader=new x(this,e.columnHeaders,new O(this.showColumnHeader?[new T(null,0,r.leftCol,e.columnHeaders.rows.length-1,r.rightCol)]:[]),o),this._cells=new x(this,e.cells,r,o),this._bottomLeft=new x(this,e.bottomLeftCells,new O(this.showRowHeader&&this.showColumnFooter?[new T(null,0,0,e.bottomLeftCells.rows.length-1,e.bottomLeftCells.columns.length-1)]:[]),o),this._columnFooter=new x(this,e.columnFooters,new O(this.showColumnFooter?[new T(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 o.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}(),x=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 o=0,n=0,i=this.panel,l=e;l<=t;l++){var s=i.columns[l];s.isVisible&&(n++,o+=s.renderWidth)}return o=r.pxToPt(o),n>1&&(o-=this._borderWidth*(n-1)),o},t.prototype.getRangeHeight=function(e,t){for(var o=0,n=0,i=this.panel,l=e;l<=t;l++){var s=i.rows[l];this.isRenderableRow(s)&&(n++,o+=s.renderHeight)}return o=r.pxToPt(o),n>1&&(o-=this._borderWidth*(n-1)),o},t.prototype.getCellsCount=function(){var e=this,t=0,r=this.range,o=this.panel,n=new S(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 h=null;(h=n.getMergedRange(o,s,a))?h.topRow!==h.bottomRow?h.firstVisibleRow!==s&&s!==l.topRow||(u=!0):(u=!0,c=Math.min(r.rightCol,h.rightCol)):u=!0,u&&t++,c&&(a=c)}}}),t):t},t.prototype.render=function(e,t,r,n){var i=this,l=this.range,s=this.panel,a=new S(this._gr.flex),u=new T(s,0,0,0,0),c=new P(this,e,this._borderWidth);if(l.isValid){for(var h={},p=l.leftCol;p<=l.rightCol;p++)h[p]=r;l.forEach(s,function(e,r,p){if(i.isRenderableRow(e))for(var f=t,d=l.leftCol;d<=l.rightCol;d++){var g,b=i.gr.getColumn(s,p,d),w=void 0,_=void 0,y=!1,m=void 0;if(b.isVisible){var C=i._gr.flex.getCellContent(i.panel,e,b,d),v=null;if(v=a.getMergedRange(s,p,d))if(u.copyFrom(v),v.topRow!==v.bottomRow)v.firstVisibleRow===p||p===r.topRow?(y=!0,g=i.gr.settings.repeatMergedValuesAcrossPages?C:v.firstVisibleRow===p?C:"",w=i.getRangeHeight(p,Math.min(v.bottomRow,r.bottomRow)),_=i.getRangeWidth(d,d)):_=i.getRangeWidth(d,d);else{y=!0,g=i.gr.settings.repeatMergedValuesAcrossPages?C:d===v.leftCol?C:"",w=i.getRangeHeight(p,p),_=i.getRangeWidth(Math.max(l.leftCol,v.leftCol),Math.min(l.rightCol,v.rightCol)),m=Math.min(l.rightCol,v.rightCol);for(var R=d+1;R<=m;R++)h[R]+=w-i._borderWidth}else u.setRange(p,d,p,d),y=!0,g=C,w=i.getRangeHeight(p,p),_=i.getRangeWidth(d,d);y&&(c.renderCell(g,e,b,u,new o.Rect(f,h[d],_,w)),n&&n()),w&&(h[d]+=w-i._borderWidth),_&&(f+=_-i._borderWidth),m&&(d=m)}}})}},t.prototype.isRenderableRow=function(e){return this._gr.isRenderableRow(e)},t}(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 o.Size(r.pxToPt(e.width),r.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}()),P=function(){function e(e,t,r){this._pr=e,this._area=t,this._borderWidth=r}return e.prototype.renderCell=function(e,t,n,i,l){var s,a=this._pr.gr.flex,u=this._pr.panel,c=function(){return a.getCell(u,i.topRow,i.leftCol)},h=null,p=this._pr.gr.getCellStyle(u,t,n);if(this._pr.gr.settings.customCellContent){var f=a.getComputedStyle(h=c());p.color=f.color,p.backgroundColor=f.backgroundColor,p.borderColor=f.borderColor||f.borderRightColor||f.borderBottomColor||f.borderLeftColor||f.borderTopColor,p.font=new r.PdfFont(f.fontFamily,r._asPt(f.fontSize,!0,void 0),f.fontStyle,f.fontWeight),p.textAlign=f.textAlign}if(p.font&&!(p.font instanceof r.PdfFont)){var d=p.font;p.font=new r.PdfFont(d.family,d.size,d.style,d.weight)}if(p.boxSizing="border-box",p.borderWidth=this._borderWidth,p.borderStyle="solid",p.textAlign||a.isGroupRow(t)&&!n.aggregate||(p.textAlign=n.getAlignment()),u.cellType===m.Cell&&a.rows.maxGroupLevel>=0&&i.leftCol===a.columns.firstVisibleIndex){var g=a.isGroupRow(t)?Math.max(t.level,0):a.rows.maxGroupLevel+1,b=r._asPt(p.paddingLeft||p.padding),w=r.pxToPt(g*a.treeIndent);console.log(g),p.paddingLeft=b+w}var _,y=this._measureCell(e,u,t,n,p,l),v=i.rowSpan>1&&i.visibleRowsCount>1&&this._pr.gr.alignMergedTextToTheTopRow(u);v&&(_=new o.Rect(y.contentRect.left,y.contentRect.top,y.contentRect.width,y.contentRect.height/(i.visibleRowsCount||1)),y.textRect=this._calculateTextRect(e,u,t,n,_,p)),o.isFunction(this._pr.gr.settings.formatItem)&&((s=new C(u,i,h,this._area,y.rect,y.contentRect,y.textRect.top,p,function(){return h||c()})).data=e,this._pr.gr.settings.formatItem(s),s.data!==e&&(e=o.asString(s.data),y.textRect=this._calculateTextRect(e,u,t,n,v?_:y.contentRect,p))),this._renderCell(e,t,n,i,y,p,!s||!s.cancel,!s||!s.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=o.isString(e)&&e.toLowerCase();return"true"===t||"false"===t||!0===e||!1===e},e.prototype._measureCell=function(e,t,n,i,l,s){this._decompositeStyle(l);var a=s.left,u=s.top,c=s.height,h=s.width,p=this._parseBorder(l),f=p.left.width,d=p.top.width,g=p.bottom.width,b=p.right.width,w=this._parsePadding(l),_=0,y=0,m=0,C=0;if("content-box"===l.boxSizing||void 0===l.boxSizing)_=w.top+c+w.bottom,y=w.left+h+w.right,m=c,C=h;else{if("border-box"!==l.boxSizing)throw"Invalid value: "+l.boxSizing;r._IE&&l instanceof CSSStyleDeclaration?(_=w.top+w.bottom+c,y=w.left+w.right+h):(_=c-d-g,y=h-f-b),m=_-w.top-w.bottom,C=y-w.left-w.right}var s=new o.Rect(a,u,h,c),v=new o.Rect(a+f,u+d,y,_),R=new o.Rect(a+f+w.left,u+d+w.top,C,m);return{rect:s,clientRect:v,contentRect:R,textRect:this._calculateTextRect(e,t,n,i,R,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:r._asPt(e.borderLeftWidth),style:e.borderLeftStyle,color:e.borderLeftColor}),"none"!==e.borderTopStyle&&(t.top={width:r._asPt(e.borderTopWidth),style:e.borderTopStyle,color:e.borderTopColor}),"none"!==e.borderBottomStyle&&(t.bottom={width:r._asPt(e.borderBottomWidth),style:e.borderBottomStyle,color:e.borderBottomColor}),"none"!==e.borderRightStyle&&(t.right={width:r._asPt(e.borderRightWidth),style:e.borderRightStyle,color:e.borderRightColor}),t},e.prototype._parsePadding=function(e){return{left:r._asPt(e.paddingLeft),top:r._asPt(e.paddingTop),bottom:r._asPt(e.paddingBottom),right:r._asPt(e.paddingRight)}},e.prototype._renderEmptyCell=function(e,t,o,n){var i=e.rect.left,l=e.rect.top,s=e.clientRect.width,a=e.clientRect.height,u=e.clientRect.left-e.rect.left,c=e.clientRect.top-e.rect.top,h=e.rect.top+e.rect.height-(e.clientRect.top+e.clientRect.height),p=e.rect.left+e.rect.width-(e.clientRect.left+e.clientRect.width);if(n&&(u||p||h||c)){var f=t.borderLeftColor||t.borderColor,d=t.borderRightColor||t.borderColor,g=t.borderTopColor||t.borderColor,b=t.borderBottomColor||t.borderColor;if(u&&c&&h&&p&&u===p&&u===h&&u===c&&f===d&&f===b&&f===g){var w=u,_=w/2;this._area.paths.rect(i+_,l+_,s+w,a+w).stroke(new r.PdfPen(f,w))}else u&&this._area.paths.polygon([[i,l],[i+u,l+c],[i+u,l+c+a],[i,l+c+a+h]]).fill(f),c&&this._area.paths.polygon([[i,l],[i+u,l+c],[i+u+s,l+c],[i+u+s+p,l]]).fill(g),p&&this._area.paths.polygon([[i+u+s+p,l],[i+u+s,l+c],[i+u+s,l+c+a],[i+u+s+p,l+c+a+h]]).fill(d),h&&this._area.paths.polygon([[i,l+c+a+h],[i+u,l+c+a],[i+u+s,l+c+a],[i+u+s+p,l+c+a+h]]).fill(b)}o&&t.backgroundColor&&s>0&&a>0&&this._area.paths.rect(i+u,l+c,s,a).fill(t.backgroundColor)},e.prototype._renderBooleanCell=function(e,t,n,i,l){if(this._renderEmptyCell(t,n,i,l),i){var s=t.textRect.left,a=t.textRect.top,u=t.textRect.height;if(this._area.paths.rect(s,a,u,u).fillAndStroke(o.Color.fromRgba(255,255,255),new r.PdfPen(void 0,.5)),!0===o.changeType(e,o.DataType.Boolean,"")){var c=u/20,h=u-.5-2*c,p=u/8;this._area.document.saveState(),this._area.translate(s+.25+c,a+.25+c).paths.moveTo(p/2,.6*h).lineTo(h-.6*h,h-p).lineTo(h-p/2,p/2).stroke(new r.PdfPen(void 0,p)),this._area.document.restoreState()}}},e.prototype._renderTextCell=function(e,t,o,n,i){this._renderEmptyCell(t,o,n,i),n&&e&&this._area.drawText(e,t.textRect.left,t.textRect.top,{brush:o.color,font:o.font,height:t.textRect.height,width:t.textRect.width,align:"center"===o.textAlign?r.PdfTextHorizontalAlign.Center:"right"===o.textAlign?r.PdfTextHorizontalAlign.Right:"justify"===o.textAlign?r.PdfTextHorizontalAlign.Justify:r.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}(),S=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 T(e,n):null},e}(),T=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 o.Size(0,0);if(this.isValid){for(var r=this.topRow;r<=this.bottomRow;r++)t.height+=e.rows[r].renderHeight;for(var n=this.leftCol;n<=this.rightCol;n++)t.width+=e.columns[n].renderWidth}return t},e.prototype.setRange=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=e),void 0===n&&(n=t),this._row=o.asInt(e),this._col=o.asInt(t),this._row2=o.asInt(r),this._col2=o.asInt(n)},e}();t._CellRange=T;var j,O=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 o.Size(0,0),r=0;r<this._ranges.length;r++){var n=this._ranges[r].getRenderSize(e);t.width=Math.max(t.width,n.width),t.height+=n.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,h=Math.min(u.bottomRow,c+r-1),p=arguments.length>2?o:u.leftCol,f=arguments.length>2?n:u.rightCol;i.push(new T(null,c,p,h,f)),r-=h-c+1}}return new e(i)},e}(),H=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}();t._removeFakeCell=p;var z=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,n,l,s,a){o.assert(!!e,"The flex argument cannot be null."),o.assert(!!t,"The doc argument cannot be null.");var u=void 0!==i().FlexGrid&&e instanceof i().FlexGrid;try{a=v._applyDefaultDrawSettings(a);var c=e;u&&(a&&a.recalculateStarWidths&&e.columns._updateStarSizes(r.ptToPx(t.width)),c=this._getFlexGridAdapter(e,a)),v.draw(c,t,n,l,s,a)}finally{p(),u&&a&&a.recalculateStarWidths&&e.invalidate(!0)}},e.export=function(e,t,n){o.assert(!!e,"The flex argument cannot be null."),o.assert(!!t,"The fileName argument cannot be empty.");var i=(n=this._applyDefaultExportSettings(n)).documentOptions.ended;n.documentOptions.ended=function(e,o){n.progress&&n.progress(1),i&&!1===i.apply(l,[e,o])||r.saveBlob(o.blob,t),e.dispose()};var l=new r.PdfDocument(n.documentOptions);this.drawToPosition(e,l,null,null,null,n),l.end()},e._getFlexGridAdapter=function(e,t){return new(l()&&e instanceof l().MultiRow&&W||s()&&e instanceof s().FlexSheet&&L||a()&&e instanceof a().PivotGrid&&A||F)(e,t)},e._applyDefaultExportSettings=function(e){return c(c({},e),this._DefaultExportSettings)},e._DefaultExportSettings=c({scaleMode:_.PageWidth,documentOptions:{compress:!1,pageSettings:{margins:{left:36,right:36,top:18,bottom:18}}},_progressMax:.9},v.DefaultDrawSettings),e}();t.FlexGridPdfConverter=z;var M,F=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 i().SelectionMode.None:break;case i().SelectionMode.Cell:case i().SelectionMode.CellRange:e.push(t);break;case i().SelectionMode.Row:e.push(new(i().CellRange)(t.topRow,0,t.topRow,this._flex.cells.columns.length-1));break;case i().SelectionMode.RowRange:e.push(new(i().CellRange)(t.topRow,0,t.bottomRow,this._flex.cells.columns.length-1));break;case i().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(i().CellRange)(r,0,o,this._flex.cells.columns.length-1))):(r>=0&&e.push(new(i().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=h(),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&i().HeadersVisibility.Column)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showRowHeader",{get:function(){return!!(this._flex.headersVisibility&i().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),l=r.isContentHtml;if(!n&&e.cellType===i().CellType.Cell){var s=t;s instanceof i().GroupRow&&s.dataItem&&s.dataItem.groupDescription&&r.index===e.columns.firstVisibleIndex&&(l=!0,n=s.getGroupHeader())}if(l)(a=h()).innerHTML=n,n=a.textContent.trim();else if(this.settings.customCellContent){var a=this.getCell(e,t.index,o);!(n=a.textContent.trim())&&this.isBooleanCell(e,t,r)&&(n=this._extractCheckboxValue(a)+"")}return n},e.prototype.isBooleanCell=function(e,t,r){return r.dataType===o.DataType.Boolean&&e.cellType===i().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 i().GroupRow},e.prototype.isNewRow=function(e){return e instanceof i()._NewRowTemplate},e.prototype.isDetailRow=function(e){return u()&&e instanceof u().DetailRow},e.prototype.isExpandableGroupRow=function(e){return e instanceof i().GroupRow&&e.hasChildren},e.prototype.getCellStyle=function(e,t,r){var o=this.settings.styles,n=c({},o.cellStyle),l=this._flex;switch(e.cellType){case i().CellType.Cell:this.isExpandableGroupRow(t)?c(n,o.groupCellStyle,!0):this.isAlternatingRow(t)&&c(n,o.altCellStyle,!0);break;case i().CellType.ColumnHeader:case i().CellType.RowHeader:case i().CellType.TopLeft:case i().CellType.BottomLeft:c(n,o.headerCellStyle,!0);break;case i().CellType.ColumnFooter:c(n,o.headerCellStyle,!0),c(n,o.footerCellStyle,!0)}return!this.settings.customCellContent&&l._getShowErrors()&&l._getError(e,t.index,r.index)&&c(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}(),L=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===i().CellType.Cell?t.rows[o]instanceof s().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,o,n){var i=e.prototype.getCellStyle.call(this,t,o,n),l=this.flex.selectedSheet.findTable(o.index,n.index);if(l){var s=l.getRange(),a=o.index-s.topRow,u=n.index-s.leftCol,h=l._getTableCellAppliedStyles(a,u);h&&(h.font=new r.PdfFont(h.fontFamily,r._asPt(h.fontSize,!0,void 0),h.fontStyle,h.fontWeight)),c(i,h,!0)}return i},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}(F),W=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 l()._MultiRow?t.dataIndex%2!=0:e.prototype.isAlternatingRow.call(this,t)},t}(F),A=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===i().CellType.ColumnHeader||e.cellType===i().CellType.RowHeader)},t}(F);!function(e){e[e.Done=1]="Done",e[e.Progress=2]="Progress"}(M||(M={}));var D=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}(o.EventArgs);t.PdfWebWorkerExportDoneEventArgs=D;var G=function(){function e(){}return e.exportGrid=function(e,t,n,i,l,s){(i=c({},i)).progress=i.progress||s,this.addGrid(e,t,"",i),this.export(e,i.documentOptions,function(e){o.isFunction(l)&&!1===l(e)||r.saveBlob(e.blob,n)},s)},e.export=function(e,t,r,n){e.addEventListener("message",function t(i){var l=i.data;switch(l.status){case M.Done:e.removeEventListener("message",t),o.isFunction(r)&&r(new D(l.data));break;case M.Progress:n&&n(l.data);break;default:throw"Unknown status: "+l.status}});var i=this._clientDataToArrayBuffer(e);e.postMessage({content:i,settings:t},[i]),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,n,i){var l=o.isString(t)&&t.indexOf("data:image/svg")>=0?t:r._PdfImageHelper.getDataUri(t);this._addClientData(e,l,n,i)},e.addString=function(e,t,r){this._addClientData(e,t,r,null)},e.serializeGrid=function(e,t){var r=this._gridToJson(e,t);return d(JSON.stringify(r))},e._addClientData=function(e,t,r,n,i){void 0===i&&(i=!1),o.asType(e,Worker),o.asString(r),o.asString(t,!0);var l=e;l.clientData=l.clientData||{},l.clientData[r]={content:t,settings:n?JSON.stringify(n):null};var s=l.clientData[r];i&&(s.isGrid=!0,s.progressMessaging=o.isFunction(n.progress))},e._clearClientData=function(e){delete e.clientData},e._clientDataToArrayBuffer=function(e){var t=e;return d(JSON.stringify(t.clientData||{}))},e._gridToJson=function(e,t){t=z._applyDefaultExportSettings(t);var o;try{o=new r.PdfDocument(t.documentOptions),t&&t.recalculateStarWidths&&e.columns._updateStarSizes(r.ptToPx(o.width));var n=this._getJsonConverter(e,t).convert();d(JSON.stringify(n));return n}finally{p(),t&&t.recalculateStarWidths&&e.invalidate(!0),null!=o&&(o.dispose(),o=null)}},e._getJsonConverter=function(e,t){return new(l()&&e instanceof l().MultiRow&&I||a()&&e instanceof a().PivotGrid&&k||N)(e,z._getFlexGridAdapter(e,t))},e}();t.PdfWebWorkerClient=G;var V=function(){function e(){}return e.initExportGrid=function(){var e=this;this.initExport(function(t,r){var o=r[""];o.progressMessaging&&(o.settings._progressMax=z._DefaultExportSettings._progressMax,o.settings.progress=function(t){e.sendExportProgress(t)},t.ended.addHandler(function(){e.sendExportProgress(1)})),z.draw(o.content,t,null,null,o.settings),t.end()})},e.initExport=function(t){self.addEventListener("message",function o(n){self.removeEventListener("message",o);var i=n.data,l=JSON.parse(f(i.content)),s=i.settings||{};s.ended=function(e,t){g(t.blob,function(e){self.postMessage({data:e,status:M.Done},[e])})};var a=new r.PdfDocument(s);Object.keys(l).forEach(function(t){var r=l[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(a,l)})},e.sendExportProgress=function(e){e=o.clamp(e,0,1),self.postMessage({data:e,status:M.Progress})},e.deserializeGrid=function(e,t){return this._deserializeGridFromString(f(e),t)},e._deserializeGridFromString=function(e,t){return this._getJsonAdapter(JSON.parse(e),z._applyDefaultExportSettings(t))},e._disableUnsupportedFeatures=function(e){e.customCellContent=!1},e._getJsonAdapter=function(e,t){switch(e.typeName){case"MultiRow":return new $(e,t);case"PivotGrid":return new Y(e,t);default:return new Q(e,t)}},e}();t.PdfWebWorker=V;var E;!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"}(E||(E={}));var B;!function(e){e[e.None=0]="None",e[e.Visible=1]="Visible"}(B||(B={}));var N=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=E.None;return this.adapter.isAlternatingRow(e)&&(t|=E.Alternate),e instanceof i().GroupRow&&(t|=E.Group),this.adapter.isDetailRow(e)&&(t|=E.Detail),this.adapter.isExpandableGroupRow(e)&&(t|=E.ExpandableGroup),e instanceof i()._NewRowTemplate&&(t|=E.New),e.isVisible&&(t|=E.Visible),t},e.prototype._getColumnState=function(e){var t=B.None;return e.isVisible&&(t|=B.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!=B.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 l=e.rows[r],s={renderHeight:l.renderHeight};t.rows.push(s),l instanceof i().GroupRow&&(s.level=l.level);var a=this._getRowState(l);a!=E.None&&(s.state=a),s.cells=[];for(var u=0;u<n;u++)s.cells[u]=this._adapter.getCellContent(e,e.rows[r],e.columns[u],u)}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}(),I=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!=i().CellType.TopLeft&&e.cellType!=i().CellType.ColumnHeader||(o=e.rows.length);for(var n=0;n<o;n++){r[n]=[];for(var l=0;l<e.columns.length;l++){var s=this.flex.getBindingColumn(e,n,l),a=t.indexOf(s);r[n][l]=a<0?t.push(s)-1:a}}return{bindingColumns:this._serializeColumns(t),mappings:r}},t}(N),k=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}(N),J=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&E.Alternate)!=E.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isGroupRow",{get:function(){return(this._state&E.Group)!=E.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDetailRow",{get:function(){return(this._state&E.Detail)!=E.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isExpandableGroupRow",{get:function(){return(this._state&E.ExpandableGroup)!=E.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isNewRow",{get:function(){return(this._state&E.New)!=E.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return(this._state&E.Visible)!=E.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}(),U=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&B.Visible)!=B.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}(),q=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 J(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}(),X=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 U(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}(),K=function(){function e(e){this._height=e.height,this._width=e.width,this._cellType=e.cellType,this._columns=new X(e.columns,e.columnsFirstVisibleIndex),this._rows=new q(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 T(null,n[0],n[1],n[2],n[3]),l=i.row;l<=i.row2;l++)t[l].push(i);return t},e}(),Q=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 T(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===o.DataType.Boolean&&e.cellType===m.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=c({},o.cellStyle);switch(e.cellType){case m.Cell:this.isExpandableGroupRow(t)?c(n,o.groupCellStyle,!0):this.isAlternatingRow(t)&&c(n,o.altCellStyle,!0);break;case m.ColumnHeader:case m.RowHeader:case m.TopLeft:case m.BottomLeft:c(n,o.headerCellStyle,!0);break;case m.ColumnFooter:c(n,o.headerCellStyle,!0),c(n,o.footerCellStyle,!0)}return n},e.prototype.deserializePanel=function(e){return new K(e)},e}(),Y=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===m.ColumnHeader||e.cellType===m.RowHeader)},t}(Q),Z=function(e){function t(t){var r=e.call(this,t)||this;return t.cellGroups&&(r._cellGroups={bindingColumns:new X(t.cellGroups.bindingColumns),mappings:t.cellGroups.mappings}),r}return __extends(t,e),t.prototype.getColumn=function(e,t,r){return this._cellGroups?(this.cellType!==m.ColumnHeader&&this.cellType!==m.BottomLeft&&(e%=r),this._cellGroups.bindingColumns[this._cellGroups.mappings[e][t]]):this.columns[t]},t}(K),$=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 Z(e)},t.prototype.getColumn=function(e,t,r){return e.getColumn(t,r,this._rowsPerItem)},t}(Q)});