@apollo-design/docx-preview 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +155 -0
- package/dist/docx-preview.cjs +4190 -0
- package/dist/docx-preview.d.ts +57 -0
- package/dist/docx-preview.js +4190 -0
- package/dist/docx-preview.js.map +1 -0
- package/dist/docx-preview.min.js +8 -0
- package/dist/docx-preview.min.js.map +1 -0
- package/dist/docx-preview.min.mjs +8 -0
- package/dist/docx-preview.min.mjs.map +1 -0
- package/dist/docx-preview.mjs +4096 -0
- package/dist/docx-preview.mjs.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license
|
|
3
|
+
* @apollo-design/docx-preview <https://github.com/apollocmh/docx-preview>
|
|
4
|
+
* Released under Apache License 2.0 — Copyright apollocmh
|
|
5
|
+
* Based on docxjs by Volodymyr Baydalka <https://github.com/VolodymyrBaydalka/docxjs>
|
|
6
|
+
*/
|
|
7
|
+
import e from"jszip";var t=/* @__PURE__ */function(e){return e.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",e.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",e.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",e.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",e.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",e.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",e.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",e.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",e.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",e.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",e.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",e.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",e.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",e.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",e.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",e.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",e.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",e.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",e.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",e.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk",e}({});function r(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e}function a(e){let t=e.lastIndexOf("/")+1;return[0==t?"":e.substring(0,t),0==t?e:e.substring(t)]}function n(e,t){try{return new URL(e,"http://docx/"+t).toString().substring(12)}catch{return`${t}${e}`}}function s(e,t){return e.reduce((e,r)=>(e[t(r)]=r,e),{})}function l(e){return e&&"object"==typeof e&&!Array.isArray(e)}function o(e){return"string"==typeof e||e instanceof String}function i(e,...t){if(!t.length)return e;const r=t.shift();if(l(e)&&l(r))for(const a in r)l(r[a])?i(e[a]??(e[a]={}),r[a]):e[a]=r[a];return i(e,...t)}function c(e){return Array.isArray(e)?e:[e]}var h="http://schemas.openxmlformats.org/wordprocessingml/2006/main",m={mul:.05,unit:"pt"},u={mul:1/12700,unit:"pt"},p={mul:.5,unit:"pt"},d={mul:.125,unit:"pt",min:.25,max:12},f={mul:1,unit:"pt"},g={mul:.02,unit:"%"};function b(e,t=m){if(null==e||/.+(p[xt]|[%])$/.test(e))return e;var r=parseInt(e)*t.mul;return t.min&&t.max&&(r=function(e,t,r){return t>e?t:r<e?r:e}(r,t.min,t.max)),`${r.toFixed(2)}${t.unit}`}function y(e,t,r){if(e.namespaceURI!=h)return!1;switch(e.localName){case"color":t.color=r.attr(e,"val");break;case"sz":t.fontSize=r.lengthAttr(e,"val",p);break;default:return!1}return!0}var k=class{elements(e,t=null){const r=[];for(let a=0,n=e.childNodes.length;a<n;a++){let n=e.childNodes.item(a);n.nodeType!=Node.ELEMENT_NODE||null!=t&&n.localName!=t||r.push(n)}return r}element(e,t){for(let r=0,a=e.childNodes.length;r<a;r++){let a=e.childNodes.item(r);if(1==a.nodeType&&a.localName==t)return a}return null}elementAttr(e,t,r){var a=this.element(e,t);return a?this.attr(a,r):void 0}attrs(e){return Array.from(e.attributes)}attr(e,t){for(let r=0,a=e.attributes.length;r<a;r++){let a=e.attributes.item(r);if(a.localName==t)return a.value}return null}intAttr(e,t,r=null){var a=this.attr(e,t);return a?parseInt(a):r}hexAttr(e,t,r=null){var a=this.attr(e,t);return a?parseInt(a,16):r}floatAttr(e,t,r=null){var a=this.attr(e,t);return a?parseFloat(a):r}boolAttr(e,t,r=null){return function(e,t=!1){switch(e){case"1":case"on":case"true":return!0;case"0":case"off":case"false":return!1;default:return t}}(this.attr(e,t),r)}lengthAttr(e,t,r=m){return b(this.attr(e,t),r)}},v=new k,S=class{constructor(e,t){this._package=e,this.path=t}async load(){this.rels=await this._package.loadRelationships(this.path);const e=await this._package.load(this.path),t=this._package.parseXmlDocument(e);this._package.options.keepOrigin&&(this._xmlDocument=t),this.parseXml(t.firstElementChild)}save(){var e;this._package.update(this.path,(e=this._xmlDocument,(new XMLSerializer).serializeToString(e)))}parseXml(e){}},w={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function x(e,t){return t.elements(e).map(e=>function(e,t){let r={name:t.attr(e,"name"),embedFontRefs:[]};for(let a of t.elements(e))switch(a.localName){case"family":r.family=t.attr(a,"val");break;case"altName":r.altName=t.attr(a,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":r.embedFontRefs.push(P(a,t))}return r}(e,t))}function P(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:w[e.localName]}}var N=class extends S{parseXml(e){this.fonts=x(e,this._package.xmlParser)}};var M=class t{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new k}get(e){const t=function(e){return e.startsWith("/")?e.substr(1):e}(e);return this._zip.files[t]??this._zip.files[t.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static async load(r,a){const n=await e.loadAsync(r);return new t(n,a)}save(e="blob"){return this._zip.generateAsync({type:e})}load(e,t="string"){return this.get(e)?.async(t)??Promise.resolve(null)}async loadRelationships(e=null){let t="_rels/.rels";if(null!=e){const[r,n]=a(e);t=`${r}_rels/${n}.rels`}const r=await this.load(t);return r?(n=this.parseXmlDocument(r).firstElementChild,(s=this.xmlParser).elements(n).map(e=>({id:s.attr(e,"Id"),type:s.attr(e,"Type"),target:s.attr(e,"Target"),targetMode:s.attr(e,"TargetMode")}))):null;var n,s}async loadContentTypes(){const e=await this.load("[Content_Types].xml");return e?(t=this.parseXmlDocument(e).firstElementChild,(r=this.xmlParser).elements(t).map(e=>({extension:r.attr(e,"Extension"),partName:r.attr(e,"PartName"),contentType:r.attr(e,"ContentType")}))):[];var t,r}parseXmlDocument(e){return function(e,t=!1){var r;t&&(e=e.replace(/<[?].*[?]>/,"")),e=65279===(r=e).charCodeAt(0)?r.substring(1):r;const a=(new DOMParser).parseFromString(e,"application/xml"),n=(s=a,s.getElementsByTagName("parsererror")[0]?.textContent);var s;if(n)throw new Error(n);return a}(e,this.options.trimXmlDeclaration)}};var C=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}};function A(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",d),offset:t.lengthAttr(e,"space",f),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}function T(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"left":r.left=A(a,t);break;case"top":r.top=A(a,t);break;case"right":r.right=A(a,t);break;case"bottom":r.bottom=A(a,t)}return r}function E(e,t=v){var r={};for(let a of t.elements(e))switch(a.localName){case"pgSz":r.pageSize={width:t.lengthAttr(a,"w"),height:t.lengthAttr(a,"h"),orientation:t.attr(a,"orient")};break;case"type":r.type=t.attr(a,"val");break;case"pgMar":r.pageMargins={left:t.lengthAttr(a,"left"),right:t.lengthAttr(a,"right"),top:t.lengthAttr(a,"top"),bottom:t.lengthAttr(a,"bottom"),header:t.lengthAttr(a,"header"),footer:t.lengthAttr(a,"footer"),gutter:t.lengthAttr(a,"gutter")};break;case"cols":r.columns=R(a,t);break;case"headerReference":(r.headerRefs??(r.headerRefs=[])).push(B(a,t));break;case"footerReference":(r.footerRefs??(r.footerRefs=[])).push(B(a,t));break;case"titlePg":r.titlePage=t.boolAttr(a,"val",!0);break;case"pgBorders":r.pageBorders=T(a,t);break;case"pgNumType":r.pageNumber=$(a,t)}return r}function R(e,t){return{numberOfColumns:t.intAttr(e,"num"),space:t.lengthAttr(e,"space"),separator:t.boolAttr(e,"sep"),equalWidth:t.boolAttr(e,"equalWidth",!0),columns:t.elements(e,"col").map(e=>({width:t.lengthAttr(e,"w"),space:t.lengthAttr(e,"space")}))}}function $(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function B(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}function D(e,t){let r={};for(let a of t.elements(e))L(a,r,t);return r}function L(e,t,r){return!!y(e,t,r)}function F(e,t){let r={};for(let a of t.elements(e))H(a,r,t);return r}function H(e,t,r){if(e.namespaceURI!=h)return!1;if(y(e,t,r))return!0;switch(e.localName){case"tabs":t.tabs=function(e,t){return t.elements(e,"tab").map(e=>({position:t.lengthAttr(e,"pos"),leader:t.attr(e,"leader"),style:t.attr(e,"val")}))}(e,r);break;case"sectPr":t.sectionProps=E(e,r);break;case"numPr":t.numbering=function(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"numId":r.id=t.attr(a,"val");break;case"ilvl":r.level=t.intAttr(a,"val")}return r}(e,r);break;case"spacing":return t.lineSpacing=function(e,t){return{before:t.lengthAttr(e,"before"),after:t.lengthAttr(e,"after"),line:t.intAttr(e,"line"),lineRule:t.attr(e,"lineRule")}}(e,r),!1;case"textAlignment":return t.textAlignment=r.attr(e,"val"),!1;case"keepLines":t.keepLines=r.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=r.boolAttr(e,"val",!0);break;case"pageBreakBefore":t.pageBreakBefore=r.boolAttr(e,"val",!0);break;case"outlineLvl":t.outlineLevel=r.intAttr(e,"val");break;case"pStyle":t.styleName=r.attr(e,"val");break;case"rPr":t.runProps=D(e,r);break;default:return!1}return!0}function I(e,t){let r={id:t.attr(e,"numId"),overrides:[]};for(let a of t.elements(e))switch(a.localName){case"abstractNumId":r.abstractId=t.attr(a,"val");break;case"lvlOverride":r.overrides.push(j(a,t))}return r}function O(e,t){let r={id:t.attr(e,"abstractNumId"),levels:[]};for(let a of t.elements(e))switch(a.localName){case"name":r.name=t.attr(a,"val");break;case"multiLevelType":r.multiLevelType=t.attr(a,"val");break;case"numStyleLink":r.numberingStyleLink=t.attr(a,"val");break;case"styleLink":r.styleLink=t.attr(a,"val");break;case"lvl":r.levels.push(_(a,t))}return r}function _(e,t){let r={level:t.intAttr(e,"ilvl")};for(let a of t.elements(e))switch(a.localName){case"start":r.start=t.attr(a,"val");break;case"lvlRestart":r.restart=t.intAttr(a,"val");break;case"numFmt":r.format=t.attr(a,"val");break;case"lvlText":r.text=t.attr(a,"val");break;case"lvlJc":r.justification=t.attr(a,"val");break;case"lvlPicBulletId":r.bulletPictureId=t.attr(a,"val");break;case"pStyle":r.paragraphStyle=t.attr(a,"val");break;case"pPr":r.paragraphProps=F(a,t);break;case"rPr":r.runProps=D(a,t)}return r}function j(e,t){let r={level:t.intAttr(e,"ilvl")};for(let a of t.elements(e))switch(a.localName){case"startOverride":r.start=t.intAttr(a,"val");break;case"lvl":r.numberingLevel=_(a,t)}return r}function z(e,t){var r=t.element(e,"pict"),a=r&&t.element(r,"shape"),n=a&&t.element(a,"imagedata");return n?{id:t.attr(e,"numPicBulletId"),referenceId:t.attr(n,"id"),style:t.attr(a,"style")}:null}var V=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){Object.assign(this,function(e,t){let r={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let a of t.elements(e))switch(a.localName){case"num":r.numberings.push(I(a,t));break;case"abstractNum":r.abstractNumberings.push(O(a,t));break;case"numPicBullet":r.bulletPictures.push(z(a,t))}return r}(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}},W=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}},X=/* @__PURE__ */function(e){return e.Document="document",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.NoBreakHyphen="noBreakHyphen",e.Table="table",e.Row="row",e.Cell="cell",e.Hyperlink="hyperlink",e.SmartTag="smartTag",e.Drawing="drawing",e.Image="image",e.Text="text",e.Tab="tab",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnote="footnote",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.MmlMath="mmlMath",e.MmlMathParagraph="mmlMathParagraph",e.MmlFraction="mmlFraction",e.MmlFunction="mmlFunction",e.MmlFunctionName="mmlFunctionName",e.MmlNumerator="mmlNumerator",e.MmlDenominator="mmlDenominator",e.MmlRadical="mmlRadical",e.MmlBase="mmlBase",e.MmlDegree="mmlDegree",e.MmlSuperscript="mmlSuperscript",e.MmlSubscript="mmlSubscript",e.MmlPreSubSuper="mmlPreSubSuper",e.MmlSubArgument="mmlSubArgument",e.MmlSuperArgument="mmlSuperArgument",e.MmlNary="mmlNary",e.MmlDelimiter="mmlDelimiter",e.MmlRun="mmlRun",e.MmlEquationArray="mmlEquationArray",e.MmlLimit="mmlLimit",e.MmlLimitLower="mmlLimitLower",e.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk",e}({}),G=class{constructor(){this.children=[],this.cssStyle={}}},q=class extends G{constructor(...e){super(...e),this.type=X.Header}},U=class extends G{constructor(...e){super(...e),this.type=X.Footer}},J=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(e)}},Y=class extends J{createRootElement(){return new q}},Z=class extends J{createRootElement(){return new U}};function K(e){if(void 0!==e)return parseInt(e)}var Q=class extends S{parseXml(e){this.props=function(e,t){const r={};for(let a of t.elements(e))switch(a.localName){case"Template":r.template=a.textContent;break;case"Pages":r.pages=K(a.textContent);break;case"Words":r.words=K(a.textContent);break;case"Characters":r.characters=K(a.textContent);break;case"Application":r.application=a.textContent;break;case"Lines":r.lines=K(a.textContent);break;case"Paragraphs":r.paragraphs=K(a.textContent);break;case"Company":r.company=a.textContent;break;case"AppVersion":r.appVersion=a.textContent}return r}(e,this._package.xmlParser)}};var ee=class extends S{parseXml(e){this.props=function(e,t){const r={};for(let a of t.elements(e))switch(a.localName){case"title":r.title=a.textContent;break;case"description":r.description=a.textContent;break;case"subject":r.subject=a.textContent;break;case"creator":r.creator=a.textContent;break;case"keywords":r.keywords=a.textContent;break;case"language":r.language=a.textContent;break;case"lastModifiedBy":r.lastModifiedBy=a.textContent;break;case"revision":a.textContent&&(r.revision=parseInt(a.textContent))}return r}(e,this._package.xmlParser)}},te=class{};function re(e,t){var r={name:t.attr(e,"name"),colors:{}};for(let s of t.elements(e)){var a=t.element(s,"srgbClr"),n=t.element(s,"sysClr");a?r.colors[s.localName]=t.attr(a,"val"):n&&(r.colors[s.localName]=t.attr(n,"lastClr"))}return r}function ae(e,t){var r={name:t.attr(e,"name")};for(let a of t.elements(e))switch(a.localName){case"majorFont":r.majorFont=ne(a,t);break;case"minorFont":r.minorFont=ne(a,t)}return r}function ne(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}var se=class extends S{constructor(e,t){super(e,t)}parseXml(e){this.theme=function(e,t){var r=new te,a=t.element(e,"themeElements");for(let n of t.elements(a))switch(n.localName){case"clrScheme":r.colorScheme=re(n,t);break;case"fontScheme":r.fontScheme=ae(n,t)}return r}(e,this._package.xmlParser)}},le=class{},oe=class extends le{constructor(...e){super(...e),this.type=X.Footnote}},ie=class extends le{constructor(...e){super(...e),this.type=X.Endnote}},ce=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}},he=class extends ce{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"footnote",oe)}},me=class extends ce{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"endnote",ie)}};function ue(e,t){var r={defaultNoteIds:[]};for(let a of t.elements(e))switch(a.localName){case"numFmt":r.nummeringFormat=t.attr(a,"val");break;case"footnote":case"endnote":r.defaultNoteIds.push(t.attr(a,"id"))}return r}var pe=class extends S{constructor(e,t){super(e,t)}parseXml(e){this.settings=function(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"defaultTabStop":r.defaultTabStop=t.lengthAttr(a,"val");break;case"footnotePr":r.footnoteProps=ue(a,t);break;case"endnotePr":r.endnoteProps=ue(a,t);break;case"autoHyphenation":r.autoHyphenation=t.boolAttr(a,"val");break;case"compat":for(let e of t.elements(a))"compatSetting"==e.localName&&"compatibilityMode"==t.attr(e,"name")&&(t.attr(e,"uri")??"").includes("schemas.microsoft.com/office/word")&&(r.compatMode=t.intAttr(e,"val",null))}return r}(e,this._package.xmlParser)}};var de=class extends S{parseXml(e){this.props=function(e,t){return t.elements(e,"property").map(e=>{const r=e.firstChild;return{formatId:t.attr(e,"fmtid"),name:t.attr(e,"name"),type:r.nodeName,value:r.textContent}})}(e,this._package.xmlParser)}},fe=class extends S{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=s(this.comments,e=>e.id)}},ge=class extends S{constructor(e,t){super(e,t),this.comments=[]}parseXml(e){const t=this._package.xmlParser;for(let r of t.elements(e,"commentEx"))this.comments.push({paraId:t.attr(r,"paraId"),paraIdParent:t.attr(r,"paraIdParent"),done:t.boolAttr(r,"done")});this.commentMap=s(this.comments,e=>e.paraId)}},be=[{type:t.OfficeDocument,target:"word/document.xml"},{type:t.ExtendedProperties,target:"docProps/app.xml"},{type:t.CoreProperties,target:"docProps/core.xml"},{type:t.CustomProperties,target:"docProps/custom.xml"}],ye=class e{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[]}static async load(t,r,a){var n=new e;return n._options=a,n._parser=r,n._package=await M.load(t,a),n.rels=await n._package.loadRelationships(),n.contentTypes=await n._package.loadContentTypes(),await Promise.all(be.map(e=>{const t=n.rels.find(t=>t.type===e.type)??e;return n.loadRelationshipPart(t.target,t.type)})),n}save(e="blob"){return this._package.save(e)}async loadRelationshipPart(e,r){if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let s=null;switch(r){case t.OfficeDocument:this.documentPart=s=new C(this._package,e,this._parser);break;case t.FontTable:this.fontTablePart=s=new N(this._package,e);break;case t.Numbering:this.numberingPart=s=new V(this._package,e,this._parser);break;case t.Styles:this.stylesPart=s=new W(this._package,e,this._parser);break;case t.Theme:this.themePart=s=new se(this._package,e);break;case t.Footnotes:this.footnotesPart=s=new he(this._package,e,this._parser);break;case t.Endnotes:this.endnotesPart=s=new me(this._package,e,this._parser);break;case t.Footer:s=new Z(this._package,e,this._parser);break;case t.Header:s=new Y(this._package,e,this._parser);break;case t.CoreProperties:this.corePropsPart=s=new ee(this._package,e);break;case t.ExtendedProperties:this.extendedPropsPart=s=new Q(this._package,e);break;case t.CustomProperties:s=new de(this._package,e);break;case t.Settings:this.settingsPart=s=new pe(this._package,e);break;case t.Comments:this.commentsPart=s=new fe(this._package,e,this._parser);break;case t.CommentsExtended:this.commentsExtendedPart=s=new ge(this._package,e)}if(null==s)return Promise.resolve(null);if(this.partsMap[e]=s,this.parts.push(s),await s.load(),s.rels?.length>0){const[e]=a(s.path);await Promise.all(s.rels.map(t=>this.loadRelationshipPart(n(t.target,e),t.type)))}return s}async loadDocumentImage(e,t){const r=this.getPathById(t??this.documentPart,e);return r?this.blobToURL(await this._package.load(r,"blob"),r):null}async loadNumberingImage(e){const t=this.getPathById(this.numberingPart,e);return t?this.blobToURL(await this._package.load(t,"blob"),t):null}async loadFont(e,t){const r=this.getPathById(this.fontTablePart,e);if(!r)return null;const a=await this._package.load(r,"uint8array");return a?this.blobToURL(new Blob([ke(a,t)]),r):a}async loadAltChunk(e,t){const r=this.getPathById(t??this.documentPart,e);return r?this._package.load(r,"string"):Promise.resolve(null)}blobToURL(e,t){if(!e)return null;if(t){const r=this.contentTypes.find(e=>e.partName===t||e.extension&&t.endsWith(`.${e.extension}`));e=r?new Blob([e],{type:r.contentType}):e}return this._options.useBase64URL?function(e){return new Promise((t,r)=>{const a=new FileReader;a.onloadend=()=>t(a.result),a.onerror=()=>r(),a.readAsDataURL(e)})}(e):URL.createObjectURL(e)}findPartByRelId(e,t=null){var r=(t.rels??this.rels).find(t=>t.id==e);const s=t?a(t.path)[0]:"";return r?this.partsMap[n(r.target,s)]:null}getPathById(e,t){const r=e.rels.find(e=>e.id==t),[s]=a(e.path);return r?n(r.target,s):null}};function ke(e,t){const r=t.replace(/{|}|-/g,""),a=new Array(16);for(let n=0;n<16;n++)a[16-n-1]=parseInt(r.substring(2*n,2*n+2),16);for(let n=0;n<32;n++)e[n]=e[n]^a[n%16];return e}function ve(e,t){return{type:X.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}}function Se(e,t){return{type:X.BookmarkEnd,id:t.attr(e,"id")}}var we=class extends G{constructor(...e){super(...e),this.type=X.VmlElement,this.attrs={}}};function xe(e,t){var r=new we;switch(e.localName){case"rect":r.tagName="rect",Object.assign(r.attrs,{width:"100%",height:"100%"});break;case"oval":r.tagName="ellipse",Object.assign(r.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":r.tagName="line";break;case"shape":r.tagName="g";break;case"textbox":r.tagName="foreignObject",Object.assign(r.attrs,{width:"100%",height:"100%"});break;default:return null}for(const a of v.attrs(e))switch(a.localName){case"style":r.cssStyleText=a.value;break;case"fillcolor":r.attrs.fill=a.value;break;case"from":const[e,t]=Me(a.value);Object.assign(r.attrs,{x1:e,y1:t});break;case"to":const[n,s]=Me(a.value);Object.assign(r.attrs,{x2:n,y2:s})}for(const a of v.elements(e))switch(a.localName){case"stroke":Object.assign(r.attrs,Pe(a));break;case"fill":Object.assign(r.attrs,Ne(a));break;case"imagedata":r.tagName="image",Object.assign(r.attrs,{width:"100%",height:"100%"}),r.imageHref={id:v.attr(a,"id"),title:v.attr(a,"title")};break;case"txbxContent":r.children.push(...t.parseBodyElements(a));break;default:const e=xe(a,t);e&&r.children.push(e)}return r}function Pe(e){return{stroke:v.attr(e,"color"),"stroke-width":v.lengthAttr(e,"weight",u)??"1px"}}function Ne(e){return{}}function Me(e){return e.split(",")}var Ce=class extends G{constructor(...e){super(...e),this.type=X.Comment}},Ae=class extends G{constructor(e){super(),this.id=e,this.type=X.CommentReference}},Te=class extends G{constructor(e){super(),this.id=e,this.type=X.CommentRangeStart}},Ee=class extends G{constructor(e){super(),this.id=e,this.type=X.CommentRangeEnd}},Re="inherit",$e="black",Be="black",De="transparent",Le=[],Fe={oMath:X.MmlMath,oMathPara:X.MmlMathParagraph,f:X.MmlFraction,func:X.MmlFunction,fName:X.MmlFunctionName,num:X.MmlNumerator,den:X.MmlDenominator,rad:X.MmlRadical,deg:X.MmlDegree,e:X.MmlBase,sSup:X.MmlSuperscript,sSub:X.MmlSubscript,sPre:X.MmlPreSubSuper,sup:X.MmlSuperArgument,sub:X.MmlSubArgument,d:X.MmlDelimiter,nary:X.MmlNary,eqArr:X.MmlEquationArray,lim:X.MmlLimit,limLow:X.MmlLimitLower,m:X.MmlMatrix,mr:X.MmlMatrixRow,box:X.MmlBox,bar:X.MmlBar,groupChr:X.MmlGroupChar},He=class{constructor(e){this.options={ignoreWidth:!1,debug:!1,...e}}parseNotes(e,t,r){var a=[];for(let n of v.elements(e,t)){const e=new r;e.id=v.attr(n,"id"),e.noteType=v.attr(n,"type"),e.children=this.parseBodyElements(n),a.push(e)}return a}parseComments(e){var t=[];for(let r of v.elements(e,"comment")){const e=new Ce;e.id=v.attr(r,"id"),e.author=v.attr(r,"author"),e.initials=v.attr(r,"initials"),e.date=v.attr(r,"date"),e.children=this.parseBodyElements(r),t.push(e)}return t}parseDocumentFile(e){var t=v.element(e,"body"),r=v.element(e,"background"),a=v.element(t,"sectPr");return{type:X.Document,children:this.parseBodyElements(t),props:a?E(a,v):{},cssStyle:r?this.parseBackground(r):{}}}parseBackground(e){var t={},r=Oe.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){var t=[];for(const r of v.elements(e))switch(r.localName){case"p":t.push(this.parseParagraph(r));break;case"altChunk":t.push(this.parseAltChunk(r));break;case"tbl":t.push(this.parseTable(r));break;case"sdt":t.push(...this.parseSdt(r,e=>this.parseBodyElements(e)))}return t}parseStylesFile(e){var t=[];for(const r of v.elements(e))switch(r.localName){case"style":t.push(this.parseStyle(r));break;case"docDefaults":t.push(this.parseDefaultStyles(r))}return t}parseDefaultStyles(e){var t={id:null,name:null,target:null,basedOn:null,styles:[]};for(const n of v.elements(e))switch(n.localName){case"rPrDefault":var r=v.element(n,"rPr");r&&t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})});break;case"pPrDefault":var a=v.element(n,"pPr");a&&t.styles.push({target:"p",values:this.parseDefaultProperties(a,{})})}return t}parseStyle(e){var t={id:v.attr(e,"styleId"),isDefault:v.boolAttr(e,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(v.attr(e,"type")){case"paragraph":t.target="p";break;case"table":t.target="table";break;case"character":t.target="span"}for(const r of v.elements(e))switch(r.localName){case"basedOn":t.basedOn=v.attr(r,"val");break;case"name":t.name=v.attr(r,"val");break;case"link":t.linked=v.attr(r,"val");break;case"next":t.next=v.attr(r,"val");break;case"aliases":t.aliases=v.attr(r,"val").split(",");break;case"pPr":t.styles.push({target:"p",values:this.parseDefaultProperties(r,{})}),t.paragraphProps=F(r,v);break;case"rPr":t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})}),t.runProps=D(r,v);break;case"tblPr":case"tcPr":t.styles.push({target:"td",values:this.parseDefaultProperties(r,{})});break;case"tblStylePr":for(let e of this.parseTableStyle(r))t.styles.push(e);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${r.localName}`)}return t}parseTableStyle(e){var t=[],r="",a="";switch(v.attr(e,"type")){case"firstRow":a=".first-row",r="tr.first-row td";break;case"lastRow":a=".last-row",r="tr.last-row td";break;case"firstCol":a=".first-col",r="td.first-col";break;case"lastCol":a=".last-col",r="td.last-col";break;case"band1Vert":a=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":a=":not(.no-vband)",r="td.even-col";break;case"band1Horz":a=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":a=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(const n of v.elements(e))switch(n.localName){case"pPr":t.push({target:`${r} p`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"rPr":t.push({target:`${r} span`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"tblPr":case"tcPr":t.push({target:r,mod:a,values:this.parseDefaultProperties(n,{})})}return t}parseNumberingFile(e){const t=[],r=[],a=[];for(const n of v.elements(e))switch(n.localName){case"abstractNum":t.push(...this.parseAbstractNumbering(n,a));break;case"numPicBullet":a.push(this.parseNumberingPicBullet(n));break;case"num":r.push({numId:v.attr(n,"numId"),abstractNumId:v.elementAttr(n,"abstractNumId","val")})}return r.flatMap(e=>t.filter(t=>e.abstractNumId==t.id).map(t=>({...t,id:e.numId})))}parseNumberingPicBullet(e){var t=v.element(e,"pict"),r=t&&v.element(t,"shape"),a=r&&v.element(r,"imagedata");return a?{id:v.intAttr(e,"numPicBulletId"),src:v.attr(a,"id"),style:v.attr(r,"style")}:null}parseAbstractNumbering(e,t){var r=[],a=v.attr(e,"abstractNumId");for(const n of v.elements(e))if("lvl"===n.localName)r.push(this.parseNumberingLevel(a,n,t));return r}parseNumberingLevel(e,t,r){var a={id:e,level:v.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const s of v.elements(t))switch(s.localName){case"start":a.start=v.intAttr(s,"val");break;case"pPr":this.parseDefaultProperties(s,a.pStyle);break;case"rPr":this.parseDefaultProperties(s,a.rStyle);break;case"lvlPicBulletId":var n=v.intAttr(s,"val");a.bullet=r.find(e=>e?.id==n);break;case"lvlText":a.levelText=v.attr(s,"val");break;case"pStyle":a.pStyleName=v.attr(s,"val");break;case"numFmt":a.format=v.attr(s,"val");break;case"suff":a.suff=v.attr(s,"val")}return a}parseSdt(e,t){const r=v.element(e,"sdtContent");return r?t(r):[]}parseChange(e,t,r){return{type:e,children:r(t)?.children??[],id:v.attr(t,"id"),author:v.attr(t,"author"),date:v.attr(t,"date")}}parseAltChunk(e){return{type:X.AltChunk,children:[],id:v.attr(e,"id")}}parseParagraph(e){var t={type:X.Paragraph,children:[]};for(let r of v.elements(e))switch(r.localName){case"pPr":this.parseParagraphProperties(r,t);break;case"r":t.children.push(this.parseRun(r,t));break;case"hyperlink":t.children.push(this.parseHyperlink(r,t));break;case"smartTag":t.children.push(this.parseSmartTag(r,t));break;case"bookmarkStart":t.children.push(ve(r,v));break;case"bookmarkEnd":t.children.push(Se(r,v));break;case"commentRangeStart":t.children.push(new Te(v.attr(r,"id")));break;case"commentRangeEnd":t.children.push(new Ee(v.attr(r,"id")));break;case"oMath":case"oMathPara":t.children.push(this.parseMathElement(r));break;case"sdt":t.children.push(...this.parseSdt(r,e=>this.parseParagraph(e).children));break;case"ins":t.children.push(this.parseChange(X.Inserted,r,e=>this.parseParagraph(e)));break;case"del":t.children.push(this.parseChange(X.Deleted,r,e=>this.parseParagraph(e)))}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{if(H(e,t,v))return!0;switch(e.localName){case"pStyle":t.styleName=v.attr(e,"val");break;case"cnfStyle":t.className=_e.classNameOfCnfStyle(e);break;case"framePr":this.parseFrame(e,t);break;case"rPr":break;default:return!1}return!0})}parseFrame(e,t){"drop"==v.attr(e,"dropCap")&&(t.cssStyle.float="left")}parseHyperlink(e,t){var r={type:X.Hyperlink,parent:t,children:[]};r.anchor=v.attr(e,"anchor"),r.id=v.attr(e,"id");for(const a of v.elements(e))if("r"===a.localName)r.children.push(this.parseRun(a,r));return r}parseSmartTag(e,t){var r={type:X.SmartTag,parent:t,children:[]},a=v.attr(e,"uri"),n=v.attr(e,"element");a&&(r.uri=a),n&&(r.element=n);for(const s of v.elements(e))switch(s.localName){case"r":r.children.push(this.parseRun(s,r));break;case"smartTag":r.children.push(this.parseSmartTag(s,r))}return r}parseRun(e,t){var a={type:X.Run,parent:t,children:[]};for(let n of v.elements(e))switch(n=this.checkAlternateContent(n),n.localName){case"t":a.children.push({type:X.Text,text:n.textContent});break;case"delText":a.children.push({type:X.DeletedText,text:n.textContent});break;case"commentReference":a.children.push(new Ae(v.attr(n,"id")));break;case"fldSimple":a.children.push({type:X.SimpleField,instruction:v.attr(n,"instr"),lock:v.boolAttr(n,"lock",!1),dirty:v.boolAttr(n,"dirty",!1)});break;case"instrText":a.fieldRun=!0,a.children.push({type:X.Instruction,text:n.textContent});break;case"fldChar":a.fieldRun=!0,a.children.push({type:X.ComplexField,charType:v.attr(n,"fldCharType"),lock:v.boolAttr(n,"lock",!1),dirty:v.boolAttr(n,"dirty",!1)});break;case"noBreakHyphen":a.children.push({type:X.NoBreakHyphen});break;case"br":a.children.push({type:X.Break,break:v.attr(n,"type")||"textWrapping"});break;case"lastRenderedPageBreak":a.children.push({type:X.Break,break:"lastRenderedPageBreak"});break;case"sym":a.children.push({type:X.Symbol,font:r(v.attr(n,"font")),char:v.hexAttr(n,"char")});break;case"tab":a.children.push({type:X.Tab});break;case"footnoteReference":a.children.push({type:X.FootnoteReference,id:v.attr(n,"id")});break;case"endnoteReference":a.children.push({type:X.EndnoteReference,id:v.attr(n,"id")});break;case"drawing":let e=this.parseDrawing(n);e&&a.children.push(e);break;case"pict":a.children.push(this.parseVmlPicture(n));break;case"rPr":this.parseRunProperties(n,a)}return a}parseMathElement(e){const t=`${e.localName}Pr`,r={type:Fe[e.localName],children:[]};for(const n of v.elements(e))if(Fe[n.localName])r.children.push(this.parseMathElement(n));else if("r"==n.localName){var a=this.parseRun(n);a.type=X.MmlRun,r.children.push(a)}else n.localName==t&&(r.props=this.parseMathProperies(n));return r}parseMathProperies(e){const t={};for(const r of v.elements(e))switch(r.localName){case"chr":t.char=v.attr(r,"val");break;case"vertJc":t.verticalJustification=v.attr(r,"val");break;case"pos":t.position=v.attr(r,"val");break;case"degHide":t.hideDegree=v.boolAttr(r,"val");break;case"begChr":t.beginChar=v.attr(r,"val");break;case"endChr":t.endChar=v.attr(r,"val")}return t}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{switch(e.localName){case"rStyle":t.styleName=v.attr(e,"val");break;case"vertAlign":t.verticalAlign=_e.valueOfVertAlign(e,!0);break;default:return!1}return!0})}parseVmlPicture(e){const t={type:X.VmlPicture,children:[]};for(const r of v.elements(e)){const e=xe(r,this);e&&t.children.push(e)}return t}checkAlternateContent(e){if("AlternateContent"!=e.localName)return e;var t=v.element(e,"Choice");if(t){var r=v.attr(t,"Requires"),a=e.lookupNamespaceURI(r);if(Le.includes(a))return t.firstElementChild}return v.element(e,"Fallback")?.firstElementChild}parseDrawing(e){for(var t of v.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t)}}parseDrawingWrapper(e){var t={type:X.Drawing,children:[],cssStyle:{}},r="anchor"==e.localName;let a=null,n=v.boolAttr(e,"simplePos");v.boolAttr(e,"behindDoc");let s={relative:"page",align:"left",offset:"0"},l={relative:"page",align:"top",offset:"0"};for(var o of v.elements(e))switch(o.localName){case"simplePos":n&&(s.offset=v.lengthAttr(o,"x",u),l.offset=v.lengthAttr(o,"y",u));break;case"extent":t.cssStyle.width=v.lengthAttr(o,"cx",u),t.cssStyle.height=v.lengthAttr(o,"cy",u);break;case"positionH":case"positionV":if(!n){let e="positionH"==o.localName?s:l;var i=v.element(o,"align"),c=v.element(o,"posOffset");e.relative=v.attr(o,"relativeFrom")??e.relative,i&&(e.align=i.textContent),c&&(e.offset=b(c.textContent,u))}break;case"wrapTopAndBottom":a="wrapTopAndBottom";break;case"wrapNone":a="wrapNone";break;case"graphic":var h=this.parseGraphic(o);h&&t.children.push(h)}return"wrapTopAndBottom"==a?(t.cssStyle.display="block",s.align&&(t.cssStyle["text-align"]=s.align,t.cssStyle.width="100%")):"wrapNone"==a?(t.cssStyle.display="block",t.cssStyle.position="relative",t.cssStyle.width="0px",t.cssStyle.height="0px",s.offset&&(t.cssStyle.left=s.offset),l.offset&&(t.cssStyle.top=l.offset)):!r||"left"!=s.align&&"right"!=s.align||(t.cssStyle.float=s.align),t}parseGraphic(e){var t=v.element(e,"graphicData");for(let r of v.elements(t))if("pic"===r.localName)return this.parsePicture(r);return null}parsePicture(e){var t={type:X.Image,src:"",cssStyle:{}},r=v.element(e,"blipFill"),a=v.element(r,"blip"),n=v.element(r,"srcRect");t.src=v.attr(a,"embed"),n&&(t.srcRect=[v.intAttr(n,"l",0)/1e5,v.intAttr(n,"t",0)/1e5,v.intAttr(n,"r",0)/1e5,v.intAttr(n,"b",0)/1e5]);var s=v.element(e,"spPr"),l=v.element(s,"xfrm");if(t.cssStyle.position="relative",l)for(var o of(t.rotation=v.intAttr(l,"rot",0)/6e4,v.elements(l)))switch(o.localName){case"ext":t.cssStyle.width=v.lengthAttr(o,"cx",u),t.cssStyle.height=v.lengthAttr(o,"cy",u);break;case"off":t.cssStyle.left=v.lengthAttr(o,"x",u),t.cssStyle.top=v.lengthAttr(o,"y",u)}return t}parseTable(e){var t={type:X.Table,children:[]};for(const r of v.elements(e))switch(r.localName){case"tr":t.children.push(this.parseTableRow(r));break;case"tblGrid":t.columns=this.parseTableColumns(r);break;case"tblPr":this.parseTableProperties(r,t)}return t}parseTableColumns(e){var t=[];for(const r of v.elements(e))if("gridCol"===r.localName)t.push({width:v.lengthAttr(r,"w")});return t}parseTableProperties(e,t){switch(t.cssStyle={},t.cellStyle={},this.parseDefaultProperties(e,t.cssStyle,t.cellStyle,e=>{switch(e.localName){case"tblStyle":t.styleName=v.attr(e,"val");break;case"tblLook":t.className=_e.classNameOftblLook(e);break;case"tblpPr":this.parseTablePosition(e,t);break;case"tblStyleColBandSize":t.colBandSize=v.intAttr(e,"val");break;case"tblStyleRowBandSize":t.rowBandSize=v.intAttr(e,"val");break;case"hidden":t.cssStyle.display="none";break;default:return!1}return!0}),t.cssStyle["text-align"]){case"center":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto",t.cssStyle["margin-right"]="auto";break;case"right":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto"}}parseTablePosition(e,t){var r=v.lengthAttr(e,"topFromText"),a=v.lengthAttr(e,"bottomFromText"),n=v.lengthAttr(e,"rightFromText"),s=v.lengthAttr(e,"leftFromText"),l=v.attr(e,"horzAnchor"),o=v.attr(e,"vertAnchor"),i=v.attr(e,"tblpXSpec");if("bottom"==v.attr(e,"tblpYSpec")&&"text"!=o)return t.cssStyle.position="absolute",t.cssStyle.bottom="page"==o?"0px":"var(--docx-pad-bottom, 0px)",void("right"==i?t.cssStyle.right="page"==l?"0px":"var(--docx-pad-right, 0px)":"center"==i?(t.cssStyle.left="50%",t.cssStyle.transform="translateX(-50%)"):t.cssStyle.left="page"==l?"0px":"var(--docx-pad-left, 0px)");t.cssStyle.float="left",t.cssStyle["margin-bottom"]=_e.addSize(t.cssStyle["margin-bottom"],a),t.cssStyle["margin-left"]=_e.addSize(t.cssStyle["margin-left"],s),t.cssStyle["margin-right"]=_e.addSize(t.cssStyle["margin-right"],n),t.cssStyle["margin-top"]=_e.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){var t={type:X.Row,children:[]};for(const r of v.elements(e))switch(r.localName){case"tc":t.children.push(this.parseTableCell(r));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(r,t)}return t}parseTableRowProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{switch(e.localName){case"cnfStyle":t.className=_e.classNameOfCnfStyle(e);break;case"tblHeader":t.isHeader=v.boolAttr(e,"val");break;case"gridBefore":t.gridBefore=v.intAttr(e,"val");break;case"gridAfter":t.gridAfter=v.intAttr(e,"val");break;default:return!1}return!0})}parseTableCell(e){var t={type:X.Cell,children:[]};for(const r of v.elements(e))switch(r.localName){case"tbl":t.children.push(this.parseTable(r));break;case"p":t.children.push(this.parseParagraph(r));break;case"tcPr":this.parseTableCellProperties(r,t)}return t}parseTableCellProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{switch(e.localName){case"gridSpan":t.span=v.intAttr(e,"val",null);break;case"vMerge":t.verticalMerge=v.attr(e,"val")??"continue";break;case"cnfStyle":t.className=_e.classNameOfCnfStyle(e);break;default:return!1}return!0}),this.parseTableCellVerticalText(e,t)}parseTableCellVerticalText(e,t){const r={btLr:{writingMode:"vertical-rl",transform:"rotate(180deg)"},lrTb:{writingMode:"vertical-lr",transform:"none"},tbRl:{writingMode:"vertical-rl",transform:"none"}};for(const a of v.elements(e))if("textDirection"===a.localName){const e=r[v.attr(a,"val")]||{writingMode:"horizontal-tb"};t.cssStyle["writing-mode"]=e.writingMode,t.cssStyle.transform=e.transform}}parseDefaultProperties(e,t=null,r=null,a=null){t=t||{};for(const n of v.elements(e))if(!a?.(n))switch(n.localName){case"jc":t["text-align"]=_e.valueOfJc(n);break;case"textAlignment":t["vertical-align"]=_e.valueOfTextAlignment(n);break;case"color":t.color=Oe.colorAttr(n,"val",null,$e);break;case"sz":t["font-size"]=t["min-height"]=v.lengthAttr(n,"val",p);break;case"shd":t["background-color"]=Oe.colorAttr(n,"fill",null,Re);break;case"highlight":t["background-color"]=Oe.colorAttr(n,"val",null,De);break;case"vertAlign":break;case"position":t.verticalAlign=v.lengthAttr(n,"val",p);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":t.width=_e.valueOfSize(n,"w");break;case"trHeight":this.parseTrHeight(n,t);break;case"strike":t["text-decoration"]=v.boolAttr(n,"val",!0)?"line-through":"none";break;case"b":t["font-weight"]=v.boolAttr(n,"val",!0)?"bold":"normal";break;case"i":t["font-style"]=v.boolAttr(n,"val",!0)?"italic":"normal";break;case"caps":t["text-transform"]=v.boolAttr(n,"val",!0)?"uppercase":"none";break;case"smallCaps":t["font-variant"]=v.boolAttr(n,"val",!0)?"small-caps":"none";break;case"u":this.parseUnderline(n,t);break;case"ind":case"tblInd":this.parseIndentation(n,t);break;case"rFonts":this.parseFont(n,t);break;case"tblBorders":this.parseBorderProperties(n,r||t);break;case"tblCellSpacing":t["border-spacing"]=_e.valueOfMargin(n),t["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(n,t);break;case"bdr":t.border=_e.valueOfBorder(n);break;case"tcBorders":this.parseBorderProperties(n,t);break;case"vanish":v.boolAttr(n,"val",!0)&&(t.display="none");break;case"kern":case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(n,r||t);break;case"tblLayout":t["table-layout"]=_e.valueOfTblLayout(n);break;case"vAlign":t["vertical-align"]=_e.valueOfTextAlignment(n);break;case"spacing":"pPr"==e.localName&&this.parseSpacing(n,t);break;case"wordWrap":v.boolAttr(n,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=v.boolAttr(n,"val",!0)?"none":"auto";break;case"lang":t.$lang=v.attr(n,"val");break;case"rtl":case"bidi":v.boolAttr(n,"val",!0)&&(t.direction="rtl");break;case"bCs":case"iCs":case"szCs":case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"webHidden":case"pageBreakBefore":case"suppressLineNumbers":case"keepLines":case"keepNext":case"widowControl":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${e.localName}.${n.localName}`)}return t}parseUnderline(e,t){var r=v.attr(e,"val");if(null!=r){switch(r){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":t["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":t["text-decoration"]="underline dotted";break;case"double":t["text-decoration"]="underline double";break;case"single":case"thick":case"words":t["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":t["text-decoration"]="underline wavy";break;case"none":t["text-decoration"]="none"}var a=Oe.colorAttr(e,"color");a&&(t["text-decoration-color"]=a)}}parseFont(e,t){var a=v.attr(e,"ascii")??v.attr(e,"hAnsi")??_e.themeValue(e,"asciiTheme")??_e.themeValue(e,"hAnsiTheme"),n=v.attr(e,"eastAsia")??_e.themeValue(e,"eastAsiaTheme");a&&(t["--docx-font-ascii"]=r(a)),n&&(t["--docx-font-ea"]=r(n))}parseIndentation(e,t){var r=v.lengthAttr(e,"firstLine"),a=v.lengthAttr(e,"hanging"),n=v.lengthAttr(e,"left"),s=v.lengthAttr(e,"start"),l=v.lengthAttr(e,"right"),o=v.lengthAttr(e,"end");r&&(t["text-indent"]=r),a&&(t["text-indent"]=`-${a}`),(n||s)&&(t["margin-inline-start"]=n||s),(l||o)&&(t["margin-inline-end"]=l||o)}parseSpacing(e,t){var r=v.lengthAttr(e,"before"),a=v.lengthAttr(e,"after"),n=v.intAttr(e,"beforeLines",null),s=v.intAttr(e,"afterLines",null),l=v.intAttr(e,"line",null),o=v.attr(e,"lineRule");if(r?t["margin-top"]=r:null!=n&&(t["margin-top"]=n/100+"em"),a?t["margin-bottom"]=a:null!=s&&(t["margin-bottom"]=s/100+"em"),null!==l)switch(o){case"auto":t["line-height"]=`${(l/240).toFixed(2)}`;break;case"atLeast":t["line-height"]=l/20+"pt";break;default:t["line-height"]=t["min-height"]=l/20+"pt"}}parseMarginProperties(e,t){for(const r of v.elements(e))switch(r.localName){case"left":t["padding-left"]=_e.valueOfMargin(r);break;case"right":t["padding-right"]=_e.valueOfMargin(r);break;case"top":t["padding-top"]=_e.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=_e.valueOfMargin(r)}}parseTrHeight(e,t){v.attr(e,"hRule"),t.height=v.lengthAttr(e,"val")}parseBorderProperties(e,t){for(const r of v.elements(e))switch(r.localName){case"start":case"left":t["border-left"]=_e.valueOfBorder(r);break;case"end":case"right":t["border-right"]=_e.valueOfBorder(r);break;case"top":t["border-top"]=_e.valueOfBorder(r);break;case"bottom":t["border-bottom"]=_e.valueOfBorder(r)}}},Ie=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"],Oe=class{static colorAttr(e,t,r=null,a="black"){var n=v.attr(e,t);if(n)return"auto"==n?a:Ie.includes(n)?n:`#${n}`;var s=v.attr(e,"themeColor");return s?`var(--docx-${s}-color)`:r}},_e=class e{static themeValue(e,t){var r=v.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){var r=m;switch(v.attr(e,"type")){case"dxa":break;case"pct":r=g;break;case"auto":return"auto"}return v.lengthAttr(e,t,r)}static valueOfMargin(e){return v.lengthAttr(e,"w")}static valueOfBorder(t){var r=e.parseBorderType(v.attr(t,"val"));if("none"==r)return"none";var a=Oe.colorAttr(t,"color");return`${v.lengthAttr(t,"sz",d)} ${r} ${"auto"==a?Be:a}`}static parseBorderType(e){switch(e){case"single":case"dashDotStroked":case"thick":case"thickThinLargeGap":case"thickThinMediumGap":case"thickThinSmallGap":case"thinThickLargeGap":case"thinThickMediumGap":case"thinThickSmallGap":case"thinThickThinLargeGap":case"thinThickThinMediumGap":case"thinThickThinSmallGap":case"threeDEmboss":case"threeDEngrave":case"wave":return"solid";case"dashed":case"dashSmallGap":return"dashed";case"dotDash":case"dotDotDash":case"dotted":return"dotted";case"double":case"doubleWave":case"triple":return"double";case"inset":return"inset";case"nil":case"none":return"none";case"outset":return"outset"}return"solid"}static valueOfTblLayout(e){return"fixed"==v.attr(e,"val")?"fixed":"auto"}static classNameOfCnfStyle(e){const t=v.attr(e,"val"),r=["first-row","last-row","first-col","last-col","odd-col","even-col","odd-row","even-row","ne-cell","nw-cell","se-cell","sw-cell"];if(t)return r.filter((e,r)=>"1"==t[r]).join(" ");const a=["firstRow","lastRow","firstColumn","lastColumn","oddVBand","evenVBand","oddHBand","evenHBand","firstRowLastColumn","firstRowFirstColumn","lastRowLastColumn","lastRowFirstColumn"];return r.filter((t,r)=>v.boolAttr(e,a[r])).join(" ")}static valueOfJc(e){var t=v.attr(e,"val");switch(t){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return t}static valueOfVertAlign(e,t=!1){var r=v.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfTextAlignment(e){var t=v.attr(e,"val");switch(t){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return t}static addSize(e,t){return null==e?t:null==t?e:`calc(${e} + ${t})`}static classNameOftblLook(e){const t=v.hexAttr(e,"val",0);let r="";return(v.boolAttr(e,"firstRow")||32&t)&&(r+=" first-row"),(v.boolAttr(e,"lastRow")||64&t)&&(r+=" last-row"),(v.boolAttr(e,"firstColumn")||128&t)&&(r+=" first-col"),(v.boolAttr(e,"lastColumn")||256&t)&&(r+=" last-col"),(v.boolAttr(e,"noHBand")||512&t)&&(r+=" no-hband"),(v.boolAttr(e,"noVBand")||1024&t)&&(r+=" no-vband"),r.trim()}},je={pos:0,leader:"none",style:"left"};function ze(e,t,r,a=.75){const n=e.closest("p"),s=e.getBoundingClientRect(),l=n.getBoundingClientRect(),o=getComputedStyle(n),i=t?.length>0?t.map(e=>({pos:Ve(e.position),leader:e.leader,style:e.style})).sort((e,t)=>e.pos-t.pos):[je],c=i[i.length-1],h=l.width*a,m=Ve(r);let u=c.pos+m;if(u<h)for(;u<h&&i.length<50;u+=m)i.push({...je,pos:u});const p=parseFloat(o.marginLeft),d=l.left+p,f=(s.left-d)*a,g=i.find(e=>"clear"!=e.style&&e.pos>f);if(null==g)return;let b=1;if("right"==g.style||"center"==g.style){const t=Array.from(n.querySelectorAll(`.${e.className}`)),r=t.indexOf(e)+1,s=document.createRange();s.setStart(e,1),r<t.length?s.setEndBefore(t[r]):s.setEndAfter(n);const o="center"==g.style?.5:1,i=s.getBoundingClientRect(),c=i.left+o*i.width-(l.left-p);b=g.pos-c*a}else b=g.pos-f;switch(e.innerHTML=" ",e.style.textDecoration="inherit",e.style.wordSpacing=`${b.toFixed(0)}pt`,g.leader){case"dot":case"middleDot":e.style.textDecoration="underline",e.style.textDecorationStyle="dotted";break;case"hyphen":case"heavy":case"underscore":e.style.textDecoration="underline"}}function Ve(e){return parseFloat(e)}var We=/* @__PURE__ */function(e){return e.html="http://www.w3.org/1999/xhtml",e.svg="http://www.w3.org/2000/svg",e.mathML="http://www.w3.org/1998/Math/MathML",e}({});function Xe(e){if(o(e))return document.createTextNode(e);if(e instanceof Node)return e;const{ns:t,tagName:r,className:a,style:n,children:s,...l}=e;if("#fragment"===r)return document.createDocumentFragment();if("#comment"===r)return document.createComment(s[0]);const i=t?document.createElementNS(t,r):document.createElement(r);if(a&&i.setAttribute("class",a),n)if(o(n))i.setAttribute("style",n);else for(const[o,c]of Object.entries(n))o.startsWith("--")?i.style.setProperty(o,c):i.style[o]=c;if(l)for(const[o,c]of Object.entries(l))void 0!==c&&(i[o]=c);return s&&s.forEach(e=>i.appendChild(Xe(e))),i}function Ge(...e){return e.filter(Boolean).join(" ")}var qe=class{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.legacyCompat=!1,this.commentMap={},this.tasks=[],this.postRenderTasks=[],this.h=Xe}async render(e,t){this.document=e,this.options=t,this.className=t.className,this.rootSelector=t.inWrapper?`.${this.className}-wrapper`:":root",this.h=t.h??Xe,this.styleMap=null,this.tasks=[],this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);const r=[...this.renderDefaultStyle()];if(e.themePart&&r.push(...this.renderTheme(e.themePart)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),r.push(...this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.prodessNumberings(e.numberingPart.domNumberings),r.push(...await this.renderNumbering(e.numberingPart.domNumberings))),e.footnotesPart&&(this.footnoteMap=s(e.footnotesPart.notes,e=>e.id)),e.endnotesPart&&(this.endnoteMap=s(e.endnotesPart.notes,e=>e.id)),e.settingsPart){this.defaultTabSize=e.settingsPart.settings?.defaultTabStop;const t=e.settingsPart.settings?.compatMode;this.legacyCompat=null!=t&&t<=11}!t.ignoreFonts&&e.fontTablePart&&r.push(...await this.renderFontTable(e.fontTablePart));var a=this.renderSections(e.documentPart.body);return this.options.inWrapper?r.push(this.renderWrapper(a)):r.push(...a),this.commentHighlight&&t.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(e=>e()),await Promise.allSettled(this.tasks),this.refreshTabStops(),r}renderTheme(e){const t={},r=e.theme?.fontScheme;r&&(r.majorFont&&(t["--docx-majorHAnsi-font"]=r.majorFont.latinTypeface,t["--docx-majorEastAsia-font"]=r.majorFont.eaTypeface||r.majorFont.latinTypeface),r.minorFont&&(t["--docx-minorHAnsi-font"]=r.minorFont.latinTypeface,t["--docx-minorEastAsia-font"]=r.minorFont.eaTypeface||r.minorFont.latinTypeface));const a=e.theme?.colorScheme;if(a)for(let[s,l]of Object.entries(a.colors))t[`--docx-${s}-color`]=`#${l}`;const n=this.styleToString(`.${this.className}`,t);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[n]})]}async renderFontTable(e){const t=[];for(let n of e.fonts)for(let e of n.embedFontRefs)try{const a=await this.document.loadFont(e.id,e.key),s={"font-family":r(n.name),src:`url(${a})`};"bold"!=e.type&&"boldItalic"!=e.type||(s["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(s["font-style"]="italic"),t.push(this.h({tagName:"#comment",children:[`docxjs ${n.name} font`]})),t.push(this.h({tagName:"style",children:[this.styleToString("@font-face",s)]}))}catch(a){this.options.debug&&console.warn(`Can't load font with id ${e.id} and key ${e.key}`)}return t}processStyleName(e){return e?`${this.className}_${function(e){return e?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}(e)}`:this.className}processStyles(e){const t=s(e.filter(e=>null!=e.id),e=>e.id);this.defaultParagraphStyle=e.find(e=>e.isDefault&&"p"==e.target),this.docDefaultsStyle=e.find(e=>null==e.id);for(const a of e.filter(e=>e.basedOn)){var r=t[a.basedOn];if(r){a.paragraphProps=i(a.paragraphProps,r.paragraphProps),a.runProps=i(a.runProps,r.runProps);for(const e of r.styles){const t=a.styles.find(t=>t.target==e.target);t?this.copyStyleProperties(e.values,t.values):a.styles.push({...e,values:{...e.values}})}}else this.options.debug&&console.warn(`Can't find base style ${a.basedOn}`)}for(let a of e)a.cssName=this.processStyleName(a.id);return t}prodessNumberings(e){for(let t of e.filter(e=>e.pStyleName)){const e=this.findStyle(t.pStyleName);e?.paragraphProps?.numbering&&(e.paragraphProps.numbering.level=t.level)}}processElement(e){if(e.children)for(var t of e.children)t.parent=e,t.type==X.Table?this.processTable(t):this.processElement(t)}processTable(e){for(var t of e.children)for(var r of t.children)r.cssStyle=this.copyStyleProperties(e.cellStyle,r.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(r)}copyStyleProperties(e,t,r=null){if(!e)return t;for(var a of(null==t&&(t={}),null==r&&(r=Object.getOwnPropertyNames(e)),r))e.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(t[a]=e[a]);return t}createPageElement(e,t,r){const a={...r};return t&&(t.pageMargins&&(a.paddingLeft=t.pageMargins.left,a.paddingRight=t.pageMargins.right,a.paddingTop=t.pageMargins.top,a.paddingBottom=t.pageMargins.bottom,a["--docx-pad-left"]=t.pageMargins.left,a["--docx-pad-right"]=t.pageMargins.right,a["--docx-pad-top"]=t.pageMargins.top,a["--docx-pad-bottom"]=t.pageMargins.bottom),t.pageSize&&(this.options.ignoreWidth||(a.width=t.pageSize.width),this.options.ignoreHeight||(a.minHeight=t.pageSize.height))),this.h({tagName:"section",className:e,style:a})}createSectionContent(e){const t={};return e.columns&&e.columns.numberOfColumns&&(t.columnCount=`${e.columns.numberOfColumns}`,t.columnGap=e.columns.space,e.columns.separator&&(t.columnRule="1px solid black")),this.h({tagName:"article",style:t})}renderSections(e){const t=[];this.processElement(e);const r=this.splitBySection(e.children,e.props),a=this.groupByPageBreaks(r);let n=null;for(let l=0,o=a.length;l<o;l++){this.currentFootnoteIds=[];let r=a[l][0].sectProps;const i=this.createPageElement(this.className,r,e.cssStyle);this.options.renderHeaders&&this.renderHeaderFooter(r.headerRefs,r,t.length,n!=r,i);for(const e of a[l]){var s=this.createSectionContent(e.sectProps);this.renderElements(e.elements,s),i.appendChild(s),r=e.sectProps}if(this.options.renderFootnotes){const e=this.renderNotes(this.currentFootnoteIds,this.footnoteMap);e&&i.appendChild(e)}if(this.options.renderEndnotes&&l==o-1){const e=this.renderNotes(this.currentEndnoteIds,this.endnoteMap);e&&i.appendChild(e)}this.options.renderFooters&&this.renderHeaderFooter(r.footerRefs,r,t.length,n!=r,i),t.push(i),n=r}return this.resolvePageFields(t),t}renderHeaderFooter(e,t,r,a,n){if(e){var s=(t.titlePage&&a?e.find(e=>"first"==e.type):null)??(r%2==1?e.find(e=>"even"==e.type):null)??e.find(e=>"default"==e.type),l=s&&this.document.findPartByRelId(s.id,this.document.documentPart);if(l){this.currentPart=l,this.usedHederFooterParts.includes(l.path)||(this.processElement(l.rootElement),this.usedHederFooterParts.push(l.path));const[e]=this.renderElements([l.rootElement],n);t?.pageMargins&&(l.rootElement.type===X.Header?(e.style.marginTop=`calc(${t.pageMargins.header} - ${t.pageMargins.top})`,e.style.minHeight=`calc(${t.pageMargins.top} - ${t.pageMargins.header})`):l.rootElement.type===X.Footer&&(e.style.marginBottom=`calc(${t.pageMargins.footer} - ${t.pageMargins.bottom})`,e.style.minHeight=`calc(${t.pageMargins.bottom} - ${t.pageMargins.footer})`)),this.currentPart=null}}}isPageBreakElement(e){return e.type==X.Break&&("lastRenderedPageBreak"==e.break?!this.options.ignoreLastRenderedPageBreak:"page"==e.break)}isPageBreakSection(e,t){return!!e&&(!!t&&(e.pageSize?.orientation!=t.pageSize?.orientation||e.pageSize?.width!=t.pageSize?.width||e.pageSize?.height!=t.pageSize?.height))}splitBySection(e,t){var r={sectProps:null,elements:[],pageBreak:!1},a=[r];for(let h of e)if(h.type==X.Paragraph&&this.findStyle(h.styleName)?.paragraphProps?.pageBreakBefore&&(r.sectProps=n,r.pageBreak=!0,r={sectProps:null,elements:[],pageBreak:!1},a.push(r)),r.elements.push(h),h.type==X.Paragraph){const e=h;var n=e.sectionProps,s=-1,l=-1;if(this.options.breakPages&&e.children&&(s=e.children.findIndex(e=>-1!=(l=e.children?.findIndex(this.isPageBreakElement.bind(this))??-1))),(n||-1!=s)&&(r.sectProps=n,r.pageBreak=-1!=s,r={sectProps:null,elements:[],pageBreak:!1},a.push(r)),-1!=s){let t=e.children[s],a=l<t.children.length-1;if(s<e.children.length-1||a){var o=h.children,i={...h,children:o.slice(s)};if(h.children=o.slice(0,s),r.elements.push(i),a){let e=t.children,r={...t,children:e.slice(0,l)};h.children.push(r),t.children=e.slice(l)}}}}let c=null;for(let h=a.length-1;h>=0;h--)null==a[h].sectProps?a[h].sectProps=c??t:c=a[h].sectProps;return a}groupByPageBreaks(e){let t,r=[];const a=[r];for(let n of e)r.push(n),(this.options.ignoreLastRenderedPageBreak||n.pageBreak||this.isPageBreakSection(t,n.sectProps))&&a.push(r=[]),t=n.sectProps;return a.filter(e=>e.length>0)}renderWrapper(e){return this.h({tagName:"div",className:`${this.className}-wrapper`,children:e})}renderDefaultStyle(){var e=this.className,t=`\n.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; } \n.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;this.options.hideWrapperOnPrint&&(t=`@media not print { ${t} }`);var r=`${t}\n.${e} { color: black; hyphens: auto; text-underline-position: from-font; }\n.${e} { --docx-font-ascii: serif; --docx-font-ea: serif; }\n.${e}, .${e} * { font-family: var(--docx-font-ascii), var(--docx-font-ea); }\nsection.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }\nsection.${e}>article { margin-bottom: auto; z-index: 1; }\nsection.${e}>footer { z-index: 1; }\n.${e} table { border-collapse: collapse; }\n.${e} table td, .${e} table th { vertical-align: top; }\n.${e} p { margin: 0pt; min-height: 1em; }\n.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }\n.${e} a { color: inherit; text-decoration: inherit; }\n.${e} svg { fill: transparent; }\n`;return this.options.renderComments&&(r+=`\n.${e}-comment-ref { cursor: default; }\n.${e}-comment-popover { display: none; z-index: 1000; padding: 0.5rem; background: white; position: absolute; box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.25); width: 30ch; }\n.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }\n.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }\n`),[this.h({tagName:"#comment",children:["docxjs library predefined styles"]}),this.h({tagName:"style",children:[r]})]}async renderNumbering(e){var t="",r=[];for(var a of e){var n=`p.${this.numberingClass(a.id,a.level)}`,s="none";if(a.bullet){let e=`--${this.className}-${a.bullet.src}`.toLowerCase();t+=this.styleToString(`${n}:before`,{content:"' '",display:"inline-block",background:`var(${e})`},a.bullet.style);try{const r=await this.document.loadNumberingImage(a.bullet.src);t+=`${this.rootSelector} { ${e}: url(${r}) }`}catch(l){this.options.debug&&console.warn(`Can't load numbering image with src ${a.bullet.src}`)}}else if(a.levelText){let e=this.numberingCounter(a.id,a.level);const s=e+" "+(a.start-1);a.level>0&&(t+=this.styleToString(`p.${this.numberingClass(a.id,a.level-1)}`,{"counter-set":s})),r.push(s),t+=this.styleToString(`${n}:before`,{content:this.levelTextToContent(a.levelText,a.suff,a.id,this.numFormatToCssValue(a.format)),"counter-increment":e,...a.rStyle})}else s=this.numFormatToCssValue(a.format);t+=this.styleToString(n,{display:"list-item","list-style-position":"inside","list-style-type":s,...a.pStyle})}return r.length>0&&(t+=this.styleToString(this.rootSelector,{"counter-reset":r.join(" ")})),[this.h({tagName:"#comment",children:["docxjs document numbering styles"]}),this.h({tagName:"style",children:[t]})]}renderStyles(e){var t="";const r=this.styleMap,a=s(e.filter(e=>e.isDefault),e=>e.target);for(const s of e){var n=s.styles;if(s.linked){var l=s.linked&&r[s.linked];l?n=n.concat(l.styles):this.options.debug&&console.warn(`Can't find linked style ${s.linked}`)}for(const e of n){var o=`${s.target??""}.${s.cssName}`;s.target!=e.target&&(o+=` ${e.target}`),null==s.id&&"span"==e.target&&(o=`.${this.className}`),a[s.target]==s&&(o=`.${this.className} ${s.target}, `+o),t+=this.styleToString(o,e.values)}}return[this.h({tagName:"#comment",children:["docxjs document styles"]}),this.h({tagName:"style",children:[t]})]}renderNotes(e,t){var r=e.map(e=>t[e]).filter(e=>e);if(r.length>0)return this.h({tagName:"ol",children:this.renderElements(r)})}renderElement(e){switch(e.type){case X.Paragraph:return this.renderParagraph(e);case X.BookmarkStart:return this.renderBookmarkStart(e);case X.BookmarkEnd:return null;case X.Run:return this.renderRun(e);case X.Table:return this.renderTable(e);case X.Row:return this.renderTableRow(e);case X.Cell:return this.renderTableCell(e);case X.Hyperlink:return this.renderHyperlink(e);case X.SmartTag:return this.renderSmartTag(e);case X.Drawing:return this.renderDrawing(e);case X.Image:return this.renderImage(e);case X.Text:case X.Text:return this.renderText(e);case X.DeletedText:return this.renderDeletedText(e);case X.Tab:return this.renderTab(e);case X.Symbol:return this.renderSymbol(e);case X.Break:return this.renderBreak(e);case X.Footer:return this.renderContainer(e,"footer");case X.Header:return this.renderContainer(e,"header");case X.Footnote:case X.Endnote:return this.renderContainer(e,"li");case X.FootnoteReference:return this.renderFootnoteReference(e);case X.EndnoteReference:return this.renderEndnoteReference(e);case X.NoBreakHyphen:return this.h({tagName:"wbr"});case X.VmlPicture:return this.renderVmlPicture(e);case X.VmlElement:return this.renderVmlElement(e);case X.MmlMath:return this.renderContainerNS(e,We.mathML,"math",{xmlns:We.mathML});case X.MmlMathParagraph:return this.renderContainer(e,"span");case X.MmlFraction:return this.renderContainerNS(e,We.mathML,"mfrac");case X.MmlBase:return this.renderContainerNS(e,We.mathML,e.parent.type==X.MmlMatrixRow?"mtd":"mrow");case X.MmlNumerator:case X.MmlDenominator:case X.MmlFunction:case X.MmlLimit:case X.MmlBox:return this.renderContainerNS(e,We.mathML,"mrow");case X.MmlGroupChar:return this.renderMmlGroupChar(e);case X.MmlLimitLower:return this.renderContainerNS(e,We.mathML,"munder");case X.MmlMatrix:return this.renderContainerNS(e,We.mathML,"mtable");case X.MmlMatrixRow:return this.renderContainerNS(e,We.mathML,"mtr");case X.MmlRadical:return this.renderMmlRadical(e);case X.MmlSuperscript:return this.renderContainerNS(e,We.mathML,"msup");case X.MmlSubscript:return this.renderContainerNS(e,We.mathML,"msub");case X.MmlDegree:case X.MmlSuperArgument:case X.MmlSubArgument:return this.renderContainerNS(e,We.mathML,"mn");case X.MmlFunctionName:return this.renderContainerNS(e,We.mathML,"ms");case X.MmlDelimiter:return this.renderMmlDelimiter(e);case X.MmlRun:return this.renderMmlRun(e);case X.MmlNary:return this.renderMmlNary(e);case X.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case X.MmlBar:return this.renderMmlBar(e);case X.MmlEquationArray:return this.renderMllList(e);case X.Inserted:return this.renderInserted(e);case X.Deleted:return this.renderDeleted(e);case X.CommentRangeStart:return this.renderCommentRangeStart(e);case X.CommentRangeEnd:return this.renderCommentRangeEnd(e);case X.CommentReference:return this.renderCommentReference(e);case X.AltChunk:return this.renderAltChunk(e)}return null}renderElements(e,t){if(null==e)return null;var r=e.flatMap(e=>this.renderElement(e)).filter(e=>null!=e);return t&&r.forEach(e=>t.appendChild(o(e)?document.createTextNode(e):e)),r}renderContainer(e,t,r){return this.h({tagName:t,children:this.renderElements(e.children),...r})}renderContainerNS(e,t,r,a){return this.h({ns:t,tagName:r,children:this.renderElements(e.children),...a})}markPageFieldRuns(e){let t=null,r=!1;for(const a of e.children??[])if(a.type==X.Run){for(const e of a.children??[])if(e.type==X.ComplexField){const a=e.charType;"begin"==a?(t=null,r=!1):"separate"==a?r=!0:"end"==a&&(t=null,r=!1)}else e.type==X.Instruction&&(t=e.text?.trim().split(/\s/)[0]?.toUpperCase());!r||"PAGE"!=t&&"NUMPAGES"!=t||a.fieldRun||(a.className=Ge(a.className,`${this.className}-field-${t.toLowerCase()}`))}}resolvePageFields(e){const t=`${e.length}`;e.forEach((e,r)=>{for(const t of Array.from(e.querySelectorAll(`.${this.className}-field-page`)))t.textContent=`${r+1}`;for(const a of Array.from(e.querySelectorAll(`.${this.className}-field-numpages`)))a.textContent=t})}renderParagraph(e){this.markPageFieldRuns(e);var t=this.toHTML(e,We.html,"p");const r=this.findStyle(e.styleName);e.tabs??(e.tabs=r?.paragraphProps?.tabs);const a=e.numbering??r?.paragraphProps?.numbering;return a&&t.classList.add(this.numberingClass(a.id,a.level)),this.legacyCompat&&"justify"===this.textAlignOf(e)&&/ {2,}| {2,}| /.test(t.textContent)&&t.style.setProperty("text-align-last","justify"),t}textAlignOf(e){if(e.cssStyle?.["text-align"])return e.cssStyle["text-align"];const t=e=>e?.styles?.find(e=>"p"==e.target)?.values?.["text-align"];return t(this.findStyle(e.styleName))??t(this.defaultParagraphStyle)??t(this.docDefaultsStyle)??null}renderHyperlink(e){const t=this.toH(e,We.html,"a");return t.href="",e.id&&(t.href=this.document.documentPart.rels.find(t=>t.id==e.id&&"External"===t.targetMode)?.target??t.href),e.anchor&&(t.href+=`#${e.anchor}`),this.h(t)}renderSmartTag(e){return this.renderContainer(e,"span")}renderCommentRangeStart(e){if(!this.options.renderComments)return null;const t=new Range;this.commentHighlight?.add(t);const r=this.h({tagName:"#comment",children:[`start of comment #${e.id}`]});return this.later(()=>t.setStart(r,0)),this.commentMap[e.id]=t,r}renderCommentRangeEnd(e){if(!this.options.renderComments)return null;const t=this.commentMap[e.id],r=this.h({tagName:"#comment",children:[`end of comment #${e.id}`]});return this.later(()=>t?.setEnd(r,0)),r}renderCommentReference(e){if(!this.options.renderComments)return null;var t=this.document.commentsPart?.commentMap[e.id];if(!t)return null;const r=this.h({tagName:"span",className:`${this.className}-comment-ref`,children:["💬"]}),a=this.h({tagName:"div",className:`${this.className}-comment-popover`,children:[this.h({tagName:"div",className:`${this.className}-comment-author`,children:[t.author]}),this.h({tagName:"div",className:`${this.className}-comment-date`,children:[new Date(t.date).toLocaleString()]}),...this.renderElements(t.children)]});return this.h({tagName:"#fragment",children:[this.h({tagName:"#comment",children:[`comment #${t.id} by ${t.author} on ${t.date}`]}),r,a]})}renderAltChunk(e){if(!this.options.renderAltChunks)return null;var t=this.h({tagName:"iframe"});return this.tasks.push(this.document.loadAltChunk(e.id,this.currentPart).then(e=>{t.srcdoc=e})),t}renderDrawing(e){var t=this.toHTML(e,We.html,"div");return t.style.display="inline-block",t.style.position="relative",t.style.textIndent="0px",t}renderImage(e){let t=this.toHTML(e,We.html,"img",[]),r=e.cssStyle?.transform;if(e.srcRect&&e.srcRect.some(e=>0!=e)){var[a,n,s,l]=e.srcRect;r=`scale(${1/(1-a-s)}, ${1/(1-n-l)})`,t.style["clip-path"]=`rect(${(100*n).toFixed(2)}% ${(100*(1-s)).toFixed(2)}% ${(100*(1-l)).toFixed(2)}% ${(100*a).toFixed(2)}%)`}return e.rotation&&(r=`rotate(${e.rotation}deg) ${r??""}`),t.style.transform=r?.trim(),this.document&&this.tasks.push(this.document.loadDocumentImage(e.src,this.currentPart).then(e=>{t.src=e})),t}renderText(e){return this.h(e.text)}renderDeletedText(e){return this.options.renderChanges?this.renderText(e):null}renderBreak(e){return"textWrapping"==e.break?this.h({tagName:"br"}):null}renderInserted(e){return this.options.renderChanges?this.renderChange(e,"ins"):this.renderElements(e.children)}renderDeleted(e){return this.options.renderChanges?this.renderChange(e,"del"):null}renderChange(e,t){return this.renderContainer(e,t,{dateTime:e.date})}renderSymbol(e){return this.h({tagName:"span",children:[String.fromCharCode(e.char)],style:{fontFamily:e.font}})}renderFootnoteReference(e){return this.currentFootnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentFootnoteIds.length}`]})}renderEndnoteReference(e){return this.currentEndnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentEndnoteIds.length}`]})}renderTab(e){var t=this.h({tagName:"span",children:[" "]});if(this.options.experimental){t.className=this.tabStopClass();var r=function(e,t){var r=e.parent;for(;null!=r&&r.type!=t;)r=r.parent;return r}(e,X.Paragraph)?.tabs;this.currentTabs.push({stops:r,span:t})}return t}renderBookmarkStart(e){return this.h({tagName:"span",id:e.name})}renderRun(e){if(e.fieldRun)return null;let t=this.renderElements(e.children);e.verticalAlign&&(t=[this.h({tagName:e.verticalAlign,children:this.renderElements(e.children)})]);const r=this.toHTML(e,We.html,"span",t);return e.id&&(r.id=e.id),r}renderTable(e){this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0};const t=[];return e.columns&&t.push(this.renderTableColumns(e.columns)),t.push(...this.renderElements(e.children)),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),this.toHTML(e,We.html,"table",t)}renderTableColumns(e){const t=e.map(e=>this.h({tagName:"col",style:{width:e.width}}));return this.h({tagName:"colgroup",children:t})}renderTableRow(e){this.currentCellPosition.col=0;const t=[];return e.gridBefore&&t.push(this.renderTableCellPlaceholder(e.gridBefore)),t.push(...this.renderElements(e.children)),e.gridAfter&&t.push(this.renderTableCellPlaceholder(e.gridAfter)),this.currentCellPosition.row++,this.toHTML(e,We.html,"tr",t)}renderTableCellPlaceholder(e){return this.h({tagName:"td",colSpan:e,style:{border:"none"}})}renderTableCell(e){let t=this.toHTML(e,We.html,"td");const r=this.currentCellPosition.col;return e.verticalMerge?"restart"==e.verticalMerge?(this.currentVerticalMerge[r]=t,t.rowSpan=1):this.currentVerticalMerge[r]&&(this.currentVerticalMerge[r].rowSpan+=1,t.style.display="none"):this.currentVerticalMerge[r]=null,e.span&&(t.colSpan=e.span),this.currentCellPosition.col+=t.colSpan,t}renderVmlPicture(e){return this.renderContainer(e,"div")}renderVmlElement(e){var t=this.h({ns:We.svg,tagName:"svg",style:e.cssStyleText});const r=this.renderVmlChildElement(e);return e.imageHref?.id&&this.tasks.push(this.document?.loadDocumentImage(e.imageHref.id,this.currentPart).then(e=>r.setAttribute("href",e))),t.appendChild(r),requestAnimationFrame(()=>{const e=t.firstElementChild.getBBox();t.setAttribute("width",`${Math.ceil(e.x+e.width)}`),t.setAttribute("height",`${Math.ceil(e.y+e.height)}`)}),t}renderVmlChildElement(e){const t=this.createSvgElement(e.tagName);Object.entries(e.attrs).forEach(([e,r])=>t.setAttribute(e,r));for(let r of e.children)r.type==X.VmlElement?t.appendChild(this.renderVmlChildElement(r)):t.appendChild(...c(this.renderElement(r)));return t}renderMmlRadical(e){const t=e.children.find(e=>e.type==X.MmlBase);if(e.props?.hideDegree)return this.createMathMLElement("msqrt",null,this.renderElements([t]));const r=e.children.find(e=>e.type==X.MmlDegree);return this.createMathMLElement("mroot",null,this.renderElements([t,r]))}renderMmlDelimiter(e){const t=[];return t.push(this.createMathMLElement("mo",null,[e.props.beginChar??"("])),t.push(...this.renderElements(e.children)),t.push(this.createMathMLElement("mo",null,[e.props.endChar??")"])),this.createMathMLElement("mrow",null,t)}renderMmlNary(e){const t=[],r=s(e.children,e=>e.type),a=r[X.MmlSuperArgument],n=r[X.MmlSubArgument],l=a?this.createMathMLElement("mo",null,c(this.renderElement(a))):null,o=n?this.createMathMLElement("mo",null,c(this.renderElement(n))):null,i=this.createMathMLElement("mo",null,[e.props?.char??"∫"]);return l||o?t.push(this.createMathMLElement("munderover",null,[i,o,l])):l?t.push(this.createMathMLElement("mover",null,[i,l])):o?t.push(this.createMathMLElement("munder",null,[i,o])):t.push(i),t.push(...this.renderElements(r[X.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlPreSubSuper(e){const t=[],r=s(e.children,e=>e.type),a=r[X.MmlSuperArgument],n=r[X.MmlSubArgument],l=a?this.createMathMLElement("mo",null,c(this.renderElement(a))):null,o=n?this.createMathMLElement("mo",null,c(this.renderElement(n))):null,i=this.createMathMLElement("mo",null);return t.push(this.createMathMLElement("msubsup",null,[i,o,l])),t.push(...this.renderElements(r[X.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlGroupChar(e){const t="bot"===e.props.verticalJustification?"mover":"munder",r=this.renderContainerNS(e,We.mathML,t);return e.props.char&&r.appendChild(this.createMathMLElement("mo",null,[e.props.char])),r}renderMmlBar(e){const t={};switch(e.props.position){case"top":t.textDecoration="overline";break;case"bottom":t.textDecoration="underline"}return this.renderContainerNS(e,We.mathML,"mrow",{style:t})}renderMmlRun(e){return this.toHTML(e,We.mathML,"ms")}renderMllList(e){const t=this.renderElements(e.children).map(e=>this.createMathMLElement("mtr",null,[this.createMathMLElement("mtd",null,[e])]));return this.toHTML(e,We.mathML,"mtable",t)}toH(e,t,r,a=null){const{$lang:n,...s}=e.cssStyle??{};return{ns:t,tagName:r,className:Ge(e.className,e.styleName&&this.processStyleName(e.styleName)),lang:n,style:s,children:a??this.renderElements(e.children)}}toHTML(e,t,r,a=null){return this.h(this.toH(e,t,r,a))}findStyle(e){return e&&this.styleMap?.[e]}numberingClass(e,t){return`${this.className}-num-${e}-${t}`}tabStopClass(){return`${this.className}-tab-stop`}styleToString(e,t,r=null){let a=`${e} {\r\n`;for(const n in t)n.startsWith("$")||(a+=` ${n}: ${t[n]};\r\n`);return r&&(a+=r),a+"}\r\n"}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,a){return`"${e.replace(/%\d*/g,e=>{let t=parseInt(e.substring(1),10)-1;return`"counter(${this.numberingCounter(r,t)}, ${a})"`})}${{tab:"\\9",space:"\\a0"}[t]??""}"`}numFormatToCssValue(e){return{none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"}[e]??e}refreshTabStops(){this.options.experimental&&setTimeout(()=>{const e=function(e=document.body){const t=document.createElement("div");t.style.width="100pt",e.appendChild(t);const r=100/t.offsetWidth;return e.removeChild(t),r}();for(let t of this.currentTabs)ze(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,r,a){return this.h({ns:e,tagName:t,children:a,...r})}createElement(e,t,r){return this.createElementNS(We.html,e,t,r)}createMathMLElement(e,t,r){return this.createElementNS(We.mathML,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(We.svg,e,t,r)}later(e){this.postRenderTasks.push(e)}};function Ue(e,t){const r=e.querySelector(":scope > article");if(!r)return 0;const a=getComputedStyle(e),n=parseFloat(a.minHeight);if(!n||Number.isNaN(n))return 0;const s=getComputedStyle(r).columnCount;if("auto"!==s&&"1"!==s)return 0;const l=n-parseFloat(a.paddingTop)-parseFloat(a.paddingBottom);if(!(l>0)||r.scrollHeight<=l+1)return 0;const o=e.querySelector(":scope > header"),i=e.querySelector(":scope > footer"),c=Array.from(e.querySelectorAll(":scope > ol")),h=[e];let m=r,u=e;function p(){const t=e.cloneNode(!1);o&&t.appendChild(o.cloneNode(!0));const a=r.cloneNode(!1);t.appendChild(a),i&&t.appendChild(i.cloneNode(!0)),u.after(t),u=t,h.push(t),m=a}const d=()=>m.scrollHeight<=l+1,f=()=>m.getBoundingClientRect().top+l,g=Array.from(r.children);for(const b of g)b.remove();for(let b=0;b<g.length&&h.length<1e3;b++){const e=g[b];if(m.appendChild(e),d())continue;const r=Je(e,f(),t);"allfit"!==r&&(r||r?(g.splice(b+1,0,r),p()):(e.remove(),0!==m.childElementCount?(p(),b--):m.appendChild(e)))}if(c.length>0&&h.length>1){const e=u.querySelector(":scope > footer");for(const t of c)u.insertBefore(t,e)}return h.length<=1?0:h.length}function Je(e,t,r){if("TABLE"===e.tagName)return function(e,t){const r=[];for(const l of Array.from(e.tBodies))r.push(...Array.from(l.rows));if(r.length<2)return null;const a=r.findIndex(e=>e.getBoundingClientRect().bottom>t);if(a<=0)return null;const n=e.cloneNode(!1),s=e.querySelector(":scope > colgroup");s&&n.appendChild(s.cloneNode(!0));e.tHead&&n.appendChild(e.tHead.cloneNode(!0));for(let l=a;l<r.length;l++)n.appendChild(r[l]);return n}(e,t);const a=function(e,t){const r=e.ownerDocument,a=r.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=r.createRange();let s=!1,l=!1;for(let o=a.nextNode();o;o=a.nextNode()){if(0===o.length)continue;l=!0;let e=0,r=o.length,a=0;for(;e<=r;){const s=e+r>>1;n.setStart(o,0),n.setEnd(o,s);const l=n.getClientRects(),i=l[l.length-1];i&&i.bottom<=t?(a=s,e=s+1):r=s-1}if(0===a)return s?{node:o,offset:0}:null;if(a<o.length){let e=a;const t=Math.max(0,a-30);for(;e>t&&!/\s/.test(o.data[e-1]);)e--;return{node:o,offset:e>t?e:a}}s=!0}return l?"allfit":null}(e,t);if("allfit"===a)return"allfit";if(null===a)return null;const n=function(e,t,r){const a=e.cloneNode(!1);return function(e,t,r){let a=e,n=r;for(;a.parentNode&&a.parentNode!==t;){const e=a.parentNode,t=e.cloneNode(!1);for(n.appendChild(t),t.appendChild(a);a.nextSibling;)t.appendChild(a.nextSibling);a=e,n=t}a===e&&r.appendChild(a);for(;a.nextSibling;)r.appendChild(a.nextSibling)}(t.splitText(r),e,a),a}(e,a.node,a.offset);return n.classList.add(`${r}-continuation`),n}var Ye={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,paginate:!1,debug:!1,experimental:!1,className:"docx",inWrapper:!0,hideWrapperOnPrint:!1,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1,renderComments:!1,renderAltChunks:!0,h:Xe};function Ze(e,t){const r={...Ye,...t};return ye.load(e,new He(r),r)}async function Ke(e,t){const r={...Ye,...t};return await(new qe).render(e,r)}async function Qe(e,t,r,a){const n=await Ze(e,a),s=await Ke(n,a),l={...Ye,...a};r??(r=t),r.innerHTML="",t.innerHTML="",l.fonts?.length&&s.unshift(function(e){const t=e.map(e=>{const t=[`font-family: "${e.name.replace(/["\\\r\n]/g,"")}"`,`src: ${e.src}`];return null!=e.weight&&t.push(`font-weight: ${e.weight}`),null!=e.style&&t.push(`font-style: ${e.style}`),`@font-face { ${t.join("; ")}; }`}).join("\n"),r=document.createElement("style");return r.textContent=t,r}(l.fonts));for(let i of s)("STYLE"===i.nodeName?r:t).appendChild(i);const o="undefined"!=typeof document?document.fonts:null;if(l.fonts?.length&&o?.load)try{await Promise.all(l.fonts.map(e=>o.load(`${e.style??"normal"} ${e.weight??"normal"} 12px "${e.name.replace(/["\\\r\n]/g,"")}"`)))}catch{}if(l.paginate){if(o?.ready)try{await o.ready}catch{}!function(e,t){const r=Array.from(e.querySelectorAll(`section.${t}`));let a=0;for(const n of r)a+=Ue(n,t);if(a>0){const r=document.createElement("style");r.textContent=`.${t} .${t}-continuation { text-indent: 0 !important; }.${t} .${t}-continuation::before { content: none !important; }`,e.prepend(r);const a=e.querySelectorAll(`section.${t}`),n=`${a.length}`;a.forEach((e,r)=>{for(const a of Array.from(e.querySelectorAll(`.${t}-field-page`)))a.textContent=`${r+1}`;for(const a of Array.from(e.querySelectorAll(`.${t}-field-numpages`)))a.textContent=n})}}(t,l.className)}return n}export{Ye as defaultOptions,Ze as parseAsync,Qe as renderAsync,Ke as renderDocument};
|
|
8
|
+
//# sourceMappingURL=docx-preview.min.mjs.map
|