jspdf-md-renderer 3.0.1 → 3.2.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
@@ -10,6 +10,7 @@ A jsPDF utility to render Markdown directly into formatted PDFs with custom desi
10
10
 
11
11
  - [Installation](#installation)
12
12
  - [Usage](#usage)
13
+ - [Browser Runtime Usage](#browser-runtime-usage)
13
14
  - [API](#api)
14
15
  - [Examples](#examples)
15
16
  - [Contributing](#contributing)
@@ -124,6 +125,41 @@ const generatePDF = async () => {
124
125
  generatePDF();
125
126
  ```
126
127
 
128
+ ## Browser Runtime Usage
129
+
130
+ ### Option 1: Use with your app bundler (Vite/Webpack/Rollup)
131
+
132
+ Install dependencies and import from modules as usual:
133
+
134
+ ```ts
135
+ import { jsPDF } from 'jspdf';
136
+ import autoTable from 'jspdf-autotable';
137
+ import { MdTextRender } from 'jspdf-md-renderer';
138
+ ```
139
+
140
+ ### Option 2: Use directly via script tags (UMD)
141
+
142
+ Load dependencies first, then load `jspdf-md-renderer` UMD bundle.
143
+
144
+ ```html
145
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
146
+ <script src="https://cdn.jsdelivr.net/npm/jspdf@latest/dist/jspdf.umd.min.js"></script>
147
+ <script src="https://cdn.jsdelivr.net/npm/jspdf-autotable@latest/dist/jspdf.plugin.autotable.min.js"></script>
148
+ <script src="https://cdn.jsdelivr.net/npm/jspdf-md-renderer@latest/dist/index.umd.js"></script>
149
+ <script>
150
+ const { jsPDF } = window.jspdf;
151
+ const { MdTextRender } = window.JspdfMdRenderer;
152
+
153
+ (async () => {
154
+ const doc = new jsPDF();
155
+ await MdTextRender(doc, '# Hello from browser runtime');
156
+ doc.save('browser-runtime.pdf');
157
+ })();
158
+ </script>
159
+ ```
160
+
161
+ > Note: For script-tag usage you must include `marked`, `jspdf`, and `jspdf-autotable` before the renderer bundle.
162
+
127
163
  ## API
128
164
 
129
165
  ### `MdTextRender`
@@ -180,6 +216,40 @@ The following Markdown elements are currently supported by `jspdf-md-renderer`:
180
216
  ```markdown
181
217
  ![Alt text](https://example.com/image.png)
182
218
  ```
219
+ Images render at their **intrinsic (original) size** by default and scale down automatically if they exceed the available page width. You can control image dimensions and alignment using an optional attribute block `{...}` after the image syntax:
220
+
221
+ **Custom Attributes:**
222
+ | Attribute | Description | Example |
223
+ |-----------|-------------|---------|
224
+ | `width` or `w` | Image width in px | `{width=200}` or `{w=200}` |
225
+ | `height` or `h` | Image height in px | `{height=150}` or `{h=150}` |
226
+ | `align` | Alignment: `left`, `center`, `right` | `{align=center}` |
227
+
228
+ **Sizing Rules:**
229
+ - If only `width` is given, height is auto-calculated from aspect ratio
230
+ - If only `height` is given, width is auto-calculated from aspect ratio
231
+ - If both are given, the image uses exact dimensions (may distort if ratio differs)
232
+ - Images that exceed page bounds are always scaled down proportionally
233
+
234
+ **Examples:**
235
+ ```markdown
236
+ ![photo](https://example.com/photo.png)
237
+ ![photo](https://example.com/photo.png){width=200}
238
+ ![photo](https://example.com/photo.png){h=150 align=center}
239
+ ![photo](https://example.com/photo.png){width=200 height=150 align=right}
240
+ ```
241
+
242
+ **Global Default Alignment:**
243
+ You can set a default alignment for all images via the `image` option:
244
+ ```ts
245
+ const options = {
246
+ // ...other options
247
+ image: {
248
+ defaultAlign: 'center', // 'left' (default) | 'center' | 'right'
249
+ },
250
+ };
251
+ ```
252
+
183
253
  - **Inline Code**:
184
254
  ```markdown
185
255
  This is an `inline code` example.
package/dist/index.d.ts CHANGED
@@ -40,6 +40,11 @@ declare type ParsedElement = {
40
40
  header?: ParsedElement[];
41
41
  rows?: ParsedElement[][];
42
42
  data?: string;
43
+ width?: number;
44
+ height?: number;
45
+ align?: 'left' | 'center' | 'right';
46
+ naturalWidth?: number;
47
+ naturalHeight?: number;
43
48
  };
44
49
 
45
50
  export declare type RenderOption = {
@@ -84,6 +89,10 @@ export declare type RenderOption = {
84
89
  linkColor: [number, number, number];
85
90
  };
86
91
  table?: UserOptions;
92
+ image?: {
93
+ /** Default alignment for images: 'left' | 'center' | 'right'. Default: 'left' */
94
+ defaultAlign?: 'left' | 'center' | 'right';
95
+ };
87
96
  pageBreakHandler?: (doc: default_2) => void;
88
97
  endCursorYHandler: (y: number) => void;
89
98
  };
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
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}.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("marked"),q=require("jspdf-autotable");var u=(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))(u||{});const A="__jmr_",G=/(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g,U=/(\w+)\s*=\s*(\w+)/g,B=["left","center","right"],J=t=>{const e=[];return t.width!==void 0&&e.push(`w=${t.width}`),t.height!==void 0&&e.push(`h=${t.height}`),t.align&&e.push(`a=${t.align}`),e.length>0?`#${A}${e.join("&")}`:""},V=t=>{const e={};let s;for(;(s=U.exec(t))!==null;){const c=s[1].toLowerCase(),g=s[2];switch(c){case"width":case"w":{const r=parseInt(g,10);!isNaN(r)&&r>0&&(e.width=r);break}case"height":case"h":{const r=parseInt(g,10);!isNaN(r)&&r>0&&(e.height=r);break}case"align":{const r=g.toLowerCase();B.includes(r)&&(e.align=r);break}}}return e},K=t=>t.replace(G,(e,s,c,g,r)=>{const l=V(r),i=J(l);return`${s}${c}${i}${g}`}),Q=t=>{const e=t.indexOf(`#${A}`);if(e===-1)return{cleanHref:t,attrs:{}};const s=t.substring(0,e),c=t.substring(e+1+A.length),g={},r=c.split("&");for(const l of r){const[i,a]=l.split("=");switch(i){case"w":{const p=parseInt(a,10);!isNaN(p)&&p>0&&(g.width=p);break}case"h":{const p=parseInt(a,10);!isNaN(p)&&p>0&&(g.height=p);break}case"a":{B.includes(a)&&(g.align=a);break}}}return{cleanHref:s,attrs:g}},_=async t=>{const e=K(t),s=await O.marked.lexer(e,{async:!0,gfm:!0});return W(s)},W=t=>{const e=[];return t.forEach(s=>{try{const c=Z[s.type];c?e.push(c(s)):e.push({type:u.Raw,content:s.raw})}catch(c){console.error("Failed to handle token ==>",s,c)}}),e},Z={[u.Heading]:t=>({type:u.Heading,depth:t.depth,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Paragraph]:t=>({type:u.Paragraph,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.List]:t=>({type:u.List,ordered:t.ordered,start:t.start,items:t.items?W(t.items):[]}),[u.ListItem]:t=>({type:u.ListItem,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Code]:t=>({type:u.Code,lang:t.lang,code:t.text}),[u.Table]:t=>({type:u.Table,header:t.header.map(e=>({type:u.TableHeader,content:e.text})),rows:t.rows.map(e=>e.map(s=>({type:u.TableCell,content:s.text})))}),[u.Image]:t=>{const{cleanHref:e,attrs:s}=Q(t.href);return{type:u.Image,src:e,alt:t.text,width:s.width,height:s.height,align:s.align}},[u.Link]:t=>({type:u.Link,href:t.href,text:t.text,items:t.tokens?W(t.tokens):[]}),[u.Strong]:t=>({type:u.Strong,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Em]:t=>({type:u.Em,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Text]:t=>({type:u.Text,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Hr]:t=>({type:u.Hr,content:t.raw,items:t.tokens?W(t.tokens):[]}),[u.CodeSpan]:t=>({type:u.CodeSpan,content:t.text,items:t.tokens?W(t.tokens):[]}),[u.Blockquote]:t=>({type:u.Blockquote,content:t.text,items:t.tokens?W(t.tokens):[]})},H=class H{static initialize(e){this.options_=e,this.cursor={x:e.cursor.x,y:e.cursor.y},this.lastContentY_=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,s="set"){s==="set"?this.cursor.x=e:s==="add"&&(this.cursor.x+=e)}static updateY(e,s="set"){s==="set"?this.cursor.y=e:s==="add"&&(this.cursor.y+=e)}static recordContentY(e){this.lastContentY_=e!==void 0?e:this.cursor.y}static get lastContentY(){return this.lastContentY_}static get X(){return this.cursor.x}static get Y(){return this.cursor.y}};H.cursor={x:0,y:0},H.lastContentY_=0,H.inlineLock=!1;let n=H;const C=t=>t.getTextDimensions("H").h*n.options.page.defaultLineHeightFactor,Y=t=>t.getTextDimensions("H").w*n.options.page.defaultLineHeightFactor,M=(t,e,s,c)=>{const g=6-(e?.depth??0)>0?6-(e?.depth??0):1;if(t.setFontSize(n.options.page.defaultFontSize+g),e?.items&&e?.items.length>0)for(const r of e?.items??[])c(r,s,!1);else{const r=C(t);t.text(e?.content??"",n.X+s,n.Y,{align:"left",maxWidth:n.options.page.maxContentWidth-s,baseline:"top"}),n.recordContentY(n.Y+r),n.updateY(r,"add")}t.setFontSize(n.options.page.defaultFontSize),n.updateX(n.options.page.xpading,"set")},k=t=>{typeof n.options.pageBreakHandler=="function"?n.options.pageBreakHandler(t):t.addPage(n.options.page?.format,n.options.page?.orientation),n.updateY(n.options.page.topmargin),n.updateX(n.options.page.xpading)};class v{static getCodespanOptions(){const e=n.options.codespan??{};return{backgroundColor:e.backgroundColor??"#EEEEEE",padding:e.padding??.5,showBackground:e.showBackground!==!1,fontSizeScale:e.fontSizeScale??.9}}static applyStyle(e,s){const c=e.getFont().fontName,g=e.getFontSize(),r=()=>{const i=n.options.font.bold?.name;return i&&i!==""?i:c},l=()=>{const i=n.options.font.regular?.name;return i&&i!==""?i:c};switch(s){case"bold":e.setFont(r(),n.options.font.bold?.style||"bold");break;case"italic":e.setFont(l(),"italic");break;case"bolditalic":e.setFont(r(),"bolditalic");break;case"codespan":e.setFont("courier","normal"),e.setFontSize(g*this.getCodespanOptions().fontSizeScale);break;default:e.setFont(l(),e.getFont().fontStyle);break}}static measureWordWidth(e,s,c){const g=e.getFont(),r=e.getFontSize();this.applyStyle(e,c);const l=e.getTextWidth(s),i=e.getCharSpace?.()??0,a=l+s.length*i;return e.setFont(g.fontName,g.fontStyle),e.setFontSize(r),a}static getStyleFromType(e,s){switch(e){case"strong":return s==="italic"?"bolditalic":"bold";case"em":return s==="bold"?"bolditalic":"italic";case"codespan":return"codespan";default:return s||"normal"}}static flattenToWords(e,s,c="normal",g=!1,r){const l=[];for(const i of s){const a=this.getStyleFromType(i.type,c),p=i.type==="link"||g,h=i.href||r;if(i.items&&i.items.length>0){const f=this.flattenToWords(e,i.items,a,p,h);l.push(...f)}else{const f=i.content||i.text||"";if(!f)continue;if(a==="codespan"){const o=f.trim();o&&l.push({text:o,width:this.measureWordWidth(e,o,a),style:a,isLink:p,href:h,linkColor:p?n.options.link?.linkColor||[0,0,255]:void 0});continue}const d=f.split(/\s+/).filter(o=>o.length>0);if(d.length===0)continue;for(let o=0;o<d.length;o++){const m=d[o];l.push({text:m,width:this.measureWordWidth(e,m,a),style:a,isLink:p,href:h,linkColor:p?n.options.link?.linkColor||[0,0,255]:void 0})}}}return l}static breakIntoLines(e,s,c){const g=[];let r=[],l=0,i=0;const a=e.getTextWidth(" ");for(let p=0;p<s.length;p++){const h=s[p],f=r.length>0?a+h.width:h.width;i+f>c&&r.length>0?(g.push({words:r,totalTextWidth:l,isLastLine:!1}),r=[h],l=h.width,i=h.width):(r.push(h),l+=h.width,i+=f)}return r.length>0&&g.push({words:r,totalTextWidth:l,isLastLine:!0}),g}static renderWord(e,s,c,g){const r=e.getFont(),l=e.getFontSize(),i=e.getTextColor();if(this.applyStyle(e,s.style),s.isLink&&s.linkColor&&e.setTextColor(...s.linkColor),s.style==="codespan"){const a=this.getCodespanOptions();if(a.showBackground){const p=C(e),h=a.padding;e.setFillColor(a.backgroundColor),e.rect(c-h,g-h,s.width+h*2,p+h*2,"F"),e.setFillColor("#000000")}}if(e.text(s.text,c,g,{baseline:"top"}),s.isLink&&s.href){const a=C(e)/2;e.link(c,g,s.width,a,{url:s.href})}e.setFont(r.fontName,r.fontStyle),e.setFontSize(l),e.setTextColor(i)}static renderAlignedLine(e,s,c,g,r,l="left"){const{words:i,totalTextWidth:a,isLastLine:p}=s;if(i.length===0)return;const h=e.getTextWidth(" ");let f=c,d=h;const o=a+(i.length-1)*h;switch(l){case"right":f=c+r-o;break;case"center":f=c+(r-o)/2;break;case"justify":!p&&i.length>1&&(d=(r-a)/(i.length-1));break}let m=f;for(let x=0;x<i.length;x++)this.renderWord(e,i[x],m,g),m+=i[x].width,x<i.length-1&&(m+=d)}static renderStyledParagraph(e,s,c,g,r,l){const i=l??n.options.content?.textAlignment??"left",a=this.flattenToWords(e,s);if(a.length===0)return;const p=this.breakIntoLines(e,a,r),h=C(e)*n.options.page.defaultLineHeightFactor;let f=g;for(const o of p)f+h>n.options.page.maxContentHeight&&(k(e),f=n.Y),this.renderAlignedLine(e,o,c,f,r,i),n.recordContentY(f+C(e)),f+=h,n.updateY(h,"add");const d=p[p.length-1];if(d){const o=d.totalTextWidth+(d.words.length-1)*e.getTextWidth(" ");n.updateX(c+o,"set")}}static renderJustifiedParagraph(e,s,c,g,r){this.renderStyledParagraph(e,s,c,g,r)}}class I{static renderText(e,s,c=n.X,g=n.Y,r,l=!1){const i=e.splitTextToSize(s,r),a=C(e),p=a*n.options.page.defaultLineHeightFactor;let h=g;for(let f=0;f<i.length;f++){const d=i[f];h+p>n.options.page.maxContentHeight&&(k(e),h=n.Y),l?f===i.length-1?e.text(d,c,h,{baseline:"top"}):e.text(d,c,h,{maxWidth:r,align:"justify",baseline:"top"}):e.text(d,c,h,{baseline:"top"}),n.recordContentY(h+a),h+=p,n.updateY(p,"add")}return h}}const tt=(t,e,s,c)=>{n.activateInlineLock(),t.setFontSize(n.options.page.defaultFontSize);const g=n.options.page.maxContentWidth-s;if(e?.items&&e?.items.length>0)if(e.items.some(l=>!["strong","em","text","codespan","link"].includes(l.type))){const l=[],i=()=>{l.length>0&&(v.renderStyledParagraph(t,l,n.X+s,n.Y,g),l.length=0)};for(const a of e.items)["strong","em","text","codespan","link"].includes(a.type)?l.push(a):(i(),c(a,s,!1));i()}else v.renderStyledParagraph(t,e.items,n.X+s,n.Y,g);else{const r=e.content??"",l=n.options.content?.textAlignment??"left";r.trim()&&I.renderText(t,r,n.X+s,n.Y,g,l==="justify")}n.updateX(n.options.page.xpading),n.deactivateInlineLock()},et=(t,e,s,c)=>{t.setFontSize(n.options.page.defaultFontSize);for(const[g,r]of e?.items?.entries()??[]){const l=e.ordered?(e.start??0)+g:e.start;c(r,s+1,!0,l,e.ordered)}},nt=(t,e,s,c,g,r)=>{n.Y+C(t)>=n.options.page.maxContentHeight&&k(t);const l=n.options,i=s*l.page.indent,a=r?`${g}. `:"• ",p=l.page.xpading;n.updateX(p,"set"),t.setFont(l.font.regular.name,l.font.regular.style),t.text(a,p+i,n.Y,{baseline:"top"});const h=t.getTextWidth(a),f=p+i+h,d=l.page.maxContentWidth-i-h;if(e.items&&e.items.length>0){const o=[],m=()=>{o.length>0&&(v.renderStyledParagraph(t,o,f,n.Y,d),o.length=0,n.updateX(p,"set"))};for(const x of e.items)x.type===u.List?(m(),c(x,s,!0,g,x.ordered??!1)):x.type===u.ListItem?(m(),c(x,s,!0,g,r)):o.push(x);m()}else if(e.content){const o=l.content?.textAlignment??"left";I.renderText(t,e.content,f,n.Y,d,o==="justify")}},st=(t,e,s,c,g,r,l,i=!0)=>{if(e?.items&&e?.items.length>0)for(const a of e?.items??[])g(a,s,c,r,l,i);else{const a=n.options,p=s*a.page.indent,h=c?l?`${r}. `:"• ":"",f=e.content||"",d=a.page.xpading;if(!f&&!h)return;if(!f.trim()&&!h){const o=(f.match(/\n/g)||[]).length;if(o>1){const m=o-1,x=t.getTextDimensions("A").h*a.page.defaultLineHeightFactor,F=m*x;n.Y+F>a.page.maxContentHeight?k(t):(n.updateY(F,"add"),n.recordContentY(n.Y))}return}if(n.updateX(d,"set"),c&&h){const o=t.getTextWidth(h),m=a.page.maxContentWidth-p-o;t.setFont(a.font.regular.name,a.font.regular.style),t.text(h,d+p,n.Y,{baseline:"top"}),I.renderText(t,f,d+p+o,n.Y,m,i)}else{const o=a.page.maxContentWidth-p;I.renderText(t,f,d+p,n.Y,o,i)}n.updateX(d,"set")}},it=t=>{const e=t.internal.pageSize.getWidth();t.setLineDashPattern([1,1],0),t.setLineWidth(.1),t.line(n.options.page.xpading,n.Y,e-n.options.page.xpading,n.Y),t.setLineWidth(.1),t.setLineDashPattern([],0),n.updateY(C(t),"add")},at=(t,e,s,c)=>{const g=t.getFont(),r=t.getFontSize();t.setFont("courier","normal");const l=n.options.page.defaultFontSize*.9;t.setFontSize(l);const i=s*n.options.page.indent,a=n.options.page.maxContentWidth-i-8,p=t.getLineHeightFactor(),h=l/t.internal.scaleFactor*p,d=(e.code??"").replace(/[\r\n\s]+$/,"");if(!d){t.setFont(g.fontName,g.fontStyle),t.setFontSize(r);return}const o=t.splitTextToSize(d,a);for(;o.length>0&&o[o.length-1].trim()==="";)o.pop();if(o.length===0){t.setFont(g.fontName,g.fontStyle),t.setFontSize(r);return}const m=4,x="#EEEEEE",F="#DDDDDD";let b=0;for(;b<o.length;){const y=n.options.page.maxContentHeight-n.Y,w=o.length-b,T=y-m*2;let S=Math.floor(T/h);if(S<=0){k(t);continue}S>w&&(S=w);const j=o.slice(b,b+S),X=b===0,z=b+S>=o.length,N=S*h;if(X&&n.updateY(m,"add"),t.setFillColor(x),t.setDrawColor(F),t.roundedRect(n.X,n.Y-m,n.options.page.maxContentWidth,N+(X?m:0)+(z?m:0),2,2,"FD"),X&&e.lang){const E=t.getFontSize();t.setFontSize(10),t.setTextColor("#666666"),t.text(e.lang,n.X+n.options.page.maxContentWidth-t.getTextWidth(e.lang)-4,n.Y,{baseline:"top"}),t.setFontSize(E),t.setTextColor("#000000")}let R=n.Y;for(const E of j)t.text(E,n.X+4,R,{baseline:"top"}),R+=h;n.updateY(N,"add"),n.recordContentY(n.Y+(z?m:0)),z&&n.updateY(m,"add"),b+=S,b<o.length&&k(t)}t.setFont(g.fontName,g.fontStyle),t.setFontSize(r)},ot=(t,e,s)=>{const c=t.getFont().fontName,g=t.getFont().fontStyle,r=t.getFontSize(),l=a=>{switch(a){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}},i=(a,p)=>{p==="bold"?t.setFont(n.options.font.bold.name&&n.options.font.bold.name!==""?n.options.font.bold.name:c,n.options.font.bold.style||"bold"):p==="italic"?t.setFont(n.options.font.regular.name,"italic"):p==="bolditalic"?t.setFont(n.options.font.bold.name&&n.options.font.bold.name!==""?n.options.font.bold.name:c,"bolditalic"):p==="codespan"?(t.setFont("courier","normal"),t.setFontSize(r*.9)):t.setFont(n.options.font.regular.name,g);const h=n.options.page.maxContentWidth-s-n.X,f=t.splitTextToSize(a,h),d=p==="codespan",o=1,m="#EEEEEE";if(n.isInlineLockActive)for(let x=0;x<f.length;x++){if(d){const F=t.getTextWidth(f[x])+Y(t),b=C(t);t.setFillColor(m),t.roundedRect(n.X+s-o,n.Y-o,F+o*2,b+o*2,2,2,"F"),t.setFillColor("#000000")}t.text(f[x],n.X+s,n.Y,{baseline:"top",maxWidth:h}),n.updateX(t.getTextDimensions(f[x]).w+(d?o*2:1),"add"),x<f.length-1&&(n.updateY(C(t),"add"),n.updateX(n.options.page.xpading,"set"))}else if(f.length>1){const x=f[0],F=f?.slice(1)?.join(" ");if(d){const w=t.getTextWidth(x)+Y(t),T=C(t);t.setFillColor(m),t.roundedRect(n.X+(s>=2?s+2:0)-o,n.Y-o,w+o*2,T+o*2,2,2,"F"),t.setFillColor("#000000")}t.text(x,n.X+(s>=2?s+2*l(p):0),n.Y,{baseline:"top",maxWidth:h}),n.updateX(n.options.page.xpading+s),n.updateY(C(t),"add");const b=n.options.page.maxContentWidth-s-n.options.page.xpading;t.splitTextToSize(F,b).forEach(w=>{if(d){const T=t.getTextWidth(w)+Y(t),S=C(t);t.setFillColor(m),t.roundedRect(n.X+Y(t)-o,n.Y-o,T+o*2,S+o*2,2,2,"F"),t.setFillColor("#000000")}t.text(w,n.X+Y(t),n.Y,{baseline:"top",maxWidth:b})})}else{if(d){const x=t.getTextWidth(a)+Y(t),F=C(t);t.setFillColor(m),t.roundedRect(n.X+s-o,n.Y-o,x+o*2,F+o*2,2,2,"F"),t.setFillColor("#000000")}t.text(a,n.X+s,n.Y,{baseline:"top",maxWidth:h}),n.updateX(t.getTextDimensions(a).w+(s>=2?a.split(" ").length+2:2)*l(p)*.5+(d?o*2:0),"add")}};if(e.type==="text"&&e.items&&e.items.length>0)for(const a of e.items)if(a.type==="codespan")i(a.content||"","codespan");else if(a.type==="em"||a.type==="strong"){const p=a.type==="em"?"italic":"bold";if(a.items&&a.items.length>0)for(const h of a.items)h.type==="strong"&&p==="italic"||h.type==="em"&&p==="bold"?i(h.content||"","bolditalic"):i(h.content||"",p);else i(a.content||"",p)}else i(a.content||"","normal");else e.type==="em"?i(e.content||"","italic"):e.type==="strong"?i(e.content||"","bold"):e.type==="codespan"?i(e.content||"","codespan"):i(e.content||"","normal");t.setFont(c,g),t.setFontSize(r)},rt=(t,e,s)=>{const c=t.getFont().fontName,g=t.getFont().fontStyle,r=t.getFontSize(),l=t.getTextColor(),i=n.options.link?.linkColor||[0,0,255];t.setTextColor(...i);const a=n.options.page.maxContentWidth-s-n.X,p=e.text||e.content||"",h=e.href||"",f=t.splitTextToSize(p,a);if(n.isInlineLockActive)for(let d=0;d<f.length;d++){const o=t.getTextDimensions(f[d]).w,m=C(t)/2;t.link(n.X+s,n.Y,o,m,{url:h}),t.text(f[d],n.X+s,n.Y,{baseline:"top",maxWidth:a}),n.updateX(o+1,"add"),n.X+o>n.options.page.maxContentWidth-s&&(n.updateY(m,"add"),n.updateX(n.options.page.xpading+s,"set")),d<f.length-1&&(n.updateY(m,"add"),n.updateX(n.options.page.xpading+s,"set"))}else if(f.length>1){const d=f[0],o=f?.slice(1)?.join(" "),m=t.getTextDimensions(d).w,x=C(t)/2;t.link(n.X+s,n.Y,m,x,{url:h}),t.text(d,n.X+s,n.Y,{baseline:"top",maxWidth:a}),n.updateX(n.options.page.xpading+s),n.updateY(x,"add");const F=n.options.page.maxContentWidth-s-n.options.page.xpading;t.splitTextToSize(o,F).forEach(y=>{const w=t.getTextDimensions(y).w;t.link(n.X+Y(t),n.Y,w,x,{url:h}),t.text(y,n.X+Y(t),n.Y,{baseline:"top",maxWidth:F})})}else{const d=t.getTextDimensions(p).w,o=C(t)/2;t.link(n.X+s,n.Y,d,o,{url:h}),t.text(p,n.X+s,n.Y,{baseline:"top",maxWidth:a}),n.updateX(d+2,"add")}t.setFont(c,g),t.setFontSize(r),t.setTextColor(l)},lt=(t,e,s,c)=>{const g=n.options,r=s+1,l=n.X+s*g.page.indent,i=n.Y,a=l+g.page.indent/2,p=i,h=t.internal.getCurrentPageInfo().pageNumber;e.items&&e.items.length>0&&e.items.forEach(o=>{c(o,r)});const f=n.Y,d=t.internal.getCurrentPageInfo().pageNumber;t.setDrawColor(100),t.setLineWidth(1);for(let o=h;o<=d;o++){t.setPage(o);const m=o===h,x=o===d,F=m?p:g.page.topmargin,b=x?f:g.page.maxContentHeight;t.line(a,F,a,b)}n.recordContentY(),t.setPage(d)},P=96,ct=t=>{if(t.data){if(t.data.startsWith("data:image/png"))return"PNG";if(t.data.startsWith("data:image/jpeg")||t.data.startsWith("data:image/jpg"))return"JPEG";if(t.data.startsWith("data:image/webp"))return"WEBP";if(t.data.startsWith("data:image/gif"))return"GIF"}return t.src?.split(".").pop()?.toUpperCase()||"JPEG"},L=(t,e="mm")=>{switch(e){case"pt":return t*72/P;case"in":return t/P;case"px":return t;default:return t*25.4/P}},gt=(t,e,s)=>{if(!e.data)return;const c=n.options,g=c.page.unit||"mm",r=s*c.page.indent,l=c.page.maxContentWidth-r,i=n.X+r;let a=n.Y;try{const p=t.getImageProperties(e.data),h=p.width,f=p.height,d=f>0?h/f:1;let o,m;if(e.width&&e.height?(o=L(e.width,g),m=L(e.height,g)):e.width?(o=L(e.width,g),m=o/d):e.height?(m=L(e.height,g),o=m*d):(o=L(h,g),m=L(f,g)),o>l){const w=l/o;o=l,m=m*w}const x=c.page.maxContentHeight-c.page.topmargin;if(m>x){const w=x/m;m=x,o=o*w}a+m>c.page.maxContentHeight&&(k(t),a=n.Y);const F=e.align||c.image?.defaultAlign||"left";let b;switch(F){case"right":b=i+l-o;break;case"center":b=i+(l-o)/2;break;default:b=i;break}const y=ct(e);t.addImage(e.data,y,b,a,o,m),n.updateY(m,"add"),n.recordContentY()}catch(p){console.warn("Failed to render image",p)}},pt=(t,e,s)=>{if(!e.header||!e.rows)return;const c=n.options,g=c.page.xmargin+s*c.page.indent,r=[e.header.map(a=>a.content||"")],l=e.rows.map(a=>a.map(p=>p.content||"")),i=c.table||{};q(t,{head:r,body:l,startY:n.Y,margin:{left:g,right:c.page.xmargin},...i,didDrawPage:a=>{i.didDrawPage&&i.didDrawPage(a)},didDrawCell:a=>{i.didDrawCell&&i.didDrawCell(a),n.setCursor({x:n.X,y:a.cell.y+2*c.page.lineSpace})}})},$=async t=>{for(const e of t){if(e.type===u.Image&&e.src)try{if(e.src.startsWith("data:"))e.data=e.src;else{const s=await fetch(e.src);if(!s.ok)throw new Error(`Failed to fetch image: ${s.statusText}`);const c=await s.blob(),g=await new Promise((r,l)=>{const i=new FileReader;i.onloadend=()=>{typeof i.result=="string"?r(i.result):l(new Error("Failed to convert image to base64 string"))},i.onerror=l,i.readAsDataURL(c)});e.data=g}}catch(s){console.warn(`[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,s)}e.items&&e.items.length>0&&await $(e.items)}},D={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"}},image:{defaultAlign:"left"}},ht=t=>{if(!t)throw new Error("RenderOption is required");const e={...D.page,...t.page},s={...D.font,...t.font},c={...D.image,...t.image};return e.maxContentWidth||(e.maxContentWidth=190),e.maxContentHeight||(e.maxContentHeight=277),{...t,page:e,font:s,image:c}},ft=async(t,e,s)=>{const c=ht(s);n.initialize(c);const g=await _(e);await $(g);const r=(l,i=0,a=!1,p=0,h=!1,f=!0)=>{const d=i*c.page.indent;switch(l.type){case u.Heading:M(t,l,d,r);break;case u.Paragraph:tt(t,l,d,r);break;case u.List:et(t,l,i,r);break;case u.ListItem:nt(t,l,i,r,p,h);break;case u.Hr:it(t);break;case u.Code:at(t,l,i);break;case u.Strong:case u.Em:case u.CodeSpan:ot(t,l,d);break;case u.Link:rt(t,l,d);break;case u.Blockquote:lt(t,l,i,r);break;case u.Image:gt(t,l,i);break;case u.Table:pt(t,l,i);break;case u.Raw:case u.Text:st(t,l,i,a,r,p,h,c.page.defaultFontSize>0);break;default:console.warn(`Warning: Unsupported element type encountered: ${l.type}.
3
2
  If you believe this element type should be supported, please create an issue at:
4
3
  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 l of r)a(l);i.endCursorYHandler(g.Y)};exports.MdTextParser=rt;exports.MdTextRender=we;
4
+ with details of the element and expected behavior. Thanks for helping to improve this library!`);break}};for(const l of g)r(l);c.endCursorYHandler(n.Y)};exports.MdTextParser=_;exports.MdTextRender=ft;