pdfmake
Version:
Client/server side PDF printing in pure JavaScript
2 lines • 1.27 MB
JavaScript
/*! pdfmake v0.3.0-beta.14, @license MIT, @link http://pdfmake.org */
!function webpackUniversalModuleDefinition(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}("undefined"!=typeof self?self:this,(()=>(()=>{var t={428:(t,r,n)=>{"use strict";n.d(r,{default:()=>ge});var i=n(6837),a=n(783).Buffer;class PDFDocument extends i.A{constructor(t,r,n,i,a,o){void 0===t&&(t={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===i&&(i={}),void 0===a&&(a={}),void 0===o&&(o=null),super(a),this.fonts={},this.fontCache={};for(let r in t)if(t.hasOwnProperty(r)){let n=t[r];this.fonts[r]={normal:n.normal,bold:n.bold,italics:n.italics,bolditalics:n.bolditalics}}this.patterns={};for(let t in n)if(n.hasOwnProperty(t)){let r=n[t];this.patterns[t]=this.pattern(r.boundingBox,r.xStep,r.yStep,r.pattern,r.colored)}this.images=r,this.attachments=i,this.virtualfs=o}getFontType(t,r){return((t,r)=>{let n="normal";return t&&r?n="bolditalics":t?n="bold":r&&(n="italics"),n})(t,r)}getFontFile(t,r,n){let i=this.getFontType(r,n);return this.fonts[t]&&this.fonts[t][i]?this.fonts[t][i]:null}provideFont(t,r,n){let i=this.getFontType(r,n);if(null===this.getFontFile(t,r,n))throw new Error(`Font '${t}' in style '${i}' is not defined in the font section of the document definition.`);if(this.fontCache[t]=this.fontCache[t]||{},!this.fontCache[t][i]){let r=this.fonts[t][i];Array.isArray(r)||(r=[r]),this.virtualfs&&this.virtualfs.existsSync(r[0])&&(r[0]=this.virtualfs.readFileSync(r[0])),this.fontCache[t][i]=this.font(...r)._font}return this.fontCache[t][i]}provideImage(t){const realImageSrc=t=>{let r=this.images[t];if(!r)return t;if(this.virtualfs&&this.virtualfs.existsSync(r))return this.virtualfs.readFileSync(r);let n=r.indexOf("base64,");return n<0?this.images[t]:a.from(r.substring(n+7),"base64")};if(this._imageRegistry[t])return this._imageRegistry[t];let r;try{if(r=this.openImage(realImageSrc(t)),!r)throw new Error("No image")}catch(t){throw new Error(`Invalid image: ${t.toString()}\nImages dictionary should contain dataURL entries (or local file paths in node.js)`)}return r.embed(this),this._imageRegistry[t]=r,r}providePattern(t){return Array.isArray(t)&&2===t.length?[this.patterns[t[0]],t[1]]:null}provideAttachment(t){const checkRequired=t=>{if(!t)throw new Error("No attachment");if(!t.src)throw new Error('The "src" key is required for attachments');return t};if("object"==typeof t)return checkRequired(t);let r=checkRequired(this.attachments[t]);return this.virtualfs&&this.virtualfs.existsSync(r.src)?this.virtualfs.readFileSync(r.src):r}setOpenActionAsPrint(){let t=this.ref({Type:"Action",S:"Named",N:"Print"});this._root.data.OpenAction=t,t.end()}}const o=PDFDocument;function isString(t){return"string"==typeof t||t instanceof String}function isNumber(t){return"number"==typeof t||t instanceof Number}function isPositiveInteger(t){return!(!isNumber(t)||!Number.isInteger(t)||t<=0)}function isObject(t){return null!==t&&!Array.isArray(t)&&!isString(t)&&!isNumber(t)&&"object"==typeof t}function isEmptyObject(t){return isObject(t)&&0===Object.keys(t).length}function isValue(t){return null!=t}function fontStringify(t,r){return"font"===t?"font":r}function stringifyNode(t){return JSON.stringify(t,fontStringify)}function getNodeId(t){if(t.id)return t.id;if(Array.isArray(t.text))for(let r of t.text){let t=getNodeId(r);if(t)return t}return null}var s=n(783).Buffer;const convertValueToString=t=>isString(t)?t.replace(/\t/g," "):isNumber(t)||"boolean"==typeof t?t.toString():!isValue(t)||isEmptyObject(t)?"":t;const l=class DocPreprocessor{preprocessDocument(t){return this.parentNode=null,this.tocs=[],this.nodeReferences=[],this.preprocessNode(t)}preprocessNode(t){if(Array.isArray(t)?t={stack:t}:isString(t)||isNumber(t)||"boolean"==typeof t||!isValue(t)||isEmptyObject(t)?t={text:convertValueToString(t)}:"text"in t&&(t.text=convertValueToString(t.text)),t.columns)return this.preprocessColumns(t);if(t.stack)return this.preprocessVerticalContainer(t);if(t.ul)return this.preprocessList(t);if(t.ol)return this.preprocessList(t);if(t.table)return this.preprocessTable(t);if(void 0!==t.text)return this.preprocessText(t);if(t.toc)return this.preprocessToc(t);if(t.image)return this.preprocessImage(t);if(t.svg)return this.preprocessSVG(t);if(t.canvas)return this.preprocessCanvas(t);if(t.qr)return this.preprocessQr(t);if(t.attachment)return this.preprocessAttachment(t);if(t.pageReference||t.textReference)return this.preprocessText(t);throw new Error(`Unrecognized document structure: ${stringifyNode(t)}`)}preprocessColumns(t){let r=t.columns;for(let t=0,n=r.length;t<n;t++)r[t]=this.preprocessNode(r[t]);return t}preprocessVerticalContainer(t){let r=t.stack;for(let t=0,n=r.length;t<n;t++)r[t]=this.preprocessNode(r[t]);return t}preprocessList(t){let r=t.ul||t.ol;for(let t=0,n=r.length;t<n;t++)r[t]=this.preprocessNode(r[t]);return t}preprocessTable(t){let r,n,i,a;for(r=0,i=t.table.body[0].length;r<i;r++)for(n=0,a=t.table.body.length;n<a;n++){let i=t.table.body[n],a=i[r];void 0!==a&&(null===a&&(a=""),a._span||(i[r]=this.preprocessNode(a)))}return t}preprocessText(t){if(t.tocItem){Array.isArray(t.tocItem)||(t.tocItem=[t.tocItem]);for(let r=0,n=t.tocItem.length;r<n;r++){isString(t.tocItem[r])||(t.tocItem[r]="_default_");let n=t.tocItem[r];this.tocs[n]||(this.tocs[n]={toc:{_items:[],_pseudo:!0}}),t.id||(t.id=`toc-${n}-${this.tocs[n].toc._items.length}`);let i={_nodeRef:this._getNodeForNodeRef(t),_textNodeRef:t};this.tocs[n].toc._items.push(i)}}if(t.id)if(this.nodeReferences[t.id]){if(!this.nodeReferences[t.id]._pseudo)throw new Error(`Node id '${t.id}' already exists`);this.nodeReferences[t.id]._nodeRef=this._getNodeForNodeRef(t),this.nodeReferences[t.id]._textNodeRef=t,this.nodeReferences[t.id]._pseudo=!1}else this.nodeReferences[t.id]={_nodeRef:this._getNodeForNodeRef(t),_textNodeRef:t};if(t.pageReference&&(this.nodeReferences[t.pageReference]||(this.nodeReferences[t.pageReference]={_nodeRef:{},_textNodeRef:{},_pseudo:!0}),t.text="00000",t.linkToDestination=t.pageReference,t._pageRef=this.nodeReferences[t.pageReference]),t.textReference&&(this.nodeReferences[t.textReference]||(this.nodeReferences[t.textReference]={_nodeRef:{},_pseudo:!0}),t.text="",t.linkToDestination=t.textReference,t._textRef=this.nodeReferences[t.textReference]),t.text&&t.text.text)t.text=[this.preprocessNode(t.text)];else if(Array.isArray(t.text)){let r=!1;null===this.parentNode&&(this.parentNode=t,r=!0);for(let r=0,n=t.text.length;r<n;r++)t.text[r]=this.preprocessNode(t.text[r]);r&&(this.parentNode=null)}return t}preprocessToc(t){if(t.toc.id||(t.toc.id="_default_"),t.toc.title=t.toc.title?this.preprocessNode(t.toc.title):null,t.toc._items=[],this.tocs[t.toc.id]){if(!this.tocs[t.toc.id].toc._pseudo)throw new Error(`TOC '${t.toc.id}' already exists`);t.toc._items=this.tocs[t.toc.id].toc._items}return this.tocs[t.toc.id]=t,t}preprocessImage(t){return void 0!==t.image.type&&void 0!==t.image.data&&"Buffer"===t.image.type&&Array.isArray(t.image.data)&&(t.image=s.from(t.image.data)),t}preprocessCanvas(t){return t}preprocessSVG(t){return t}preprocessQr(t){return t}preprocessAttachment(t){return t}_getNodeForNodeRef(t){return this.parentNode?this.parentNode:t}};var h=n(9534),u=n.n(h);class StyleContextStack{constructor(t,r){void 0===r&&(r={}),this.styleDictionary=t,this.defaultStyle=r,this.styleOverrides=[]}clone(){let t=new StyleContextStack(this.styleDictionary,this.defaultStyle);return this.styleOverrides.forEach((r=>{t.styleOverrides.push(r)})),t}push(t){this.styleOverrides.push(t)}pop(t){for(void 0===t&&(t=1);t-- >0;)this.styleOverrides.pop()}autopush(t){if(isString(t))return 0;let r=[];t.style&&(r=Array.isArray(t.style)?t.style:[t.style]);for(let t=0,n=r.length;t<n;t++)this.push(r[t]);return this.push(t),r.length+1}auto(t,r){let n=this.autopush(t),i=r();return n>0&&this.pop(n),i}getProperty(t){if(this.styleOverrides)for(let r=this.styleOverrides.length-1;r>=0;r--){let n=this.styleOverrides[r];if(isString(n)){let r=this.styleDictionary[n];if(r&&isValue(r[t]))return r[t]}else if(isValue(n[t]))return n[t]}return this.defaultStyle&&this.defaultStyle[t]}static getStyleProperty(t,r,n,i){let a;return isValue(t[n])?t[n]:r?(r.auto(t,(()=>{a=r.getProperty(n)})),isValue(a)?a:i):i}static copyStyle(t,r){void 0===t&&(t={}),void 0===r&&(r={});for(let n in t)"text"!=n&&t.hasOwnProperty(n)&&(r[n]=t[n]);return r}}const p=StyleContextStack,splitWords=(t,r)=>{let n=[];if(r)return n.push({text:t}),n;let i,a=new(u())(t),o=0;for(;i=a.nextBreak();){let r=t.slice(o,i.position);i.required||r.match(/\r?\n$|\r$/)?(r=r.replace(/\r?\n$|\r$/,""),n.push({text:r,lineEnd:!0})):n.push({text:r}),o=i.position}return n},getFirstWord=(t,r)=>{let n=t[0];if(void 0===n)return null;if(r){let t=splitWords(n.text,!1);if(void 0===t[0])return null;n=t[0]}return n.text},getLastWord=(t,r)=>{let n=t[t.length-1];if(void 0===n)return null;if(n.lineEnd)return null;if(r){let t=splitWords(n.text,!1);if(void 0===t[t.length-1])return null;n=t[t.length-1]}return n.text};const g=class TextBreaker{getBreaks(t,r){let n=[];Array.isArray(t)||(t=[t]);let i=null;for(let a=0,o=t.length;a<o;a++){let s,l=t[a],h=null,u=p.getStyleProperty(l||{},r,"noWrap",!1);if(isObject(l)?(l._textRef&&l._textRef._textNodeRef.text&&(l.text=l._textRef._textNodeRef.text),s=splitWords(l.text,u),h=p.copyStyle(l)):s=splitWords(l,u),i&&s.length){let t=getFirstWord(s,u);1===splitWords(i+t,!1).length&&(n[n.length-1].noNewLine=!0)}for(let t=0,r=s.length;t<r;t++){let r={text:s[t].text};s[t].lineEnd&&(r.lineEnd=!0),p.copyStyle(h,r),n.push(r)}i=null,a+1<o&&(i=getLastWord(s,u))}return n}},m=/^(\s)+/g,y=/(\s)+$/g;const v=class TextInlines{constructor(t){this.pdfDocument=t}buildInlines(t,r){const getTrimmedWidth=t=>Math.max(0,t.width-t.leadingCut-t.trailingCut);let n,i=0,a=0,o=(s=t,Array.isArray(s)||(s=[s]),function flatten(t){return t.reduce(((t,r)=>{let n=Array.isArray(r.text)?flatten(r.text):r,i=[].concat(n).some(Array.isArray);return t.concat(i?flatten(n):n)}),[])}(s));var s;let l=(new g).getBreaks(o,r),h=this.measure(l,r);return h.forEach((t=>{i=Math.max(i,getTrimmedWidth(t)),n||(n={width:0,leadingCut:t.leadingCut,trailingCut:0}),n.width+=t.width,n.trailingCut=t.trailingCut,a=Math.max(a,getTrimmedWidth(n)),t.lineEnd&&(n=null)})),p.getStyleProperty({},r,"noWrap",!1)&&(i=a),{items:h,minWidth:i,maxWidth:a}}measure(t,r){if(t.length){let n=p.getStyleProperty(t[0],r,"leadingIndent",0);n&&(t[0].leadingCut=-n,t[0].leadingIndent=n)}return t.forEach((t=>{let n=p.getStyleProperty(t,r,"font","Roboto"),i=p.getStyleProperty(t,r,"bold",!1),a=p.getStyleProperty(t,r,"italics",!1);t.font=this.pdfDocument.provideFont(n,i,a),t.alignment=p.getStyleProperty(t,r,"alignment","left"),t.fontSize=p.getStyleProperty(t,r,"fontSize",12),t.fontFeatures=p.getStyleProperty(t,r,"fontFeatures",null),t.characterSpacing=p.getStyleProperty(t,r,"characterSpacing",0),t.color=p.getStyleProperty(t,r,"color","black"),t.decoration=p.getStyleProperty(t,r,"decoration",null),t.decorationColor=p.getStyleProperty(t,r,"decorationColor",null),t.decorationStyle=p.getStyleProperty(t,r,"decorationStyle",null),t.background=p.getStyleProperty(t,r,"background",null),t.link=p.getStyleProperty(t,r,"link",null),t.linkToPage=p.getStyleProperty(t,r,"linkToPage",null),t.linkToDestination=p.getStyleProperty(t,r,"linkToDestination",null),t.noWrap=p.getStyleProperty(t,r,"noWrap",null),t.opacity=p.getStyleProperty(t,r,"opacity",1),t.sup=p.getStyleProperty(t,r,"sup",!1),t.sub=p.getStyleProperty(t,r,"sub",!1),(t.sup||t.sub)&&(t.fontSize*=.58);let o=p.getStyleProperty(t,r,"lineHeight",1);if(t.width=this.widthOfText(t.text,t),t.height=t.font.lineHeight(t.fontSize)*o,t.leadingCut||(t.leadingCut=0),!p.getStyleProperty(t,r,"preserveLeadingSpaces",!1)){let r=t.text.match(m);r&&(t.leadingCut+=this.widthOfText(r[0],t))}if(t.trailingCut=0,!p.getStyleProperty(t,r,"preserveTrailingSpaces",!1)){let r=t.text.match(y);r&&(t.trailingCut=this.widthOfText(r[0],t))}}),this),t}widthOfText(t,r){return r.font.widthOfString(t,r.fontSize,r.fontFeatures)+(r.characterSpacing||0)*(t.length-1)}sizeOfText(t,r){let n=p.getStyleProperty({},r,"font","Roboto"),i=p.getStyleProperty({},r,"fontSize",12),a=p.getStyleProperty({},r,"fontFeatures",null),o=p.getStyleProperty({},r,"bold",!1),s=p.getStyleProperty({},r,"italics",!1),l=p.getStyleProperty({},r,"lineHeight",1),h=p.getStyleProperty({},r,"characterSpacing",0),u=this.pdfDocument.provideFont(n,o,s);return{width:this.widthOfText(t,{font:u,fontSize:i,characterSpacing:h,fontFeatures:a}),height:u.lineHeight(i)*l,fontSize:i,lineHeight:l,ascender:u.ascender/1e3*i,descender:u.descender/1e3*i}}sizeOfRotatedText(t,r,n){let i=r*Math.PI/-180,a=this.sizeOfText(t,n);return{width:Math.abs(a.height*Math.sin(i))+Math.abs(a.width*Math.cos(i)),height:Math.abs(a.width*Math.sin(i))+Math.abs(a.height*Math.cos(i))}}};function isAutoColumn(t){return"auto"===t.width}function isStarColumn(t){return null===t.width||void 0===t.width||"*"===t.width||"star"===t.width}const w={buildColumnWidths:function buildColumnWidths(t,r,n,i){void 0===n&&(n=0);let a=[],o=0,s=0,l=[],h=0,u=0,p=[],g=r;t.forEach((t=>{isAutoColumn(t)?(a.push(t),o+=t._minWidth,s+=t._maxWidth):isStarColumn(t)?(l.push(t),h=Math.max(h,t._minWidth),u=Math.max(u,t._maxWidth)):p.push(t)})),p.forEach(((t,a)=>{if(isString(t.width)&&/\d+%/.test(t.width)){let r=0;if(i){const t=i._layout.paddingLeft(a,i),n=i._layout.paddingRight(a,i),o=i._layout.vLineWidth(a,i),s=i._layout.vLineWidth(a+1,i);r=0===a?t+n+o+s/2:a===p.length-1?t+n+o/2+s:t+n+o/2+s/2}const o=g+n;t.width=parseFloat(t.width)*o/100-r}t.width<t._minWidth&&t.elasticWidth?t._calcWidth=t._minWidth:t._calcWidth=t.width,r-=t._calcWidth}));let m=o+h*l.length,y=s+u*l.length;if(m>=r)a.forEach((t=>{t._calcWidth=t._minWidth})),l.forEach((t=>{t._calcWidth=h}));else{if(y<r)a.forEach((t=>{t._calcWidth=t._maxWidth,r-=t._calcWidth}));else{let t=r-m,n=y-m;a.forEach((i=>{let a=i._maxWidth-i._minWidth;i._calcWidth=i._minWidth+a*t/n,r-=i._calcWidth}))}if(l.length>0){let t=r/l.length;l.forEach((r=>{r._calcWidth=t}))}}},measureMinMax:function measureMinMax(t){let r={min:0,max:0},n={min:0,max:0},i=0;for(let a=0,o=t.length;a<o;a++){let o=t[a];isStarColumn(o)?(n.min=Math.max(n.min,o._minWidth),n.max=Math.max(n.max,o._maxWidth),i++):isAutoColumn(o)?(r.min+=o._minWidth,r.max+=o._maxWidth):(r.min+=void 0!==o.width&&o.width||o._minWidth,r.max+=void 0!==o.width&&o.width||o._maxWidth)}return i&&(r.min+=i*n.min,r.max+=i*n.max),r},isAutoColumn,isStarColumn},S={noBorders:{hLineWidth:t=>0,vLineWidth:t=>0,paddingLeft:t=>t?4:0,paddingRight:(t,r)=>t<r.table.widths.length-1?4:0},headerLineOnly:{hLineWidth:(t,r)=>0===t||t===r.table.body.length?0:t===r.table.headerRows?2:0,vLineWidth:t=>0,paddingLeft:t=>0===t?0:8,paddingRight:(t,r)=>t===r.table.widths.length-1?0:8},lightHorizontalLines:{hLineWidth:(t,r)=>0===t||t===r.table.body.length?0:t===r.table.headerRows?2:1,vLineWidth:t=>0,hLineColor:t=>1===t?"black":"#aaa",paddingLeft:t=>0===t?0:8,paddingRight:(t,r)=>t===r.table.widths.length-1?0:8}},_={hLineWidth:(t,r)=>1,vLineWidth:(t,r)=>1,hLineColor:(t,r)=>"black",vLineColor:(t,r)=>"black",hLineStyle:(t,r)=>null,vLineStyle:(t,r)=>null,paddingLeft:(t,r)=>4,paddingRight:(t,r)=>4,paddingTop:(t,r)=>2,paddingBottom:(t,r)=>2,fillColor:(t,r)=>null,fillOpacity:(t,r)=>1,defaultBorder:!0};function pack(){let t={};for(let r=0,n=arguments.length;r<n;r++){let n=r<0||arguments.length<=r?void 0:arguments[r];if(n)for(let r in n)n.hasOwnProperty(r)&&(t[r]=n[r])}return t}function offsetVector(t,r,n){switch(t.type){case"ellipse":case"rect":t.x+=r,t.y+=n;break;case"line":t.x1+=r,t.x2+=r,t.y1+=n,t.y2+=n;break;case"polyline":for(let i=0,a=t.points.length;i<a;i++)t.points[i].x+=r,t.points[i].y+=n}}function convertToDynamicContent(t){return()=>JSON.parse(JSON.stringify(t))}for(var x=[null,[[10,7,17,13],[1,1,1,1],[]],[[16,10,28,22],[1,1,1,1],[4,16]],[[26,15,22,18],[1,1,2,2],[4,20]],[[18,20,16,26],[2,1,4,2],[4,24]],[[24,26,22,18],[2,1,4,4],[4,28]],[[16,18,28,24],[4,2,4,4],[4,32]],[[18,20,26,18],[4,2,5,6],[4,20,36]],[[22,24,26,22],[4,2,6,6],[4,22,40]],[[22,30,24,20],[5,2,8,8],[4,24,44]],[[26,18,28,24],[5,4,8,8],[4,26,48]],[[30,20,24,28],[5,4,11,8],[4,28,52]],[[22,24,28,26],[8,4,11,10],[4,30,56]],[[22,26,22,24],[9,4,16,12],[4,32,60]],[[24,30,24,20],[9,4,16,16],[4,24,44,64]],[[24,22,24,30],[10,6,18,12],[4,24,46,68]],[[28,24,30,24],[10,6,16,17],[4,24,48,72]],[[28,28,28,28],[11,6,19,16],[4,28,52,76]],[[26,30,28,28],[13,6,21,18],[4,28,54,80]],[[26,28,26,26],[14,7,25,21],[4,28,56,84]],[[26,28,28,30],[16,8,25,20],[4,32,60,88]],[[26,28,30,28],[17,8,25,23],[4,26,48,70,92]],[[28,28,24,30],[17,9,34,23],[4,24,48,72,96]],[[28,30,30,30],[18,9,30,25],[4,28,52,76,100]],[[28,30,30,30],[20,10,32,27],[4,26,52,78,104]],[[28,26,30,30],[21,12,35,29],[4,30,56,82,108]],[[28,28,30,28],[23,12,37,34],[4,28,56,84,112]],[[28,30,30,30],[25,12,40,34],[4,32,60,88,116]],[[28,30,30,30],[26,13,42,35],[4,24,48,72,96,120]],[[28,30,30,30],[28,14,45,38],[4,28,52,76,100,124]],[[28,30,30,30],[29,15,48,40],[4,24,50,76,102,128]],[[28,30,30,30],[31,16,51,43],[4,28,54,80,106,132]],[[28,30,30,30],[33,17,54,45],[4,32,58,84,110,136]],[[28,30,30,30],[35,18,57,48],[4,28,56,84,112,140]],[[28,30,30,30],[37,19,60,51],[4,32,60,88,116,144]],[[28,30,30,30],[38,19,63,53],[4,28,52,76,100,124,148]],[[28,30,30,30],[40,20,66,56],[4,22,48,74,100,126,152]],[[28,30,30,30],[43,21,70,59],[4,26,52,78,104,130,156]],[[28,30,30,30],[45,22,74,62],[4,30,56,82,108,134,160]],[[28,30,30,30],[47,24,77,65],[4,24,52,80,108,136,164]],[[28,30,30,30],[49,25,81,68],[4,28,56,84,112,140,168]]],A=/^\d*$/,C=/^[A-Za-z0-9 $%*+\-./:]*$/,P=/^[A-Z0-9 $%*+\-./:]*$/,k=[],T=[-1],B=0,I=1;B<255;++B)k.push(I),T[I]=B,I=2*I^(I>=128?285:0);var O=[[]];for(B=0;B<30;++B){for(var D=O[B],R=[],L=0;L<=B;++L){var M=L<B?k[D[L]]:0,N=k[(B+(D[L-1]||0))%255];R.push(T[M^N])}O.push(R)}var U={};for(B=0;B<45;++B)U["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".charAt(B)]=B;var W=[function(t,r){return(t+r)%2==0},function(t,r){return t%2==0},function(t,r){return r%3==0},function(t,r){return(t+r)%3==0},function(t,r){return((t/2|0)+(r/3|0))%2==0},function(t,r){return t*r%2+t*r%3==0},function(t,r){return(t*r%2+t*r%3)%2==0},function(t,r){return((t+r)%2+t*r%3)%2==0}],needsverinfo=function(t){return t>6},ndatabits=function(t,r){var n=-8&function(t){var r=x[t],n=16*t*t+128*t+64;return needsverinfo(t)&&(n-=36),r[2].length&&(n-=25*r[2].length*r[2].length-10*r[2].length-55),n}(t),i=x[t];return n-=8*i[0][r]*i[1][r]},ndatalenbits=function(t,r){switch(r){case 1:return t<10?10:t<27?12:14;case 2:return t<10?9:t<27?11:13;case 4:return t<10?8:16;case 8:return t<10?8:t<27?10:12}},getmaxdatalen=function(t,r,n){var i=ndatabits(t,n)-4-ndatalenbits(t,r);switch(r){case 1:return 3*(i/10|0)+(i%10<4?0:i%10<7?1:2);case 2:return 2*(i/11|0)+(i%11<6?0:1);case 4:return i/8|0;case 8:return i/13|0}},calculateecc=function(t,r){for(var n=t.slice(0),i=t.length,a=r.length,o=0;o<a;++o)n.push(0);for(o=0;o<i;){var s=T[n[o++]];if(s>=0)for(var l=0;l<a;++l)n[o+l]^=k[(s+r[l])%255]}return n.slice(i)},augumentbch=function(t,r,n,i){for(var a=t<<i,o=r-1;o>=0;--o)a>>i+o&1&&(a^=n<<o);return t<<i|a},maskdata=function(t,r,n){for(var i=W[n],a=t.length,o=0;o<a;++o)for(var s=0;s<a;++s)r[o][s]||(t[o][s]^=i(o,s));return t},putformatinfo=function(t,r,n,i){for(var a=t.length,o=21522^augumentbch(n<<3|i,5,1335,10),s=0;s<15;++s){var l=[a-1,a-2,a-3,a-4,a-5,a-6,a-7,a-8,7,5,4,3,2,1,0][s];t[[0,1,2,3,4,5,7,8,a-7,a-6,a-5,a-4,a-3,a-2,a-1][s]][8]=t[8][l]=o>>s&1}return t},evaluatematrix=function(t){for(var evaluategroup=function(t){for(var r=0,n=0;n<t.length;++n)t[n]>=5&&(r+=t[n]-5+3);for(n=5;n<t.length;n+=2){var i=t[n];t[n-1]==i&&t[n-2]==3*i&&t[n-3]==i&&t[n-4]==i&&(t[n-5]>=4*i||t[n+1]>=4*i)&&(r+=40)}return r},r=t.length,n=0,i=0,a=0;a<r;++a){var o,s=t[a];o=[0];for(var l=0;l<r;){for(h=0;l<r&&s[l];++h)++l;for(o.push(h),h=0;l<r&&!s[l];++h)++l;o.push(h)}n+=evaluategroup(o),o=[0];for(l=0;l<r;){var h;for(h=0;l<r&&t[l][a];++h)++l;for(o.push(h),h=0;l<r&&!t[l][a];++h)++l;o.push(h)}n+=evaluategroup(o);var u=t[a+1]||[];i+=s[0];for(l=1;l<r;++l){var p=s[l];i+=p,s[l-1]==p&&u[l]===p&&u[l-1]===p&&(n+=3)}}return n+=10*(Math.abs(i/r/r-.5)/.05|0)},generate=function(t,r,n,i,a){var o=x[r],s=function(t,r,n,i){var a=[],o=0,s=8,l=n.length,pack=function(t,r){if(r>=s){for(a.push(o|t>>(r-=s));r>=8;)a.push(t>>(r-=8)&255);o=0,s=8}r>0&&(o|=(t&(1<<r)-1)<<(s-=r))},h=ndatalenbits(t,r);switch(pack(r,4),pack(l,h),r){case 1:for(var u=2;u<l;u+=3)pack(parseInt(n.substring(u-2,u+1),10),10);pack(parseInt(n.substring(u-2),10),[0,4,7][l%3]);break;case 2:for(u=1;u<l;u+=2)pack(45*U[n.charAt(u-1)]+U[n.charAt(u)],11);l%2==1&&pack(U[n.charAt(u-1)],6);break;case 4:for(u=0;u<l;++u)pack(n[u],8)}for(pack(0,4),s<8&&a.push(o);a.length+1<i;)a.push(236,17);return a.length<i&&a.push(236),a}(r,n,t,ndatabits(r,i)>>3);s=function(t,r,n){for(var i=[],a=t.length/r|0,o=0,s=r-t.length%r,l=0;l<s;++l)i.push(o),o+=a;for(l=s;l<r;++l)i.push(o),o+=a+1;i.push(o);var h=[];for(l=0;l<r;++l)h.push(calculateecc(t.slice(i[l],i[l+1]),n));var u=[],p=t.length/r|0;for(l=0;l<p;++l)for(var g=0;g<r;++g)u.push(t[i[g]+l]);for(g=s;g<r;++g)u.push(t[i[g+1]-1]);for(l=0;l<n.length;++l)for(g=0;g<r;++g)u.push(h[g][l]);return u}(s,o[1][i],O[o[0][i]]);var l=function(t){for(var r=x[t],n=function(t){return 4*t+17}(t),i=[],a=[],o=0;o<n;++o)i.push([]),a.push([]);var blit=function(t,r,n,o,s){for(var l=0;l<n;++l)for(var h=0;h<o;++h)i[t+l][r+h]=s[l]>>h&1,a[t+l][r+h]=1};for(blit(0,0,9,9,[127,65,93,93,93,65,383,0,64]),blit(n-8,0,8,9,[256,127,65,93,93,93,65,127]),blit(0,n-8,9,8,[254,130,186,186,186,130,254,0,0]),o=9;o<n-8;++o)i[6][o]=i[o][6]=1&~o,a[6][o]=a[o][6]=1;var s=r[2],l=s.length;for(o=0;o<l;++o)for(var h=0===o?l-1:l,u=0===o||o===l-1?1:0;u<h;++u)blit(s[o],s[u],5,5,[31,17,21,17,31]);if(needsverinfo(t)){var p=augumentbch(t,6,7973,12),g=0;for(o=0;o<6;++o)for(u=0;u<3;++u)i[o][n-11+u]=i[n-11+u][o]=p>>g++&1,a[o][n-11+u]=a[n-11+u][o]=1}return{matrix:i,reserved:a}}(r),h=l.matrix,u=l.reserved;if(function(t,r,n){for(var i=t.length,a=0,o=-1,s=i-1;s>=0;s-=2){6==s&&--s;for(var l=o<0?i-1:0,h=0;h<i;++h){for(var u=s;u>s-2;--u)r[l][u]||(t[l][u]=n[a>>3]>>(7&~a)&1,++a);l+=o}o=-o}}(h,u,s),a<0){maskdata(h,u,0),putformatinfo(h,0,i,0);var p=0,g=evaluatematrix(h);for(maskdata(h,u,0),a=1;a<8;++a){maskdata(h,u,a),putformatinfo(h,0,i,a);var m=evaluatematrix(h);g>m&&(g=m,p=a),maskdata(h,u,a)}a=p}return maskdata(h,u,a),putformatinfo(h,0,i,a),h};function generateFrame(t,r){var n={numeric:1,alphanumeric:2,octet:4},i={L:1,M:0,Q:3,H:2},a=(r=r||{}).version||-1,o=i[(r.eccLevel||"L").toUpperCase()],s=r.mode?n[r.mode.toLowerCase()]:-1,l="mask"in r?r.mask:-1;if(s<0)s="string"==typeof t?t.match(A)?1:t.match(P)?2:4:4;else if(1!=s&&2!=s&&4!=s)throw"invalid or unsupported mode";if(t=function(t,r){switch(t){case 1:return r.match(A)?r:null;case 2:return r.match(C)?r.toUpperCase():null;case 4:if("string"==typeof r){for(var n=[],i=0;i<r.length;++i){var a=r.charCodeAt(i);a<128?n.push(a):a<2048?n.push(192|a>>6,128|63&a):a<65536?n.push(224|a>>12,128|a>>6&63,128|63&a):n.push(240|a>>18,128|a>>12&63,128|a>>6&63,128|63&a)}return n}return r}}(s,t),null===t)throw"invalid data format";if(o<0||o>3)throw"invalid ECC level";if(a<0){for(a=1;a<=40&&!(t.length<=getmaxdatalen(a,s,o));++a);if(a>40)throw"too large data for the Qr format"}else if(a<1||a>40)throw"invalid Qr version! should be between 1 and 40";if(-1!=l&&(l<0||l>8))throw"invalid mask";return generate(t,a,s,o,l)}const z={measure:function measure(t){var r=function buildCanvas(t,r){var n=[],i=r.background||"#fff",a=r.foreground||"#000",o=r.padding||0,s=generateFrame(t,r),l=s.length,h=Math.floor(r.fit?r.fit/l:5),u=l*h+h*o*2,p=h*o;n.push({type:"rect",x:0,y:0,w:u,h:u,lineWidth:0,color:i});for(var g=0;g<l;++g)for(var m=0;m<l;++m)s[g][m]&&n.push({type:"rect",x:h*m+p,y:h*g+p,w:h,h,lineWidth:0,color:a});return{canvas:n,size:u}}(t.qr,t);return t._canvas=r.canvas,t._width=t._height=t._minWidth=t._maxWidth=t._minHeight=t._maxHeight=r.size,t}};const j=class DocMeasure{constructor(t,r,n,i,a){this.pdfDocument=t,this.textInlines=new v(t),this.styleStack=new p(r,n),this.svgMeasure=i,this.tableLayouts=a,this.autoImageIndex=1}measureDocument(t){return this.measureNode(t)}measureNode(t){return this.styleStack.auto(t,(()=>{if(t._margin=function getNodeMargin(t,r){function processSingleMargins(t,r){return t.marginLeft||t.marginTop||t.marginRight||t.marginBottom?[t.marginLeft||r[0]||0,t.marginTop||r[1]||0,t.marginRight||r[2]||0,t.marginBottom||r[3]||0]:r}function convertMargin(t){return isNumber(t)?t=[t,t,t,t]:Array.isArray(t)&&2===t.length&&(t=[t[0],t[1],t[0],t[1]]),t}let n=[void 0,void 0,void 0,void 0];if(t.style){let i=function flattenStyleArray(t,r){let n={};for(let i=t.length-1;i>=0;i--){let a=t[i],o=r.styleDictionary[a];for(let t in o)o.hasOwnProperty(t)&&(n[t]=o[t])}return n}(Array.isArray(t.style)?t.style:[t.style],r);i&&(n=processSingleMargins(i,n)),i.margin&&(n=convertMargin(i.margin))}return n=processSingleMargins(t,n),t.margin&&(n=convertMargin(t.margin)),void 0===n[0]&&void 0===n[1]&&void 0===n[2]&&void 0===n[3]?null:n}(t,this.styleStack),t.columns)return extendMargins(this.measureColumns(t));if(t.stack)return extendMargins(this.measureVerticalContainer(t));if(t.ul)return extendMargins(this.measureUnorderedList(t));if(t.ol)return extendMargins(this.measureOrderedList(t));if(t.table)return extendMargins(this.measureTable(t));if(void 0!==t.text)return extendMargins(this.measureLeaf(t));if(t.toc)return extendMargins(this.measureToc(t));if(t.image)return extendMargins(this.measureImage(t));if(t.svg)return extendMargins(this.measureSVG(t));if(t.canvas)return extendMargins(this.measureCanvas(t));if(t.qr)return extendMargins(this.measureQr(t));if(t.attachment)return extendMargins(this.measureAttachment(t));throw new Error(`Unrecognized document structure: ${stringifyNode(t)}`)}));function extendMargins(t){let r=t._margin;return r&&(t._minWidth+=r[0]+r[2],t._maxWidth+=r[0]+r[2]),t}}measureImageWithDimensions(t,r){if(t.fit){let n=r.width/r.height>t.fit[0]/t.fit[1]?t.fit[0]/r.width:t.fit[1]/r.height;t._width=t._minWidth=t._maxWidth=r.width*n,t._height=r.height*n}else t.cover?(t._width=t._minWidth=t._maxWidth=t.cover.width,t._height=t._minHeight=t._maxHeight=t.cover.height):(t._width=t._minWidth=t._maxWidth=t.width||r.width,t._height=t.height||r.height*t._width/r.width,isNumber(t.maxWidth)&&t.maxWidth<t._width&&(t._width=t._minWidth=t._maxWidth=t.maxWidth,t._height=t._width*r.height/r.width),isNumber(t.maxHeight)&&t.maxHeight<t._height&&(t._height=t.maxHeight,t._width=t._minWidth=t._maxWidth=t._height*r.width/r.height),isNumber(t.minWidth)&&t.minWidth>t._width&&(t._width=t._minWidth=t._maxWidth=t.minWidth,t._height=t._width*r.height/r.width),isNumber(t.minHeight)&&t.minHeight>t._height&&(t._height=t.minHeight,t._width=t._minWidth=t._maxWidth=t._height*r.width/r.height));t._alignment=this.styleStack.getProperty("alignment")}convertIfBase64Image(t){if(/^data:image\/(jpeg|jpg|png);base64,/.test(t.image)){let r="$$pdfmake$$"+this.autoImageIndex++;this.pdfDocument.images[r]=t.image,t.image=r}}measureImage(t){this.convertIfBase64Image(t);let r=this.pdfDocument.provideImage(t.image),n={width:r.width,height:r.height};return"JPEG"===r.constructor.name&&r.orientation>4&&(n={width:r.height,height:r.width}),this.measureImageWithDimensions(t,n),t}measureSVG(t){let r=this.svgMeasure.measureSVG(t.svg);return this.measureImageWithDimensions(t,r),t.font=this.styleStack.getProperty("font"),t.svg=this.svgMeasure.writeDimensions(t.svg,{width:t._width,height:t._height}),t}measureLeaf(t){t._textRef&&t._textRef._textNodeRef.text&&(t.text=t._textRef._textNodeRef.text);let r=this.styleStack.clone();r.push(t);let n=this.textInlines.buildInlines(t.text,r);return t._inlines=n.items,t._minWidth=n.minWidth,t._maxWidth=n.maxWidth,t}measureToc(t){if(t.toc.title&&(t.toc.title=this.measureNode(t.toc.title)),t.toc._items.length>0){let r=[],n=t.toc.textStyle||{},i=t.toc.numberStyle||n,a=t.toc.textMargin||[0,0,0,0];for(let o=0,s=t.toc._items.length;o<s;o++){let s=t.toc._items[o],l=s._textNodeRef.tocStyle||n,h=s._textNodeRef.tocMargin||a,u=s._textNodeRef.tocNumberStyle||i,p=getNodeId(s._nodeRef);r.push([{text:s._textNodeRef.text,linkToDestination:p,alignment:"left",style:l,margin:h},{text:"00000",linkToDestination:p,alignment:"right",_tocItemRef:s._nodeRef,style:u,margin:[0,h[1],0,h[3]]}])}t.toc._table={table:{dontBreakRows:!0,widths:["*","auto"],body:r},layout:"noBorders"},t.toc._table=this.measureNode(t.toc._table)}return t}measureVerticalContainer(t){let r=t.stack;t._minWidth=0,t._maxWidth=0;for(let n=0,i=r.length;n<i;n++)r[n]=this.measureNode(r[n]),t._minWidth=Math.max(t._minWidth,r[n]._minWidth),t._maxWidth=Math.max(t._maxWidth,r[n]._maxWidth);return t}gapSizeForList(){return this.textInlines.sizeOfText("9. ",this.styleStack)}buildUnorderedMarker(t,r,n){let i,a=t.getProperty("markerColor")||t.getProperty("color")||"black";switch(n){case"circle":i=function buildCircle(t,r){let n=t.fontSize/6;return{canvas:[{x:n,y:t.height/t.lineHeight+t.descender-t.fontSize/3,r1:n,r2:n,type:"ellipse",lineColor:r}]}}(r,a);break;case"square":i=function buildSquare(t,r){let n=t.fontSize/3;return{canvas:[{x:0,y:t.height/t.lineHeight+t.descender-t.fontSize/3-n/2,h:n,w:n,type:"rect",color:r}]}}(r,a);break;case"none":i={};break;default:i=function buildDisc(t,r){let n=t.fontSize/6;return{canvas:[{x:n,y:t.height/t.lineHeight+t.descender-t.fontSize/3,r1:n,r2:n,type:"ellipse",color:r}]}}(r,a)}return i._minWidth=i._maxWidth=r.width,i._minHeight=i._maxHeight=r.height,i}buildOrderedMarker(t,r,n,i){function prepareAlpha(t){return t<1?t.toString():function toAlpha(t){return(t>=26?toAlpha((t/26|0)-1):"")+"abcdefghijklmnopqrstuvwxyz"[t%26|0]}(t-1)}function prepareRoman(t){if(t<1||t>4999)return t.toString();let r=t,n={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},i="";for(let t in n)for(;r>=n[t];)i+=t,r-=n[t];return i}let a;switch(n){case"none":a=null;break;case"upper-alpha":a=prepareAlpha(t).toUpperCase();break;case"lower-alpha":a=prepareAlpha(t);break;case"upper-roman":a=prepareRoman(t);break;case"lower-roman":a=prepareRoman(t).toLowerCase();break;default:a=function prepareDecimal(t){return t.toString()}(t)}if(null===a)return{};i&&(Array.isArray(i)?(i[0]&&(a=i[0]+a),i[1]&&(a+=i[1]),a+=" "):a+=`${i} `);let o={text:a},s=r.getProperty("markerColor");return s&&(o.color=s),{_inlines:this.textInlines.buildInlines(o,r).items}}measureUnorderedList(t){let r=this.styleStack.clone(),n=t.ul;t.type=t.type||"disc",t._gapSize=this.gapSizeForList(),t._minWidth=0,t._maxWidth=0;for(let i=0,a=n.length;i<a;i++){let a=n[i]=this.measureNode(n[i]);a.ol||a.ul||(a.listMarker=this.buildUnorderedMarker(r,t._gapSize,a.listType||t.type)),t._minWidth=Math.max(t._minWidth,n[i]._minWidth+t._gapSize.width),t._maxWidth=Math.max(t._maxWidth,n[i]._maxWidth+t._gapSize.width)}return t}measureOrderedList(t){let r=this.styleStack.clone(),n=t.ol;t.type=t.type||"decimal",t.separator=t.separator||".",t.reversed=t.reversed||!1,isNumber(t.start)||(t.start=t.reversed?n.length:1),t._gapSize=this.gapSizeForList(),t._minWidth=0,t._maxWidth=0;let i=t.start;for(let a=0,o=n.length;a<o;a++){let o=n[a]=this.measureNode(n[a]);if(!o.ol&&!o.ul){let n=isNumber(o.counter)?o.counter:i;o.listMarker=this.buildOrderedMarker(n,r,o.listType||t.type,t.separator),o.listMarker._inlines&&(t._gapSize.width=Math.max(t._gapSize.width,o.listMarker._inlines[0].width)),t.reversed?i--:i++}t._minWidth=Math.max(t._minWidth,n[a]._minWidth),t._maxWidth=Math.max(t._maxWidth,n[a]._maxWidth)}t._minWidth+=t._gapSize.width,t._maxWidth+=t._gapSize.width;for(let r=0,i=n.length;r<i;r++){let i=n[r];i.ol||i.ul||(i.listMarker._minWidth=i.listMarker._maxWidth=t._gapSize.width)}return t}measureColumns(t){let r=t.columns;t._gap=this.styleStack.getProperty("columnGap")||0;for(let t=0,n=r.length;t<n;t++)r[t]=this.measureNode(r[t]);let n=w.measureMinMax(r),i=r.length>0?r.length-1:0;return t._minWidth=n.min+t._gap*i,t._maxWidth=n.max+t._gap*i,t}measureTable(t){!function extendTableWidths(t){t.table.widths||(t.table.widths="auto");if(isString(t.table.widths))for(t.table.widths=[t.table.widths];t.table.widths.length<t.table.body[0].length;)t.table.widths.push(t.table.widths[t.table.widths.length-1]);for(let r=0,n=t.table.widths.length;r<n;r++){let n=t.table.widths[r];(isNumber(n)||isString(n))&&(t.table.widths[r]={width:n})}}(t),t._layout=function getLayout(r){let n=t.layout;isString(n)&&(n=r[n]);return pack(_,n)}(this.tableLayouts),t._offsets=function getOffsets(r){let n=[],i=0,a=0;for(let o=0,s=t.table.widths.length;o<s;o++){let s=a+r.vLineWidth(o,t)+r.paddingLeft(o,t);n.push(s),i+=s,a=r.paddingRight(o,t)}return i+=a+r.vLineWidth(t.table.widths.length,t),{total:i,offsets:n}}(t._layout);let r,n,i,a,o=[];for(r=0,i=t.table.body[0].length;r<i;r++){let i=t.table.widths[r];for(i._minWidth=0,i._maxWidth=0,n=0,a=t.table.body.length;n<a;n++){let a=t.table.body[n],s=a[r];if(void 0===s)throw new Error(`Malformed table row, a cell is undefined.\nRow index: ${n}\nColumn index: ${r}\nRow data: ${stringifyNode(a)}`);null===s&&(s=""),s._span||(s=a[r]=this.styleStack.auto(s,measureCb(this,s)),s.colSpan&&s.colSpan>1?(markSpans(a,r,s.colSpan),o.push({col:r,span:s.colSpan,minWidth:s._minWidth,maxWidth:s._maxWidth})):(i._minWidth=Math.max(i._minWidth,s._minWidth),i._maxWidth=Math.max(i._maxWidth,s._maxWidth))),s.rowSpan&&s.rowSpan>1&&markVSpans(t.table,n,r,s.rowSpan)}}!function extendWidthsForColSpans(){let r,n;for(let i=0,a=o.length;i<a;i++){let a=o[i],s=getMinMax(a.col,a.span,t._offsets),l=a.minWidth-s.minWidth,h=a.maxWidth-s.maxWidth;if(l>0)for(r=l/a.span,n=0;n<a.span;n++)t.table.widths[a.col+n]._minWidth+=r;if(h>0)for(r=h/a.span,n=0;n<a.span;n++)t.table.widths[a.col+n]._maxWidth+=r}}();let s=w.measureMinMax(t.table.widths);return t._minWidth=s.min+t._offsets.total,t._maxWidth=s.max+t._offsets.total,t;function measureCb(t,r){return()=>(isObject(r)&&(r.fillColor=t.styleStack.getProperty("fillColor"),r.fillOpacity=t.styleStack.getProperty("fillOpacity")),t.measureNode(r))}function getMinMax(r,n,i){let a={minWidth:0,maxWidth:0};for(let o=0;o<n;o++)a.minWidth+=t.table.widths[r+o]._minWidth+(o?i.offsets[r+o]:0),a.maxWidth+=t.table.widths[r+o]._maxWidth+(o?i.offsets[r+o]:0);return a}function markSpans(t,r,n){for(let i=1;i<n;i++)t[r+i]={_span:!0,_minWidth:0,_maxWidth:0,rowSpan:t[r].rowSpan}}function markVSpans(t,r,n,i){for(let a=1;a<i;a++)t.body[r+a][n]={_span:!0,_minWidth:0,_maxWidth:0,fillColor:t.body[r][n].fillColor,fillOpacity:t.body[r][n].fillOpacity}}}measureCanvas(t){let r=0,n=0;for(let i=0,a=t.canvas.length;i<a;i++){let a=t.canvas[i];switch(a.type){case"ellipse":r=Math.max(r,a.x+a.r1),n=Math.max(n,a.y+a.r2);break;case"rect":r=Math.max(r,a.x+a.w),n=Math.max(n,a.y+a.h);break;case"line":r=Math.max(r,a.x1,a.x2),n=Math.max(n,a.y1,a.y2);break;case"polyline":for(let t=0,i=a.points.length;t<i;t++)r=Math.max(r,a.points[t].x),n=Math.max(n,a.points[t].y)}}return t._minWidth=t._maxWidth=r,t._minHeight=t._maxHeight=n,t._alignment=this.styleStack.getProperty("alignment"),t}measureQr(t){return(t=z.measure(t))._alignment=this.styleStack.getProperty("alignment"),t}measureAttachment(t){return t._width=t.width||7,t._height=t.height||18,t}};var G=n(4785);class DocumentContext extends G.EventEmitter{constructor(){super(),this.pages=[],this.pageMargins=void 0,this.x=void 0,this.availableWidth=void 0,this.availableHeight=void 0,this.page=-1,this.snapshots=[],this.backgroundLength=[]}beginColumnGroup(t,r){void 0===r&&(r={}),this.snapshots.push({x:this.x,y:this.y,availableHeight:this.availableHeight,availableWidth:this.availableWidth,page:this.page,bottomByPage:r||{},bottomMost:{x:this.x,y:this.y,availableHeight:this.availableHeight,availableWidth:this.availableWidth,page:this.page},lastColumnWidth:this.lastColumnWidth}),this.lastColumnWidth=0,t&&(this.marginXTopParent=t)}updateBottomByPage(){const t=this.snapshots[this.snapshots.length-1],r=this.page;let n=-Number.MIN_VALUE;t.bottomByPage[r]&&(n=t.bottomByPage[r]),t.bottomByPage[r]=Math.max(n,this.y)}resetMarginXTopParent(){this.marginXTopParent=null}beginColumn(t,r,n){let i=this.snapshots[this.snapshots.length-1];this.calculateBottomMost(i,n),this.page=i.page,this.x=this.x+this.lastColumnWidth+(r||0),this.y=i.y,this.availableWidth=t,this.availableHeight=i.availableHeight,this.lastColumnWidth=t}calculateBottomMost(t,r){r?this.saveContextInEndingCell(r):t.bottomMost=function bottomMostContext(t,r){let n;n=t.page>r.page?t:r.page>t.page?r:t.y>r.y?t:r;return{page:n.page,x:n.x,y:n.y,availableHeight:n.availableHeight,availableWidth:n.availableWidth}}(this,t.bottomMost)}markEnding(t,r,n){this.page=t._columnEndingContext.page,this.x=t._columnEndingContext.x+r,this.y=t._columnEndingContext.y-n,this.availableWidth=t._columnEndingContext.availableWidth,this.availableHeight=t._columnEndingContext.availableHeight,this.lastColumnWidth=t._columnEndingContext.lastColumnWidth}saveContextInEndingCell(t){t._columnEndingContext={page:this.page,x:this.x,y:this.y,availableHeight:this.availableHeight,availableWidth:this.availableWidth,lastColumnWidth:this.lastColumnWidth}}completeColumnGroup(t,r){let n=this.snapshots.pop();this.calculateBottomMost(n,r),this.x=n.x;let i=n.bottomMost.y;return t&&(n.page===n.bottomMost.page?n.y+t>i&&(i=n.y+t):i+=t),this.y=i,this.page=n.bottomMost.page,this.availableWidth=n.availableWidth,this.availableHeight=n.bottomMost.availableHeight,t&&(this.availableHeight-=i-n.bottomMost.y),this.lastColumnWidth=n.lastColumnWidth,n.bottomByPage}addMargin(t,r){this.x+=t,this.availableWidth-=t+(r||0)}moveDown(t){return this.y+=t,this.availableHeight-=t,this.availableHeight>0}initializePage(){this.y=this.pageMargins.top,this.availableHeight=this.getCurrentPage().pageSize.height-this.pageMargins.top-this.pageMargins.bottom;const{pageCtx:t,isSnapshot:r}=this.pageSnapshot();t.availableWidth=this.getCurrentPage().pageSize.width-this.pageMargins.left-this.pageMargins.right,r&&this.marginXTopParent&&(t.availableWidth-=this.marginXTopParent[0],t.availableWidth-=this.marginXTopParent[1])}pageSnapshot(){return this.snapshots[0]?{pageCtx:this.snapshots[0],isSnapshot:!0}:{pageCtx:this,isSnapshot:!1}}moveTo(t,r){null!=t&&(this.x=t,this.availableWidth=this.getCurrentPage().pageSize.width-this.x-this.pageMargins.right),null!=r&&(this.y=r,this.availableHeight=this.getCurrentPage().pageSize.height-this.y-this.pageMargins.bottom)}moveToRelative(t,r){null!=t&&(this.x=this.x+t),null!=r&&(this.y=this.y+r)}beginDetachedBlock(){this.snapshots.push({x:this.x,y:this.y,availableHeight:this.availableHeight,availableWidth:this.availableWidth,page:this.page,lastColumnWidth:this.lastColumnWidth})}endDetachedBlock(){let t=this.snapshots.pop();this.x=t.x,this.y=t.y,this.availableWidth=t.availableWidth,this.availableHeight=t.availableHeight,this.page=t.page,this.lastColumnWidth=t.lastColumnWidth}moveToNextPage(t){let r=this.page+1,n=this.page,i=this.y;if(this.snapshots.length>0){let t=this.snapshots[this.snapshots.length-1];t.bottomMost&&t.bottomMost.y&&(i=Math.max(this.y,t.bottomMost.y))}let a=r>=this.pages.length;if(a){let r=this.availableWidth,n=this.getCurrentPage().pageSize.orientation,i=getPageSize(this.getCurrentPage(),t);this.addPage(i),n===i.orientation&&(this.availableWidth=r)}else this.page=r,this.initializePage();return{newPageCreated:a,prevPage:n,prevY:i,y:this.y}}addPage(t,r){void 0===r&&(r=null),null!==r&&(this.pageMargins=r,this.x=r.left,this.availableWidth=t.width-r.left-r.right);let n={items:[],pageSize:t,pageMargins:this.pageMargins};return this.pages.push(n),this.backgroundLength.push(0),this.page=this.pages.length-1,this.initializePage(),this.emit("pageAdded"),n}getCurrentPage(){return this.page<0||this.page>=this.pages.length?null:this.pages[this.page]}getCurrentPosition(){let t=this.getCurrentPage().pageSize,r=t.height-this.pageMargins.top-this.pageMargins.bottom,n=t.width-this.pageMargins.left-this.pageMargins.right;return{pageNumber:this.page+1,pageOrientation:t.orientation,pageInnerHeight:r,pageInnerWidth:n,left:this.x,top:this.y,verticalRatio:(this.y-this.pageMargins.top)/r,horizontalRatio:(this.x-this.pageMargins.left)/n}}}const getPageSize=(t,r)=>(r=function pageOrientation(t,r){return void 0===t?r:isString(t)&&"landscape"===t.toLowerCase()?"landscape":"portrait"}(r,t.pageSize.orientation))!==t.pageSize.orientation?{orientation:r,width:t.pageSize.height,height:t.pageSize.width}:{orientation:t.pageSize.orientation,width:t.pageSize.width,height:t.pageSize.height};const V=DocumentContext;class ElementWriter extends G.EventEmitter{constructor(t){super(),this._context=t,this.contextStack=[]}context(){return this._context}addLine(t,r,n){let i=t.getHeight(),a=this.context(),o=a.getCurrentPage(),s=this.getCurrentPositionOnPage();return!(a.availableHeight<i||!o)&&(t.x=a.x+(t.x||0),t.y=a.y+(t.y||0),this.alignLine(t),addPageItem(o,{type:"line",item:t},n),this.emit("lineAdded",t),r||a.moveDown(i),s)}alignLine(t){let r=this.context().availableWidth,n=t.getWidth(),i=t.inlines&&t.inlines.length>0&&t.inlines[0].alignment,a=0;switch(i){case"right":a=r-n;break;case"center":a=(r-n)/2}if(a&&(t.x=(t.x||0)+a),"justify"===i&&!t.newLineForced&&!t.lastLineInParagraph&&t.inlines.length>1){let i=(r-n)/(t.inlines.length-1);for(let r=1,n=t.inlines.length;r<n;r++)a=r*i,t.inlines[r].x+=a,t.inlines[r].justifyShift=i}}addImage(t,r){let n=this.context(),i=n.getCurrentPage(),a=this.getCurrentPositionOnPage();return!(!i||void 0===t.absolutePosition&&n.availableHeight<t._height&&i.items.length>0)&&(void 0===t._x&&(t._x=t.x||0),t.x=n.x+t._x,t.y=n.y,this.alignImage(t),addPageItem(i,{type:"image",item:t},r),n.moveDown(t._height),a)}addCanvas(t,r){let n=this.context(),i=n.getCurrentPage(),a=[],o=t._minHeight;return!(!i||void 0===t.absolutePosition&&n.availableHeight<o)&&(this.alignCanvas(t),t.canvas.forEach((function(t){let n=this.addVector(t,!1,!1,r);a.push(n),void 0!==r&&r++}),this),n.moveDown(o),a)}addSVG(t,r){let n=this.context(),i=n.getCurrentPage(),a=this.getCurrentPositionOnPage();return!(!i||void 0===t.absolutePosition&&n.availableHeight<t._height&&i.items.length>0)&&(void 0===t._x&&(t._x=t.x||0),t.x=n.x+t._x,t.y=n.y,this.alignImage(t),addPageItem(i,{type:"svg",item:t},r),n.moveDown(t._height),a)}addQr(t,r){let n=this.context(),i=n.getCurrentPage(),a=this.getCurrentPositionOnPage();if(!i||void 0===t.absolutePosition&&n.availableHeight<t._height)return!1;void 0===t._x&&(t._x=t.x||0),t.x=n.x+t._x,t.y=n.y,this.alignImage(t);for(let n=0,i=t._canvas.length;n<i;n++){let i=t._canvas[n];i.x+=t.x,i.y+=t.y,this.addVector(i,!0,!0,r)}return n.moveDown(t._height),a}addAttachment(t,r){let n=this.context(),i=n.getCurrentPage(),a=this.getCurrentPositionOnPage();return!(!i||void 0===t.absolutePosition&&n.availableHeight<t._height&&i.items.length>0)&&(void 0===t._x&&(t._x=t.x||0),t.x=n.x+t._x,t.y=n.y,addPageItem(i,{type:"attachment",item:t},r),n.moveDown(t._height),a)}alignImage(t){let r=this.context().availableWidth,n=t._minWidth,i=0;switch(t._alignment){case"right":i=r-n;break;case"center":i=(r-n)/2}i&&(t.x=(t.x||0)+i)}alignCanvas(t){let r=this.context().availableWidth,n=t._minWidth,i=0;switch(t._alignment){case"right":i=r-n;break;case"center":i=(r-n)/2}i&&t.canvas.forEach((t=>{offsetVector(t,i,0)}))}addVector(t,r,n,i,a){let o=this.context(),s=o.getCurrentPage();isNumber(a)&&(s=o.pages[a]);let l=this.getCurrentPositionOnPage();if(s)return offsetVector(t,r?0:o.x,n?0:o.y),addPageItem(s,{type:"vector",item:t},i),l}beginClip(t,r){let n=this.context();return n.getCurrentPage().items.push({type:"beginClip",item:{x:n.x,y:n.y,width:t,height:r}}),!0}endClip(){return this.context().getCurrentPage().items.push({type:"endClip"}),!0}addFragment(t,r,n,i){let a=this.context(),o=a.getCurrentPage();return!(!r&&t.height>a.availableHeight)&&(t.items.forEach((i=>{switch(i.type){case"line":var s=i.item.clone();s._node&&(s._node.positions[0].pageNumber=a.page+1),s.x=(s.x||0)+(r?t.xOffset||0:a.x),s.y=(s.y||0)+(n?t.yOffset||0:a.y),o.items.push({type:"line",item:s});break;case"vector":var l=pack(i.item);if(offsetVector(l,r?t.xOffset||0:a.x,n?t.yOffset||0:a.y),l._isFillColorFromUnbreakable){delete l._isFillColorFromUnbreakable;const t=a.backgroundLength[a.page];o.items.splice(t,0,{type:"vector",item:l})}else o.items.push({type:"vector",item:l});break;case"image":case"svg":var h=pack(i.item);h.x=(h.x||0)+(r?t.xOffset||0:a.x),h.y=(h.y||0)+(n?t.yOffset||0:a.y),o.items.push({type:i.type,item:h})}})),i||a.moveDown(t.height),!0)}pushContext(t,r){if(void 0===t&&(r=this.context().getCurrentPage().height-this.context().pageMargins.top-this.context().pageMargins.bottom,t=this.context().availableWidth),isNumber(t)){let n=t;(t=new V).addPage({width:n,height:r},{left:0,right:0,top:0,bottom:0})}this.contextStack.push(this.context()),this._context=t}popContext(){this._context=this.contextStack.pop()}getCurrentPositionOnPage(){return(this.contextStack[0]||this.context()).getCurrentPosition()}}function addPageItem(t,r,n){null==n||n<0||n>t.items.length?t.items.push(r):t.items.splice(n,0,r)}const H=ElementWriter,q={"4A0":[4767.87,6740.79],"2A0":[3370.39,4767.87],A0:[2383.94,3370.39],A1:[1683.78,2383.94],A2:[1190.55,1683.78],A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],A6:[297.64,419.53],A7:[209.76,297.64],A8:[147.4,209.76],A9:[104.88,147.4],A10:[73.7,104.88],B0:[2834.65,4008.19],B1:[2004.09,2834.65],B2:[1417.32,2004.09],B3:[1000.63,1417.32],B4:[708.66,1000.63],B5:[498.9,708.66],B6:[354.33,498.9],B7:[249.45,354.33],B8:[175.75,249.45],B9:[124.72,175.75],B10:[87.87,124.72],C0:[2599.37,3676.54],C1:[1836.85,2599.37],C2:[1298.27,1836.85],C3:[918.43,1298.27],C4:[649.13,918.43],C5:[459.21,649.13],C6:[323.15,459.21],C7:[229.61,323.15],C8:[161.57,229.61],C9:[113.39,161.57],C10:[79.37,113.39],RA0:[2437.8,3458.27],RA1:[1729.13,2437.8],RA2:[1218.9,1729.13],RA3:[864.57,1218.9],RA4:[609.45,864.57],SRA0:[2551.18,3628.35],SRA1:[1814.17,2551.18],SRA2:[1275.59,1814.17],SRA3:[907.09,1275.59],SRA4:[637.8,907.09],EXECUTIVE:[521.86,756],FOLIO:[612,936],LEGAL:[612,1008],LETTER:[612,792],TABLOID:[792,1224]};function normalizePageSize(t,r){t&&"auto"===t.height&&(t.height=1/0);let n=function pageSizeToWidthAndHeight(t){if(isString(t)){let r=q[t.toUpperCase()];if(!r)throw new Error(`Page size ${t} not recognized`);return{width:r[0],height:r[1]}}return t}(t||"A4");return function isNeedSwapPageSizes(t){return!!isString(t)&&("portrait"===(t=t.toLowerCase())&&n.width>n.height||"landscape"===t&&n.width<n.height)}(r)&&(n={width:n.height,height:n.width}),n.orientation=n.width>n.height?"landscape":"portrait",n}function normalizePageMargin(t){if(isNumber(t))t={left:t,right:t,top:t,bottom:t};else if(Array.isArray(t))if(2===t.length)t={left:t[0],top:t[1],right:t[0],bottom:t[1]};else{if(4!==t.length)throw new Error("Invalid pageMargins definition");t={left:t[0],top:t[1],right:t[2],bottom:t[3]}}return t}const X=class PageElementWriter extends H{constructor(t){super(t),this.transactionLevel=0,this.repeatables=[]}addLine(t,r,n){return this._fitOnPage((()=>super.addLine(t,r,n)))}addImage(t,r){return this._fitOnPage((()=>super.addImage(t,r)))}addCanvas(t,r){return this._fitOnPage((()=>super.addCanvas(t,r)))}addSVG(t,r){return this._fitOnPage((()=>super.addSVG(t,r)))}addQr(t,r){return this._fitOnPage((()=>super.addQr(t,r)))}addAttachment(t,r){return this._fitOnPage((()=>super.addAttachment(t,r)))}addVector(t,r,n,i,a){return super.addVector(t,r,n,i,a)}beginClip(t,r){return super.beginClip(t,r)}endClip(){return super.endClip()}addFragment(t,r,n,i){return this._fitOnPage((()=>super.addFragment(t,r,n,i)))}moveToNextPage(t){let r=this.context().moveToNextPage(t);this.repeatables.forEach((function(t){void 0===t.insertedOnPages[this.context().page]?(t.insertedOnPages[this.context().page]=!0,this.addFragment(t,!0)):this.context().moveDown(t.height)}),this),this.emit("pageChanged",{prevPage:r.prevPage,prevY:r.prevY,y:this.context().y})}addPage(t,r,n){let i=this.page,a=this.y;this.context().addPage(normalizePageSize(t,r),normalizePageMargin(n)),this.emit("pageChanged",{prevPage:i,prevY:a,y:this.context().y})}beginUnbreakableBlock(t,r){0==this.transactionLevel++&&(this.originalX=this.context().x,this.pushContext(t,r))}commitUnbreakableBlock(t,r){if(0==--this.transactionLevel){let n=this.context();this.popContext();let i=n.pages.length;if(i>0){let a=n.pages[0];if(a.xOffset=t,a.yOffset=r,i>1)if(void 0!==t||void 0!==r)a.height=n.getCurrentPage().pageSize.height-n.pageMargins.top-n.pageMargins.bottom;else{a.height=this.context().getCurrentPage().pageSize.height-this.context().pageMargins.top-this.context().pageMargins.bottom;for(let t=0,r=this.repeatables.length;t<r;t++)a.height-=this.repeatables[t].height}else a.height=n.y;void 0!==t||void 0!==r?super.addFragment(a,!0,!0,!0):this.addFragment(a)}}}currentBlockToRepeatable(){let t=this.context(),r={items:[]};return t.pages[0].items.forEach((t=>{r.items.push(t)})),r.xOffset=this.originalX,r.height=t.y,r.insertedOnPages=[],r}pushToRepeatables(t){this.repeatables.push(t)}popFromRepeatables(){this.repeatables.pop()}_fitOnPage(t){let r=t();return r||(this.moveToNextPage(),r=t()),r}};const Z=class TableProcessor{constructor(t){this.tableNode=t}beginTable(t){let r,n;r=this.tableNode,this.offsets=r._offsets,this.layout=r._layout,n=t.context().availableWidth-this.offsets.total,w.buildColumnWidths(r.table.widths,n,this.offsets.total,r),this.tableWidth=r._offsets.total+(()=>{let t=0;return r.table.widths.forEach((r=>{t+=r._calcWidth})),t})(),this.rowSpanData=(()=>{let t=[],r=0,n=0;t.push({left:0,rowSpan:0});for(let i=0,a=this.tableNode.table.body[0].length;i<a;i++){n=this.layout.paddingLeft(i,this.tableNode)+this.layout.paddingRight(i,this.tableNode)+this.layout.vLineWidth(i,this.tableNode)+this.tableNode.table.widths[i]._calcWidth,t[t.length-1].width=n,r+=n,t.push({left:r,rowSpan:0,width:0})}return t})(),this.cleanUpRepeatables=!1,this.headerRows=0,this.rowsWithoutPageBreak=0;const i=r.table.headerRows;if(isPositiveInteger(i)){if(this.headerRows=i,t