PageSourceSearch

https://devg-01-curivio.hf.space/assets/docx-preview-6cfT7j1D.js

js devg-01-curivio.hf.space collected 2026-10-04 16:48:21 UTC 76,521 bytes, 27 lines download raw bytes

1import{J as fe}from"./jszip.min-D8XRrMuL.js";import"./vendor-C8itMhPO.js";/*
2 * @license
3 * docx-preview <https://github.com/VolodymyrBaydalka/docxjs>
4 * Released under Apache License 2.0  <https://github.com/VolodymyrBaydalka/docxjs/blob/master/LICENSE>
5 * Copyright Volodymyr Baydalka
6 */var g;(function(a){a.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",a.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",a.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",a.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",a.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",a.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",a.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",a.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",a.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",a.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",a.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",a.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",a.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",a.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",a.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",a.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",a.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",a.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",a.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",a.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"})(g||(g={}));function ge(a,e){return e.elements(a).map(t=>({id:e.attr(t,"Id"),type:e.attr(t,"Type"),target:e.attr(t,"Target"),targetMode:e.attr(t,"TargetMode")}))}function be(a){return a?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}function _(a){return/^[^"'].*\s.*[^"']$/.test(a)?`'${a}'`:a}function L(a){let e=a.lastIndexOf("/")+1,t=e==0?"":a.substring(0,e),r=e==0?a:a.substring(e);return[t,r]}function O(a,e){try{const t="http://docx/";return new URL(a,t+e).toString().substring(t.length)}catch{return`${e}${a}`}}function S(a,e){return a.reduce((t,r)=>(t[e(r)]=r,t),{})}function ke(a){return new Promise((e,t)=>{const r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=()=>t(),r.readAsDataURL(a)})}function I(a){return a&&typeof a=="object"&&!Array.isArray(a)}function z(a){return typeof a=="string"||a instanceof String}function H(a,...e){if(!e.length)return a;const t=e.shift();if(I(a)&&I(t))for(const r in t)if(I(t[r])){const s=a[r]??(a[r]={});H(s,t[r])}else a[r]=t[r];return H(a,...e)}function A(a){return Array.isArray(a)?a:[a]}function ve(a,e,t){return e>a?e:t<a?t:a}const ee={wordml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},b={Dxa:{mul:.05,unit:"pt"},Emu:{mul:1/12700,unit:"pt"},FontSize:{mul:.5,unit:"pt"},Border:{mul:.125,unit:"pt",min:.25,max:12},Point:{mul:1,unit:"pt"},Percent:{mul:.02,unit:"%"}};function te(a,e=b.Dxa){if(a==null||/.+(p[xt]|[%])$/.test(a))return a;var t=parseInt(a)*e.mul;return e.min&&e.max&&(t=ve(t,e.min,e.max)),`${t.toFixed(2)}${e.unit}`}function ye(a,e=!1){switch(a){case"1":return!0;case"0":return!1;case"on":return!0;case"off":return!1;case"true":return!0;case"false":return!1;default:return e}}function re(a,e,t){if(a.namespaceURI!=ee.wordml)return!1;switch(a.localName){case"color":e.color=t.attr(a,"val");break;case"sz":e.fontSize=t.lengthAttr(a,"val",b.FontSize);break;default:return!1}return!0}function Pe(a,e=!1){e&&(a=a.replace(/<[?].*[?]>/,"")),a=Se(a);const t=new DOMParser().parseFromString(a,"application/xml"),r=we(t);if(r)throw new Error(r);return t}function we(a){return a.getElementsByTagName("parsererror")[0]?.textContent}function Se(a){return a.charCodeAt(0)===65279?a.substring(1):a}function Me(a){return new XMLSerializer().serializeToString(a)}class ae{elements(e,t=null){const r=[];for(let s=0,n=e.childNodes.length;s<n;s++){let l=e.childNodes.item(s);l.nodeType==Node.ELEMENT_NODE&&(t==null||l.localName==t)&&r.push(l)}return r}element(e,t){for(let r=0,s=e.childNodes.length;r<s;r++){let n=e.childNodes.item(r);if(n.nodeType==1&&n.localName==t)return n}return null}
6elementAttr(e,t,r){var s=this.element(e,t);return s?this.attr(s,r):void 0}attrs(e){return Array.from(e.attributes)}attr(e,t){for(let r=0,s=e.attributes.length;r<s;r++){let n=e.attributes.item(r);if(n.localName==t)return n.value}return null}intAttr(e,t,r=null){var s=this.attr(e,t);return s?parseInt(s):r}hexAttr(e,t,r=null){var s=this.attr(e,t);return s?parseInt(s,16):r}floatAttr(e,t,r=null){var s=this.attr(e,t);return s?parseFloat(s):r}boolAttr(e,t,r=null){return ye(this.attr(e,t),r)}lengthAttr(e,t,r=b.Dxa){return te(this.attr(e,t),r)}}const i=new ae;class v{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(){this._package.update(this.path,Me(this._xmlDocument))}parseXml(e){}}const Ne={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function Ce(a,e){return e.elements(a).map(t=>Ae(t,e))}function Ae(a,e){let t={name:e.attr(a,"name"),embedFontRefs:[]};for(let r of e.elements(a))switch(r.localName){case"family":t.family=e.attr(r,"val");break;case"altName":t.altName=e.attr(r,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":t.embedFontRefs.push(Ee(r,e));break}return t}function Ee(a,e){return{id:e.attr(a,"id"),key:e.attr(a,"fontKey"),type:Ne[a.localName]}}class xe extends v{parseXml(e){this.fonts=Ce(e,this._package.xmlParser)}}function Be(a,e){return e.elements(a).map(t=>({extension:e.attr(t,"Extension"),partName:e.attr(t,"PartName"),contentType:e.attr(t,"ContentType")}))}class j{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new ae}get(e){const t=Re(e);return this._zip.files[t]??this._zip.files[t.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static async load(e,t){const r=await fe.loadAsync(e);return new j(r,t)}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(e!=null){const[s,n]=L(e);t=`${s}_rels/${n}.rels`}const r=await this.load(t);return r?ge(this.parseXmlDocument(r).firstElementChild,this.xmlParser):null}async loadContentTypes(){const e=await this.load("[Content_Types].xml");return e?Be(this.parseXmlDocument(e).firstElementChild,this.xmlParser):[]}parseXmlDocument(e){return Pe(e,this.options.trimXmlDeclaration)}}function Re(a){return a.startsWith("/")?a.substr(1):a}class Te extends v{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}}function F(a,e){return{type:e.attr(a,"val"),color:e.attr(a,"color"),size:e.lengthAttr(a,"sz",b.Border),offset:e.lengthAttr(a,"space",b.Point),frame:e.boolAttr(a,"frame"),shadow:e.boolAttr(a,"shadow")}}function Fe(a,e){var t={};for(let r of e.elements(a))switch(r.localName){case"left":t.left=F(r,e);break;case"top":t.top=F(r,e);break;case"right":t.right=F(r,e);break;case"bottom":t.bottom=F(r,e);break}return t}var G;(function(a){a.Continuous="continuous",a.NextPage="nextPage",a.NextColumn="nextColumn",a.EvenPage="evenPage",a.OddPage="oddPage"})(G||(G={}));function se(a,e=i){var t={};for(let r of e.elements(a))switch(r.localName){case"pgSz":t.pageSize={width:e.lengthAttr(r,"w"),height:e.lengthAttr(r,"h"),orientation:e.attr(r,"orient")};break;case"type":t.type=e.attr(r,"val");break;case"pgMar":t.pageMargins={left:e.lengthAttr(r,"left"),right:e.lengthAttr(r,"right"),top:e.lengthAttr(r,"top"),bottom:e.lengthAttr(r,"bottom"),header:e.lengthAttr(r,"header"),footer:e.lengthAttr(r,"footer"),gutter:e.lengthAttr(r,"gutter")};break;case"cols":t.columns=Le(r,e);break;case"headerReference":(t.headerRefs??(t.headerRefs=[])).push(U(r,e));break;case"footerReference":(t.footerRefs??(t.footerRefs=[])).push(U(r,e));break;case"titlePg":t.titlePage=e.boolAttr(r,"val",!0);break;case"pgBorders":t.pageBorders=Fe(r,e);break;case"pgNumType":t.pageNumber=$e(r,e);break}return t}function Le(a,e){return{numberOfColumns:e.intAttr(a,"num"),space:e.lengthAttr(a,"space"),separator:e.boolAttr(a,"sep"),equalWidth:e.boolAttr(a,"equalWidth",!0),columns:e.elements(a,"col").map(t=>({width:e.lengthAttr(t,"w"),space:e.lengthAttr(t,"space")}))}}function $e(a,e){return{chapSep:e.attr(a,"chapSep"),chapStyle:e.attr(a,"chapStyle"),format:e.attr(a,"fmt"),start:e.intAttr(a,"start")}}function U(a,e){return{id:e.attr(a,"id"),type:e.attr(a,"type")}}function He(a,e){return{before:e.lengthAttr(a,"before"),after:e.lengthAttr(a,"after"),line:e.intAttr(a,"line"),lineRule:e.attr(a,"lineRule")}}function V(a,e){let t={};for(let r of e.elements(a))De(r,t,e);return t}function De(a,e,t){return!!re(a,e,t)}function ne(a,e){let t={};for(let r of e.elements(a))ie(r,t,e);return t}function ie(a,e,t){if(a.namespaceURI!=ee.wordml)return!1;if(re(a,e,t))return!0;switch(a.localName){case"tabs":e.tabs=Oe(a,t);break;case"sectPr":e.sectionProps=se(a,t);break;case"numPr":e.numbering=Ie(a,t);break;case"spacing":return e.lineSpacing=He(a,t),!1;case"textAlignment":return e.textAlignment=t.attr(a,"val"),!1;case"keepLines":e.keepLines=t.boolAttr(a,"val",!0);break;case"keepNext":e.keepNext=t.boolAttr(a,"val",!0);break;case"pageBreakBefore":e.pageBreakBefore=t.boolAttr(a,"val",!0);break;case"outlineLvl":e.outlineLevel=t.intAttr(a,"val");break;case"pStyle":e.styleName=t.attr(a,"val");break;case"rPr":e.runProps=V(a,t);break;default:return!1}return!0}function Oe(a,e){return e.elements(a,"tab").map(t=>({position:e.lengthAttr(t,"pos"),leader:e.attr(t,"leader"),style:e.attr(t,"val")}))}function Ie(a,e){var t={};for(let r of e.elements(a))switch(r.localName){case"numId":t.id=e.attr(r,"val");break;case"ilvl":t.level=e.intAttr(r,"val");break}return t}function _e(a,e){let t={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let r of e.elements(a))switch(r.localName){case"num":t.numberings.push(ze(r,e));break;case"abstractNum":t.abstractNumberings.push(je(r,e));break;case"numPicBullet":t.bulletPictures.push(We(r,e));break}return t}function ze(a,e){let t={id:e.attr(a,"numId"),overrides:[]};for(let r of e.elements(a))switch(r.localName){case"abstractNumId":t.abstractId=e.attr(r,"val");break;case"lvlOverride":t.overrides.push(Ve(r,e));break}return t}function je(a,e){let t={id:e.attr(a,"abstractNumId"),levels:[]};for(let r of e.elements(a))switch(r.localName){case"name":t.name=e.attr(r,"val");break;case"multiLevelType":t.multiLevelType=e.attr(r,"val");break;case"numStyleLink":t.numberingStyleLink=e.attr(r,"val");break;case"styleLink":t.styleLink=e.attr(r,"val");break;case"lvl":t.levels.push(oe(r,e));break}return t}function oe(a,e){let t={level:e.intAttr(a,"ilvl")};for(let r of e.elements(a))switch(r.localName){case"start":t.start=e.attr(r,"val");break;case"lvlRestart":t.restart=e.intAttr(r,"val");break;case"numFmt":t.format=e.attr(r,"val");break;case"lvlText":t.text=e.attr(r,"val");break;case"lvlJc":t.justification=e.attr(r,"val");break;case"lvlPicBulletId":t.bulletPictureId=e.attr(r,"val");break;case"pStyle":t.paragraphStyle=e.attr(r,"val");break;case"pPr":t.paragraphProps=ne(r,e);break;case"rPr":t.runProps=V(r,e);break}return t}function Ve(a,e){let t={level:e.intAttr(a,"ilvl")};for(let r of e.elements(a))switch(r.localName){case"startOverride":t.start=e.intAttr(r,"val");break;case"lvl":t.numberingLevel=oe(r,e);break}return t}function We(a,e){var t=e.element(a,"pict"),r=t&&e.element(t,"shape"),s=r&&e.element(r,"imagedata");return s?{id:e.attr(a,"numPicBulletId"),referenceId:e.attr(s,"id"),style:e.attr(r,"style")}:null}class Xe extends v{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){Object.assign(this,_e(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}}class Ge extends v{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}}var o;(function(a){a.Document="document",a.Paragraph="paragraph",a.Run="run",a.Break="break",a.NoBreakHyphen="noBreakHyphen",a.Table="table",a.Row="row",a.Cell="cell",a.Hyperlink="hyperlink",a.SmartTag="smartTag",a.Drawing="drawing",a.Image="image",a.Text="text",a.Tab="tab",a.Symbol="symbol",a.BookmarkStart="bookmarkStart",a.BookmarkEnd="bookmarkEnd",a.Footer="footer",a.Header="header",a.FootnoteReference="footnoteReference",a.EndnoteReference="endnoteReference",a.Footnote="footnote",a.Endnote="endnote",a.SimpleField="simpleField",a.ComplexField="complexField",a.Instruction="instruction",a.VmlPicture="vmlPicture",a.MmlMath="mmlMath",a.MmlMathParagraph="mmlMathParagraph",a.MmlFraction="mmlFraction",a.MmlFunction="mmlFunction",a.MmlFunctionName="mmlFunctionName",a.MmlNumerator="mmlNumerator",a.MmlDenominator="mmlDenominator",a.MmlRadical="mmlRadical",a.MmlBase="mmlBase",a.MmlDegree="mmlDegree",a.MmlSuperscript="mmlSuperscript",a.MmlSubscript="mmlSubscript",a.MmlPreSubSuper="mmlPreSubSuper",a.MmlSubArgument="mmlSubArgument",a.MmlSuperArgument="mmlSuperArgument",a.MmlNary="mmlNary",a.MmlDelimiter="mmlDelimiter",a.MmlRun="mmlRun",a.MmlEquationArray="mmlEquationArray",a.MmlLimit="mmlLimit",a.MmlLimitLower="mmlLimitLower",a.MmlMatrix="mmlMatrix",a.MmlMatrixRow="mmlMatrixRow",a.MmlBox="mmlBox",a.MmlBar="mmlBar",a.MmlGroupChar="mmlGroupChar",a.VmlElement="vmlElement",a.Inserted="inserted",a.Deleted="deleted",a.DeletedText="deletedText",a.Comment="comment",a.CommentReference="commentReference",a.CommentRangeStart="commentRangeStart",a.CommentRangeEnd="commentRangeEnd",a.AltChunk="altChunk"})(o||(o={}));class M{constructor(){this.children=[],this.cssStyle={}}}class Ue extends M{constructor(){super(...arguments),this.type=o.Header}}class qe extends M{constructor(){super(...arguments),this.type=o.Footer}}class le extends v{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(e)}}class Je extends le{createRootElement(){return new Ue}}class Ye extends le{createRootElement(){return new qe}}function Ze(a,e){const t={};for(let r of e.elements(a))switch(r.localName){case"Template":t.template=r.textContent;break;case"Pages":t.pages=E(r.textContent);break;case"Words":t.words=E(r.textContent);break;case"Characters":t.characters=E(r.textContent);break;case"Application":t.application=r.textContent;break;case"Lines":t.lines=E(r.textContent);break;case"Paragraphs":t.paragraphs=E(r.textContent);break;case"Company":t.company=r.textContent;break;case"AppVersion":t.appVersion=r.textContent;break}return t}function E(a){if(!(typeof a>"u"))return parseInt(a)}class Ke extends v{parseXml(e){this.props=Ze(e,this._package.xmlParser)}}function Qe(a,e){const t={};for(let r of e.elements(a))switch(r.localName){case"title":t.title=r.textContent;break;
vendor: 13,156 bytes, line 6
6case"description":t.description=r.textContent;break;case"subject":t.subject=r.textContent;break;case"creator":t.creator=r.textContent;break;case"keywords":t.keywords=r.textContent;break;case"language":t.language=r.textContent;break;case"lastModifiedBy":t.lastModifiedBy=r.textContent;break;case"revision":r.textContent&&(t.revision=parseInt(r.textContent));break}return t}class et extends v{parseXml(e){this.props=Qe(e,this._package.xmlParser)}}class tt{}function rt(a,e){var t=new tt,r=e.element(a,"themeElements");for(let s of e.elements(r))switch(s.localName){case"clrScheme":t.colorScheme=at(s,e);break;case"fontScheme":t.fontScheme=st(s,e);break}return t}function at(a,e){var t={name:e.attr(a,"name"),colors:{}};for(let n of e.elements(a)){var r=e.element(n,"srgbClr"),s=e.element(n,"sysClr");r?t.colors[n.localName]=e.attr(r,"val"):s&&(t.colors[n.localName]=e.attr(s,"lastClr"))}return t}function st(a,e){var t={name:e.attr(a,"name")};for(let r of e.elements(a))switch(r.localName){case"majorFont":t.majorFont=q(r,e);break;case"minorFont":t.minorFont=q(r,e);break}return t}function q(a,e){return{latinTypeface:e.elementAttr(a,"latin","typeface"),eaTypeface:e.elementAttr(a,"ea","typeface"),csTypeface:e.elementAttr(a,"cs","typeface")}}class nt extends v{constructor(e,t){super(e,t)}parseXml(e){this.theme=rt(e,this._package.xmlParser)}}class ce{}class it extends ce{constructor(){super(...arguments),this.type=o.Footnote}}class ot extends ce{constructor(){super(...arguments),this.type=o.Endnote}}class he extends v{constructor(e,t,r){super(e,t),this._documentParser=r}}class lt extends he{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"footnote",it)}}class ct extends he{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"endnote",ot)}}function ht(a,e){var t={};for(let r of e.elements(a))switch(r.localName){case"defaultTabStop":t.defaultTabStop=e.lengthAttr(r,"val");break;case"footnotePr":t.footnoteProps=J(r,e);break;case"endnotePr":t.endnoteProps=J(r,e);break;case"autoHyphenation":t.autoHyphenation=e.boolAttr(r,"val");break;case"evenAndOddHeaders":t.evenAndOddHeaders=e.boolAttr(r,"val",!0);break}return t}function J(a,e){var t={defaultNoteIds:[]};for(let r of e.elements(a))switch(r.localName){case"numFmt":t.nummeringFormat=e.attr(r,"val");break;case"footnote":case"endnote":t.defaultNoteIds.push(e.attr(r,"id"));break}return t}class ut extends v{constructor(e,t){super(e,t)}parseXml(e){this.settings=ht(e,this._package.xmlParser)}}function dt(a,e){return e.elements(a,"property").map(t=>{const r=t.firstChild;return{formatId:e.attr(t,"fmtid"),name:e.attr(t,"name"),type:r.nodeName,value:r.textContent}})}class pt extends v{parseXml(e){this.props=dt(e,this._package.xmlParser)}}class mt extends v{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=S(this.comments,t=>t.id)}}class ft extends v{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,r=>r.paraId)}}const gt=[{type:g.OfficeDocument,target:"word/document.xml"},{type:g.ExtendedProperties,target:"docProps/app.xml"},{type:g.CoreProperties,target:"docProps/core.xml"},{type:g.CustomProperties,target:"docProps/custom.xml"}];class W{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[]}static async load(e,t,r){var s=new W;return s._options=r,s._parser=t,s._package=await j.load(e,r),s.rels=await s._package.loadRelationships(),s.contentTypes=await s._package.loadContentTypes(),await Promise.all(gt.map(n=>{const l=s.rels.find(h=>h.type===n.type)??n;return s.loadRelationshipPart(l.target,l.type)})),s}save(e="blob"){return this._package.save(e)}async loadRelationshipPart(e,t){if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let r=null;switch(t){case g.OfficeDocument:this.documentPart=r=new Te(this._package,e,this._parser);break;case g.FontTable:this.fontTablePart=r=new xe(this._package,e);break;case g.Numbering:this.numberingPart=r=new Xe(this._package,e,this._parser);break;case g.Styles:this.stylesPart=r=new Ge(this._package,e,this._parser);break;case g.Theme:this.themePart=r=new nt(this._package,e);break;case g.Footnotes:this.footnotesPart=r=new lt(this._package,e,this._parser);break;case g.Endnotes:this.endnotesPart=r=new ct(this._package,e,this._parser);break;case g.Footer:r=new Ye(this._package,e,this._parser);break;case g.Header:r=new Je(this._package,e,this._parser);break;case g.CoreProperties:this.corePropsPart=r=new et(this._package,e);break;case g.ExtendedProperties:this.extendedPropsPart=r=new Ke(this._package,e);break;case g.CustomProperties:r=new pt(this._package,e);break;case g.Settings:this.settingsPart=r=new ut(this._package,e);break;case g.Comments:this.commentsPart=r=new mt(this._package,e,this._parser);break;case g.CommentsExtended:this.commentsExtendedPart=r=new ft(this._package,e);break}if(r==null)return Promise.resolve(null);if(this.partsMap[e]=r,this.parts.push(r),await r.load(),r.rels?.length>0){const[s]=L(r.path);await Promise.all(r.rels.map(n=>this.loadRelationshipPart(O(n.target,s),n.type)))}return r}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 s=await this._package.load(r,"uint8array");return s&&this.blobToURL(new Blob([bt(s,t)]),r)}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(s=>s.partName===t||s.extension&&t.endsWith(`.${s.extension}`));e=r?new Blob([e],{type:r.contentType}):e}return this._options.useBase64URL?ke(e):URL.createObjectURL(e)}findPartByRelId(e,t=null){var r=(t.rels??this.rels).find(n=>n.id==e);const s=t?L(t.path)[0]:"";return r?this.partsMap[O(r.target,s)]:null}getPathById(e,t){const r=e.rels.find(n=>n.id==t),[s]=L(e.path);return r?O(r.target,s):null}}function bt(a,e){const r=e.replace(/{|}|-/g,""),s=new Array(16);for(let n=0;n<16;n++)s[16-n-1]=parseInt(r.substring(n*2,n*2+2),16);for(let n=0;n<32;n++)a[n]=a[n]^s[n%16];return a}function kt(a,e){return{type:o.BookmarkStart,id:e.attr(a,"id"),name:e.attr(a,"name"),colFirst:e.intAttr(a,"colFirst"),colLast:e.intAttr(a,"colLast")}}function vt(a,e){return{type:o.BookmarkEnd,id:e.attr(a,"id")}}class yt extends M{constructor(){super(...arguments),this.type=o.VmlElement,this.attrs={}}}function ue(a,e){var t=new yt;switch(a.localName){case"rect":t.tagName="rect",Object.assign(t.attrs,{width:"100%",height:"100%"});break;case"oval":t.tagName="ellipse",Object.assign(t.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":t.tagName="line";break;case"shape":t.tagName="g";break;case"textbox":t.tagName="foreignObject",Object.assign(t.attrs,{width:"100%",height:"100%"});break;default:return null}for(const r of i.attrs(a))switch(r.localName){case"style":t.cssStyleText=r.value;break;case"fillcolor":t.attrs.fill=r.value;break;case"from":const[s,n]=Y(r.value);Object.assign(t.attrs,{x1:s,y1:n});break;case"to":const[l,h]=Y(r.value);Object.assign(t.attrs,{x2:l,y2:h});break}for(const r of i.elements(a))switch(r.localName){case"stroke":Object.assign(t.attrs,Pt(r));break;case"fill":Object.assign(t.attrs,wt());break;case"imagedata":t.tagName="image",Object.assign(t.attrs,{width:"100%",height:"100%"}),t.imageHref={id:i.attr(r,"id"),title:i.attr(r,"title")};break;case"txbxContent":t.children.push(...e.parseBodyElements(r));break;default:const s=ue(r,e);s&&t.children.push(s);break}return t}function Pt(a){return{stroke:i.attr(a,"color"),"stroke-width":i.lengthAttr(a,"weight",b.Emu)??"1px"}}function wt(a){return{}}function Y(a){return a.split(",")}class St extends M{constructor(){super(...arguments),this.type=o.Comment}}class Mt extends M{constructor(e){super(),this.id=e,this.type=o.CommentReference}}class Nt extends M{constructor(e){super(),this.id=e,this.type=o.CommentRangeStart}}class Ct extends M{constructor(e){super(),this.id=e,this.type=o.CommentRangeEnd}}var $={shd:"inherit",color:"black",borderColor:"black",highlight:"transparent"};const At=[],Z={oMath:o.MmlMath,oMathPara:o.MmlMathParagraph,f:o.MmlFraction,func:o.MmlFunction,fName:o.MmlFunctionName,num:o.MmlNumerator,den:o.MmlDenominator,rad:o.MmlRadical,deg:o.MmlDegree,e:o.MmlBase,sSup:o.MmlSuperscript,sSub:o.MmlSubscript,sPre:o.MmlPreSubSuper,sup:o.MmlSuperArgument,sub:o.MmlSubArgument,d:o.MmlDelimiter,nary:o.MmlNary,eqArr:o.MmlEquationArray,lim:o.MmlLimit,limLow:o.MmlLimitLower,m:o.MmlMatrix,mr:o.MmlMatrixRow,box:o.MmlBox,bar:o.MmlBar,groupChr:o.MmlGroupChar};class Et{constructor(e){this.options={ignoreWidth:!1,debug:!1,...e}}parseNotes(e,t,r){var s=[];for(let n of i.elements(e,t)){const l=new r;l.id=i.attr(n,"id"),l.noteType=i.attr(n,"type"),l.children=this.parseBodyElements(n),s.push(l)}return s}parseComments(e){var t=[];for(let r of i.elements(e,"comment")){const s=new St;s.id=i.attr(r,"id"),s.author=i.attr(r,"author"),s.initials=i.attr(r,"initials"),s.date=i.attr(r,"date"),s.children=this.parseBodyElements(r),t.push(s)}return t}parseDocumentFile(e){var t=i.element(e,"body"),r=i.element(e,"background"),s=i.element(t,"sectPr");return{type:o.Document,children:this.parseBodyElements(t),props:s?se(s,i):{},cssStyle:r?this.parseBackground(r):{}}}parseBackground(e){var t={},r=N.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){var t=[];for(const r of i.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,s=>this.parseBodyElements(s)));break}return t}parseStylesFile(e){var t=[];for(const r of i.elements(e))switch(r.localName){case"style":t.push(this.parseStyle(r));break;case"docDefaults":t.push(this.parseDefaultStyles(r));break}return t}parseDefaultStyles(e){var t={id:null,name:null,target:null,basedOn:null,styles:[]};for(const n of i.elements(e))switch(n.localName){case"rPrDefault":var r=i.element(n,"rPr");r&&t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})});break;case"pPrDefault":var s=i.element(n,"pPr");s&&t.styles.push({target:"p",values:this.parseDefaultProperties(s,{})});break}return t}parseStyle(e){var t={id:i.attr(e,"styleId"),isDefault:i.boolAttr(e,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(i.attr(e,"type")){case"paragraph":t.target="p";break;case"table":t.target="table";break;case"character":t.target="span";break}for(const r of i.elements(e))switch(r.localName){case"basedOn":t.basedOn=i.attr(r,"val");break;case"name":t.name=i.attr(r,"val");break;case"link":t.linked=i.attr(r,"val");break;case"next":t.next=i.attr(r,"val");break;case"aliases":t.aliases=i.attr(r,"val").split(",");break;case"pPr":t.styles.push({target:"p",values:this.parseDefaultProperties(r,{})}),t.paragraphProps=ne(r,i);break;case"rPr":t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})}),t.runProps=V(r,i);break;case"tblPr":case"tcPr":t.styles.push({target:"td",values:this.parseDefaultProperties(r,{})});break;case"tblStylePr":for(let s of this.parseTableStyle(r))t.styles.push(s);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=i.attr(e,"type"),s="",n="";switch(r){case"firstRow":n=".first-row",s="tr.first-row td";break;case"lastRow":n=".last-row",s="tr.last-row td";break;case"firstCol":n=".first-col",s="td.first-col";break;case"lastCol":n=".last-col",s="td.last-col";break;case"band1Vert":n=":not(.no-vband)",s="td.odd-col";break;case"band2Vert":n=":not(.no-vband)",s="td.even-col";break;case"band1Horz":n=":not(.no-hband)",s="tr.odd-row";break;case"band2Horz":n=":not(.no-hband)",s="tr.even-row";break;default:return[]}for(const l of i.elements(e))switch(l.localName){case"pPr":t.push({target:`${s} p`,mod:n,values:this.parseDefaultProperties(l,{})});break;case"rPr":t.push({target:`${s} span`,mod:n,values:this.parseDefaultProperties(l,{})});break;case"tblPr":case"tcPr":t.push({target:s,mod:n,values:this.parseDefaultProperties(l,{})});break}return t}parseNumberingFile(e){const t=[],r=[],s=[];for(const n of i.elements(e))switch(n.localName){case"abstractNum":t.push(...this.parseAbstractNumbering(n,s));break;case"numPicBullet":s.push(this.parseNumberingPicBullet(n));break;case"num":r.push({numId:i.attr(n,"numId"),abstractNumId:i.elementAttr(n,"abstractNumId","val")});break}return r.flatMap(n=>t.filter(l=>n.abstractNumId==l.id).map(l=>({...l,id:n.numId})))}
6parseNumberingPicBullet(e){var t=i.element(e,"pict"),r=t&&i.element(t,"shape"),s=r&&i.element(r,"imagedata");return s?{id:i.intAttr(e,"numPicBulletId"),src:i.attr(s,"id"),style:i.attr(r,"style")}:null}parseAbstractNumbering(e,t){var r=[],s=i.attr(e,"abstractNumId");for(const n of i.elements(e))switch(n.localName){case"lvl":r.push(this.parseNumberingLevel(s,n,t));break}return r}parseNumberingLevel(e,t,r){var s={id:e,level:i.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const l of i.elements(t))switch(l.localName){case"start":s.start=i.intAttr(l,"val");break;case"pPr":this.parseDefaultProperties(l,s.pStyle);break;case"rPr":this.parseDefaultProperties(l,s.rStyle);break;case"lvlPicBulletId":var n=i.intAttr(l,"val");s.bullet=r.find(h=>h?.id==n);break;case"lvlText":s.levelText=i.attr(l,"val");break;case"pStyle":s.pStyleName=i.attr(l,"val");break;case"numFmt":s.format=i.attr(l,"val");break;case"suff":s.suff=i.attr(l,"val");break}return s}parseSdt(e,t){const r=i.element(e,"sdtContent");return r?t(r):[]}parseChange(e,t,r){return{type:e,children:r(t)?.children??[],id:i.attr(t,"id"),author:i.attr(t,"author"),date:i.attr(t,"date")}}parseAltChunk(e){return{type:o.AltChunk,children:[],id:i.attr(e,"id")}}parseParagraph(e){var t={type:o.Paragraph,children:[]};for(let r of i.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(kt(r,i));break;case"bookmarkEnd":t.children.push(vt(r,i));break;case"commentRangeStart":t.children.push(new Nt(i.attr(r,"id")));break;case"commentRangeEnd":t.children.push(new Ct(i.attr(r,"id")));break;case"oMath":case"oMathPara":t.children.push(this.parseMathElement(r));break;case"sdt":t.children.push(...this.parseSdt(r,s=>this.parseParagraph(s).children));break;case"ins":t.children.push(this.parseChange(o.Inserted,r,s=>this.parseParagraph(s)));break;case"del":t.children.push(this.parseChange(o.Deleted,r,s=>this.parseParagraph(s)));break}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,r=>{if(ie(r,t,i))return!0;switch(r.localName){case"pStyle":t.styleName=i.attr(r,"val");break;case"cnfStyle":t.className=f.classNameOfCnfStyle(r);break;case"framePr":this.parseFrame(r,t);break;case"rPr":break;default:return!1}return!0})}parseFrame(e,t){var r=i.attr(e,"dropCap");r=="drop"&&(t.cssStyle.float="left")}parseHyperlink(e,t){var r={type:o.Hyperlink,parent:t,children:[]};r.anchor=i.attr(e,"anchor"),r.id=i.attr(e,"id");for(const s of i.elements(e))switch(s.localName){case"r":r.children.push(this.parseRun(s,r));break}return r}parseSmartTag(e,t){var r={type:o.SmartTag,parent:t,children:[]},s=i.attr(e,"uri"),n=i.attr(e,"element");s&&(r.uri=s),n&&(r.element=n);for(const l of i.elements(e))switch(l.localName){case"r":r.children.push(this.parseRun(l,r));break;case"smartTag":r.children.push(this.parseSmartTag(l,r));break}return r}parseRun(e,t){var r={type:o.Run,parent:t,children:[]};for(let s of i.elements(e))switch(s=this.checkAlternateContent(s),s?.localName){case"t":r.children.push({type:o.Text,text:s.textContent});break;case"delText":r.children.push({type:o.DeletedText,text:s.textContent});break;case"commentReference":r.children.push(new Mt(i.attr(s,"id")));break;case"fldSimple":r.children.push({type:o.SimpleField,instruction:i.attr(s,"instr"),lock:i.boolAttr(s,"lock",!1),dirty:i.boolAttr(s,"dirty",!1)});break;case"instrText":r.fieldRun=!0,r.children.push({type:o.Instruction,text:s.textContent});break;case"fldChar":r.fieldRun=!0,r.children.push({type:o.ComplexField,charType:i.attr(s,"fldCharType"),lock:i.boolAttr(s,"lock",!1),dirty:i.boolAttr(s,"dirty",!1)});break;case"noBreakHyphen":r.children.push({type:o.NoBreakHyphen});break;case"br":r.children.push({type:o.Break,break:i.attr(s,"type")||"textWrapping"});break;case"lastRenderedPageBreak":r.children.push({type:o.Break,break:"lastRenderedPageBreak"});break;case"sym":r.children.push({type:o.Symbol,font:_(i.attr(s,"font")),char:i.hexAttr(s,"char")});break;case"tab":r.children.push({type:o.Tab});break;case"footnoteReference":r.children.push({type:o.FootnoteReference,id:i.attr(s,"id")});break;case"endnoteReference":r.children.push({type:o.EndnoteReference,id:i.attr(s,"id")});break;case"drawing":let n=this.parseDrawing(s);n&&r.children.push(n);break;case"pict":r.children.push(this.parseVmlPicture(s));break;case"rPr":this.parseRunProperties(s,r);break}return r}parseMathElement(e){const t=`${e.localName}Pr`,r={type:Z[e.localName],children:[]};for(const n of i.elements(e))if(Z[n.localName])r.children.push(this.parseMathElement(n));else if(n.localName=="r"){var s=this.parseRun(n);s.type=o.MmlRun,r.children.push(s)}else n.localName==t&&(r.props=this.parseMathProperies(n));return r}parseMathProperies(e){const t={};for(const r of i.elements(e))switch(r.localName){case"chr":t.char=i.attr(r,"val");break;case"vertJc":t.verticalJustification=i.attr(r,"val");break;case"pos":t.position=i.attr(r,"val");break;case"degHide":t.hideDegree=i.boolAttr(r,"val");break;case"begChr":t.beginChar=i.attr(r,"val");break;case"endChr":t.endChar=i.attr(r,"val");break}return t}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,r=>{switch(r.localName){case"rStyle":t.styleName=i.attr(r,"val");break;case"vertAlign":t.verticalAlign=f.valueOfVertAlign(r,!0);break;default:return!1}return!0})}parseVmlPicture(e){const t={type:o.VmlPicture,children:[]};
6for(const r of i.elements(e)){const s=ue(r,this);s&&t.children.push(s)}return t}checkAlternateContent(e){if(e.localName!="AlternateContent")return e;var t=i.element(e,"Choice");if(t){var r=i.attr(t,"Requires"),s=e.lookupNamespaceURI(r);if(At.includes(s))return t.firstElementChild}return i.element(e,"Fallback")?.firstElementChild}parseDrawing(e){for(var t of i.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t)}}parseDrawingWrapper(e){var t={type:o.Drawing,children:[],cssStyle:{}},r=e.localName=="anchor";let s=null,n=i.boolAttr(e,"simplePos");i.boolAttr(e,"behindDoc");let l={relative:"page",align:"left",offset:"0"},h={relative:"page",align:"top",offset:"0"};for(var c of i.elements(e))switch(c.localName){case"simplePos":n&&(l.offset=i.lengthAttr(c,"x",b.Emu),h.offset=i.lengthAttr(c,"y",b.Emu));break;case"extent":t.cssStyle.width=i.lengthAttr(c,"cx",b.Emu),t.cssStyle.height=i.lengthAttr(c,"cy",b.Emu);break;case"positionH":case"positionV":if(!n){let m=c.localName=="positionH"?l:h;var u=i.element(c,"align"),k=i.element(c,"posOffset");m.relative=i.attr(c,"relativeFrom")??m.relative,u&&(m.align=u.textContent),k&&(m.offset=te(k.textContent,b.Emu))}break;case"wrapTopAndBottom":s="wrapTopAndBottom";break;case"wrapNone":s="wrapNone";break;case"graphic":var p=this.parseGraphic(c);p&&t.children.push(p);break}return s=="wrapTopAndBottom"?(t.cssStyle.display="block",l.align&&(t.cssStyle["text-align"]=l.align,t.cssStyle.width="100%")):s=="wrapNone"?(t.cssStyle.display="block",t.cssStyle.position="relative",t.cssStyle.width="0px",t.cssStyle.height="0px",l.offset&&(t.cssStyle.left=l.offset),h.offset&&(t.cssStyle.top=h.offset)):r&&(l.align=="left"||l.align=="right")&&(t.cssStyle.float=l.align),t}parseGraphic(e){var t=i.element(e,"graphicData");for(let r of i.elements(t))switch(r.localName){case"pic":return this.parsePicture(r)}return null}parsePicture(e){var t={type:o.Image,src:"",cssStyle:{}},r=i.element(e,"blipFill"),s=i.element(r,"blip"),n=i.element(r,"srcRect");t.src=i.attr(s,"embed"),n&&(t.srcRect=[i.intAttr(n,"l",0)/1e5,i.intAttr(n,"t",0)/1e5,i.intAttr(n,"r",0)/1e5,i.intAttr(n,"b",0)/1e5]);var l=i.element(e,"spPr"),h=i.element(l,"xfrm");if(t.cssStyle.position="relative",h){t.rotation=i.intAttr(h,"rot",0)/6e4;for(var c of i.elements(h))switch(c.localName){case"ext":t.cssStyle.width=i.lengthAttr(c,"cx",b.Emu),t.cssStyle.height=i.lengthAttr(c,"cy",b.Emu);break;case"off":t.cssStyle.left=i.lengthAttr(c,"x",b.Emu),t.cssStyle.top=i.lengthAttr(c,"y",b.Emu);break}}return t}parseTable(e){var t={type:o.Table,children:[]};for(const r of i.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);break}return t}parseTableColumns(e){var t=[];for(const r of i.elements(e))switch(r.localName){case"gridCol":t.push({width:i.lengthAttr(r,"w")});break}return t}parseTableProperties(e,t){switch(t.cssStyle={},t.cellStyle={},this.parseDefaultProperties(e,t.cssStyle,t.cellStyle,r=>{switch(r.localName){case"tblStyle":t.styleName=i.attr(r,"val");break;case"tblLook":t.className=f.classNameOftblLook(r);break;case"tblpPr":this.parseTablePosition(r,t);break;case"tblStyleColBandSize":t.colBandSize=i.intAttr(r,"val");break;case"tblStyleRowBandSize":t.rowBandSize=i.intAttr(r,"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";break}}parseTablePosition(e,t){var r=i.lengthAttr(e,"topFromText"),s=i.lengthAttr(e,"bottomFromText"),n=i.lengthAttr(e,"rightFromText"),l=i.lengthAttr(e,"leftFromText");t.cssStyle.float="left",t.cssStyle["margin-bottom"]=f.addSize(t.cssStyle["margin-bottom"],s),t.cssStyle["margin-left"]=f.addSize(t.cssStyle["margin-left"],l),t.cssStyle["margin-right"]=f.addSize(t.cssStyle["margin-right"],n),t.cssStyle["margin-top"]=f.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){var t={type:o.Row,children:[]};for(const r of i.elements(e))switch(r.localName){case"tc":t.children.push(this.parseTableCell(r));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(r,t);break}return t}parseTableRowProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,r=>{switch(r.localName){case"cnfStyle":t.className=f.classNameOfCnfStyle(r);break;case"tblHeader":t.isHeader=i.boolAttr(r,"val");break;case"gridBefore":t.gridBefore=i.intAttr(r,"val");break;case"gridAfter":t.gridAfter=i.intAttr(r,"val");break;default:return!1}return!0})}parseTableCell(e){var t={type:o.Cell,children:[]};for(const r of i.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);break}return t}parseTableCellProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,r=>{switch(r.localName){case"gridSpan":t.span=i.intAttr(r,"val",null);break;case"vMerge":t.verticalMerge=i.attr(r,"val")??"continue";break;case"cnfStyle":t.className=f.classNameOfCnfStyle(r);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 s of i.elements(e))if(s.localName==="textDirection"){const n=i.attr(s,"val"),l=r[n]||{writingMode:"horizontal-tb"};t.cssStyle["writing-mode"]=l.writingMode,t.cssStyle.transform=l.transform}}parseDefaultProperties(e,t=null,r=null,s=null){t=t||{};for(const n of i.elements(e))if(!s?.(n))switch(n.localName){case"jc":t["text-align"]=f.valueOfJc(n);break;case"textAlignment":t["vertical-align"]=f.valueOfTextAlignment(n);break;case"color":t.color=N.colorAttr(n,"val",null,$.color);break;case"sz":t["font-size"]=t["min-height"]=i.lengthAttr(n,"val",b.FontSize);break;case"shd":t["background-color"]=N.colorAttr(n,"fill",null,$.shd);break;case"highlight":t["background-color"]=N.colorAttr(n,"val",null,$.highlight);break;case"vertAlign":break;case"position":t.verticalAlign=i.lengthAttr(n,"val",b.FontSize);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":t.width=f.valueOfSize(n,"w");break;case"trHeight":this.parseTrHeight(n,t);break;case"strike":t["text-decoration"]=i.boolAttr(n,"val",!0)?"line-through":"none";break;case"b":t["font-weight"]=i.boolAttr(n,"val",!0)?"bold":"normal";break;case"i":t["font-style"]=i.boolAttr(n,"val",!0)?"italic":"normal";break;case"caps":t["text-transform"]=i.boolAttr(n,"val",!0)?"uppercase":"none";break;case"smallCaps":t["font-variant"]=i.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"]=f.valueOfMargin(n),t["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(n,t);break;case"bdr":t.border=f.valueOfBorder(n);break;case"tcBorders":this.parseBorderProperties(n,t);break;case"vanish":i.boolAttr(n,"val",!0)&&(t.display="none");break;case"kern":break;case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(n,r||t);break;case"tblLayout":t["table-layout"]=f.valueOfTblLayout(n);break;case"vAlign":t["vertical-align"]=f.valueOfTextAlignment(n);break;case"spacing":e.localName=="pPr"&&this.parseSpacing(n,t);break;case"wordWrap":i.boolAttr(n,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=i.boolAttr(n,"val",!0)?"none":"auto";break;case"lang":t.$lang=i.attr(n,"val");break;case"rtl":case"bidi":i.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}`);break}return t}parseUnderline(e,t){var r=i.attr(e,"val");if(r!=null){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":t["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":t["text-decoration"]="underline wavy";break;case"words":t["text-decoration"]="underline";break;case"none":t["text-decoration"]="none";break}var s=N.colorAttr(e,"color");s&&(t["text-decoration-color"]=s)}}parseFont(e,t){var r=i.attr(e,"ascii"),s=f.themeValue(e,"asciiTheme"),n=i.attr(e,"eastAsia"),l=[r,s,n].filter(h=>h).map(h=>_(h));l.length>0&&(t["font-family"]=[...new Set(l)].join(", "))}parseIndentation(e,t){var r=i.lengthAttr(e,"firstLine"),s=i.lengthAttr(e,"hanging"),n=i.lengthAttr(e,"left"),l=i.lengthAttr(e,"start"),h=i.lengthAttr(e,"right"),c=i.lengthAttr(e,"end");r&&(t["text-indent"]=r),s&&(t["text-indent"]=`-${s}`),(n||l)&&(t["margin-inline-start"]=n||l),(h||c)&&(t["margin-inline-end"]=h||c)}parseSpacing(e,t){var r=i.lengthAttr(e,"before"),s=i.lengthAttr(e,"after"),n=i.intAttr(e,"line",null),l=i.attr(e,"lineRule");if(r&&(t["margin-top"]=r),s&&(t["margin-bottom"]=s),n!==null)switch(l){case"auto":t["line-height"]=`${(n/240).toFixed(2)}`;break;case"atLeast":t["line-height"]=`calc(100% + ${n/20}pt)`;break;default:t["line-height"]=t["min-height"]=`${n/20}pt`;break}}parseMarginProperties(e,t){for(const r of i.elements(e))switch(r.localName){case"left":t["padding-left"]=f.valueOfMargin(r);break;case"right":t["padding-right"]=f.valueOfMargin(r);break;case"top":t["padding-top"]=f.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=f.valueOfMargin(r);break}}parseTrHeight(e,t){switch(i.attr(e,"hRule")){case"exact":t.height=i.lengthAttr(e,"val");break;case"atLeast":default:t.height=i.lengthAttr(e,"val");break}}parseBorderProperties(e,t){for(const r of i.elements(e))switch(r.localName){case"start":case"left":t["border-left"]=f.valueOfBorder(r);break;case"end":case"right":t["border-right"]=f.valueOfBorder(r);break;case"top":t["border-top"]=f.valueOfBorder(r);break;case"bottom":t["border-bottom"]=f.valueOfBorder(r);break}}}const xt=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class N{static colorAttr(e,t,r=null,s="black"){var n=i.attr(e,t);if(n)return n=="auto"?s:xt.includes(n)?n:`#${n}`;var l=i.attr(e,"themeColor");return l?`var(--docx-${l}-color)`:r}}class f{static themeValue(e,t){var r=i.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){var r=b.Dxa;switch(i.attr(e,"type")){case"dxa":break;case"pct":r=b.Percent;break;case"auto":return"auto"}return i.lengthAttr(e,t,r)}static valueOfMargin(e){return i.lengthAttr(e,"w")}static valueOfBorder(e){var t=f.parseBorderType(i.attr(e,"val"));if(t=="none")return"none";var r=N.colorAttr(e,"color"),s=i.lengthAttr(e,"sz",b.Border);return`${s} ${t} ${r=="auto"?$.borderColor:r}`}static parseBorderType(e){switch(e){case"single":return"solid";case"dashDotStroked":return"solid";case"dashed":return"dashed";case"dashSmallGap":return"dashed";case"dotDash":return"dotted";case"dotDotDash":return"dotted";case"dotted":return"dotted";case"double":return"double";case"doubleWave":return"double";case"inset":return"inset";case"nil":return"none";case"none":return"none";case"outset":return"outset";case"thick":return"solid";case"thickThinLargeGap":return"solid";case"thickThinMediumGap":return"solid";case"thickThinSmallGap":return"solid";case"thinThickLargeGap":return"solid";case"thinThickMediumGap":return"solid";case"thinThickSmallGap":return"solid";case"thinThickThinLargeGap":return"solid";case"thinThickThinMediumGap":return"solid";case"thinThickThinSmallGap":return"solid";case"threeDEmboss":return"solid";case"threeDEngrave":return"solid";case"triple":return"double";case"wave":return"solid"}return"solid"}static valueOfTblLayout(e){var t=i.attr(e,"val");return t=="fixed"?"fixed":"auto"}static classNameOfCnfStyle(e){const t=i.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((n,l)=>t[l]=="1").join(" ");const s=["firstRow","lastRow","firstColumn","lastColumn","oddVBand","evenVBand","oddHBand","evenHBand","firstRowLastColumn","firstRowFirstColumn","lastRowLastColumn","lastRowFirstColumn"];return r.filter((n,l)=>i.boolAttr(e,s[l])).join(" ")}static valueOfJc(e){var t=i.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=i.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfTextAlignment(e){var t=i.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 e==null?t:t==null?e:`calc(${e} + ${t})`}static classNameOftblLook(e){const t=i.hexAttr(e,"val",0);let r="";return(i.boolAttr(e,"firstRow")||t&32)&&(r+=" first-row"),(i.boolAttr(e,"lastRow")||t&64)&&(r+=" last-row"),(i.boolAttr(e,"firstColumn")||t&128)&&(r+=" first-col"),(i.boolAttr(e,"lastColumn")||t&256)&&(r+=" last-col"),(i.boolAttr(e,"noHBand")||t&512)&&(r+=" no-hband"),(i.boolAttr(e,"noVBand")||t&1024)&&(r+=" no-vband"),r.trim()}}const K={pos:0,leader:"none",style:"left"},Bt=50;function Rt(a=document.body){const e=document.createElement("div");e.style.width="100pt",a.appendChild(e);const t=100/e.offsetWidth;return a.removeChild(e),t}function Tt(a,e,t,r=72/96){const s=a.closest("p"),n=a.getBoundingClientRect(),l=s.getBoundingClientRect(),h=getComputedStyle(s),c=e?.length>0?e.map(y=>({pos:Q(y.position),leader:y.leader,style:y.style})).sort((y,R)=>y.pos-R.pos):[K],u=c[c.length-1],k=l.width*r,p=Q(t);let m=u.pos+p;if(m<k)for(;m<k&&c.length<Bt;m+=p)c.push({...K,pos:m});const P=parseFloat(h.marginLeft),B=l.left+P,C=(n.left-B)*r,w=c.find(y=>y.style!="clear"&&y.pos>C);if(w==null)return;let D=1;if(w.style=="right"||w.style=="center"){const y=Array.from(s.querySelectorAll(`.${a.className}`)),R=y.indexOf(a)+1,T=document.createRange();T.setStart(a,1),R<y.length?T.setEndBefore(y[R]):T.setEndAfter(s);const pe=w.style=="center"?.5:1,X=T.getBoundingClientRect(),me=X.left+pe*X.width-(l.left-P);D=w.pos-me*r}else D=w.pos-C;switch(a.innerHTML="&nbsp;",a.style.textDecoration="inherit",a.style.wordSpacing=`${D.toFixed(0)}pt`,w.leader){case"dot":case"middleDot":a.style.textDecoration="underline",a.style.textDecorationStyle="dotted";break;case"hyphen":case"heavy":case"underscore":a.style.textDecoration="underline";break}}function Q(a){return parseFloat(a)}var d;(function(a){a.html="http://www.w3.org/1999/xhtml",a.svg="http://www.w3.org/2000/svg",a.mathML="http://www.w3.org/1998/Math/MathML"})(d||(d={}));function x(a){if(z(a))return document.createTextNode(a);if(a instanceof Node)return a;const{ns:e,tagName:t,className:r,style:s,children:n,...l}=a;if(t==="#fragment"){const c=document.createDocumentFragment();
6return n&&n.forEach(u=>c.appendChild(x(u))),c}if(t==="#comment")return document.createComment(n?n[0]:"");const h=e?document.createElementNS(e,t):document.createElement(t);if(r&&h.setAttribute("class",r),s&&(z(s)?h.setAttribute("style",s):Object.assign(h.style,s)),l)for(const[c,u]of Object.entries(l))u!==void 0&&(h[c]=u);return n&&n.forEach(c=>h.appendChild(x(c))),h}function Ft(...a){return a.filter(Boolean).join(" ")}class Lt{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.commentMap={},this.tasks=[],this.postRenderTasks=[],this.h=x}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??x,this.styleMap=null,this.tasks=[],this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);const r=[...this.renderDefaultStyle()];e.themePart&&r.push(...this.renderTheme(e.themePart)),e.stylesPart!=null&&(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,n=>n.id)),e.endnotesPart&&(this.endnoteMap=S(e.endnotesPart.notes,n=>n.id)),e.settingsPart&&(this.defaultTabSize=e.settingsPart.settings?.defaultTabStop),!t.ignoreFonts&&e.fontTablePart&&r.push(...await this.renderFontTable(e.fontTablePart));var s=this.renderSections(e.documentPart.body);return this.options.inWrapper?r.push(this.renderWrapper(s)):r.push(...s),this.commentHighlight&&t.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(n=>n()),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),r.minorFont&&(t["--docx-minorHAnsi-font"]=r.minorFont.latinTypeface));const s=e.theme?.colorScheme;if(s)for(let[l,h]of Object.entries(s.colors))t[`--docx-${l}-color`]=`#${h}`;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 r of e.fonts)for(let s of r.embedFontRefs)try{const n=await this.document.loadFont(s.id,s.key),l={"font-family":_(r.name),src:`url(${n})`};(s.type=="bold"||s.type=="boldItalic")&&(l["font-weight"]="bold"),(s.type=="italic"||s.type=="boldItalic")&&(l["font-style"]="italic"),t.push(this.h({tagName:"#comment",children:[`docxjs ${r.name} font`]})),t.push(this.h({tagName:"style",children:[this.styleToString("@font-face",l)]}))}catch{this.options.debug&&console.warn(`Can't load font with id ${s.id} and key ${s.key}`)}return t}processStyleName(e){return e?`${this.className}_${be(e)}`:this.className}processStyles(e){const t=S(e.filter(s=>s.id!=null),s=>s.id);for(const s of e.filter(n=>n.basedOn)){var r=t[s.basedOn];if(r){s.paragraphProps=H(s.paragraphProps,r.paragraphProps),s.runProps=H(s.runProps,r.runProps);for(const n of r.styles){const l=s.styles.find(h=>h.target==n.target);l?this.copyStyleProperties(n.values,l.values):s.styles.push({...n,values:{...n.values}})}}else this.options.debug&&console.warn(`Can't find base style ${s.basedOn}`)}for(let s of e)s.cssName=this.processStyleName(s.id);return t}prodessNumberings(e){for(let t of e.filter(r=>r.pStyleName)){const r=this.findStyle(t.pStyleName);r?.paragraphProps?.numbering&&(r.paragraphProps.numbering.level=t.level)}}processElement(e){if(e.children)for(var t of e.children)t.parent=e,t.type==o.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;t==null&&(t={}),r==null&&(r=Object.getOwnPropertyNames(e));for(var s of r)e.hasOwnProperty(s)&&!t.hasOwnProperty(s)&&(t[s]=e[s]);return t}createPageElement(e,t,r){const s={...r};return t&&(t.pageMargins&&(s.paddingLeft=t.pageMargins.left,s.paddingRight=t.pageMargins.right,s.paddingTop=t.pageMargins.top,s.paddingBottom=t.pageMargins.bottom),t.pageSize&&(this.options.ignoreWidth||(s.width=t.pageSize.width),this.options.ignoreHeight||(s.minHeight=t.pageSize.height))),this.h({tagName:"section",className:e,style:s})}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),s=this.groupByPageBreaks(r);let n=null;for(let h=0,c=s.length;h<c;h++){this.currentFootnoteIds=[];let k=s[h][0].sectProps;const p=this.createPageElement(this.className,k,e.cssStyle);this.options.renderHeaders&&this.renderHeaderFooter(k.headerRefs,k,t.length,n!=k,p);for(const m of s[h]){var l=this.createSectionContent(m.sectProps);this.renderElements(m.elements,l),p.appendChild(l),k=m.sectProps}
vendor: 10,996 bytes, lines 6-24
6if(this.options.renderFootnotes){const m=this.renderNotes(this.currentFootnoteIds,this.footnoteMap);m&&p.appendChild(m)}if(this.options.renderEndnotes&&h==c-1){const m=this.renderNotes(this.currentEndnoteIds,this.endnoteMap);m&&p.appendChild(m)}this.options.renderFooters&&this.renderHeaderFooter(k.footerRefs,k,t.length,n!=k,p),t.push(p),n=k}return t}renderHeaderFooter(e,t,r,s,n){if(!e)return;const l=this.document.settingsPart?.settings?.evenAndOddHeaders??!1;var h=(t.titlePage&&s?e.find(u=>u.type=="first"):null)??(r%2==1&&l?e.find(u=>u.type=="even"):null)??e.find(u=>u.type=="default"),c=h&&this.document.findPartByRelId(h.id,this.document.documentPart);if(c){this.currentPart=c,this.usedHederFooterParts.includes(c.path)||(this.processElement(c.rootElement),this.usedHederFooterParts.push(c.path));const[u]=this.renderElements([c.rootElement],n);t?.pageMargins&&(c.rootElement.type===o.Header?(u.style.marginTop=`calc(${t.pageMargins.header} - ${t.pageMargins.top})`,u.style.minHeight=`calc(${t.pageMargins.top} - ${t.pageMargins.header})`):c.rootElement.type===o.Footer&&(u.style.marginBottom=`calc(${t.pageMargins.footer} - ${t.pageMargins.bottom})`,u.style.minHeight=`calc(${t.pageMargins.bottom} - ${t.pageMargins.footer})`)),this.currentPart=null}}isPageBreakElement(e){return e.type!=o.Break?!1:e.break=="lastRenderedPageBreak"?!this.options.ignoreLastRenderedPageBreak:e.break=="page"}isPageBreakSection(e,t){return!e||!t?!1: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},s=[r];for(let p of e){if(p.type==o.Paragraph){const m=p,P=this.findStyle(m.styleName);(m.pageBreakBefore||P?.paragraphProps?.pageBreakBefore)&&(r.sectProps=n,r.pageBreak=!0,r={sectProps:null,elements:[],pageBreak:!1},s.push(r))}if(r.elements.push(p),p.type==o.Paragraph){const m=p;var n=m.sectionProps,l=-1,h=-1;if(this.options.breakPages&&m.children&&(l=m.children.findIndex(P=>(h=P.children?.findIndex(this.isPageBreakElement.bind(this))??-1,h!=-1))),(n||l!=-1)&&(r.sectProps=n,r.pageBreak=l!=-1,r={sectProps:null,elements:[],pageBreak:!1},s.push(r)),l!=-1){let P=m.children[l],B=h<P.children.length-1;if(l<m.children.length-1||B){var c=p.children,u={...p,children:c.slice(l)};if(p.children=c.slice(0,l),r.elements.push(u),B){let C=P.children,w={...P,children:C.slice(0,h)};p.children.push(w),P.children=C.slice(h)}}}}}let k=null;for(let p=s.length-1;p>=0;p--)s[p].sectProps==null?s[p].sectProps=k??t:k=s[p].sectProps;return s}groupByPageBreaks(e){let t=[],r;const s=[t];for(let n of e)t.push(n),(this.options.ignoreLastRenderedPageBreak||n.pageBreak||this.isPageBreakSection(r,n.sectProps))&&s.push(t=[]),r=n.sectProps;return s.filter(n=>n.length>0)}renderWrapper(e){return this.h({tagName:"div",className:`${this.className}-wrapper`,children:e})}renderDefaultStyle(){var e=this.className,t=`
7.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; } 
8.${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}
9.${e} { color: black; hyphens: auto; text-underline-position: from-font; }
10section.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }
11section.${e}>article { margin-bottom: auto; z-index: 1; }
12section.${e}>footer { z-index: 1; }
13.${e} table { border-collapse: collapse; }
14.${e} table td, .${e} table th { vertical-align: top; }
15.${e} p { margin: 0pt; min-height: 1em; }
16.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }
17.${e} a { color: inherit; text-decoration: inherit; }
18.${e} svg { fill: transparent; }
19`;return this.options.renderComments&&(r+=`
20.${e}-comment-ref { cursor: default; }
21.${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; }
22.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }
23.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }
24`),[this.h({tagName:"#comment",children:["docxjs library predefined styles"]}),this.h({tagName:"style",children:[r]})]}async renderNumbering(e){var t="",r=[];for(var s of e){var n=`p.${this.numberingClass(s.id,s.level)}`,l="none";if(s.bullet){let h=`--${this.className}-${s.bullet.src}`.toLowerCase();t+=this.styleToString(`${n}:before`,{content:"' '",display:"inline-block",background:`var(${h})`},s.bullet.style);try{const c=await this.document.loadNumberingImage(s.bullet.src);t+=`${this.rootSelector} { ${h}: url(${c}) }`}catch{this.options.debug&&console.warn(`Can't load numbering image with src ${s.bullet.src}`)}}else if(s.levelText){let h=this.numberingCounter(s.id,s.level);const c=h+" "+(s.start-1);s.level>0&&(t+=this.styleToString(`p.${this.numberingClass(s.id,s.level-1)}`,{"counter-set":c})),r.push(c),t+=this.styleToString(`${n}:before`,{content:this.levelTextToContent(s.levelText,s.suff,s.id,this.numFormatToCssValue(s.format)),"counter-increment":h,...s.rStyle})}else l=this.numFormatToCssValue(s.format);t+=this.styleToString(n,{display:"list-item","list-style-position":"inside","list-style-type":l,...s.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,s=S(e.filter(c=>c.isDefault),c=>c.target);for(const c of e){var n=c.styles;if(c.linked){var l=c.linked&&r[c.linked];l?n=n.concat(l.styles):this.options.debug&&console.warn(`Can't find linked style ${c.linked}`)}for(const u of n){var h=`${c.target??""}.${c.cssName}`;c.target!=u.target&&(h+=` ${u.target}`),s[c.target]==c&&(h=`.${this.className} ${c.target}, `+h),t+=this.styleToString(h,u.values)}}return[this.h({tagName:"#comment",children:["docxjs document styles"]}),this.h({tagName:"style",children:[t]})]}renderNotes(e,t){var r=e.map(s=>t[s]).filter(s=>s);if(r.length>0)return this.h({tagName:"ol",children:this.renderElements(r)})}renderElement(e){switch(e.type){case o.Paragraph:return this.renderParagraph(e);case o.BookmarkStart:return this.renderBookmarkStart(e);case o.BookmarkEnd:return null;case o.Run:return this.renderRun(e);case o.Table:return this.renderTable(e);case o.Row:return this.renderTableRow(e);case o.Cell:return this.renderTableCell(e);case o.Hyperlink:return this.renderHyperlink(e);case o.SmartTag:return this.renderSmartTag(e);case o.Drawing:return this.renderDrawing(e);case o.Image:return this.renderImage(e);case o.Text:return this.renderText(e);case o.Text:return this.renderText(e);case o.DeletedText:return this.renderDeletedText(e);case o.Tab:return this.renderTab(e);case o.Symbol:return this.renderSymbol(e);case o.Break:return this.renderBreak(e);case o.Footer:return this.renderContainer(e,"footer");case o.Header:return this.renderContainer(e,"header");case o.Footnote:case o.Endnote:return this.renderContainer(e,"li");case o.FootnoteReference:return this.renderFootnoteReference(e);case o.EndnoteReference:return this.renderEndnoteReference(e);case o.NoBreakHyphen:return this.h({tagName:"wbr"});case o.VmlPicture:return this.renderVmlPicture(e);case o.VmlElement:return this.renderVmlElement(e);case o.MmlMath:return this.renderContainerNS(e,d.mathML,"math",{xmlns:d.mathML});case o.MmlMathParagraph:return this.renderContainer(e,"span");case o.MmlFraction:return this.renderContainerNS(e,d.mathML,"mfrac");case o.MmlBase:return this.renderContainerNS(e,d.mathML,e.parent.type==o.MmlMatrixRow?"mtd":"mrow");case o.MmlNumerator:case o.MmlDenominator:case o.MmlFunction:case o.MmlLimit:case o.MmlBox:return this.renderContainerNS(e,d.mathML,"mrow");case o.MmlGroupChar:return this.renderMmlGroupChar(e);case o.MmlLimitLower:return this.renderContainerNS(e,d.mathML,"munder");case o.MmlMatrix:return this.renderContainerNS(e,d.mathML,"mtable");case o.MmlMatrixRow:return this.renderContainerNS(e,d.mathML,"mtr");case o.MmlRadical:return this.renderMmlRadical(e);case o.MmlSuperscript:return this.renderContainerNS(e,d.mathML,"msup");case o.MmlSubscript:return this.renderContainerNS(e,d.mathML,"msub");case o.MmlDegree:case o.MmlSuperArgument:case o.MmlSubArgument:return this.renderContainerNS(e,d.mathML,"mn");case o.MmlFunctionName:return this.renderContainerNS(e,d.mathML,"ms");case o.MmlDelimiter:return this.renderMmlDelimiter(e);case o.MmlRun:return this.renderMmlRun(e);case o.MmlNary:return this.renderMmlNary(e);case o.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case o.MmlBar:return this.renderMmlBar(e);case o.MmlEquationArray:return this.renderMllList(e);case o.Inserted:return this.renderInserted(e);case o.Deleted:return this.renderDeleted(e);case o.CommentRangeStart:return this.renderCommentRangeStart(e);case o.CommentRangeEnd:return this.renderCommentRangeEnd(e);case o.CommentReference:return this.renderCommentReference(e);case o.AltChunk:return this.renderAltChunk(e)}return null}renderElements(e,t){if(e==null)return null;var r=e.flatMap(s=>this.renderElement(s)).filter(s=>s!=null);return t&&r.forEach(s=>t.appendChild(z(s)?document.createTextNode(s):s)),r}renderContainer(e,t,r){return this.h({tagName:t,children:this.renderElements(e.children),...r})}renderContainerNS(e,t,r,s){return this.h({ns:t,tagName:r,children:this.renderElements(e.children),...s})}renderParagraph(e){var t=this.toHTML(e,d.html,"p");const r=this.findStyle(e.styleName);e.tabs??(e.tabs=r?.paragraphProps?.tabs);const s=e.numbering??r?.paragraphProps?.numbering;return s&&t.classList.add(this.numberingClass(s.id,s.level)),t}renderHyperlink(e){const t=this.toH(e,d.html,"a");if(t.href="",e.id){const r=this.document.documentPart.rels.find(s=>s.id==e.id&&s.targetMode==="External");t.href=r?.target??t.href}return 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:["💬"]}),s=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}
24-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,s]})}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(r=>{t.srcdoc=r})),t}renderDrawing(e){var t=this.toHTML(e,d.html,"div");return t.style.display="inline-block",t.style.position="relative",t.style.textIndent="0px",t}renderImage(e){let t=this.toHTML(e,d.html,"img",[]),r=e.cssStyle?.transform;if(e.srcRect&&e.srcRect.some(c=>c!=0)){var[s,n,l,h]=e.srcRect;r=`scale(${1/(1-s-l)}, ${1/(1-n-h)})`,t.style["clip-path"]=`rect(${(100*n).toFixed(2)}% ${(100*(1-l)).toFixed(2)}% ${(100*(1-h)).toFixed(2)}% ${(100*s).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(c=>{t.src=c})),t}renderText(e){return this.h(e.text)}renderDeletedText(e){return this.options.renderChanges?this.renderText(e):null}renderBreak(e){return e.break=="textWrapping"?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=$t(e,o.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,d.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,d.html,"table",t)}renderTableColumns(e){const t=e.map(r=>this.h({tagName:"col",style:{width:r.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,d.html,"tr",t)}renderTableCellPlaceholder(e){return this.h({tagName:"td",colSpan:e,style:{border:"none"}})}renderTableCell(e){let t=this.toHTML(e,d.html,"td");const r=this.currentCellPosition.col;return e.verticalMerge?e.verticalMerge=="restart"?(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:d.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(s=>r.setAttribute("href",s))),t.appendChild(r),requestAnimationFrame(()=>{const s=t.firstElementChild.getBBox();t.setAttribute("width",`${Math.ceil(s.x+s.width)}`),t.setAttribute("height",`${Math.ceil(s.y+s.height)}`)}),t}renderVmlChildElement(e){const t=this.createSvgElement(e.tagName);
24Object.entries(e.attrs).forEach(([r,s])=>t.setAttribute(r,s));for(let r of e.children)r.type==o.VmlElement?t.appendChild(this.renderVmlChildElement(r)):t.appendChild(...A(this.renderElement(r)));return t}renderMmlRadical(e){const t=e.children.find(s=>s.type==o.MmlBase);if(e.props?.hideDegree)return this.createMathMLElement("msqrt",null,this.renderElements([t]));const r=e.children.find(s=>s.type==o.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,u=>u.type),s=r[o.MmlSuperArgument],n=r[o.MmlSubArgument],l=s?this.createMathMLElement("mo",null,A(this.renderElement(s))):null,h=n?this.createMathMLElement("mo",null,A(this.renderElement(n))):null,c=this.createMathMLElement("mo",null,[e.props?.char??"∫"]);return l||h?t.push(this.createMathMLElement("munderover",null,[c,h,l])):l?t.push(this.createMathMLElement("mover",null,[c,l])):h?t.push(this.createMathMLElement("munder",null,[c,h])):t.push(c),t.push(...this.renderElements(r[o.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlPreSubSuper(e){const t=[],r=S(e.children,u=>u.type),s=r[o.MmlSuperArgument],n=r[o.MmlSubArgument],l=s?this.createMathMLElement("mo",null,A(this.renderElement(s))):null,h=n?this.createMathMLElement("mo",null,A(this.renderElement(n))):null,c=this.createMathMLElement("mo",null);return t.push(this.createMathMLElement("msubsup",null,[c,h,l])),t.push(...this.renderElements(r[o.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlGroupChar(e){const t=e.props.verticalJustification==="bot"?"mover":"munder",r=this.renderContainerNS(e,d.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";break}return this.renderContainerNS(e,d.mathML,"mrow",{style:t})}renderMmlRun(e){return this.toHTML(e,d.mathML,"ms")}renderMllList(e){const t=this.renderElements(e.children).map(r=>this.createMathMLElement("mtr",null,[this.createMathMLElement("mtd",null,[r])]));return this.toHTML(e,d.mathML,"mtable",t)}toH(e,t,r,s=null){const{$lang:n,...l}=e.cssStyle??{},h=Ft(e.className,e.styleName&&this.processStyleName(e.styleName));return{ns:t,tagName:r,className:h,lang:n,style:l,children:s??this.renderElements(e.children)}}toHTML(e,t,r,s=null){return this.h(this.toH(e,t,r,s))}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 s=`${e} {\r
25`;for(const n in t)n.startsWith("$")||(s+=`  ${n}: ${t[n]};\r
26`);return r&&(s+=r),s+`}\r
27`}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,s){const n={tab:"\\9",space:"\\a0"};var l=e.replace(/%\d*/g,h=>{let c=parseInt(h.substring(1),10)-1;return`"counter(${this.numberingCounter(r,c)}, ${s})"`});return`"${l}${n[t]??""}"`}numFormatToCssValue(e){var 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"};return t[e]??e}refreshTabStops(){this.options.experimental&&setTimeout(()=>{const e=Rt();for(let t of this.currentTabs)Tt(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,r,s){return this.h({ns:e,tagName:t,children:s,...r})}createElement(e,t,r){return this.createElementNS(d.html,e,t,r)}createMathMLElement(e,t,r){return this.createElementNS(d.mathML,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(d.svg,e,t,r)}later(e){this.postRenderTasks.push(e)}}function $t(a,e){for(var t=a.parent;t!=null&&t.type!=e;)t=t.parent;return t}const de={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,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:x};function Ht(a,e){const t={...de,...e};return W.load(a,new Et(t),t)}async function Dt(a,e){const t={...de,...e};return await new Lt().render(a,t)}async function _t(a,e,t,r){const s=await Ht(a,r),n=await Dt(s,r);t??(t=e),t.innerHTML="",e.innerHTML="";for(let l of n)(l.nodeName==="STYLE"?t:e).appendChild(l);return s}export{de as defaultOptions,Ht as parseAsync,_t as renderAsync,Dt as renderDocument};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.