file-viewer-demo/public/dist/assets/docx-preview-1cf76835.js

28 lines
161 KiB
JavaScript
Raw Permalink Normal View History

2024-01-30 00:54:29 +00:00
import{c as Tt,g as xe}from"./index-be50c070.js";import{c as Ft}from"./_commonjs-dynamic-modules-302442b1.js";var oe={exports:{}};/*!
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/main/LICENSE
*/(function(c,e){(function(t){c.exports=t()})(function(){return function t(r,n,a){function i(k,w){if(!n[k]){if(!r[k]){var y=typeof Ft=="function"&&Ft;if(!w&&y)return y(k,!0);if(l)return l(k,!0);var _=new Error("Cannot find module '"+k+"'");throw _.code="MODULE_NOT_FOUND",_}var d=n[k]={exports:{}};r[k][0].call(d.exports,function(v){var u=r[k][1][v];return i(u||v)},d,d.exports,t,r,n,a)}return n[k].exports}for(var l=typeof Ft=="function"&&Ft,h=0;h<a.length;h++)i(a[h]);return i}({1:[function(t,r,n){var a=t("./utils"),i=t("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(h){for(var k,w,y,_,d,v,u,m=[],f=0,b=h.length,x=b,A=a.getTypeOf(h)!=="string";f<h.length;)x=b-f,y=A?(k=h[f++],w=f<b?h[f++]:0,f<b?h[f++]:0):(k=h.charCodeAt(f++),w=f<b?h.charCodeAt(f++):0,f<b?h.charCodeAt(f++):0),_=k>>2,d=(3&k)<<4|w>>4,v=1<x?(15&w)<<2|y>>6:64,u=2<x?63&y:64,m.push(l.charAt(_)+l.charAt(d)+l.charAt(v)+l.charAt(u));return m.join("")},n.decode=function(h){var k,w,y,_,d,v,u=0,m=0,f="data:";if(h.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var b,x=3*(h=h.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(h.charAt(h.length-1)===l.charAt(64)&&x--,h.charAt(h.length-2)===l.charAt(64)&&x--,x%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=i.uint8array?new Uint8Array(0|x):new Array(0|x);u<h.length;)k=l.indexOf(h.charAt(u++))<<2|(_=l.indexOf(h.charAt(u++)))>>4,w=(15&_)<<4|(d=l.indexOf(h.charAt(u++)))>>2,y=(3&d)<<6|(v=l.indexOf(h.charAt(u++))),b[m++]=k,d!==64&&(b[m++]=w),v!==64&&(b[m++]=y);return b}},{"./support":30,"./utils":32}],2:[function(t,r,n){var a=t("./external"),i=t("./stream/DataWorker"),l=t("./stream/Crc32Probe"),h=t("./stream/DataLengthProbe");function k(w,y,_,d,v){this.compressedSize=w,this.uncompressedSize=y,this.crc32=_,this.compression=d,this.compressedContent=v}k.prototype={getContentWorker:function(){var w=new i(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),y=this;return w.on("end",function(){if(this.streamInfo.data_length!==y.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),w},getCompressedWorker:function(){return new i(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},k.createWorkerFrom=function(w,y,_){return w.pipe(new l).pipe(new h("uncompressedSize")).pipe(y.compressWorker(_)).pipe(new h("compressedSize")).withStreamInfo("compression",y)},r.exports=k},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,r,n){var a=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,r,n){var a=t("./utils"),i=function(){for(var l,h=[],k=0;k<256;k++){l=k;for(var w=0;w<8;w++)l=1&l?3988292384^l>>>1:l>>>1;h[k]=l}return h}();r.exports=function(l,h){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?function(k,w,y,_){var d=i,v=_+y;k^=-1;for(var u=_;u<v;u++)k=k>>>8^d[255&(k^w[u])];return-1^k}(0|h,l,l.length,0):function(k,w,y,_){var d=i,v=_+y;k^=-1;for(var u=_;u<v;u++)k=k>>>8^d[255&(k^w.charCodeAt(u))];return-1^k}(0|h,l,l.length,0):0}},{"./utils":32}],5:[function(t,r,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(t,r,n){var a=null;a=typeof Promise<"u"?Promise:t("lie"),r.exports={Promise:a}},{lie:37}],7:[function(t,r,n){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=t("pako"),l=t("./utils"),h=t("./stream/GenericWorker"),k=a?"uint8array":"array";function w(y,_){h.call(this,"FlateWorker/"+y),this._pako=null,this._pakoAction=y,this._pakoOptions=_,th
\0`,K+=a(B,2),K+=D.magic,K+=a(x,2),K+=a(A,2),K+=a(tt.crc32,4),K+=a(tt.compressedSize,4),K+=a(tt.uncompressedSize,4),K+=a(H.length,2),K+=a(L.length,2),{fileRecord:y.LOCAL_FILE_HEADER+K+H+L,dirRecord:y.CENTRAL_FILE_HEADER+a(J,2)+K+a(Q.length,2)+"\0\0\0\0"+a(z,4)+a(m,4)+H+L+Q}}var l=t("../utils"),h=t("../stream/GenericWorker"),k=t("../utf8"),w=t("../crc32"),y=t("../signature");function _(d,v,u,m){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=u,this.encodeFileName=m,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(_,h),_.prototype.push=function(d){var v=d.meta.percent||0,u=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,h.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:u?(v+100*(u-m-1))/u:100}}))},_.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var v=this.streamFiles&&!d.file.dir;if(v){var u=i(d,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:u.fileRecord,meta:{percent:0}})}else this.accumulate=!0},_.prototype.closedSource=function(d){this.accumulate=!1;var v=this.streamFiles&&!d.file.dir,u=i(d,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(u.dirRecord),v)this.push({data:function(m){return y.DATA_DESCRIPTOR+a(m.crc32,4)+a(m.compressedSize,4)+a(m.uncompressedSize,4)}(d),meta:{percent:100}});else for(this.push({data:u.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},_.prototype.flush=function(){for(var d=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var u=this.bytesWritten-d,m=function(f,b,x,A,P){var D=l.transformTo("string",P(A));return y.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(f,2)+a(f,2)+a(b,4)+a(x,4)+a(D.length,2)+D}(this.dirRecords.length,u,d,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},_.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},_.prototype.registerPrevious=function(d){this._sources.push(d);var v=this;return d.on("data",function(u){v.processChunk(u)}),d.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),d.on("error",function(u){v.error(u)}),this},_.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},_.prototype.error=function(d){var v=this._sources;if(!h.prototype.error.call(this,d))return!1;for(var u=0;u<v.length;u++)try{v[u].error(d)}catch{}return!0},_.prototype.lock=function(){h.prototype.lock.call(this);for(var d=this._sources,v=0;v<d.length;v++)d[v].lock()},r.exports=_},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,r,n){var a=t("../compressions"),i=t("./ZipFileWorker");n.generateWorker=function(l,h,k){var w=new i(h.streamFiles,k,h.platform,h.encodeFileName),y=0;try{l.forEach(function(_,d){y++;var v=function(b,x){var A=b||x,P=a[A];if(!P)throw new Error(A+" is not a valid compression method !");return P}(d.options.compression,h.compression),u=d.options.compressionOptions||h.compressionOptions||{},m=d.dir,f=d.date;d._compressWorker(v,u).withStreamInfo("file",{name:_,dir:m,date:f,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(w)}),w.entriesCount=y}catch(_){w.error(_)}return w}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,r,n){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upg
.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }
.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }
.${e} { color: black; hyphens: auto; text-underline-position: from-font; }
section.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }
section.${e}>article { margin-bottom: auto; z-index: 1; }
section.${e}>footer { z-index: 1; }
.${e} table { border-collapse: collapse; }
.${e} table td, .${e} table th { vertical-align: top; }
.${e} p { margin: 0pt; min-height: 1em; }
.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }
.${e} a { color: inherit; text-decoration: inherit; }
`;return Ct(t)}renderNumbering(e,t){var r="",n=[];for(var a of e){var i=`p.${this.numberingClass(a.id,a.level)}`,l="none";if(a.bullet){let h=`--${this.className}-${a.bullet.src}`.toLowerCase();r+=this.styleToString(`${i}:before`,{content:"' '",display:"inline-block",background:`var(${h})`},a.bullet.style),this.tasks.push(this.document.loadNumberingImage(a.bullet.src).then(k=>{var w=`${this.rootSelector} { ${h}: url(${k}) }`;t.appendChild(Ct(w))}))}else if(a.levelText){let h=this.numberingCounter(a.id,a.level);const k=h+" "+(a.start-1);a.level>0&&(r+=this.styleToString(`p.${this.numberingClass(a.id,a.level-1)}`,{"counter-reset":k})),n.push(k),r+=this.styleToString(`${i}:before`,{content:this.levelTextToContent(a.levelText,a.suff,a.id,this.numFormatToCssValue(a.format)),"counter-increment":h,...a.rStyle})}else l=this.numFormatToCssValue(a.format);r+=this.styleToString(i,{display:"list-item","list-style-position":"inside","list-style-type":l,...a.pStyle})}return n.length>0&&(r+=this.styleToString(this.rootSelector,{"counter-reset":n.join(" ")})),Ct(r)}renderStyles(e){var t="";const r=this.styleMap,n=xt(e.filter(h=>h.isDefault),h=>h.target);for(const h of e){var a=h.styles;if(h.linked){var i=h.linked&&r[h.linked];i?a=a.concat(i.styles):this.options.debug&&console.warn(`Can't find linked style ${h.linked}`)}for(const k of a){var l=`${h.target??""}.${h.cssName}`;h.target!=k.target&&(l+=` ${k.target}`),n[h.target]==h&&(l=`.${this.className} ${h.target}, `+l),t+=this.styleToString(l,k.values)}}return Ct(t)}renderNotes(e,t,r){var n=e.map(i=>t[i]).filter(i=>i);if(n.length>0){var a=this.createElement("ol",null,this.renderElements(n));r.appendChild(a)}}renderElement(e){switch(e.type){case R.Paragraph:return this.renderParagraph(e);case R.BookmarkStart:return this.renderBookmarkStart(e);case R.BookmarkEnd:return null;case R.Run:return this.renderRun(e);case R.Table:return this.renderTable(e);case R.Row:return this.renderTableRow(e);case R.Cell:return this.renderTableCell(e);case R.Hyperlink:return this.renderHyperlink(e);case R.Drawing:return this.renderDrawing(e);case R.Image:return this.renderImage(e);case R.Text:return this.renderText(e);case R.Text:return this.renderText(e);case R.DeletedText:return this.renderDeletedText(e);case R.Tab:return this.renderTab(e);case R.Symbol:return this.renderSymbol(e);case R.Break:return this.renderBreak(e);case R.Footer:return this.renderContainer(e,"footer");case R.Header:return this.renderContainer(e,"header");case R.Footnote:case R.Endnote:return this.renderContainer(e,"li");case R.FootnoteReference:return this.renderFootnoteReference(e);case R.EndnoteReference:return this.renderEndnoteReference(e);case R.NoBreakHyphen:return this.createElement("wbr");case R.VmlPicture:return this.renderVmlPicture(e);case R.VmlElement:return this.renderVmlElement(e);case R.MmlMath:return this.renderContainerNS(e,at.mathML,"math",{xmlns:at.mathML});case R.MmlMathParagraph:return this.renderContainer(e,"span");case R.MmlFraction:return this.renderContainerNS(e,at.mathML,"mfrac");case R.MmlBase:return this.renderContainerNS(e,at.mathML,e.parent.type==R.MmlMatrixRow?"mtd":"mrow");case R.MmlNumerator:case R.MmlDenominator:case R.MmlFunction:case R.MmlLimit:case R.MmlBox:return this.renderContainerNS(e,at.mathML,"mrow");case R.MmlGroupChar:return this.renderMmlGroupChar(e);case R.MmlLimitLower:return this.renderContainerNS(e,at.mathML,"munder");case R.MmlMatrix:return this.renderContainerNS(e,at.mathML,"mtable");case R.MmlMatrixRow:return this.renderContainerNS(e,at.mathML,"mtr");case R.MmlRadical:return this.renderMmlRadical(e);case R.MmlSuperscript:return this.renderContainerNS(e,at.mathML,"msup");case R.MmlSubscript:return this.renderContainerNS(e,at.mathML,"msub");case R.MmlDegree:case R.MmlSuperArgument:case R.MmlSubArgument:return this.renderContainerNS(e,at.mathML,"mn");case R.MmlFunctionName:return this.renderContainerNS(e,at.mathML,"ms");case R.MmlDelimiter:return this.renderMmlDelimiter(e);case R.MmlRun:return this.renderMmlRun(e);case R.MmlNary:return this.renderMmlNary(e);case R.MmlPreSubSuper:return t
`;for(const a in t)a.startsWith("$")||(n+=` ${a}: ${t[a]};\r
`);return r&&(n+=r),n+`}\r
`}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,n){const a={tab:"\\9",space:"\\a0"};var i=e.replace(/%\d*/g,l=>{let h=parseInt(l.substring(1),10)-1;return`"counter(${this.numberingCounter(r,h)}, ${n})"`});return`"${i}${a[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&&(clearTimeout(this.tabsTimeout),this.tabsTimeout=setTimeout(()=>{const e=Fr();for(let t of this.currentTabs)Ir(t.span,t.stops,this.defaultTabSize,e)},500))}}function Ht(c,e,t){return ct(void 0,c,e,t)}function se(c,e,t){return ct(at.svg,c,e,t)}function ct(c,e,t,r){var n=c?document.createElementNS(c,e):document.createElement(e);return Object.assign(n,t),r&&$t(n,r),n}function ie(c){c.innerHTML=""}function $t(c,e){e.forEach(t=>c.appendChild(je(t)?document.createTextNode(t):t))}function Ct(c){return Ht("style",{innerHTML:c})}function Bt(c,e){c.appendChild(document.createComment(e))}function Dr(c,e){for(var t=c.parent;t!=null&&t.type!=e;)t=t.parent;return t}const ye={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,debug:!1,experimental:!1,className:"docx",inWrapper:!0,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1};function Lr(c,e){const t={...ye,...e};return Gt.load(c,new Mr(t),t)}async function jr(c,e,t,r){const n={...ye,...r},a=new Or(window.document);return a.render(c,e,t,n),Promise.allSettled(a.tasks.filter(i=>i))}async function Hr(c,e,t,r){const n=await Lr(c,r);return await jr(n,e,t,r),n}export{ye as defaultOptions,Lr as praseAsync,Hr as renderAsync,jr as renderDocument};