jspdf-md-renderer 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -70,6 +70,16 @@ export declare type RenderOption = {
70
70
  content?: {
71
71
  textAlignment: 'left' | 'right' | 'center' | 'justify';
72
72
  };
73
+ codespan?: {
74
+ /** Background color for inline code. Default: '#EEEEEE' */
75
+ backgroundColor?: string;
76
+ /** Padding around inline code text. Default: 0.5 */
77
+ padding?: number;
78
+ /** Whether to show background rectangle. Default: true */
79
+ showBackground?: boolean;
80
+ /** Font size scale factor for code. Default: 0.9 */
81
+ fontSizeScale?: number;
82
+ };
73
83
  link?: {
74
84
  linkColor: [number, number, number];
75
85
  };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const vt=require("marked");var c=(t=>(t.Heading="heading",t.Paragraph="paragraph",t.List="list",t.ListItem="list_item",t.Blockquote="blockquote",t.Code="code",t.CodeSpan="codespan",t.Table="table",t.Html="html",t.Hr="hr",t.Image="image",t.Link="link",t.Strong="strong",t.Em="em",t.TableHeader="table_header",t.TableCell="table_cell",t.Raw="raw",t.Text="text",t))(c||{});const Z=async t=>{const e=await vt.marked.lexer(t,{async:!0,gfm:!0});return b(e)},b=t=>{const e=[];return t.forEach(i=>{try{const n=ct[i.type];n?e.push(n(i)):e.push({type:c.Raw,content:i.raw})}catch(n){console.error("Failed to handle token ==>",i,n)}}),e},ct={[c.Heading]:t=>({type:c.Heading,depth:t.depth,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Paragraph]:t=>({type:c.Paragraph,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.List]:t=>({type:c.List,ordered:t.ordered,start:t.start,items:t.items?b(t.items):[]}),[c.ListItem]:t=>({type:c.ListItem,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Code]:t=>({type:c.Code,lang:t.lang,code:t.text}),[c.Table]:t=>({type:c.Table,header:t.header.map(e=>({type:c.TableHeader,content:e.text})),rows:t.rows.map(e=>e.map(i=>({type:c.TableCell,content:i.text})))}),[c.Image]:t=>({type:c.Image,src:t.href,alt:t.text}),[c.Link]:t=>({type:c.Link,href:t.href,text:t.text,items:t.tokens?b(t.tokens):[]}),[c.Strong]:t=>({type:c.Strong,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Em]:t=>({type:c.Em,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Text]:t=>({type:c.Text,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Hr]:t=>({type:c.Hr,content:t.raw,items:t.tokens?b(t.tokens):[]}),[c.CodeSpan]:t=>({type:c.CodeSpan,content:t.text,items:t.tokens?b(t.tokens):[]}),[c.Blockquote]:t=>({type:c.Blockquote,content:t.text,items:t.tokens?b(t.tokens):[]})},L=class L{static initialize(e){this.options_=e,this.cursor={x:e.cursor.x,y:e.cursor.y}}static getCursor(){return this.cursor}static setCursor(e){this.cursor=e}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(e,i="set"){i==="set"?this.cursor.x=e:i==="add"&&(this.cursor.x+=e)}static updateY(e,i="set"){i==="set"?this.cursor.y=e:i==="add"&&(this.cursor.y+=e)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.inlineLock=!1;let f=L;const D=t=>{typeof f.options.pageBreakHandler=="function"?f.options.pageBreakHandler(t):t.addPage(f.options.page?.format,f.options.page?.orientation),f.updateY(f.options.page.topmargin),f.updateX(f.options.page.xpading)},w=t=>t.getTextDimensions("H").h*f.options.page.defaultLineHeightFactor,F=t=>t.getTextDimensions("H").w*f.options.page.defaultLineHeightFactor,yt=(t,e,i,n)=>{const r=6-(e?.depth??0)>0?6-(e?.depth??0):1;if(t.setFontSize(f.options.page.defaultFontSize+r),f.updateY(r*.2*w(t),"add"),e?.items&&e?.items.length>0)for(const a of e?.items??[])n(a,i,!1);else t.text(e?.content??"",f.X+i,f.Y,{align:"left",maxWidth:f.options.page.maxContentWidth-i});t.setFontSize(f.options.page.defaultFontSize),f.updateX(f.options.page.xpading)},O=(t,e,i)=>{const n=t.getFont().fontName,r=t.getFont().fontStyle,a=t.getFontSize(),s=l=>{switch(l){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;case"codespan":return .5;default:return 0}},h=(l,o)=>{o==="bold"?t.setFont(f.options.font.bold.name&&f.options.font.bold.name!==""?f.options.font.bold.name:n,f.options.font.bold.style||"bold"):o==="italic"?t.setFont(f.options.font.regular.name,"italic"):o==="bolditalic"?t.setFont(f.options.font.bold.name&&f.options.font.bold.name!==""?f.options.font.bold.name:n,"bolditalic"):o==="codespan"?(t.setFont("courier","normal"),t.setFontSize(a*.9)):t.setFont(f.options.font.regular.name,r);const g=f.options.page.maxContentWidth-i-f.X,p=t.splitTextToSize(l,g),u=o==="codespan",d=1,v="#EEEEEE";if(f.isInlineLockActive)for(let y=0;y<p.length;y++){if(u){const m=t.getTextWidth(p[y])+F(t),x=w(t);t.setFillColor(v),t.roundedRect(f.X+i-d,f.Y-d,m+d*2,x+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(p[y],f.X+i,f.Y,{baseline:"top",maxWidth:g}),f.updateX(t.getTextDimensions(p[y]).w+(u?d*2:1),"add"),y<p.length-1&&(f.updateY(w(t),"add"),f.updateX(f.options.page.xpading,"set"))}else if(p.length>1){const y=p[0],m=p?.slice(1)?.join(" ");if(u){const S=t.getTextWidth(y)+F(t),W=w(t);t.setFillColor(v),t.roundedRect(f.X+(i>=2?i+2:0)-d,f.Y-d,S+d*2,W+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(y,f.X+(i>=2?i+2*s(o):0),f.Y,{baseline:"top",maxWidth:g}),f.updateX(f.options.page.xpading+i),f.updateY(w(t),"add");const x=f.options.page.maxContentWidth-i-f.options.page.xpading;t.splitTextToSize(m,x).forEach(S=>{if(u){const W=t.getTextWidth(S)+F(t),X=w(t);t.setFillColor(v),t.roundedRect(f.X+F(t)-d,f.Y-d,W+d*2,X+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(S,f.X+F(t),f.Y,{baseline:"top",maxWidth:x})})}else{if(u){const y=t.getTextWidth(l)+F(t),m=w(t);t.setFillColor(v),t.roundedRect(f.X+i-d,f.Y-d,y+d*2,m+d*2,2,2,"F"),t.setFillColor("#000000")}t.text(l,f.X+i,f.Y,{baseline:"top",maxWidth:g}),f.updateX(t.getTextDimensions(l).w+(i>=2?l.split(" ").length+2:2)*s(o)*.5+(u?d*2:0),"add")}};if(e.type==="text"&&e.items&&e.items.length>0)for(const l of e.items)if(l.type==="codespan")h(l.content||"","codespan");else if(l.type==="em"||l.type==="strong"){const o=l.type==="em"?"italic":"bold";if(l.items&&l.items.length>0)for(const g of l.items)g.type==="strong"&&o==="italic"||g.type==="em"&&o==="bold"?h(g.content||"","bolditalic"):h(g.content||"",o);else h(l.content||"",o)}else h(l.content||"","normal");else e.type==="em"?h(e.content||"","italic"):e.type==="strong"?h(e.content||"","bold"):e.type==="codespan"?h(e.content||"","codespan"):h(e.content||"","normal");t.setFont(n,r),t.setFontSize(a)};class mt{static renderText(e,i,n=f.X,r=f.Y,a,s=!1){const h=e.splitTextToSize(i,a),l=w(e);let o=r;for(let g=0;g<h.length;g++){const p=h[g];o+l>f.options.page.maxContentHeight&&(D(e),o=f.Y),s?g===h.length-1?e.text(p,n,o):e.text(p,n,o,{maxWidth:a,align:"justify"}):e.text(p,n,o),o+=l,f.updateY(l,"add")}return o}}const xt=(t,e,i,n)=>{f.activateInlineLock(),t.setFontSize(f.options.page.defaultFontSize);const r=e.content,a=t.getTextDimensions("A").h*f.options.page.defaultLineHeightFactor;if(e?.items&&e?.items.length>0){let s=0;for(const h of e?.items??[])["strong","em","text","codespan"].includes(h.type)?(h.type!=="text"&&s!=0&&f.updateX(F(t)*1.5,"add"),O(t,h,i),h.type!=="text"&&s!=0&&f.updateX(F(t),"add")):n(h,i,!1),s++}else{const s=f.options.page.maxContentWidth-i;mt.renderText(t,r??"",f.X+i,f.Y,s,!0)}f.updateY(a,"add"),f.updateX(f.options.page.xpading),f.deactivateInlineLock()},wt=(t,e,i,n)=>{t.setFontSize(f.options.page.defaultFontSize);for(const[r,a]of e?.items?.entries()??[]){const s=e.ordered?(e.start??0)+r:e.start;n(a,i+1,!0,s,e.ordered)}},St=(t,e,i,n,r,a)=>{const s=i*f.options.page.indent,h=a?`${r}. `:"• ";f.Y+w(t)>=f.options.page.maxContentHeight&&D(t),t.setFont(f.options.font.regular.name,f.options.font.regular.style),t.text(h,f.X+s,f.Y,{baseline:"top"});const l=t.getTextWidth(h);if(f.updateX(l,"add"),e.items&&e.items.length>0)for(const o of e.items){if(f.Y+w(t)>=f.options.page.maxContentHeight&&D(t),o.type===c.List)n(o,i+1,!0,r,o.ordered??!1);else if(o.type===c.ListItem){const g=e.type===c.List?i:i+1;n(o,g,!0,r,a)}else f.activateInlineLock(),O(t,o,s),f.deactivateInlineLock();f.updateX(f.options.page.xpading),f.updateY(w(t),"add")}else if(e.content){const o=f.X+s,g=t.getTextWidth(h),p=f.options.page.maxContentWidth-s-g,u=t.splitTextToSize(e.content,p);if(u.length>0){t.text(u[0],o+g,f.Y,{baseline:"top",maxWidth:p});for(let v=1;v<u.length;v++)f.updateY(w(t),"add"),t.text(u[v],o+g,f.Y,{baseline:"top",maxWidth:p});f.updateX(f.options.page.xmargin+s),f.updateY(w(t),"add");const d=t.getTextWidth(e.content);f.updateX(d,"add")}}},Ct=(t,e,i,n,r,a,s,h,l)=>{const o=(h-i)/(e.length-1);let g=r;const p=a+n*s;for(const u of e)t.text(u.text,g,p,{align:"justify",lineHeightFactor:l,maxWidth:h}),g+=u.wordLength+o},bt=(t,e,i,n,r,a,s,h)=>{const l=t.map(o=>o.text).join(" ");e.text(l,i,n+r*a,{align:"justify",lineHeightFactor:h,maxWidth:s})},Wt=(t,e,i,n,r,a)=>{const s={x:i,y:n},h=t.getTextDimensions("A").h*a,l=e.split(" ");let o=0,g=[],p=0;for(const u of l){const d=t.getTextWidth(u+"a");d+p>=r&&(Ct(t,g,p,o++,i,n,h,r,a),g=[],p=0),g.push({text:u,wordLength:d}),p+=d}return g.length>0&&bt(g,t,i,n,o,h,r,a),s.y=n+o*h,s.x=t.getTextWidth(e)+i,s},Ft=(t,e,i,n,r,a,s,h=!0)=>{if(e?.items&&e?.items.length>0)for(const l of e?.items??[])r(l,i,n,a,s,h);else{const l=i*f.options.page.indent,o=n?s?`${a}. `:"• ":"";if(n&&o){const g=t.getTextWidth(o),p=f.options.page.maxContentWidth-l-g,u=t.splitTextToSize(e.content||"",p);if(u.length>0){t.text(o,f.X+l,f.Y,{baseline:"top"}),t.text(u[0],f.X+l+g,f.Y,{baseline:"top",maxWidth:p});for(let v=1;v<u.length;v++)f.updateX(f.options.page.xpading),f.updateY(w(t),"add"),t.text(u[v],f.X+l+g,f.Y,{baseline:"top",maxWidth:p-l-g});f.updateY(w(t),"add"),f.updateX(f.options.page.xpading+l);const d=t.getTextWidth(e.content||"");f.updateX(d,"add")}}else{const g=t.splitTextToSize(e.content||"",f.options.page.maxContentWidth-l);if(f.Y+g.length*w(t)>=f.options.page.maxContentHeight&&D(t),h){const p=Wt(t,e.content||"",f.X+l,f.Y,f.options.page.maxContentWidth-l,f.options.page.defaultLineHeightFactor).y+w(t)*.5;f.updateY(p),f.updateX(f.options.page.xpading)}else t.text(g||"",f.X+l,f.Y,{baseline:"top"}),f.updateX(t.getTextWidth(e.content||""),"add"),f.X>=f.options.page.xpading+f.options.page.maxContentWidth&&D(t)}}},Ht=t=>{const e=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(f.options.page.xpading,f.Y,e-f.options.page.xpading,f.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),f.updateY(w(t),"add")},Pt=(t,e,i,n)=>{const r=i*f.options.page.indent,a=f.options.page.maxContentWidth-r,s=w(t),h=e.code??"",l=t.splitTextToSize(h,a),o=f.options.page.lineSpace??4,g="#EEEEEE",p="#eee";let u=0;for(;u<l.length;){const d=f.options.page.maxContentHeight-f.Y,v=l.length-u;let y=Math.floor(d/s);if(y<=0){D(t);continue}y>v&&(y=v);const m=l.slice(u,u+y),x=y===v,C=y*s;u===0&&f.updateY(o,"add"),t.setFillColor(g),t.setDrawColor(p),t.roundedRect(f.X,f.Y-o,f.options.page.maxContentWidth,C+o+(x?o:0),2,2,"FD"),u===0&&e.lang&&(t.setFontSize(10),t.text(e.lang,f.X+f.options.page.maxContentWidth-t.getTextWidth(e.lang)-f.options.page.lineSpace/2,f.Y)),t.setFontSize(f.options.page.defaultFontSize),t.text(m,f.X+4,f.Y);const S=y*s;f.updateY(S,"add"),u+=y,u<l.length&&(D(t),f.updateY(o,"add"))}f.updateY(o,"add")},Dt=(t,e,i)=>{const n=t.getFont().fontName,r=t.getFont().fontStyle,a=t.getFontSize(),s=t.getTextColor(),h=f.options.link?.linkColor||[0,0,255];t.setTextColor(...h);const l=f.options.page.maxContentWidth-i-f.X,o=e.text||e.content||"",g=e.href||"",p=t.splitTextToSize(o,l);if(f.isInlineLockActive)for(let u=0;u<p.length;u++){const d=t.getTextDimensions(p[u]).w,v=w(t)/2;t.link(f.X+i,f.Y,d,v,{url:g}),t.text(p[u],f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(d+1,"add"),f.X+d>f.options.page.maxContentWidth-i&&(f.updateY(v,"add"),f.updateX(f.options.page.xpading+i,"set")),u<p.length-1&&(f.updateY(v,"add"),f.updateX(f.options.page.xpading+i,"set"))}else if(p.length>1){const u=p[0],d=p?.slice(1)?.join(" "),v=t.getTextDimensions(u).w,y=w(t)/2;t.link(f.X+i,f.Y,v,y,{url:g}),t.text(u,f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(f.options.page.xpading+i),f.updateY(y,"add");const m=f.options.page.maxContentWidth-i-f.options.page.xpading;t.splitTextToSize(d,m).forEach(C=>{const S=t.getTextDimensions(C).w;t.link(f.X+F(t),f.Y,S,y,{url:g}),t.text(C,f.X+F(t),f.Y,{baseline:"top",maxWidth:m})})}else{const u=t.getTextDimensions(o).w,d=w(t)/2;t.link(f.X+i,f.Y,u,d,{url:g}),t.text(o,f.X+i,f.Y,{baseline:"top",maxWidth:l}),f.updateX(u+2,"add")}t.setFont(n,r),t.setFontSize(a),t.setTextColor(s)},Tt=(t,e,i,n)=>{const r=f.options,a=i+1,s=f.X+i*r.page.indent,h=f.Y,l=s+r.page.indent/2,o=h,g=t.internal.getCurrentPageInfo().pageNumber;e.items&&e.items.length>0&&e.items.forEach(d=>{n(d,a)});const p=f.Y,u=t.internal.getCurrentPageInfo().pageNumber;t.setDrawColor(100),t.setLineWidth(1);for(let d=g;d<=u;d++){t.setPage(d);const v=d===g,y=d===u,m=v?o:r.page.topmargin,x=y?p:r.page.maxContentHeight;t.line(l,m,l,x)}t.setPage(u),f.updateY(r.page.lineSpace,"add")},kt=(t,e,i)=>{if(!e.data)return;const n=f.options,r=f.X+i*n.page.indent;let a=f.Y;const s=n.page.maxContentWidth-i*n.page.indent;try{const h=t.getImageProperties(e.data),l=h.width,o=h.height;let g=l,p=o;const u=l/o;g>0&&(g=s,p=g/u),a+p>n.page.maxContentHeight&&(t.addPage(),a=n.page.topmargin,f.updateY(a));let d=e.src?.split(".").pop()?.toUpperCase()||"JPEG";e.data.startsWith("data:image/png")?d="PNG":e.data.startsWith("data:image/jpeg")||e.data.startsWith("data:image/jpg")?d="JPEG":e.data.startsWith("data:image/webp")&&(d="WEBP"),t.addImage(e.data,d,r,a,g,p),f.updateY(p+n.page.lineSpace,"add")}catch(h){console.warn("Failed to render image",h)}};function V(t,e,i,n,r){n=n||{};var a=1.15,s=r.internal.scaleFactor,h=r.internal.getFontSize()/s,l=r.getLineHeightFactor?r.getLineHeightFactor():a,o=h*l,g=/\r\n|\r|\n/g,p="",u=1;if((n.valign==="middle"||n.valign==="bottom"||n.halign==="center"||n.halign==="right")&&(p=typeof t=="string"?t.split(g):t,u=p.length||1),i+=h*(2-a),n.valign==="middle"?i-=u/2*o:n.valign==="bottom"&&(i-=u*o),n.halign==="center"||n.halign==="right"){var d=h;if(n.halign==="center"&&(d*=.5),p&&u>=1){for(var v=0;v<p.length;v++)r.text(p[v],e-r.getStringUnitWidth(p[v])*d,i),i+=o;return r}e-=r.getStringUnitWidth(t)*d}return n.halign==="justify"?r.text(t,e,i,{maxWidth:n.maxWidth||100,align:"justify"}):r.text(t,e,i),r}var q={},T=(function(){function t(e){this.jsPDFDocument=e,this.userStyles={textColor:e.getTextColor?this.jsPDFDocument.getTextColor():0,fontSize:e.internal.getFontSize(),fontStyle:e.internal.getFont().fontStyle,font:e.internal.getFont().fontName,lineWidth:e.getLineWidth?this.jsPDFDocument.getLineWidth():0,lineColor:e.getDrawColor?this.jsPDFDocument.getDrawColor():0}}return t.setDefaults=function(e,i){i===void 0&&(i=null),i?i.__autoTableDocumentDefaults=e:q=e},t.unifyColor=function(e){return Array.isArray(e)?e:typeof e=="number"?[e,e,e]:typeof e=="string"?[e]:null},t.prototype.applyStyles=function(e,i){var n,r,a;i===void 0&&(i=!1),e.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(e.fontStyle);var s=this.jsPDFDocument.internal.getFont(),h=s.fontStyle,l=s.fontName;if(e.font&&(l=e.font),e.fontStyle){h=e.fontStyle;var o=this.getFontList()[l];o&&o.indexOf(h)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(o[0]),h=o[0])}if(this.jsPDFDocument.setFont(l,h),e.fontSize&&this.jsPDFDocument.setFontSize(e.fontSize),!i){var g=t.unifyColor(e.fillColor);g&&(n=this.jsPDFDocument).setFillColor.apply(n,g),g=t.unifyColor(e.textColor),g&&(r=this.jsPDFDocument).setTextColor.apply(r,g),g=t.unifyColor(e.lineColor),g&&(a=this.jsPDFDocument).setDrawColor.apply(a,g),typeof e.lineWidth=="number"&&this.jsPDFDocument.setLineWidth(e.lineWidth)}},t.prototype.splitTextToSize=function(e,i,n){return this.jsPDFDocument.splitTextToSize(e,i,n)},t.prototype.rect=function(e,i,n,r,a){return this.jsPDFDocument.rect(e,i,n,r,a)},t.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},t.prototype.getTextWidth=function(e){return this.jsPDFDocument.getTextWidth(e)},t.prototype.getDocument=function(){return this.jsPDFDocument},t.prototype.setPage=function(e){this.jsPDFDocument.setPage(e)},t.prototype.addPage=function(){return this.jsPDFDocument.addPage()},t.prototype.getFontList=function(){return this.jsPDFDocument.getFontList()},t.prototype.getGlobalOptions=function(){return q||{}},t.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},t.prototype.pageSize=function(){var e=this.jsPDFDocument.internal.pageSize;return e.width==null&&(e={width:e.getWidth(),height:e.getHeight()}),e},t.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},t.prototype.getLineHeightFactor=function(){var e=this.jsPDFDocument;return e.getLineHeightFactor?e.getLineHeightFactor():1.15},t.prototype.getLineHeight=function(e){return e/this.scaleFactor()*this.getLineHeightFactor()},t.prototype.pageNumber=function(){var e=this.jsPDFDocument.internal.getCurrentPageInfo();return e?e.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},t})(),I=function(t,e){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},I(t,e)};function tt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}var et=(function(t){tt(e,t);function e(i){var n=t.call(this)||this;return n._element=i,n}return e})(Array);function Yt(t){return{font:"helvetica",fontStyle:"normal",overflow:"linebreak",fillColor:!1,textColor:20,halign:"left",valign:"top",fontSize:10,cellPadding:5/t,lineColor:200,lineWidth:0,cellWidth:"auto",minCellHeight:0,minCellWidth:0}}function zt(t){var e={striped:{table:{fillColor:255,textColor:80,fontStyle:"normal"},head:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},body:{},foot:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:"normal",lineWidth:.1},head:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},body:{},foot:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},alternateRow:{}},plain:{head:{fontStyle:"bold"},foot:{fontStyle:"bold"}}};return e[t]}function Y(t,e,i){i.applyStyles(e,!0);var n=Array.isArray(t)?t:[t],r=n.map(function(a){return i.getTextWidth(a)}).reduce(function(a,s){return Math.max(a,s)},0);return r}function it(t,e,i,n){var r=e.settings.tableLineWidth,a=e.settings.tableLineColor;t.applyStyles({lineWidth:r,lineColor:a});var s=nt(r,!1);s&&t.rect(i.x,i.y,e.getWidth(t.pageSize().width),n.y-i.y,s)}function nt(t,e){var i=t>0,n=e||e===0;return i&&n?"DF":i?"S":n?"F":null}function R(t,e){var i,n,r,a;if(t=t||e,Array.isArray(t)){if(t.length>=4)return{top:t[0],right:t[1],bottom:t[2],left:t[3]};if(t.length===3)return{top:t[0],right:t[1],bottom:t[2],left:t[1]};if(t.length===2)return{top:t[0],right:t[1],bottom:t[0],left:t[1]};t.length===1?t=t[0]:t=e}return typeof t=="object"?(typeof t.vertical=="number"&&(t.top=t.vertical,t.bottom=t.vertical),typeof t.horizontal=="number"&&(t.right=t.horizontal,t.left=t.horizontal),{left:(i=t.left)!==null&&i!==void 0?i:e,top:(n=t.top)!==null&&n!==void 0?n:e,right:(r=t.right)!==null&&r!==void 0?r:e,bottom:(a=t.bottom)!==null&&a!==void 0?a:e}):(typeof t!="number"&&(t=e),{top:t,right:t,bottom:t,left:t})}function rt(t,e){var i=R(e.settings.margin,0);return t.pageSize().width-(i.left+i.right)}function Lt(t,e,i,n,r){var a={},s=1.3333333333333333,h=E(e,function(S){return r.getComputedStyle(S).backgroundColor});h!=null&&(a.fillColor=h);var l=E(e,function(S){return r.getComputedStyle(S).color});l!=null&&(a.textColor=l);var o=Xt(n,i);o&&(a.cellPadding=o);var g="borderTopColor",p=s*i,u=n.borderTopWidth;if(n.borderBottomWidth===u&&n.borderRightWidth===u&&n.borderLeftWidth===u){var d=(parseFloat(u)||0)/p;d&&(a.lineWidth=d)}else a.lineWidth={top:(parseFloat(n.borderTopWidth)||0)/p,right:(parseFloat(n.borderRightWidth)||0)/p,bottom:(parseFloat(n.borderBottomWidth)||0)/p,left:(parseFloat(n.borderLeftWidth)||0)/p},a.lineWidth.top||(a.lineWidth.right?g="borderRightColor":a.lineWidth.bottom?g="borderBottomColor":a.lineWidth.left&&(g="borderLeftColor"));var v=E(e,function(S){return r.getComputedStyle(S)[g]});v!=null&&(a.lineColor=v);var y=["left","right","center","justify"];y.indexOf(n.textAlign)!==-1&&(a.halign=n.textAlign),y=["middle","bottom","top"],y.indexOf(n.verticalAlign)!==-1&&(a.valign=n.verticalAlign);var m=parseInt(n.fontSize||"");isNaN(m)||(a.fontSize=m/s);var x=Rt(n);x&&(a.fontStyle=x);var C=(n.fontFamily||"").toLowerCase();return t.indexOf(C)!==-1&&(a.font=C),a}function Rt(t){var e="";return(t.fontWeight==="bold"||t.fontWeight==="bolder"||parseInt(t.fontWeight)>=700)&&(e="bold"),(t.fontStyle==="italic"||t.fontStyle==="oblique")&&(e+="italic"),e}function E(t,e){var i=at(t,e);if(!i)return null;var n=i.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!n||!Array.isArray(n))return null;var r=[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])],a=parseInt(n[4]);return a===0||isNaN(r[0])||isNaN(r[1])||isNaN(r[2])?null:r}function at(t,e){var i=e(t);return i==="rgba(0, 0, 0, 0)"||i==="transparent"||i==="initial"||i==="inherit"?t.parentElement==null?null:at(t.parentElement,e):i}function Xt(t,e){var i=[t.paddingTop,t.paddingRight,t.paddingBottom,t.paddingLeft],n=96/(72/e),r=(parseInt(t.lineHeight)-parseInt(t.fontSize))/e/2,a=i.map(function(h){return parseInt(h||"0")/n}),s=R(a,0);return r>s.top&&(s.top=r),r>s.bottom&&(s.bottom=r),s}function ot(t,e,i,n,r){var a,s;n===void 0&&(n=!1),r===void 0&&(r=!1);var h;typeof e=="string"?h=i.document.querySelector(e):h=e;var l=Object.keys(t.getFontList()),o=t.scaleFactor(),g=[],p=[],u=[];if(!h)return console.error("Html table could not be found with input: ",e),{head:g,body:p,foot:u};for(var d=0;d<h.rows.length;d++){var v=h.rows[d],y=(s=(a=v?.parentElement)===null||a===void 0?void 0:a.tagName)===null||s===void 0?void 0:s.toLowerCase(),m=Et(l,o,i,v,n,r);m&&(y==="thead"?g.push(m):y==="tfoot"?u.push(m):p.push(m))}return{head:g,body:p,foot:u}}function Et(t,e,i,n,r,a){for(var s=new et(n),h=0;h<n.cells.length;h++){var l=n.cells[h],o=i.getComputedStyle(l);if(r||o.display!=="none"){var g=void 0;a&&(g=Lt(t,l,e,o,i)),s.push({rowSpan:l.rowSpan,colSpan:l.colSpan,styles:g,_element:l,content:jt(l)})}}var p=i.getComputedStyle(n);if(s.length>0&&(r||p.display!=="none"))return s}function jt(t){var e=t.cloneNode(!0);return e.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/ +/g," "),e.innerHTML=e.innerHTML.split(/<br.*?>/).map(function(i){return i.trim()}).join(`
2
- `),e.innerText||e.textContent||""}function At(t,e,i){for(var n=0,r=[t,e,i];n<r.length;n++){var a=r[n];a&&typeof a!="object"&&console.error("The options parameter should be of type object, is: "+typeof a),a.startY&&typeof a.startY!="number"&&(console.error("Invalid value for startY option",a.startY),delete a.startY)}}function H(t,e,i,n,r){if(t==null)throw new TypeError("Cannot convert undefined or null to object");for(var a=Object(t),s=1;s<arguments.length;s++){var h=arguments[s];if(h!=null)for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(a[l]=h[l])}return a}function st(t,e){var i=new T(t),n=i.getDocumentOptions(),r=i.getGlobalOptions();At(r,n,e);var a=H({},r,n,e),s;typeof window<"u"&&(s=window);var h=Bt(r,n,e),l=It(r,n,e),o=Nt(i,a),g=Ot(i,a,s);return{id:e.tableId,content:g,hooks:l,styles:h,settings:o}}function Bt(t,e,i){for(var n={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},r=function(l){if(l==="columnStyles"){var o=t[l],g=e[l],p=i[l];n.columnStyles=H({},o,g,p)}else{var u=[t,e,i],d=u.map(function(v){return v[l]||{}});n[l]=H({},d[0],d[1],d[2])}},a=0,s=Object.keys(n);a<s.length;a++){var h=s[a];r(h)}return n}function It(t,e,i){for(var n=[t,e,i],r={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},a=0,s=n;a<s.length;a++){var h=s[a];h.didParseCell&&r.didParseCell.push(h.didParseCell),h.willDrawCell&&r.willDrawCell.push(h.willDrawCell),h.didDrawCell&&r.didDrawCell.push(h.didDrawCell),h.willDrawPage&&r.willDrawPage.push(h.willDrawPage),h.didDrawPage&&r.didDrawPage.push(h.didDrawPage)}return r}function Nt(t,e){var i,n,r,a,s,h,l,o,g,p,u,d,v=R(e.margin,40/t.scaleFactor()),y=(i=Mt(t,e.startY))!==null&&i!==void 0?i:v.top,m;e.showFoot===!0?m="everyPage":e.showFoot===!1?m="never":m=(n=e.showFoot)!==null&&n!==void 0?n:"everyPage";var x;e.showHead===!0?x="everyPage":e.showHead===!1?x="never":x=(r=e.showHead)!==null&&r!==void 0?r:"everyPage";var C=(a=e.useCss)!==null&&a!==void 0?a:!1,S=e.theme||(C?"plain":"striped"),W=!!e.horizontalPageBreak,X=(s=e.horizontalPageBreakRepeat)!==null&&s!==void 0?s:null;return{includeHiddenHtml:(h=e.includeHiddenHtml)!==null&&h!==void 0?h:!1,useCss:C,theme:S,startY:y,margin:v,pageBreak:(l=e.pageBreak)!==null&&l!==void 0?l:"auto",rowPageBreak:(o=e.rowPageBreak)!==null&&o!==void 0?o:"auto",tableWidth:(g=e.tableWidth)!==null&&g!==void 0?g:"auto",showHead:x,showFoot:m,tableLineWidth:(p=e.tableLineWidth)!==null&&p!==void 0?p:0,tableLineColor:(u=e.tableLineColor)!==null&&u!==void 0?u:200,horizontalPageBreak:W,horizontalPageBreakRepeat:X,horizontalPageBreakBehaviour:(d=e.horizontalPageBreakBehaviour)!==null&&d!==void 0?d:"afterAllRows"}}function Mt(t,e){var i=t.getLastAutoTable(),n=t.scaleFactor(),r=t.pageNumber(),a=!1;if(i&&i.startPageNumber){var s=i.startPageNumber+i.pageNumber-1;a=s===r}return typeof e=="number"?e:(e==null||e===!1)&&a&&i?.finalY!=null?i.finalY+20/n:null}function Ot(t,e,i){var n=e.head||[],r=e.body||[],a=e.foot||[];if(e.html){var s=e.includeHiddenHtml;if(i){var h=ot(t,e.html,i,s,e.useCss)||{};n=h.head||n,r=h.body||n,a=h.foot||n}else console.error("Cannot parse html in non browser environment")}var l=e.columns||qt(n,r,a);return{columns:l,head:n,body:r,foot:a}}function qt(t,e,i){var n=t[0]||e[0]||i[0]||[],r=[];return Object.keys(n).filter(function(a){return a!=="_element"}).forEach(function(a){var s=1,h;Array.isArray(n)?h=n[parseInt(a)]:h=n[a],typeof h=="object"&&!Array.isArray(h)&&(s=h?.colSpan||1);for(var l=0;l<s;l++){var o=void 0;Array.isArray(n)?o=r.length:o=a+(l>0?"_".concat(l):"");var g={dataKey:o};r.push(g)}}),r}var N=(function(){function t(e,i,n){this.table=i,this.pageNumber=i.pageNumber,this.settings=i.settings,this.cursor=n,this.doc=e.getDocument()}return t})(),Jt=(function(t){tt(e,t);function e(i,n,r,a,s,h){var l=t.call(this,i,n,h)||this;return l.cell=r,l.row=a,l.column=s,l.section=a.section,l}return e})(N),Kt=(function(){function t(e,i){this.pageNumber=1,this.id=e.id,this.settings=e.settings,this.styles=e.styles,this.hooks=e.hooks,this.columns=i.columns,this.head=i.head,this.body=i.body,this.foot=i.foot}return t.prototype.getHeadHeight=function(e){return this.head.reduce(function(i,n){return i+n.getMaxCellHeight(e)},0)},t.prototype.getFootHeight=function(e){return this.foot.reduce(function(i,n){return i+n.getMaxCellHeight(e)},0)},t.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},t.prototype.callCellHooks=function(e,i,n,r,a,s){for(var h=0,l=i;h<l.length;h++){var o=l[h],g=new Jt(e,this,n,r,a,s),p=o(g)===!1;if(n.text=Array.isArray(n.text)?n.text:[n.text],p)return!1}return!0},t.prototype.callEndPageHooks=function(e,i){e.applyStyles(e.userStyles);for(var n=0,r=this.hooks.didDrawPage;n<r.length;n++){var a=r[n];a(new N(e,this,i))}},t.prototype.callWillDrawPageHooks=function(e,i){for(var n=0,r=this.hooks.willDrawPage;n<r.length;n++){var a=r[n];a(new N(e,this,i))}},t.prototype.getWidth=function(e){if(typeof this.settings.tableWidth=="number")return this.settings.tableWidth;if(this.settings.tableWidth==="wrap"){var i=this.columns.reduce(function(r,a){return r+a.wrappedWidth},0);return i}else{var n=this.settings.margin;return e-n.left-n.right}},t})(),lt=(function(){function t(e,i,n,r,a){a===void 0&&(a=!1),this.height=0,this.raw=e,e instanceof et&&(this.raw=e._element,this.element=e._element),this.index=i,this.section=n,this.cells=r,this.spansMultiplePages=a}return t.prototype.getMaxCellHeight=function(e){var i=this;return e.reduce(function(n,r){var a;return Math.max(n,((a=i.cells[r.index])===null||a===void 0?void 0:a.height)||0)},0)},t.prototype.hasRowSpan=function(e){var i=this;return e.filter(function(n){var r=i.cells[n.index];return r?r.rowSpan>1:!1}).length>0},t.prototype.canEntireRowFit=function(e,i){return this.getMaxCellHeight(i)<=e},t.prototype.getMinimumRowHeight=function(e,i){var n=this;return e.reduce(function(r,a){var s=n.cells[a.index];if(!s)return 0;var h=i.getLineHeight(s.styles.fontSize),l=s.padding("vertical"),o=l+h;return o>r?o:r},0)},t})(),ht=(function(){function t(e,i,n){var r;this.contentHeight=0,this.contentWidth=0,this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.height=0,this.x=0,this.y=0,this.styles=i,this.section=n,this.raw=e;var a=e;e!=null&&typeof e=="object"&&!Array.isArray(e)?(this.rowSpan=e.rowSpan||1,this.colSpan=e.colSpan||1,a=(r=e.content)!==null&&r!==void 0?r:e,e._element&&(this.raw=e._element)):(this.rowSpan=1,this.colSpan=1);var s=a!=null?""+a:"",h=/\r\n|\r|\n/g;this.text=s.split(h)}return t.prototype.getTextPos=function(){var e;if(this.styles.valign==="top")e=this.y+this.padding("top");else if(this.styles.valign==="bottom")e=this.y+this.height-this.padding("bottom");else{var i=this.height-this.padding("vertical");e=this.y+i/2+this.padding("top")}var n;if(this.styles.halign==="right")n=this.x+this.width-this.padding("right");else if(this.styles.halign==="center"){var r=this.width-this.padding("horizontal");n=this.x+r/2+this.padding("left")}else n=this.x+this.padding("left");return{x:n,y:e}},t.prototype.getContentHeight=function(e,i){i===void 0&&(i=1.15);var n=Array.isArray(this.text)?this.text.length:1,r=this.styles.fontSize/e*i,a=n*r+this.padding("vertical");return Math.max(a,this.styles.minCellHeight)},t.prototype.padding=function(e){var i=R(this.styles.cellPadding,0);return e==="vertical"?i.top+i.bottom:e==="horizontal"?i.left+i.right:i[e]},t})(),$t=(function(){function t(e,i,n){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=e,this.raw=i,this.index=n}return t.prototype.getMaxCustomCellWidth=function(e){for(var i=0,n=0,r=e.allRows();n<r.length;n++){var a=r[n],s=a.cells[this.index];s&&typeof s.styles.cellWidth=="number"&&(i=Math.max(i,s.styles.cellWidth))}return i},t})();function Ut(t,e){_t(t,e);var i=[],n=0;e.columns.forEach(function(a){var s=a.getMaxCustomCellWidth(e);s?a.width=s:(a.width=a.wrappedWidth,i.push(a)),n+=a.width});var r=e.getWidth(t.pageSize().width)-n;r&&(r=M(i,r,function(a){return Math.max(a.minReadableWidth,a.minWidth)})),r&&(r=M(i,r,function(a){return a.minWidth})),r=Math.abs(r),!e.settings.horizontalPageBreak&&r>.1/t.scaleFactor()&&(r=r<1?r:Math.round(r),console.warn("Of the table content, ".concat(r," units width could not fit page"))),Qt(e),Zt(e,t),Gt(e)}function _t(t,e){var i=t.scaleFactor(),n=e.settings.horizontalPageBreak,r=rt(t,e);e.allRows().forEach(function(a){for(var s=0,h=e.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o){var g=e.hooks.didParseCell;e.callCellHooks(t,g,o,a,l,null);var p=o.padding("horizontal");o.contentWidth=Y(o.text,o.styles,t)+p;var u=Y(o.text.join(" ").split(/[^\S\u00A0]+/),o.styles,t);if(o.minReadableWidth=u+o.padding("horizontal"),typeof o.styles.cellWidth=="number")o.minWidth=o.styles.cellWidth,o.wrappedWidth=o.styles.cellWidth;else if(o.styles.cellWidth==="wrap"||n===!0)o.contentWidth>r?(o.minWidth=r,o.wrappedWidth=r):(o.minWidth=o.contentWidth,o.wrappedWidth=o.contentWidth);else{var d=10/i;o.minWidth=o.styles.minCellWidth||d,o.wrappedWidth=o.contentWidth,o.minWidth>o.wrappedWidth&&(o.wrappedWidth=o.minWidth)}}}}),e.allRows().forEach(function(a){for(var s=0,h=e.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o&&o.colSpan===1)l.wrappedWidth=Math.max(l.wrappedWidth,o.wrappedWidth),l.minWidth=Math.max(l.minWidth,o.minWidth),l.minReadableWidth=Math.max(l.minReadableWidth,o.minReadableWidth);else{var g=e.styles.columnStyles[l.dataKey]||e.styles.columnStyles[l.index]||{},p=g.cellWidth||g.minCellWidth;p&&typeof p=="number"&&(l.minWidth=p,l.wrappedWidth=p)}o&&(o.colSpan>1&&!l.minWidth&&(l.minWidth=o.minWidth),o.colSpan>1&&!l.wrappedWidth&&(l.wrappedWidth=o.minWidth))}})}function M(t,e,i){for(var n=e,r=t.reduce(function(d,v){return d+v.wrappedWidth},0),a=0;a<t.length;a++){var s=t[a],h=s.wrappedWidth/r,l=n*h,o=s.width+l,g=i(s),p=o<g?g:o;e-=p-s.width,s.width=p}if(e=Math.round(e*1e10)/1e10,e){var u=t.filter(function(d){return e<0?d.width>i(d):!0});u.length&&(e=M(u,e,i))}return e}function Gt(t){for(var e={},i=1,n=t.allRows(),r=0;r<n.length;r++)for(var a=n[r],s=0,h=t.columns;s<h.length;s++){var l=h[s],o=e[l.index];if(i>1)i--,delete a.cells[l.index];else if(o)o.cell.height+=a.height,i=o.cell.colSpan,delete a.cells[l.index],o.left--,o.left<=1&&delete e[l.index];else{var g=a.cells[l.index];if(!g)continue;if(g.height=a.height,g.rowSpan>1){var p=n.length-r,u=g.rowSpan>p?p:g.rowSpan;e[l.index]={cell:g,left:u,row:a}}}}}function Qt(t){for(var e=t.allRows(),i=0;i<e.length;i++)for(var n=e[i],r=null,a=0,s=0,h=0;h<t.columns.length;h++){var l=t.columns[h];if(s-=1,s>1&&t.columns[h+1])a+=l.width,delete n.cells[l.index];else if(r){var o=r;delete n.cells[l.index],r=null,o.width=l.width+a}else{var o=n.cells[l.index];if(!o)continue;if(s=o.colSpan,a=0,o.colSpan>1){r=o,a+=l.width;continue}o.width=l.width+a}}}function Zt(t,e){for(var i={count:0,height:0},n=0,r=t.allRows();n<r.length;n++){for(var a=r[n],s=0,h=t.columns;s<h.length;s++){var l=h[s],o=a.cells[l.index];if(o){e.applyStyles(o.styles,!0);var g=o.width-o.padding("horizontal");if(o.styles.overflow==="linebreak")o.text=e.splitTextToSize(o.text,g+1/e.scaleFactor(),{fontSize:o.styles.fontSize});else if(o.styles.overflow==="ellipsize")o.text=J(o.text,g,o.styles,e,"...");else if(o.styles.overflow==="hidden")o.text=J(o.text,g,o.styles,e,"");else if(typeof o.styles.overflow=="function"){var p=o.styles.overflow(o.text,g);typeof p=="string"?o.text=[p]:o.text=p}o.contentHeight=o.getContentHeight(e.scaleFactor(),e.getLineHeightFactor());var u=o.contentHeight/o.rowSpan;o.rowSpan>1&&i.count*i.height<u*o.rowSpan?i={height:u,count:o.rowSpan}:i&&i.count>0&&i.height>u&&(u=i.height),u>a.height&&(a.height=u)}}i.count--}}function J(t,e,i,n,r){return t.map(function(a){return Vt(a,e,i,n,r)})}function Vt(t,e,i,n,r){var a=1e4*n.scaleFactor();if(e=Math.ceil(e*a)/a,e>=Y(t,i,n))return t;for(;e<Y(t+r,i,n)&&!(t.length<=1);)t=t.substring(0,t.length-1);return t.trim()+r}function ft(t,e){var i=new T(t),n=te(e,i.scaleFactor()),r=new Kt(e,n);return Ut(i,r),i.applyStyles(i.userStyles),r}function te(t,e){var i=t.content,n=ie(i.columns);if(i.head.length===0){var r=K(n,"head");r&&i.head.push(r)}if(i.foot.length===0){var r=K(n,"foot");r&&i.foot.push(r)}var a=t.settings.theme,s=t.styles;return{columns:n,head:j("head",i.head,n,s,a,e),body:j("body",i.body,n,s,a,e),foot:j("foot",i.foot,n,s,a,e)}}function j(t,e,i,n,r,a){var s={},h=e.map(function(l,o){for(var g=0,p={},u=0,d=0,v=0,y=i;v<y.length;v++){var m=y[v];if(s[m.index]==null||s[m.index].left===0)if(d===0){var x=void 0;Array.isArray(l)?x=l[m.index-u-g]:x=l[m.dataKey];var C={};typeof x=="object"&&!Array.isArray(x)&&(C=x?.styles||{});var S=ne(t,m,o,r,n,a,C),W=new ht(x,S,t);p[m.dataKey]=W,p[m.index]=W,d=W.colSpan-1,s[m.index]={left:W.rowSpan-1,times:d}}else d--,u++;else s[m.index].left--,d=s[m.index].times,g++}return new lt(l,o,t,p)});return h}function K(t,e){var i={};return t.forEach(function(n){if(n.raw!=null){var r=ee(e,n.raw);r!=null&&(i[n.dataKey]=r)}}),Object.keys(i).length>0?i:null}function ee(t,e){if(t==="head"){if(typeof e=="object")return e.header||null;if(typeof e=="string"||typeof e=="number")return e}else if(t==="foot"&&typeof e=="object")return e.footer;return null}function ie(t){return t.map(function(e,i){var n,r;return typeof e=="object"?r=(n=e.dataKey)!==null&&n!==void 0?n:i:r=i,new $t(r,e,i)})}function ne(t,e,i,n,r,a,s){var h=zt(n),l;t==="head"?l=r.headStyles:t==="body"?l=r.bodyStyles:t==="foot"&&(l=r.footStyles);var o=H({},h.table,h[t],r.styles,l),g=r.columnStyles[e.dataKey]||r.columnStyles[e.index]||{},p=t==="body"?g:{},u=t==="body"&&i%2===0?H({},h.alternateRow,r.alternateRowStyles):{},d=Yt(a),v=H({},d,o,u,p);return H(v,s)}function re(t,e,i){var n;i===void 0&&(i={});var r=rt(t,e),a=new Map,s=[],h=[],l=[];Array.isArray(e.settings.horizontalPageBreakRepeat)?l=e.settings.horizontalPageBreakRepeat:(typeof e.settings.horizontalPageBreakRepeat=="string"||typeof e.settings.horizontalPageBreakRepeat=="number")&&(l=[e.settings.horizontalPageBreakRepeat]),l.forEach(function(u){var d=e.columns.find(function(v){return v.dataKey===u||v.index===u});d&&!a.has(d.index)&&(a.set(d.index,!0),s.push(d.index),h.push(e.columns[d.index]),r-=d.wrappedWidth)});for(var o=!0,g=(n=i?.start)!==null&&n!==void 0?n:0;g<e.columns.length;){if(a.has(g)){g++;continue}var p=e.columns[g].wrappedWidth;if(o||r>=p)o=!1,s.push(g),h.push(e.columns[g]),r-=p;else break;g++}return{colIndexes:s,columns:h,lastIndex:g-1}}function ae(t,e){for(var i=[],n=0;n<e.columns.length;n++){var r=re(t,e,{start:n});r.columns.length&&(i.push(r),n=r.lastIndex)}return i}function gt(t,e){var i=e.settings,n=i.startY,r=i.margin,a={x:r.left,y:n},s=e.getHeadHeight(e.columns)+e.getFootHeight(e.columns),h=n+r.bottom+s;if(i.pageBreak==="avoid"){var l=e.body,o=l.reduce(function(u,d){return u+d.height},0);h+=o}var g=new T(t);(i.pageBreak==="always"||i.startY!=null&&h>g.pageSize().height)&&(ut(g),a.y=r.top),e.callWillDrawPageHooks(g,a);var p=H({},a);e.startPageNumber=g.pageNumber(),i.horizontalPageBreak?oe(g,e,p,a):(g.applyStyles(g.userStyles),(i.showHead==="firstPage"||i.showHead==="everyPage")&&e.head.forEach(function(u){return P(g,e,u,a,e.columns)}),g.applyStyles(g.userStyles),e.body.forEach(function(u,d){var v=d===e.body.length-1;z(g,e,u,v,p,a,e.columns)}),g.applyStyles(g.userStyles),(i.showFoot==="lastPage"||i.showFoot==="everyPage")&&e.foot.forEach(function(u){return P(g,e,u,a,e.columns)})),it(g,e,p,a),e.callEndPageHooks(g,a),e.finalY=a.y,t.lastAutoTable=e,g.applyStyles(g.userStyles)}function oe(t,e,i,n){var r=ae(t,e),a=e.settings;if(a.horizontalPageBreakBehaviour==="afterAllRows")r.forEach(function(o,g){t.applyStyles(t.userStyles),g>0?k(t,e,i,n,o.columns,!0):$(t,e,n,o.columns),se(t,e,i,n,o.columns),A(t,e,n,o.columns)});else for(var s=-1,h=r[0],l=function(){var o=s;if(h){t.applyStyles(t.userStyles);var g=h.columns;s>=0?k(t,e,i,n,g,!0):$(t,e,n,g),o=U(t,e,s+1,n,g),A(t,e,n,g)}var p=o-s;r.slice(1).forEach(function(u){t.applyStyles(t.userStyles),k(t,e,i,n,u.columns,!0),U(t,e,s+1,n,u.columns,p),A(t,e,n,u.columns)}),s=o};s<e.body.length-1;)l()}function $(t,e,i,n){var r=e.settings;t.applyStyles(t.userStyles),(r.showHead==="firstPage"||r.showHead==="everyPage")&&e.head.forEach(function(a){return P(t,e,a,i,n)})}function se(t,e,i,n,r){t.applyStyles(t.userStyles),e.body.forEach(function(a,s){var h=s===e.body.length-1;z(t,e,a,h,i,n,r)})}function U(t,e,i,n,r,a){t.applyStyles(t.userStyles),a=a??e.body.length;var s=Math.min(i+a,e.body.length),h=-1;return e.body.slice(i,s).forEach(function(l,o){var g=i+o===e.body.length-1,p=pt(t,e,g,n);l.canEntireRowFit(p,r)&&(P(t,e,l,n,r),h=i+o)}),h}function A(t,e,i,n){var r=e.settings;t.applyStyles(t.userStyles),(r.showFoot==="lastPage"||r.showFoot==="everyPage")&&e.foot.forEach(function(a){return P(t,e,a,i,n)})}function le(t,e,i){var n=i.getLineHeight(t.styles.fontSize),r=t.padding("vertical"),a=Math.floor((e-r)/n);return Math.max(0,a)}function he(t,e,i,n){var r={};t.spansMultiplePages=!0,t.height=0;for(var a=0,s=0,h=i.columns;s<h.length;s++){var l=h[s],o=t.cells[l.index];if(o){Array.isArray(o.text)||(o.text=[o.text]);var g=new ht(o.raw,o.styles,o.section);g=H(g,o),g.text=[];var p=le(o,e,n);o.text.length>p&&(g.text=o.text.splice(p,o.text.length));var u=n.scaleFactor(),d=n.getLineHeightFactor();o.contentHeight=o.getContentHeight(u,d),o.contentHeight>=e&&(o.contentHeight=e,g.styles.minCellHeight-=e),o.contentHeight>t.height&&(t.height=o.contentHeight),g.contentHeight=g.getContentHeight(u,d),g.contentHeight>a&&(a=g.contentHeight),r[l.index]=g}}var v=new lt(t.raw,-1,t.section,r,!0);v.height=a;for(var y=0,m=i.columns;y<m.length;y++){var l=m[y],g=v.cells[l.index];g&&(g.height=v.height);var o=t.cells[l.index];o&&(o.height=t.height)}return v}function fe(t,e,i,n){var r=t.pageSize().height,a=n.settings.margin,s=a.top+a.bottom,h=r-s;e.section==="body"&&(h-=n.getHeadHeight(n.columns)+n.getFootHeight(n.columns));var l=e.getMinimumRowHeight(n.columns,t),o=l<i;if(l>h)return console.error("Will not be able to print row ".concat(e.index," correctly since it's minimum height is larger than page height")),!0;if(!o)return!1;var g=e.hasRowSpan(n.columns),p=e.getMaxCellHeight(n.columns)>h;return p?(g&&console.error("The content of row ".concat(e.index," will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.")),!0):!(g||n.settings.rowPageBreak==="avoid")}function z(t,e,i,n,r,a,s){var h=pt(t,e,n,a);if(i.canEntireRowFit(h,s))P(t,e,i,a,s);else if(fe(t,i,h,e)){var l=he(i,h,e,t);P(t,e,i,a,s),k(t,e,r,a,s),z(t,e,l,n,r,a,s)}else k(t,e,r,a,s),z(t,e,i,n,r,a,s)}function P(t,e,i,n,r){n.x=e.settings.margin.left;for(var a=0,s=r;a<s.length;a++){var h=s[a],l=i.cells[h.index];if(!l){n.x+=h.width;continue}t.applyStyles(l.styles),l.x=n.x,l.y=n.y;var o=e.callCellHooks(t,e.hooks.willDrawCell,l,i,h,n);if(o===!1){n.x+=h.width;continue}ge(t,l,n);var g=l.getTextPos();V(l.text,g.x,g.y,{halign:l.styles.halign,valign:l.styles.valign,maxWidth:Math.ceil(l.width-l.padding("left")-l.padding("right"))},t.getDocument()),e.callCellHooks(t,e.hooks.didDrawCell,l,i,h,n),n.x+=h.width}n.y+=i.height}function ge(t,e,i){var n=e.styles;if(t.getDocument().setFillColor(t.getDocument().getFillColor()),typeof n.lineWidth=="number"){var r=nt(n.lineWidth,n.fillColor);r&&t.rect(e.x,i.y,e.width,e.height,r)}else typeof n.lineWidth=="object"&&(n.fillColor&&t.rect(e.x,i.y,e.width,e.height,"F"),pe(t,e,i,n.lineWidth))}function pe(t,e,i,n){var r,a,s,h;n.top&&(r=i.x,a=i.y,s=i.x+e.width,h=i.y,n.right&&(s+=.5*n.right),n.left&&(r-=.5*n.left),l(n.top,r,a,s,h)),n.bottom&&(r=i.x,a=i.y+e.height,s=i.x+e.width,h=i.y+e.height,n.right&&(s+=.5*n.right),n.left&&(r-=.5*n.left),l(n.bottom,r,a,s,h)),n.left&&(r=i.x,a=i.y,s=i.x,h=i.y+e.height,n.top&&(a-=.5*n.top),n.bottom&&(h+=.5*n.bottom),l(n.left,r,a,s,h)),n.right&&(r=i.x+e.width,a=i.y,s=i.x+e.width,h=i.y+e.height,n.top&&(a-=.5*n.top),n.bottom&&(h+=.5*n.bottom),l(n.right,r,a,s,h));function l(o,g,p,u,d){t.getDocument().setLineWidth(o),t.getDocument().line(g,p,u,d,"S")}}function pt(t,e,i,n){var r=e.settings.margin.bottom,a=e.settings.showFoot;return(a==="everyPage"||a==="lastPage"&&i)&&(r+=e.getFootHeight(e.columns)),t.pageSize().height-n.y-r}function k(t,e,i,n,r,a){r===void 0&&(r=[]),a===void 0&&(a=!1),t.applyStyles(t.userStyles),e.settings.showFoot==="everyPage"&&!a&&e.foot.forEach(function(h){return P(t,e,h,n,r)}),e.callEndPageHooks(t,n);var s=e.settings.margin;it(t,e,i,n),ut(t),e.pageNumber++,n.x=s.left,n.y=s.top,i.y=s.top,e.callWillDrawPageHooks(t,n),e.settings.showHead==="everyPage"&&(e.head.forEach(function(h){return P(t,e,h,n,r)}),t.applyStyles(t.userStyles))}function ut(t){var e=t.pageNumber();t.setPage(e+1);var i=t.pageNumber();return i===e?(t.addPage(),!0):!1}function ue(t){t.API.autoTable=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=e[0],r=st(this,n),a=ft(this,r);return gt(this,a),this},t.API.lastAutoTable=!1,t.API.autoTableText=function(e,i,n,r){V(e,i,n,r,this)},t.API.autoTableSetDefaults=function(e){return T.setDefaults(e,this),this},t.autoTableSetDefaults=function(e,i){T.setDefaults(e,i)},t.API.autoTableHtmlToJson=function(e,i){var n;if(i===void 0&&(i=!1),typeof window>"u")return console.error("Cannot run autoTableHtmlToJson in non browser environment"),null;var r=new T(this),a=ot(r,e,window,i,!1),s=a.head,h=a.body,l=((n=s[0])===null||n===void 0?void 0:n.map(function(o){return o.content}))||[];return{columns:l,rows:h,data:h}}}var B;function de(t,e){var i=st(t,e),n=ft(t,i);gt(t,n)}try{if(typeof window<"u"&&window){var _=window,G=_.jsPDF||((B=_.jspdf)===null||B===void 0?void 0:B.jsPDF);G&&ue(G)}}catch(t){console.error("Could not apply autoTable plugin",t)}const ve=(t,e,i)=>{if(!e.header||!e.rows)return;const n=f.options,r=n.page.xmargin+i*n.page.indent,a=[e.header.map(l=>l.content||"")],s=e.rows.map(l=>l.map(o=>o.content||"")),h=n.table||{};de(t,{head:a,body:s,startY:f.Y,margin:{left:r,right:n.page.xmargin},...h,didDrawPage:l=>{h.didDrawPage&&h.didDrawPage(l)},didDrawCell:l=>{h.didDrawCell&&h.didDrawCell(l),f.setCursor({x:f.X,y:l.cell.y+2*n.page.lineSpace})}})},dt=async t=>{for(const e of t){if(e.type===c.Image&&e.src)try{if(e.src.startsWith("data:"))e.data=e.src;else{const i=await fetch(e.src);if(!i.ok)throw new Error(`Failed to fetch image: ${i.statusText}`);const n=await i.blob(),r=await new Promise((a,s)=>{const h=new FileReader;h.onloadend=()=>{typeof h.result=="string"?a(h.result):s(new Error("Failed to convert image to base64 string"))},h.onerror=s,h.readAsDataURL(n)});e.data=r}}catch(i){console.warn(`[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,i)}e.items&&e.items.length>0&&await dt(e.items)}},Q={page:{indent:10,maxContentWidth:190,maxContentHeight:277,lineSpace:1.5,defaultLineHeightFactor:1.2,defaultFontSize:12,defaultTitleFontSize:14,topmargin:10,xpading:10,xmargin:10,format:"a4",orientation:"p"},font:{bold:{name:"helvetica",style:"bold"},regular:{name:"helvetica",style:"normal"},light:{name:"helvetica",style:"light"}}},ce=t=>{if(!t)throw new Error("RenderOption is required");const e={...Q.page,...t.page},i={...Q.font,...t.font};return e.maxContentWidth||(e.maxContentWidth=190),e.maxContentHeight||(e.maxContentHeight=277),{...t,page:e,font:i}},ye=async(t,e,i)=>{const n=ce(i);f.initialize(n);const r=await Z(e);await dt(r),console.log(r);const a=(s,h=0,l=!1,o=0,g=!1,p=!0)=>{const u=h*n.page.indent;switch(f.Y+t.splitTextToSize(s.content??"",n.page.maxContentWidth-u).length*w(t)>=n.page.maxContentHeight&&D(t),s.type){case c.Heading:yt(t,s,u,a);break;case c.Paragraph:xt(t,s,u,a);break;case c.List:wt(t,s,h,a);break;case c.ListItem:St(t,s,h,a,o,g);break;case c.Hr:Ht(t);break;case c.Code:Pt(t,s,h);break;case c.Strong:case c.Em:case c.CodeSpan:O(t,s,u);break;case c.Link:Dt(t,s,u);break;case c.Blockquote:Tt(t,s,h,a);break;case c.Image:kt(t,s,h);break;case c.Table:ve(t,s,h);break;case c.Raw:case c.Text:Ft(t,s,h,l,a,o,g,n.page.defaultFontSize>0);break;default:console.warn(`Warning: Unsupported element type encountered: ${s.type}.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ct=require("marked");var y=(e=>(e.Heading="heading",e.Paragraph="paragraph",e.List="list",e.ListItem="list_item",e.Blockquote="blockquote",e.Code="code",e.CodeSpan="codespan",e.Table="table",e.Html="html",e.Hr="hr",e.Image="image",e.Link="link",e.Strong="strong",e.Em="em",e.TableHeader="table_header",e.TableCell="table_cell",e.Raw="raw",e.Text="text",e))(y||{});const rt=async e=>{const t=await Ct.marked.lexer(e,{async:!0,gfm:!0});return F(t)},F=e=>{const t=[];return e.forEach(n=>{try{const i=bt[n.type];i?t.push(i(n)):t.push({type:y.Raw,content:n.raw})}catch(i){console.error("Failed to handle token ==>",n,i)}}),t},bt={[y.Heading]:e=>({type:y.Heading,depth:e.depth,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Paragraph]:e=>({type:y.Paragraph,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.List]:e=>({type:y.List,ordered:e.ordered,start:e.start,items:e.items?F(e.items):[]}),[y.ListItem]:e=>({type:y.ListItem,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Code]:e=>({type:y.Code,lang:e.lang,code:e.text}),[y.Table]:e=>({type:y.Table,header:e.header.map(t=>({type:y.TableHeader,content:t.text})),rows:e.rows.map(t=>t.map(n=>({type:y.TableCell,content:n.text})))}),[y.Image]:e=>({type:y.Image,src:e.href,alt:e.text}),[y.Link]:e=>({type:y.Link,href:e.href,text:e.text,items:e.tokens?F(e.tokens):[]}),[y.Strong]:e=>({type:y.Strong,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Em]:e=>({type:y.Em,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Text]:e=>({type:y.Text,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Hr]:e=>({type:y.Hr,content:e.raw,items:e.tokens?F(e.tokens):[]}),[y.CodeSpan]:e=>({type:y.CodeSpan,content:e.text,items:e.tokens?F(e.tokens):[]}),[y.Blockquote]:e=>({type:y.Blockquote,content:e.text,items:e.tokens?F(e.tokens):[]})},L=class L{static initialize(t){this.options_=t,this.cursor={x:t.cursor.x,y:t.cursor.y},this.lastContentY_=t.cursor.y}static getCursor(){return this.cursor}static setCursor(t){this.cursor=t}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(t,n="set"){n==="set"?this.cursor.x=t:n==="add"&&(this.cursor.x+=t)}static updateY(t,n="set"){n==="set"?this.cursor.y=t:n==="add"&&(this.cursor.y+=t)}static recordContentY(t){this.lastContentY_=t!==void 0?t:this.cursor.y}static get lastContentY(){return this.lastContentY_}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.lastContentY_=0,L.inlineLock=!1;let g=L;const w=e=>e.getTextDimensions("H").h*g.options.page.defaultLineHeightFactor,k=e=>e.getTextDimensions("H").w*g.options.page.defaultLineHeightFactor,Ft=(e,t,n,i)=>{const r=6-(t?.depth??0)>0?6-(t?.depth??0):1;if(e.setFontSize(g.options.page.defaultFontSize+r),t?.items&&t?.items.length>0)for(const a of t?.items??[])i(a,n,!1);else{const a=w(e);e.text(t?.content??"",g.X+n,g.Y,{align:"left",maxWidth:g.options.page.maxContentWidth-n,baseline:"top"}),g.recordContentY(g.Y+a),g.updateY(a,"add")}e.setFontSize(g.options.page.defaultFontSize),g.updateX(g.options.page.xpading,"set")},T=e=>{typeof g.options.pageBreakHandler=="function"?g.options.pageBreakHandler(e):e.addPage(g.options.page?.format,g.options.page?.orientation),g.updateY(g.options.page.topmargin),g.updateX(g.options.page.xpading)};class q{static getCodespanOptions(){const t=g.options.codespan??{};return{backgroundColor:t.backgroundColor??"#EEEEEE",padding:t.padding??.5,showBackground:t.showBackground!==!1,fontSizeScale:t.fontSizeScale??.9}}static applyStyle(t,n){const i=t.getFont().fontName,r=t.getFontSize(),a=()=>{const o=g.options.font.bold?.name;return o&&o!==""?o:i},l=()=>{const o=g.options.font.regular?.name;return o&&o!==""?o:i};switch(n){case"bold":t.setFont(a(),g.options.font.bold?.style||"bold");break;case"italic":t.setFont(l(),"italic");break;case"bolditalic":t.setFont(a(),"bolditalic");break;case"codespan":t.setFont("courier","normal"),t.setFontSize(r*this.getCodespanOptions().fontSizeScale);break;default:t.setFont(l(),t.getFont().fontStyle);break}}static measureWordWidth(t,n,i){const r=t.getFont(),a=t.getFontSize();this.applyStyle(t,i);const l=t.getTextWidth(n),o=t.getCharSpace?.()??0,h=l+n.length*o;return t.setFont(r.fontName,r.fontStyle),t.setFontSize(a),h}static getStyleFromType(t,n){switch(t){case"strong":return n==="italic"?"bolditalic":"bold";case"em":return n==="bold"?"bolditalic":"italic";case"codespan":return"codespan";default:return n||"normal"}}static flattenToWords(t,n,i="normal",r=!1,a){const l=[];for(const o of n){const h=this.getStyleFromType(o.type,i),s=o.type==="link"||r,f=o.href||a;if(o.items&&o.items.length>0){const u=this.flattenToWords(t,o.items,h,s,f);l.push(...u)}else{const u=o.content||o.text||"";if(!u)continue;if(h==="codespan"){const p=u.trim();p&&l.push({text:p,width:this.measureWordWidth(t,p,h),style:h,isLink:s,href:f,linkColor:s?g.options.link?.linkColor||[0,0,255]:void 0});continue}const d=u.split(/\s+/).filter(p=>p.length>0);if(d.length===0)continue;for(let p=0;p<d.length;p++){const c=d[p];l.push({text:c,width:this.measureWordWidth(t,c,h),style:h,isLink:s,href:f,linkColor:s?g.options.link?.linkColor||[0,0,255]:void 0})}}}return l}static breakIntoLines(t,n,i){const r=[];let a=[],l=0,o=0;const h=t.getTextWidth(" ");for(let s=0;s<n.length;s++){const f=n[s],u=a.length>0?h+f.width:f.width;o+u>i&&a.length>0?(r.push({words:a,totalTextWidth:l,isLastLine:!1}),a=[f],l=f.width,o=f.width):(a.push(f),l+=f.width,o+=u)}return a.length>0&&r.push({words:a,totalTextWidth:l,isLastLine:!0}),r}static renderWord(t,n,i,r){const a=t.getFont(),l=t.getFontSize(),o=t.getTextColor();if(this.applyStyle(t,n.style),n.isLink&&n.linkColor&&t.setTextColor(...n.linkColor),n.style==="codespan"){const h=this.getCodespanOptions();if(h.showBackground){const s=w(t),f=h.padding;t.setFillColor(h.backgroundColor),t.rect(i-f,r-f,n.width+f*2,s+f*2,"F"),t.setFillColor("#000000")}}if(t.text(n.text,i,r,{baseline:"top"}),n.isLink&&n.href){const h=w(t)/2;t.link(i,r,n.width,h,{url:n.href})}t.setFont(a.fontName,a.fontStyle),t.setFontSize(l),t.setTextColor(o)}static renderAlignedLine(t,n,i,r,a,l="left"){const{words:o,totalTextWidth:h,isLastLine:s}=n;if(o.length===0)return;const f=t.getTextWidth(" ");let u=i,d=f;const p=h+(o.length-1)*f;switch(l){case"right":u=i+a-p;break;case"center":u=i+(a-p)/2;break;case"justify":!s&&o.length>1&&(d=(a-h)/(o.length-1));break}let c=u;for(let v=0;v<o.length;v++)this.renderWord(t,o[v],c,r),c+=o[v].width,v<o.length-1&&(c+=d)}static renderStyledParagraph(t,n,i,r,a,l){const o=l??g.options.content?.textAlignment??"left",h=this.flattenToWords(t,n);if(h.length===0)return;const s=this.breakIntoLines(t,h,a),f=w(t)*g.options.page.defaultLineHeightFactor;let u=r;for(const p of s)u+f>g.options.page.maxContentHeight&&(T(t),u=g.Y),this.renderAlignedLine(t,p,i,u,a,o),g.recordContentY(u+w(t)),u+=f,g.updateY(f,"add");const d=s[s.length-1];if(d){const p=d.totalTextWidth+(d.words.length-1)*t.getTextWidth(" ");g.updateX(i+p,"set")}}static renderJustifiedParagraph(t,n,i,r,a){this.renderStyledParagraph(t,n,i,r,a)}}class Y{static renderText(t,n,i=g.X,r=g.Y,a,l=!1){const o=t.splitTextToSize(n,a),h=w(t),s=h*g.options.page.defaultLineHeightFactor;let f=r;for(let u=0;u<o.length;u++){const d=o[u];f+s>g.options.page.maxContentHeight&&(T(t),f=g.Y),l?u===o.length-1?t.text(d,i,f,{baseline:"top"}):t.text(d,i,f,{maxWidth:a,align:"justify",baseline:"top"}):t.text(d,i,f,{baseline:"top"}),g.recordContentY(f+h),f+=s,g.updateY(s,"add")}return f}}const Wt=(e,t,n,i)=>{g.activateInlineLock(),e.setFontSize(g.options.page.defaultFontSize);const r=g.options.page.maxContentWidth-n;if(t?.items&&t?.items.length>0)if(t.items.some(l=>!["strong","em","text","codespan","link"].includes(l.type))){const l=[],o=()=>{l.length>0&&(q.renderStyledParagraph(e,l,g.X+n,g.Y,r),l.length=0)};for(const h of t.items)["strong","em","text","codespan","link"].includes(h.type)?l.push(h):(o(),i(h,n,!1));o()}else q.renderStyledParagraph(e,t.items,g.X+n,g.Y,r);else{const a=t.content??"",l=g.options.content?.textAlignment??"left";a.trim()&&Y.renderText(e,a,g.X+n,g.Y,r,l==="justify")}g.updateX(g.options.page.xpading),g.deactivateInlineLock()},Ht=(e,t,n,i)=>{e.setFontSize(g.options.page.defaultFontSize);for(const[r,a]of t?.items?.entries()??[]){const l=t.ordered?(t.start??0)+r:t.start;i(a,n+1,!0,l,t.ordered)}},Pt=(e,t,n,i,r,a)=>{g.Y+w(e)>=g.options.page.maxContentHeight&&T(e);const l=g.options,o=n*l.page.indent,h=a?`${r}. `:"• ",s=l.page.xpading;g.updateX(s,"set"),e.setFont(l.font.regular.name,l.font.regular.style),e.text(h,s+o,g.Y,{baseline:"top"});const f=e.getTextWidth(h),u=s+o+f,d=l.page.maxContentWidth-o-f;if(t.items&&t.items.length>0){const p=[],c=()=>{p.length>0&&(q.renderStyledParagraph(e,p,u,g.Y,d),p.length=0,g.updateX(s,"set"))};for(const v of t.items)v.type===y.List?(c(),i(v,n+1,!0,r,v.ordered??!1)):v.type===y.ListItem?(c(),i(v,n+1,!0,r,a)):p.push(v);c()}else if(t.content){const p=l.content?.textAlignment??"left";Y.renderText(e,t.content,u,g.Y,d,p==="justify")}},kt=(e,t,n,i,r,a,l,o=!0)=>{if(t?.items&&t?.items.length>0)for(const h of t?.items??[])r(h,n,i,a,l,o);else{const h=g.options,s=n*h.page.indent,f=i?l?`${a}. `:"• ":"",u=t.content||"",d=h.page.xpading;if(!u&&!f)return;if(!u.trim()&&!f){const p=(u.match(/\n/g)||[]).length;if(p>1){const c=p-1,v=e.getTextDimensions("A").h*h.page.defaultLineHeightFactor,m=c*v;g.Y+m>h.page.maxContentHeight?T(e):(g.updateY(m,"add"),g.recordContentY(g.Y))}return}if(g.updateX(d,"set"),i&&f){const p=e.getTextWidth(f),c=h.page.maxContentWidth-s-p;e.setFont(h.font.regular.name,h.font.regular.style),e.text(f,d+s,g.Y,{baseline:"top"}),Y.renderText(e,u,d+s+p,g.Y,c,o)}else{const p=h.page.maxContentWidth-s;Y.renderText(e,u,d+s,g.Y,p,o)}g.updateX(d,"set")}},Dt=e=>{const t=e.internal.pageSize.getWidth();e.setLineDashPattern([1,1],0),e.setLineWidth(.1),e.line(g.options.page.xpading,g.Y,t-g.options.page.xpading,g.Y),e.setLineWidth(.1),e.setLineDashPattern([],0),g.updateY(w(e),"add")},Tt=(e,t,n,i)=>{const r=e.getFont(),a=e.getFontSize();e.setFont("courier","normal");const l=g.options.page.defaultFontSize*.9;e.setFontSize(l);const o=n*g.options.page.indent,h=g.options.page.maxContentWidth-o-8,s=e.getLineHeightFactor(),f=l/e.internal.scaleFactor*s,d=(t.code??"").replace(/[\r\n\s]+$/,"");if(!d){e.setFont(r.fontName,r.fontStyle),e.setFontSize(a);return}const p=e.splitTextToSize(d,h);for(;p.length>0&&p[p.length-1].trim()==="";)p.pop();if(p.length===0){e.setFont(r.fontName,r.fontStyle),e.setFontSize(a);return}const c=4,v="#EEEEEE",m="#DDDDDD";let x=0;for(;x<p.length;){const C=g.options.page.maxContentHeight-g.Y,S=p.length-x,b=C-c*2;let W=Math.floor(b/f);if(W<=0){T(e);continue}W>S&&(W=S);const wt=p.slice(x,x+W),B=x===0,j=x+W>=p.length,K=W*f;if(B&&g.updateY(c,"add"),e.setFillColor(v),e.setDrawColor(m),e.roundedRect(g.X,g.Y-c,g.options.page.maxContentWidth,K+(B?c:0)+(j?c:0),2,2,"FD"),B&&t.lang){const X=e.getFontSize();e.setFontSize(10),e.setTextColor("#666666"),e.text(t.lang,g.X+g.options.page.maxContentWidth-e.getTextWidth(t.lang)-4,g.Y,{baseline:"top"}),e.setFontSize(X),e.setTextColor("#000000")}let G=g.Y;for(const X of wt)e.text(X,g.X+4,G,{baseline:"top"}),G+=f;g.updateY(K,"add"),g.recordContentY(g.Y+(j?c:0)),j&&g.updateY(c,"add"),x+=W,x<p.length&&T(e)}e.setFont(r.fontName,r.fontStyle),e.setFontSize(a)},zt=(e,t,n)=>{const i=e.getFont().fontName,r=e.getFont().fontStyle,a=e.getFontSize(),l=h=>{switch(h){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;case"codespan":return .5;default:return 0}},o=(h,s)=>{s==="bold"?e.setFont(g.options.font.bold.name&&g.options.font.bold.name!==""?g.options.font.bold.name:i,g.options.font.bold.style||"bold"):s==="italic"?e.setFont(g.options.font.regular.name,"italic"):s==="bolditalic"?e.setFont(g.options.font.bold.name&&g.options.font.bold.name!==""?g.options.font.bold.name:i,"bolditalic"):s==="codespan"?(e.setFont("courier","normal"),e.setFontSize(a*.9)):e.setFont(g.options.font.regular.name,r);const f=g.options.page.maxContentWidth-n-g.X,u=e.splitTextToSize(h,f),d=s==="codespan",p=1,c="#EEEEEE";if(g.isInlineLockActive)for(let v=0;v<u.length;v++){if(d){const m=e.getTextWidth(u[v])+k(e),x=w(e);e.setFillColor(c),e.roundedRect(g.X+n-p,g.Y-p,m+p*2,x+p*2,2,2,"F"),e.setFillColor("#000000")}e.text(u[v],g.X+n,g.Y,{baseline:"top",maxWidth:f}),g.updateX(e.getTextDimensions(u[v]).w+(d?p*2:1),"add"),v<u.length-1&&(g.updateY(w(e),"add"),g.updateX(g.options.page.xpading,"set"))}else if(u.length>1){const v=u[0],m=u?.slice(1)?.join(" ");if(d){const S=e.getTextWidth(v)+k(e),b=w(e);e.setFillColor(c),e.roundedRect(g.X+(n>=2?n+2:0)-p,g.Y-p,S+p*2,b+p*2,2,2,"F"),e.setFillColor("#000000")}e.text(v,g.X+(n>=2?n+2*l(s):0),g.Y,{baseline:"top",maxWidth:f}),g.updateX(g.options.page.xpading+n),g.updateY(w(e),"add");const x=g.options.page.maxContentWidth-n-g.options.page.xpading;e.splitTextToSize(m,x).forEach(S=>{if(d){const b=e.getTextWidth(S)+k(e),W=w(e);e.setFillColor(c),e.roundedRect(g.X+k(e)-p,g.Y-p,b+p*2,W+p*2,2,2,"F"),e.setFillColor("#000000")}e.text(S,g.X+k(e),g.Y,{baseline:"top",maxWidth:x})})}else{if(d){const v=e.getTextWidth(h)+k(e),m=w(e);e.setFillColor(c),e.roundedRect(g.X+n-p,g.Y-p,v+p*2,m+p*2,2,2,"F"),e.setFillColor("#000000")}e.text(h,g.X+n,g.Y,{baseline:"top",maxWidth:f}),g.updateX(e.getTextDimensions(h).w+(n>=2?h.split(" ").length+2:2)*l(s)*.5+(d?p*2:0),"add")}};if(t.type==="text"&&t.items&&t.items.length>0)for(const h of t.items)if(h.type==="codespan")o(h.content||"","codespan");else if(h.type==="em"||h.type==="strong"){const s=h.type==="em"?"italic":"bold";if(h.items&&h.items.length>0)for(const f of h.items)f.type==="strong"&&s==="italic"||f.type==="em"&&s==="bold"?o(f.content||"","bolditalic"):o(f.content||"",s);else o(h.content||"",s)}else o(h.content||"","normal");else t.type==="em"?o(t.content||"","italic"):t.type==="strong"?o(t.content||"","bold"):t.type==="codespan"?o(t.content||"","codespan"):o(t.content||"","normal");e.setFont(i,r),e.setFontSize(a)},Lt=(e,t,n)=>{const i=e.getFont().fontName,r=e.getFont().fontStyle,a=e.getFontSize(),l=e.getTextColor(),o=g.options.link?.linkColor||[0,0,255];e.setTextColor(...o);const h=g.options.page.maxContentWidth-n-g.X,s=t.text||t.content||"",f=t.href||"",u=e.splitTextToSize(s,h);if(g.isInlineLockActive)for(let d=0;d<u.length;d++){const p=e.getTextDimensions(u[d]).w,c=w(e)/2;e.link(g.X+n,g.Y,p,c,{url:f}),e.text(u[d],g.X+n,g.Y,{baseline:"top",maxWidth:h}),g.updateX(p+1,"add"),g.X+p>g.options.page.maxContentWidth-n&&(g.updateY(c,"add"),g.updateX(g.options.page.xpading+n,"set")),d<u.length-1&&(g.updateY(c,"add"),g.updateX(g.options.page.xpading+n,"set"))}else if(u.length>1){const d=u[0],p=u?.slice(1)?.join(" "),c=e.getTextDimensions(d).w,v=w(e)/2;e.link(g.X+n,g.Y,c,v,{url:f}),e.text(d,g.X+n,g.Y,{baseline:"top",maxWidth:h}),g.updateX(g.options.page.xpading+n),g.updateY(v,"add");const m=g.options.page.maxContentWidth-n-g.options.page.xpading;e.splitTextToSize(p,m).forEach(C=>{const S=e.getTextDimensions(C).w;e.link(g.X+k(e),g.Y,S,v,{url:f}),e.text(C,g.X+k(e),g.Y,{baseline:"top",maxWidth:m})})}else{const d=e.getTextDimensions(s).w,p=w(e)/2;e.link(g.X+n,g.Y,d,p,{url:f}),e.text(s,g.X+n,g.Y,{baseline:"top",maxWidth:h}),g.updateX(d+2,"add")}e.setFont(i,r),e.setFontSize(a),e.setTextColor(l)},Yt=(e,t,n,i)=>{const r=g.options,a=n+1,l=g.X+n*r.page.indent,o=g.Y,h=l+r.page.indent/2,s=o,f=e.internal.getCurrentPageInfo().pageNumber;t.items&&t.items.length>0&&t.items.forEach(p=>{i(p,a)});const u=g.Y,d=e.internal.getCurrentPageInfo().pageNumber;e.setDrawColor(100),e.setLineWidth(1);for(let p=f;p<=d;p++){e.setPage(p);const c=p===f,v=p===d,m=c?s:r.page.topmargin,x=v?u:r.page.maxContentHeight;e.line(h,m,h,x)}g.recordContentY(),e.setPage(d)},Rt=(e,t,n)=>{if(!t.data)return;const i=g.options,r=g.X+n*i.page.indent;let a=g.Y;const l=i.page.maxContentWidth-n*i.page.indent;try{const o=e.getImageProperties(t.data),h=o.width,s=o.height;let f=h,u=s;const d=h/s;f>0&&(f=l,u=f/d),a+u>i.page.maxContentHeight&&(e.addPage(),a=i.page.topmargin,g.updateY(a));let p=t.src?.split(".").pop()?.toUpperCase()||"JPEG";t.data.startsWith("data:image/png")?p="PNG":t.data.startsWith("data:image/jpeg")||t.data.startsWith("data:image/jpg")?p="JPEG":t.data.startsWith("data:image/webp")&&(p="WEBP"),e.addImage(t.data,p,r,a,f,u),g.updateY(u,"add"),g.recordContentY()}catch(o){console.warn("Failed to render image",o)}};function at(e,t,n,i,r){i=i||{};var a=1.15,l=r.internal.scaleFactor,o=r.internal.getFontSize()/l,h=r.getLineHeightFactor?r.getLineHeightFactor():a,s=o*h,f=/\r\n|\r|\n/g,u="",d=1;if((i.valign==="middle"||i.valign==="bottom"||i.halign==="center"||i.halign==="right")&&(u=typeof e=="string"?e.split(f):e,d=u.length||1),n+=o*(2-a),i.valign==="middle"?n-=d/2*s:i.valign==="bottom"&&(n-=d*s),i.halign==="center"||i.halign==="right"){var p=o;if(i.halign==="center"&&(p*=.5),u&&d>=1){for(var c=0;c<u.length;c++)r.text(u[c],t-r.getStringUnitWidth(u[c])*p,n),n+=s;return r}t-=r.getStringUnitWidth(e)*p}return i.halign==="justify"?r.text(e,t,n,{maxWidth:i.maxWidth||100,align:"justify"}):r.text(e,t,n),r}var U={},D=(function(){function e(t){this.jsPDFDocument=t,this.userStyles={textColor:t.getTextColor?this.jsPDFDocument.getTextColor():0,fontSize:t.internal.getFontSize(),fontStyle:t.internal.getFont().fontStyle,font:t.internal.getFont().fontName,lineWidth:t.getLineWidth?this.jsPDFDocument.getLineWidth():0,lineColor:t.getDrawColor?this.jsPDFDocument.getDrawColor():0}}return e.setDefaults=function(t,n){n===void 0&&(n=null),n?n.__autoTableDocumentDefaults=t:U=t},e.unifyColor=function(t){return Array.isArray(t)?t:typeof t=="number"?[t,t,t]:typeof t=="string"?[t]:null},e.prototype.applyStyles=function(t,n){var i,r,a;n===void 0&&(n=!1),t.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(t.fontStyle);var l=this.jsPDFDocument.internal.getFont(),o=l.fontStyle,h=l.fontName;if(t.font&&(h=t.font),t.fontStyle){o=t.fontStyle;var s=this.getFontList()[h];s&&s.indexOf(o)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(s[0]),o=s[0])}if(this.jsPDFDocument.setFont(h,o),t.fontSize&&this.jsPDFDocument.setFontSize(t.fontSize),!n){var f=e.unifyColor(t.fillColor);f&&(i=this.jsPDFDocument).setFillColor.apply(i,f),f=e.unifyColor(t.textColor),f&&(r=this.jsPDFDocument).setTextColor.apply(r,f),f=e.unifyColor(t.lineColor),f&&(a=this.jsPDFDocument).setDrawColor.apply(a,f),typeof t.lineWidth=="number"&&this.jsPDFDocument.setLineWidth(t.lineWidth)}},e.prototype.splitTextToSize=function(t,n,i){return this.jsPDFDocument.splitTextToSize(t,n,i)},e.prototype.rect=function(t,n,i,r,a){return this.jsPDFDocument.rect(t,n,i,r,a)},e.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},e.prototype.getTextWidth=function(t){return this.jsPDFDocument.getTextWidth(t)},e.prototype.getDocument=function(){return this.jsPDFDocument},e.prototype.setPage=function(t){this.jsPDFDocument.setPage(t)},e.prototype.addPage=function(){return this.jsPDFDocument.addPage()},e.prototype.getFontList=function(){return this.jsPDFDocument.getFontList()},e.prototype.getGlobalOptions=function(){return U||{}},e.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},e.prototype.pageSize=function(){var t=this.jsPDFDocument.internal.pageSize;return t.width==null&&(t={width:t.getWidth(),height:t.getHeight()}),t},e.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},e.prototype.getLineHeightFactor=function(){var t=this.jsPDFDocument;return t.getLineHeightFactor?t.getLineHeightFactor():1.15},e.prototype.getLineHeight=function(t){return t/this.scaleFactor()*this.getLineHeightFactor()},e.prototype.pageNumber=function(){var t=this.jsPDFDocument.internal.getCurrentPageInfo();return t?t.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},e})(),_=function(e,t){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])},_(e,t)};function ot(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var st=(function(e){ot(t,e);function t(n){var i=e.call(this)||this;return i._element=n,i}return t})(Array);function Et(e){return{font:"helvetica",fontStyle:"normal",overflow:"linebreak",fillColor:!1,textColor:20,halign:"left",valign:"top",fontSize:10,cellPadding:5/e,lineColor:200,lineWidth:0,cellWidth:"auto",minCellHeight:0,minCellWidth:0}}function At(e){var t={striped:{table:{fillColor:255,textColor:80,fontStyle:"normal"},head:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},body:{},foot:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:"normal",lineWidth:.1},head:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},body:{},foot:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},alternateRow:{}},plain:{head:{fontStyle:"bold"},foot:{fontStyle:"bold"}}};return t[e]}function R(e,t,n){n.applyStyles(t,!0);var i=Array.isArray(e)?e:[e],r=i.map(function(a){return n.getTextWidth(a)}).reduce(function(a,l){return Math.max(a,l)},0);return r}function lt(e,t,n,i){var r=t.settings.tableLineWidth,a=t.settings.tableLineColor;e.applyStyles({lineWidth:r,lineColor:a});var l=ht(r,!1);l&&e.rect(n.x,n.y,t.getWidth(e.pageSize().width),i.y-n.y,l)}function ht(e,t){var n=e>0,i=t||t===0;return n&&i?"DF":n?"S":i?"F":null}function A(e,t){var n,i,r,a;if(e=e||t,Array.isArray(e)){if(e.length>=4)return{top:e[0],right:e[1],bottom:e[2],left:e[3]};if(e.length===3)return{top:e[0],right:e[1],bottom:e[2],left:e[1]};if(e.length===2)return{top:e[0],right:e[1],bottom:e[0],left:e[1]};e.length===1?e=e[0]:e=t}return typeof e=="object"?(typeof e.vertical=="number"&&(e.top=e.vertical,e.bottom=e.vertical),typeof e.horizontal=="number"&&(e.right=e.horizontal,e.left=e.horizontal),{left:(n=e.left)!==null&&n!==void 0?n:t,top:(i=e.top)!==null&&i!==void 0?i:t,right:(r=e.right)!==null&&r!==void 0?r:t,bottom:(a=e.bottom)!==null&&a!==void 0?a:t}):(typeof e!="number"&&(e=t),{top:e,right:e,bottom:e,left:e})}function ft(e,t){var n=A(t.settings.margin,0);return e.pageSize().width-(n.left+n.right)}function Bt(e,t,n,i,r){var a={},l=1.3333333333333333,o=I(t,function(S){return r.getComputedStyle(S).backgroundColor});o!=null&&(a.fillColor=o);var h=I(t,function(S){return r.getComputedStyle(S).color});h!=null&&(a.textColor=h);var s=Xt(i,n);s&&(a.cellPadding=s);var f="borderTopColor",u=l*n,d=i.borderTopWidth;if(i.borderBottomWidth===d&&i.borderRightWidth===d&&i.borderLeftWidth===d){var p=(parseFloat(d)||0)/u;p&&(a.lineWidth=p)}else a.lineWidth={top:(parseFloat(i.borderTopWidth)||0)/u,right:(parseFloat(i.borderRightWidth)||0)/u,bottom:(parseFloat(i.borderBottomWidth)||0)/u,left:(parseFloat(i.borderLeftWidth)||0)/u},a.lineWidth.top||(a.lineWidth.right?f="borderRightColor":a.lineWidth.bottom?f="borderBottomColor":a.lineWidth.left&&(f="borderLeftColor"));var c=I(t,function(S){return r.getComputedStyle(S)[f]});c!=null&&(a.lineColor=c);var v=["left","right","center","justify"];v.indexOf(i.textAlign)!==-1&&(a.halign=i.textAlign),v=["middle","bottom","top"],v.indexOf(i.verticalAlign)!==-1&&(a.valign=i.verticalAlign);var m=parseInt(i.fontSize||"");isNaN(m)||(a.fontSize=m/l);var x=jt(i);x&&(a.fontStyle=x);var C=(i.fontFamily||"").toLowerCase();return e.indexOf(C)!==-1&&(a.font=C),a}function jt(e){var t="";return(e.fontWeight==="bold"||e.fontWeight==="bolder"||parseInt(e.fontWeight)>=700)&&(t="bold"),(e.fontStyle==="italic"||e.fontStyle==="oblique")&&(t+="italic"),t}function I(e,t){var n=gt(e,t);if(!n)return null;var i=n.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!i||!Array.isArray(i))return null;var r=[parseInt(i[1]),parseInt(i[2]),parseInt(i[3])],a=parseInt(i[4]);return a===0||isNaN(r[0])||isNaN(r[1])||isNaN(r[2])?null:r}function gt(e,t){var n=t(e);return n==="rgba(0, 0, 0, 0)"||n==="transparent"||n==="initial"||n==="inherit"?e.parentElement==null?null:gt(e.parentElement,t):n}function Xt(e,t){var n=[e.paddingTop,e.paddingRight,e.paddingBottom,e.paddingLeft],i=96/(72/t),r=(parseInt(e.lineHeight)-parseInt(e.fontSize))/t/2,a=n.map(function(o){return parseInt(o||"0")/i}),l=A(a,0);return r>l.top&&(l.top=r),r>l.bottom&&(l.bottom=r),l}function pt(e,t,n,i,r){var a,l;i===void 0&&(i=!1),r===void 0&&(r=!1);var o;typeof t=="string"?o=n.document.querySelector(t):o=t;var h=Object.keys(e.getFontList()),s=e.scaleFactor(),f=[],u=[],d=[];if(!o)return console.error("Html table could not be found with input: ",t),{head:f,body:u,foot:d};for(var p=0;p<o.rows.length;p++){var c=o.rows[p],v=(l=(a=c?.parentElement)===null||a===void 0?void 0:a.tagName)===null||l===void 0?void 0:l.toLowerCase(),m=It(h,s,n,c,i,r);m&&(v==="thead"?f.push(m):v==="tfoot"?d.push(m):u.push(m))}return{head:f,body:u,foot:d}}function It(e,t,n,i,r,a){for(var l=new st(i),o=0;o<i.cells.length;o++){var h=i.cells[o],s=n.getComputedStyle(h);if(r||s.display!=="none"){var f=void 0;a&&(f=Bt(e,h,t,s,n)),l.push({rowSpan:h.rowSpan,colSpan:h.colSpan,styles:f,_element:h,content:Nt(h)})}}var u=n.getComputedStyle(i);if(l.length>0&&(r||u.display!=="none"))return l}function Nt(e){var t=e.cloneNode(!0);return t.innerHTML=t.innerHTML.replace(/\n/g,"").replace(/ +/g," "),t.innerHTML=t.innerHTML.split(/<br.*?>/).map(function(n){return n.trim()}).join(`
2
+ `),t.innerText||t.textContent||""}function Ot(e,t,n){for(var i=0,r=[e,t,n];i<r.length;i++){var a=r[i];a&&typeof a!="object"&&console.error("The options parameter should be of type object, is: "+typeof a),a.startY&&typeof a.startY!="number"&&(console.error("Invalid value for startY option",a.startY),delete a.startY)}}function H(e,t,n,i,r){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var a=Object(e),l=1;l<arguments.length;l++){var o=arguments[l];if(o!=null)for(var h in o)Object.prototype.hasOwnProperty.call(o,h)&&(a[h]=o[h])}return a}function ut(e,t){var n=new D(e),i=n.getDocumentOptions(),r=n.getGlobalOptions();Ot(r,i,t);var a=H({},r,i,t),l;typeof window<"u"&&(l=window);var o=Mt(r,i,t),h=qt(r,i,t),s=_t(n,a),f=Jt(n,a,l);return{id:t.tableId,content:f,hooks:h,styles:o,settings:s}}function Mt(e,t,n){for(var i={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},r=function(h){if(h==="columnStyles"){var s=e[h],f=t[h],u=n[h];i.columnStyles=H({},s,f,u)}else{var d=[e,t,n],p=d.map(function(c){return c[h]||{}});i[h]=H({},p[0],p[1],p[2])}},a=0,l=Object.keys(i);a<l.length;a++){var o=l[a];r(o)}return i}function qt(e,t,n){for(var i=[e,t,n],r={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},a=0,l=i;a<l.length;a++){var o=l[a];o.didParseCell&&r.didParseCell.push(o.didParseCell),o.willDrawCell&&r.willDrawCell.push(o.willDrawCell),o.didDrawCell&&r.didDrawCell.push(o.didDrawCell),o.willDrawPage&&r.willDrawPage.push(o.willDrawPage),o.didDrawPage&&r.didDrawPage.push(o.didDrawPage)}return r}function _t(e,t){var n,i,r,a,l,o,h,s,f,u,d,p,c=A(t.margin,40/e.scaleFactor()),v=(n=$t(e,t.startY))!==null&&n!==void 0?n:c.top,m;t.showFoot===!0?m="everyPage":t.showFoot===!1?m="never":m=(i=t.showFoot)!==null&&i!==void 0?i:"everyPage";var x;t.showHead===!0?x="everyPage":t.showHead===!1?x="never":x=(r=t.showHead)!==null&&r!==void 0?r:"everyPage";var C=(a=t.useCss)!==null&&a!==void 0?a:!1,S=t.theme||(C?"plain":"striped"),b=!!t.horizontalPageBreak,W=(l=t.horizontalPageBreakRepeat)!==null&&l!==void 0?l:null;return{includeHiddenHtml:(o=t.includeHiddenHtml)!==null&&o!==void 0?o:!1,useCss:C,theme:S,startY:v,margin:c,pageBreak:(h=t.pageBreak)!==null&&h!==void 0?h:"auto",rowPageBreak:(s=t.rowPageBreak)!==null&&s!==void 0?s:"auto",tableWidth:(f=t.tableWidth)!==null&&f!==void 0?f:"auto",showHead:x,showFoot:m,tableLineWidth:(u=t.tableLineWidth)!==null&&u!==void 0?u:0,tableLineColor:(d=t.tableLineColor)!==null&&d!==void 0?d:200,horizontalPageBreak:b,horizontalPageBreakRepeat:W,horizontalPageBreakBehaviour:(p=t.horizontalPageBreakBehaviour)!==null&&p!==void 0?p:"afterAllRows"}}function $t(e,t){var n=e.getLastAutoTable(),i=e.scaleFactor(),r=e.pageNumber(),a=!1;if(n&&n.startPageNumber){var l=n.startPageNumber+n.pageNumber-1;a=l===r}return typeof t=="number"?t:(t==null||t===!1)&&a&&n?.finalY!=null?n.finalY+20/i:null}function Jt(e,t,n){var i=t.head||[],r=t.body||[],a=t.foot||[];if(t.html){var l=t.includeHiddenHtml;if(n){var o=pt(e,t.html,n,l,t.useCss)||{};i=o.head||i,r=o.body||i,a=o.foot||i}else console.error("Cannot parse html in non browser environment")}var h=t.columns||Kt(i,r,a);return{columns:h,head:i,body:r,foot:a}}function Kt(e,t,n){var i=e[0]||t[0]||n[0]||[],r=[];return Object.keys(i).filter(function(a){return a!=="_element"}).forEach(function(a){var l=1,o;Array.isArray(i)?o=i[parseInt(a)]:o=i[a],typeof o=="object"&&!Array.isArray(o)&&(l=o?.colSpan||1);for(var h=0;h<l;h++){var s=void 0;Array.isArray(i)?s=r.length:s=a+(h>0?"_".concat(h):"");var f={dataKey:s};r.push(f)}}),r}var $=(function(){function e(t,n,i){this.table=n,this.pageNumber=n.pageNumber,this.settings=n.settings,this.cursor=i,this.doc=t.getDocument()}return e})(),Gt=(function(e){ot(t,e);function t(n,i,r,a,l,o){var h=e.call(this,n,i,o)||this;return h.cell=r,h.row=a,h.column=l,h.section=a.section,h}return t})($),Ut=(function(){function e(t,n){this.pageNumber=1,this.id=t.id,this.settings=t.settings,this.styles=t.styles,this.hooks=t.hooks,this.columns=n.columns,this.head=n.head,this.body=n.body,this.foot=n.foot}return e.prototype.getHeadHeight=function(t){return this.head.reduce(function(n,i){return n+i.getMaxCellHeight(t)},0)},e.prototype.getFootHeight=function(t){return this.foot.reduce(function(n,i){return n+i.getMaxCellHeight(t)},0)},e.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},e.prototype.callCellHooks=function(t,n,i,r,a,l){for(var o=0,h=n;o<h.length;o++){var s=h[o],f=new Gt(t,this,i,r,a,l),u=s(f)===!1;if(i.text=Array.isArray(i.text)?i.text:[i.text],u)return!1}return!0},e.prototype.callEndPageHooks=function(t,n){t.applyStyles(t.userStyles);for(var i=0,r=this.hooks.didDrawPage;i<r.length;i++){var a=r[i];a(new $(t,this,n))}},e.prototype.callWillDrawPageHooks=function(t,n){for(var i=0,r=this.hooks.willDrawPage;i<r.length;i++){var a=r[i];a(new $(t,this,n))}},e.prototype.getWidth=function(t){if(typeof this.settings.tableWidth=="number")return this.settings.tableWidth;if(this.settings.tableWidth==="wrap"){var n=this.columns.reduce(function(r,a){return r+a.wrappedWidth},0);return n}else{var i=this.settings.margin;return t-i.left-i.right}},e})(),dt=(function(){function e(t,n,i,r,a){a===void 0&&(a=!1),this.height=0,this.raw=t,t instanceof st&&(this.raw=t._element,this.element=t._element),this.index=n,this.section=i,this.cells=r,this.spansMultiplePages=a}return e.prototype.getMaxCellHeight=function(t){var n=this;return t.reduce(function(i,r){var a;return Math.max(i,((a=n.cells[r.index])===null||a===void 0?void 0:a.height)||0)},0)},e.prototype.hasRowSpan=function(t){var n=this;return t.filter(function(i){var r=n.cells[i.index];return r?r.rowSpan>1:!1}).length>0},e.prototype.canEntireRowFit=function(t,n){return this.getMaxCellHeight(n)<=t},e.prototype.getMinimumRowHeight=function(t,n){var i=this;return t.reduce(function(r,a){var l=i.cells[a.index];if(!l)return 0;var o=n.getLineHeight(l.styles.fontSize),h=l.padding("vertical"),s=h+o;return s>r?s:r},0)},e})(),ct=(function(){function e(t,n,i){var r;this.contentHeight=0,this.contentWidth=0,this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.height=0,this.x=0,this.y=0,this.styles=n,this.section=i,this.raw=t;var a=t;t!=null&&typeof t=="object"&&!Array.isArray(t)?(this.rowSpan=t.rowSpan||1,this.colSpan=t.colSpan||1,a=(r=t.content)!==null&&r!==void 0?r:t,t._element&&(this.raw=t._element)):(this.rowSpan=1,this.colSpan=1);var l=a!=null?""+a:"",o=/\r\n|\r|\n/g;this.text=l.split(o)}return e.prototype.getTextPos=function(){var t;if(this.styles.valign==="top")t=this.y+this.padding("top");else if(this.styles.valign==="bottom")t=this.y+this.height-this.padding("bottom");else{var n=this.height-this.padding("vertical");t=this.y+n/2+this.padding("top")}var i;if(this.styles.halign==="right")i=this.x+this.width-this.padding("right");else if(this.styles.halign==="center"){var r=this.width-this.padding("horizontal");i=this.x+r/2+this.padding("left")}else i=this.x+this.padding("left");return{x:i,y:t}},e.prototype.getContentHeight=function(t,n){n===void 0&&(n=1.15);var i=Array.isArray(this.text)?this.text.length:1,r=this.styles.fontSize/t*n,a=i*r+this.padding("vertical");return Math.max(a,this.styles.minCellHeight)},e.prototype.padding=function(t){var n=A(this.styles.cellPadding,0);return t==="vertical"?n.top+n.bottom:t==="horizontal"?n.left+n.right:n[t]},e})(),Qt=(function(){function e(t,n,i){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=t,this.raw=n,this.index=i}return e.prototype.getMaxCustomCellWidth=function(t){for(var n=0,i=0,r=t.allRows();i<r.length;i++){var a=r[i],l=a.cells[this.index];l&&typeof l.styles.cellWidth=="number"&&(n=Math.max(n,l.styles.cellWidth))}return n},e})();function Zt(e,t){Vt(e,t);var n=[],i=0;t.columns.forEach(function(a){var l=a.getMaxCustomCellWidth(t);l?a.width=l:(a.width=a.wrappedWidth,n.push(a)),i+=a.width});var r=t.getWidth(e.pageSize().width)-i;r&&(r=J(n,r,function(a){return Math.max(a.minReadableWidth,a.minWidth)})),r&&(r=J(n,r,function(a){return a.minWidth})),r=Math.abs(r),!t.settings.horizontalPageBreak&&r>.1/e.scaleFactor()&&(r=r<1?r:Math.round(r),console.log("Of the table content, ".concat(r," units width could not fit page"))),ee(t),ne(t,e),te(t)}function Vt(e,t){var n=e.scaleFactor(),i=t.settings.horizontalPageBreak,r=ft(e,t);t.allRows().forEach(function(a){for(var l=0,o=t.columns;l<o.length;l++){var h=o[l],s=a.cells[h.index];if(s){var f=t.hooks.didParseCell;t.callCellHooks(e,f,s,a,h,null);var u=s.padding("horizontal");s.contentWidth=R(s.text,s.styles,e)+u;var d=R(s.text.join(" ").split(/[^\S\u00A0]+/),s.styles,e);if(s.minReadableWidth=d+s.padding("horizontal"),typeof s.styles.cellWidth=="number")s.minWidth=s.styles.cellWidth,s.wrappedWidth=s.styles.cellWidth;else if(s.styles.cellWidth==="wrap"||i===!0)s.contentWidth>r?(s.minWidth=r,s.wrappedWidth=r):(s.minWidth=s.contentWidth,s.wrappedWidth=s.contentWidth);else{var p=10/n;s.minWidth=s.styles.minCellWidth||p,s.wrappedWidth=s.contentWidth,s.minWidth>s.wrappedWidth&&(s.wrappedWidth=s.minWidth)}}}}),t.allRows().forEach(function(a){for(var l=0,o=t.columns;l<o.length;l++){var h=o[l],s=a.cells[h.index];if(s&&s.colSpan===1)h.wrappedWidth=Math.max(h.wrappedWidth,s.wrappedWidth),h.minWidth=Math.max(h.minWidth,s.minWidth),h.minReadableWidth=Math.max(h.minReadableWidth,s.minReadableWidth);else{var f=t.styles.columnStyles[h.dataKey]||t.styles.columnStyles[h.index]||{},u=f.cellWidth||f.minCellWidth;u&&typeof u=="number"&&(h.minWidth=u,h.wrappedWidth=u)}s&&(s.colSpan>1&&!h.minWidth&&(h.minWidth=s.minWidth),s.colSpan>1&&!h.wrappedWidth&&(h.wrappedWidth=s.minWidth))}})}function J(e,t,n){for(var i=t,r=e.reduce(function(p,c){return p+c.wrappedWidth},0),a=0;a<e.length;a++){var l=e[a],o=l.wrappedWidth/r,h=i*o,s=l.width+h,f=n(l),u=s<f?f:s;t-=u-l.width,l.width=u}if(t=Math.round(t*1e10)/1e10,t){var d=e.filter(function(p){return t<0?p.width>n(p):!0});d.length&&(t=J(d,t,n))}return t}function te(e){for(var t={},n=1,i=e.allRows(),r=0;r<i.length;r++)for(var a=i[r],l=0,o=e.columns;l<o.length;l++){var h=o[l],s=t[h.index];if(n>1)n--,delete a.cells[h.index];else if(s)s.cell.height+=a.height,n=s.cell.colSpan,delete a.cells[h.index],s.left--,s.left<=1&&delete t[h.index];else{var f=a.cells[h.index];if(!f)continue;if(f.height=a.height,f.rowSpan>1){var u=i.length-r,d=f.rowSpan>u?u:f.rowSpan;t[h.index]={cell:f,left:d,row:a}}}}}function ee(e){for(var t=e.allRows(),n=0;n<t.length;n++)for(var i=t[n],r=null,a=0,l=0,o=0;o<e.columns.length;o++){var h=e.columns[o];if(l-=1,l>1&&e.columns[o+1])a+=h.width,delete i.cells[h.index];else if(r){var s=r;delete i.cells[h.index],r=null,s.width=h.width+a}else{var s=i.cells[h.index];if(!s)continue;if(l=s.colSpan,a=0,s.colSpan>1){r=s,a+=h.width;continue}s.width=h.width+a}}}function ne(e,t){for(var n={count:0,height:0},i=0,r=e.allRows();i<r.length;i++){for(var a=r[i],l=0,o=e.columns;l<o.length;l++){var h=o[l],s=a.cells[h.index];if(s){t.applyStyles(s.styles,!0);var f=s.width-s.padding("horizontal");if(s.styles.overflow==="linebreak")s.text=t.splitTextToSize(s.text,f+1/t.scaleFactor(),{fontSize:s.styles.fontSize});else if(s.styles.overflow==="ellipsize")s.text=Q(s.text,f,s.styles,t,"...");else if(s.styles.overflow==="hidden")s.text=Q(s.text,f,s.styles,t,"");else if(typeof s.styles.overflow=="function"){var u=s.styles.overflow(s.text,f);typeof u=="string"?s.text=[u]:s.text=u}s.contentHeight=s.getContentHeight(t.scaleFactor(),t.getLineHeightFactor());var d=s.contentHeight/s.rowSpan;s.rowSpan>1&&n.count*n.height<d*s.rowSpan?n={height:d,count:s.rowSpan}:n&&n.count>0&&n.height>d&&(d=n.height),d>a.height&&(a.height=d)}}n.count--}}function Q(e,t,n,i,r){return e.map(function(a){return ie(a,t,n,i,r)})}function ie(e,t,n,i,r){var a=1e4*i.scaleFactor();if(t=Math.ceil(t*a)/a,t>=R(e,n,i))return e;for(;t<R(e+r,n,i)&&!(e.length<=1);)e=e.substring(0,e.length-1);return e.trim()+r}function vt(e,t){var n=new D(e),i=re(t,n.scaleFactor()),r=new Ut(t,i);return Zt(n,r),n.applyStyles(n.userStyles),r}function re(e,t){var n=e.content,i=oe(n.columns);if(n.head.length===0){var r=Z(i,"head");r&&n.head.push(r)}if(n.foot.length===0){var r=Z(i,"foot");r&&n.foot.push(r)}var a=e.settings.theme,l=e.styles;return{columns:i,head:N("head",n.head,i,l,a,t),body:N("body",n.body,i,l,a,t),foot:N("foot",n.foot,i,l,a,t)}}function N(e,t,n,i,r,a){var l={},o=t.map(function(h,s){for(var f=0,u={},d=0,p=0,c=0,v=n;c<v.length;c++){var m=v[c];if(l[m.index]==null||l[m.index].left===0)if(p===0){var x=void 0;Array.isArray(h)?x=h[m.index-d-f]:x=h[m.dataKey];var C={};typeof x=="object"&&!Array.isArray(x)&&(C=x?.styles||{});var S=se(e,m,s,r,i,a,C),b=new ct(x,S,e);u[m.dataKey]=b,u[m.index]=b,p=b.colSpan-1,l[m.index]={left:b.rowSpan-1,times:p}}else p--,d++;else l[m.index].left--,p=l[m.index].times,f++}return new dt(h,s,e,u)});return o}function Z(e,t){var n={};return e.forEach(function(i){if(i.raw!=null){var r=ae(t,i.raw);r!=null&&(n[i.dataKey]=r)}}),Object.keys(n).length>0?n:null}function ae(e,t){if(e==="head"){if(typeof t=="object")return t.header||null;if(typeof t=="string"||typeof t=="number")return t}else if(e==="foot"&&typeof t=="object")return t.footer;return null}function oe(e){return e.map(function(t,n){var i,r;return typeof t=="object"?r=(i=t.dataKey)!==null&&i!==void 0?i:n:r=n,new Qt(r,t,n)})}function se(e,t,n,i,r,a,l){var o=At(i),h;e==="head"?h=r.headStyles:e==="body"?h=r.bodyStyles:e==="foot"&&(h=r.footStyles);var s=H({},o.table,o[e],r.styles,h),f=r.columnStyles[t.dataKey]||r.columnStyles[t.index]||{},u=e==="body"?f:{},d=e==="body"&&n%2===0?H({},o.alternateRow,r.alternateRowStyles):{},p=Et(a),c=H({},p,s,d,u);return H(c,l)}function le(e,t,n){var i;n===void 0&&(n={});var r=ft(e,t),a=new Map,l=[],o=[],h=[];Array.isArray(t.settings.horizontalPageBreakRepeat)?h=t.settings.horizontalPageBreakRepeat:(typeof t.settings.horizontalPageBreakRepeat=="string"||typeof t.settings.horizontalPageBreakRepeat=="number")&&(h=[t.settings.horizontalPageBreakRepeat]),h.forEach(function(d){var p=t.columns.find(function(c){return c.dataKey===d||c.index===d});p&&!a.has(p.index)&&(a.set(p.index,!0),l.push(p.index),o.push(t.columns[p.index]),r-=p.wrappedWidth)});for(var s=!0,f=(i=n?.start)!==null&&i!==void 0?i:0;f<t.columns.length;){if(a.has(f)){f++;continue}var u=t.columns[f].wrappedWidth;if(s||r>=u)s=!1,l.push(f),o.push(t.columns[f]),r-=u;else break;f++}return{colIndexes:l,columns:o,lastIndex:f-1}}function he(e,t){for(var n=[],i=0;i<t.columns.length;i++){var r=le(e,t,{start:i});r.columns.length&&(n.push(r),i=r.lastIndex)}return n}function yt(e,t){var n=t.settings,i=n.startY,r=n.margin,a={x:r.left,y:i},l=t.getHeadHeight(t.columns)+t.getFootHeight(t.columns),o=i+r.bottom+l;if(n.pageBreak==="avoid"){var h=t.body,s=h.reduce(function(d,p){return d+p.height},0);o+=s}var f=new D(e);(n.pageBreak==="always"||n.startY!=null&&o>f.pageSize().height)&&(xt(f),a.y=r.top),t.callWillDrawPageHooks(f,a);var u=H({},a);t.startPageNumber=f.pageNumber(),n.horizontalPageBreak?fe(f,t,u,a):(f.applyStyles(f.userStyles),(n.showHead==="firstPage"||n.showHead==="everyPage")&&t.head.forEach(function(d){return P(f,t,d,a,t.columns)}),f.applyStyles(f.userStyles),t.body.forEach(function(d,p){var c=p===t.body.length-1;E(f,t,d,c,u,a,t.columns)}),f.applyStyles(f.userStyles),(n.showFoot==="lastPage"||n.showFoot==="everyPage")&&t.foot.forEach(function(d){return P(f,t,d,a,t.columns)})),lt(f,t,u,a),t.callEndPageHooks(f,a),t.finalY=a.y,e.lastAutoTable=t,f.applyStyles(f.userStyles)}function fe(e,t,n,i){var r=he(e,t),a=t.settings;if(a.horizontalPageBreakBehaviour==="afterAllRows")r.forEach(function(s,f){e.applyStyles(e.userStyles),f>0?z(e,t,n,i,s.columns,!0):V(e,t,i,s.columns),ge(e,t,n,i,s.columns),O(e,t,i,s.columns)});else for(var l=-1,o=r[0],h=function(){var s=l;if(o){e.applyStyles(e.userStyles);var f=o.columns;l>=0?z(e,t,n,i,f,!0):V(e,t,i,f),s=tt(e,t,l+1,i,f),O(e,t,i,f)}var u=s-l;r.slice(1).forEach(function(d){e.applyStyles(e.userStyles),z(e,t,n,i,d.columns,!0),tt(e,t,l+1,i,d.columns,u),O(e,t,i,d.columns)}),l=s};l<t.body.length-1;)h()}function V(e,t,n,i){var r=t.settings;e.applyStyles(e.userStyles),(r.showHead==="firstPage"||r.showHead==="everyPage")&&t.head.forEach(function(a){return P(e,t,a,n,i)})}function ge(e,t,n,i,r){e.applyStyles(e.userStyles),t.body.forEach(function(a,l){var o=l===t.body.length-1;E(e,t,a,o,n,i,r)})}function tt(e,t,n,i,r,a){e.applyStyles(e.userStyles),a=a??t.body.length;var l=Math.min(n+a,t.body.length),o=-1;return t.body.slice(n,l).forEach(function(h,s){var f=n+s===t.body.length-1,u=mt(e,t,f,i);h.canEntireRowFit(u,r)&&(P(e,t,h,i,r),o=n+s)}),o}function O(e,t,n,i){var r=t.settings;e.applyStyles(e.userStyles),(r.showFoot==="lastPage"||r.showFoot==="everyPage")&&t.foot.forEach(function(a){return P(e,t,a,n,i)})}function pe(e,t,n){var i=n.getLineHeight(e.styles.fontSize),r=e.padding("vertical"),a=Math.floor((t-r)/i);return Math.max(0,a)}function ue(e,t,n,i){var r={};e.spansMultiplePages=!0,e.height=0;for(var a=0,l=0,o=n.columns;l<o.length;l++){var h=o[l],s=e.cells[h.index];if(s){Array.isArray(s.text)||(s.text=[s.text]);var f=new ct(s.raw,s.styles,s.section);f=H(f,s),f.text=[];var u=pe(s,t,i);s.text.length>u&&(f.text=s.text.splice(u,s.text.length));var d=i.scaleFactor(),p=i.getLineHeightFactor();s.contentHeight=s.getContentHeight(d,p),s.contentHeight>=t&&(s.contentHeight=t,f.styles.minCellHeight-=t),s.contentHeight>e.height&&(e.height=s.contentHeight),f.contentHeight=f.getContentHeight(d,p),f.contentHeight>a&&(a=f.contentHeight),r[h.index]=f}}var c=new dt(e.raw,-1,e.section,r,!0);c.height=a;for(var v=0,m=n.columns;v<m.length;v++){var h=m[v],f=c.cells[h.index];f&&(f.height=c.height);var s=e.cells[h.index];s&&(s.height=e.height)}return c}function de(e,t,n,i){var r=e.pageSize().height,a=i.settings.margin,l=a.top+a.bottom,o=r-l;t.section==="body"&&(o-=i.getHeadHeight(i.columns)+i.getFootHeight(i.columns));var h=t.getMinimumRowHeight(i.columns,e),s=h<n;if(h>o)return console.log("Will not be able to print row ".concat(t.index," correctly since it's minimum height is larger than page height")),!0;if(!s)return!1;var f=t.hasRowSpan(i.columns),u=t.getMaxCellHeight(i.columns)>o;return u?(f&&console.log("The content of row ".concat(t.index," will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.")),!0):!(f||i.settings.rowPageBreak==="avoid")}function E(e,t,n,i,r,a,l){var o=mt(e,t,i,a);if(n.canEntireRowFit(o,l))P(e,t,n,a,l);else if(de(e,n,o,t)){var h=ue(n,o,t,e);P(e,t,n,a,l),z(e,t,r,a,l),E(e,t,h,i,r,a,l)}else z(e,t,r,a,l),E(e,t,n,i,r,a,l)}function P(e,t,n,i,r){i.x=t.settings.margin.left;for(var a=0,l=r;a<l.length;a++){var o=l[a],h=n.cells[o.index];if(!h){i.x+=o.width;continue}e.applyStyles(h.styles),h.x=i.x,h.y=i.y;var s=t.callCellHooks(e,t.hooks.willDrawCell,h,n,o,i);if(s===!1){i.x+=o.width;continue}ce(e,h,i);var f=h.getTextPos();at(h.text,f.x,f.y,{halign:h.styles.halign,valign:h.styles.valign,maxWidth:Math.ceil(h.width-h.padding("left")-h.padding("right"))},e.getDocument()),t.callCellHooks(e,t.hooks.didDrawCell,h,n,o,i),i.x+=o.width}i.y+=n.height}function ce(e,t,n){var i=t.styles;if(e.getDocument().setFillColor(e.getDocument().getFillColor()),typeof i.lineWidth=="number"){var r=ht(i.lineWidth,i.fillColor);r&&e.rect(t.x,n.y,t.width,t.height,r)}else typeof i.lineWidth=="object"&&(i.fillColor&&e.rect(t.x,n.y,t.width,t.height,"F"),ve(e,t,n,i.lineWidth))}function ve(e,t,n,i){var r,a,l,o;i.top&&(r=n.x,a=n.y,l=n.x+t.width,o=n.y,i.right&&(l+=.5*i.right),i.left&&(r-=.5*i.left),h(i.top,r,a,l,o)),i.bottom&&(r=n.x,a=n.y+t.height,l=n.x+t.width,o=n.y+t.height,i.right&&(l+=.5*i.right),i.left&&(r-=.5*i.left),h(i.bottom,r,a,l,o)),i.left&&(r=n.x,a=n.y,l=n.x,o=n.y+t.height,i.top&&(a-=.5*i.top),i.bottom&&(o+=.5*i.bottom),h(i.left,r,a,l,o)),i.right&&(r=n.x+t.width,a=n.y,l=n.x+t.width,o=n.y+t.height,i.top&&(a-=.5*i.top),i.bottom&&(o+=.5*i.bottom),h(i.right,r,a,l,o));function h(s,f,u,d,p){e.getDocument().setLineWidth(s),e.getDocument().line(f,u,d,p,"S")}}function mt(e,t,n,i){var r=t.settings.margin.bottom,a=t.settings.showFoot;return(a==="everyPage"||a==="lastPage"&&n)&&(r+=t.getFootHeight(t.columns)),e.pageSize().height-i.y-r}function z(e,t,n,i,r,a){r===void 0&&(r=[]),a===void 0&&(a=!1),e.applyStyles(e.userStyles),t.settings.showFoot==="everyPage"&&!a&&t.foot.forEach(function(o){return P(e,t,o,i,r)}),t.callEndPageHooks(e,i);var l=t.settings.margin;lt(e,t,n,i),xt(e),t.pageNumber++,i.x=l.left,i.y=l.top,n.y=l.top,t.callWillDrawPageHooks(e,i),t.settings.showHead==="everyPage"&&(t.head.forEach(function(o){return P(e,t,o,i,r)}),e.applyStyles(e.userStyles))}function xt(e){var t=e.pageNumber();e.setPage(t+1);var n=e.pageNumber();return n===t?(e.addPage(),!0):!1}function ye(e){e.API.autoTable=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=t[0],r=ut(this,i),a=vt(this,r);return yt(this,a),this},e.API.lastAutoTable=!1,e.API.autoTableText=function(t,n,i,r){at(t,n,i,r,this)},e.API.autoTableSetDefaults=function(t){return D.setDefaults(t,this),this},e.autoTableSetDefaults=function(t,n){D.setDefaults(t,n)},e.API.autoTableHtmlToJson=function(t,n){var i;if(n===void 0&&(n=!1),typeof window>"u")return console.error("Cannot run autoTableHtmlToJson in non browser environment"),null;var r=new D(this),a=pt(r,t,window,n,!1),l=a.head,o=a.body,h=((i=l[0])===null||i===void 0?void 0:i.map(function(s){return s.content}))||[];return{columns:h,rows:o,data:o}}}var M;function me(e,t){var n=ut(e,t),i=vt(e,n);yt(e,i)}try{if(typeof window<"u"&&window){var et=window,nt=et.jsPDF||((M=et.jspdf)===null||M===void 0?void 0:M.jsPDF);nt&&ye(nt)}}catch(e){console.error("Could not apply autoTable plugin",e)}const xe=(e,t,n)=>{if(!t.header||!t.rows)return;const i=g.options,r=i.page.xmargin+n*i.page.indent,a=[t.header.map(h=>h.content||"")],l=t.rows.map(h=>h.map(s=>s.content||"")),o=i.table||{};me(e,{head:a,body:l,startY:g.Y,margin:{left:r,right:i.page.xmargin},...o,didDrawPage:h=>{o.didDrawPage&&o.didDrawPage(h)},didDrawCell:h=>{o.didDrawCell&&o.didDrawCell(h),g.setCursor({x:g.X,y:h.cell.y+2*i.page.lineSpace})}})},St=async e=>{for(const t of e){if(t.type===y.Image&&t.src)try{if(t.src.startsWith("data:"))t.data=t.src;else{const n=await fetch(t.src);if(!n.ok)throw new Error(`Failed to fetch image: ${n.statusText}`);const i=await n.blob(),r=await new Promise((a,l)=>{const o=new FileReader;o.onloadend=()=>{typeof o.result=="string"?a(o.result):l(new Error("Failed to convert image to base64 string"))},o.onerror=l,o.readAsDataURL(i)});t.data=r}}catch(n){console.warn(`[jspdf-md-renderer] Warning: Failed to load image at ${t.src}. It will be skipped.`,n)}t.items&&t.items.length>0&&await St(t.items)}},it={page:{indent:10,maxContentWidth:190,maxContentHeight:277,lineSpace:1.5,defaultLineHeightFactor:1.2,defaultFontSize:12,defaultTitleFontSize:14,topmargin:10,xpading:10,xmargin:10,format:"a4",orientation:"p"},font:{bold:{name:"helvetica",style:"bold"},regular:{name:"helvetica",style:"normal"},light:{name:"helvetica",style:"light"}}},Se=e=>{if(!e)throw new Error("RenderOption is required");const t={...it.page,...e.page},n={...it.font,...e.font};return t.maxContentWidth||(t.maxContentWidth=190),t.maxContentHeight||(t.maxContentHeight=277),{...e,page:t,font:n}},we=async(e,t,n)=>{const i=Se(n);g.initialize(i);const r=await rt(t);await St(r);const a=(l,o=0,h=!1,s=0,f=!1,u=!0)=>{const d=o*i.page.indent;switch(l.type){case y.Heading:Ft(e,l,d,a);break;case y.Paragraph:Wt(e,l,d,a);break;case y.List:Ht(e,l,o,a);break;case y.ListItem:Pt(e,l,o,a,s,f);break;case y.Hr:Dt(e);break;case y.Code:Tt(e,l,o);break;case y.Strong:case y.Em:case y.CodeSpan:zt(e,l,d);break;case y.Link:Lt(e,l,d);break;case y.Blockquote:Yt(e,l,o,a);break;case y.Image:Rt(e,l,o);break;case y.Table:xe(e,l,o);break;case y.Raw:case y.Text:kt(e,l,o,h,a,s,f,i.page.defaultFontSize>0);break;default:console.warn(`Warning: Unsupported element type encountered: ${l.type}.
3
3
  If you believe this element type should be supported, please create an issue at:
4
4
  https://github.com/JeelGajera/jspdf-md-renderer/issues
5
- with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const s of r)a(s);n.endCursorYHandler(f.Y)};exports.MdTextParser=Z;exports.MdTextRender=ye;
5
+ with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const l of r)a(l);i.endCursorYHandler(g.Y)};exports.MdTextParser=rt;exports.MdTextRender=we;