@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.
@@ -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
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jszip")):"function"==typeof define&&define.amd?define(["exports","jszip"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).docx={},e.JSZip)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var r,a,n,s=Object.create,l=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,c=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;a=1,n=null!=(r=t)?s(c(r)):{},t=((e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var n,s=i(t),c=0,u=s.length;c<u;c++)n=s[c],h.call(e,n)||n===r||l(e,n,{get:(e=>t[e]).bind(null,n),enumerable:!(a=o(t,n))||a.enumerable});return e})(!a&&r&&r.__esModule&&h.call(r,"default")?n:l(n,"default",{value:r,enumerable:!0}),r);var u=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 d(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e}function m(e){let t=e.lastIndexOf("/")+1;return[0==t?"":e.substring(0,t),0==t?e:e.substring(t)]}function p(e,t){try{return new URL(e,"http://docx/"+t).toString().substring(12)}catch{return`${t}${e}`}}function f(e,t){return e.reduce((e,r)=>(e[t(r)]=r,e),{})}function g(e){return e&&"object"==typeof e&&!Array.isArray(e)}function b(e){return"string"==typeof e||e instanceof String}function y(e,...t){if(!t.length)return e;const r=t.shift();if(g(e)&&g(r))for(const n in r)if(g(r[n])){var a;y(null!==(a=e[n])&&void 0!==a?a:e[n]={},r[n])}else e[n]=r[n];return y(e,...t)}function v(e){return Array.isArray(e)?e:[e]}var k="http://schemas.openxmlformats.org/wordprocessingml/2006/main",S={mul:.05,unit:"pt"},w={mul:1/12700,unit:"pt"},x={mul:.5,unit:"pt"},P={mul:.125,unit:"pt",min:.25,max:12},N={mul:1,unit:"pt"},M={mul:.02,unit:"%"};function C(e,t=S){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 A(e,t,r){if(e.namespaceURI!=k)return!1;switch(e.localName){case"color":t.color=r.attr(e,"val");break;case"sz":t.fontSize=r.lengthAttr(e,"val",x);break;default:return!1}return!0}var T=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=S){return C(this.attr(e,t),r)}},E=new T,R=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){}},$={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function B(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(D(a,t))}return r}(e,t))}function D(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:$[e.localName]}}var L=class extends R{parseXml(e){this.fonts=B(e,this._package.xmlParser)}};var F=class e{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new T}get(e){var t;const r=function(e){return e.startsWith("/")?e.substr(1):e}(e);return null!==(t=this._zip.files[r])&&void 0!==t?t:this._zip.files[r.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static async load(r,a){const n=await t.default.loadAsync(r);return new e(n,a)}save(e="blob"){return this._zip.generateAsync({type:e})}load(e,t="string"){var r,a;return null!==(r=null===(a=this.get(e))||void 0===a?void 0:a.async(t))&&void 0!==r?r:Promise.resolve(null)}async loadRelationships(e=null){let t="_rels/.rels";if(null!=e){const[r,a]=m(e);t=`${r}_rels/${a}.rels`}const r=await this.load(t);return r?(a=this.parseXmlDocument(r).firstElementChild,(n=this.xmlParser).elements(a).map(e=>({id:n.attr(e,"Id"),type:n.attr(e,"Type"),target:n.attr(e,"Target"),targetMode:n.attr(e,"TargetMode")}))):null;var a,n}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=null===(s=a.getElementsByTagName("parsererror")[0])||void 0===s?void 0:s.textContent;var s;if(n)throw new Error(n);return a}(e,this.options.trimXmlDeclaration)}};var H=class extends R{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}};function O(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",P),offset:t.lengthAttr(e,"space",N),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}function I(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"left":r.left=O(a,t);break;case"top":r.top=O(a,t);break;case"right":r.right=O(a,t);break;case"bottom":r.bottom=O(a,t)}return r}function _(e,t=E){var r={};for(let s of t.elements(e))switch(s.localName){case"pgSz":r.pageSize={width:t.lengthAttr(s,"w"),height:t.lengthAttr(s,"h"),orientation:t.attr(s,"orient")};break;case"type":r.type=t.attr(s,"val");break;case"pgMar":r.pageMargins={left:t.lengthAttr(s,"left"),right:t.lengthAttr(s,"right"),top:t.lengthAttr(s,"top"),bottom:t.lengthAttr(s,"bottom"),header:t.lengthAttr(s,"header"),footer:t.lengthAttr(s,"footer"),gutter:t.lengthAttr(s,"gutter")};break;case"cols":r.columns=j(s,t);break;case"headerReference":var a;(null!==(a=r.headerRefs)&&void 0!==a?a:r.headerRefs=[]).push(V(s,t));break;case"footerReference":var n;(null!==(n=r.footerRefs)&&void 0!==n?n:r.footerRefs=[]).push(V(s,t));break;case"titlePg":r.titlePage=t.boolAttr(s,"val",!0);break;case"pgBorders":r.pageBorders=I(s,t);break;case"pgNumType":r.pageNumber=z(s,t)}return r}function j(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 z(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function V(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}function W(e,t){let r={};for(let a of t.elements(e))X(a,r,t);return r}function X(e,t,r){return!!A(e,t,r)}function q(e,t){let r={};for(let a of t.elements(e))G(a,r,t);return r}function G(e,t,r){if(e.namespaceURI!=k)return!1;if(A(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,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=W(e,r);break;default:return!1}return!0}function U(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(Z(a,t))}return r}function J(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(Y(a,t))}return r}function Y(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=q(a,t);break;case"rPr":r.runProps=W(a,t)}return r}function Z(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=Y(a,t)}return r}function K(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 Q=class extends R{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(U(a,t));break;case"abstractNum":r.abstractNumberings.push(J(a,t));break;case"numPicBullet":r.bulletPictures.push(K(a,t))}return r}(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}},ee=class extends R{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}},te=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}({}),re=class{constructor(){this.children=[],this.cssStyle={}}},ae=class extends re{constructor(...e){super(...e),this.type=te.Header}},ne=class extends re{constructor(...e){super(...e),this.type=te.Footer}},se=class extends R{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(e)}},le=class extends se{createRootElement(){return new ae}},oe=class extends se{createRootElement(){return new ne}};function ie(e){if(void 0!==e)return parseInt(e)}var ce=class extends R{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=ie(a.textContent);break;case"Words":r.words=ie(a.textContent);break;case"Characters":r.characters=ie(a.textContent);break;case"Application":r.application=a.textContent;break;case"Lines":r.lines=ie(a.textContent);break;case"Paragraphs":r.paragraphs=ie(a.textContent);break;case"Company":r.company=a.textContent;break;case"AppVersion":r.appVersion=a.textContent}return r}(e,this._package.xmlParser)}};var he=class extends R{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)}},ue=class{};function de(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 me(e,t){var r={name:t.attr(e,"name")};for(let a of t.elements(e))switch(a.localName){case"majorFont":r.majorFont=pe(a,t);break;case"minorFont":r.minorFont=pe(a,t)}return r}function pe(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}var fe=class extends R{constructor(e,t){super(e,t)}parseXml(e){this.theme=function(e,t){var r=new ue,a=t.element(e,"themeElements");for(let n of t.elements(a))switch(n.localName){case"clrScheme":r.colorScheme=de(n,t);break;case"fontScheme":r.fontScheme=me(n,t)}return r}(e,this._package.xmlParser)}},ge=class{},be=class extends ge{constructor(...e){super(...e),this.type=te.Footnote}},ye=class extends ge{constructor(...e){super(...e),this.type=te.Endnote}},ve=class extends R{constructor(e,t,r){super(e,t),this._documentParser=r}},ke=class extends ve{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"footnote",be)}},Se=class extends ve{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"endnote",ye)}};function we(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 xe=class extends R{constructor(e,t){super(e,t)}parseXml(e){this.settings=function(e,t){var r={};for(let n of t.elements(e))switch(n.localName){case"defaultTabStop":r.defaultTabStop=t.lengthAttr(n,"val");break;case"footnotePr":r.footnoteProps=we(n,t);break;case"endnotePr":r.endnoteProps=we(n,t);break;case"autoHyphenation":r.autoHyphenation=t.boolAttr(n,"val");break;case"compat":for(let e of t.elements(n)){var a;"compatSetting"==e.localName&&"compatibilityMode"==t.attr(e,"name")&&(null!==(a=t.attr(e,"uri"))&&void 0!==a?a:"").includes("schemas.microsoft.com/office/word")&&(r.compatMode=t.intAttr(e,"val",null))}}return r}(e,this._package.xmlParser)}};var Pe=class extends R{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)}},Ne=class extends R{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=f(this.comments,e=>e.id)}},Me=class extends R{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=f(this.comments,e=>e.paraId)}},Ce=[{type:u.OfficeDocument,target:"word/document.xml"},{type:u.ExtendedProperties,target:"docProps/app.xml"},{type:u.CoreProperties,target:"docProps/core.xml"},{type:u.CustomProperties,target:"docProps/custom.xml"}],Ae=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 F.load(t,a),n.rels=await n._package.loadRelationships(),n.contentTypes=await n._package.loadContentTypes(),await Promise.all(Ce.map(e=>{var t;const r=null!==(t=n.rels.find(t=>t.type===e.type))&&void 0!==t?t:e;return n.loadRelationshipPart(r.target,r.type)})),n}save(e="blob"){return this._package.save(e)}async loadRelationshipPart(e,t){var r;if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let a=null;switch(t){case u.OfficeDocument:this.documentPart=a=new H(this._package,e,this._parser);break;case u.FontTable:this.fontTablePart=a=new L(this._package,e);break;case u.Numbering:this.numberingPart=a=new Q(this._package,e,this._parser);break;case u.Styles:this.stylesPart=a=new ee(this._package,e,this._parser);break;case u.Theme:this.themePart=a=new fe(this._package,e);break;case u.Footnotes:this.footnotesPart=a=new ke(this._package,e,this._parser);break;case u.Endnotes:this.endnotesPart=a=new Se(this._package,e,this._parser);break;case u.Footer:a=new oe(this._package,e,this._parser);break;case u.Header:a=new le(this._package,e,this._parser);break;case u.CoreProperties:this.corePropsPart=a=new he(this._package,e);break;case u.ExtendedProperties:this.extendedPropsPart=a=new ce(this._package,e);break;case u.CustomProperties:a=new Pe(this._package,e);break;case u.Settings:this.settingsPart=a=new xe(this._package,e);break;case u.Comments:this.commentsPart=a=new Ne(this._package,e,this._parser);break;case u.CommentsExtended:this.commentsExtendedPart=a=new Me(this._package,e)}if(null==a)return Promise.resolve(null);if(this.partsMap[e]=a,this.parts.push(a),await a.load(),(null===(r=a.rels)||void 0===r?void 0:r.length)>0){const[e]=m(a.path);await Promise.all(a.rels.map(t=>this.loadRelationshipPart(p(t.target,e),t.type)))}return a}async loadDocumentImage(e,t){const r=this.getPathById(null!=t?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([Te(a,t)]),r):a}async loadAltChunk(e,t){const r=this.getPathById(null!=t?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,a=(null!==(r=t.rels)&&void 0!==r?r:this.rels).find(t=>t.id==e);const n=t?m(t.path)[0]:"";return a?this.partsMap[p(a.target,n)]:null}getPathById(e,t){const r=e.rels.find(e=>e.id==t),[a]=m(e.path);return r?p(r.target,a):null}};function Te(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 Ee(e,t){return{type:te.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}}function Re(e,t){return{type:te.BookmarkEnd,id:t.attr(e,"id")}}var $e=class extends re{constructor(...e){super(...e),this.type=te.VmlElement,this.attrs={}}};function Be(e,t){var r=new $e;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 E.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]=Fe(a.value);Object.assign(r.attrs,{x1:e,y1:t});break;case"to":const[n,s]=Fe(a.value);Object.assign(r.attrs,{x2:n,y2:s})}for(const a of E.elements(e))switch(a.localName){case"stroke":Object.assign(r.attrs,De(a));break;case"fill":Object.assign(r.attrs,Le(a));break;case"imagedata":r.tagName="image",Object.assign(r.attrs,{width:"100%",height:"100%"}),r.imageHref={id:E.attr(a,"id"),title:E.attr(a,"title")};break;case"txbxContent":r.children.push(...t.parseBodyElements(a));break;default:const e=Be(a,t);e&&r.children.push(e)}return r}function De(e){var t;return{stroke:E.attr(e,"color"),"stroke-width":null!==(t=E.lengthAttr(e,"weight",w))&&void 0!==t?t:"1px"}}function Le(e){return{}}function Fe(e){return e.split(",")}var He=class extends re{constructor(...e){super(...e),this.type=te.Comment}},Oe=class extends re{constructor(e){super(),this.id=e,this.type=te.CommentReference}},Ie=class extends re{constructor(e){super(),this.id=e,this.type=te.CommentRangeStart}},_e=class extends re{constructor(e){super(),this.id=e,this.type=te.CommentRangeEnd}},je="inherit",ze="black",Ve="black",We="transparent",Xe=[],qe={oMath:te.MmlMath,oMathPara:te.MmlMathParagraph,f:te.MmlFraction,func:te.MmlFunction,fName:te.MmlFunctionName,num:te.MmlNumerator,den:te.MmlDenominator,rad:te.MmlRadical,deg:te.MmlDegree,e:te.MmlBase,sSup:te.MmlSuperscript,sSub:te.MmlSubscript,sPre:te.MmlPreSubSuper,sup:te.MmlSuperArgument,sub:te.MmlSubArgument,d:te.MmlDelimiter,nary:te.MmlNary,eqArr:te.MmlEquationArray,lim:te.MmlLimit,limLow:te.MmlLimitLower,m:te.MmlMatrix,mr:te.MmlMatrixRow,box:te.MmlBox,bar:te.MmlBar,groupChr:te.MmlGroupChar},Ge=class{constructor(e){this.options={ignoreWidth:!1,debug:!1,...e}}parseNotes(e,t,r){var a=[];for(let n of E.elements(e,t)){const e=new r;e.id=E.attr(n,"id"),e.noteType=E.attr(n,"type"),e.children=this.parseBodyElements(n),a.push(e)}return a}parseComments(e){var t=[];for(let r of E.elements(e,"comment")){const e=new He;e.id=E.attr(r,"id"),e.author=E.attr(r,"author"),e.initials=E.attr(r,"initials"),e.date=E.attr(r,"date"),e.children=this.parseBodyElements(r),t.push(e)}return t}parseDocumentFile(e){var t=E.element(e,"body"),r=E.element(e,"background"),a=E.element(t,"sectPr");return{type:te.Document,children:this.parseBodyElements(t),props:a?_(a,E):{},cssStyle:r?this.parseBackground(r):{}}}parseBackground(e){var t={},r=Je.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){var t=[];for(const r of E.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 E.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 E.elements(e))switch(n.localName){case"rPrDefault":var r=E.element(n,"rPr");r&&t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})});break;case"pPrDefault":var a=E.element(n,"pPr");a&&t.styles.push({target:"p",values:this.parseDefaultProperties(a,{})})}return t}parseStyle(e){var t={id:E.attr(e,"styleId"),isDefault:E.boolAttr(e,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(E.attr(e,"type")){case"paragraph":t.target="p";break;case"table":t.target="table";break;case"character":t.target="span"}for(const r of E.elements(e))switch(r.localName){case"basedOn":t.basedOn=E.attr(r,"val");break;case"name":t.name=E.attr(r,"val");break;case"link":t.linked=E.attr(r,"val");break;case"next":t.next=E.attr(r,"val");break;case"aliases":t.aliases=E.attr(r,"val").split(",");break;case"pPr":t.styles.push({target:"p",values:this.parseDefaultProperties(r,{})}),t.paragraphProps=q(r,E);break;case"rPr":t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})}),t.runProps=W(r,E);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(E.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 E.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 E.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:E.attr(n,"numId"),abstractNumId:E.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=E.element(e,"pict"),r=t&&E.element(t,"shape"),a=r&&E.element(r,"imagedata");return a?{id:E.intAttr(e,"numPicBulletId"),src:E.attr(a,"id"),style:E.attr(r,"style")}:null}parseAbstractNumbering(e,t){var r=[],a=E.attr(e,"abstractNumId");for(const n of E.elements(e))if("lvl"===n.localName)r.push(this.parseNumberingLevel(a,n,t));return r}parseNumberingLevel(e,t,r){var a={id:e,level:E.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const s of E.elements(t))switch(s.localName){case"start":a.start=E.intAttr(s,"val");break;case"pPr":this.parseDefaultProperties(s,a.pStyle);break;case"rPr":this.parseDefaultProperties(s,a.rStyle);break;case"lvlPicBulletId":var n=E.intAttr(s,"val");a.bullet=r.find(e=>(null==e?void 0:e.id)==n);break;case"lvlText":a.levelText=E.attr(s,"val");break;case"pStyle":a.pStyleName=E.attr(s,"val");break;case"numFmt":a.format=E.attr(s,"val");break;case"suff":a.suff=E.attr(s,"val")}return a}parseSdt(e,t){const r=E.element(e,"sdtContent");return r?t(r):[]}parseChange(e,t,r){var a,n;return{type:e,children:null!==(a=null===(n=r(t))||void 0===n?void 0:n.children)&&void 0!==a?a:[],id:E.attr(t,"id"),author:E.attr(t,"author"),date:E.attr(t,"date")}}parseAltChunk(e){return{type:te.AltChunk,children:[],id:E.attr(e,"id")}}parseParagraph(e){var t={type:te.Paragraph,children:[]};for(let r of E.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(Ee(r,E));break;case"bookmarkEnd":t.children.push(Re(r,E));break;case"commentRangeStart":t.children.push(new Ie(E.attr(r,"id")));break;case"commentRangeEnd":t.children.push(new _e(E.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(te.Inserted,r,e=>this.parseParagraph(e)));break;case"del":t.children.push(this.parseChange(te.Deleted,r,e=>this.parseParagraph(e)))}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{if(G(e,t,E))return!0;switch(e.localName){case"pStyle":t.styleName=E.attr(e,"val");break;case"cnfStyle":t.className=Ye.classNameOfCnfStyle(e);break;case"framePr":this.parseFrame(e,t);break;case"rPr":break;default:return!1}return!0})}parseFrame(e,t){"drop"==E.attr(e,"dropCap")&&(t.cssStyle.float="left")}parseHyperlink(e,t){var r={type:te.Hyperlink,parent:t,children:[]};r.anchor=E.attr(e,"anchor"),r.id=E.attr(e,"id");for(const a of E.elements(e))if("r"===a.localName)r.children.push(this.parseRun(a,r));return r}parseSmartTag(e,t){var r={type:te.SmartTag,parent:t,children:[]},a=E.attr(e,"uri"),n=E.attr(e,"element");a&&(r.uri=a),n&&(r.element=n);for(const s of E.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 r={type:te.Run,parent:t,children:[]};for(let a of E.elements(e))switch(a=this.checkAlternateContent(a),a.localName){case"t":r.children.push({type:te.Text,text:a.textContent});break;case"delText":r.children.push({type:te.DeletedText,text:a.textContent});break;case"commentReference":r.children.push(new Oe(E.attr(a,"id")));break;case"fldSimple":r.children.push({type:te.SimpleField,instruction:E.attr(a,"instr"),lock:E.boolAttr(a,"lock",!1),dirty:E.boolAttr(a,"dirty",!1)});break;case"instrText":r.fieldRun=!0,r.children.push({type:te.Instruction,text:a.textContent});break;case"fldChar":r.fieldRun=!0,r.children.push({type:te.ComplexField,charType:E.attr(a,"fldCharType"),lock:E.boolAttr(a,"lock",!1),dirty:E.boolAttr(a,"dirty",!1)});break;case"noBreakHyphen":r.children.push({type:te.NoBreakHyphen});break;case"br":r.children.push({type:te.Break,break:E.attr(a,"type")||"textWrapping"});break;case"lastRenderedPageBreak":r.children.push({type:te.Break,break:"lastRenderedPageBreak"});break;case"sym":r.children.push({type:te.Symbol,font:d(E.attr(a,"font")),char:E.hexAttr(a,"char")});break;case"tab":r.children.push({type:te.Tab});break;case"footnoteReference":r.children.push({type:te.FootnoteReference,id:E.attr(a,"id")});break;case"endnoteReference":r.children.push({type:te.EndnoteReference,id:E.attr(a,"id")});break;case"drawing":let e=this.parseDrawing(a);e&&r.children.push(e);break;case"pict":r.children.push(this.parseVmlPicture(a));break;case"rPr":this.parseRunProperties(a,r)}return r}parseMathElement(e){const t=`${e.localName}Pr`,r={type:qe[e.localName],children:[]};for(const n of E.elements(e))if(qe[n.localName])r.children.push(this.parseMathElement(n));else if("r"==n.localName){var a=this.parseRun(n);a.type=te.MmlRun,r.children.push(a)}else n.localName==t&&(r.props=this.parseMathProperies(n));return r}parseMathProperies(e){const t={};for(const r of E.elements(e))switch(r.localName){case"chr":t.char=E.attr(r,"val");break;case"vertJc":t.verticalJustification=E.attr(r,"val");break;case"pos":t.position=E.attr(r,"val");break;case"degHide":t.hideDegree=E.boolAttr(r,"val");break;case"begChr":t.beginChar=E.attr(r,"val");break;case"endChr":t.endChar=E.attr(r,"val")}return t}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{switch(e.localName){case"rStyle":t.styleName=E.attr(e,"val");break;case"vertAlign":t.verticalAlign=Ye.valueOfVertAlign(e,!0);break;default:return!1}return!0})}parseVmlPicture(e){const t={type:te.VmlPicture,children:[]};for(const r of E.elements(e)){const e=Be(r,this);e&&t.children.push(e)}return t}checkAlternateContent(e){var t;if("AlternateContent"!=e.localName)return e;var r=E.element(e,"Choice");if(r){var a=E.attr(r,"Requires"),n=e.lookupNamespaceURI(a);if(Xe.includes(n))return r.firstElementChild}return null===(t=E.element(e,"Fallback"))||void 0===t?void 0:t.firstElementChild}parseDrawing(e){for(var t of E.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t)}}parseDrawingWrapper(e){var t={type:te.Drawing,children:[],cssStyle:{}},r="anchor"==e.localName;let a=null,n=E.boolAttr(e,"simplePos");E.boolAttr(e,"behindDoc");let s={relative:"page",align:"left",offset:"0"},l={relative:"page",align:"top",offset:"0"};for(var o of E.elements(e))switch(o.localName){case"simplePos":n&&(s.offset=E.lengthAttr(o,"x",w),l.offset=E.lengthAttr(o,"y",w));break;case"extent":t.cssStyle.width=E.lengthAttr(o,"cx",w),t.cssStyle.height=E.lengthAttr(o,"cy",w);break;case"positionH":case"positionV":if(!n){var i;let e="positionH"==o.localName?s:l;var c=E.element(o,"align"),h=E.element(o,"posOffset");e.relative=null!==(i=E.attr(o,"relativeFrom"))&&void 0!==i?i:e.relative,c&&(e.align=c.textContent),h&&(e.offset=C(h.textContent,w))}break;case"wrapTopAndBottom":a="wrapTopAndBottom";break;case"wrapNone":a="wrapNone";break;case"graphic":var u=this.parseGraphic(o);u&&t.children.push(u)}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=E.element(e,"graphicData");for(let r of E.elements(t))if("pic"===r.localName)return this.parsePicture(r);return null}parsePicture(e){var t={type:te.Image,src:"",cssStyle:{}},r=E.element(e,"blipFill"),a=E.element(r,"blip"),n=E.element(r,"srcRect");t.src=E.attr(a,"embed"),n&&(t.srcRect=[E.intAttr(n,"l",0)/1e5,E.intAttr(n,"t",0)/1e5,E.intAttr(n,"r",0)/1e5,E.intAttr(n,"b",0)/1e5]);var s=E.element(e,"spPr"),l=E.element(s,"xfrm");if(t.cssStyle.position="relative",l)for(var o of(t.rotation=E.intAttr(l,"rot",0)/6e4,E.elements(l)))switch(o.localName){case"ext":t.cssStyle.width=E.lengthAttr(o,"cx",w),t.cssStyle.height=E.lengthAttr(o,"cy",w);break;case"off":t.cssStyle.left=E.lengthAttr(o,"x",w),t.cssStyle.top=E.lengthAttr(o,"y",w)}return t}parseTable(e){var t={type:te.Table,children:[]};for(const r of E.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 E.elements(e))if("gridCol"===r.localName)t.push({width:E.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=E.attr(e,"val");break;case"tblLook":t.className=Ye.classNameOftblLook(e);break;case"tblpPr":this.parseTablePosition(e,t);break;case"tblStyleColBandSize":t.colBandSize=E.intAttr(e,"val");break;case"tblStyleRowBandSize":t.rowBandSize=E.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=E.lengthAttr(e,"topFromText"),a=E.lengthAttr(e,"bottomFromText"),n=E.lengthAttr(e,"rightFromText"),s=E.lengthAttr(e,"leftFromText"),l=E.attr(e,"horzAnchor"),o=E.attr(e,"vertAnchor"),i=E.attr(e,"tblpXSpec");if("bottom"==E.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"]=Ye.addSize(t.cssStyle["margin-bottom"],a),t.cssStyle["margin-left"]=Ye.addSize(t.cssStyle["margin-left"],s),t.cssStyle["margin-right"]=Ye.addSize(t.cssStyle["margin-right"],n),t.cssStyle["margin-top"]=Ye.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){var t={type:te.Row,children:[]};for(const r of E.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=Ye.classNameOfCnfStyle(e);break;case"tblHeader":t.isHeader=E.boolAttr(e,"val");break;case"gridBefore":t.gridBefore=E.intAttr(e,"val");break;case"gridAfter":t.gridAfter=E.intAttr(e,"val");break;default:return!1}return!0})}parseTableCell(e){var t={type:te.Cell,children:[]};for(const r of E.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=E.intAttr(e,"val",null);break;case"vMerge":var r;t.verticalMerge=null!==(r=E.attr(e,"val"))&&void 0!==r?r:"continue";break;case"cnfStyle":t.className=Ye.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 E.elements(e))if("textDirection"===a.localName){const e=r[E.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 E.elements(e))if(!(null==a?void 0:a(n)))switch(n.localName){case"jc":t["text-align"]=Ye.valueOfJc(n);break;case"textAlignment":t["vertical-align"]=Ye.valueOfTextAlignment(n);break;case"color":t.color=Je.colorAttr(n,"val",null,ze);break;case"sz":t["font-size"]=t["min-height"]=E.lengthAttr(n,"val",x);break;case"shd":t["background-color"]=Je.colorAttr(n,"fill",null,je);break;case"highlight":t["background-color"]=Je.colorAttr(n,"val",null,We);break;case"vertAlign":break;case"position":t.verticalAlign=E.lengthAttr(n,"val",x);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":t.width=Ye.valueOfSize(n,"w");break;case"trHeight":this.parseTrHeight(n,t);break;case"strike":t["text-decoration"]=E.boolAttr(n,"val",!0)?"line-through":"none";break;case"b":t["font-weight"]=E.boolAttr(n,"val",!0)?"bold":"normal";break;case"i":t["font-style"]=E.boolAttr(n,"val",!0)?"italic":"normal";break;case"caps":t["text-transform"]=E.boolAttr(n,"val",!0)?"uppercase":"none";break;case"smallCaps":t["font-variant"]=E.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"]=Ye.valueOfMargin(n),t["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(n,t);break;case"bdr":t.border=Ye.valueOfBorder(n);break;case"tcBorders":this.parseBorderProperties(n,t);break;case"vanish":E.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"]=Ye.valueOfTblLayout(n);break;case"vAlign":t["vertical-align"]=Ye.valueOfTextAlignment(n);break;case"spacing":"pPr"==e.localName&&this.parseSpacing(n,t);break;case"wordWrap":E.boolAttr(n,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=E.boolAttr(n,"val",!0)?"none":"auto";break;case"lang":t.$lang=E.attr(n,"val");break;case"rtl":case"bidi":E.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=E.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=Je.colorAttr(e,"color");a&&(t["text-decoration-color"]=a)}}parseFont(e,t){var r,a,n,s,l=null!==(r=null!==(a=null!==(n=E.attr(e,"ascii"))&&void 0!==n?n:E.attr(e,"hAnsi"))&&void 0!==a?a:Ye.themeValue(e,"asciiTheme"))&&void 0!==r?r:Ye.themeValue(e,"hAnsiTheme"),o=null!==(s=E.attr(e,"eastAsia"))&&void 0!==s?s:Ye.themeValue(e,"eastAsiaTheme");l&&(t["--docx-font-ascii"]=d(l)),o&&(t["--docx-font-ea"]=d(o))}parseIndentation(e,t){var r=E.lengthAttr(e,"firstLine"),a=E.lengthAttr(e,"hanging"),n=E.lengthAttr(e,"left"),s=E.lengthAttr(e,"start"),l=E.lengthAttr(e,"right"),o=E.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=E.lengthAttr(e,"before"),a=E.lengthAttr(e,"after"),n=E.intAttr(e,"beforeLines",null),s=E.intAttr(e,"afterLines",null),l=E.intAttr(e,"line",null),o=E.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 E.elements(e))switch(r.localName){case"left":t["padding-left"]=Ye.valueOfMargin(r);break;case"right":t["padding-right"]=Ye.valueOfMargin(r);break;case"top":t["padding-top"]=Ye.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=Ye.valueOfMargin(r)}}parseTrHeight(e,t){E.attr(e,"hRule"),t.height=E.lengthAttr(e,"val")}parseBorderProperties(e,t){for(const r of E.elements(e))switch(r.localName){case"start":case"left":t["border-left"]=Ye.valueOfBorder(r);break;case"end":case"right":t["border-right"]=Ye.valueOfBorder(r);break;case"top":t["border-top"]=Ye.valueOfBorder(r);break;case"bottom":t["border-bottom"]=Ye.valueOfBorder(r)}}},Ue=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"],Je=class{static colorAttr(e,t,r=null,a="black"){var n=E.attr(e,t);if(n)return"auto"==n?a:Ue.includes(n)?n:`#${n}`;var s=E.attr(e,"themeColor");return s?`var(--docx-${s}-color)`:r}},Ye=class e{static themeValue(e,t){var r=E.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){var r=S;switch(E.attr(e,"type")){case"dxa":break;case"pct":r=M;break;case"auto":return"auto"}return E.lengthAttr(e,t,r)}static valueOfMargin(e){return E.lengthAttr(e,"w")}static valueOfBorder(t){var r=e.parseBorderType(E.attr(t,"val"));if("none"==r)return"none";var a=Je.colorAttr(t,"color");return`${E.lengthAttr(t,"sz",P)} ${r} ${"auto"==a?Ve: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"==E.attr(e,"val")?"fixed":"auto"}static classNameOfCnfStyle(e){const t=E.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)=>E.boolAttr(e,a[r])).join(" ")}static valueOfJc(e){var t=E.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=E.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfTextAlignment(e){var t=E.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=E.hexAttr(e,"val",0);let r="";return(E.boolAttr(e,"firstRow")||32&t)&&(r+=" first-row"),(E.boolAttr(e,"lastRow")||64&t)&&(r+=" last-row"),(E.boolAttr(e,"firstColumn")||128&t)&&(r+=" first-col"),(E.boolAttr(e,"lastColumn")||256&t)&&(r+=" last-col"),(E.boolAttr(e,"noHBand")||512&t)&&(r+=" no-hband"),(E.boolAttr(e,"noVBand")||1024&t)&&(r+=" no-vband"),r.trim()}},Ze={pos:0,leader:"none",style:"left"};function Ke(e,t,r,a=.75){const n=e.closest("p"),s=e.getBoundingClientRect(),l=n.getBoundingClientRect(),o=getComputedStyle(n),i=(null==t?void 0:t.length)>0?t.map(e=>({pos:Qe(e.position),leader:e.leader,style:e.style})).sort((e,t)=>e.pos-t.pos):[Ze],c=i[i.length-1],h=l.width*a,u=Qe(r);let d=c.pos+u;if(d<h)for(;d<h&&i.length<50;d+=u)i.push({...Ze,pos:d});const m=parseFloat(o.marginLeft),p=l.left+m,f=(s.left-p)*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-m);b=g.pos-c*a}else b=g.pos-f;switch(e.innerHTML="&nbsp;",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 Qe(e){return parseFloat(e)}var et=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 tt(e){if(b(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 o=t?document.createElementNS(t,r):document.createElement(r);if(a&&o.setAttribute("class",a),n)if(b(n))o.setAttribute("style",n);else for(const[i,c]of Object.entries(n))i.startsWith("--")?o.style.setProperty(i,c):o.style[i]=c;if(l)for(const[i,c]of Object.entries(l))void 0!==c&&(o[i]=c);return s&&s.forEach(e=>o.appendChild(tt(e))),o}function rt(...e){return e.filter(Boolean).join(" ")}var at=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=tt}async render(e,t){var r;this.document=e,this.options=t,this.className=t.className,this.rootSelector=t.inWrapper?`.${this.className}-wrapper`:":root",this.h=null!==(r=t.h)&&void 0!==r?r:tt,this.styleMap=null,this.tasks=[],this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);const a=[...this.renderDefaultStyle()];if(e.themePart&&a.push(...this.renderTheme(e.themePart)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),a.push(...this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.prodessNumberings(e.numberingPart.domNumberings),a.push(...await this.renderNumbering(e.numberingPart.domNumberings))),e.footnotesPart&&(this.footnoteMap=f(e.footnotesPart.notes,e=>e.id)),e.endnotesPart&&(this.endnoteMap=f(e.endnotesPart.notes,e=>e.id)),e.settingsPart){var n,s;this.defaultTabSize=null===(n=e.settingsPart.settings)||void 0===n?void 0:n.defaultTabStop;const t=null===(s=e.settingsPart.settings)||void 0===s?void 0:s.compatMode;this.legacyCompat=null!=t&&t<=11}!t.ignoreFonts&&e.fontTablePart&&a.push(...await this.renderFontTable(e.fontTablePart));var l=this.renderSections(e.documentPart.body);return this.options.inWrapper?a.push(this.renderWrapper(l)):a.push(...l),this.commentHighlight&&t.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(e=>e()),await Promise.allSettled(this.tasks),this.refreshTabStops(),a}renderTheme(e){var t,r;const a={},n=null===(t=e.theme)||void 0===t?void 0:t.fontScheme;n&&(n.majorFont&&(a["--docx-majorHAnsi-font"]=n.majorFont.latinTypeface,a["--docx-majorEastAsia-font"]=n.majorFont.eaTypeface||n.majorFont.latinTypeface),n.minorFont&&(a["--docx-minorHAnsi-font"]=n.minorFont.latinTypeface,a["--docx-minorEastAsia-font"]=n.minorFont.eaTypeface||n.minorFont.latinTypeface));const s=null===(r=e.theme)||void 0===r?void 0:r.colorScheme;if(s)for(let[o,i]of Object.entries(s.colors))a[`--docx-${o}-color`]=`#${i}`;const l=this.styleToString(`.${this.className}`,a);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[l]})]}async renderFontTable(e){const t=[];for(let a of e.fonts)for(let e of a.embedFontRefs)try{const r=await this.document.loadFont(e.id,e.key),n={"font-family":d(a.name),src:`url(${r})`};"bold"!=e.type&&"boldItalic"!=e.type||(n["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(n["font-style"]="italic"),t.push(this.h({tagName:"#comment",children:[`docxjs ${a.name} font`]})),t.push(this.h({tagName:"style",children:[this.styleToString("@font-face",n)]}))}catch(r){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 null==e?void 0:e.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}(e)}`:this.className}processStyles(e){const t=f(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=y(a.paragraphProps,r.paragraphProps),a.runProps=y(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 r of e.filter(e=>e.pStyleName)){var t;const e=this.findStyle(r.pStyleName);(null==e||null===(t=e.paragraphProps)||void 0===t?void 0:t.numbering)&&(e.paragraphProps.numbering.level=r.level)}}processElement(e){if(e.children)for(var t of e.children)t.parent=e,t.type==te.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){var s,l;if(e){var o=null!==(s=null!==(l=t.titlePage&&a?e.find(e=>"first"==e.type):null)&&void 0!==l?l:r%2==1?e.find(e=>"even"==e.type):null)&&void 0!==s?s:e.find(e=>"default"==e.type),i=o&&this.document.findPartByRelId(o.id,this.document.documentPart);if(i){this.currentPart=i,this.usedHederFooterParts.includes(i.path)||(this.processElement(i.rootElement),this.usedHederFooterParts.push(i.path));const[e]=this.renderElements([i.rootElement],n);(null==t?void 0:t.pageMargins)&&(i.rootElement.type===te.Header?(e.style.marginTop=`calc(${t.pageMargins.header} - ${t.pageMargins.top})`,e.style.minHeight=`calc(${t.pageMargins.top} - ${t.pageMargins.header})`):i.rootElement.type===te.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==te.Break&&("lastRenderedPageBreak"==e.break?!this.options.ignoreLastRenderedPageBreak:"page"==e.break)}isPageBreakSection(e,t){var r,a,n,s,l,o;return!!e&&(!!t&&((null===(r=e.pageSize)||void 0===r?void 0:r.orientation)!=(null===(a=t.pageSize)||void 0===a?void 0:a.orientation)||(null===(n=e.pageSize)||void 0===n?void 0:n.width)!=(null===(s=t.pageSize)||void 0===s?void 0:s.width)||(null===(l=e.pageSize)||void 0===l?void 0:l.height)!=(null===(o=t.pageSize)||void 0===o?void 0:o.height)))}splitBySection(e,t){var r={sectProps:null,elements:[],pageBreak:!1},a=[r];for(let d of e){if(d.type==te.Paragraph){var n;const e=this.findStyle(d.styleName);(null==e||null===(n=e.paragraphProps)||void 0===n?void 0:n.pageBreakBefore)&&(r.sectProps=s,r.pageBreak=!0,r={sectProps:null,elements:[],pageBreak:!1},a.push(r))}if(r.elements.push(d),d.type==te.Paragraph){const e=d;var s=e.sectionProps,l=-1,o=-1;if(this.options.breakPages&&e.children&&(l=e.children.findIndex(e=>{var t,r;return-1!=(o=null!==(t=null===(r=e.children)||void 0===r?void 0:r.findIndex(this.isPageBreakElement.bind(this)))&&void 0!==t?t:-1)})),(s||-1!=l)&&(r.sectProps=s,r.pageBreak=-1!=l,r={sectProps:null,elements:[],pageBreak:!1},a.push(r)),-1!=l){let t=e.children[l],a=o<t.children.length-1;if(l<e.children.length-1||a){var i=d.children,c={...d,children:i.slice(l)};if(d.children=i.slice(0,l),r.elements.push(c),a){let e=t.children,r={...t,children:e.slice(0,o)};d.children.push(r),t.children=e.slice(o)}}}}}let h=null;for(let d=a.length-1;d>=0;d--)if(null==a[d].sectProps){var u;a[d].sectProps=null!==(u=h)&&void 0!==u?u:t}else h=a[d].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=f(e.filter(e=>e.isDefault),e=>e.target);for(const i of e){var n=i.styles;if(i.linked){var s=i.linked&&r[i.linked];s?n=n.concat(s.styles):this.options.debug&&console.warn(`Can't find linked style ${i.linked}`)}for(const e of n){var l,o=`${null!==(l=i.target)&&void 0!==l?l:""}.${i.cssName}`;i.target!=e.target&&(o+=` ${e.target}`),null==i.id&&"span"==e.target&&(o=`.${this.className}`),a[i.target]==i&&(o=`.${this.className} ${i.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 te.Paragraph:return this.renderParagraph(e);case te.BookmarkStart:return this.renderBookmarkStart(e);case te.BookmarkEnd:return null;case te.Run:return this.renderRun(e);case te.Table:return this.renderTable(e);case te.Row:return this.renderTableRow(e);case te.Cell:return this.renderTableCell(e);case te.Hyperlink:return this.renderHyperlink(e);case te.SmartTag:return this.renderSmartTag(e);case te.Drawing:return this.renderDrawing(e);case te.Image:return this.renderImage(e);case te.Text:case te.Text:return this.renderText(e);case te.DeletedText:return this.renderDeletedText(e);case te.Tab:return this.renderTab(e);case te.Symbol:return this.renderSymbol(e);case te.Break:return this.renderBreak(e);case te.Footer:return this.renderContainer(e,"footer");case te.Header:return this.renderContainer(e,"header");case te.Footnote:case te.Endnote:return this.renderContainer(e,"li");case te.FootnoteReference:return this.renderFootnoteReference(e);case te.EndnoteReference:return this.renderEndnoteReference(e);case te.NoBreakHyphen:return this.h({tagName:"wbr"});case te.VmlPicture:return this.renderVmlPicture(e);case te.VmlElement:return this.renderVmlElement(e);case te.MmlMath:return this.renderContainerNS(e,et.mathML,"math",{xmlns:et.mathML});case te.MmlMathParagraph:return this.renderContainer(e,"span");case te.MmlFraction:return this.renderContainerNS(e,et.mathML,"mfrac");case te.MmlBase:return this.renderContainerNS(e,et.mathML,e.parent.type==te.MmlMatrixRow?"mtd":"mrow");case te.MmlNumerator:case te.MmlDenominator:case te.MmlFunction:case te.MmlLimit:case te.MmlBox:return this.renderContainerNS(e,et.mathML,"mrow");case te.MmlGroupChar:return this.renderMmlGroupChar(e);case te.MmlLimitLower:return this.renderContainerNS(e,et.mathML,"munder");case te.MmlMatrix:return this.renderContainerNS(e,et.mathML,"mtable");case te.MmlMatrixRow:return this.renderContainerNS(e,et.mathML,"mtr");case te.MmlRadical:return this.renderMmlRadical(e);case te.MmlSuperscript:return this.renderContainerNS(e,et.mathML,"msup");case te.MmlSubscript:return this.renderContainerNS(e,et.mathML,"msub");case te.MmlDegree:case te.MmlSuperArgument:case te.MmlSubArgument:return this.renderContainerNS(e,et.mathML,"mn");case te.MmlFunctionName:return this.renderContainerNS(e,et.mathML,"ms");case te.MmlDelimiter:return this.renderMmlDelimiter(e);case te.MmlRun:return this.renderMmlRun(e);case te.MmlNary:return this.renderMmlNary(e);case te.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case te.MmlBar:return this.renderMmlBar(e);case te.MmlEquationArray:return this.renderMllList(e);case te.Inserted:return this.renderInserted(e);case te.Deleted:return this.renderDeleted(e);case te.CommentRangeStart:return this.renderCommentRangeStart(e);case te.CommentRangeEnd:return this.renderCommentRangeEnd(e);case te.CommentReference:return this.renderCommentReference(e);case te.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(b(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){var t;let r=null,a=!1;for(const l of null!==(t=e.children)&&void 0!==t?t:[]){var n;if(l.type==te.Run){for(const e of null!==(n=l.children)&&void 0!==n?n:[])if(e.type==te.ComplexField){const t=e.charType;"begin"==t?(r=null,a=!1):"separate"==t?a=!0:"end"==t&&(r=null,a=!1)}else if(e.type==te.Instruction){var s;r=null===(s=e.text)||void 0===s||null===(s=s.trim().split(/\s/)[0])||void 0===s?void 0:s.toUpperCase()}!a||"PAGE"!=r&&"NUMPAGES"!=r||l.fieldRun||(l.className=rt(l.className,`${this.className}-field-${r.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){var t,r,a,n;this.markPageFieldRuns(e);var s=this.toHTML(e,et.html,"p");const l=this.findStyle(e.styleName);null!==(t=e.tabs)&&void 0!==t||(e.tabs=null==l||null===(r=l.paragraphProps)||void 0===r?void 0:r.tabs);const o=null!==(a=e.numbering)&&void 0!==a?a:null==l||null===(n=l.paragraphProps)||void 0===n?void 0:n.numbering;return o&&s.classList.add(this.numberingClass(o.id,o.level)),this.legacyCompat&&"justify"===this.textAlignOf(e)&&/ {2,}| {2,}| /.test(s.textContent)&&s.style.setProperty("text-align-last","justify"),s}textAlignOf(e){var t,r,a,n;if(null===(t=e.cssStyle)||void 0===t?void 0:t["text-align"])return e.cssStyle["text-align"];const s=e=>{var t;return null==e||null===(t=e.styles)||void 0===t||null===(t=t.find(e=>"p"==e.target))||void 0===t||null===(t=t.values)||void 0===t?void 0:t["text-align"]};return null!==(r=null!==(a=null!==(n=s(this.findStyle(e.styleName)))&&void 0!==n?n:s(this.defaultParagraphStyle))&&void 0!==a?a:s(this.docDefaultsStyle))&&void 0!==r?r:null}renderHyperlink(e){const t=this.toH(e,et.html,"a");if(t.href="",e.id){var r;const a=this.document.documentPart.rels.find(t=>t.id==e.id&&"External"===t.targetMode);t.href=null!==(r=null==a?void 0:a.target)&&void 0!==r?r:t.href}return e.anchor&&(t.href+=`#${e.anchor}`),this.h(t)}renderSmartTag(e){return this.renderContainer(e,"span")}renderCommentRangeStart(e){var t;if(!this.options.renderComments)return null;const r=new Range;null===(t=this.commentHighlight)||void 0===t||t.add(r);const a=this.h({tagName:"#comment",children:[`start of comment #${e.id}`]});return this.later(()=>r.setStart(a,0)),this.commentMap[e.id]=r,a}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(()=>null==t?void 0:t.setEnd(r,0)),r}renderCommentReference(e){var t;if(!this.options.renderComments)return null;var r=null===(t=this.document.commentsPart)||void 0===t?void 0:t.commentMap[e.id];if(!r)return null;const a=this.h({tagName:"span",className:`${this.className}-comment-ref`,children:["💬"]}),n=this.h({tagName:"div",className:`${this.className}-comment-popover`,children:[this.h({tagName:"div",className:`${this.className}-comment-author`,children:[r.author]}),this.h({tagName:"div",className:`${this.className}-comment-date`,children:[new Date(r.date).toLocaleString()]}),...this.renderElements(r.children)]});return this.h({tagName:"#fragment",children:[this.h({tagName:"#comment",children:[`comment #${r.id} by ${r.author} on ${r.date}`]}),a,n]})}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,et.html,"div");return t.style.display="inline-block",t.style.position="relative",t.style.textIndent="0px",t}renderImage(e){var t,r;let a=this.toHTML(e,et.html,"img",[]),n=null===(t=e.cssStyle)||void 0===t?void 0:t.transform;if(e.srcRect&&e.srcRect.some(e=>0!=e)){var[s,l,o,i]=e.srcRect;n=`scale(${1/(1-s-o)}, ${1/(1-l-i)})`,a.style["clip-path"]=`rect(${(100*l).toFixed(2)}% ${(100*(1-o)).toFixed(2)}% ${(100*(1-i)).toFixed(2)}% ${(100*s).toFixed(2)}%)`}return e.rotation&&(n=`rotate(${e.rotation}deg) ${null!==(r=n)&&void 0!==r?r:""}`),a.style.transform=null==n?void 0:n.trim(),this.document&&this.tasks.push(this.document.loadDocumentImage(e.src,this.currentPart).then(e=>{a.src=e})),a}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){var r;t.className=this.tabStopClass();var a=null===(r=function(e,t){var r=e.parent;for(;null!=r&&r.type!=t;)r=r.parent;return r}(e,te.Paragraph))||void 0===r?void 0:r.tabs;this.currentTabs.push({stops:a,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,et.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,et.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,et.html,"tr",t)}renderTableCellPlaceholder(e){return this.h({tagName:"td",colSpan:e,style:{border:"none"}})}renderTableCell(e){let t=this.toHTML(e,et.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,r=this.h({ns:et.svg,tagName:"svg",style:e.cssStyleText});const a=this.renderVmlChildElement(e);var n;(null===(t=e.imageHref)||void 0===t?void 0:t.id)&&this.tasks.push(null===(n=this.document)||void 0===n?void 0:n.loadDocumentImage(e.imageHref.id,this.currentPart).then(e=>a.setAttribute("href",e)));return r.appendChild(a),requestAnimationFrame(()=>{const e=r.firstElementChild.getBBox();r.setAttribute("width",`${Math.ceil(e.x+e.width)}`),r.setAttribute("height",`${Math.ceil(e.y+e.height)}`)}),r}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==te.VmlElement?t.appendChild(this.renderVmlChildElement(r)):t.appendChild(...v(this.renderElement(r)));return t}renderMmlRadical(e){var t;const r=e.children.find(e=>e.type==te.MmlBase);if(null===(t=e.props)||void 0===t?void 0:t.hideDegree)return this.createMathMLElement("msqrt",null,this.renderElements([r]));const a=e.children.find(e=>e.type==te.MmlDegree);return this.createMathMLElement("mroot",null,this.renderElements([r,a]))}renderMmlDelimiter(e){var t,r;const a=[];return a.push(this.createMathMLElement("mo",null,[null!==(t=e.props.beginChar)&&void 0!==t?t:"("])),a.push(...this.renderElements(e.children)),a.push(this.createMathMLElement("mo",null,[null!==(r=e.props.endChar)&&void 0!==r?r:")"])),this.createMathMLElement("mrow",null,a)}renderMmlNary(e){var t,r;const a=[],n=f(e.children,e=>e.type),s=n[te.MmlSuperArgument],l=n[te.MmlSubArgument],o=s?this.createMathMLElement("mo",null,v(this.renderElement(s))):null,i=l?this.createMathMLElement("mo",null,v(this.renderElement(l))):null,c=this.createMathMLElement("mo",null,[null!==(t=null===(r=e.props)||void 0===r?void 0:r.char)&&void 0!==t?t:"∫"]);return o||i?a.push(this.createMathMLElement("munderover",null,[c,i,o])):o?a.push(this.createMathMLElement("mover",null,[c,o])):i?a.push(this.createMathMLElement("munder",null,[c,i])):a.push(c),a.push(...this.renderElements(n[te.MmlBase].children)),this.createMathMLElement("mrow",null,a)}renderMmlPreSubSuper(e){const t=[],r=f(e.children,e=>e.type),a=r[te.MmlSuperArgument],n=r[te.MmlSubArgument],s=a?this.createMathMLElement("mo",null,v(this.renderElement(a))):null,l=n?this.createMathMLElement("mo",null,v(this.renderElement(n))):null,o=this.createMathMLElement("mo",null);return t.push(this.createMathMLElement("msubsup",null,[o,l,s])),t.push(...this.renderElements(r[te.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlGroupChar(e){const t="bot"===e.props.verticalJustification?"mover":"munder",r=this.renderContainerNS(e,et.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,et.mathML,"mrow",{style:t})}renderMmlRun(e){return this.toHTML(e,et.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,et.mathML,"mtable",t)}toH(e,t,r,a=null){var n;const{$lang:s,...l}=null!==(n=e.cssStyle)&&void 0!==n?n:{};return{ns:t,tagName:r,className:rt(e.className,e.styleName&&this.processStyleName(e.styleName)),lang:s,style:l,children:null!=a?a:this.renderElements(e.children)}}toHTML(e,t,r,a=null){return this.h(this.toH(e,t,r,a))}findStyle(e){var t;return e&&(null===(t=this.styleMap)||void 0===t?void 0:t[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){var n;return`"${e.replace(/%\d*/g,e=>{let t=parseInt(e.substring(1),10)-1;return`"counter(${this.numberingCounter(r,t)}, ${a})"`})}${null!==(n={tab:"\\9",space:"\\a0"}[t])&&void 0!==n?n:""}"`}numFormatToCssValue(e){var t;return null!==(t={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])&&void 0!==t?t: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)Ke(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(et.html,e,t,r)}createMathMLElement(e,t,r){return this.createElementNS(et.mathML,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(et.svg,e,t,r)}later(e){this.postRenderTasks.push(e)}};function nt(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 u=r,d=e;function m(){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)),d.after(t),d=t,h.push(t),u=a}const p=()=>u.scrollHeight<=l+1,f=()=>u.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(u.appendChild(e),p())continue;const r=st(e,f(),t);"allfit"!==r&&(r||r?(g.splice(b+1,0,r),m()):(e.remove(),0!==u.childElementCount?(m(),b--):u.appendChild(e)))}if(c.length>0&&h.length>1){const e=d.querySelector(":scope > footer");for(const t of c)d.insertBefore(t,e)}return h.length<=1?0:h.length}function st(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 lt={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:tt};function ot(e,t){const r={...lt,...t};return Ae.load(e,new Ge(r),r)}async function it(e,t){const r={...lt,...t};return await(new at).render(e,r)}e.defaultOptions=lt,e.parseAsync=ot,e.renderAsync=async function(e,t,r,a){var n,s,l;const o=await ot(e,a),i=await it(o,a),c={...lt,...a};null!==(n=r)&&void 0!==n||(r=t),r.innerHTML="",t.innerHTML="",(null===(s=c.fonts)||void 0===s?void 0:s.length)&&i.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}(c.fonts));for(let u of i)("STYLE"===u.nodeName?r:t).appendChild(u);const h="undefined"!=typeof document?document.fonts:null;if((null===(l=c.fonts)||void 0===l?void 0:l.length)&&(null==h?void 0:h.load))try{await Promise.all(c.fonts.map(e=>{var t,r;return h.load(`${null!==(t=e.style)&&void 0!==t?t:"normal"} ${null!==(r=e.weight)&&void 0!==r?r:"normal"} 12px "${e.name.replace(/["\\\r\n]/g,"")}"`)}))}catch{}if(c.paginate){if(null==h?void 0:h.ready)try{await h.ready}catch{}!function(e,t){const r=Array.from(e.querySelectorAll(`section.${t}`));let a=0;for(const n of r)a+=nt(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,c.className)}return o},e.renderDocument=it});
8
+ //# sourceMappingURL=docx-preview.min.js.map