html-in-pptx-out 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Christopher Alden
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # html-in-pptx-out
2
+
3
+ Convert HTML to PowerPoint with a plugin architecture.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/html-in-pptx-out.svg)](https://www.npmjs.com/package/html-in-pptx-out)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install html-in-pptx-out pptxgenjs
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ import { HtmlToPptx } from "html-in-pptx-out";
18
+
19
+ const html = `
20
+ <div class="slide">
21
+ <h1>Title</h1>
22
+ <p>Content</p>
23
+ </div>
24
+ `;
25
+
26
+ const converter = new HtmlToPptx();
27
+ await converter.load(html).convert();
28
+
29
+ const buffer = await converter.export({
30
+ format: "pptx",
31
+ filename: "output.pptx",
32
+ });
33
+ ```
34
+
35
+ ## CLI
36
+
37
+ ```bash
38
+ npx html-in-pptx-out input.html output.pptx
39
+ npx html-in-pptx-out input.html output.pptx --selector ".page"
40
+ ```
41
+
42
+ ## Core Plugins
43
+
44
+ Built-in plugins for common element types:
45
+
46
+ - `core:text` - Text elements with typography
47
+ - `core:shape` - Rectangles, rounded rectangles with fill/stroke
48
+ - `core:image` - Images (base64, URLs)
49
+ - `core:table` - HTML tables
50
+ - `core:line` - Horizontal/vertical lines
51
+ - `core:chart-plotly` - Plotly.js charts
52
+ - `core:fontawesome` - Font Awesome icons
53
+
54
+ ## Architecture
55
+
56
+ ```
57
+ HTML → Parser → Plugins (onParse) → ElementDTOs → Plugins (onSlide) → Serializer → PPTX
58
+ ```
59
+
60
+ ### Plugin Lifecycle
61
+
62
+ 1. **beforeParse** - Modify HTML before parsing
63
+ 2. **onParse** - Transform DOM element to ElementDTO
64
+ 3. **onSlide** - Modify slide after all elements parsed
65
+ 4. **afterGenerate** - Post-process the PPTX object
66
+
67
+ ### Custom Plugin
68
+
69
+ ```typescript
70
+ import { Plugin, TextElementDTO } from "html-in-pptx-out";
71
+
72
+ const myPlugin: Plugin<TextElementDTO> = {
73
+ name: "my-plugin",
74
+ handles: ["text"],
75
+ onParse: (element, context) => {
76
+ return {
77
+ type: "text",
78
+ id: crypto.randomUUID(),
79
+ content: element.textContent || "",
80
+ position: {
81
+ left: context.boundingRect.left,
82
+ top: context.boundingRect.top,
83
+ },
84
+ dimensions: {
85
+ width: context.boundingRect.width,
86
+ height: context.boundingRect.height,
87
+ },
88
+ };
89
+ },
90
+ };
91
+
92
+ const converter = new HtmlToPptx().use(myPlugin);
93
+ ```
94
+
95
+ ## API
96
+
97
+ ```typescript
98
+ class HtmlToPptx {
99
+ constructor(config?: {
100
+ selector?: string; // default: ".slide"
101
+ dimensions?: { width: number; height: number };
102
+ plugins?: { core?: Plugin[]; extensions?: Plugin[] };
103
+ });
104
+
105
+ load(html: string): this;
106
+ use(plugin: Plugin): this;
107
+ convert(): Promise<this>;
108
+ export(options: ExportConfig): Promise<ArrayBuffer>;
109
+ getPresentation(): PresentationDTO;
110
+ }
111
+ ```
112
+
113
+ ## Types
114
+
115
+ Core types exported from the package:
116
+
117
+ - `ElementDTO` - Union of all element types
118
+ - `TextElementDTO`, `ShapeElementDTO`, `ImageElementDTO`, etc.
119
+ - `Position`, `Dimensions`, `Typography`, `Fill`, `Stroke`
120
+ - `Plugin`, `ParseContext`, `PluginContext`
121
+ - `PresentationDTO`, `SlideDTO`
122
+
123
+ See [docs/api.md](docs/api.md) for full type reference.
124
+
125
+ ## Demo
126
+
127
+ ```bash
128
+ npm run demo
129
+ # Open http://localhost:3000/demo
130
+ ```
131
+
132
+ ## Requirements
133
+
134
+ - Node.js >= 20.19.0
135
+ - pptxgenjs ^3.12.0 (peer dependency)
136
+
137
+ ## License
138
+
139
+ MIT
package/dist/cli.cjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const e=require(`./converter-DDaOhRYr.cjs`);let t=require(`fs/promises`),n=require(`path`);function r(t){let n=`${e.a.dim}[html-in-pptx-out]${e.a.reset}`;return{error:()=>{console.error(`${n} ${e.a.red}Error:${e.a.reset}\n${t}`)},info:()=>{console.log(`${n} ${t}`)},success:()=>{console.log(`${n} ${e.a.green}${t}${e.a.reset}`)}}}async function i(){let i=process.argv.slice(2),a=[],o=`.slide`;for(let e=0;e<i.length;e++)i[e]===`--selector`&&e+1<i.length?(o=i[e+1],e++):i[e].startsWith(`--`)||a.push(i[e]);a.length<2&&(r(`Usage: html-in-pptx-out <input.html> <output.pptx> [--selector <selector>]`).error(),process.exit(1));let[s,c]=a,l=(0,n.resolve)(s),u=(0,n.resolve)(c),d=await(0,t.readFile)(l,`utf-8`),f=new e.t({selector:o});await f.load(d).convert();let p=await f.export({format:`pptx`,filename:u});await(0,t.writeFile)(u,Buffer.from(p)),r(`exported: ${u}`).success()}i().catch(e=>{console.error(e.message),process.exit(1)});
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{a as e,t}from"./converter-B7cokS5k.mjs";import{readFile as n,writeFile as r}from"fs/promises";import{resolve as i}from"path";function a(t){let n=`${e.dim}[html-in-pptx-out]${e.reset}`;return{error:()=>{console.error(`${n} ${e.red}Error:${e.reset}\n${t}`)},info:()=>{console.log(`${n} ${t}`)},success:()=>{console.log(`${n} ${e.green}${t}${e.reset}`)}}}async function o(){let e=process.argv.slice(2),o=[],s=`.slide`;for(let t=0;t<e.length;t++)e[t]===`--selector`&&t+1<e.length?(s=e[t+1],t++):e[t].startsWith(`--`)||o.push(e[t]);o.length<2&&(a(`Usage: html-in-pptx-out <input.html> <output.pptx> [--selector <selector>]`).error(),process.exit(1));let[c,l]=o,u=i(c),d=i(l),f=await n(u,`utf-8`),p=new t({selector:s});await p.load(f).convert();let m=await p.export({format:`pptx`,filename:d});await r(d,Buffer.from(m)),a(`exported: ${d}`).success()}o().catch(e=>{console.error(e.message),process.exit(1)});export{};
3
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":["positional: string[]"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFile, writeFile } from \"fs/promises\";\nimport { resolve } from \"path\";\nimport { HtmlToPptx } from \"@/core/converter\";\nimport { ANSI } from \"@/constants\";\n\nfunction log(text: string): {\n error: () => void;\n info: () => void;\n success: () => void;\n} {\n const tag = `${ANSI.dim}[html-in-pptx-out]${ANSI.reset}`;\n return {\n error: () => {\n console.error(`${tag} ${ANSI.red}Error:${ANSI.reset}\\n${text}`);\n },\n info: () => {\n console.log(`${tag} ${text}`);\n },\n success: () => {\n console.log(`${tag} ${ANSI.green}${text}${ANSI.reset}`);\n },\n };\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const positional: string[] = [];\n let selector = \".slide\";\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === \"--selector\" && i + 1 < args.length) {\n selector = args[i + 1];\n i++;\n } else if (!args[i].startsWith(\"--\")) {\n positional.push(args[i]);\n }\n }\n\n if (positional.length < 2) {\n log(\n \"Usage: html-in-pptx-out <input.html> <output.pptx> [--selector <selector>]\",\n ).error();\n process.exit(1);\n }\n\n const [inputPath, outputPath] = positional;\n const inputResolved = resolve(inputPath);\n const outputResolved = resolve(outputPath);\n\n const html = await readFile(inputResolved, \"utf-8\");\n\n const converter = new HtmlToPptx({\n selector: selector,\n });\n\n await converter.load(html).convert();\n\n const buffer = await converter.export({\n format: \"pptx\",\n filename: outputResolved,\n });\n\n await writeFile(outputResolved, Buffer.from(buffer));\n\n log(`exported: ${outputResolved}`).success();\n}\n\nmain().catch((err) => {\n console.error(err.message);\n process.exit(1);\n});\n"],"mappings":";oIAMA,SAAS,EAAI,EAIX,CACA,IAAM,EAAM,GAAG,EAAK,IAAI,oBAAoB,EAAK,QACjD,MAAO,CACL,UAAa,CACX,QAAQ,MAAM,GAAG,EAAI,GAAG,EAAK,IAAI,QAAQ,EAAK,MAAM,IAAI,IAAO,EAEjE,SAAY,CACV,QAAQ,IAAI,GAAG,EAAI,GAAG,IAAO,EAE/B,YAAe,CACb,QAAQ,IAAI,GAAG,EAAI,GAAG,EAAK,QAAQ,IAAO,EAAK,QAAQ,EAE1D,CAGH,eAAe,GAAsB,CACnC,IAAM,EAAO,QAAQ,KAAK,MAAM,EAAE,CAC5BA,EAAuB,EAAE,CAC3B,EAAW,SAEf,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAC3B,EAAK,KAAO,cAAgB,EAAI,EAAI,EAAK,QAC3C,EAAW,EAAK,EAAI,GACpB,KACU,EAAK,GAAG,WAAW,KAAK,EAClC,EAAW,KAAK,EAAK,GAAG,CAIxB,EAAW,OAAS,IACtB,EACE,6EACD,CAAC,OAAO,CACT,QAAQ,KAAK,EAAE,EAGjB,GAAM,CAAC,EAAW,GAAc,EAC1B,EAAgB,EAAQ,EAAU,CAClC,EAAiB,EAAQ,EAAW,CAEpC,EAAO,MAAM,EAAS,EAAe,QAAQ,CAE7C,EAAY,IAAI,EAAW,CACrB,WACX,CAAC,CAEF,MAAM,EAAU,KAAK,EAAK,CAAC,SAAS,CAEpC,IAAM,EAAS,MAAM,EAAU,OAAO,CACpC,OAAQ,OACR,SAAU,EACX,CAAC,CAEF,MAAM,EAAU,EAAgB,OAAO,KAAK,EAAO,CAAC,CAEpD,EAAI,aAAa,IAAiB,CAAC,SAAS,CAG9C,GAAM,CAAC,MAAO,GAAQ,CACpB,QAAQ,MAAM,EAAI,QAAQ,CAC1B,QAAQ,KAAK,EAAE,EACf"}
@@ -0,0 +1,5 @@
1
+ import e from"pptxgenjs";var t=class{plugins=[];context={presentation:void 0,metadata:{},state:new Map};register(e){if(this.plugins.some(t=>t.name===e.name))throw Error(`Plugin "${e.name}" is already registered`);this.plugins.push(e)}unregister(e){let t=this.plugins.findIndex(t=>t.name===e);t!==-1&&this.plugins.splice(t,1)}getPlugins(){return[...this.plugins]}setPresentation(e){this.context.presentation=e}async executeBeforeParse(e,t){let n=e;for(let e of this.plugins)e.beforeParse&&(n=await e.beforeParse(n,t,this.context));return n}async executeOnParse(e,t){for(let n of this.plugins){if(!n.handles||!n.onParse||!new Set(n.handles).has(t.elementType))continue;let r=await n.onParse(e,t,this.context);if(r)return r}return null}async executeOnSlide(e){let t=e;for(let e of this.plugins)e.onSlide&&(t=await e.onSlide(t,this.context));return t}async executeAfterGenerate(e,t){for(let n of this.plugins)n.afterGenerate&&await n.afterGenerate(e,t,this.context)}},n=class extends Error{constructor(e){super(`Assertion failed: ${e}`),this.name=`AssertionError`}};function r(e,t){if(!e)throw new n(t)}function i(e,t){if(e==null)throw new n(t)}const a=e=>e.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``).trim()).filter(e=>e!=null).join(`, `),o=e=>{if(!e||e===`transparent`)return``;let t=e.trim().replace(/^#/,``);if(/^[0-9a-fA-F]{3}$/.test(t))return t[0]+t[0]+t[1]+t[1]+t[2]+t[2];if(/^[0-9a-fA-F]{6}$/.test(t))return t;let n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(n){let[,e,t,r]=n;return[e,t,r].map(e=>parseInt(e,10).toString(16).padStart(2,`0`)).join(``)}return``},s=e=>{let t=parseInt(e,10);if(!isNaN(t))return String(t);if(e===`bold`||e===`bolder`)return`700`;if(e===`lighter`)return`300`;if(e===`normal`)return`400`},c=e=>{if(e===`italic`)return`italic`;if(e===`oblique`)return`oblique`;if(e===`normal`)return`normal`},l=e=>{if(e===`left`||e===`start`)return`left`;if(e===`center`)return`center`;if(e===`right`||e===`end`)return`right`;if(e===`justify`)return`justify`},u=e=>{if(e===`top`)return`top`;if(e===`middle`)return`middle`;if(e===`bottom`)return`bottom`},d=e=>({fontFamily:a(e.fontFamily)||B.FONT_FAMILY,fontSize:parseFloat(e.fontSize)||void 0,fontWeight:s(e.fontWeight),fontStyle:c(e.fontStyle),letterSpacing:parseFloat(e.letterSpacing)||void 0,lineHeight:parseFloat(e.lineHeight)||void 0,color:o(e.color)||void 0,underline:e.textDecorationLine?.includes(`underline`)||!1,strikethrough:e.textDecorationLine?.includes(`line-through`)||!1,textAlign:l(e.textAlign),verticalAlign:u(e.verticalAlign)}),f=e=>({top:parseFloat(e.paddingTop)||0,right:parseFloat(e.paddingRight)||0,bottom:parseFloat(e.paddingBottom)||0,left:parseFloat(e.paddingLeft)||0}),p=e=>{let t=e.transform;if(!t||t===`none`)return;let n=t.match(/rotate\(([-\d.]+)/);if(n)return parseFloat(n[1])||void 0;let r=t.match(/matrix\(([^)]+)\)/);if(r){let e=r[1].split(`,`).map(e=>parseFloat(e.trim()));if(e.length>=2){let t=e[0],n=e[1],r=Math.atan2(n,t)*(180/Math.PI);return Math.abs(r)<.01?void 0:r}}},m=e=>{let t=parseFloat(e.opacity);return t===1?void 0:t||void 0},h=e=>parseInt(e.zIndex,10)||void 0,g=(e,t)=>({left:e.left-t.left,top:e.top-t.top}),_=(e,t=1)=>({width:e.width*t,height:e.height}),v=new Set([`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`p`,`span`,`div`,`a`,`li`,`label`,`strong`,`em`,`b`,`u`,`s`,`small`,`mark`]),y=new Set([`img`,`picture`,`svg`]),ee=new Set([`table`]),te=new Set([`td`,`th`,`tr`,`thead`,`tbody`,`tfoot`,`caption`,`colgroup`,`col`]),ne=(e,t=window)=>{let n=[],r=e.tagName.toLowerCase();if(ee.has(r))return n.push(`table`),n;if(te.has(r))return n;if(e.id.toLowerCase().includes(`chart`)&&n.push(`chart`),y.has(r))return n.push(`image`),n;if(r===`hr`)return n.push(`line`),n;if(x(e))return n.push(`icon`),n;let i=t.getComputedStyle(e);return re(i)&&n.push(`shape`),oe(i)&&n.push(`line`),v.has(r)&&ae(e)&&n.push(`text`),n},re=e=>{let t=e.backgroundColor!==`transparent`&&e.backgroundColor!==`rgba(0, 0, 0, 0)`,n=e.backgroundImage!==`none`&&e.backgroundImage!==``,r=parseFloat(e.borderWidth)>0&&e.borderColor!==`transparent`&&e.borderColor!==`rgba(0, 0, 0, 0)`,i=e.boxShadow!==`none`&&e.boxShadow!==``,a=parseFloat(e.borderRadius)>0;return t||n||r||i||a},b=e=>{let t=e.toLowerCase();return v.has(e)?/^h[1-6]$/.test(t)?t:t===`p`?`p`:`body`:null},ie=(e,t)=>{let n=parseFloat(e.borderRadius)||0,{width:r,height:i}=t;return n>=Math.min(r,i)/2*.9&&Math.abs(r-i)<2?`ellipse`:n>0?`roundRect`:`rect`},ae=e=>{for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&t.textContent&&t.textContent.trim().length>0)return!0;return!1},oe=e=>{let t=parseFloat(e.borderLeftWidth)||0,n=parseFloat(e.borderRightWidth)||0,r=parseFloat(e.borderTopWidth)||0,i=parseFloat(e.borderBottomWidth)||0,a=[{side:`left`,width:t},{side:`right`,width:n},{side:`top`,width:r},{side:`bottom`,width:i}].filter(e=>e.width>0);return a.length===1?a[0].side:null},x=e=>e.tagName.toLowerCase()===`i`?Array.from(e.classList).some(e=>e.startsWith(`fa-`)&&e!==`fa`):!1,S=e=>{let t=[];for(let n of e.childNodes){if(n.nodeType===Node.TEXT_NODE){let e=n.textContent?.replace(/\s+/g,` `)||``;e.trim().length>0&&t.push({content:e})}if(n.nodeType===Node.ELEMENT_NODE){let e=n,r=e.tagName.toLowerCase();if(r===`br`){t.push({content:`
2
+ `});continue}let i=e.className||``,a=e.ownerDocument.defaultView.getComputedStyle(e),o=S(e);if(!b(r))continue;let s={content:e.textContent||``,tagName:r,className:i,typography:d(a),children:o.length>0?o:void 0};r===`a`&&(s.href=e.getAttribute(`href`)||void 0),t.push(s)}}return t},se=e=>{let t=``,n=e=>{if(e.nodeType===Node.TEXT_NODE){t+=e.textContent||``;return}if(e.nodeType===Node.ELEMENT_NODE){let r=e.tagName.toLowerCase();if(r===`br`){t+=`
3
+ `;return}for(let t of e.childNodes)n(t);(r===`p`||r===`div`)&&e.nextSibling&&(t+=`
4
+ `)}};for(let t of e.childNodes)n(t);return t.trim()},ce=(e,t)=>{let n=e.querySelectorAll(`i`),r=0;for(let e of n)if(x(e)){let t=e.getBoundingClientRect().width,n=e.ownerDocument.defaultView.getComputedStyle(e),i=parseFloat(n.marginRight)||0;r+=t+i}return new DOMRect(t.left+r,t.top,t.width-r,t.height)},C={name:`core:text`,handles:[`text`],onParse:(e,t)=>{let{computedStyle:n,boundingRect:r,tagName:i,slideElement:a}=t,o=e.textContent?.trim();if(!o)return null;let s=b(i);if(!s)return null;let c=a.getBoundingClientRect(),l=ce(e,r),u=g(l,c),v=_(l,Pe),y=S(e);return{type:`text`,id:crypto.randomUUID(),content:o,runs:y.length>0?y:void 0,position:u,dimensions:v,typography:d(n),textType:s,padding:f(n),zIndex:h(n),rotation:p(n),opacity:m(n)}}},w=e=>{let t=e.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/);if(t){let e=parseFloat(t[1]);if(e<1)return e}},T=e=>{let t=[],n=/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,6}|\w+)\s*([\d.]+%)?/g,r,i=0;for(;(r=n.exec(e))!==null;){let[,e,n]=r,a=o(e);if(!a)continue;let s=0;s=n?parseFloat(n)/100:i===0?0:1;let c=w(e);t.push({color:a,position:s,opacity:c}),i++}return t},le=e=>{let t=e.match(/(\d+)deg/);if(t)return parseInt(t[1],10);for(let[t,n]of Object.entries({"to top":0,"to right":90,"to bottom":180,"to left":270,"to top right":45,"to bottom right":135,"to bottom left":225,"to top left":315}))if(e.includes(t))return n;return 180},E=e=>{let t=e.backgroundImage;if(t&&t!==`none`){if(t.includes(`linear-gradient`)){let e=T(t);if(e.length>=2)return{type:`gradient`,gradientType:`linear`,angle:le(t),stops:e}}if(t.includes(`radial-gradient`)){let e=T(t);if(e.length>=2)return{type:`gradient`,gradientType:`radial`,stops:e}}}let n=e.backgroundColor;if(!n||n===`transparent`||n===`rgba(0, 0, 0, 0)`)return;let r=o(n);if(r)return{type:`solid`,color:r,opacity:w(n)}},ue=e=>{let t=parseFloat(e.borderWidth)||0;if(t===0)return;let n=e.borderColor,r=o(n);if(!r)return;let i=e.borderStyle,a=`solid`;i===`dashed`?a=`dashed`:i===`dotted`&&(a=`dotted`);let s,c=n.match(/rgba?\([^)]+,\s*([\d.]+)\)/);if(c){let e=parseFloat(c[1]);e<1&&(s=e)}return{color:r,width:t,style:a,opacity:s}},de=e=>{let t=parseFloat(e.borderRadius)||0;if(t!==0)return t},D={name:`core:shape`,handles:[`shape`],onParse:(e,t)=>{let{computedStyle:n,boundingRect:r,slideElement:i}=t,a=i.getBoundingClientRect();return{type:`shape`,id:crypto.randomUUID(),shapeType:ie(n,r),position:g(r,a),dimensions:_(r),fill:E(n),stroke:ue(n),borderRadius:de(n),zIndex:h(n),rotation:p(n),opacity:m(n)}}},fe=(e,t)=>{let n=1,r=`rgb(0,0,0)`,i=`solid`;t===`left`?(n=parseFloat(e.borderLeftWidth)||1,r=e.borderLeftColor||`rgb(0,0,0)`,i=e.borderLeftStyle||`solid`):t===`right`?(n=parseFloat(e.borderRightWidth)||1,r=e.borderRightColor||`rgb(0,0,0)`,i=e.borderRightStyle||`solid`):t===`top`?(n=parseFloat(e.borderTopWidth)||1,r=e.borderTopColor||`rgb(0,0,0)`,i=e.borderTopStyle||`solid`):(n=parseFloat(e.borderBottomWidth)||1,r=e.borderBottomColor||`rgb(0,0,0)`,i=e.borderBottomStyle||`solid`);let a=o(r)||`000000`,s=`solid`;i===`dashed`?s=`dashed`:i===`dotted`&&(s=`dotted`);let c,l=r.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/);if(l){let e=parseFloat(l[1]);e<1&&(c=e)}return{color:a,width:n,style:s,opacity:c}},pe=(e,t,n)=>{let r=e.left-t.left,i=e.top-t.top,a=r+e.width,o=i+e.height;return n===`left`?{start:{left:r,top:i},end:{left:r,top:o}}:n===`right`?{start:{left:a,top:i},end:{left:a,top:o}}:n===`top`?{start:{left:r,top:i},end:{left:a,top:i}}:{start:{left:r,top:o},end:{left:a,top:o}}},O={name:`core:line`,handles:[`line`],onParse:(e,t)=>{let{computedStyle:n,boundingRect:r,tagName:i,slideElement:a}=t,s=a.getBoundingClientRect(),c,l,u;if(i===`hr`){let e=r.left-s.left,t=r.top-s.top,i=e+r.width;l={left:e,top:t},u={left:i,top:t};let a=parseFloat(n.borderTopWidth)||1;c={color:o(n.borderTopColor||`rgb(0,0,0)`)||`000000`,width:a,style:`solid`}}else{let e=oe(n);if(!e)return null;let t=pe(r,s,e);l=t.start,u=t.end,c=fe(n,e)}return{type:`line`,id:crypto.randomUUID(),start:l,end:u,stroke:c,zIndex:h(n),rotation:p(n),opacity:m(n)}}},k=(e,t,n)=>{if(t===0)return;let r=o(e);if(!r)return;let i=`solid`;n===`dashed`?i=`dashed`:n===`dotted`&&(i=`dotted`);let a=w(e);return{color:r,width:t,style:i,opacity:a}},A=e=>{let t=parseFloat(e.borderTopWidth)||0,n=parseFloat(e.borderRightWidth)||0,r=parseFloat(e.borderBottomWidth)||0,i=parseFloat(e.borderLeftWidth)||0;if(!(t>0||n>0||r>0||i>0))return;let a={};return t>0&&(a.top=k(e.borderTopColor,t,e.borderTopStyle)),n>0&&(a.right=k(e.borderRightColor,n,e.borderRightStyle)),r>0&&(a.bottom=k(e.borderBottomColor,r,e.borderBottomStyle)),i>0&&(a.left=k(e.borderLeftColor,i,e.borderLeftStyle)),a},me=e=>{let t=e.ownerDocument,n=t.defaultView.getComputedStyle(e),r=E(n),i=A(n),a=e.parentElement;if(a){let e=t.defaultView.getComputedStyle(a);r||=E(e),i||=A(e)}let o={id:crypto.randomUUID(),text:se(e),typography:d(n),fill:r,border:i};return e.colSpan>1&&(o.colspan=e.colSpan),e.rowSpan>1&&(o.rowspan=e.rowSpan),o},he=e=>{let t=[],n=e.querySelectorAll(`tr`);for(let e of n){let n=[],r=e.querySelectorAll(`th, td`);for(let e of r)n.push(me(e));n.length>0&&t.push(n)}return t},ge=e=>{let t=e.querySelector(`tr`);if(!t)return[];let n=t.querySelectorAll(`th, td`);if(n.length===0)return[];let r=[];for(let e of n){let t=e.getBoundingClientRect().width;r.push(t)}return r},j={name:`core:table`,handles:[`table`],onParse:(e,t)=>{let{boundingRect:n,slideElement:r}=t,i=e,a=r.getBoundingClientRect(),o=he(i);if(o.length===0)return null;let s=i.querySelector(`thead`)!==null,c=i.querySelector(`th`)!==null,l=ge(i);return{type:`table`,id:crypto.randomUUID(),position:g(n,a),dimensions:_(n),rows:o,colWidths:l.length>0?l:void 0,headerRow:s||c}}},_e=e=>{if(!e||typeof e!=`object`)return`unknown`;let t=e;return Array.isArray(t.data)&&t.data.length>0&&t.data[0]&&typeof t.data[0]==`object`&&`type`in t.data[0]?`plotly`:`unknown`},ve=e=>{let t=new Map;return e.querySelectorAll(`script[type="application/json"][data-chart-id]`).forEach(n=>{let r=n.getAttribute(`data-chart-id`),i=n.getAttribute(`data-chart-type`);if(!(!r||!i)&&e.getElementById(r))try{let e=JSON.parse(n.textContent||`{}`),a=e;if(!(Array.isArray(a.data)&&a.data.length>0&&a.data[0]&&typeof a.data[0]==`object`&&`type`in a.data[0]))return;let o=_e(e),s=a.data[0].type;t.set(r,{chartId:r,chartType:s||i,config:e,sourceLibrary:o})}catch{return}}),t},M=e=>Array.isArray(e)?e.map(e=>e==null?``:String(e)):[],N=e=>Array.isArray(e)?e.map(e=>{let t=Number(e);return isNaN(t)?0:t}):[],ye=e=>{for(let t of e){if(t.labels&&Array.isArray(t.labels))return M(t.labels);if(t.orientation===`h`&&t.y&&Array.isArray(t.y))return M(t.y);if(t.x&&Array.isArray(t.x))return M(t.x)}return[]},be=e=>{if(e.marker?.color&&typeof e.marker.color==`string`)return e.marker.color;if(e.line?.color&&typeof e.line.color==`string`)return e.line.color},xe=e=>{if(e.marker?.colors&&Array.isArray(e.marker.colors))return e.marker.colors;if(e.marker?.color&&Array.isArray(e.marker.color))return e.marker.color},Se=e=>{if(e.title){if(typeof e.title==`string`)return e.title;if(typeof e.title==`object`&&e.title.text)return e.title.text}},Ce=e=>{if(e.title){if(typeof e.title==`string`)return 11;if(typeof e.title==`object`&&e.title.font)return e.title.font.size}},P=e=>{if(!(!e||!e.title)){if(typeof e.title==`string`)return e.title;if(typeof e.title==`object`&&e.title.text)return e.title.text}},we=e=>{let t=e.data||[],n=e.layout||{};if(t.length===0)throw Error(`No traces found in config.data`);let r=t[0],i=W[(r?.type||`bar`).toLowerCase()]||`bar`,a=ye(t),o=t.map(e=>{let t={name:e.name||`Series`,values:[],color:be(e),colors:xe(e)},n=e.type||`bar`;return t.chartType=W[n.toLowerCase()]||n,e.values?t.values=N(e.values):e.orientation===`h`&&e.x?t.values=N(e.x):e.y&&(t.values=N(e.y)),e.yaxis===`y2`?t.yAxis=`y2`:e.yaxis===`y3`&&(t.yAxis=`y3`),t}),s={title:Se(n),titleFontSize:Ce(n),showLegend:n.showlegend!==!1,xAxisTitle:P(n.xaxis),yAxisTitle:P(n.yaxis),margin:n.margin};return n.yaxis2&&(s.hasSecondaryAxis=!0,s.yAxis2Title=P(n.yaxis2)),(t.some(e=>e.text&&Array.isArray(e.text)&&e.text.length>0)||r.textinfo)&&(s.showDataLabels=!0),i===`bar`&&(s.orientation=r.orientation===`h`?`horizontal`:`vertical`,n.barmode===`stack`?(s.barGrouping=`stacked`,s.barmode=`stack`):n.barmode===`group`?(s.barGrouping=`clustered`,s.barmode=`group`):n.barmode===`relative`&&(s.barGrouping=`percentStacked`,s.barmode=`relative`),r.textposition&&(s.dataLabelPosition=r.textposition)),i===`pie`&&(r.hole!==void 0&&(s.hole=r.hole),r.textinfo&&(s.dataLabelFormat=r.textinfo),r.textposition&&(s.dataLabelPosition=r.textposition)),n.font&&(s.font={family:n.font.family,size:n.font.size}),{chartType:i,series:o,labels:a,options:s}},F={name:`core:chart-plotly`,handles:[`chart`],beforeParse:(e,t,n)=>{let r=ve(new DOMParser().parseFromString(e,`text/html`));if(r.size===0)return e;let i={extractedCharts:r,chartBoundsMap:new Map};return n.state.set(F.name,i),e},onParse:(e,t,n)=>{let r=n.state.get(F.name);if(!r||r.extractedCharts.size===0)return null;let i=e.ownerDocument,{slideIndex:a,slideElement:o}=t,s=o.getBoundingClientRect();return r.extractedCharts.forEach((e,t)=>{if(r.chartBoundsMap.has(t))return;let n=i.getElementById(t);if(!n||!o.contains(n))return;let c=n.getBoundingClientRect();r.chartBoundsMap.set(t,{left:c.left-s.left,top:c.top-s.top,width:c.width,height:c.height,slideIndex:a})}),null},onSlide:(e,t)=>{let n=t.state.get(F.name);if(!n||n.extractedCharts.size===0||n.chartBoundsMap.size===0)return e;let{extractedCharts:r,chartBoundsMap:i}=n,a=new Set,o=[];r.forEach((t,n)=>{let r=i.get(n);if(!r||r.slideIndex!==e.order)return;let s=-1,c=1/0;if(e.elements.forEach((e,t)=>{if(e.type!==`image`||a.has(t))return;let n=Math.sqrt((e.position.left-r.left)**2+(e.position.top-r.top)**2);n<c&&(c=n,s=t)}),s!==-1){let n;try{if(t.sourceLibrary===`plotly`)n=we(t.config);else return}catch{return}let i=e.elements[s],c=i.position.left,l=i.position.top,u=c+i.dimensions.width,d=l+i.dimensions.height;e.elements.forEach((e,t)=>{if(e.type!==`image`)return;let n=e,r=n.position.left,i=n.position.top,o=r+n.dimensions.width,s=i+n.dimensions.height;r>=c&&i>=l&&o<=u&&s<=d&&a.add(t)});let f={type:`chart`,originalType:`image`,id:crypto.randomUUID(),position:{left:r.left,top:r.top},dimensions:{width:r.width,height:r.height},data:n,sourceLibrary:t.sourceLibrary};o.push(f)}});let s=e.elements.filter((e,t)=>!a.has(t));return{...e,elements:[...s,...o]}}},Te=e=>{let t=e.tagName.toLowerCase();if(t===`img`)return e.src||``;if(t===`svg`){let t=new XMLSerializer().serializeToString(e);return`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}if(t===`picture`){let t=e.querySelector(`img`);if(t)return t.src||``}return``},Ee=e=>{let t=e.tagName.toLowerCase();if(t===`img`)return e.alt||void 0;if(t===`svg`){let t=e.querySelector(`title`);if(t)return t.textContent||void 0}},I={name:`core:image`,handles:[`image`],onParse:(e,t)=>{let{computedStyle:n,boundingRect:r,slideElement:i}=t,a=i.getBoundingClientRect(),o=Te(e);return o?{type:`image`,id:crypto.randomUUID(),src:o,alt:Ee(e),position:g(r,a),dimensions:_(r),zIndex:h(n),rotation:p(n),opacity:m(n)}:null}},L=new Map,R=new Map,De=e=>e.includes(`fab`)||e.includes(`fa-brands`)?`brands`:e.includes(`far`)||e.includes(`fa-regular`)?`regular`:`solid`,Oe=e=>e.find(e=>e.startsWith(`fa-`)&&e!==`fa`)||null,ke=async(e,t)=>{let n=e.replace(`fa-`,``),r=Fe[n]||n,i=r===n?[n]:[r,n],a=t===`solid`?[`solid`]:[t,`solid`];for(let e of i)for(let t of a){let n=[`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/svgs/${t}/${e}.svg`,`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@7.0.0/svgs/${t}/${e}.svg`];for(let e of n)try{let t=await fetch(e);if(!t.ok)continue;let n=await t.text(),r=new DOMParser().parseFromString(n,`image/svg+xml`).querySelector(`svg`);if(!r)continue;let i=r.getAttribute(`viewBox`)||`0 0 512 512`,a=Array.from(r.querySelectorAll(`path`)).map(e=>e.getAttribute(`d`)).filter(Boolean).join(` `);if(!a)continue;return{viewBox:i,path:a}}catch{continue}}return null},Ae=async(e,t)=>{let n=`${t}:${e}`;if(L.has(n))return L.get(n);if(R.has(n))return R.get(n);let r=ke(e,t).then(e=>(e&&L.set(n,e),e)).finally(()=>{R.delete(n)});return R.set(n,r),r},je=(e,t)=>{let n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e.viewBox}"><path fill="#${t}" d="${e.path}"/></svg>`;return`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(n)))}`},z={name:`core:icon-fontawesome`,handles:[`icon`],onParse:async(e,t)=>{let{computedStyle:n,boundingRect:r,slideElement:i}=t,a=Array.from(e.classList),s=Oe(a);if(!s)return null;let c=await Ae(s,De(a));if(!c)return null;let l=je(c,o(n.color)||`000000`),u=i.getBoundingClientRect();return{type:`image`,originalType:`icon`,id:crypto.randomUUID(),src:l,alt:s,position:g(r,u),dimensions:_(r),zIndex:h(n),rotation:p(n),opacity:m(n)}}},Me={reset:`\x1B[0m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,dim:`\x1B[2m`},B={SLIDE_SELECTOR:`.slide`,SLIDE_WIDTH:992,SLIDE_HEIGHT:558,FONT_FAMILY:``,CHART_FONT_SIZE:9},V={DPI:96,PPTX_PIXELS_TO_INCHES:73.7,RADIUS_MULTIPLIER:.75},H={solid:`solid`,dashed:`dash`,dotted:`sysDot`},Ne={100:`Thin`,200:`ExtraLight`,300:`Light`,400:``,500:`Medium`,600:`SemiBold`,700:`Bold`,800:`ExtraBold`,900:`Black`},U=[C,D,O,j,I,z,F],Pe=1.02,W={pie:`pie`,bar:`bar`,line:`line`,scatter:`scatter`,area:`area`,doughnut:`doughnut`,radar:`radar`,bubble:`bubble`},G={pie:`pie`,bar:`bar`,line:`line`,scatter:`line`,area:`area`,doughnut:`doughnut`,radar:`radar`,bubble:`bubble`},Fe={"check-circle":`circle-check`,"times-circle":`circle-xmark`,"exclamation-circle":`circle-exclamation`,"exclamation-triangle":`triangle-exclamation`,"shield-alt":`shield`,search:`magnifying-glass`,times:`xmark`,bars:`bars`,cog:`gear`,trash:`trash-can`,edit:`pen-to-square`,"external-link-alt":`arrow-up-right-from-square`,"arrow-alt-circle-down":`circle-down`,"arrow-alt-circle-up":`circle-up`,"arrow-alt-circle-left":`circle-left`,"arrow-alt-circle-right":`circle-right`,"sign-in-alt":`right-to-bracket`,"sign-out-alt":`right-from-bracket`,percentage:`percent`};var K=class{config;pluginManager;presentation=null;source=null;parser;serializer;constructor(e){i(e.parser,`Parser strategy is required`),i(e.serializer,`Serializer strategy is required`),this.config={...e,selector:e.selector||`.slide`,dimensions:e.dimensions||{width:B.SLIDE_WIDTH,height:B.SLIDE_HEIGHT}},this.parser=e.parser,this.serializer=e.serializer,this.pluginManager=new t,this.serializer.setPluginManager&&this.serializer.setPluginManager(this.pluginManager);let n=e.plugins?.core??[],r=e.plugins?.extensions??[];n.forEach(e=>this.use(e)),r.forEach(e=>this.use(e))}use(e){return this.pluginManager.register(e),this}load(e){return typeof e==`string`?this.source=e:this.source=e.content,this}async convert(){i(this.source,`No HTML source loaded. Call load() first.`),this.config.debug&&console.group(`[html-in-pptx-out] convert`);let e={selector:this.config.selector,dimensions:this.config.dimensions},t=await this.pluginManager.executeBeforeParse(this.source,e),{elements:n,cleanup:r}=await this.parser.parse(t,e);this.config.debug&&console.log(`before: executeOnParse`,{elements:n});let a=new Map;for(let{slideIndex:e,element:t,parseContext:r}of n){let n=await this.pluginManager.executeOnParse(t,r);n&&(a.has(e)||a.set(e,[]),a.get(e).push(n))}this.config.debug&&console.log(`after: executeOnParse`,{slides:a}),r();let o=[],s=Array.from(a.keys()).sort((e,t)=>e-t);for(let e of s){let t={id:crypto.randomUUID(),order:e,elements:a.get(e)||[]};o.push(t)}this.presentation={slides:o,metadata:{createdAt:new Date,plugins:this.pluginManager.getPlugins().map(e=>e.name)},viewport:this.config.dimensions};for(let e=0;e<this.presentation.slides.length;e++)this.presentation.slides[e]=await this.pluginManager.executeOnSlide(this.presentation.slides[e]);return this.pluginManager.setPresentation(this.presentation),this.config.debug&&(console.log(`after: executeOnSlide`,{presentation:this.presentation}),console.groupEnd()),this}async export(e){return i(this.presentation,`No presentation to export. Call convert() first.`),await this.serializer.serialize(this.presentation,e)}async exportImages(e){throw Error(`Not implemented`)}getPresentation(){return i(this.presentation,`No presentation available. Call convert() first.`),this.presentation}};const Ie=(e,t)=>new Promise((n,r)=>{let i=document.createElement(`iframe`);i.style.position=`fixed`,i.style.left=`-9999px`,i.style.top=`-9999px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`,i.style.opacity=`0`,i.style.pointerEvents=`none`,i.style.zIndex=`-1`,i.setAttribute(`aria-hidden`,`true`);let a=()=>{i.removeEventListener(`load`,a);let e=i.contentDocument;if(!e){r(Error(`Failed to access iframe document`));return}let t=()=>{e.readyState===`complete`?requestAnimationFrame(()=>n(i)):setTimeout(t,10)};t()};i.addEventListener(`load`,a),i.onerror=()=>r(Error(`Failed to load iframe`)),i.srcdoc=e,document.body.appendChild(i)}),Le=e=>{e.remove()};var q=class{async parse(e,t){let n=await Ie(e,t.dimensions),r=n.contentDocument.querySelectorAll(t.selector),i=[];for(let e=0;e<r.length;e++){let t=r[e],a=t.querySelectorAll(`*`),o=[t,...Array.from(a)],s=[];for(let r of o){let a=ne(r,n.contentWindow);if(a.length===0)continue;let o=n.contentWindow.getComputedStyle(r),c=r.getBoundingClientRect(),l=r.tagName.toLowerCase();for(let n of a){if(n===`text`){if(s.some(e=>c.left>=e.left&&c.top>=e.top&&c.right<=e.right&&c.bottom<=e.bottom))continue;s.push(c)}let a={elementType:n,tagName:l,computedStyle:o,boundingRect:c,slideIndex:e,slideElement:t};i.push({slideIndex:e,element:r,parseContext:a})}}}return{elements:i,cleanup:()=>Le(n)}}};const J=e=>e/V.DPI,Y=e=>e/V.DPI*72,X=(e,t)=>{let n=e.left/t.width*100,r=e.top/t.height*100;return{x:`${n}%`,y:`${r}%`}},Z=(e,t)=>{let n=e.width/t.width*100,r=e.height/t.height*100;return{w:`${n}%`,h:`${r}%`}},Re=e=>({x:J(e.left),y:J(e.top)}),ze=e=>({w:J(e.width),h:J(e.height)}),Q=e=>{let t={};return e.fontFamily&&(t.fontFace=e.fontFamily.split(`,`)[0].trim()),e.fontSize&&(t.fontSize=Y(e.fontSize)),e.color&&(t.color=e.color.toUpperCase()),e.fontWeight&&(parseInt(e.fontWeight,10)||400)>400&&(t.bold=!0),(e.fontStyle===`italic`||e.fontStyle===`oblique`)&&(t.italic=!0),e.underline&&(t.underline={style:`sng`}),e.strikethrough&&(t.strike=`sngStrike`),t},Be=e=>{let t=[];for(let n of e)if(n.children&&n.children.length>0){let e=Be(n.children);for(let r of e){let e={...r.options};if(n.typography){let t=Q(n.typography);Object.assign(e,t,r.options)}n.href&&(e.hyperlink={url:n.href}),t.push({text:r.text,options:e})}}else{let e={};n.typography&&Object.assign(e,Q(n.typography)),n.href&&(e.hyperlink={url:n.href}),t.push({text:n.content,options:e})}return t},Ve=(e,t,n)=>{let r=X(t.position,n),i=Z(t.dimensions,n),a={x:r.x,y:r.y,w:i.w,h:i.h,lineSpacingMultiple:1,valign:`top`,align:`left`,isTextBox:!0,wrap:!0,shrinkText:!1};if(t.typography){let e=t.typography,n=Q(e);Object.assign(a,n),e.textAlign&&(a.align=e.textAlign),e.verticalAlign&&(a.valign=e.verticalAlign),e.letterSpacing&&(a.charSpacing=e.letterSpacing)}if(t.padding&&(a.margin=[Y(t.padding.top),Y(t.padding.right),Y(t.padding.bottom),Y(t.padding.left)]),t.rotation&&(a.rotate=t.rotation),t.opacity!==void 0&&t.opacity<1&&(a.transparency=Math.round((1-t.opacity)*100)),t.runs&&t.runs.length>0){let n=Be(t.runs);e.addText(n,a)}else e.addText(t.content,a)},He=e=>e,Ue=e=>H[e.style]||`solid`,We=(t,n,r)=>{let i=X(n.position,r),a=Z(n.dimensions,r),o=He(n.shapeType)||e.ShapeType.rect,s={x:i.x,y:i.y,w:a.w,h:a.h};if(n.fill){let e={};if(n.fill.type===`solid`)e.color=n.fill.color.toUpperCase(),n.fill.opacity!==void 0&&n.fill.opacity<1&&(e.transparency=Math.round((1-n.fill.opacity)*100));else if(n.fill.type===`gradient`){let t=n.fill.stops[0];t&&(e.color=t.color.toUpperCase(),t.opacity!==void 0&&t.opacity<1&&(e.transparency=Math.round((1-t.opacity)*100)))}e.color&&(s.fill=e)}if(n.stroke){let e={color:n.stroke.color.toUpperCase(),width:n.stroke.width,dashType:Ue(n.stroke)};n.stroke.opacity!==void 0&&(e.transparency=Math.round((1-n.stroke.opacity)*100)),s.line=e}if(n.rotation&&(s.rotate=n.rotation),n.borderRadius&&n.shapeType===`roundRect`){let e=Math.min(n.dimensions.width,n.dimensions.height);s.rectRadius=Math.min(n.borderRadius/e,1)*V.RADIUS_MULTIPLIER}if(n.shadow){let e=n.shadow.offset.x,t=n.shadow.offset.y,r=Math.sqrt(e**2+t**2),i=(Math.atan2(t,e)*180/Math.PI%360+360)%360;s.shadow={type:n.shadow.type,color:n.shadow.color.toUpperCase(),blur:Y(n.shadow.blur),offset:Y(r),angle:i,opacity:n.shadow.opacity??1}}t.addShape(o,s)},Ge=e=>H[e.style]||`solid`,Ke=(e,t,n)=>{let r=t.start.left/n.width*100,i=t.start.top/n.height*100,a=t.end.left/n.width*100,o=t.end.top/n.height*100,s=Math.abs(a-r),c=Math.abs(o-i),l={color:t.stroke.color.toUpperCase(),width:t.stroke.width,dashType:Ge(t.stroke)};t.stroke.opacity!==void 0&&(l.transparency=Math.round((1-t.stroke.opacity)*100));let u={x:`${Math.min(r,a)}%`,y:`${Math.min(i,o)}%`,w:`${s||.1}%`,h:`${c||.1}%`,line:l},d=t.end.left<t.start.left,f=t.end.top<t.start.top;d&&(u.flipH=!0),f&&(u.flipV=!0),e.addShape(`line`,u)},qe=(e,t,n)=>{let r=X(t.position,n),i=Z(t.dimensions,n),a={x:r.x,y:r.y,w:i.w,h:i.h};t.src.startsWith(`data:`)?a.data=t.src:a.path=t.src,t.alt&&(a.altText=t.alt),t.rotation&&(a.rotate=t.rotation),t.opacity!==void 0&&t.opacity<1&&(a.transparency=Math.round((1-t.opacity)*100)),t.fit&&(a.sizing={type:{contain:`contain`,cover:`cover`,stretch:`crop`}[t.fit]||`contain`,w:t.dimensions.width,h:t.dimensions.height}),e.addImage(a)},Je=(e,t)=>{let n=e.split(`,`)[0].trim();if(!t)return n;let r=Ne[parseInt(t,10)||400];return!r||r===``?n:`${n} ${r}`},Ye=(e,t,n)=>{let r=X(t.position,n),i=Z(t.dimensions,n),a=t.rows.map(e=>e.map(e=>{let t={text:e.text};if(e.colspan&&(t.options={...t.options,colspan:e.colspan}),e.rowspan&&(t.options={...t.options,rowspan:e.rowspan}),e.typography){let n=e.typography,r=n.fontWeight&&parseInt(n.fontWeight,10)||400;t.options={...t.options,fontFace:n.fontFamily?Je(n.fontFamily,n.fontWeight):void 0,fontSize:n.fontSize?Y(n.fontSize):void 0,color:n.color?n.color.toUpperCase():void 0,bold:r>400,italic:n.fontStyle===`italic`||n.fontStyle===`oblique`,underline:n.underline?{style:`sng`}:void 0,align:n.textAlign,valign:n.verticalAlign}}if(e.fill){if(e.fill.type===`solid`){let n={color:e.fill.color.toUpperCase()};e.fill.opacity!==void 0&&e.fill.opacity<1&&(n.transparency=Math.round((1-e.fill.opacity)*100)),t.options={...t.options,fill:n}}else if(e.fill.type===`gradient`){let n=e.fill.stops[0];n&&(t.options={...t.options,fill:{color:n.color.toUpperCase()}})}}if(e.border){let n=[`top`,`right`,`bottom`,`left`],r=[];for(let t of n){let n=e.border[t];if(n){let e=`solid`;(n.style===`dashed`||n.style===`dotted`)&&(e=`dash`),r.push({color:n.color.toUpperCase(),pt:n.width,type:e})}else r.push({type:`none`})}let i=r;t.options={...t.options,border:i}}return t})),o={x:r.x,y:r.y,w:i.w,h:i.h};t.colWidths&&t.colWidths.length>0&&(o.colW=t.colWidths.map(e=>J(e))),t.cellMinHeight&&(o.rowH=Y(t.cellMinHeight)/72),t.headerRow&&(o.autoPageHeaderRows=1),e.addTable(a,o)},Xe=e=>{for(let t of e)if(!(!t.values||!Array.isArray(t.values))){for(let e of t.values)if(typeof e==`number`&&!Number.isInteger(e)){let e=0;for(let n of t.values)if(typeof n==`number`&&!Number.isInteger(n)){let t=n.toString().split(`.`)[1]?.length||0;e=Math.max(e,Math.min(t,2))}return e===1?`#,##0.0`:`#,##0.00`}}return`#,##0`},Ze=e=>G[e]||`bar`,$=e=>{let t=e.data.chartType;return t===`pie`&&e.data.options?.hole!==void 0&&e.data.options.hole>0?`doughnut`:G[t]||`bar`},Qe=e=>{let t=Re(e.position),n=ze(e.dimensions),r=e.data,i={type:r.chartType,series:r.series,labels:r.labels,options:r.options},a=i.series.map(e=>({name:e.name,labels:i.labels,values:e.values,color:o(e.color||``)})),s={x:t.x,y:t.y,w:n.w,h:n.h,title:i.options?.title,showTitle:!!i.options?.title,titleFontSize:i.options?.titleFontSize||B.CHART_FONT_SIZE,showLegend:i.options?.showLegend!==!1,legendPos:`t`,legendFontSize:B.CHART_FONT_SIZE,showLabel:i.options?.showDataLabels===!0,dataLabelFontSize:B.CHART_FONT_SIZE};if(i.options?.showDataLabels===!0)if(i.type===`bar`){s.showValue=!0;let e=Xe(i.series);e&&(s.dataLabelFormatCode=e)}else i.type===`pie`&&(s.showPercent=!0);i.type===`pie`&&(s.dataLabelPosition=`outEnd`);let c=[];if(i.series.some(e=>e.colors&&e.colors.length>0)){let e=i.series.find(e=>e.colors&&e.colors.length>0);e?.colors&&c.push(...e.colors)}else i.series.forEach(e=>{e.color&&c.push(e.color)});if(c.length>0&&(s.chartColors=c.map(e=>o(e)).filter(e=>e!==void 0)),i.options?.xAxisTitle&&(s.catAxisTitle=i.options.xAxisTitle,s.showCatAxisTitle=!0,s.catAxisTitleFontSize=B.CHART_FONT_SIZE),i.options?.yAxisTitle&&(s.valAxisTitle=i.options.yAxisTitle,s.showValAxisTitle=!0,s.valAxisTitleFontSize=B.CHART_FONT_SIZE),s.catAxisLabelFontSize=B.CHART_FONT_SIZE,s.valAxisLabelFontSize=B.CHART_FONT_SIZE,s.catGridLine={style:`none`},s.valGridLine={style:`solid`,size:1,color:`D9D9D9`},i.options?.hole!==void 0&&i.options.hole>0&&(s.holeSize=Math.round(i.options.hole*100)),i.options?.orientation===`horizontal`?s.barDir=`bar`:(i.options?.orientation===`vertical`||i.type===`bar`)&&(s.barDir=`col`),i.options?.barGrouping&&(s.barGrouping=i.options.barGrouping),i.options?.hasSecondaryAxis){let t=new Map,n=new Map;if(i.series.forEach((e,r)=>{let o=e.chartType||i.type,s=a[r];e.yAxis===`y2`?(n.has(o)||n.set(o,[]),n.get(o).push(s)):(t.has(o)||t.set(o,[]),t.get(o).push(s))}),n.size===0)return{data:a,options:s,chartTypeKey:$(e)};let r=[];return t.forEach((e,t)=>{r.push({typeKey:Ze(t),data:e,options:{}})}),n.forEach((e,t)=>{let n=t===`line`||t===`area`;r.push({typeKey:Ze(t),data:e,options:{secondaryValAxis:!0,secondaryCatAxis:!0,...n?{showValue:!0,dataLabelPosition:`t`}:{}}})}),{data:null,options:{x:s.x,y:s.y,w:s.w,h:s.h,title:s.title,showTitle:s.showTitle,titleFontSize:s.titleFontSize,showLegend:s.showLegend,legendPos:`t`,legendFontSize:B.CHART_FONT_SIZE,chartColors:s.chartColors,dataLabelFormatCode:s.dataLabelFormatCode,dataLabelFontSize:B.CHART_FONT_SIZE,valAxes:[{valAxisTitle:i.options.yAxisTitle||``,showValAxisTitle:!!i.options.yAxisTitle,valAxisTitleFontSize:B.CHART_FONT_SIZE,valAxisLabelFontSize:B.CHART_FONT_SIZE,valGridLine:{style:`solid`,size:1,color:`D9D9D9`}},{valAxisTitle:i.options.yAxis2Title||``,showValAxisTitle:!1,valAxisTitleFontSize:B.CHART_FONT_SIZE,valAxisLabelFontSize:B.CHART_FONT_SIZE,valGridLine:{style:`none`}}],catAxes:[{catAxisTitle:i.options.xAxisTitle||``,showCatAxisTitle:!!i.options.xAxisTitle,catAxisTitleFontSize:B.CHART_FONT_SIZE,catAxisLabelFontSize:B.CHART_FONT_SIZE,catGridLine:{style:`none`}},{catAxisLabelFontSize:B.CHART_FONT_SIZE,catAxisHidden:!0,catGridLine:{style:`none`}}]},chartTypesForCombo:r,chartTypeKey:$(e)}}return{data:a,options:s,chartTypeKey:$(e)}},$e=(e,t)=>{let{data:n,options:r,chartTypesForCombo:i,chartTypeKey:a}=Qe(t);if(t.data.options?.hasSecondaryAxis&&i){let t=i.map(e=>({type:e.typeKey,data:e.data,options:e.options||{}}));e.addChart(t,r)}else{let t=a;if(!t||!n)return;e.addChart(t,n,r)}};var et=class{pluginManager=null;setPluginManager(e){this.pluginManager=e}async serialize(t,n){r(t.slides.length>0,`No slides to export. Check selector or create a slide to export`);let i=new e,a=J(t.viewport.width),o=J(t.viewport.height);i.defineLayout({name:`custom`,width:a,height:o}),i.layout=`custom`,t.metadata.title&&(i.title=t.metadata.title),t.metadata.author&&(i.author=t.metadata.author),t.metadata.subject&&(i.subject=t.metadata.subject);for(let e of t.slides){let n=i.addSlide();for(let r of e.elements)switch(r.type){case`text`:Ve(n,r,t.viewport);break;case`image`:qe(n,r,t.viewport);break;case`shape`:We(n,r,t.viewport);break;case`table`:Ye(n,r,t.viewport);break;case`chart`:$e(n,r);break;case`line`:Ke(n,r,t.viewport);break}}return this.pluginManager&&await this.pluginManager.executeAfterGenerate(i,t),await i.write({outputType:`arraybuffer`})}},tt=class extends K{constructor(e={}){super({selector:e.selector||B.SLIDE_SELECTOR,dimensions:e.dimensions||{width:B.SLIDE_WIDTH,height:B.SLIDE_HEIGHT},plugins:{core:e.plugins?.core??U,extensions:e.plugins?.extensions??[]},parser:e.parser||new q,serializer:e.serializer||new et,debug:e.debug})}};export{Me as a,z as c,j as d,O as f,K as i,I as l,C as m,et as n,B as o,D as p,q as r,U as s,tt as t,F as u};
5
+ //# sourceMappingURL=converter-B7cokS5k.mjs.map