jspdf-md-renderer 1.8.3 → 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/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.
4
4
 
5
+ [![npm version](https://img.shields.io/npm/v/jspdf-md-renderer.svg)](https://www.npmjs.com/package/jspdf-md-renderer)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Downloads](https://img.shields.io/npm/dm/jspdf-md-renderer.svg)](https://www.npmjs.com/package/jspdf-md-renderer)
8
+
5
9
  ## Table of Contents
6
10
 
7
11
  - [Installation](#installation)
@@ -148,7 +152,6 @@ Parses markdown into tokens and converts to a custom parsed structure.
148
152
 
149
153
  The following Markdown elements are currently supported by `jspdf-md-renderer`:
150
154
 
151
- ### Already Implemented:
152
155
  - **Headings**: `#`, `##`, `###`, etc.
153
156
  - **Paragraphs**
154
157
  - **Lists**:
@@ -169,8 +172,6 @@ The following Markdown elements are currently supported by `jspdf-md-renderer`:
169
172
  ```markdown
170
173
  [GitHub](https://github.com)
171
174
  ```
172
-
173
- ### Proposed for Future Implementation:
174
175
  - **Blockquotes**:
175
176
  ```markdown
176
177
  > This is a blockquote.
@@ -200,6 +201,10 @@ You can find more examples in the [examples](examples/test-pdf-gen) directory.
200
201
 
201
202
  Contributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
202
203
 
204
+ ## Support
205
+
206
+ If you find this library useful, please consider giving it a ⭐ on GitHub! It helps others find the project and motivates continued development.
207
+
203
208
  ## License
204
209
 
205
210
  This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { default as default_2 } from 'jspdf';
2
2
  import { jsPDFOptions } from 'jspdf';
3
+ import { UserOptions } from 'jspdf-autotable';
3
4
 
4
5
  declare type FontItem = {
5
6
  name: string;
@@ -36,14 +37,9 @@ declare type ParsedElement = {
36
37
  alt?: string;
37
38
  href?: string;
38
39
  text?: string;
39
- header?: {
40
- type?: string;
41
- content?: any;
42
- };
43
- rows?: {
44
- type?: string;
45
- content?: any;
46
- };
40
+ header?: ParsedElement[];
41
+ rows?: ParsedElement[][];
42
+ data?: string;
47
43
  };
48
44
 
49
45
  export declare type RenderOption = {
@@ -74,10 +70,21 @@ export declare type RenderOption = {
74
70
  content?: {
75
71
  textAlignment: 'left' | 'right' | 'center' | 'justify';
76
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
+ };
77
83
  link?: {
78
84
  linkColor: [number, number, number];
79
85
  };
80
- pageBreakHandler?: () => void;
86
+ table?: UserOptions;
87
+ pageBreakHandler?: (doc: default_2) => void;
81
88
  endCursorYHandler: (y: number) => void;
82
89
  };
83
90
 
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("marked");var o=(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))(o||{});const H=async t=>{const i=await z.marked.lexer(t,{async:!0});return b(i)},b=t=>{const i=[];return t.forEach(s=>{try{const x=w[s.type];x?i.push(x(s)):i.push({type:o.Raw,content:s.raw})}catch(x){console.error("Failed to handle token ==>",s,x)}}),i},w={[o.Heading]:t=>({type:o.Heading,depth:t.depth,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Paragraph]:t=>({type:o.Paragraph,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.List]:t=>({type:o.List,ordered:t.ordered,start:t.start,items:t.items?b(t.items):[]}),[o.ListItem]:t=>({type:o.ListItem,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Code]:t=>({type:o.Code,lang:t.lang,code:t.text}),[o.Table]:t=>({type:o.Table,header:t.header.map(i=>({type:o.TableHeader,content:i})),rows:t.rows.map(i=>i.map(s=>({type:o.TableCell,content:s})))}),[o.Image]:t=>({type:o.Image,src:t.href,alt:t.text}),[o.Link]:t=>({type:o.Link,href:t.href,text:t.text,items:t.tokens?b(t.tokens):[]}),[o.Strong]:t=>({type:o.Strong,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Em]:t=>({type:o.Em,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Text]:t=>({type:o.Text,content:t.text,items:t.tokens?b(t.tokens):[]}),[o.Hr]:t=>({type:o.Hr,content:t.raw,items:t.tokens?b(t.tokens):[]}),[o.CodeSpan]:t=>({type:o.CodeSpan,content:t.text,items:t.tokens?b(t.tokens):[]})},L=class L{static initialize(i){this.options_=i,this.cursor={x:i.cursor.x,y:i.cursor.y}}static getCursor(){return this.cursor}static setCursor(i){this.cursor=i}static get options(){return this.options_}static get isInlineLockActive(){return this.inlineLock}static activateInlineLock(){this.inlineLock=!0}static deactivateInlineLock(){this.inlineLock=!1}static updateX(i,s="set"){s==="set"?this.cursor.x=i:s==="add"&&(this.cursor.x+=i)}static updateY(i,s="set"){s==="set"?this.cursor.y=i:s==="add"&&(this.cursor.y+=i)}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};L.cursor={x:0,y:0},L.inlineLock=!1;let e=L;const W=t=>{typeof e.options.pageBreakHandler=="function"?e.options.pageBreakHandler():t.addPage(e.options.page?.format,e.options.page?.orientation),e.updateY(e.options.page.topmargin),e.updateX(e.options.page.xpading)},f=t=>t.getTextDimensions("H").h*e.options.page.defaultLineHeightFactor,Y=t=>t.getTextDimensions("H").w*e.options.page.defaultLineHeightFactor,I=(t,i,s,x)=>{const g=6-(i?.depth??0)>0?6-(i?.depth??0):1;if(t.setFontSize(e.options.page.defaultFontSize+g),e.updateY(g*.2*f(t),"add"),i?.items&&i?.items.length>0)for(const p of i?.items??[])x(p,s,!1);else t.text(i?.content??"",e.X+s,e.Y,{align:"left",maxWidth:e.options.page.maxContentWidth-s});t.setFontSize(e.options.page.defaultFontSize),e.updateX(e.options.page.xpading)},k=(t,i,s,x,g,p,c,l,n)=>{const r=(l-s)/(i.length-1);let a=g;const h=p+x*c;for(const u of i)t.text(u.text,a,h,{align:"justify",lineHeightFactor:n,maxWidth:l}),a+=u.wordLength+r},E=(t,i,s,x,g,p,c,l)=>{const n=t.map(r=>r.text).join(" ");i.text(n,s,x+g*p,{align:"justify",lineHeightFactor:l,maxWidth:c})},y=(t,i,s,x,g,p)=>{const c={x:s,y:x},l=t.getTextDimensions("A").h*p,n=i.split(" ");let r=0,a=[],h=0;for(const u of n){const d=t.getTextWidth(u+"a");d+h>=g&&(k(t,a,h,r++,s,x,l,g,p),a=[],h=0),a.push({text:u,wordLength:d}),h+=d}return a.length>0&&E(a,t,s,x,r,l,g,p),c.y=x+r*l,c.x=t.getTextWidth(i)+s,c},F=(t,i,s)=>{const x=t.getFont().fontName,g=t.getFont().fontStyle,p=t.getFontSize(),c=n=>{switch(n){case"normal":return 0;case"bold":return 1;case"italic":return 1.5;case"bolditalic":return 1.5;default:return 0}},l=(n,r)=>{r==="bold"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,e.options.font.bold.style||"bold"):r==="italic"?t.setFont(e.options.font.regular.name,"italic"):r==="bolditalic"?t.setFont(e.options.font.bold.name&&e.options.font.bold.name!==""?e.options.font.bold.name:x,"bolditalic"):t.setFont(e.options.font.regular.name,g);const a=e.options.page.maxContentWidth-s-e.X,h=t.splitTextToSize(n,a);if(e.isInlineLockActive)for(let u=0;u<h.length;u++)t.text(h[u],e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(t.getTextDimensions(h[u]).w+1,"add"),u<h.length-1&&(e.updateY(f(t),"add"),e.updateX(e.options.page.xpading+s,"set"));else if(h.length>1){const u=h[0],d=h?.slice(1)?.join(" ");t.text(u,e.X+(s>=2?s+2*c(r):0),e.Y,{baseline:"top",maxWidth:a}),e.updateX(e.options.page.xpading+s),e.updateY(f(t),"add");const m=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(d,m).forEach(X=>{t.text(X,e.X+Y(t),e.Y,{baseline:"top",maxWidth:m})})}else t.text(n,e.X+s,e.Y,{baseline:"top",maxWidth:a}),e.updateX(t.getTextDimensions(n).w+(s>=2?n.split(" ").length+2:2)*c(r)*.5,"add")};if(i.type==="text"&&i.items&&i.items.length>0)for(const n of i.items)if(n.type==="em"||n.type==="strong"){const r=n.type==="em"?"italic":"bold";if(n.items&&n.items.length>0)for(const a of n.items)a.type==="strong"&&r==="italic"||a.type==="em"&&r==="bold"?l(a.content||"","bolditalic"):l(a.content||"",r);else l(n.content||"",r)}else l(n.content||"","normal");else i.type==="em"?l(i.content||"","italic"):i.type==="strong"?l(i.content||"","bold"):l(i.content||"","normal");t.setFont(x,g),t.setFontSize(p)},D=(t,i,s,x)=>{e.activateInlineLock(),t.setFontSize(e.options.page.defaultFontSize);let g=i.content;const p=t.getTextDimensions("A").h*e.options.page.defaultLineHeightFactor;if(i?.items&&i?.items.length>0){let c=0;for(const l of i?.items??[])["strong","em","text"].includes(l.type)?(l.type!=="text"&&c!=0&&e.updateX(Y(t)*1.5,"add"),F(t,l,s),l.type!=="text"&&c!=0&&e.updateX(Y(t),"add")):x(l,s,!1),c++}else{if(e.Y+t.splitTextToSize(g??"",e.options.page.maxContentWidth-s).length*p-3*p>=e.options.page.maxContentHeight){const l=t.splitTextToSize(g??"",e.options.page.maxContentWidth-s),n=[],r=e.Y;for(let a=0;a<l.length;a++)if(e.Y-2*p<e.options.page.maxContentHeight)n.push(l[a]),e.updateY(e.options.page.lineSpace,"add");else{a<=l.length-1&&(g=l.slice(a).join(""));break}if(n.length>0){const a=y(t,n.join(" "),e.X+s,r,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor);e.setCursor(a)}W(t)}const c=y(t,g??"",e.X+s,e.Y,e.options.page.maxContentWidth-s,e.options.page.defaultLineHeightFactor).y+f(t);e.updateY(c)}e.updateY(p,"add"),e.updateX(e.options.page.xpading),e.deactivateInlineLock()},P=(t,i,s,x)=>{t.setFontSize(e.options.page.defaultFontSize);for(const[g,p]of i?.items?.entries()??[]){const c=i.ordered?(i.start??0)+g:i.start;x(p,s+1,!0,c,i.ordered)}},j=(t,i,s,x,g,p)=>{const c=s*e.options.page.indent,l=p?`${g}. `:"• ";e.Y+f(t)>=e.options.page.maxContentHeight&&W(t),t.setFont(e.options.font.regular.name,e.options.font.regular.style),t.text(l,e.X+c,e.Y,{baseline:"top"});const n=t.getTextWidth(l);if(e.updateX(n,"add"),i.items&&i.items.length>0)for(const r of i.items){if(e.Y+f(t)>=e.options.page.maxContentHeight&&W(t),r.type===o.List)x(r,s+1,!0,g,r.ordered??!1);else if(r.type===o.ListItem){const a=i.type===o.List?s:s+1;x(r,a,!0,g,p)}else e.activateInlineLock(),F(t,r,c),e.deactivateInlineLock();e.updateX(e.options.page.xpading),e.updateY(f(t),"add")}else if(i.content){const r=e.X+c,a=t.getTextWidth(l),h=e.options.page.maxContentWidth-c-a,u=t.splitTextToSize(i.content,h);if(u.length>0){t.text(u[0],r+a,e.Y,{baseline:"top",maxWidth:h});for(let m=1;m<u.length;m++)e.updateY(f(t),"add"),t.text(u[m],r+a,e.Y,{baseline:"top",maxWidth:h});e.updateX(e.options.page.xmargin+c),e.updateY(f(t),"add");const d=t.getTextWidth(i.content);e.updateX(d,"add")}}},v=(t,i,s,x,g,p,c,l=!0)=>{if(i?.items&&i?.items.length>0)for(const n of i?.items??[])g(n,s,x,p,c,l);else{const n=s*e.options.page.indent,r=x?c?`${p}. `:"• ":"";if(x&&r){const a=t.getTextWidth(r),h=e.options.page.maxContentWidth-n-a,u=t.splitTextToSize(i.content||"",h);if(u.length>0){t.text(r,e.X+n,e.Y,{baseline:"top"}),t.text(u[0],e.X+n+a,e.Y,{baseline:"top",maxWidth:h});for(let m=1;m<u.length;m++)e.updateX(e.options.page.xpading),e.updateY(f(t),"add"),t.text(u[m],e.X+n+a,e.Y,{baseline:"top",maxWidth:h-n-a});e.updateY(f(t),"add"),e.updateX(e.options.page.xpading+n);const d=t.getTextWidth(i.content||"");e.updateX(d,"add")}}else{const a=t.splitTextToSize(i.content||"",e.options.page.maxContentWidth-n);if(e.Y+a.length*f(t)>=e.options.page.maxContentHeight&&W(t),l){const h=y(t,i.content||"",e.X+n,e.Y,e.options.page.maxContentWidth-n,e.options.page.defaultLineHeightFactor).y+f(t)*.5;e.updateY(h),e.updateX(e.options.page.xpading)}else t.text(a||"",e.X+n,e.Y,{baseline:"top"}),e.updateX(t.getTextWidth(i.content||""),"add"),e.X>=e.options.page.xpading+e.options.page.maxContentWidth&&W(t)}}},A=t=>{const i=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(e.options.page.xpading,e.Y,i-e.options.page.xpading,e.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),e.updateY(f(t),"add")},R=(t,i,s,x)=>{const g=s*e.options.page.indent;e.Y+t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-g).length*f(t)-2*f(t)>=e.options.page.maxContentHeight&&W(t);const p=t.splitTextToSize(i.code??"",e.options.page.maxContentWidth-g).length*f(t);e.updateY(e.options.page.lineSpace,"add"),t.setFillColor("#EEEEEE"),t.setDrawColor("#eee"),t.roundedRect(e.X,e.Y-e.options.page.lineSpace,e.options.page.maxContentWidth,p,2,2,"FD"),t.setFontSize(10),t.text(i.lang??"",e.X+e.options.page.maxContentWidth-t.getTextWidth(i.lang??"")-e.options.page.lineSpace/2,e.Y),t.setFontSize(e.options.page.defaultFontSize),t.text(i.code??"",e.X+4,e.Y),e.updateY(p,"add")},B=(t,i,s)=>{const x=t.getFont().fontName,g=t.getFont().fontStyle,p=t.getFontSize(),c=t.getTextColor(),l=e.options.link?.linkColor||[0,0,255];t.setTextColor(...l);const n=e.options.page.maxContentWidth-s-e.X,r=i.text||i.content||"",a=i.href||"",h=t.splitTextToSize(r,n);if(e.isInlineLockActive)for(let u=0;u<h.length;u++){const d=t.getTextDimensions(h[u]).w,m=f(t)/2;t.link(e.X+s,e.Y,d,m,{url:a}),t.text(h[u],e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(d+1,"add"),e.X+d>e.options.page.maxContentWidth-s&&(e.updateY(m,"add"),e.updateX(e.options.page.xpading+s,"set")),u<h.length-1&&(e.updateY(m,"add"),e.updateX(e.options.page.xpading+s,"set"))}else if(h.length>1){const u=h[0],d=h?.slice(1)?.join(" "),m=t.getTextDimensions(u).w,C=f(t)/2;t.link(e.X+s,e.Y,m,C,{url:a}),t.text(u,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(e.options.page.xpading+s),e.updateY(C,"add");const X=e.options.page.maxContentWidth-s-e.options.page.xpading;t.splitTextToSize(d,X).forEach(S=>{const T=t.getTextDimensions(S).w;t.link(e.X+Y(t),e.Y,T,C,{url:a}),t.text(S,e.X+Y(t),e.Y,{baseline:"top",maxWidth:X})})}else{const u=t.getTextDimensions(r).w,d=f(t)/2;t.link(e.X+s,e.Y,u,d,{url:a}),t.text(r,e.X+s,e.Y,{baseline:"top",maxWidth:n}),e.updateX(u+2,"add")}t.setFont(x,g),t.setFontSize(p),t.setTextColor(c)},_=async(t,i,s)=>{e.initialize(s);const x=await H(i),g=(p,c=0,l=!1,n=0,r=!1,a=!0)=>{const h=c*s.page.indent;switch(e.Y+t.splitTextToSize(p.content??"",s.page.maxContentWidth-h).length*f(t)>=s.page.maxContentHeight&&W(t),p.type){case o.Heading:I(t,p,h,g);break;case o.Paragraph:D(t,p,h,g);break;case o.List:P(t,p,c,g);break;case o.ListItem:j(t,p,c,g,n,r);break;case o.Hr:A(t);break;case o.Code:R(t,p,c);break;case o.Strong:case o.Em:F(t,p,h);break;case o.Link:B(t,p,h);break;case o.Raw:case o.Text:v(t,p,c,l,g,n,r,a);break;default:console.warn(`Warning: Unsupported element type encountered: ${p.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}.
2
3
  If you believe this element type should be supported, please create an issue at:
3
4
  https://github.com/JeelGajera/jspdf-md-renderer/issues
4
- with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const p of x)g(p);s.endCursorYHandler(e.Y)};exports.MdTextParser=H;exports.MdTextRender=_;
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;