@office-open/docx 0.9.5 → 0.9.7

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-Db2NGghB.mjs","names":["findDeep"],"sources":["../src/parts/alt-chunk/alt-chunk-parse.ts","../src/parts/custom-xml/custom-xml-parse.ts","../src/parts/sub-doc/sub-doc-parse.ts","../src/parts/textbox/textbox-parse.ts","../src/parse/body.ts","../src/parse.ts"],"sourcesContent":["/**\n * AltChunk parser for DOCX documents.\n *\n * Parses w:altChunk elements and extracts embedded content from the ZIP.\n *\n * @module\n */\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AltChunkOptions } from \"@parts/alt-chunk/alt-chunk\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse a w:altChunk element into AltChunkOptions.\n * Reads the referenced data from the ZIP package.\n */\nexport function parseAltChunk(el: Element, ctx: DocxReadContext): AltChunkOptions {\n const rId = attr(el, \"r:id\");\n if (!rId) {\n throw new Error(\"w:altChunk missing r:id attribute\");\n }\n\n // Look up the path from relationships\n const path = ctx.docx.partRefs.afChunks.get(rId);\n if (!path) {\n throw new Error(`AltChunk relationship ${rId} not found`);\n }\n\n // Read raw data from ZIP\n const data = ctx.docx.doc.getRaw(path);\n if (!data) {\n throw new Error(`AltChunk data not found at ${path}`);\n }\n\n // Determine content type from extension\n const ext = path.split(\".\").pop() ?? \"txt\";\n let contentType: \"text/html\" | \"application/rtf\" | \"text/plain\";\n let extension: \"html\" | \"rtf\" | \"txt\";\n\n switch (ext) {\n case \"html\":\n contentType = \"text/html\";\n extension = \"html\";\n break;\n case \"rtf\":\n contentType = \"application/rtf\";\n extension = \"rtf\";\n break;\n default:\n contentType = \"text/plain\";\n extension = \"txt\";\n break;\n }\n\n return {\n data,\n contentType,\n extension,\n };\n}\n","/**\n * Parser for custom XML block elements (w:customXml).\n *\n * @module\n */\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { parseCustomXmlPr } from \"../bodychildren\";\nimport type { CustomXmlBlockOptions } from \"./custom-xml\";\n\n/**\n * Parse w:customXml element into CustomXmlBlockOptions.\n *\n * Uses a callback for child parsing to avoid circular dependencies\n * (same pattern as parseTable).\n */\nexport function parseCustomXmlBlock(\n el: Element,\n ctx: DocxReadContext,\n parseChild: (el: Element, ctx: DocxReadContext) => SectionChild,\n): CustomXmlBlockOptions {\n const opts: Record<string, unknown> = {};\n\n // Required attribute\n const element = attr(el, \"w:element\");\n if (element) opts.element = element;\n\n // Optional URI\n const uri = attr(el, \"w:uri\");\n if (uri) opts.uri = uri;\n\n // Parse w:customXmlPr\n const xmlPr = findChild(el, \"w:customXmlPr\");\n if (xmlPr) {\n opts.customXmlPr = parseCustomXmlPr(xmlPr);\n }\n\n // Parse block-level children\n const children: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:customXmlPr\") continue;\n const parsed = parseChild(child, ctx);\n children.push(parsed);\n }\n if (children.length > 0) opts.children = children;\n\n return opts as unknown as CustomXmlBlockOptions;\n}\n","/**\n * SubDoc parser for DOCX documents.\n *\n * Parses w:subDoc elements and extracts embedded document data.\n *\n * @module\n */\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { SubDocOptions } from \"@parts/sub-doc/sub-doc\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse a w:subDoc element into SubDocOptions.\n * Reads the referenced document data from the ZIP package.\n */\nexport function parseSubDoc(el: Element, ctx: DocxReadContext): SubDocOptions {\n const rId = attr(el, \"r:id\");\n if (!rId) {\n throw new Error(\"w:subDoc missing r:id attribute\");\n }\n\n const path = ctx.docx.partRefs.subDocs.get(rId);\n if (!path) {\n throw new Error(`SubDoc relationship ${rId} not found`);\n }\n\n const data = ctx.docx.doc.getRaw(path);\n if (!data) {\n throw new Error(`SubDoc data not found at ${path}`);\n }\n\n return { data };\n}\n","/**\n * Textbox parser for DOCX documents.\n *\n * Parses w:pict → v:shape → v:textbox → w:txbxContent elements.\n *\n * @module\n */\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse VML shape style string into VmlShapeStyle-like object.\n */\nfunction parseVmlStyle(styleStr: string): Record<string, string> {\n const style: Record<string, string> = {};\n for (const part of styleStr.split(\";\")) {\n const [key, val] = part.split(\":\").map((s) => s.trim());\n if (key && val) style[key] = val;\n }\n return style;\n}\n\n/**\n * Parse a w:pict element that contains a textbox.\n * Returns an object suitable for the { textbox: ... } SectionChild variant.\n */\nexport function parseTextbox(\n el: Element,\n ctx: DocxReadContext,\n parseChildren: (elements: Element[], ctx: DocxReadContext) => unknown[],\n): {\n style?: Record<string, string>;\n children?: unknown[];\n} {\n const shape = findDeep(el, \"v:shape\")[0];\n if (!shape) return {};\n\n const opts: Record<string, unknown> = {};\n\n // Parse VML style\n const styleAttr = attr(shape, \"style\");\n if (styleAttr) {\n opts.style = parseVmlStyle(styleAttr);\n }\n\n // Parse textbox content\n const textbox = findDeep(shape, \"v:textbox\")[0];\n if (textbox) {\n const txbxContent = findChild(textbox, \"w:txbxContent\");\n if (txbxContent) {\n const childList = parseChildren(txbxContent.elements ?? [], ctx);\n if (childList.length > 0) opts.children = childList;\n }\n }\n\n return opts as { style?: Record<string, string>; children?: unknown[] };\n}\n\n// Simple deep finder\nfunction findDeep(parent: Element, name: string): Element[] {\n const result: Element[] = [];\n for (const child of parent.elements ?? []) {\n if (child.name === name) result.push(child);\n result.push(...findDeep(child, name));\n }\n return result;\n}\n","/**\n * Body parser for DOCX documents.\n *\n * Parses w:body → SectionOptions[] by splitting at w:sectPr boundaries.\n *\n * @module\n */\nimport { attr, findChild, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { parseAltChunk } from \"@parts/alt-chunk/alt-chunk-parse\";\nimport { parseCustomXmlBlock } from \"@parts/custom-xml/custom-xml-parse\";\nimport { parseSectionPropertiesEl } from \"@parts/document/body/section-properties/descriptor\";\nimport type { SectionPropertiesOptions } from \"@parts/document/body/section-properties/section-properties\";\nimport { parseSdtBlock } from \"@parts/sdt/sdt-parse\";\nimport { parseSubDoc } from \"@parts/sub-doc/sub-doc-parse\";\nimport { parseToc } from \"@parts/table-of-contents/toc-parse\";\nimport { tableDesc } from \"@parts/table/descriptor\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport { parseTextbox } from \"@parts/textbox/textbox-parse\";\nimport type { SectionOptions } from \"@shared/section\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport { parseParagraph } from \"../body\";\nimport { DocxReadContext } from \"../context\";\nimport { setBodyParseChild } from \"../parts\";\n\n// ── Section properties parser ────────────────────────────────────────────────\n\n/**\n * Parse w:sectPr element into SectionPropertiesOptions.\n * Delegates to the section properties descriptor's parse method.\n */\nfunction parseSectionProperties(el: Element, ctx: DocxReadContext): SectionPropertiesOptions {\n const opts = parseSectionPropertiesEl(el) as Record<string, unknown>;\n\n // Headers/footers - parse from references and store in a separate field\n const headerRefs: Record<string, unknown> = {};\n const footerRefs: Record<string, unknown> = {};\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:headerReference\") {\n const rId = attr(child, \"r:id\");\n const type = attr(child, \"w:type\");\n if (rId && type) {\n const headerChildren = parseHeaderFooterRef(rId, ctx);\n if (headerChildren) headerRefs[type] = headerChildren;\n }\n }\n if (child.name === \"w:footerReference\") {\n const rId = attr(child, \"r:id\");\n const type = attr(child, \"w:type\");\n if (rId && type) {\n const footerChildren = parseHeaderFooterRef(rId, ctx);\n if (footerChildren) footerRefs[type] = footerChildren;\n }\n }\n }\n\n if (Object.keys(headerRefs).length > 0) {\n opts.parsedHeaders = headerRefs;\n }\n if (Object.keys(footerRefs).length > 0) {\n opts.parsedFooters = footerRefs;\n }\n\n return opts as SectionPropertiesOptions;\n}\n\n/**\n * Parse a header/footer reference by following the relationship to its XML part.\n */\nfunction parseHeaderFooterRef(rId: string, ctx: DocxReadContext): SectionChild[] | undefined {\n const path = ctx.docx.partRefs.headers.get(rId) ?? ctx.docx.partRefs.footers.get(rId);\n if (!path) return undefined;\n\n const partEl = ctx.docx.doc.get(path);\n if (!partEl) return undefined;\n\n // The header/footer XML root element contains w:p, w:tbl, etc.\n const children: SectionChild[] = [];\n for (const child of partEl.elements ?? []) {\n const sectionChild = parseSectionChild(child, ctx);\n if (sectionChild !== undefined) {\n children.push(sectionChild);\n }\n }\n\n return children.length > 0 ? children : undefined;\n}\n\n// ── Section child dispatch ───────────────────────────────────────────────────\n\n/**\n * Parse a single body child element into a SectionChild.\n */\nexport function parseSectionChild(el: Element, ctx: DocxReadContext): SectionChild {\n switch (el.name) {\n case \"w:p\": {\n // Check for textbox (w:pict containing v:textbox)\n const pict = findChild(el, \"w:pict\");\n if (pict) {\n const textbox = findDeepElement(pict, \"v:textbox\");\n if (textbox) {\n const textboxOpts = parseTextbox(pict, ctx, parseSectionChildrenElements);\n return { textbox: textboxOpts as SectionChild extends { textbox: infer T } ? T : never };\n }\n }\n\n return { paragraph: parseParagraph(el, ctx) };\n }\n case \"w:tbl\":\n return { table: tableDesc.parse(el, ctx) as TableOptions };\n case \"w:sdt\": {\n // Try TOC first\n const tocResult = parseToc(el, ctx);\n if (tocResult) {\n return { toc: tocResult };\n }\n // Otherwise parse as generic SDT block\n const sdtResult = parseSdtBlock(el, ctx, parseSectionChildrenElements);\n return {\n sdt: {\n properties: sdtResult.properties,\n children: sdtResult.children as SectionChild[] | undefined,\n },\n };\n }\n case \"w:altChunk\":\n return { altChunk: parseAltChunk(el, ctx) };\n case \"w:subDoc\":\n return { subDoc: parseSubDoc(el, ctx) };\n case \"w:customXml\":\n return { customXml: parseCustomXmlBlock(el, ctx, parseSectionChild) };\n default:\n return { rawXml: stringify(el) };\n }\n}\n\n/**\n * Find a deep descendant element by name.\n */\nfunction findDeepElement(parent: Element, name: string): Element | undefined {\n for (const child of parent.elements ?? []) {\n if (child.name === name) return child;\n const found = findDeepElement(child, name);\n if (found) return found;\n }\n return undefined;\n}\n\n// ── Body parsing with section splitting ───────────────────────────────────────\n\n/**\n * Parse w:body element into SectionOptions[].\n *\n * Splits body content at w:sectPr boundaries to create sections.\n * The last w:sectPr (child of w:body directly) defines the last section.\n * Previous w:sectPr elements appear inside w:pPr elements.\n */\nexport function parseBody(body: Element, ctx: DocxReadContext): SectionOptions[] {\n // Register the body child parser for descriptor parse callbacks\n setBodyParseChild(parseSectionChild);\n\n // Collect body children and detect section breaks\n interface SectionBoundary {\n index: number;\n sectPr: Element;\n }\n\n const bodyChildren: Element[] = [];\n const boundaries: SectionBoundary[] = [];\n\n for (const child of body.elements ?? []) {\n if (child.name === \"w:sectPr\") {\n // Final section properties (last section)\n boundaries.push({ index: bodyChildren.length, sectPr: child });\n } else {\n bodyChildren.push(child);\n\n // Check for inline sectPr in paragraph properties\n if (child.name === \"w:p\") {\n const pPr = findChild(child, \"w:pPr\");\n if (pPr) {\n const sectPr = findChild(pPr, \"w:sectPr\");\n if (sectPr) {\n boundaries.push({ index: bodyChildren.length, sectPr });\n }\n }\n }\n }\n }\n\n // If no boundaries, the whole body is one section\n if (boundaries.length === 0) {\n return [\n {\n children: bodyChildren.map((el) => parseSectionChild(el, ctx)),\n },\n ];\n }\n\n // Split into sections\n const sections: SectionOptions[] = [];\n let start = 0;\n\n for (let i = 0; i < boundaries.length; i++) {\n const boundary = boundaries[i];\n // For inline sectPr (inside w:pPr), the containing paragraph was pushed to\n // bodyChildren. Exclude it — it's a section break marker, not content.\n // The last boundary uses a body-level sectPr, so no paragraph to exclude.\n const isInlineSectPr = i < boundaries.length - 1;\n const endIdx = isInlineSectPr ? Math.max(start, boundary.index - 1) : boundary.index;\n const sectionElements = bodyChildren.slice(start, endIdx);\n const parsedProps = parseSectionProperties(boundary.sectPr, ctx);\n const rawProps = parsedProps as Record<string, unknown>;\n\n // Extract headers/footers that were stored as parsedHeaders/parsedFooters\n const parsedHeaders = rawProps.parsedHeaders as Record<string, SectionChild[]> | undefined;\n const parsedFooters = rawProps.parsedFooters as Record<string, SectionChild[]> | undefined;\n\n // Build clean properties without internal fields\n const cleanProps = { ...parsedProps };\n delete (cleanProps as Record<string, unknown>).parsedHeaders;\n delete (cleanProps as Record<string, unknown>).parsedFooters;\n\n const section = {\n children: sectionElements.map((el) => parseSectionChild(el, ctx)),\n properties: cleanProps,\n ...(parsedHeaders ? { headers: parsedHeaders } : {}),\n ...(parsedFooters ? { footers: parsedFooters } : {}),\n } as SectionOptions;\n\n sections.push(section);\n start = boundary.index;\n }\n\n // If there are elements after the last boundary, they form the last section\n // with the body-level w:sectPr (already captured)\n // Actually the body-level sectPr IS the last boundary\n\n return sections;\n}\n\n/**\n * Parse a list of elements into SectionChild[].\n * Used by SDT and textbox parsers for their content.\n */\nfunction parseSectionChildrenElements(elements: Element[], ctx: DocxReadContext): SectionChild[] {\n return elements.map((el) => parseSectionChild(el, ctx));\n}\n","import type { ParsedArchive } from \"@office-open/core\";\nimport { parseArchive } from \"@office-open/core\";\nimport type { DataType } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { appPropertiesDesc } from \"@parts/app-properties\";\nimport { bibliographyDesc } from \"@parts/bibliography\";\nimport { setBodyParseChild } from \"@parts/bodychildren\";\nimport { commentsDesc } from \"@parts/comments\";\nimport { contentTypesDesc } from \"@parts/contenttypes\";\nimport { corePropertiesDesc } from \"@parts/core-properties\";\nimport type { DocumentOptions } from \"@parts/core-properties\";\nimport { customPropertiesDesc } from \"@parts/custom-properties\";\nimport { endnotesDesc } from \"@parts/endnotes/descriptor\";\nimport { fontTableDesc } from \"@parts/fonts/descriptor\";\nimport { footnotesDesc } from \"@parts/footnotes/descriptor\";\nimport { glossaryDesc } from \"@parts/glossary-document\";\nimport { parseNumberingDefinitions } from \"@parts/numbering/numbering\";\nimport { settingsDesc } from \"@parts/settings/descriptor\";\nimport { buildStyleCache, buildNumberingCache, parseStyleDefinitions } from \"@parts/styles/styles\";\nimport { setTableParseChild } from \"@parts/table/descriptor\";\nimport { webSettingsDesc } from \"@parts/web-settings\";\n\nimport { parseParagraphProperties } from \"./body\";\nimport { DocxReadContext } from \"./context\";\nimport { parseBody, parseSectionChild } from \"./parse/body\";\n\nexport { parseArchive };\n\n/**\n * All part paths extracted from the DOCX package.\n * Field names correspond directly to the OOXML directory structure.\n */\nexport interface DocxPartRefs {\n /** word/headerN.xml keyed by rId */\n headers: Map<string, string>;\n /** word/footerN.xml keyed by rId */\n footers: Map<string, string>;\n /** word/footnotes.xml */\n footnotes?: string;\n /** word/endnotes.xml */\n endnotes?: string;\n /** word/comments.xml */\n comments?: string;\n /** Hyperlink targets keyed by rId (external URLs) */\n hyperlinks: Map<string, string>;\n /** word/charts/chartN.xml keyed by rId */\n charts: Map<string, string>;\n /** word/diagrams/dataN.xml keyed by rId */\n diagramData: Map<string, string>;\n /** word/media/* keyed by rId */\n media: Map<string, string>;\n /** Alternative format chunks (word/afchunkN.*) keyed by rId */\n afChunks: Map<string, string>;\n /** Sub-documents (word/subdocs/subdocN.docx) keyed by rId */\n subDocs: Map<string, string>;\n /** word/bibliography.xml */\n bibliography?: string;\n /** word/glossary/document.xml */\n glossary?: string;\n}\n\nexport interface DocxDocument {\n doc: ParsedArchive;\n /** word/document.xml → w:body element */\n body: Element;\n /** word/document.xml → w:background element */\n background?: Element;\n /** word/styles.xml */\n styles?: Element;\n /** word/numbering.xml */\n numbering?: Element;\n /** word/settings.xml */\n settings?: Element;\n /** word/fontTable.xml */\n fontTable?: Element;\n /** word/webSettings.xml */\n webSettings?: Element;\n partRefs: DocxPartRefs;\n /** docProps/core.xml */\n coreProps?: string;\n /** docProps/app.xml */\n appProps?: string;\n /** docProps/custom.xml */\n customProps?: string;\n /** [Content_Types].xml */\n contentTypes?: Element;\n}\n\nfunction resolveRelsPath(target: string): string {\n if (target.startsWith(\"/\")) return target.slice(1);\n if (target.startsWith(\"../\")) return target.replace(\"../\", \"\");\n return `word/${target}`;\n}\n\nfunction parseDocPartRefs(doc: ParsedArchive): DocxPartRefs {\n const refs: DocxPartRefs = {\n headers: new Map(),\n footers: new Map(),\n hyperlinks: new Map(),\n charts: new Map(),\n diagramData: new Map(),\n media: new Map(),\n afChunks: new Map(),\n subDocs: new Map(),\n };\n\n const relsEl = doc.get(\"word/_rels/document.xml.rels\");\n if (!relsEl) return refs;\n\n for (const child of relsEl.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n const id = attr(child, \"Id\") ?? \"\";\n if (!target) continue;\n\n const path = resolveRelsPath(target);\n\n if (type.includes(\"/header\")) {\n refs.headers.set(id, path);\n } else if (type.includes(\"/footer\")) {\n refs.footers.set(id, path);\n } else if (type.includes(\"/footnotes\")) {\n refs.footnotes = path;\n } else if (type.includes(\"/endnotes\")) {\n refs.endnotes = path;\n } else if (type.includes(\"/comments\")) {\n refs.comments = path;\n } else if (type.includes(\"/chart\")) {\n refs.charts.set(id, path);\n } else if (type.includes(\"/diagramData\")) {\n refs.diagramData.set(id, path);\n } else if (type.includes(\"/image\") || type.includes(\"/media\")) {\n refs.media.set(id, path);\n } else if (type.includes(\"/aFChunk\")) {\n refs.afChunks.set(id, path);\n } else if (type.includes(\"/subDocument\")) {\n refs.subDocs.set(id, path);\n } else if (type.includes(\"/bibliography\")) {\n refs.bibliography = path;\n } else if (type.includes(\"/glossaryDocument\")) {\n refs.glossary = path;\n } else if (type.includes(\"/hyperlink\")) {\n refs.hyperlinks.set(id, target);\n }\n }\n\n return refs;\n}\n\nfunction parseRootRels(doc: ParsedArchive): {\n coreProps?: string;\n appProps?: string;\n customProps?: string;\n} {\n const relsEl = doc.get(\"_rels/.rels\");\n if (!relsEl) return {};\n\n let coreProps: string | undefined;\n let appProps: string | undefined;\n let customProps: string | undefined;\n\n for (const child of relsEl.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (!target) continue;\n\n const path = target.startsWith(\"/\") ? target.slice(1) : target;\n\n if (type.includes(\"/core-properties\")) {\n coreProps = path;\n } else if (type.includes(\"/extended-properties\")) {\n appProps = path;\n } else if (type.includes(\"/custom-properties\")) {\n customProps = path;\n }\n }\n\n return { coreProps, appProps, customProps };\n}\n\n/**\n * Parse a .docx file and convert it into DocumentOptions.\n *\n * This is the main public API for parsing DOCX files.\n * The returned options can be passed directly to `new Document(parsed)`\n * to recreate the document.\n *\n * @param data - Raw bytes of a .docx file\n * @returns Document options including sections and metadata\n */\nexport function parseDocument(data: DataType): DocumentOptions {\n const docx = parseDocx(data);\n const ctx = new DocxReadContext(\n docx,\n buildStyleCache(docx.styles),\n buildNumberingCache(docx.numbering),\n );\n\n // Register the child parser for table and body child descriptors\n setTableParseChild(parseSectionChild);\n setBodyParseChild(parseSectionChild);\n\n const sections = parseBody(docx.body, ctx);\n\n const opts: Record<string, unknown> = { sections };\n\n // Background (w:background in document.xml)\n if (docx.background) {\n const bg: Record<string, unknown> = {};\n const color = attr(docx.background, \"w:color\");\n if (color) bg.color = color;\n const themeColor = attr(docx.background, \"w:themeColor\");\n if (themeColor) bg.themeColor = themeColor;\n const themeShade = attr(docx.background, \"w:themeShade\");\n if (themeShade) bg.themeShade = themeShade;\n const themeTint = attr(docx.background, \"w:themeTint\");\n if (themeTint) bg.themeTint = themeTint;\n if (Object.keys(bg).length > 0) opts.background = bg;\n }\n\n // Core properties\n if (docx.coreProps) {\n const corePropsEl = docx.doc.get(docx.coreProps);\n if (corePropsEl) {\n const cp = corePropertiesDesc.parse(corePropsEl, ctx);\n if (cp.title) opts.title = cp.title;\n if (cp.subject) opts.subject = cp.subject;\n if (cp.creator) opts.creator = cp.creator;\n if (cp.keywords) opts.keywords = cp.keywords;\n if (cp.description) opts.description = cp.description;\n if (cp.lastModifiedBy) opts.lastModifiedBy = cp.lastModifiedBy;\n if (cp.revision) opts.revision = cp.revision;\n }\n }\n\n // App (extended) properties\n if (docx.appProps) {\n const appPropsEl = docx.doc.get(docx.appProps);\n if (appPropsEl) {\n const ap = appPropertiesDesc.parse(appPropsEl, ctx);\n if (Object.keys(ap).length > 0) opts.appProperties = ap;\n }\n }\n\n // Settings\n if (docx.settings) {\n Object.assign(opts, settingsDesc.parse(docx.settings, ctx));\n }\n\n // Web settings\n if (docx.webSettings) {\n const wsOpts = webSettingsDesc.parse(docx.webSettings, ctx);\n if (Object.keys(wsOpts).length > 0) opts.webSettings = wsOpts;\n }\n\n // Custom properties\n if (docx.customProps) {\n const customPropsEl = docx.doc.get(docx.customProps);\n if (customPropsEl) {\n const cpResult = customPropertiesDesc.parse(customPropsEl, ctx);\n if (cpResult.properties && cpResult.properties.length > 0) {\n opts.customProperties = cpResult.properties;\n }\n }\n }\n\n // Comments content\n if (docx.partRefs.comments) {\n const commentsEl = docx.doc.get(docx.partRefs.comments);\n if (commentsEl) {\n const commentsResult = commentsDesc.parse(commentsEl, ctx);\n const children = commentsResult.children;\n if (children && children.length > 0) {\n opts.comments = { children } as unknown as DocumentOptions[\"comments\"];\n }\n }\n }\n\n // Footnotes content\n if (docx.partRefs.footnotes) {\n const footnotesEl = docx.doc.get(docx.partRefs.footnotes);\n if (footnotesEl) {\n const fnResult = footnotesDesc.parse(footnotesEl, ctx);\n const footnotesMap: Record<string, { children: unknown[] }> = {};\n for (const [id, paragraphs] of fnResult.notes) {\n footnotesMap[String(id)] = { children: paragraphs };\n }\n if (Object.keys(footnotesMap).length > 0) opts.footnotes = footnotesMap;\n }\n }\n\n // Endnotes content\n if (docx.partRefs.endnotes) {\n const endnotesEl = docx.doc.get(docx.partRefs.endnotes);\n if (endnotesEl) {\n const enResult = endnotesDesc.parse(endnotesEl, ctx);\n const endnotesMap: Record<string, { children: unknown[] }> = {};\n for (const [id, paragraphs] of enResult.notes) {\n endnotesMap[String(id)] = { children: paragraphs };\n }\n if (Object.keys(endnotesMap).length > 0) opts.endnotes = endnotesMap;\n }\n }\n\n // Styles definitions\n if (docx.styles) {\n const styleOpts = parseStyleDefinitions(docx.styles, parseParagraphProperties, ctx);\n if (styleOpts) opts.styles = styleOpts;\n }\n\n // Numbering definitions\n if (docx.numbering) {\n const numOpts = parseNumberingDefinitions(docx.numbering, parseParagraphProperties, ctx);\n if (numOpts) opts.numbering = numOpts;\n }\n\n // Font table\n if (docx.fontTable) {\n const ftResult = fontTableDesc.parse(docx.fontTable, ctx);\n if (ftResult.fonts && ftResult.fonts.length > 0) opts.fonts = ftResult.fonts;\n }\n\n // Bibliography\n if (docx.partRefs.bibliography) {\n const bibEl = docx.doc.get(docx.partRefs.bibliography);\n if (bibEl) {\n const bibResult = bibliographyDesc.parse(bibEl, ctx);\n if (bibResult.sources && bibResult.sources.length > 0) opts.bibliography = bibResult;\n }\n }\n\n // Glossary document\n if (docx.partRefs.glossary) {\n const glossaryEl = docx.doc.get(docx.partRefs.glossary);\n if (glossaryEl) {\n const glossaryResult = glossaryDesc.parse(glossaryEl, ctx);\n if (glossaryResult.parts && glossaryResult.parts.length > 0) opts.glossary = glossaryResult;\n }\n }\n\n // Content types\n if (docx.contentTypes) {\n const ctResult = contentTypesDesc.parse(docx.contentTypes, ctx);\n if (ctResult) opts.contentTypes = ctResult;\n }\n\n return opts as unknown as DocumentOptions;\n}\n\nexport function parseDocx(data: DataType): DocxDocument {\n const uint8 = toUint8Array(data);\n const doc = parseArchive(uint8);\n\n const documentEl = doc.get(\"word/document.xml\");\n if (!documentEl) throw new Error(\"word/document.xml not found\");\n const body = documentEl.elements?.find((e) => e.name === \"w:body\");\n if (!body) throw new Error(\"w:body not found in word/document.xml\");\n const background = documentEl.elements?.find((e) => e.name === \"w:background\");\n\n const styles = doc.get(\"word/styles.xml\");\n const numbering = doc.get(\"word/numbering.xml\");\n const settings = doc.get(\"word/settings.xml\");\n const fontTable = doc.get(\"word/fontTable.xml\");\n const webSettings = doc.get(\"word/webSettings.xml\");\n\n const partRefs = parseDocPartRefs(doc);\n const { coreProps, appProps, customProps } = parseRootRels(doc);\n\n const contentTypes = doc.get(\"[Content_Types].xml\");\n\n return {\n doc,\n body,\n background,\n styles,\n numbering,\n settings,\n fontTable,\n webSettings,\n partRefs,\n coreProps,\n appProps,\n customProps,\n contentTypes,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,IAAa,KAAuC;CAChF,MAAM,MAAM,KAAK,IAAI,MAAM;CAC3B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,mCAAmC;CAIrD,MAAM,OAAO,IAAI,KAAK,SAAS,SAAS,IAAI,GAAG;CAC/C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,yBAAyB,IAAI,WAAW;CAI1D,MAAM,OAAO,IAAI,KAAK,IAAI,OAAO,IAAI;CACrC,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,8BAA8B,MAAM;CAItD,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK;CACrC,IAAI;CACJ,IAAI;CAEJ,QAAQ,KAAR;EACE,KAAK;GACH,cAAc;GACd,YAAY;GACZ;EACF,KAAK;GACH,cAAc;GACd,YAAY;GACZ;EACF;GACE,cAAc;GACd,YAAY;GACZ;CACJ;CAEA,OAAO;EACL;EACA;EACA;CACF;AACF;;;;;;;;;;;;;;ACzCA,SAAgB,oBACd,IACA,KACA,YACuB;CACvB,MAAM,OAAgC,CAAC;CAGvC,MAAM,UAAU,KAAK,IAAI,WAAW;CACpC,IAAI,SAAS,KAAK,UAAU;CAG5B,MAAM,MAAM,KAAK,IAAI,OAAO;CAC5B,IAAI,KAAK,KAAK,MAAM;CAGpB,MAAM,QAAQ,UAAU,IAAI,eAAe;CAC3C,IAAI,OACF,KAAK,cAAc,iBAAiB,KAAK;CAI3C,MAAM,WAA2B,CAAC;CACl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