officeparser 7.0.1 → 7.0.3

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.
@@ -34,13 +34,14 @@ export declare class OfficeConverter {
34
34
  * // Convert Word to Markdown with a single call
35
35
  * const { value: markdown } = await OfficeConverter.convert('report.docx', 'md');
36
36
  *
37
- * // Convert PDF to HTML with OCR enabled for images
37
+ * // Convert PDF to HTML (Note: OCR is disabled in this one-step API)
38
38
  * const { value: html } = await OfficeConverter.convert(buffer, 'html', {
39
- * ocr: true,
40
- * includeImages: true
39
+ * generatorConfig: {
40
+ * includeImages: true
41
+ * }
41
42
  * });
42
43
  * ```
43
44
  */
44
- static convert<F extends string | Buffer | ArrayBuffer, T extends SupportedFileType = InferFileTypeFromPath<F>>(file: F, destination: SupportedDestination<T>, config?: OfficeConverterConfig<SupportedDestination<T>, T>): Promise<ConversionResult<SupportedDestination<T>>>;
45
+ static convert<F extends string | Buffer | ArrayBuffer | Uint8Array, T extends SupportedFileType = InferFileTypeFromPath<F>>(file: F, destination: SupportedDestination<T>, config?: OfficeConverterConfig<SupportedDestination<T>, T>): Promise<ConversionResult<SupportedDestination<T>>>;
45
46
  }
46
47
  export {};
@@ -34,10 +34,11 @@ class OfficeConverter {
34
34
  * // Convert Word to Markdown with a single call
35
35
  * const { value: markdown } = await OfficeConverter.convert('report.docx', 'md');
36
36
  *
37
- * // Convert PDF to HTML with OCR enabled for images
37
+ * // Convert PDF to HTML (Note: OCR is disabled in this one-step API)
38
38
  * const { value: html } = await OfficeConverter.convert(buffer, 'html', {
39
- * ocr: true,
40
- * includeImages: true
39
+ * generatorConfig: {
40
+ * includeImages: true
41
+ * }
41
42
  * });
42
43
  * ```
43
44
  */
@@ -30,7 +30,7 @@
30
30
  * const ast = await OfficeParser.parseOffice(buffer);
31
31
  *
32
32
  * // Get plain text
33
- * console.log(ast.toText());
33
+ * console.log((await ast.to('text')).value);
34
34
  * ```
35
35
  *
36
36
  * @module OfficeParser
@@ -91,7 +91,7 @@ export declare class OfficeParser {
91
91
  * const text = ast.toText();
92
92
  * ```
93
93
  */
94
- static parseOffice(file: string | Buffer | ArrayBuffer, configOrCallback?: OfficeParserConfig | ((ast: OfficeParserAST, err?: any) => void), config?: OfficeParserConfig): Promise<OfficeParserAST>;
94
+ static parseOffice(file: string | Buffer | ArrayBuffer | Uint8Array, configOrCallback?: OfficeParserConfig | ((ast: OfficeParserAST, err?: any) => void), config?: OfficeParserConfig): Promise<OfficeParserAST>;
95
95
  /**
96
96
  * Terminates all active OCR workers and cleans up resources.
97
97
  *
@@ -31,7 +31,7 @@
31
31
  * const ast = await OfficeParser.parseOffice(buffer);
32
32
  *
33
33
  * // Get plain text
34
- * console.log(ast.toText());
34
+ * console.log((await ast.to('text')).value);
35
35
  * ```
36
36
  *
37
37
  * @module OfficeParser
@@ -136,6 +136,9 @@ class OfficeParser {
136
136
  if (file instanceof ArrayBuffer) {
137
137
  buffer = Buffer.from(file);
138
138
  }
139
+ else if (file instanceof Uint8Array) {
140
+ buffer = Buffer.from(file.buffer, file.byteOffset, file.byteLength);
141
+ }
139
142
  else if (Buffer.isBuffer(file)) {
140
143
  buffer = file;
141
144
  }
@@ -13,7 +13,7 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
13
13
  }
14
14
  async generate() {
15
15
  this.colorTable = [];
16
- // We first process all nodes to collect colors
16
+ // We first process all nodes to collect colors and analyze structure
17
17
  const bodyContent = await this.renderBody(this.ast);
18
18
  let output = '{\\rtf1\\ansi\\deff0\n';
19
19
  // 1. Info Group (Metadata)
@@ -61,7 +61,6 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
61
61
  let body = '';
62
62
  this.inTable = false;
63
63
  const processor = async (node, childrenOutput) => {
64
- // Handle Semantic Style Mapping for RTF using the semantic mapping helper
65
64
  const mapping = this.getSemanticMapping(node);
66
65
  if (mapping) {
67
66
  if (mapping.tag === 'blockquote') {
@@ -112,7 +111,7 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
112
111
  const pt = parseInt(f.size);
113
112
  prefix += `\\fs${pt * 2} `;
114
113
  }
115
- text = `{\\rtlch\\f1 ${prefix}${text}${suffix}}`;
114
+ text = `{\\f0 ${prefix}${text}${suffix}}`;
116
115
  }
117
116
  if (meta?.link) {
118
117
  const isInternal = meta.linkType !== 'external';
@@ -142,25 +141,16 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
142
141
  else if (meta.alignment === 'justify')
143
142
  pPr += '\\qj';
144
143
  }
145
- if (meta.paragraphIndentation) {
146
- const ind = meta.paragraphIndentation;
147
- if (ind.left)
148
- pPr += `\\li${ind.left}`;
149
- if (ind.right)
150
- pPr += `\\ri${ind.right}`;
151
- if (ind.firstLine)
152
- pPr += `\\fi${ind.firstLine}`;
153
- }
154
144
  }
155
145
  return `${pPr} ${childrenOutput}\\par\n`;
156
146
  }
157
147
  case 'list': {
158
148
  const meta = node.metadata;
159
- const indent = ((meta?.indentation || 0) + 1) * 360;
149
+ const level = meta?.indentation || 0;
150
+ const indent = (level + 1) * 360;
160
151
  const isOrdered = meta?.listType === 'ordered';
161
152
  const marker = isOrdered ? `${(meta.itemIndex ?? 0) + 1}. ` : '\\bullet ';
162
153
  const listControl = isOrdered ? '\\pndec' : '\\pnbullet';
163
- const level = meta?.indentation || 0;
164
154
  const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
165
155
  return `${pPr}\\li${indent}\\fi-360\\ilvl${level}${listControl} ${marker}${childrenOutput}\\par\n`;
166
156
  }
@@ -168,11 +158,40 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
168
158
  return `\\pard\\sa0\n${childrenOutput}`;
169
159
  }
170
160
  case 'row': {
171
- return `\\trowd\\trgaph108\\trleft-108\n${childrenOutput}\\row\n`;
161
+ const cells = node.children || [];
162
+ const pageWidth = 9000; // Standard twips width
163
+ const cellWidth = Math.floor(pageWidth / (cells.length || 1));
164
+ let cellDefs = '';
165
+ for (let i = 0; i < cells.length; i++) {
166
+ // Add basic cell borders and calculate width
167
+ cellDefs += `\\clbrdrt\\brdrs\\brdrw10\\clbrdrl\\brdrs\\brdrw10\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrs\\brdrw10\\cellx${(i + 1) * cellWidth}`;
168
+ }
169
+ return `\\trowd\\trgaph108\\trleft-108${cellDefs}\n${childrenOutput}\\row\n`;
172
170
  }
173
171
  case 'cell': {
174
- const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
175
- return `${pPr}\\intbl\\sb60\\sa60 ${childrenOutput}\\cell\n`;
172
+ return `\\pard\\intbl\\sb60\\sa60 ${childrenOutput}\\cell\n`;
173
+ }
174
+ case 'image': {
175
+ if (!this.config.includeImages)
176
+ return '';
177
+ const meta = node.metadata;
178
+ const attachmentName = meta?.attachmentName;
179
+ const attachment = this.ast.attachments.find(a => a.name === attachmentName);
180
+ if (attachment && attachment.data) {
181
+ const type = attachment.extension === 'png' ? 'pngblip' : 'jpegblip';
182
+ // Convert base64 to hex
183
+ const binary = atob(attachment.data);
184
+ let hex = '';
185
+ for (let i = 0; i < binary.length; i++) {
186
+ const h = binary.charCodeAt(i).toString(16);
187
+ hex += h.length === 1 ? '0' + h : h;
188
+ if (i % 64 === 63)
189
+ hex += '\n'; // Add newlines for better RTF readability
190
+ }
191
+ // Default goals (approx 3 inches wide at 1440 twips per inch)
192
+ return `{\\pict\\${type}\\picwgoal4320\\pichgoal3240\n${hex}\n}\n`;
193
+ }
194
+ return '';
176
195
  }
177
196
  case 'break': {
178
197
  return node.metadata?.breakType === 'page' ? '\\page\n' : '\\line\n';
@@ -17,7 +17,7 @@ export declare enum OfficeErrorType {
17
17
  IMPROPER_ARGUMENTS = "IMPROPER_ARGUMENTS",
18
18
  /** Error occurred while reading or processing file buffers */
19
19
  IMPROPER_BUFFERS = "IMPROPER_BUFFERS",
20
- /** Input type is not a supported type (string, Buffer, ArrayBuffer) */
20
+ /** Input type is not a supported type (string, Buffer, ArrayBuffer, Uint8Array) */
21
21
  INVALID_INPUT = "INVALID_INPUT",
22
22
  /** PDF worker source is missing (required in browser) */
23
23
  PDF_WORKER_MISSING = "PDF_WORKER_MISSING",
@@ -1546,7 +1546,7 @@ export declare class OfficeParser {
1546
1546
  * const text = ast.toText();
1547
1547
  * ```
1548
1548
  */
1549
- static parseOffice(file: string | Buffer | ArrayBuffer, configOrCallback?: OfficeParserConfig | ((ast: OfficeParserAST, err?: any) => void), config?: OfficeParserConfig): Promise<OfficeParserAST>;
1549
+ static parseOffice(file: string | Buffer | ArrayBuffer | Uint8Array, configOrCallback?: OfficeParserConfig | ((ast: OfficeParserAST, err?: any) => void), config?: OfficeParserConfig): Promise<OfficeParserAST>;
1550
1550
  /**
1551
1551
  * Terminates all active OCR workers and cleans up resources.
1552
1552
  *
@@ -1610,14 +1610,15 @@ export declare class OfficeConverter {
1610
1610
  * // Convert Word to Markdown with a single call
1611
1611
  * const { value: markdown } = await OfficeConverter.convert('report.docx', 'md');
1612
1612
  *
1613
- * // Convert PDF to HTML with OCR enabled for images
1613
+ * // Convert PDF to HTML (Note: OCR is disabled in this one-step API)
1614
1614
  * const { value: html } = await OfficeConverter.convert(buffer, 'html', {
1615
- * ocr: true,
1616
- * includeImages: true
1615
+ * generatorConfig: {
1616
+ * includeImages: true
1617
+ * }
1617
1618
  * });
1618
1619
  * ```
1619
1620
  */
1620
- static convert<F extends string | Buffer | ArrayBuffer, T extends SupportedFileType = InferFileTypeFromPath<F>>(file: F, destination: SupportedDestination<T>, config?: OfficeConverterConfig<SupportedDestination<T>, T>): Promise<ConversionResult<SupportedDestination<T>>>;
1621
+ static convert<F extends string | Buffer | ArrayBuffer | Uint8Array, T extends SupportedFileType = InferFileTypeFromPath<F>>(file: F, destination: SupportedDestination<T>, config?: OfficeConverterConfig<SupportedDestination<T>, T>): Promise<ConversionResult<SupportedDestination<T>>>;
1621
1622
  }
1622
1623
  export declare const parseOffice: typeof OfficeParser.parseOffice;
1623
1624
  export declare const terminateOcr: typeof OfficeParser.terminateOcr;
@@ -704,14 +704,18 @@ ${i} </tr>
704
704
  `}return n+=`\\f0\\fs24
705
705
  `,n+=e,n+="}",{value:n,messages:this.messages}}async processNodeRecursive(e,n){let i=this.inTable;e.type==="table"&&(this.inTable=!0);let s=await super.processNodeRecursive(e,n);return this.inTable=i,s}async renderBody(e){let n="";this.inTable=!1;let i=async(s,a)=>{let l=this.getSemanticMapping(s);if(l){if(l.tag==="blockquote")return`${this.inTable?"\\pard\\intbl":"\\pard"}\\li720\\ri720\\sa120 ${a}\\par
706
706
  `;let c=l.tag.match(/^h([1-6])$/);if(c){let u=parseInt(c[1]),h=24+(6-u)*4;return`${this.inTable?"\\pard\\intbl":"\\pard"}\\s${u}\\sb240\\sa120{\\b\\fs${h} ${a}}\\par
707
- `}}switch(s.type){case"text":{let c=this.escapeRtf(s.text||""),u=s.formatting,h=s.metadata;if(this.config.includeFormatting&&u){let d="",f="";if(u.bold&&(d+="\\b ",f="\\b0 "+f),u.italic&&(d+="\\i ",f="\\i0 "+f),u.underline&&(d+="\\ul ",f="\\ul0 "+f),u.strikethrough&&(d+="\\strike ",f="\\strike0 "+f),u.color){let p=this.getColorIndex(u.color);d+=`\\cf${p+1} `}if(u.backgroundColor){let p=this.getColorIndex(u.backgroundColor);d+=`\\highlight${p+1} `}if(u.size){let p=parseInt(u.size);d+=`\\fs${p*2} `}c=`{\\rtlch\\f1 ${d}${c}${f}}`}if(h?.link){let d=h.linkType!=="external";if(!this.config.ignoreInternalLinks||!d)return`{\\field{\\*\\fldinst{HYPERLINK "${h.link}"}}{\\fldrslt ${c}}}`}return c}case"heading":{let u=s.metadata?.level||1,h=24+(6-u)*4;return`${this.inTable?"\\pard\\intbl":"\\pard"}\\s${u}\\sb240\\sa120{\\b\\fs${h} ${a}}\\par
708
- `}case"paragraph":{let c=this.inTable?"\\pard\\intbl":"\\pard";if(c+="\\sa120",this.config.includeFormatting&&s.metadata){let u=s.metadata;if(u.alignment&&(u.alignment==="center"?c+="\\qc":u.alignment==="right"?c+="\\qr":u.alignment==="justify"&&(c+="\\qj")),u.paragraphIndentation){let h=u.paragraphIndentation;h.left&&(c+=`\\li${h.left}`),h.right&&(c+=`\\ri${h.right}`),h.firstLine&&(c+=`\\fi${h.firstLine}`)}}return`${c} ${a}\\par
709
- `}case"list":{let c=s.metadata,u=((c?.indentation||0)+1)*360,h=c?.listType==="ordered",d=h?`${(c.itemIndex??0)+1}. `:"\\bullet ",f=h?"\\pndec":"\\pnbullet",p=c?.indentation||0;return`${this.inTable?"\\pard\\intbl":"\\pard"}\\li${u}\\fi-360\\ilvl${p}${f} ${d}${a}\\par
707
+ `}}switch(s.type){case"text":{let c=this.escapeRtf(s.text||""),u=s.formatting,h=s.metadata;if(this.config.includeFormatting&&u){let d="",f="";if(u.bold&&(d+="\\b ",f="\\b0 "+f),u.italic&&(d+="\\i ",f="\\i0 "+f),u.underline&&(d+="\\ul ",f="\\ul0 "+f),u.strikethrough&&(d+="\\strike ",f="\\strike0 "+f),u.color){let p=this.getColorIndex(u.color);d+=`\\cf${p+1} `}if(u.backgroundColor){let p=this.getColorIndex(u.backgroundColor);d+=`\\highlight${p+1} `}if(u.size){let p=parseInt(u.size);d+=`\\fs${p*2} `}c=`{\\f0 ${d}${c}${f}}`}if(h?.link){let d=h.linkType!=="external";if(!this.config.ignoreInternalLinks||!d)return`{\\field{\\*\\fldinst{HYPERLINK "${h.link}"}}{\\fldrslt ${c}}}`}return c}case"heading":{let u=s.metadata?.level||1,h=24+(6-u)*4;return`${this.inTable?"\\pard\\intbl":"\\pard"}\\s${u}\\sb240\\sa120{\\b\\fs${h} ${a}}\\par
708
+ `}case"paragraph":{let c=this.inTable?"\\pard\\intbl":"\\pard";if(c+="\\sa120",this.config.includeFormatting&&s.metadata){let u=s.metadata;u.alignment&&(u.alignment==="center"?c+="\\qc":u.alignment==="right"?c+="\\qr":u.alignment==="justify"&&(c+="\\qj"))}return`${c} ${a}\\par
709
+ `}case"list":{let c=s.metadata,u=c?.indentation||0,h=(u+1)*360,d=c?.listType==="ordered",f=d?`${(c.itemIndex??0)+1}. `:"\\bullet ",p=d?"\\pndec":"\\pnbullet";return`${this.inTable?"\\pard\\intbl":"\\pard"}\\li${h}\\fi-360\\ilvl${u}${p} ${f}${a}\\par
710
710
  `}case"table":return`\\pard\\sa0
711
- ${a}`;case"row":return`\\trowd\\trgaph108\\trleft-108
711
+ ${a}`;case"row":{let c=s.children||[],h=Math.floor(9e3/(c.length||1)),d="";for(let f=0;f<c.length;f++)d+=`\\clbrdrt\\brdrs\\brdrw10\\clbrdrl\\brdrs\\brdrw10\\clbrdrb\\brdrs\\brdrw10\\clbrdrr\\brdrs\\brdrw10\\cellx${(f+1)*h}`;return`\\trowd\\trgaph108\\trleft-108${d}
712
712
  ${a}\\row
713
- `;case"cell":return`${this.inTable?"\\pard\\intbl":"\\pard"}\\intbl\\sb60\\sa60 ${a}\\cell
714
- `;case"break":return s.metadata?.breakType==="page"?`\\page
713
+ `}case"cell":return`\\pard\\intbl\\sb60\\sa60 ${a}\\cell
714
+ `;case"image":{if(!this.config.includeImages)return"";let u=s.metadata?.attachmentName,h=this.ast.attachments.find(d=>d.name===u);if(h&&h.data){let d=h.extension==="png"?"pngblip":"jpegblip",f=atob(h.data),p="";for(let m=0;m<f.length;m++){let y=f.charCodeAt(m).toString(16);p+=y.length===1?"0"+y:y,m%64===63&&(p+=`
715
+ `)}return`{\\pict\\${d}\\picwgoal4320\\pichgoal3240
716
+ ${p}
717
+ }
718
+ `}return""}case"break":return s.metadata?.breakType==="page"?`\\page
715
719
  `:`\\line
716
720
  `;default:return a}};for(let s of e.content)n+=await this.processNodeRecursive(s,i);return n}getColorIndex(e){let n=e.toUpperCase(),i=this.colorTable.indexOf(n);return i===-1&&(i=this.colorTable.length,this.colorTable.push(n)),i}escapeRtf(e){return e.replace(/\\/g,"\\\\").replace(/{/g,"\\{").replace(/}/g,"\\}").replace(/[^\x00-\x7F]/g,n=>`\\u${n.charCodeAt(0)}?`)}};B();var _g=class extends qn{constructor(t,e){super("text",t,e)}async generate(){let t="",e=this.config.textConfig.newlineDelimiter;this.config.renderMetadata&&this.ast.metadata&&(this.ast.metadata.title&&(t+=`Title: ${this.ast.metadata.title}${e}`),this.ast.metadata.author&&(t+=`Author: ${this.ast.metadata.author}${e}`),this.ast.metadata.created&&(t+=`Created: ${new Date(this.ast.metadata.created).toLocaleString()}${e}`),t+=`-------------------${e}${e}`);let n=async(i,s)=>{if(i.type==="text"||i.type==="code")return i.text||"";if(i.type==="break")return e;if(i.type==="image"){if(!this.config.includeImages)return"";let l=i.metadata;return`[Image: ${l?.altText||l?.attachmentName||"Untitled"}]${e}`}if(i.type==="table"&&this.config.textConfig.preserveLayout)return await this.renderTable(i,n,e);if(i.type==="list"&&this.config.textConfig.preserveLayout){let l=i.metadata,u=" ".repeat(4).repeat(l?.indentation||0),h=l?.listType==="ordered"?`${(l.itemIndex??0)+1}. `:"- ";return`${u}${h}${s.trimStart()}`+(s.endsWith(e)?"":e)}return["paragraph","heading","row","sheet","slide","note","list","table","code"].includes(i.type)?s.trim()===""?"":s+(s.endsWith(e)?"":e):s};for(let i of this.ast.content)t+=await this.processNodeRecursive(i,n);return{value:t.trim(),messages:this.messages}}async renderTable(t,e,n){if(!t.children||t.children.length===0)return"";let i=[],s=[];for(let l of t.children){let c=await this.handleOnNode(l);if(c===!1)continue;if(typeof c=="string"){i.push([c]);continue}let u=[];if(l.children)for(let h=0;h<l.children.length;h++){let d=l.children[h],f=(await this.processNodeRecursive(d,e)).trim().replace(/\r?\n/g," ");u.push(f),s[h]=Math.max(s[h]||0,f.length)}i.push(u)}let a=n;for(let l of i){a+="| ";for(let c=0;c<l.length;c++)a+=(l[c]||"").padEnd(s[c]||0)+" | ";a+=n}return a+n}};var Xs=class{static async generate(t,e,n){switch(e.toLowerCase()){case"text":return new _g(t,n).generate();case"md":return new Sg(t,n).generate();case"html":return new hu(t,n).generate();case"pdf":return new Ig(t,n).generate();case"csv":return new Tg(t,n).generate();case"rtf":return new kg(t,n).generate();case"chunks":return new yg(t,n).generate();default:throw hn("EXTENSION_UNSUPPORTED",void 0,e)}}};function An(r,t,e,n,i,s){return{config:i,type:r,metadata:t,content:e,attachments:n,warnings:[],toText:s,async to(a,l){return Xs.generate(this,a,l)}}}var Hv=async(r,t)=>{let e=r.toString("utf-8"),n=t.csvDelimiter,i=[],s=[],a="",l=!1;for(let f=0;f<e.length;f++){let p=e[f],m=e[f+1];l?p==='"'?m==='"'?(a+='"',f++):l=!1:a+=p:p==='"'?l=!0:e.substring(f,f+n.length)===n?(s.push(a),a="",f+=n.length-1):p===`
717
721
  `?(s.push(a),i.push(s),s=[],a=""):p==="\r"||(a+=p)}(a!==""||s.length>0)&&(s.push(a),i.push(s)),i.length>0&&i[i.length-1].length===1&&i[i.length-1][0]===""&&i.pop();let c=[];i.forEach((f,p)=>{if(f.length===1&&f[0].startsWith("#")){c.push({type:"comment",text:f[0]});return}let m=[];f.forEach((y,x)=>{if(y&&y.trim()!==""){let b={row:p,col:x};m.push({type:"cell",text:y,metadata:b,children:[{type:"text",text:y}]})}}),m.length>0&&c.push({type:"row",children:m})});let h={type:"sheet",metadata:{sheetName:"Sheet1"},children:c,rawContent:t.includeRawContent?e:void 0};return An("csv",{title:"Sheet1"},[h],[],t,()=>i.map(f=>f.filter(p=>p.trim()!=="").join(t.newlineDelimiter)).join(t.newlineDelimiter).replace(/\n{3,}/g,`
@@ -749,7 +753,7 @@ ${x}
749
753
  `})))}}}return W.filter(V=>V.text?.trim()||V.children&&V.children.length>0)};function q(T,I,_){let W=[];for(let z of Array.from(T?.childNodes||[])){if(!Oe(z))continue;let D=z,F=D.tagName;if(F==="p:sp")W.push(...$(D,I,_));else if(F==="p:pic"){let P=M(D,I,_);P&&W.push(P)}else if(F==="p:graphicFrame"){let P=j(D,I,_);P&&W.push(P)}else if(F==="p:grpSp"){let P=pt(D,"p:spTree");P&&W.push(...q(P,I,_))}}return W}for(let T of h)if(T.path.match(i)){let I=T.path.match(/slide(\d+)\.xml\.rels/);if(I){let _=parseInt(I[1]);x[_]={};let W=le(T.content.toString()),z=ut(W,"Relationship");for(let D=0;D<z.length;D++){let F=z[D].getAttribute("Id"),P=z[D].getAttribute("Type"),G=z[D].getAttribute("Target");if(F&&P&&G){let H="other";P.includes("relationships/image")?H="image":P.includes("relationships/hyperlink")?H="hyperlink":P.includes("relationships/chart")?H="chart":P.includes("relationships/slide")?H="slide":P.includes("relationships/notesSlide")&&(H="notes");let V=G;G.startsWith("http://")||G.startsWith("https://")||(V=V.split("/").pop()||""),x[_][F]={type:H,target:V}}}}}for(let T of h){if(T.path.match(a)||T.path.match(l)||T.path.match(i)||T.path.match(c))continue;let I=T.content.toString(),_=le(I,{locator:t.includeRawContent});t.includeRawContent&&y.push(I);let W=T.path.match(s),z=W?parseInt(W[1]):0,D=T.path.includes("notesSlide"),F={type:D?"note":"slide",children:[],metadata:{slideNumber:z,...D?{noteId:`slide-note-${z}`}:{}}};t.includeRawContent&&(F.rawContent=ee(_,I,t));let P=pt(_,"p:spTree");P&&F.children?.push(...q(P,z,I)),F.children&&F.children.length>0&&m.push(F)}let Q=[],Z=h.filter(T=>T.path.match(/ppt\/media\/.*/)),Y=h.filter(T=>T.path.match(/ppt\/charts\/chart\d+\.xml/));if(t.extractAttachments){for(let I of Z){let _=Mr(I.path.split("/").pop()||"image",I.content);if(Q.push(_),t.ocr&&_.mimeType.startsWith("image/"))try{_.ocrText=(await lr(I.content,{...t.ocrConfig})).trim()}catch(W){Ce("OCR_FAILED",t,_.name,W)}}for(let I of Y){let _={type:"chart",mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",data:I.content.toString("base64"),name:I.path.split("/").pop()||"",extension:"xml"};Q.push(_);try{let W=await pl(I.content);_.chartData=W}catch(W){Ce("CHART_DATA_EXTRACTION_FAILED",t,I.path,W)}}let T=I=>{for(let _ of I){if("attachmentName"in(_.metadata||{})){let W=_.metadata,z=Q.find(D=>D.name===W.attachmentName);z&&(_.type==="image"&&(z.altText=W.altText,z.ocrText&&(_.text=z.ocrText)),_.type==="chart"&&(_.text=z.chartData?.rawTexts.join(t.newlineDelimiter)))}_.children&&T(_.children)}};T(m)}return!t.ignoreNotes&&t.putNotesAtLast&&m.sort((T,I)=>{let _=T.type==="note"?1:0,W=I.type==="note"?1:0;return _-W}),An("pptx",f,m,Q,t,()=>m.map(T=>{let I=_=>{let W="";return _.children?W+=_.children.map(I).filter(z=>z!="").join(_.children[0]?.children?t.newlineDelimiter:""):W+=_.text||"",W};return I(T)}).filter(T=>T!="").join(t.newlineDelimiter))};B();var cF={pngblip:"png",jpegblip:"jpeg",gifblip:"gif",tiffblip:"tiff",dibitmap:"bmp",wbitmap:"bmp"},uF={png:"image/png",jpeg:"image/jpeg",gif:"image/gif",tiff:"image/tiff",bmp:"image/bmp"},M2=class{constructor(t){U(this,"index",0);U(this,"buffer");U(this,"codePage",1252);U(this,"decoders",{});U(this,"pendingBytes",[]);U(this,"length");this.buffer=t,this.length=t.length}parse(){let t={type:"group",content:[]},e=[t];for(;this.index<this.length;){let n=this.buffer[this.index],i=e[e.length-1];if(n===123){this.index++,this.flushPendingText(i);let s={type:"group",content:[]};i.content.push(s),e.push(s)}else n===125?(this.index++,this.flushPendingText(i),e.length>1&&e.pop()):n===92?(this.index++,this.parseControl(i)):n===13||n===10?this.index++:this.parseText(i)}return this.flushPendingText(t),t}parseControl(t){if(this.index>=this.length)return;let e=this.buffer[this.index];if(e===123||e===125||e===92){this.pendingBytes.push(e),this.index++;return}if(e===39){if(this.index++,this.index+1<this.length){let l=String.fromCharCode(this.buffer[this.index],this.buffer[this.index+1]),c=parseInt(l,16);isNaN(c)||this.pendingBytes.push(c),this.index+=2}return}if(this.flushPendingText(t),e===42){t.content.push({type:"control",value:"*"}),this.index++;return}let n="";for(;this.index<this.length;){let l=this.buffer[this.index];if(l>=97&&l<=122||l>=65&&l<=90)n+=String.fromCharCode(l),this.index++;else break}let i,s=!1,a="";for(this.index<this.length&&this.buffer[this.index]===45&&(a+="-",this.index++);this.index<this.length;){let l=this.buffer[this.index];if(l>=48&&l<=57)a+=String.fromCharCode(l),this.index++,s=!0;else break}if(s&&(i=parseInt(a,10)),n!==""&&this.index<this.length&&this.buffer[this.index]===32&&this.index++,n==="bin"&&i!==void 0&&i>0){this.index+=i;return}n==="ansicpg"&&i!==void 0?this.codePage=i:n==="ansi"?this.codePage=1252:n==="mac"?this.codePage=1e4:n==="pc"?this.codePage=437:n==="pca"&&(this.codePage=850),t.content.push({type:"control",value:n,param:i}),(t.content.length===1&&t.type==="group"||t.content.length===2&&t.content[0].type==="control"&&t.content[0].value==="*")&&(t.destination=n)}parseText(t){for(;this.index<this.length;){let e=this.buffer[this.index];if(e===void 0||e===123||e===125||e===92||e===13||e===10)break;this.pendingBytes.push(e),this.index++}}flushPendingText(t){this.pendingBytes.length>0&&(t.content.push({type:"text",value:this.decodeBytes(this.pendingBytes,this.codePage)}),this.pendingBytes=[])}decodeBytes(t,e){let n=new Uint8Array(t);if(t.some(s=>s>127))try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}if(!this.decoders[e]){let s=`windows-${e}`;e===1e4?s="macintosh":e===437?s="ibm437":e===850&&(s="ibm850");try{this.decoders[e]=new TextDecoder(s)}catch{if(e!==1252)try{this.decoders[e]=new TextDecoder("windows-1252")}catch{return String.fromCharCode(...t)}else return String.fromCharCode(...t)}}let i=this.decoders[e].decode(n);if(e===1252&&/[\u0080-\u009F]/.test(i)){let s={"\x80":"\u20AC","\x82":"\u201A","\x83":"\u0192","\x84":"\u201E","\x85":"\u2026","\x86":"\u2020","\x87":"\u2021","\x88":"\u02C6","\x89":"\u2030","\x8A":"\u0160","\x8B":"\u2039","\x8C":"\u0152","\x8E":"\u017D","\x91":"\u2018","\x92":"\u2019","\x93":"\u201C","\x94":"\u201D","\x95":"\u2022","\x96":"\u2013","\x97":"\u2014","\x98":"\u02DC","\x99":"\u2122","\x9A":"\u0161","\x9B":"\u203A","\x9C":"\u0153","\x9E":"\u017E","\x9F":"\u0178"};return i.replace(/[\u0080-\u009F]/g,a=>s[a]||a)}return i}},VD=async(r,t)=>{let n=new M2(r).parse(),i=hF(n),s=dF(n),a=[],l=[],c=[],u=[],h=[],d=[],f=[],p={},m=a,y=0,x="left",b=!1,w,C,E,S=[],N,k,M=[],R=0,j=0,$=()=>M.length>0?M[M.length-1]:void 0,q=()=>{M.length===0&&M.push({rows:[],currentCells:[],currentCellContent:[],rowIndex:0})},Q=!1,Z=!1,Y=0,X=[],T={isMergedContinuation:!1},I=0,_=0,W={},z=!1,D=!1,F,P,G={},H=!1,V,L,tt={},rt={},at,ft=(O,K)=>O.bold!==K.bold||O.italic!==K.italic||O.underline!==K.underline||O.strikethrough!==K.strikethrough||O.size!==K.size||O.font!==K.font||O.color!==K.color||O.backgroundColor!==K.backgroundColor||O.subscript!==K.subscript||O.superscript!==K.superscript,J=()=>{if(f.length>0){let O=f.join(""),K={type:"text",text:O,formatting:{...p}};at&&(K.metadata={link:at,linkType:Ft(at)}),h.push(K),u.push(O),f=[]}},st=!1,lt=()=>{J();let O=u.length>0||h.length>0;if(Q&&!Z&&!st&&O){let K=[...u],Tt=[...h],xt=[...d];u=[],h=[],d=[],vt(),u=K,h=Tt,d=xt}if(O){let K=u.join(""),Tt="paragraph",xt;if(C===void 0&&h.length>0){let Ot=h[0];if(Ot.type==="text"&&Ot.formatting?.bold){let Yt=parseInt(Ot.formatting.size||"12");Yt>=14&&K.length<300&&(Yt>=22?C=1:Yt>=18?C=2:Yt>=16?C=3:C=4)}}if(!b&&y>300){let Ot=K.trim();(/^[\u2022\u00b7\-\u25cf\u25cb]/.test(Ot)||/^\d+[.\)]/.test(Ot))&&(b=!0,w=/^\d+[.\)]/.test(Ot)?"ordered":"unordered")}if(C!==void 0&&C>0)Tt="heading",xt={level:C},N=void 0,k=void 0;else if(b){Tt="list";let Ot=E||N,Yt=w||k||"unordered",se=0;if(Ot){rt[Ot]||(rt[Ot]={});let _n=Object.keys(rt[Ot]).map($s=>parseInt($s));for(let $s of _n)$s>y&&delete rt[Ot][$s];rt[Ot][y]===void 0?rt[Ot][y]=0:rt[Ot][y]++,se=rt[Ot][y]}xt={listType:Yt,indentation:y,listId:Ot||"",itemIndex:se,alignment:x},Ot&&(N=Ot),Yt&&(k=Yt)}let Mt={type:Tt,text:K,children:h,formatting:void 0,metadata:{...xt,anchorIds:S.length>0?[...S]:void 0}};t.includeRawContent&&d.length>0&&(Mt.rawContent=d.join("")),Q&&Z?(q(),$().currentCellContent.push(Mt)):m.push(Mt),u=[],h=[],d=[],S=[]}},dt=O=>{lt();let K=O||$();if(!K)return;let Tt={type:"cell",text:K.currentCellContent.map(xt=>xt.text).join(`
750
754
  `),children:[...K.currentCellContent],metadata:{row:K.rowIndex,col:K.currentCells.length}};return K.currentCellContent=[],Tt},et=O=>{let K=O||$();if(!K)return;let Tt=dt(K);if(Tt&&(Tt.children&&Tt.children.length>0||Tt.text)&&K.currentCells.push(Tt),K.currentCells.length>0){let xt={type:"row",text:K.currentCells.map(Mt=>Mt.text).filter(Mt=>Mt!=="").join(t.newlineDelimiter),children:[...K.currentCells]};K.rows.push(xt),K.currentCells=[],K.rowIndex++}},vt=()=>{if(st)return;st=!0;let O=$();if(!O){st=!1;return}if(et(O),O.rows.length>0){Y++;let K={type:"table",text:O.rows.map(Tt=>Tt.text).join(`
751
755
  `),children:[...O.rows]};M.length>1?M[M.length-2].currentCellContent.push(K):m.push(K)}M.pop(),M.length===0&&(Q=!1,Z=!1),st=!1},bt=O=>{let K,Tt=xt=>{if(xt.type==="text"){let Mt=xt.value,Ot=Mt.match(/HYPERLINK\s+"([^"]+)"/i);if(Ot)return Ot[1];let Yt=Mt.match(/"(https?:\/\/[^"]+|mailto:[^"]+|#[^"]+)"/);if(Yt)return Yt[1]}else if(xt.type==="group"){let Mt=!1,Ot,Yt=!1;for(let se of xt.content)if(se.type==="text"){let _n=se.value.toUpperCase();_n.includes("HYPERLINK")&&(Mt=!0),_n.includes("\\L")&&(Yt=!0);let $s=se.value.match(/"([^"]+)"/);$s&&Mt&&(Ot=$s[1])}else if(se.type==="group"){let _n=Tt(se);_n&&(Ot=_n)}if(Ot)return Yt&&!Ot.startsWith("#")?"#"+Ot:Ot}};for(let xt of O.content)if(xt.type==="group"){let Mt=Tt(xt);if(Mt)return Mt}return K},Ft=O=>{let K=O.trim();return K.startsWith("#")||!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(K)?"internal":"external"},Ct=O=>{let K="",Tt=xt=>{if(xt.type==="text")K+=xt.value;else if(xt.type==="group")for(let Mt of xt.content)Tt(Mt)};for(let xt of O.content)Tt(xt);return K},mt=O=>{let K,Tt=[];for(let Ot of O.content)if(Ot.type==="control"){let Yt=cF[Ot.value];Yt&&(K=Yt)}else Ot.type==="text"?Tt.push(Ot.value.replace(/[^0-9a-fA-F]/g,"")):Ot.type;let xt=Tt.join("");if(!K||xt.length===0)return;let Mt=uF[K];if(Mt)try{let Ot=ct.Buffer.from(xt,"hex"),Yt=K,se=`image_${c.length+1}.${Yt}`;return{type:"image",mimeType:Mt,data:Ot.toString("base64"),name:se,extension:Yt}}catch{return}},ot=O=>{if(!/^[a-zA-Z]/.test(O.value))return`\\${O.value}`;let K=`\\${O.value}`;return O.param!==void 0&&(K+=O.param),K+=" ",K},ht=O=>{let K="";for(let Tt of O.content)Tt.type==="text"?K+=Tt.value:Tt.type==="group"&&(K+=ht(Tt));return K.trim()},gt=O=>O.value.replace(/([\\{}])/g,"\\$1"),Et=(O,K,Tt=0)=>{if(O.type==="group"){let xt=["fonttbl","colortbl","stylesheet","info","macpict","pmmetafile","wmetafile","dibitmap","bitmap","object","nextGenerator","header","footer","nonshppict","xml","private","upnp","ud","filetbl","operator","author","creatim","revtim","printim","comment","fldinst","listtext","pntext"],Mt=!1,Ot=!1,Yt=!1,se=!1;if(O.destination){if(O.destination==="footnote")Ot=!0;else if(O.destination==="field"){let Ye=bt(O);Ye&&(J(),Yt=!0,at=Ye)}else if(O.destination==="listtable")z=!0;else if(z&&O.destination==="list")D=!0,F=void 0,P=void 0;else if(O.destination==="listoverridetable")H=!0;else if(H&&O.destination==="listoverride")V=void 0,L=void 0;else if(O.destination==="pict")t.extractAttachments?se=!0:Mt=!0;else if(xt.includes(O.destination))Mt=!0;else if(O.content.length>0&&O.content[0].type==="control"&&O.content[0].value==="*"){let Ye=["fldinst","nesttableprops"];if(t.extractAttachments&&Ye.push("shppict","listpicture"),!Ye.includes(O.destination||""))if(O.destination==="bkmkstart"){let Ke=ht(O);Ke&&!S.includes(Ke)&&S.push(Ke),Mt=!0}else O.destination,Mt=!0}}if(O.destination==="listtext"||O.destination==="pntext"){b||(y=0),b=!0;let Ye=Ct(O);if(Ye){let Ke=Ye.trim();["\xB7","\u2022","o","\xA7","\u25A0","\u25A1","\u25CF","\u25CB","\u25C6","\u25C7","\u25BA","\u25B8","\xB7","\u2022","\u25CF","\u25CB"].some(Za=>Ke.includes(Za))||Ke.length===1&&!/[0-9a-zA-Z]/.test(Ke)?w="unordered":(/^[0-9ivxlcdm]+[\.\)]/i.test(Ke)||/^[a-z][\.\)]/i.test(Ke))&&(w="ordered")}Mt=!0}if(Mt)return;if(d.push("{"),se){let Ye=mt(O);Ye&&(c.push(Ye),!z&&!D&&(lt(),m.push({type:"image",text:"",metadata:{attachmentName:Ye.name||`image_${c.length}`}})));for(let Ke of O.content)if(Ke.type==="control")d.push(ot(Ke));else if(Ke.type==="text")d.push(gt(Ke));else if(Ke.type==="group"){let ru=er=>{for(let Za of er.content)Za.type==="control"?d.push(ot(Za)):Za.type==="text"?d.push(gt(Za)):Za.type==="group"&&(d.push("{"),ru(Za),d.push("}"))};ru(O)}d.push("}");return}let _n=m;if(Ot){if(t.ignoreNotes)return;lt(),R++;let Ye="footnote";j===1?Ye="endnote":j===2&&(Ye=O.content.some(er=>er.type==="control"&&er.value==="ftnalt")?"endnote":"footnote");let Ke={type:"note",children:[],metadata:{noteId:R.toString(),noteType:Ye}};l.push(Ke),m=Ke.children}let $s={...K};for(let Ye of O.content){if(Ye.type==="group"&&Ye.destination==="fldinst"){d.push("{");let Ke=ru=>{for(let er of ru.content)er.type==="control"?d.push(ot(er)):er.type==="text"?d.push(gt(er)):er.type==="group"&&(d.push("{"),Ke(er),d.push("}"))};Ke(Ye),d.push("}");continue}Et(Ye,$s,Tt+1)}O.destination==="listtable"?z=!1:O.destination==="list"?(D=!1,F!==void 0&&P!==void 0&&(G[F]=P)):O.destination==="listoverridetable"?H=!1:H&&O.destination==="listoverride"&&L!==void 0&&V!==void 0&&(tt[L]=V),Ot&&(lt(),m=_n),Yt&&(J(),at=void 0),d.push("}")}else if(O.type==="text"){if(z||H){d.push(gt(O));return}ft(p,K)&&(J(),p={...K}),f.push(O.value),d.push(gt(O))}else if(O.type==="control"){if(d.push(ot(O)),z){if(O.value==="listid")F=O.param;else if(O.value==="levelnfc"||O.value==="levelnfcn"){let xt=O.param!==void 0&&(O.param===0||O.param>=0&&O.param<=4);(!P||P==="unordered"&&xt)&&(P=xt?"ordered":"unordered")}return}if(H){O.value==="listid"?V=O.param:O.value==="ls"&&(L=O.param);return}if(O.value==="par")lt(),p={...K};else if(O.value==="trowd"){let xt=$();Q&&xt&&xt.currentCellContent.length>0?(q(),M.push({rows:[],currentCells:[],currentCellContent:[],rowIndex:0})):Q||(Q=!0,q()),Z=!0,X=[],T={isMergedContinuation:!1},I=0}else if(O.value==="clvmrg")T.isMergedContinuation=!0;else if(O.value==="clmgf")T.isMergedContinuation=!1;else if(O.value==="cellx")X.push({...T}),T={isMergedContinuation:!1};else if(O.value==="cell"){Z=!0;let xt=!1;I<X.length&&(xt=X[I].isMergedContinuation),I++;let Mt=dt();if(Mt&&!xt){let Ot=$();Ot&&Ot.currentCells.push(Mt)}p={...K}}else if(O.value==="nestcell"){if(M.length>1){let Mt=$();Mt&&(Mt.rows.length>0||Mt.currentCells.length>0)&&vt()}Z=!0;let xt=dt();if(xt){let Mt=$();Mt&&Mt.currentCells.push(xt)}p={...K}}else if(O.value==="row")et(),p={...K},I=0,Z=!1;else if(O.value==="nestrow")M.length>1&&vt(),et(),p={...K},I=0;else if(O.value==="intbl")Q=!0,Z=!0,q();else if(O.value==="pard")Z=!1,y=0,x="left",b=!1,w=void 0,C=void 0,E=void 0,K.backgroundColor=void 0;else if(O.value==="tab")ft(p,K)&&(J(),p={...K}),f.push(" ");else if(O.value==="line")ft(p,K)&&(J(),p={...K}),f.push(`
752
- `);else if(O.value==="lquote")ft(p,K)&&(J(),p={...K}),f.push("\u2018");else if(O.value==="rquote")ft(p,K)&&(J(),p={...K}),f.push("\u2019");else if(O.value==="ldblquote")ft(p,K)&&(J(),p={...K}),f.push("\u201C");else if(O.value==="rdblquote")ft(p,K)&&(J(),p={...K}),f.push("\u201D");else if(O.value==="u"){if(O.param!==void 0){let xt=O.param;xt<0&&(xt+=65536),ft(p,K)&&(J(),p={...K}),f.push(String.fromCharCode(xt))}}else if(O.value==="b")K.bold=O.param!==0;else if(O.value==="i")K.italic=O.param!==0;else if(O.value==="ul")K.underline=O.param!==0;else if(O.value==="ulnone")K.underline=!1;else if(O.value==="strike")K.strikethrough=O.param!==0;else if(O.value==="plain")K.bold=!1,K.italic=!1,K.underline=!1,K.strikethrough=!1,K.subscript=!1,K.superscript=!1,K.size=void 0,K.font=void 0,K.color=void 0,K.backgroundColor=void 0;else if(O.value==="fs")O.param!==void 0&&(K.size=(O.param/2).toString()+"pt");else if(O.value==="f")O.param!==void 0&&i[O.param]&&(K.font=i[O.param]);else if(O.value==="cf")O.param!==void 0&&s[O.param]&&(K.color=s[O.param]);else if(O.value==="fet")O.param!==void 0&&(j=O.param);else if(O.value==="cb"||O.value==="highlight"||O.value==="chcbpat"||O.value==="cbpat")O.param!==void 0&&s[O.param]&&(K.backgroundColor=s[O.param]);else if(O.value==="sub")K.subscript=!0,K.superscript=!1;else if(O.value==="super")K.superscript=!0,K.subscript=!1;else if(O.value==="nosupersub")K.subscript=!1,K.superscript=!1;else if(O.value==="li"){if(O.param!==void 0){let xt=Math.round(O.param/720);b||(y=xt)}}else if(O.value==="ls"){if(O.param!==void 0){b||(y=0),b=!0,W[O.param]||(_++,W[O.param]=`rtf-list-${_}`),E=W[O.param];let xt=tt[O.param]!==void 0?tt[O.param]:O.param;G[xt]&&(w=G[xt])}}else O.value==="ilvl"?O.param!==void 0&&(b=!0,y=O.param):O.value==="pnlvl"?(b=!0,O.param!==void 0&&(y=O.param)):O.value==="levelnfc"||O.value==="pnf"?O.param!==void 0&&(b=!0,O.param===23?w="unordered":w="ordered"):O.value==="pndec"||O.value==="pnord"||O.value==="pnlcltr"||O.value==="pnucltr"?(b||(y=0),b=!0,w="ordered"):O.value==="pnbullet"||O.value==="pncard"?(b||(y=0),b=!0,w="unordered"):O.value==="s"?O.param!==void 0&&O.param>=1&&O.param<=9&&(C=O.param):O.value==="ql"?x="left":O.value==="qc"?x="center":O.value==="qr"?x="right":O.value==="qj"&&(x="justify")}};Et(n,{});let Pt=$();if((Q||Pt&&(Pt.rows.length>0||Pt.currentCells.length>0))&&vt(),lt(),!t.putNotesAtLast&&l.length>0&&(a.push(...l),l.length=0),t.ocr&&t.extractAttachments){for(let K of c)if(K.mimeType.startsWith("image/"))try{let Tt=ct.Buffer.from(K.data,"base64");K.ocrText=(await lr(Tt,{...t.ocrConfig})).trim()}catch(Tt){Ce("OCR_FAILED",t,K.name,Tt)}let O=K=>{for(let Tt of K){if(Tt.type==="image"&&Tt.metadata&&"attachmentName"in Tt.metadata){let xt=Tt.metadata,Mt=c.find(Ot=>Ot.name===xt.attachmentName);Mt&&(Mt.ocrText&&(Tt.text=Mt.ocrText),Mt.altText&&(xt.altText=Mt.altText))}Tt.children&&O(Tt.children)}};O(a)}let wt=O=>{for(let K of O){if(K.type==="note"&&K.children){let Tt=xt=>xt.children&&xt.children.length>0?xt.children.map(Tt).join(""):xt.text||"";K.text=K.children.map(Tt).join("").trim()}K.children&&wt(K.children)}};wt(a),wt(l);let St=An("rtf",{},a,c,t,()=>{let O=a.map(K=>K.text).join(t.newlineDelimiter);return t.putNotesAtLast&&l.length>0&&(O+=t.newlineDelimiter+l.map(K=>K.text).join(t.newlineDelimiter)),O});return t.putNotesAtLast&&l.length>0&&a.push(...l),St};function O2(r,t){for(let e of r.content)if(e.type==="group"){if(e.destination===t)return e;let n=O2(e,t);if(n)return n}return null}function hF(r){let t={},e=O2(r,"fonttbl");if(e){for(let n of e.content)if(n.type==="group"){let i,s="";for(let a of n.content)a.type==="control"&&a.value==="f"?i=a.param:a.type==="text"&&(s+=a.value);i!==void 0&&s&&(t[i]=s.replace(/;$/,"").trim())}}return t}function dF(r){let t={},e=O2(r,"colortbl");if(e){let n=0,i=0,s=0,a=0;for(let l of e.content)if(l.type==="control")l.value==="red"&&l.param!==void 0?i=l.param:l.value==="green"&&l.param!==void 0?s=l.param:l.value==="blue"&&l.param!==void 0&&(a=l.param);else if(l.type==="text"&&l.value===";"){let c=`#${i.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;t[n]=c,n++,i=0,s=0,a=0}}return t}B();var XD=async(r,t)=>{let e=/word\/document[\d+]?.xml/,n=/word\/footnotes[\d+]?.xml/,i=/word\/endnotes[\d+]?.xml/,s=/word\/numbering[\d+]?.xml/,a=/(word\/)?media\/.*/,l=/docProps\/core[\d+]?.xml/,c=/docProps\/custom\.xml/,u=/word\/_rels\/document[\d+]?.xml\.rels/,h=/word\/styles[\d+]?.xml/,d=D=>{let F={},P=(dt,et)=>{let vt=pt(dt,et);if(vt){let bt=vt.getAttribute("w:val");return bt===null?!0:bt==="1"||bt==="true"||bt==="on"}return null},G=P(D,"w:b");G!==null&&(F.bold=G);let H=P(D,"w:i");H!==null&&(F.italic=H);let V=pt(D,"w:u");if(V){let dt=V.getAttribute("w:val");(!dt||dt!=="none")&&(F.underline=!0)}let L=P(D,"w:strike"),tt=P(D,"w:dstrike");L!==null?F.strikethrough=L:tt!==null&&(F.strikethrough=tt);let rt=pt(D,"w:sz");if(rt){let dt=rt.getAttribute("w:val");dt&&(F.size=(parseInt(dt,10)/2).toString()+"pt")}let at=pt(D,"w:color");if(at){let dt=at.getAttribute("w:val");dt&&dt!=="auto"&&(F.color="#"+dt)}let ft=pt(D,"w:shd");if(ft){let dt=ft.getAttribute("w:fill");dt&&dt!=="auto"&&(F.backgroundColor="#"+dt)}let J=pt(D,"w:highlight");if(J){let dt=J.getAttribute("w:val");if(dt&&dt!=="none"){let et={yellow:"#FFFF00",green:"#00FF00",cyan:"#00FFFF",magenta:"#FF00FF",blue:"#0000FF",red:"#FF0000",darkBlue:"#00008B",darkCyan:"#008B8B",darkGreen:"#006400",darkMagenta:"#8B008B",darkRed:"#8B0000",darkYellow:"#808000",darkGray:"#A9A9A9",lightGray:"#D3D3D3",black:"#000000"};F.backgroundColor=et[dt]||dt}}let st=pt(D,"w:rFonts");if(st){let dt=st.getAttribute("w:ascii")||st.getAttribute("w:hAnsi");dt&&(F.font=dt)}let lt=pt(D,"w:vertAlign");if(lt){let dt=lt.getAttribute("w:val");dt==="subscript"?F.subscript=!0:dt==="superscript"&&(F.superscript=!0)}return F},f=D=>{let F=pt(D,"w:ind");if(F){let P={},G=F.getAttribute("w:left")||F.getAttribute("w:start"),H=F.getAttribute("w:right")||F.getAttribute("w:end"),V=F.getAttribute("w:firstLine"),L=F.getAttribute("w:hanging");return G&&(P.left=parseInt(G,10)),H&&(P.right=parseInt(H,10)),V&&(P.firstLine=parseInt(V,10)),L&&(P.hanging=parseInt(L,10)),Object.keys(P).length>0?P:void 0}},p=D=>{let F=pt(D,"mc:Choice");if(F)return Array.from(F.childNodes);let P=pt(D,"mc:Fallback");return Array.from(P?P.childNodes:D.childNodes)},m=await oo(r,D=>!!D.match(e)||!!D.match(n)||!!D.match(i)||!!D.match(s)||!!D.match(l)||!!D.match(c)||!!D.match(u)||!!D.match(h)||!!t.extractAttachments&&!!D.match(a)),y=m.find(D=>D.path.match(l)),x=y?so(y.content.toString()):{},b=m.find(D=>D.path.match(c));if(b){let D=ku(b.content.toString());Object.keys(D).length>0&&(x.customProperties=D)}let w=new Map,C=new Map,E=[],S=[],N=m.filter(D=>D.path.match(a)),k=m.find(D=>D.path.match(u)),M={};if(k){let D=le(k.content.toString()),F=ut(D,"Relationship");for(let P of F){let G=P.getAttribute("Id"),H=P.getAttribute("Target");G&&H&&(M[G]=H)}}let R=m.find(D=>D.path.match(s)),j={};if(R){let D=le(R.content.toString()),F=ut(D,"w:num"),P=ut(D,"w:abstractNum"),G={};for(let H of P){let V=H.getAttribute("w:abstractNumId");V&&(G[V]=H)}for(let H of F){let V=H.getAttribute("w:numId"),tt=pt(H,"w:abstractNumId")?.getAttribute("w:val");if(V&&tt&&G[tt]){j[V]={};let rt=ut(G[tt],"w:lvl");for(let ft of rt){let J=ft.getAttribute("w:ilvl"),st=pt(ft,"w:numFmt"),lt=pt(ft,"w:lvlText"),dt=pt(ft,"w:start");J&&(j[V][J]={numFmt:st?.getAttribute("w:val")||"decimal",lvlText:lt?.getAttribute("w:val")||"",start:parseInt(dt?.getAttribute("w:val")||"1",10)})}let at=ut(H,"w:lvlOverride");for(let ft of at){let J=ft.getAttribute("w:ilvl");if(J&&j[V][J]){let st=pt(ft,"w:startOverride");st&&(j[V][J].start=parseInt(st.getAttribute("w:val")||"1",10))}}}}}let $=m.find(D=>D.path.match(h)),q={};if($){let D=le($.content.toString()),F=ut(D,"w:style");for(let P of F){let G=P.getAttribute("w:styleId");if(G){let H=pt(P,"w:rPr"),V=pt(P,"w:pPr"),L=H?d(H):{},tt,rt,at;if(V){let ft=pt(V,"w:jc");if(ft){let lt=ft.getAttribute("w:val");(lt==="left"||lt==="center"||lt==="right"||lt==="justify")&&(tt=lt)}let J=pt(V,"w:shd");if(J){let lt=J.getAttribute("w:fill");lt&&lt!=="auto"&&(rt="#"+lt)}let st=f(V);st&&(at=st)}q[G]={formatting:L,alignment:tt,backgroundColor:rt,paragraphIndentation:at}}}}let Q={};if($){let D=le($.content.toString()),F=pt(D,"w:docDefaults");if(F){let P=pt(F,"w:rPrDefault");if(P){let G=pt(P,"w:rPr");G&&(Q=d(G))}}}let Z;if($){let D=le($.content.toString()),F=ut(D,"w:style");for(let P of F){let G=P.getAttribute("w:type"),H=P.getAttribute("w:default"),V=P.getAttribute("w:styleId");if(G==="paragraph"&&H==="1"&&V){Z=V;break}}!Z&&q.Normal&&(Z="Normal")}let Y=[],X=[],T={},I={},_=(D,F,P=[])=>{let G=pt(D,"w:numPr"),H=!!G,V=pt(D,"w:pPr"),tt=(V?pt(V,"w:pStyle"):null)?.getAttribute("w:val"),rt=tt?tt.startsWith("Heading")||tt==="Title":!1,at=tt&&q[tt]?q[tt]:{formatting:{}},ft=at.alignment;if(V){let mt=pt(V,"w:jc");if(mt){let ot=mt.getAttribute("w:val");(ot==="left"||ot==="center"||ot==="right"||ot==="justify")&&(ft=ot)}}let J=at.paragraphIndentation;if(V){let mt=f(V);mt&&(J={...J,...mt})}let st=at.backgroundColor;if(V){let mt=pt(V,"w:shd");if(mt){let ot=mt.getAttribute("w:fill");ot&&ot!=="auto"&&(st="#"+ot)}}let lt={...at.formatting};if(V){let mt=pt(V,"w:rPr");if(mt){let ot=d(mt);for(let ht in ot){let gt=ot[ht];gt===!1?delete lt[ht]:gt!==void 0&&(lt[ht]=gt)}}}let dt="",et=[],vt=mt=>{if(Oe(mt)&&mt.nodeName==="w:r"){let ot=mt,ht=pt(ot,"w:rPr"),gt={};for(let wt in lt)gt[wt]=lt[wt];let Et=ht?pt(ht,"w:rStyle"):null,Pt=Et?Et.getAttribute("w:val"):tt;if(Pt&&q[Pt])for(let wt in q[Pt].formatting)gt[wt]=q[Pt].formatting[wt];if(ht){let wt=d(ht);for(let kt in wt){let St=wt[kt];St===!1?delete gt[kt]:St!==void 0&&(gt[kt]=St)}}!gt.backgroundColor&&st&&(gt.backgroundColor=st);for(let wt of ot.childNodes)if(Oe(wt)){if(wt.tagName==="w:t"||wt.tagName==="t"){let kt=wt,St=kt.textContent||"";dt+=St;let O={type:"text",text:St,formatting:gt};t.includeRawContent&&(O.rawContent=ee(kt,F,t));let K=Pt||tt||Z;K&&(O.metadata={style:K}),et.push(O)}else if(t.includeBreakNodes&&(wt.tagName==="w:br"||wt.tagName==="br"||wt.tagName==="w:cr"||wt.tagName==="cr")){let kt=wt,St="textWrapping";if(wt.tagName==="w:cr"||wt.tagName==="cr")St="carriageReturn";else{let Tt=kt.getAttribute("w:type")||kt.getAttribute("type");Tt!==null&&(St=Tt)}let O;St==="textWrapping"&&kt.getAttribute("w:clear")!==null&&(O=kt.getAttribute("w:clear"));let K={type:"break",metadata:{breakType:St,clear:O}};t.includeRawContent&&(K.rawContent=ee(kt,F,t)),et.push(K)}else if(t.includeBreakNodes&&(wt.tagName==="w:lastRenderedPageBreak"||wt.tagName==="lastRenderedPageBreak")){let kt={type:"break",metadata:{breakType:"lastRenderedPage"}};t.includeRawContent&&(kt.rawContent=ee(wt,F,t)),et.push(kt)}}if(t.extractAttachments){let wt=ut(ot,"w:drawing"),kt=ut(ot,"w:pict"),St=[...wt,...kt];for(let O of St){let K=mx(O),Tt="",xt=pt(O,"wp:docPr");xt&&(Tt=xt.getAttribute("descr")||xt.getAttribute("title")||"");let Mt="",Ot=pt(O,"a:blip");if(Ot)Mt=Ot.getAttribute("r:embed")||"";else{let Yt=pt(O,"v:imagedata");Yt&&(Mt=Yt.getAttribute("r:id")||"")}if(Mt&&M[Mt]){let se=M[Mt].split("/").pop();if(se){let _n={type:"image",text:"",metadata:{attachmentName:se,altText:Tt}};t.includeRawContent&&(_n.rawContent=ee(O,F,t)),et.push(_n)}}else{let Yt={type:"image",text:""};t.includeRawContent&&(Yt.rawContent=ee(O,F,t)),et.push(Yt)}}}if(!t.ignoreNotes){let wt=pt(ot,"w:footnoteReference");if(wt){let St=wt.getAttribute("w:id");if(St&&w.has(St)){let O=w.get(St),K={type:"note",text:O.map(Tt=>Tt.text).join(" "),children:O,metadata:{noteType:"footnote",noteId:St}};t.putNotesAtLast?E.push(K):et.push(K)}}let kt=pt(ot,"w:endnoteReference");if(kt){let St=kt.getAttribute("w:id");if(St&&C.has(St)){let O=C.get(St),K={type:"note",text:O.map(Tt=>Tt.text).join(" "),children:O,metadata:{noteType:"endnote",noteId:St}};t.putNotesAtLast?E.push(K):et.push(K)}}}}else if(Oe(mt)&&mt.nodeName==="w:hyperlink"){let ot=mt,ht=ot.getAttribute("r:id"),gt=ot.getAttribute("w:anchor"),Et;gt&&!t.ignoreInternalLinks?Et={link:"#"+gt,linkType:"internal"}:ht&&M[ht]&&(Et={link:M[ht],linkType:"external"});let Pt=Array.from(ot.childNodes);for(let wt of Pt){let kt=et.length;if(vt(wt),Et)for(let St=kt;St<et.length;St++)et[St].type==="text"&&(et[St].metadata={...et[St].metadata??{},...Et})}}else if(Oe(mt)&&mt.nodeName==="w:bookmarkStart"){let ot=mt.getAttribute("w:name");ot&&!ot.startsWith("_GoBack")&&!t.ignoreInternalLinks&&bt.push(ot)}else if(Oe(mt)&&(mt.nodeName==="mc:AlternateContent"||mt.nodeName==="AlternateContent")){let ot=p(mt);for(let ht of ot)vt(ht)}else if(Oe(mt)&&(mt.nodeName==="w:pict"||mt.nodeName==="pict"||mt.nodeName==="w:drawing"||mt.nodeName==="drawing")){let ot=ut(mt,"w:txbxContent");for(let ht of ot){let gt=Array.from(ht.childNodes);for(let Et of gt)if(Oe(Et)&&Et.nodeName==="w:p"){let Pt=_(Et,F);et.push(...Pt.children||[]),dt+=Pt.text}}}else if(mt.childNodes.length>0)for(let ot of Array.from(mt.childNodes))vt(ot)},bt=[...P],Ft=Array.from(D.childNodes);for(let mt of Ft)vt(mt);let Ct=bt.length>0?{anchorIds:bt}:{};if(H){let mt=pt(G,"w:numId"),ot=pt(G,"w:ilvl"),ht=mt&&mt.getAttribute("w:val")||"0",gt=ot?parseInt(ot.getAttribute("w:val")||"0",10):0,Et="ordered",Pt=0;if(ht&&j[ht]){let kt=gt.toString();T[ht]||(T[ht]={}),T[ht][kt]||(T[ht][kt]=0),T[ht][kt]++;for(let O=gt+1;O<10;O++)T[ht][O.toString()]&&(T[ht][O.toString()]=0);Et=(j[ht][kt]?.numFmt||"decimal")==="bullet"?"unordered":"ordered",I[ht]||(I[ht]={}),I[ht][kt]===void 0?I[ht][kt]=(j[ht][kt]?.start??1)-1:I[ht][kt]++,Pt=I[ht][kt]}let wt={type:"list",text:dt,children:et,metadata:{listType:Et,indentation:gt,paragraphIndentation:J,alignment:ft||"left",listId:ht,itemIndex:Pt,style:tt,...Ct}};return t.includeRawContent&&(wt.rawContent=ee(D,F,t)),wt}else if(rt){let mt=tt&&parseInt(tt.replace("Heading",""),10)||1,ot={type:"heading",text:dt,children:et,metadata:{level:mt,alignment:ft,paragraphIndentation:J,style:tt??void 0,...Ct}};return t.includeRawContent&&(ot.rawContent=ee(D,F,t)),ot}else{let mt={type:"paragraph",text:dt,children:et,metadata:{alignment:ft,paragraphIndentation:J,style:tt??void 0,...Ct}};return t.includeRawContent&&(mt.rawContent=ee(D,F,t)),mt}},W=(D,F,P=[])=>{let G=[],H=Qe(D,"w:tr"),V=new Map;for(let L=0;L<H.length;L++){let tt=H[L],rt=[],at=Qe(tt,"w:tc"),ft=0;for(let st=0;st<at.length;st++){let lt=at[st],dt=pt(lt,"w:tcPr"),et=1;if(dt){let ht=pt(dt,"w:gridSpan");ht&&(et=parseInt(ht.getAttribute("w:val")||"1",10))}let vt=!1,bt=!1;if(dt){let ht=pt(dt,"w:vMerge");ht&&(bt=!0,(ht.getAttribute("w:val")==="restart"||!V.has(ft))&&(vt=!0))}let Ft=[],Ct="",mt=Array.from(lt.childNodes);for(let ht of mt)if(Oe(ht)&&ht.nodeName==="w:p"){let gt=_(ht,F);Ft.push(gt),Ct+=gt.text}else if(Oe(ht)&&ht.nodeName==="w:tbl"){let gt=W(ht,F);Ft.push(gt)}let ot={type:"cell",text:Ct,children:Ft,metadata:{row:L,col:ft}};if(et>1&&(ot.metadata.colSpan=et),bt)if(vt)V.set(ft,{node:ot,span:1}),rt.push(ot);else{let ht=V.get(ft);ht?(ht.span++,ht.node.metadata.rowSpan=ht.span,Ft.length>0&&(ht.node.children||(ht.node.children=[]),ht.node.children.push(...Ft),ht.node.text+=" "+Ct)):rt.push(ot)}else V.delete(ft),rt.push(ot);ft+=et}let J={type:"row",children:rt};G.push(J)}return{type:"table",children:G}};if(!t.ignoreNotes){let D=m.find(P=>P.path.match(n));if(D){let P=le(D.content.toString()),G=D.content.toString(),H=ut(P,"w:footnote");for(let V of H){let L=V.getAttribute("w:id");if(!L||L==="-1"||L==="0")continue;let tt=ut(V,"w:p");w.set(L,tt.map(rt=>_(rt,G)))}}let F=m.find(P=>P.path.match(i));if(F){let P=le(F.content.toString()),G=F.content.toString(),H=ut(P,"w:endnote");for(let V of H){let L=V.getAttribute("w:id");if(!L||L==="-1"||L==="0")continue;let tt=ut(V,"w:p");C.set(L,tt.map(rt=>_(rt,G)))}}}for(let D of m){if(D.path.match(a)||D.path.match(s)||D.path.match(u)||D.path.match(h)||D.path.match(n)||D.path.match(i))continue;let F=D.content.toString();t.includeRawContent&&X.push(F);let P=le(F,{locator:t.includeRawContent}),G=pt(P,"w:body");if(G){let H=Array.from(G.childNodes),V=[];for(let L of H)if(Oe(L)){if(L.nodeName==="w:p")Y.push(_(L,F,V)),V=[];else if(L.nodeName==="w:tbl")Y.push(W(L,F,V)),V=[];else if(L.nodeName==="w:bookmarkStart"){let tt=L.getAttribute("w:name");tt&&!tt.startsWith("_GoBack")&&!t.ignoreInternalLinks&&V.push(tt)}}}}if(t.extractAttachments){for(let D of N){let F=Mr(D.path.split("/").pop()||"image",D.content);if(S.push(F),t.ocr&&F.mimeType.startsWith("image/"))try{F.ocrText=(await lr(D.content,{...t.ocrConfig})).trim()}catch(P){Ce("OCR_FAILED",t,F.name,P)}}if(t.ocr){let D=F=>{for(let P of F){if(P.type==="image"&&"attachmentName"in(P.metadata||{})){let G=P.metadata,H=S.find(V=>V.name===G.attachmentName);H&&H.ocrText&&(P.text=H.ocrText,H.altText=G.altText)}P.children&&D(P.children)}};D(Y)}}t.putNotesAtLast&&E.length>0&&Y.push(...E);let z=()=>Y.map(D=>{let F=P=>{let G="";return P.children?G+=P.children.map(F).filter(H=>H!="").join(P.children[0]?.children?t.newlineDelimiter:""):P.type==="break"?G+=t.newlineDelimiter:G+=P.text||"",G};return F(D)}).filter(D=>D!="").join(t.newlineDelimiter);return An("docx",{...x,formatting:Q,styleMap:q},Y,S,t,z)};var Ka=class{static async parseOffice(t,e,n){let i,s={};typeof e=="function"?(i=e,s=n||{}):s=e||{};let a=pv(s),l=[],c=a.onWarning;a.onWarning=f=>{l.push(f),c&&c(f)};let u=ct.Buffer.alloc(0),h=a.fileType??"",d;try{if(!t)throw hn("IMPROPER_ARGUMENTS",a);if(t instanceof ArrayBuffer)u=ct.Buffer.from(t);else if(ct.Buffer.isBuffer(t))u=t;else if(typeof t=="string"){d=t,Ng("path-parsing");let p=await Promise.resolve().then(()=>(rN(),iN));if(!p.existsSync(t))throw hn("FILE_DOES_NOT_EXIST",a,t);if(p.lstatSync(t).isDirectory())throw hn("LOCATION_NOT_FOUND",a,t);u=p.readFileSync(t),h=h||t.split(".").pop()||""}else throw hn("INVALID_INPUT",a);if(u.length>0&&!h)try{let{fileTypeFromBuffer:p}=await _2(),m=await p(u);m&&(h=m.ext)}catch(p){Ce("FILE_TYPE_DETECTION_FAILED",a,{error:p})}else if(u.length>0&&h)try{let{fileTypeFromBuffer:p}=await _2(),m=await p(u);m&&m.ext.toLowerCase()!==h.toLowerCase()&&Ce("BUFFER_TYPE_MISMATCH",a,{detected:m.ext,expected:h})}catch(p){Ce("FILE_TYPE_DETECTION_FAILED",a,{error:p})}if(!h)throw hn("IMPROPER_BUFFERS",a);let f;switch(h.toLowerCase()){case"docx":f=await XD(u,a);break;case"pptx":f=await qD(u,a);break;case"xlsx":f=await HE(u,a);break;case"odt":case"odp":case"ods":f=await VE(u,a);break;case"pdf":f=await WD(u,a);break;case"rtf":f=await VD(u,a);break;case"csv":f=await Hv(u,a);break;case"html":f=await WE(u,a);break;case"md":f=await qE(u,a);break;default:throw hn("EXTENSION_UNSUPPORTED",a,h)}return f.warnings=l,i&&i(f),f}catch(f){let p=fv(f,a,d);throw i&&i(void 0,p),p}}static async terminateOcr(){await GE()}};B();var cg=class{static async convert(t,e,n){let i={...n?.parseConfig,onWarning:n?.onWarning||n?.parseConfig?.onWarning};i.ocr=!1,Object.keys(i).forEach(c=>i[c]===void 0&&delete i[c]),i.extractAttachments=n?.generatorConfig?.includeImages!==!1||n?.generatorConfig?.includeCharts!==!1;let s=await Ka.parseOffice(t,i),a={...n?.generatorConfig,onWarning:n?.onWarning||n?.generatorConfig?.onWarning},l=await Xs.generate(s,e,a);return l.messages=[...s.warnings||[],...l.messages],l}};var pF=Ka.parseOffice,mF=Ka.terminateOcr,gF=cg.convert,yF=Xs.generate;var bF=Ka;return hN(xF);})();
756
+ `);else if(O.value==="lquote")ft(p,K)&&(J(),p={...K}),f.push("\u2018");else if(O.value==="rquote")ft(p,K)&&(J(),p={...K}),f.push("\u2019");else if(O.value==="ldblquote")ft(p,K)&&(J(),p={...K}),f.push("\u201C");else if(O.value==="rdblquote")ft(p,K)&&(J(),p={...K}),f.push("\u201D");else if(O.value==="u"){if(O.param!==void 0){let xt=O.param;xt<0&&(xt+=65536),ft(p,K)&&(J(),p={...K}),f.push(String.fromCharCode(xt))}}else if(O.value==="b")K.bold=O.param!==0;else if(O.value==="i")K.italic=O.param!==0;else if(O.value==="ul")K.underline=O.param!==0;else if(O.value==="ulnone")K.underline=!1;else if(O.value==="strike")K.strikethrough=O.param!==0;else if(O.value==="plain")K.bold=!1,K.italic=!1,K.underline=!1,K.strikethrough=!1,K.subscript=!1,K.superscript=!1,K.size=void 0,K.font=void 0,K.color=void 0,K.backgroundColor=void 0;else if(O.value==="fs")O.param!==void 0&&(K.size=(O.param/2).toString()+"pt");else if(O.value==="f")O.param!==void 0&&i[O.param]&&(K.font=i[O.param]);else if(O.value==="cf")O.param!==void 0&&s[O.param]&&(K.color=s[O.param]);else if(O.value==="fet")O.param!==void 0&&(j=O.param);else if(O.value==="cb"||O.value==="highlight"||O.value==="chcbpat"||O.value==="cbpat")O.param!==void 0&&s[O.param]&&(K.backgroundColor=s[O.param]);else if(O.value==="sub")K.subscript=!0,K.superscript=!1;else if(O.value==="super")K.superscript=!0,K.subscript=!1;else if(O.value==="nosupersub")K.subscript=!1,K.superscript=!1;else if(O.value==="li"){if(O.param!==void 0){let xt=Math.round(O.param/720);b||(y=xt)}}else if(O.value==="ls"){if(O.param!==void 0){b||(y=0),b=!0,W[O.param]||(_++,W[O.param]=`rtf-list-${_}`),E=W[O.param];let xt=tt[O.param]!==void 0?tt[O.param]:O.param;G[xt]&&(w=G[xt])}}else O.value==="ilvl"?O.param!==void 0&&(b=!0,y=O.param):O.value==="pnlvl"?(b=!0,O.param!==void 0&&(y=O.param)):O.value==="levelnfc"||O.value==="pnf"?O.param!==void 0&&(b=!0,O.param===23?w="unordered":w="ordered"):O.value==="pndec"||O.value==="pnord"||O.value==="pnlcltr"||O.value==="pnucltr"?(b||(y=0),b=!0,w="ordered"):O.value==="pnbullet"||O.value==="pncard"?(b||(y=0),b=!0,w="unordered"):O.value==="s"?O.param!==void 0&&O.param>=1&&O.param<=9&&(C=O.param):O.value==="ql"?x="left":O.value==="qc"?x="center":O.value==="qr"?x="right":O.value==="qj"&&(x="justify")}};Et(n,{});let Pt=$();if((Q||Pt&&(Pt.rows.length>0||Pt.currentCells.length>0))&&vt(),lt(),!t.putNotesAtLast&&l.length>0&&(a.push(...l),l.length=0),t.ocr&&t.extractAttachments){for(let K of c)if(K.mimeType.startsWith("image/"))try{let Tt=ct.Buffer.from(K.data,"base64");K.ocrText=(await lr(Tt,{...t.ocrConfig})).trim()}catch(Tt){Ce("OCR_FAILED",t,K.name,Tt)}let O=K=>{for(let Tt of K){if(Tt.type==="image"&&Tt.metadata&&"attachmentName"in Tt.metadata){let xt=Tt.metadata,Mt=c.find(Ot=>Ot.name===xt.attachmentName);Mt&&(Mt.ocrText&&(Tt.text=Mt.ocrText),Mt.altText&&(xt.altText=Mt.altText))}Tt.children&&O(Tt.children)}};O(a)}let wt=O=>{for(let K of O){if(K.type==="note"&&K.children){let Tt=xt=>xt.children&&xt.children.length>0?xt.children.map(Tt).join(""):xt.text||"";K.text=K.children.map(Tt).join("").trim()}K.children&&wt(K.children)}};wt(a),wt(l);let St=An("rtf",{},a,c,t,()=>{let O=a.map(K=>K.text).join(t.newlineDelimiter);return t.putNotesAtLast&&l.length>0&&(O+=t.newlineDelimiter+l.map(K=>K.text).join(t.newlineDelimiter)),O});return t.putNotesAtLast&&l.length>0&&a.push(...l),St};function O2(r,t){for(let e of r.content)if(e.type==="group"){if(e.destination===t)return e;let n=O2(e,t);if(n)return n}return null}function hF(r){let t={},e=O2(r,"fonttbl");if(e){for(let n of e.content)if(n.type==="group"){let i,s="";for(let a of n.content)a.type==="control"&&a.value==="f"?i=a.param:a.type==="text"&&(s+=a.value);i!==void 0&&s&&(t[i]=s.replace(/;$/,"").trim())}}return t}function dF(r){let t={},e=O2(r,"colortbl");if(e){let n=0,i=0,s=0,a=0;for(let l of e.content)if(l.type==="control")l.value==="red"&&l.param!==void 0?i=l.param:l.value==="green"&&l.param!==void 0?s=l.param:l.value==="blue"&&l.param!==void 0&&(a=l.param);else if(l.type==="text"&&l.value===";"){let c=`#${i.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;t[n]=c,n++,i=0,s=0,a=0}}return t}B();var XD=async(r,t)=>{let e=/word\/document[\d+]?.xml/,n=/word\/footnotes[\d+]?.xml/,i=/word\/endnotes[\d+]?.xml/,s=/word\/numbering[\d+]?.xml/,a=/(word\/)?media\/.*/,l=/docProps\/core[\d+]?.xml/,c=/docProps\/custom\.xml/,u=/word\/_rels\/document[\d+]?.xml\.rels/,h=/word\/styles[\d+]?.xml/,d=D=>{let F={},P=(dt,et)=>{let vt=pt(dt,et);if(vt){let bt=vt.getAttribute("w:val");return bt===null?!0:bt==="1"||bt==="true"||bt==="on"}return null},G=P(D,"w:b");G!==null&&(F.bold=G);let H=P(D,"w:i");H!==null&&(F.italic=H);let V=pt(D,"w:u");if(V){let dt=V.getAttribute("w:val");(!dt||dt!=="none")&&(F.underline=!0)}let L=P(D,"w:strike"),tt=P(D,"w:dstrike");L!==null?F.strikethrough=L:tt!==null&&(F.strikethrough=tt);let rt=pt(D,"w:sz");if(rt){let dt=rt.getAttribute("w:val");dt&&(F.size=(parseInt(dt,10)/2).toString()+"pt")}let at=pt(D,"w:color");if(at){let dt=at.getAttribute("w:val");dt&&dt!=="auto"&&(F.color="#"+dt)}let ft=pt(D,"w:shd");if(ft){let dt=ft.getAttribute("w:fill");dt&&dt!=="auto"&&(F.backgroundColor="#"+dt)}let J=pt(D,"w:highlight");if(J){let dt=J.getAttribute("w:val");if(dt&&dt!=="none"){let et={yellow:"#FFFF00",green:"#00FF00",cyan:"#00FFFF",magenta:"#FF00FF",blue:"#0000FF",red:"#FF0000",darkBlue:"#00008B",darkCyan:"#008B8B",darkGreen:"#006400",darkMagenta:"#8B008B",darkRed:"#8B0000",darkYellow:"#808000",darkGray:"#A9A9A9",lightGray:"#D3D3D3",black:"#000000"};F.backgroundColor=et[dt]||dt}}let st=pt(D,"w:rFonts");if(st){let dt=st.getAttribute("w:ascii")||st.getAttribute("w:hAnsi");dt&&(F.font=dt)}let lt=pt(D,"w:vertAlign");if(lt){let dt=lt.getAttribute("w:val");dt==="subscript"?F.subscript=!0:dt==="superscript"&&(F.superscript=!0)}return F},f=D=>{let F=pt(D,"w:ind");if(F){let P={},G=F.getAttribute("w:left")||F.getAttribute("w:start"),H=F.getAttribute("w:right")||F.getAttribute("w:end"),V=F.getAttribute("w:firstLine"),L=F.getAttribute("w:hanging");return G&&(P.left=parseInt(G,10)),H&&(P.right=parseInt(H,10)),V&&(P.firstLine=parseInt(V,10)),L&&(P.hanging=parseInt(L,10)),Object.keys(P).length>0?P:void 0}},p=D=>{let F=pt(D,"mc:Choice");if(F)return Array.from(F.childNodes);let P=pt(D,"mc:Fallback");return Array.from(P?P.childNodes:D.childNodes)},m=await oo(r,D=>!!D.match(e)||!!D.match(n)||!!D.match(i)||!!D.match(s)||!!D.match(l)||!!D.match(c)||!!D.match(u)||!!D.match(h)||!!t.extractAttachments&&!!D.match(a)),y=m.find(D=>D.path.match(l)),x=y?so(y.content.toString()):{},b=m.find(D=>D.path.match(c));if(b){let D=ku(b.content.toString());Object.keys(D).length>0&&(x.customProperties=D)}let w=new Map,C=new Map,E=[],S=[],N=m.filter(D=>D.path.match(a)),k=m.find(D=>D.path.match(u)),M={};if(k){let D=le(k.content.toString()),F=ut(D,"Relationship");for(let P of F){let G=P.getAttribute("Id"),H=P.getAttribute("Target");G&&H&&(M[G]=H)}}let R=m.find(D=>D.path.match(s)),j={};if(R){let D=le(R.content.toString()),F=ut(D,"w:num"),P=ut(D,"w:abstractNum"),G={};for(let H of P){let V=H.getAttribute("w:abstractNumId");V&&(G[V]=H)}for(let H of F){let V=H.getAttribute("w:numId"),tt=pt(H,"w:abstractNumId")?.getAttribute("w:val");if(V&&tt&&G[tt]){j[V]={};let rt=ut(G[tt],"w:lvl");for(let ft of rt){let J=ft.getAttribute("w:ilvl"),st=pt(ft,"w:numFmt"),lt=pt(ft,"w:lvlText"),dt=pt(ft,"w:start");J&&(j[V][J]={numFmt:st?.getAttribute("w:val")||"decimal",lvlText:lt?.getAttribute("w:val")||"",start:parseInt(dt?.getAttribute("w:val")||"1",10)})}let at=ut(H,"w:lvlOverride");for(let ft of at){let J=ft.getAttribute("w:ilvl");if(J&&j[V][J]){let st=pt(ft,"w:startOverride");st&&(j[V][J].start=parseInt(st.getAttribute("w:val")||"1",10))}}}}}let $=m.find(D=>D.path.match(h)),q={};if($){let D=le($.content.toString()),F=ut(D,"w:style");for(let P of F){let G=P.getAttribute("w:styleId");if(G){let H=pt(P,"w:rPr"),V=pt(P,"w:pPr"),L=H?d(H):{},tt,rt,at;if(V){let ft=pt(V,"w:jc");if(ft){let lt=ft.getAttribute("w:val");(lt==="left"||lt==="center"||lt==="right"||lt==="justify")&&(tt=lt)}let J=pt(V,"w:shd");if(J){let lt=J.getAttribute("w:fill");lt&&lt!=="auto"&&(rt="#"+lt)}let st=f(V);st&&(at=st)}q[G]={formatting:L,alignment:tt,backgroundColor:rt,paragraphIndentation:at}}}}let Q={};if($){let D=le($.content.toString()),F=pt(D,"w:docDefaults");if(F){let P=pt(F,"w:rPrDefault");if(P){let G=pt(P,"w:rPr");G&&(Q=d(G))}}}let Z;if($){let D=le($.content.toString()),F=ut(D,"w:style");for(let P of F){let G=P.getAttribute("w:type"),H=P.getAttribute("w:default"),V=P.getAttribute("w:styleId");if(G==="paragraph"&&H==="1"&&V){Z=V;break}}!Z&&q.Normal&&(Z="Normal")}let Y=[],X=[],T={},I={},_=(D,F,P=[])=>{let G=pt(D,"w:numPr"),H=!!G,V=pt(D,"w:pPr"),tt=(V?pt(V,"w:pStyle"):null)?.getAttribute("w:val"),rt=tt?tt.startsWith("Heading")||tt==="Title":!1,at=tt&&q[tt]?q[tt]:{formatting:{}},ft=at.alignment;if(V){let mt=pt(V,"w:jc");if(mt){let ot=mt.getAttribute("w:val");(ot==="left"||ot==="center"||ot==="right"||ot==="justify")&&(ft=ot)}}let J=at.paragraphIndentation;if(V){let mt=f(V);mt&&(J={...J,...mt})}let st=at.backgroundColor;if(V){let mt=pt(V,"w:shd");if(mt){let ot=mt.getAttribute("w:fill");ot&&ot!=="auto"&&(st="#"+ot)}}let lt={...at.formatting};if(V){let mt=pt(V,"w:rPr");if(mt){let ot=d(mt);for(let ht in ot){let gt=ot[ht];gt===!1?delete lt[ht]:gt!==void 0&&(lt[ht]=gt)}}}let dt="",et=[],vt=mt=>{if(Oe(mt)&&mt.nodeName==="w:r"){let ot=mt,ht=pt(ot,"w:rPr"),gt={};for(let wt in lt)gt[wt]=lt[wt];let Et=ht?pt(ht,"w:rStyle"):null,Pt=Et?Et.getAttribute("w:val"):tt;if(Pt&&q[Pt])for(let wt in q[Pt].formatting)gt[wt]=q[Pt].formatting[wt];if(ht){let wt=d(ht);for(let kt in wt){let St=wt[kt];St===!1?delete gt[kt]:St!==void 0&&(gt[kt]=St)}}!gt.backgroundColor&&st&&(gt.backgroundColor=st);for(let wt of ot.childNodes)if(Oe(wt)){if(wt.tagName==="w:t"||wt.tagName==="t"){let kt=wt,St=kt.textContent||"";dt+=St;let O={type:"text",text:St,formatting:gt};t.includeRawContent&&(O.rawContent=ee(kt,F,t));let K=Pt||tt||Z;K&&(O.metadata={style:K}),et.push(O)}else if(t.includeBreakNodes&&(wt.tagName==="w:br"||wt.tagName==="br"||wt.tagName==="w:cr"||wt.tagName==="cr")){let kt=wt,St="textWrapping";if(wt.tagName==="w:cr"||wt.tagName==="cr")St="carriageReturn";else{let Tt=kt.getAttribute("w:type")||kt.getAttribute("type");Tt!==null&&(St=Tt)}let O;St==="textWrapping"&&kt.getAttribute("w:clear")!==null&&(O=kt.getAttribute("w:clear"));let K={type:"break",metadata:{breakType:St,clear:O}};t.includeRawContent&&(K.rawContent=ee(kt,F,t)),et.push(K)}else if(t.includeBreakNodes&&(wt.tagName==="w:lastRenderedPageBreak"||wt.tagName==="lastRenderedPageBreak")){let kt={type:"break",metadata:{breakType:"lastRenderedPage"}};t.includeRawContent&&(kt.rawContent=ee(wt,F,t)),et.push(kt)}}if(t.extractAttachments){let wt=ut(ot,"w:drawing"),kt=ut(ot,"w:pict"),St=[...wt,...kt];for(let O of St){let K=mx(O),Tt="",xt=pt(O,"wp:docPr");xt&&(Tt=xt.getAttribute("descr")||xt.getAttribute("title")||"");let Mt="",Ot=pt(O,"a:blip");if(Ot)Mt=Ot.getAttribute("r:embed")||"";else{let Yt=pt(O,"v:imagedata");Yt&&(Mt=Yt.getAttribute("r:id")||"")}if(Mt&&M[Mt]){let se=M[Mt].split("/").pop();if(se){let _n={type:"image",text:"",metadata:{attachmentName:se,altText:Tt}};t.includeRawContent&&(_n.rawContent=ee(O,F,t)),et.push(_n)}}else{let Yt={type:"image",text:""};t.includeRawContent&&(Yt.rawContent=ee(O,F,t)),et.push(Yt)}}}if(!t.ignoreNotes){let wt=pt(ot,"w:footnoteReference");if(wt){let St=wt.getAttribute("w:id");if(St&&w.has(St)){let O=w.get(St),K={type:"note",text:O.map(Tt=>Tt.text).join(" "),children:O,metadata:{noteType:"footnote",noteId:St}};t.putNotesAtLast?E.push(K):et.push(K)}}let kt=pt(ot,"w:endnoteReference");if(kt){let St=kt.getAttribute("w:id");if(St&&C.has(St)){let O=C.get(St),K={type:"note",text:O.map(Tt=>Tt.text).join(" "),children:O,metadata:{noteType:"endnote",noteId:St}};t.putNotesAtLast?E.push(K):et.push(K)}}}}else if(Oe(mt)&&mt.nodeName==="w:hyperlink"){let ot=mt,ht=ot.getAttribute("r:id"),gt=ot.getAttribute("w:anchor"),Et;gt&&!t.ignoreInternalLinks?Et={link:"#"+gt,linkType:"internal"}:ht&&M[ht]&&(Et={link:M[ht],linkType:"external"});let Pt=Array.from(ot.childNodes);for(let wt of Pt){let kt=et.length;if(vt(wt),Et)for(let St=kt;St<et.length;St++)et[St].type==="text"&&(et[St].metadata={...et[St].metadata??{},...Et})}}else if(Oe(mt)&&mt.nodeName==="w:bookmarkStart"){let ot=mt.getAttribute("w:name");ot&&!ot.startsWith("_GoBack")&&!t.ignoreInternalLinks&&bt.push(ot)}else if(Oe(mt)&&(mt.nodeName==="mc:AlternateContent"||mt.nodeName==="AlternateContent")){let ot=p(mt);for(let ht of ot)vt(ht)}else if(Oe(mt)&&(mt.nodeName==="w:pict"||mt.nodeName==="pict"||mt.nodeName==="w:drawing"||mt.nodeName==="drawing")){let ot=ut(mt,"w:txbxContent");for(let ht of ot){let gt=Array.from(ht.childNodes);for(let Et of gt)if(Oe(Et)&&Et.nodeName==="w:p"){let Pt=_(Et,F);et.push(...Pt.children||[]),dt+=Pt.text}}}else if(mt.childNodes.length>0)for(let ot of Array.from(mt.childNodes))vt(ot)},bt=[...P],Ft=Array.from(D.childNodes);for(let mt of Ft)vt(mt);let Ct=bt.length>0?{anchorIds:bt}:{};if(H){let mt=pt(G,"w:numId"),ot=pt(G,"w:ilvl"),ht=mt&&mt.getAttribute("w:val")||"0",gt=ot?parseInt(ot.getAttribute("w:val")||"0",10):0,Et="ordered",Pt=0;if(ht&&j[ht]){let kt=gt.toString();T[ht]||(T[ht]={}),T[ht][kt]||(T[ht][kt]=0),T[ht][kt]++;for(let O=gt+1;O<10;O++)T[ht][O.toString()]&&(T[ht][O.toString()]=0);Et=(j[ht][kt]?.numFmt||"decimal")==="bullet"?"unordered":"ordered",I[ht]||(I[ht]={}),I[ht][kt]===void 0?I[ht][kt]=(j[ht][kt]?.start??1)-1:I[ht][kt]++,Pt=I[ht][kt]}let wt={type:"list",text:dt,children:et,metadata:{listType:Et,indentation:gt,paragraphIndentation:J,alignment:ft||"left",listId:ht,itemIndex:Pt,style:tt,...Ct}};return t.includeRawContent&&(wt.rawContent=ee(D,F,t)),wt}else if(rt){let mt=tt&&parseInt(tt.replace("Heading",""),10)||1,ot={type:"heading",text:dt,children:et,metadata:{level:mt,alignment:ft,paragraphIndentation:J,style:tt??void 0,...Ct}};return t.includeRawContent&&(ot.rawContent=ee(D,F,t)),ot}else{let mt={type:"paragraph",text:dt,children:et,metadata:{alignment:ft,paragraphIndentation:J,style:tt??void 0,...Ct}};return t.includeRawContent&&(mt.rawContent=ee(D,F,t)),mt}},W=(D,F,P=[])=>{let G=[],H=Qe(D,"w:tr"),V=new Map;for(let L=0;L<H.length;L++){let tt=H[L],rt=[],at=Qe(tt,"w:tc"),ft=0;for(let st=0;st<at.length;st++){let lt=at[st],dt=pt(lt,"w:tcPr"),et=1;if(dt){let ht=pt(dt,"w:gridSpan");ht&&(et=parseInt(ht.getAttribute("w:val")||"1",10))}let vt=!1,bt=!1;if(dt){let ht=pt(dt,"w:vMerge");ht&&(bt=!0,(ht.getAttribute("w:val")==="restart"||!V.has(ft))&&(vt=!0))}let Ft=[],Ct="",mt=Array.from(lt.childNodes);for(let ht of mt)if(Oe(ht)&&ht.nodeName==="w:p"){let gt=_(ht,F);Ft.push(gt),Ct+=gt.text}else if(Oe(ht)&&ht.nodeName==="w:tbl"){let gt=W(ht,F);Ft.push(gt)}let ot={type:"cell",text:Ct,children:Ft,metadata:{row:L,col:ft}};if(et>1&&(ot.metadata.colSpan=et),bt)if(vt)V.set(ft,{node:ot,span:1}),rt.push(ot);else{let ht=V.get(ft);ht?(ht.span++,ht.node.metadata.rowSpan=ht.span,Ft.length>0&&(ht.node.children||(ht.node.children=[]),ht.node.children.push(...Ft),ht.node.text+=" "+Ct)):rt.push(ot)}else V.delete(ft),rt.push(ot);ft+=et}let J={type:"row",children:rt};G.push(J)}return{type:"table",children:G}};if(!t.ignoreNotes){let D=m.find(P=>P.path.match(n));if(D){let P=le(D.content.toString()),G=D.content.toString(),H=ut(P,"w:footnote");for(let V of H){let L=V.getAttribute("w:id");if(!L||L==="-1"||L==="0")continue;let tt=ut(V,"w:p");w.set(L,tt.map(rt=>_(rt,G)))}}let F=m.find(P=>P.path.match(i));if(F){let P=le(F.content.toString()),G=F.content.toString(),H=ut(P,"w:endnote");for(let V of H){let L=V.getAttribute("w:id");if(!L||L==="-1"||L==="0")continue;let tt=ut(V,"w:p");C.set(L,tt.map(rt=>_(rt,G)))}}}for(let D of m){if(D.path.match(a)||D.path.match(s)||D.path.match(u)||D.path.match(h)||D.path.match(n)||D.path.match(i))continue;let F=D.content.toString();t.includeRawContent&&X.push(F);let P=le(F,{locator:t.includeRawContent}),G=pt(P,"w:body");if(G){let H=Array.from(G.childNodes),V=[];for(let L of H)if(Oe(L)){if(L.nodeName==="w:p")Y.push(_(L,F,V)),V=[];else if(L.nodeName==="w:tbl")Y.push(W(L,F,V)),V=[];else if(L.nodeName==="w:bookmarkStart"){let tt=L.getAttribute("w:name");tt&&!tt.startsWith("_GoBack")&&!t.ignoreInternalLinks&&V.push(tt)}}}}if(t.extractAttachments){for(let D of N){let F=Mr(D.path.split("/").pop()||"image",D.content);if(S.push(F),t.ocr&&F.mimeType.startsWith("image/"))try{F.ocrText=(await lr(D.content,{...t.ocrConfig})).trim()}catch(P){Ce("OCR_FAILED",t,F.name,P)}}if(t.ocr){let D=F=>{for(let P of F){if(P.type==="image"&&"attachmentName"in(P.metadata||{})){let G=P.metadata,H=S.find(V=>V.name===G.attachmentName);H&&H.ocrText&&(P.text=H.ocrText,H.altText=G.altText)}P.children&&D(P.children)}};D(Y)}}t.putNotesAtLast&&E.length>0&&Y.push(...E);let z=()=>Y.map(D=>{let F=P=>{let G="";return P.children?G+=P.children.map(F).filter(H=>H!="").join(P.children[0]?.children?t.newlineDelimiter:""):P.type==="break"?G+=t.newlineDelimiter:G+=P.text||"",G};return F(D)}).filter(D=>D!="").join(t.newlineDelimiter);return An("docx",{...x,formatting:Q,styleMap:q},Y,S,t,z)};var Ka=class{static async parseOffice(t,e,n){let i,s={};typeof e=="function"?(i=e,s=n||{}):s=e||{};let a=pv(s),l=[],c=a.onWarning;a.onWarning=f=>{l.push(f),c&&c(f)};let u=ct.Buffer.alloc(0),h=a.fileType??"",d;try{if(!t)throw hn("IMPROPER_ARGUMENTS",a);if(t instanceof ArrayBuffer)u=ct.Buffer.from(t);else if(t instanceof Uint8Array)u=ct.Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ct.Buffer.isBuffer(t))u=t;else if(typeof t=="string"){d=t,Ng("path-parsing");let p=await Promise.resolve().then(()=>(rN(),iN));if(!p.existsSync(t))throw hn("FILE_DOES_NOT_EXIST",a,t);if(p.lstatSync(t).isDirectory())throw hn("LOCATION_NOT_FOUND",a,t);u=p.readFileSync(t),h=h||t.split(".").pop()||""}else throw hn("INVALID_INPUT",a);if(u.length>0&&!h)try{let{fileTypeFromBuffer:p}=await _2(),m=await p(u);m&&(h=m.ext)}catch(p){Ce("FILE_TYPE_DETECTION_FAILED",a,{error:p})}else if(u.length>0&&h)try{let{fileTypeFromBuffer:p}=await _2(),m=await p(u);m&&m.ext.toLowerCase()!==h.toLowerCase()&&Ce("BUFFER_TYPE_MISMATCH",a,{detected:m.ext,expected:h})}catch(p){Ce("FILE_TYPE_DETECTION_FAILED",a,{error:p})}if(!h)throw hn("IMPROPER_BUFFERS",a);let f;switch(h.toLowerCase()){case"docx":f=await XD(u,a);break;case"pptx":f=await qD(u,a);break;case"xlsx":f=await HE(u,a);break;case"odt":case"odp":case"ods":f=await VE(u,a);break;case"pdf":f=await WD(u,a);break;case"rtf":f=await VD(u,a);break;case"csv":f=await Hv(u,a);break;case"html":f=await WE(u,a);break;case"md":f=await qE(u,a);break;default:throw hn("EXTENSION_UNSUPPORTED",a,h)}return f.warnings=l,i&&i(f),f}catch(f){let p=fv(f,a,d);throw i&&i(void 0,p),p}}static async terminateOcr(){await GE()}};B();var cg=class{static async convert(t,e,n){let i={...n?.parseConfig,onWarning:n?.onWarning||n?.parseConfig?.onWarning};i.ocr=!1,Object.keys(i).forEach(c=>i[c]===void 0&&delete i[c]),i.extractAttachments=n?.generatorConfig?.includeImages!==!1||n?.generatorConfig?.includeCharts!==!1;let s=await Ka.parseOffice(t,i),a={...n?.generatorConfig,onWarning:n?.onWarning||n?.generatorConfig?.onWarning},l=await Xs.generate(s,e,a);return l.messages=[...s.warnings||[],...l.messages],l}};var pF=Ka.parseOffice,mF=Ka.terminateOcr,gF=cg.convert,yF=Xs.generate;var bF=Ka;return hN(xF);})();
753
757
  /*! Bundled license information:
754
758
 
755
759
  ieee754/index.js: