@cerebriline/core 4.100.250 → 4.100.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,34 @@
1
- import{createRequire as F$}from"node:module";var D=F$(import.meta.url);import{mkdir as wJ,writeFile as yJ}from"node:fs/promises";import{join as W$}from"node:path";import xJ from"node:fs/promises";import{existsSync as PQ,readdirSync as v$,readFileSync as AQ,statSync as S$}from"node:fs";import*as u from"node:path";import{createHash as C$}from"node:crypto";import{inflateSync as R$}from"node:zlib";var N$=new Set(["image/png","image/jpeg","image/gif","image/webp"]),L$={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/tiff":"tif","image/svg+xml":"svg","image/emf":"emf","image/wmf":"wmf","image/x-pict":"pict"};function j$(Q){let $=(q,...Z)=>Z.every((K,H)=>Q[q+H]===K);if($(0,137,80,78,71))return"image/png";if($(0,255,216,255))return"image/jpeg";if($(0,71,73,70,56))return"image/gif";if($(0,82,73,70,70)&&$(8,87,69,66,80))return"image/webp";if($(0,66,77))return"image/bmp";if($(0,73,73,42,0)||$(0,77,77,0,42))return"image/tiff";if($(40,32,69,77,70))return"image/emf";if($(0,215,205,198,154)||$(0,1,0,9,0))return"image/wmf";if($(10,0,17,2,255))return"image/x-pict";let J=Buffer.from(Q.subarray(0,256)).toString("utf8").trimStart();if(J.startsWith("<svg")||J.startsWith("<?xml")&&J.includes("<svg"))return"image/svg+xml";return}function T$(Q){if(Q[0]!==120||![1,94,156,218].includes(Q[1]??0))return Q;try{return new Uint8Array(R$(Q))}catch{return Q}}class BQ{linkDir;byHash=new Map;names=new Set;pending=[];constructor(Q="images"){this.linkDir=Q}add(Q){if(Q.data.byteLength===0)return;let $=T$(Q.data),J=C$("sha1").update($).digest("hex"),q=this.byHash.get(J);if(q)return q;let Z=j$($)??Q.mediaType??"application/octet-stream",K=L$[Z]??"bin",H=this.uniqueName(O$(Q.stem),K),Y={file:H,link:`${this.linkDir}/${H}`,mediaType:Z,bytes:$.byteLength,...Q.width?{width:Q.width}:{},...Q.height?{height:Q.height}:{},...Q.source?{source:Q.source}:{},...Q.alt?.trim()?{alt:Q.alt.trim()}:{},...N$.has(Z)||Z==="image/svg+xml"?{}:{notViewable:!0},sha1:J};return this.byHash.set(J,Y),this.pending.push({image:Y,data:$}),Y}get images(){return this.pending.map((Q)=>Q.image)}entries(){return this.pending}uniqueName(Q,$){let J=`${Q}.${$}`;for(let q=2;this.names.has(J);q++)J=`${Q}-${q}.${$}`;return this.names.add(J),J}}function O$(Q){return Q.replace(/\.[a-z0-9]{2,4}$/i,"").replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"image"}function x(Q){return`![${(Q.alt??"").replace(/[[\]\n]/g," ").trim()}](${Q.link})`}var P$=/\.(png|jpe?g|gif|webp|bmp|svg|tiff?)$/i;function A$(Q){if(Q.length<90)return 0;let $=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),J=$.getUint32(78);if(J+14>Q.length)return 0;return $.getUint16(J+12)}function I$(Q){let $=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);return $.includes("META-INF/rights.xml")||$.includes("META-INF/license.lcpl")}function k$(Q){let $=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);if($.length<22||$.readUInt32LE(0)!==67324752)return"it does not start as a ZIP archive, which every EPUB is";let J=$.lastIndexOf(Buffer.from([80,75,5,6]),$.length-22);if(J<0||J<$.length-22-65535)return`it ends before its index (${$.length.toLocaleString("en-US")} bytes), so it was cut short when it was copied, downloaded or unpacked`;let q=$.readUInt32LE(J+12),Z=$.readUInt32LE(J+16);if(Z!==4294967295&&q!==4294967295&&Z+q>J)return"its index points past the end of the file, so part of it is missing";return}var IQ=120000;async function $Q(Q){let $;try{return await Promise.race([Q,new Promise((J,q)=>{$=setTimeout(()=>q(Error(`The book could not be opened: the reader gave no answer in ${IQ/1000}s, which is what it does with a damaged file. Check that the file is complete.`)),IQ)})])}finally{clearTimeout($)}}function kQ(Q,$=0,J=[]){for(let q of Q){if(J.length>=200)break;let Z=String(q.label??"").trim();if(Z)J.push(`${" ".repeat($)}${Z}`);if(Array.isArray(q.children))kQ(q.children,$+1,J)}return J}function JQ(Q){if(typeof Q==="string")return Q.trim()||void 0;if(Array.isArray(Q))for(let $ of Q){let J=JQ(typeof $==="object"&&$!==null?$.contributor??$.name:$);if(J)return J}if(typeof Q==="object"&&Q!==null){let $=Q;return JQ($.contributor??$.name??$.value)}return}async function D$(Q){let{default:$}=await import("turndown"),{gfm:J}=await import("@joplin/turndown-plugin-gfm"),q=new $({headingStyle:"atx",codeBlockStyle:"fenced",bulletListMarker:"-"});return q.use(J),q.remove(["script","style","head"]),q.addRule("image",{filter:"img",replacement:(Z,K)=>{let H=K,Y=H.getAttribute("src")??"";return Q(Y,H.getAttribute("alt")??"")??""}}),q.addRule("svgImage",{filter:(Z)=>Z.nodeName.toLowerCase()==="image",replacement:(Z,K)=>{let H=K,Y=H.getAttribute("xlink:href")??H.getAttribute("href")??"";return Q(Y,"")??""}}),q}async function DQ(Q,$,J,q){if((J==="mobi"||J==="azw3")&&A$($)>1)throw Error("This Kindle book is DRM-protected. It can be read only in a Kindle app; nothing here can remove the protection.");if(J==="epub"&&I$($))throw Error("This EPUB is DRM-protected (Adobe ADEPT or Readium LCP). It can be read only in a reader app licensed for it.");if(J==="epub"){let U=k$($);if(U)throw Error(`This EPUB is damaged: ${U}. Nothing can be read from it; get the file again.`)}let Z=q.scratchDir,{initEpubFile:K}=await import("@lingo-reader/epub-parser"),{initFb2File:H}=await import("@lingo-reader/fb2-parser"),{initKf8File:Y,initMobiFile:X}=await import("@lingo-reader/mobi-parser"),B,F;if(J==="epub")B=await $Q(K(Q,Z)),F="lingo-reader (EPUB)";else if(J==="fb2")B=await $Q(H(Q,Z)),F="lingo-reader (FB2)";else{let[U,V]=J==="azw3"?[Y,X]:[X,Y];try{B=await $Q(U(Q,Z)),F=`lingo-reader (${U===Y?"KF8":"MOBI"})`}catch{B=await $Q(V(Q,Z)),F=`lingo-reader (${V===Y?"KF8":"MOBI"})`}}try{let U=new Map,V=0,G=await D$((L,T)=>{if(!q.wantImages||!L||/^(data:|https?:)/i.test(L))return;let S=L;try{S=decodeURI(L.replace(/^file:\/\//,""))}catch{}if(!u.isAbsolute(S)||!PQ(S))return;if(!U.has(S))U.set(S,q.images.add({data:AQ(S),stem:u.basename(S),source:`chapter ${V}`,...T?{alt:T}:{}}));let w=U.get(S);return w?x(w):void 0}),z=B.getSpine(),C=[],I=[];for(let L=0;L<z.length;L++){let T=L+1;if(q.selects&&!q.selects(T))continue;q.signal?.throwIfAborted(),V=T,q.onProgress?.({unit:"chapter",at:T,total:z.length,pictures:U.size}),C.push(T);let w=(await B.loadChapter(z[L].id))?.html??"",i=w?G.turndown(w).trim():"";if(i)I.push(i)}if(q.wantImages&&PQ(Z))for(let L of v$(Z,{recursive:!0})){let T=u.join(Z,L);if(!P$.test(L)||U.has(T)||!S$(T).isFile())continue;U.set(T,q.images.add({data:AQ(T),stem:u.basename(L)}))}let P=B.getMetadata()??{},v=JQ(P.title),b=JQ(P.creator??P.author),d=kQ(B.getToc()??[]);return{markdown:I.join(`
2
-
3
- `),reader:F,...v&&v!=="Unknown"?{title:v}:{},...b&&b!=="Unknown"?{author:b}:{},units:{name:"chapter",total:z.length,read:C},...d.length?{contents:d}:{}}}finally{B.destroy()}}import*as WQ from"node:path";var M$={pdf:"PDF",docx:"Word document (DOCX)",pptx:"PowerPoint presentation (PPTX)",xlsx:"Excel workbook (XLSX)",odt:"OpenDocument text (ODT)",odp:"OpenDocument presentation (ODP)",ods:"OpenDocument spreadsheet (ODS)",odg:"OpenDocument drawing (ODG)",rtf:"Rich Text (RTF)",csv:"CSV",html:"HTML",epub:"EPUB ebook",mobi:"Mobipocket / Kindle ebook (MOBI)",azw3:"Kindle KF8 ebook (AZW3)",fb2:"FictionBook (FB2)",doc:"Word 97-2003 document (DOC)",xls:"Excel 97-2003 workbook (XLS)",ppt:"PowerPoint 97-2003 presentation (PPT)"},MQ={".pdf":"pdf",".docx":"docx",".docm":"docx",".dotx":"docx",".pptx":"pptx",".pptm":"pptx",".ppsx":"pptx",".xlsx":"xlsx",".xlsm":"xlsx",".odt":"odt",".odp":"odp",".ods":"ods",".odg":"odg",".rtf":"rtf",".csv":"csv",".html":"html",".htm":"html",".xhtml":"html",".epub":"epub",".mobi":"mobi",".prc":"mobi",".azw":"mobi",".azw3":"azw3",".kf8":"azw3",".fb2":"fb2",".doc":"doc",".dot":"doc",".xls":"xls",".ppt":"ppt",".pps":"ppt"},E$={".djvu":"DjVu has no JavaScript reader.",".djv":"DjVu has no JavaScript reader.",".chm":"Compiled HTML Help (CHM) has no JavaScript reader.",".lit":"Microsoft Reader (LIT) has no JavaScript reader.",".lrf":"Sony BBeB (LRF) has no JavaScript reader.",".kfx":"KFX is Amazon's DRM-bound format and cannot be read.",".pages":"Apple Pages files have no JavaScript reader; export them as DOCX or PDF.",".key":"Apple Keynote files have no JavaScript reader; export them as PPTX or PDF.",".numbers":"Apple Numbers files have no JavaScript reader; export them as XLSX or CSV.",".xlsb":"Binary Excel workbooks (XLSB) are not read; save the workbook as XLSX.",".wps":"Microsoft Works documents are not read; save them as DOCX.",".cbz":"Comic archives are not read yet.",".cbr":"Comic archives are not read yet."},oJ=Object.keys(MQ);function EQ(Q,$){let J=WQ.extname(Q).toLowerCase(),q=E$[J];if(q)return{unsupported:q};let Z=Buffer.from($.subarray(0,512)).toString("latin1"),K=MQ[J];if(Z.startsWith("%PDF"))return{format:"pdf"};if(Z.startsWith("{\\rtf"))return{format:"rtf"};if(Z.slice(60,68)==="BOOKMOBI")return{format:K==="azw3"?"azw3":"mobi"};let H=Z.startsWith("PK\x03\x04"),Y=Z.startsWith("ÐÏ\x11ࡱ\x1Aá");if(H){if(Z.includes("mimetypeapplication/epub+zip"))return{format:"epub"};let X=/mimetypeapplication\/vnd\.oasis\.opendocument\.(text|presentation|spreadsheet|graphics)/.exec(Z);if(X)return{format:{text:"odt",presentation:"odp",spreadsheet:"ods",graphics:"odg"}[X[1]]};if(K&&["docx","pptx","xlsx","epub","odt","odp","ods","odg"].includes(K))return{format:K};if(K==="doc")return{format:"docx"};if(K==="xls")return{format:"xlsx"};if(K==="ppt")return{format:"pptx"}}if(Y){if(K==="doc"||K==="xls"||K==="ppt")return{format:K};if(K==="docx")return{format:"doc"};if(K==="xlsx")return{format:"xls"};if(K==="pptx")return{format:"ppt"};return{unsupported:"This is an OLE compound file, but its extension does not say which Office program wrote it; rename it to .doc, .xls or .ppt."}}if(K==="fb2"||/<FictionBook[\s>]/.test(Z))return{format:"fb2"};if(K==="html"||K==="csv")return{format:K};if(K)return{unsupported:`The file is named as ${M$[K]} but its contents are not; it may be damaged or a different format.`};return{unsupported:`No reader for ${J||"files without an extension"}. Readable: PDF, DOCX/DOC, PPTX/PPT, XLSX/XLS, ODT/ODP/ODS/ODG, RTF, CSV, HTML, EPUB, MOBI/AZW/AZW3, FB2.`}}import{existsSync as hQ,readFileSync as c$}from"node:fs";import{dirname as cQ,join as bQ}from"node:path";import{fileURLToPath as g$}from"node:url";class t{__destroy_into_raw(){let Q=this.__wbg_ptr;return this.__wbg_ptr=0,xQ.unregister(this),Q}free(){let Q=this.__destroy_into_raw();W.__wbg_wasmdocument_free(Q,0)}formatName(){let Q,$;try{let Z=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_formatName(Z,this.__wbg_ptr);var J=R().getInt32(Z+0,!0),q=R().getInt32(Z+4,!0);return Q=J,$=q,h(J,q)}finally{W.__wbindgen_add_to_stack_pointer(16),W.__wbindgen_export3(Q,$,1)}}constructor(Q,$){try{let K=W.__wbindgen_add_to_stack_pointer(-16),H=wQ(Q,W.__wbindgen_export),Y=E,X=r($,W.__wbindgen_export,W.__wbindgen_export2),B=E;W.wasmdocument_new(K,H,Y,X,B);var J=R().getInt32(K+0,!0),q=R().getInt32(K+4,!0),Z=R().getInt32(K+8,!0);if(Z)throw M(q);return this.__wbg_ptr=J,xQ.register(this,this.__wbg_ptr,this),this}finally{W.__wbindgen_add_to_stack_pointer(16)}}plainText(){let Q,$;try{let Z=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_plainText(Z,this.__wbg_ptr);var J=R().getInt32(Z+0,!0),q=R().getInt32(Z+4,!0);return Q=J,$=q,h(J,q)}finally{W.__wbindgen_add_to_stack_pointer(16),W.__wbindgen_export3(Q,$,1)}}toHtml(){let Q,$;try{let Z=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_toHtml(Z,this.__wbg_ptr);var J=R().getInt32(Z+0,!0),q=R().getInt32(Z+4,!0);return Q=J,$=q,h(J,q)}finally{W.__wbindgen_add_to_stack_pointer(16),W.__wbindgen_export3(Q,$,1)}}toIr(){try{let q=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_toIr(q,this.__wbg_ptr);var Q=R().getInt32(q+0,!0),$=R().getInt32(q+4,!0),J=R().getInt32(q+8,!0);if(J)throw M($);return M(Q)}finally{W.__wbindgen_add_to_stack_pointer(16)}}toMarkdownWithImages(){let Q,$;try{let Z=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_toMarkdownWithImages(Z,this.__wbg_ptr);var J=R().getInt32(Z+0,!0),q=R().getInt32(Z+4,!0);return Q=J,$=q,h(J,q)}finally{W.__wbindgen_add_to_stack_pointer(16),W.__wbindgen_export3(Q,$,1)}}toMarkdown(){let Q,$;try{let Z=W.__wbindgen_add_to_stack_pointer(-16);W.wasmdocument_toMarkdown(Z,this.__wbg_ptr);var J=R().getInt32(Z+0,!0),q=R().getInt32(Z+4,!0);return Q=J,$=q,h(J,q)}finally{W.__wbindgen_add_to_stack_pointer(16),W.__wbindgen_export3(Q,$,1)}}}if(Symbol.dispose)t.prototype[Symbol.dispose]=t.prototype.free;class UQ{__destroy_into_raw(){let Q=this.__wbg_ptr;return this.__wbg_ptr=0,_Q.unregister(this),Q}free(){let Q=this.__destroy_into_raw();W.__wbg_wasmeditabledocument_free(Q,0)}constructor(Q,$){try{let K=W.__wbindgen_add_to_stack_pointer(-16),H=wQ(Q,W.__wbindgen_export),Y=E,X=r($,W.__wbindgen_export,W.__wbindgen_export2),B=E;W.wasmeditabledocument_new(K,H,Y,X,B);var J=R().getInt32(K+0,!0),q=R().getInt32(K+4,!0),Z=R().getInt32(K+8,!0);if(Z)throw M(q);return this.__wbg_ptr=J,_Q.register(this,this.__wbg_ptr,this),this}finally{W.__wbindgen_add_to_stack_pointer(16)}}replaceText(Q,$){try{let K=W.__wbindgen_add_to_stack_pointer(-16),H=r(Q,W.__wbindgen_export,W.__wbindgen_export2),Y=E,X=r($,W.__wbindgen_export,W.__wbindgen_export2),B=E;W.wasmeditabledocument_replaceText(K,this.__wbg_ptr,H,Y,X,B);var J=R().getInt32(K+0,!0),q=R().getInt32(K+4,!0),Z=R().getInt32(K+8,!0);if(Z)throw M(q);return J>>>0}finally{W.__wbindgen_add_to_stack_pointer(16)}}toBytes(){try{let K=W.__wbindgen_add_to_stack_pointer(-16);W.wasmeditabledocument_toBytes(K,this.__wbg_ptr);var Q=R().getInt32(K+0,!0),$=R().getInt32(K+4,!0),J=R().getInt32(K+8,!0),q=R().getInt32(K+12,!0);if(q)throw M(J);var Z=w$(Q,$).slice();return W.__wbindgen_export3(Q,$*1,1),Z}finally{W.__wbindgen_add_to_stack_pointer(16)}}}if(Symbol.dispose)UQ.prototype[Symbol.dispose]=UQ.prototype.free;function x$(){return{__proto__:null,"./office_oxide_bg.js":{__proto__:null,__wbg_Error_67e7344beaa85059:function($,J){let q=Error(h($,J));return y(q)},__wbg_String_8564e559799eccda:function($,J){let q=String(s(J)),Z=r(q,W.__wbindgen_export,W.__wbindgen_export2),K=E;R().setInt32($+4,K,!0),R().setInt32($+0,Z,!0)},__wbg___wbindgen_throw_5d9e815e6fdf150f:function($,J){throw Error(h($,J))},__wbg_new_bebc3f4757acf305:function(){return y({})},__wbg_new_ffa92086ea89f79c:function(){return y([])},__wbg_set_13d25b81ab403f5e:function($,J,q){s($)[J>>>0]=M(q)},__wbg_set_6be42768c690e380:function($,J,q){s($)[M(J)]=M(q)},__wbindgen_generic_0000000000000001:function($){return y($)},__wbindgen_generic_0000000000000002:function($){return y($)},__wbindgen_generic_0000000000000003:function($,J){let q=h($,J);return y(q)},__wbindgen_generic_0000000000000004:function($){let J=BigInt.asUintN(64,$);return y(J)},__wbindgen_object_clone_ref:function($){let J=s($);return y(J)},__wbindgen_object_drop_ref:function($){M($)}}}}var xQ=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((Q)=>W.__wbg_wasmdocument_free(Q,1)),_Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((Q)=>W.__wbg_wasmeditabledocument_free(Q,1));function y(Q){if(o===_.length)_.push(_.length+1);let $=o;return o=_[$],_[$]=Q,$}function _$(Q){if(Q<1028)return;_[Q]=o,o=Q}function w$(Q,$){return Q=Q>>>0,g().subarray(Q/1,Q/1+$)}var c=null;function R(){if(c===null||c.buffer.detached===!0||c.buffer.detached===void 0&&c.buffer!==W.memory.buffer)c=new DataView(W.memory.buffer);return c}function h(Q,$){return h$(Q>>>0,$)}var n=null;function g(){if(n===null||n.byteLength===0)n=new Uint8Array(W.memory.buffer);return n}function s(Q){return _[Q]}var _=Array(1024).fill(void 0);_.push(void 0,null,!0,!1);var o=_.length;function wQ(Q,$){let J=$(Q.length*1,1)>>>0;return g().set(Q,J/1),E=Q.length,J}function r(Q,$,J){if(J===void 0){let Y=a.encode(Q),X=$(Y.length,1)>>>0;return g().subarray(X,X+Y.length).set(Y),E=Y.length,X}let q=Q.length,Z=$(q,1)>>>0,K=g(),H=0;for(;H<q;H++){let Y=Q.charCodeAt(H);if(Y>127)break;K[Z+H]=Y}if(H!==q){if(H!==0)Q=Q.slice(H);Z=J(Z,q,q=H+Q.length*3,1)>>>0;let Y=g().subarray(Z+H,Z+q),X=a.encodeInto(Q,Y);H+=X.written,Z=J(Z,q,H,1)>>>0}return E=H,Z}function M(Q){let $=s(Q);return _$(Q),$}var qQ=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qQ.decode();var y$=2146435072,GQ=0;function h$(Q,$){if(GQ+=$,GQ>=y$)qQ=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qQ.decode(),GQ=$;return qQ.decode(g().subarray(Q,Q+$))}var a=new TextEncoder;if(!("encodeInto"in a))a.encodeInto=function(Q,$){let J=a.encode(Q);return $.set(J),{read:Q.length,written:J.length}};var E=0,b$,f$,W;function u$(Q,$){return f$=Q,W=Q.exports,b$=$,c=null,n=null,W}function yQ(Q){if(W!==void 0)return W;if(Q!==void 0)if(Object.getPrototypeOf(Q)===Object.prototype)({module:Q}=Q);else console.warn("using deprecated parameters for `initSync()`; pass a single object instead");let $=x$();if(!(Q instanceof WebAssembly.Module))Q=new WebAssembly.Module(Q);let J=new WebAssembly.Instance(Q,$);return u$(J,Q)}var fQ="office_oxide_bg.wasm",uQ=!1;function l$(Q=m$()){let $=bQ(Q,"office-oxide",fQ);if(hQ($))return $;let J=Q;for(let q=0;q<7;q++){let Z=bQ(J,"assets","office-oxide",fQ);if(hQ(Z))return Z;let K=cQ(J);if(K===J)break;J=K}return}function m$(){try{return cQ(g$(import.meta.url))}catch{return"."}}function gQ(Q,$){if(!uQ){let J=l$();if(!J)throw Error("The reader for Word, Excel and PowerPoint 97-2003 files is missing from this installation (office_oxide_bg.wasm was not found).");yQ({module:c$(J)}),uQ=!0}return new t(Q,$)}var p$=/\[image-base64:([A-Za-z0-9+/=\s]+)\]/g;function d$(Q){return Q.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"")}function i$(Q,$){let J=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),q=$+8;while(q+12<=Q.length){let Z=J.getUint32(q),K=String.fromCharCode(...Q.subarray(q+4,q+8));if(q+=12+Z,K==="IEND")return q-$;if(Z>Q.length)return}return}function n$(Q,$){let J=$+2;while(J+4<=Q.length){if(Q[J]!==255)return;let q=Q[J+1];if(q===217)return J+2-$;if(q===218){J+=2+(Q[J+2]<<8|Q[J+3]);while(J+1<Q.length){if(Q[J]===255){let Z=Q[J+1];if(Z===217)return J+2-$;if(Z!==0&&(Z<208||Z>215))break}J++}continue}J+=2+(Q[J+2]<<8|Q[J+3])}return}async function s$(Q){let $=await import("cfb"),J=$.default??$,q;try{q=J.read(Buffer.from(Q),{type:"buffer"})}catch{return[]}let Z=[];for(let K of q.FileIndex){let H=K.content;if(K.type!==2||!H||H.length<64)continue;let Y=H instanceof Uint8Array?H:new Uint8Array(H);for(let X=0;X+8<Y.length;X++){let B;if(Y[X]===137&&Y[X+1]===80&&Y[X+2]===78&&Y[X+3]===71)B=i$(Y,X);else if(Y[X]===255&&Y[X+1]===216&&Y[X+2]===255)B=n$(Y,X);if(B&&B>64&&X+B<=Y.length)Z.push(Y.slice(X,X+B)),X+=B-1}}return Z}async function lQ(Q,$,J){let q=gQ(Q,$),Z;try{Z=q.toMarkdownWithImages()}finally{q.free()}let K=0;Z=Z.replace(p$,(Y,X)=>{if(!J.wantImages)return"";K++;let B=J.images.add({data:Buffer.from(X.replace(/\s/g,""),"base64"),stem:`${$}-image-${K}`});return B?x(B):""}),Z=d$(Z).replace(/\n{3,}/g,`
4
-
5
- `).trim();let H=[];if(J.wantImages&&$==="doc"){let Y=[];for(let X of await s$(Q)){let B=J.images.images.length;K++;let F=J.images.add({data:X,stem:`${$}-image-${K}`});if(F&&J.images.images.length>B)Y.push(x(F))}if(Y.length)Z+=`
1
+ import{createRequire as nh}from"node:module";var Yc=Object.create;var{getPrototypeOf:Jc,defineProperty:ys,getOwnPropertyNames:Qc}=Object;var ws=Object.prototype.hasOwnProperty;function eh(e){return this[e]}var th,rh,bs=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var i=t?th??=new WeakMap:rh??=new WeakMap,a=i.get(e);if(a)return a}r=e!=null?Yc(Jc(e)):{};let s=t||!e||!e.__esModule||!ws.call(e,"default")?ys(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let o of Qc(e))if(!ws.call(s,o))ys(s,o,{get:eh.bind(e,o),enumerable:!0})}if(n)i.set(e,s);return s};var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var pi=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var Ee=nh(import.meta.url);var xs=I(function(un){(function(e){e.parser=function(u,f){return new r(u,f)},e.SAXParser=r,e.SAXStream=c,e.createStream=h,e.MAX_BUFFER_LENGTH=65536;var t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(u,f){if(!(this instanceof r))return new r(u,f);var y=this;if(i(y),y.q=y.c="",y.bufferCheckPosition=e.MAX_BUFFER_LENGTH,y.encoding=null,y.opt=f||{},y.opt.lowercase=y.opt.lowercase||y.opt.lowercasetags,y.looseCase=y.opt.lowercase?"toLowerCase":"toUpperCase",y.opt.maxEntityCount=y.opt.maxEntityCount||512,y.opt.maxEntityDepth=y.opt.maxEntityDepth||4,y.entityCount=y.entityDepth=0,y.tags=[],y.closed=y.closedRoot=y.sawRoot=!1,y.tag=y.error=null,y.strict=!!u,y.noscript=!!(u||y.opt.noscript),y.state=d.BEGIN,y.strictEntities=y.opt.strictEntities,y.ENTITIES=y.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),y.attribList=[],y.opt.xmlns)y.ns=Object.create(v);if(y.opt.unquotedAttributeValues===void 0)y.opt.unquotedAttributeValues=!u;if(y.trackPosition=y.opt.position!==!1,y.trackPosition)y.position=y.line=y.column=0;E(y,"onready")}if(!Object.create)Object.create=function(u){function f(){}f.prototype=u;var y=new f;return y};if(!Object.keys)Object.keys=function(u){var f=[];for(var y in u)if(u.hasOwnProperty(y))f.push(y);return f};function n(u){var f=Math.max(e.MAX_BUFFER_LENGTH,10),y=0;for(var g=0,j=t.length;g<j;g++){var K=u[t[g]].length;if(K>f)switch(t[g]){case"textNode":ne(u);break;case"cdata":N(u,"oncdata",u.cdata),u.cdata="";break;case"script":N(u,"onscript",u.script),u.script="";break;default:ee(u,"Max buffer length exceeded: "+t[g])}y=Math.max(y,K)}var te=e.MAX_BUFFER_LENGTH-y;u.bufferCheckPosition=te+u.position}function i(u){for(var f=0,y=t.length;f<y;f++)u[t[f]]=""}function a(u){if(ne(u),u.cdata!=="")N(u,"oncdata",u.cdata),u.cdata="";if(u.script!=="")N(u,"onscript",u.script),u.script=""}r.prototype={end:function(){on(this)},write:ln,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var s;try{s=Ee("stream").Stream}catch(u){s=function(){}}if(!s)s=function(){};var o=e.EVENTS.filter(function(u){return u!=="error"&&u!=="end"});function h(u,f){return new c(u,f)}function l(u,f){if(u.length>=2){if(u[0]===255&&u[1]===254)return"utf-16le";if(u[0]===254&&u[1]===255)return"utf-16be"}if(u.length>=3&&u[0]===239&&u[1]===187&&u[2]===191)return"utf8";if(u.length>=4){if(u[0]===60&&u[1]===0&&u[2]===63&&u[3]===0)return"utf-16le";if(u[0]===0&&u[1]===60&&u[2]===0&&u[3]===63)return"utf-16be";return"utf8"}return f?"utf8":null}function c(u,f){if(!(this instanceof c))return new c(u,f);s.apply(this),this._parser=new r(u,f),this.writable=!0,this.readable=!0;var y=this;this._parser.onend=function(){y.emit("end")},this._parser.onerror=function(g){y.emit("error",g),y._parser.error=null},this._decoder=null,this._decoderBuffer=null,o.forEach(function(g){Object.defineProperty(y,"on"+g,{get:function(){return y._parser["on"+g]},set:function(j){if(!j)return y.removeAllListeners(g),y._parser["on"+g]=j,j;y.on(g,j)},enumerable:!0,configurable:!1})})}c.prototype=Object.create(s.prototype,{constructor:{value:c}}),c.prototype._decodeBuffer=function(u,f){if(this._decoderBuffer)u=Buffer.concat([this._decoderBuffer,u]),this._decoderBuffer=null;if(!this._decoder){var y=l(u,f);if(!y)return this._decoderBuffer=u,"";this._parser.encoding=y,this._decoder=new TextDecoder(y)}return this._decoder.decode(u,{stream:!f})},c.prototype.write=function(u){if(typeof Buffer==="function"&&typeof Buffer.isBuffer==="function"&&Buffer.isBuffer(u))u=this._decodeBuffer(u,!1);else if(this._decoderBuffer){var f=this._decodeBuffer(Buffer.alloc(0),!0);if(f)this._parser.write(f),this.emit("data",f)}return this._parser.write(u.toString()),this.emit("data",u),!0},c.prototype.end=function(u){if(u&&u.length)this.write(u);if(this._decoderBuffer){var f=this._decodeBuffer(Buffer.alloc(0),!0);if(f)this._parser.write(f),this.emit("data",f)}else if(this._decoder){var y=this._decoder.decode();if(y)this._parser.write(y),this.emit("data",y)}return this._parser.end(),!0},c.prototype.on=function(u,f){var y=this;if(!y._parser["on"+u]&&o.indexOf(u)!==-1)y._parser["on"+u]=function(){var g=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);g.splice(0,0,u),y.emit.apply(y,g)};return s.prototype.on.call(y,u,f)};var p=/^\[CDATA\[$/i,m=/^DOCTYPE$/i,_="http://www.w3.org/XML/1998/namespace",w="http://www.w3.org/2000/xmlns/",v={xml:_,xmlns:w},b=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,S=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,T=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,k=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(u){return u===" "||u===`
2
+ `||u==="\r"||u==="\t"}function A(u){return u==='"'||u==="'"}function O(u){return u===">"||x(u)}function C(u,f){return u.test(f)}function D(u,f){return!C(u,f)}var d=0;e.STATE={BEGIN:d++,BEGIN_WHITESPACE:d++,TEXT:d++,TEXT_ENTITY:d++,OPEN_WAKA:d++,SGML_DECL:d++,SGML_DECL_QUOTED:d++,DOCTYPE:d++,DOCTYPE_QUOTED:d++,DOCTYPE_DTD:d++,DOCTYPE_DTD_QUOTED:d++,COMMENT_STARTING:d++,COMMENT:d++,COMMENT_ENDING:d++,COMMENT_ENDED:d++,CDATA:d++,CDATA_ENDING:d++,CDATA_ENDING_2:d++,PROC_INST:d++,PROC_INST_BODY:d++,PROC_INST_ENDING:d++,OPEN_TAG:d++,OPEN_TAG_SLASH:d++,ATTRIB:d++,ATTRIB_NAME:d++,ATTRIB_NAME_SAW_WHITE:d++,ATTRIB_VALUE:d++,ATTRIB_VALUE_QUOTED:d++,ATTRIB_VALUE_CLOSED:d++,ATTRIB_VALUE_UNQUOTED:d++,ATTRIB_VALUE_ENTITY_Q:d++,ATTRIB_VALUE_ENTITY_U:d++,CLOSE_TAG:d++,CLOSE_TAG_SAW_WHITE:d++,SCRIPT:d++,SCRIPT_ENDING:d++},e.XML_ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'"}),e.ENTITIES=Object.assign(Object.create(null),{amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830}),Object.keys(e.ENTITIES).forEach(function(u){var f=e.ENTITIES[u],y=typeof f==="number"?String.fromCharCode(f):f;e.ENTITIES[u]=y});for(var R in e.STATE)e.STATE[e.STATE[R]]=R;d=e.STATE;function E(u,f,y){u[f]&&u[f](y)}function B(u){var f=u&&u.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return f?f[2]:null}function G(u){if(!u)return null;return u.toLowerCase().replace(/[^a-z0-9]/g,"")}function V(u,f){let y=G(u),g=G(f);if(!y||!g)return!0;if(g==="utf16")return y==="utf16le"||y==="utf16be";return y===g}function Ie(u,f){if(!u.strict||!u.encoding||!f||f.name!=="xml")return;var y=B(f.body);if(y&&!V(u.encoding,y))U(u,"XML declaration encoding "+y+" does not match detected stream encoding "+u.encoding.toUpperCase())}function N(u,f,y){if(u.textNode)ne(u);E(u,f,y)}function ne(u){if(u.textNode=ue(u.opt,u.textNode),u.textNode)E(u,"ontext",u.textNode);u.textNode=""}function ue(u,f){if(u.trim)f=f.trim();if(u.normalize)f=f.replace(/\s+/g," ");return f}function ee(u,f){if(ne(u),u.trackPosition)f+=`
3
+ Line: `+u.line+`
4
+ Column: `+u.column+`
5
+ Char: `+u.c;return f=Error(f),u.error=f,E(u,"onerror",f),u}function on(u){if(u.sawRoot&&!u.closedRoot)U(u,"Unclosed root tag");if(u.state!==d.BEGIN&&u.state!==d.BEGIN_WHITESPACE&&u.state!==d.TEXT)ee(u,"Unexpected end");return ne(u),u.c="",u.closed=!0,E(u,"onend"),r.call(u,u.strict,u.opt),u}function U(u,f){if(typeof u!=="object"||!(u instanceof r))throw Error("bad call to strictFail");if(u.strict)ee(u,f)}function hr(u){if(!u.strict)u.tagName=u.tagName[u.looseCase]();var f=u.tags[u.tags.length-1]||u,y=u.tag={name:u.tagName,attributes:{}};if(u.opt.xmlns)y.ns=f.ns;u.attribList.length=0,N(u,"onopentagstart",y)}function Ce(u,f){var y=u.indexOf(":"),g=y<0?["",u]:u.split(":"),j=g[0],K=g[1];if(f&&u==="xmlns")j="xmlns",K="";return{prefix:j,local:K}}function Ct(u){if(!u.strict)u.attribName=u.attribName[u.looseCase]();if(u.attribList.indexOf(u.attribName)!==-1||u.tag.attributes.hasOwnProperty(u.attribName)){u.attribName=u.attribValue="";return}if(u.opt.xmlns){var f=Ce(u.attribName,!0),{prefix:y,local:g}=f;if(y==="xmlns")if(g==="xml"&&u.attribValue!==_)U(u,"xml: prefix must be bound to "+_+`
6
+ Actual: `+u.attribValue);else if(g==="xmlns"&&u.attribValue!==w)U(u,"xmlns: prefix must be bound to "+w+`
7
+ Actual: `+u.attribValue);else{var j=u.tag,K=u.tags[u.tags.length-1]||u;if(j.ns===K.ns)j.ns=Object.create(K.ns);j.ns[g]=u.attribValue}u.attribList.push([u.attribName,u.attribValue])}else u.tag.attributes[u.attribName]=u.attribValue,N(u,"onattribute",{name:u.attribName,value:u.attribValue});u.attribName=u.attribValue=""}function pe(u,f){if(u.opt.xmlns){var y=u.tag,g=Ce(u.tagName);if(y.prefix=g.prefix,y.local=g.local,y.uri=y.ns[g.prefix]||"",y.prefix&&!y.uri)U(u,"Unbound namespace prefix: "+JSON.stringify(u.tagName)),y.uri=g.prefix;var j=u.tags[u.tags.length-1]||u;if(y.ns&&j.ns!==y.ns)Object.keys(y.ns).forEach(function(_s){N(u,"onopennamespace",{prefix:_s,uri:y.ns[_s]})});for(var K=0,te=u.attribList.length;K<te;K++){var ce=u.attribList[K],he=ce[0],je=ce[1],ae=Ce(he,!0),{prefix:qe,local:Kc}=ae,vs=qe===""?"":y.ns[qe]||"",di={name:he,value:je,prefix:qe,local:Kc,uri:vs};if(qe&&qe!=="xmlns"&&!vs)U(u,"Unbound namespace prefix: "+JSON.stringify(qe)),di.uri=qe;u.tag.attributes[he]=di,N(u,"onattribute",di)}u.attribList.length=0}if(u.tag.isSelfClosing=!!f,u.sawRoot=!0,u.tags.push(u.tag),N(u,"onopentag",u.tag),!f){if(!u.noscript&&u.tagName.toLowerCase()==="script")u.state=d.SCRIPT;else u.state=d.TEXT;u.tag=null,u.tagName=""}u.attribName=u.attribValue="",u.attribList.length=0}function ht(u){if(!u.tagName){U(u,"Weird empty close tag."),u.textNode+="</>",u.state=d.TEXT;return}if(u.script){if(u.tagName!=="script"){u.script+="</"+u.tagName+">",u.tagName="",u.state=d.SCRIPT;return}N(u,"onscript",u.script),u.script=""}var f=u.tags.length,y=u.tagName;if(!u.strict)y=y[u.looseCase]();var g=y;while(f--){var j=u.tags[f];if(j.name!==g)U(u,"Unexpected close tag");else break}if(f<0){U(u,"Unmatched closing tag: "+u.tagName),u.textNode+="</"+u.tagName+">",u.state=d.TEXT;return}u.tagName=y;var K=u.tags.length;while(K-- >f){var te=u.tag=u.tags.pop();u.tagName=u.tag.name,N(u,"onclosetag",u.tagName);var ce={};for(var he in te.ns)ce[he]=te.ns[he];var je=u.tags[u.tags.length-1]||u;if(u.opt.xmlns&&te.ns!==je.ns)Object.keys(te.ns).forEach(function(ae){var qe=te.ns[ae];N(u,"onclosenamespace",{prefix:ae,uri:qe})})}if(f===0)u.closedRoot=!0;u.tagName=u.attribValue=u.attribName="",u.attribList.length=0,u.state=d.TEXT}function dr(u){var f=u.entity,y=f.toLowerCase(),g,j="";if(u.ENTITIES[f])return u.ENTITIES[f];if(u.ENTITIES[y])return u.ENTITIES[y];if(f=y,f.charAt(0)==="#")if(f.charAt(1)==="x")f=f.slice(2),g=parseInt(f,16),j=g.toString(16);else f=f.slice(1),g=parseInt(f,10),j=g.toString(10);if(f=f.replace(/^0+/,""),isNaN(g)||j.toLowerCase()!==f||g<0||g>1114111||!fn(g))return U(u,"Invalid character entity"),"&"+u.entity+";";return String.fromCodePoint(g)}function fn(u){return u===9||u===10||u===13||u>=32&&u<=55295||u>=57344&&u<=65533||u>=65536&&u<=1114111}function pr(u,f){if(f==="<")u.state=d.OPEN_WAKA,u.startTagPosition=u.position;else if(!x(f))U(u,"Non-whitespace before first tag."),u.textNode=f,u.state=d.TEXT}function gr(u,f){var y="";if(f<u.length)y=u.charAt(f);return y}function ln(u){var f=this;if(this.error)throw this.error;if(f.closed)return ee(f,"Cannot write after close. Assign an onready handler.");if(u===null)return on(f);if(typeof u==="object")u=u.toString();var y=0,g="";while(!0){if(g=gr(u,y++),f.c=g,!g)break;if(f.trackPosition)if(f.position++,g===`
8
+ `)f.line++,f.column=0;else f.column++;switch(f.state){case d.BEGIN:if(f.state=d.BEGIN_WHITESPACE,g==="\uFEFF")continue;pr(f,g);continue;case d.BEGIN_WHITESPACE:pr(f,g);continue;case d.TEXT:if(f.sawRoot&&!f.closedRoot){var K=y-1;while(g&&g!=="<"&&g!=="&")if(g=gr(u,y++),g&&f.trackPosition)if(f.position++,g===`
9
+ `)f.line++,f.column=0;else f.column++;f.textNode+=u.substring(K,y-1)}if(g==="<"&&!(f.sawRoot&&f.closedRoot&&!f.strict))f.state=d.OPEN_WAKA,f.startTagPosition=f.position;else{if(!x(g)&&(!f.sawRoot||f.closedRoot))U(f,"Text data outside of root node.");if(g==="&")f.state=d.TEXT_ENTITY;else f.textNode+=g}continue;case d.SCRIPT:if(g==="<")f.state=d.SCRIPT_ENDING;else f.script+=g;continue;case d.SCRIPT_ENDING:if(g==="/")f.state=d.CLOSE_TAG;else f.script+="<"+g,f.state=d.SCRIPT;continue;case d.OPEN_WAKA:if(g==="!")f.state=d.SGML_DECL,f.sgmlDecl="";else if(x(g));else if(C(b,g))f.state=d.OPEN_TAG,f.tagName=g;else if(g==="/")f.state=d.CLOSE_TAG,f.tagName="";else if(g==="?")f.state=d.PROC_INST,f.procInstName=f.procInstBody="";else{if(U(f,"Unencoded <"),f.startTagPosition+1<f.position){var j=f.position-f.startTagPosition;g=Array(j).join(" ")+g}f.textNode+="<"+g,f.state=d.TEXT}continue;case d.SGML_DECL:if(f.sgmlDecl+g==="--"){f.state=d.COMMENT,f.comment="",f.sgmlDecl="";continue}if(f.doctype&&f.doctype!==!0&&f.sgmlDecl)f.state=d.DOCTYPE_DTD,f.doctype+="<!"+f.sgmlDecl+g,f.sgmlDecl="";else if(p.test(f.sgmlDecl+g))N(f,"onopencdata"),f.state=d.CDATA,f.sgmlDecl="",f.cdata="";else if(m.test(f.sgmlDecl+g)){if(f.state=d.DOCTYPE,f.doctype||f.sawRoot)U(f,"Inappropriately located doctype declaration");f.doctype="",f.sgmlDecl=""}else if(g===">")N(f,"onsgmldeclaration",f.sgmlDecl),f.sgmlDecl="",f.state=d.TEXT;else if(A(g))f.state=d.SGML_DECL_QUOTED,f.sgmlDecl+=g;else f.sgmlDecl+=g;continue;case d.SGML_DECL_QUOTED:if(g===f.q)f.state=d.SGML_DECL,f.q="";f.sgmlDecl+=g;continue;case d.DOCTYPE:if(g===">")f.state=d.TEXT,N(f,"ondoctype",f.doctype),f.doctype=!0;else if(f.doctype+=g,g==="[")f.state=d.DOCTYPE_DTD;else if(A(g))f.state=d.DOCTYPE_QUOTED,f.q=g;continue;case d.DOCTYPE_QUOTED:if(f.doctype+=g,g===f.q)f.q="",f.state=d.DOCTYPE;continue;case d.DOCTYPE_DTD:if(g==="]")f.doctype+=g,f.state=d.DOCTYPE;else if(g==="<")f.state=d.OPEN_WAKA,f.startTagPosition=f.position;else if(A(g))f.doctype+=g,f.state=d.DOCTYPE_DTD_QUOTED,f.q=g;else f.doctype+=g;continue;case d.DOCTYPE_DTD_QUOTED:if(f.doctype+=g,g===f.q)f.state=d.DOCTYPE_DTD,f.q="";continue;case d.COMMENT:if(g==="-")f.state=d.COMMENT_ENDING;else f.comment+=g;continue;case d.COMMENT_ENDING:if(g==="-"){if(f.state=d.COMMENT_ENDED,f.comment=ue(f.opt,f.comment),f.comment)N(f,"oncomment",f.comment);f.comment=""}else f.comment+="-"+g,f.state=d.COMMENT;continue;case d.COMMENT_ENDED:if(g!==">")U(f,"Malformed comment"),f.comment+="--"+g,f.state=d.COMMENT;else if(f.doctype&&f.doctype!==!0)f.state=d.DOCTYPE_DTD;else f.state=d.TEXT;continue;case d.CDATA:var K=y-1;while(g&&g!=="]")if(g=gr(u,y++),g&&f.trackPosition)if(f.position++,g===`
10
+ `)f.line++,f.column=0;else f.column++;if(f.cdata+=u.substring(K,y-1),g==="]")f.state=d.CDATA_ENDING;continue;case d.CDATA_ENDING:if(g==="]")f.state=d.CDATA_ENDING_2;else f.cdata+="]"+g,f.state=d.CDATA;continue;case d.CDATA_ENDING_2:if(g===">"){if(f.cdata)N(f,"oncdata",f.cdata);N(f,"onclosecdata"),f.cdata="",f.state=d.TEXT}else if(g==="]")f.cdata+="]";else f.cdata+="]]"+g,f.state=d.CDATA;continue;case d.PROC_INST:if(g==="?")f.state=d.PROC_INST_ENDING;else if(x(g))f.state=d.PROC_INST_BODY;else f.procInstName+=g;continue;case d.PROC_INST_BODY:if(!f.procInstBody&&x(g))continue;else if(g==="?")f.state=d.PROC_INST_ENDING;else f.procInstBody+=g;continue;case d.PROC_INST_ENDING:if(g===">"){let je={name:f.procInstName,body:f.procInstBody};Ie(f,je),N(f,"onprocessinginstruction",je),f.procInstName=f.procInstBody="",f.state=d.TEXT}else f.procInstBody+="?"+g,f.state=d.PROC_INST_BODY;continue;case d.OPEN_TAG:if(C(S,g))f.tagName+=g;else if(hr(f),g===">")pe(f);else if(g==="/")f.state=d.OPEN_TAG_SLASH;else{if(!x(g))U(f,"Invalid character in tag name");f.state=d.ATTRIB}continue;case d.OPEN_TAG_SLASH:if(g===">")pe(f,!0),ht(f);else U(f,"Forward-slash in opening tag not followed by >"),f.state=d.ATTRIB;continue;case d.ATTRIB:if(x(g))continue;else if(g===">")pe(f);else if(g==="/")f.state=d.OPEN_TAG_SLASH;else if(C(b,g))f.attribName=g,f.attribValue="",f.state=d.ATTRIB_NAME;else U(f,"Invalid attribute name");continue;case d.ATTRIB_NAME:if(g==="=")f.state=d.ATTRIB_VALUE;else if(g===">")U(f,"Attribute without value"),f.attribValue=f.attribName,Ct(f),pe(f);else if(x(g))f.state=d.ATTRIB_NAME_SAW_WHITE;else if(C(S,g))f.attribName+=g;else U(f,"Invalid attribute name");continue;case d.ATTRIB_NAME_SAW_WHITE:if(g==="=")f.state=d.ATTRIB_VALUE;else if(x(g))continue;else if(U(f,"Attribute without value"),f.tag.attributes[f.attribName]="",f.attribValue="",N(f,"onattribute",{name:f.attribName,value:""}),f.attribName="",g===">")pe(f);else if(C(b,g))f.attribName=g,f.state=d.ATTRIB_NAME;else U(f,"Invalid attribute name"),f.state=d.ATTRIB;continue;case d.ATTRIB_VALUE:if(x(g))continue;else if(A(g))f.q=g,f.state=d.ATTRIB_VALUE_QUOTED;else{if(!f.opt.unquotedAttributeValues)ee(f,"Unquoted attribute value");f.state=d.ATTRIB_VALUE_UNQUOTED,f.attribValue=g}continue;case d.ATTRIB_VALUE_QUOTED:if(g!==f.q){if(g==="&")f.state=d.ATTRIB_VALUE_ENTITY_Q;else f.attribValue+=g;continue}Ct(f),f.q="",f.state=d.ATTRIB_VALUE_CLOSED;continue;case d.ATTRIB_VALUE_CLOSED:if(x(g))f.state=d.ATTRIB;else if(g===">")pe(f);else if(g==="/")f.state=d.OPEN_TAG_SLASH;else if(C(b,g))U(f,"No whitespace between attributes"),f.attribName=g,f.attribValue="",f.state=d.ATTRIB_NAME;else U(f,"Invalid attribute name");continue;case d.ATTRIB_VALUE_UNQUOTED:if(!O(g)){if(g==="&")f.state=d.ATTRIB_VALUE_ENTITY_U;else f.attribValue+=g;continue}if(Ct(f),g===">")pe(f);else f.state=d.ATTRIB;continue;case d.CLOSE_TAG:if(!f.tagName)if(x(g))continue;else if(D(b,g))if(f.script)f.script+="</"+g,f.state=d.SCRIPT;else U(f,"Invalid tagname in closing tag.");else f.tagName=g;else if(g===">")ht(f);else if(C(S,g))f.tagName+=g;else if(f.script)f.script+="</"+f.tagName+g,f.tagName="",f.state=d.SCRIPT;else{if(!x(g))U(f,"Invalid tagname in closing tag");f.state=d.CLOSE_TAG_SAW_WHITE}continue;case d.CLOSE_TAG_SAW_WHITE:if(x(g))continue;if(g===">")ht(f);else U(f,"Invalid characters in closing tag");continue;case d.TEXT_ENTITY:case d.ATTRIB_VALUE_ENTITY_Q:case d.ATTRIB_VALUE_ENTITY_U:var te,ce;switch(f.state){case d.TEXT_ENTITY:te=d.TEXT,ce="textNode";break;case d.ATTRIB_VALUE_ENTITY_Q:te=d.ATTRIB_VALUE_QUOTED,ce="attribValue";break;case d.ATTRIB_VALUE_ENTITY_U:te=d.ATTRIB_VALUE_UNQUOTED,ce="attribValue";break}if(g===";"){var he=dr(f);if(f.opt.unparsedEntities&&!Object.values(e.XML_ENTITIES).includes(he)){if((f.entityCount+=1)>f.opt.maxEntityCount)ee(f,"Parsed entity count exceeds max entity count");if((f.entityDepth+=1)>f.opt.maxEntityDepth)ee(f,"Parsed entity depth exceeds max entity depth");f.entity="",f.state=te,f.write(he),f.entityDepth-=1}else f[ce]+=he,f.entity="",f.state=te}else if(C(f.entity.length?k:T,g))f.entity+=g;else U(f,"Invalid character in entity name"),f[ce]+="&"+f.entity+g,f.entity="",f.state=te;continue;default:throw Error(f,"Unknown state: "+f.state)}}if(f.position>=f.bufferCheckPosition)n(f);return f}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint)(function(){var u=String.fromCharCode,f=Math.floor,y=function(){var g=16384,j=[],K,te,ce=-1,he=arguments.length;if(!he)return"";var je="";while(++ce<he){var ae=Number(arguments[ce]);if(!isFinite(ae)||ae<0||ae>1114111||f(ae)!==ae)throw RangeError("Invalid code point: "+ae);if(ae<=65535)j.push(ae);else ae-=65536,K=(ae>>10)+55296,te=ae%1024+56320,j.push(K,te);if(ce+1===he||j.length>g)je+=u.apply(null,j),j.length=0}return je};if(Object.defineProperty)Object.defineProperty(String,"fromCodePoint",{value:y,configurable:!0,writable:!0});else String.fromCodePoint=y})()})(typeof un>"u"?un.sax={}:un)});import Ts,{resolve as ch,basename as hh,extname as dh,dirname as ph}from"node:path";import{EventEmitter as gh}from"events";function mh(...e){return ch(...e)}function vh(e,t){return hh(e,t)}function _h(e){return dh(e)}function yh(e){return ph(e)}function wh(e){return Ts.posix.isAbsolute(e)}function bh(...e){return Ts.posix.join(...e)}function Th(e){if(e.charCodeAt(0)===65279)return e.slice(1);return e}function Sh(e){return e.toLowerCase()}function kh(e){return typeof e==="object"&&e!==null&&Object.keys(e).length===0}function cn(e,t,r){for(let n of e)t=n(t,r);return t}function Dt(e,t,r){let n=Object.create(null);n.value=r,n.writable=!0,n.enumerable=!0,n.configurable=!0,Object.defineProperty(e,t,n)}function Ah(e,t){let r={};if(typeof t==="object")r=t;return new ks(r).parseStringPromise(e)}async function Ot(e,t={}){return await Ah(e,t)}function hn(e){return e.replace(/-([a-z])/gi,(t)=>t[1].toUpperCase())}var Ss,J,xh,Eh=(e,t,r)=>(t in e)?xh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ve=(e,t,r)=>Eh(e,typeof t!=="symbol"?t+"":t,r),Es,ks;var As=pi(()=>{Ss=bs(xs(),1);J={resolve:mh,basename:vh,extname:_h,dirname:yh,isAbsolutePosix:wh,joinPosix:bh},xh=Object.defineProperty;Es={0.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},0.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
11
+ `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}};ks=class ks extends gh{constructor(e){super();if(ve(this,"options"),ve(this,"remaining",""),ve(this,"saxParser"),ve(this,"resultObject",null),ve(this,"EXPLICIT_CHARKEY"),ve(this,"errThrown",!1),ve(this,"ended",!1),ve(this,"processAsync",()=>{try{if(this.remaining.length<=this.options.chunkSize){let t=this.remaining;this.remaining="",this.saxParser=this.saxParser.write(t),this.saxParser.close()}else{let t=this.remaining.slice(0,this.options.chunkSize);this.remaining=this.remaining.slice(this.options.chunkSize),this.saxParser=this.saxParser.write(t),setTimeout(this.processAsync,0)}}catch(t){if(!this.errThrown)this.errThrown=!0,this.emit("error",t)}}),ve(this,"assignOrPush",(t,r,n)=>{if(!(r in t))if(!this.options.explicitArray)Dt(t,r,n);else Dt(t,r,[n]);else{if(!Array.isArray(t[r]))Dt(t,r,[t[r]]);t[r].push(n)}}),ve(this,"reset",()=>{this.removeAllListeners(),this.saxParser=Ss.default.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.errThrown=!1,this.saxParser.onerror=(a)=>{if(this.saxParser.resume(),!this.errThrown)this.errThrown=!0,this.emit("error",a)},this.saxParser.onend=()=>{if(!this.ended)this.ended=!0,this.emit("end",this.resultObject)},this.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null;let t=[],r=this.options.attrkey,n=this.options.charkey;this.saxParser.onopentag=(a)=>{let s={};if(s[n]="",!this.options.ignoreAttrs)Object.keys(a.attributes).forEach((o)=>{if(!(r in s)&&!this.options.mergeAttrs)s[r]={};let h=this.options.attrValueProcessors?cn(this.options.attrValueProcessors,a.attributes[o],o):a.attributes[o],l=this.options.attrNameProcessors?cn(this.options.attrNameProcessors,o):o;if(this.options.mergeAttrs)this.assignOrPush(s,l,h);else Dt(s[r],l,h)});if(s["#name"]=this.options.tagNameProcessors?cn(this.options.tagNameProcessors,a.name):a.name,this.options.xmlns)s[this.options.xmlnskey]={uri:a.uri,local:a.local};t.push(s)},this.saxParser.onclosetag=()=>{let a=t.pop(),s=a["#name"];if(!this.options.explicitChildren||!this.options.preserveChildrenOrder)delete a["#name"];let o;if(a.cdata===!0)o=a.cdata,delete a.cdata;let h=t[t.length-1],l="";if(a[n].match(/^\s*$/)&&!o)l=a[n],delete a[n];else{if(this.options.trim)a[n]=a[n].trim();if(this.options.normalize)a[n]=a[n].replace(/\s{2,}/g," ").trim();if(a[n]=this.options.valueProcessors?cn(this.options.valueProcessors,a[n],s):a[n],Object.keys(a).length===1&&n in a&&!this.EXPLICIT_CHARKEY)a=a[n]}if(kh(a))if(typeof this.options.emptyTag==="function")a=this.options.emptyTag();else a=this.options.emptyTag!==""?this.options.emptyTag:l;if(this.options.validator){let c=`/${t.map((p)=>p["#name"]).concat(s).join("/")}`;(()=>{try{a=this.options.validator(c,h&&h[s],a)}catch(p){this.emit("error",p)}})()}if(this.options.explicitChildren&&!this.options.mergeAttrs&&typeof a==="object"){if(!this.options.preserveChildrenOrder){let c={};if(this.options.attrkey in a)c[this.options.attrkey]=a[this.options.attrkey],delete a[this.options.attrkey];if(!this.options.charsAsChildren&&this.options.charkey in a)c[this.options.charkey]=a[this.options.charkey],delete a[this.options.charkey];if(Object.getOwnPropertyNames(a).length>0)c[this.options.childkey]=a;a=c}else if(h){h[this.options.childkey]=h[this.options.childkey]||[];let c={};if(Object.keys(a).forEach((p)=>{Dt(c,p,a[p])}),h[this.options.childkey].push(c),delete a["#name"],Object.keys(a).length===1&&n in a&&!this.EXPLICIT_CHARKEY)a=a[n]}}if(t.length>0)this.assignOrPush(h,s,a);else{if(this.options.explicitRoot){let c=a,p={};Dt(p,s,c),a=p}this.resultObject=a,this.ended=!0,this.emit("end",this.resultObject)}};let i=(a)=>{let s=t[t.length-1];if(s){if(s[n]+=a,this.options.explicitChildren&&this.options.preserveChildrenOrder&&this.options.charsAsChildren&&(this.options.includeWhiteChars||a.replace(/\\n/g,"").trim()!=="")){s[this.options.childkey]=s[this.options.childkey]||[];let o={"#name":"__text__"};if(o[n]=a,this.options.normalize)o[n]=o[n].replace(/\s{2,}/g," ").trim();s[this.options.childkey].push(o)}}return s};this.saxParser.ontext=i,this.saxParser.oncdata=(a)=>{let s=i(a);if(s)s.cdata=!0}}),ve(this,"parseString",(t,r)=>{if(r&&typeof r==="function")this.on("end",(n)=>{this.reset(),r(null,n)}),this.on("error",(n)=>{this.reset(),r(n)});try{if(t=t.toString(),t.trim()==="")return this.emit("end",null),!0;if(t=Th(t),this.options.async)return this.remaining=t,setTimeout(this.processAsync,0),this.saxParser;return this.saxParser.write(t).close()}catch(n){if(!this.errThrown&&!this.ended)this.emit("error",n),this.errThrown=!0;else if(this.ended)throw n}}),ve(this,"parseStringPromise",(t)=>new Promise((r,n)=>{this.parseString(t,(i,a)=>{if(i)n(i);else r(a)})})),this.options={},Object.keys(Es["0.2"]).forEach((t)=>{this.options[t]=Es["0.2"][t]}),e)Object.keys(e).forEach((t)=>{this.options[t]=e[t]});if(this.options.xmlns)this.options.xmlnskey=`${this.options.attrkey}ns`;if(this.options.normalizeTags){if(!this.options.tagNameProcessors)this.options.tagNameProcessors=[];this.options.tagNameProcessors.unshift(Sh)}this.reset()}}});var mr=I(function(Kw,mi){if(typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)mi.exports={nextTick:Ih};else mi.exports=process;function Ih(e,t,r,n){if(typeof e!=="function")throw TypeError('"callback" argument must be a function');var i=arguments.length,a,s;switch(i){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,r)});case 4:return process.nextTick(function(){e.call(null,t,r,n)});default:a=Array(i-1),s=0;while(s<a.length)a[s++]=arguments[s];return process.nextTick(function(){e.apply(null,a)})}}});var Cs=I(function(Yw,Is){var Ch={}.toString;Is.exports=Array.isArray||function(e){return Ch.call(e)=="[object Array]"}});var vr=I(function(vi,Os){var dn=Ee("buffer"),$e=dn.Buffer;function Ds(e,t){for(var r in e)t[r]=e[r]}if($e.from&&$e.alloc&&$e.allocUnsafe&&$e.allocUnsafeSlow)Os.exports=dn;else Ds(dn,vi),vi.Buffer=Pt;function Pt(e,t,r){return $e(e,t,r)}Ds($e,Pt);Pt.from=function(e,t,r){if(typeof e==="number")throw TypeError("Argument must not be a number");return $e(e,t,r)};Pt.alloc=function(e,t,r){if(typeof e!=="number")throw TypeError("Argument must be a number");var n=$e(e);if(t!==void 0)if(typeof r==="string")n.fill(t,r);else n.fill(t);else n.fill(0);return n};Pt.allocUnsafe=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return $e(e)};Pt.allocUnsafeSlow=function(e){if(typeof e!=="number")throw TypeError("Argument must be a number");return dn.SlowBuffer(e)}});var Rt=I(function($h){function Dh(e){if(Array.isArray)return Array.isArray(e);return pn(e)==="[object Array]"}$h.isArray=Dh;function Oh(e){return typeof e==="boolean"}$h.isBoolean=Oh;function Ph(e){return e===null}$h.isNull=Ph;function Rh(e){return e==null}$h.isNullOrUndefined=Rh;function Nh(e){return typeof e==="number"}$h.isNumber=Nh;function Fh(e){return typeof e==="string"}$h.isString=Fh;function Mh(e){return typeof e==="symbol"}$h.isSymbol=Mh;function Bh(e){return e===void 0}$h.isUndefined=Bh;function zh(e){return pn(e)==="[object RegExp]"}$h.isRegExp=zh;function Lh(e){return typeof e==="object"&&e!==null}$h.isObject=Lh;function Uh(e){return pn(e)==="[object Date]"}$h.isDate=Uh;function jh(e){return pn(e)==="[object Error]"||e instanceof Error}$h.isError=jh;function qh(e){return typeof e==="function"}$h.isFunction=qh;function Wh(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e>"u"}$h.isPrimitive=Wh;$h.isBuffer=Ee("buffer").Buffer.isBuffer;function pn(e){return Object.prototype.toString.call(e)}});var Ps=I(function(Qw,_i){if(typeof Object.create==="function")_i.exports=function(t,r){if(r)t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};else _i.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Nt=I(function(eb,yi){try{if(gn=Ee("util"),typeof gn.inherits!=="function")throw"";yi.exports=gn.inherits}catch(e){yi.exports=Ps()}var gn});var Ns=I(function(tb,wi){function sd(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}var Rs=vr().Buffer,_r=Ee("util");function od(e,t,r){e.copy(t,r)}wi.exports=function(){function e(){sd(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};if(this.length>0)this.tail.next=n;else this.head=n;this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};if(this.length===0)this.tail=n;this.head=n,++this.length},e.prototype.shift=function(){if(this.length===0)return;var r=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,r},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";var n=this.head,i=""+n.data;while(n=n.next)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Rs.alloc(0);var n=Rs.allocUnsafe(r>>>0),i=this.head,a=0;while(i)od(i.data,n,a),a+=i.data.length,i=i.next;return n},e}();if(_r&&_r.inspect&&_r.inspect.custom)wi.exports.prototype[_r.inspect.custom]=function(){var e=_r.inspect({length:this.length});return this.constructor.name+" "+e}});var bi=I(function(rb,Fs){var mn=mr();function fd(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;if(n||i){if(t)t(e);else if(e){if(!this._writableState)mn.nextTick(vn,this,e);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,mn.nextTick(vn,this,e)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy(e||null,function(a){if(!t&&a){if(!r._writableState)mn.nextTick(vn,r,a);else if(!r._writableState.errorEmitted)r._writableState.errorEmitted=!0,mn.nextTick(vn,r,a)}else if(t)t(a)}),this}function ld(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function vn(e,t){e.emit("error",t)}Fs.exports={destroy:fd,undestroy:ld}});var Bs=I(function(nb,Ms){Ms.exports=Ee("util").deprecate});var Ei=I(function(ib,Zs){var dt=mr();Zs.exports=Q;function Ls(e){var t=this;this.next=null,this.entry=null,this.finish=function(){Ad(t,e)}}var ud=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:dt.nextTick,Ft;Q.WritableState=wr;var Us=Object.create(Rt());Us.inherits=Nt();var cd={deprecate:Bs()},js=Ee("stream"),yn=vr().Buffer,hd=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function dd(e){return yn.from(e)}function pd(e){return yn.isBuffer(e)||e instanceof hd}var qs=bi();Us.inherits(Q,js);function gd(){}function wr(e,t){Ft=Ft||pt(),e=e||{};var r=t instanceof Ft;if(this.objectMode=!!e.objectMode,r)this.objectMode=this.objectMode||!!e.writableObjectMode;var n=e.highWaterMark,i=e.writableHighWaterMark,a=this.objectMode?16:16384;if(n||n===0)this.highWaterMark=n;else if(r&&(i||i===0))this.highWaterMark=i;else this.highWaterMark=a;this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(o){xd(t,o)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Ls(this)}wr.prototype.getBuffer=function(){var t=this.bufferedRequest,r=[];while(t)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(wr.prototype,"buffer",{get:cd.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}})();var _n;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")_n=Function.prototype[Symbol.hasInstance],Object.defineProperty(Q,Symbol.hasInstance,{value:function(e){if(_n.call(this,e))return!0;if(this!==Q)return!1;return e&&e._writableState instanceof wr}});else _n=function(e){return e instanceof this};function Q(e){if(Ft=Ft||pt(),!_n.call(Q,this)&&!(this instanceof Ft))return new Q(e);if(this._writableState=new wr(e,this),this.writable=!0,e){if(typeof e.write==="function")this._write=e.write;if(typeof e.writev==="function")this._writev=e.writev;if(typeof e.destroy==="function")this._destroy=e.destroy;if(typeof e.final==="function")this._final=e.final}js.call(this)}Q.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))};function md(e,t){var r=Error("write after end");e.emit("error",r),dt.nextTick(t,r)}function vd(e,t,r,n){var i=!0,a=!1;if(r===null)a=TypeError("May not write null values to stream");else if(typeof r!=="string"&&r!==void 0&&!t.objectMode)a=TypeError("Invalid non-string/buffer chunk");if(a)e.emit("error",a),dt.nextTick(n,a),i=!1;return i}Q.prototype.write=function(e,t,r){var n=this._writableState,i=!1,a=!n.objectMode&&pd(e);if(a&&!yn.isBuffer(e))e=dd(e);if(typeof t==="function")r=t,t=null;if(a)t="buffer";else if(!t)t=n.defaultEncoding;if(typeof r!=="function")r=gd;if(n.ended)md(this,r);else if(a||vd(this,n,e,r))n.pendingcb++,i=yd(this,n,a,e,t,r);return i};Q.prototype.cork=function(){var e=this._writableState;e.corked++};Q.prototype.uncork=function(){var e=this._writableState;if(e.corked){if(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest)Ws(this,e)}};Q.prototype.setDefaultEncoding=function(t){if(typeof t==="string")t=t.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function _d(e,t,r){if(!e.objectMode&&e.decodeStrings!==!1&&typeof t==="string")t=yn.from(t,r);return t}Object.defineProperty(Q.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function yd(e,t,r,n,i,a){if(!r){var s=_d(t,n,i);if(n!==s)r=!0,i="buffer",n=s}var o=t.objectMode?1:n.length;t.length+=o;var h=t.length<t.highWaterMark;if(!h)t.needDrain=!0;if(t.writing||t.corked){var l=t.lastBufferedRequest;if(t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:a,next:null},l)l.next=t.lastBufferedRequest;else t.bufferedRequest=t.lastBufferedRequest;t.bufferedRequestCount+=1}else xi(e,t,!1,o,n,i,a);return h}function xi(e,t,r,n,i,a,s){if(t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r)e._writev(i,t.onwrite);else e._write(i,a,t.onwrite);t.sync=!1}function wd(e,t,r,n,i){if(--t.pendingcb,r)dt.nextTick(i,n),dt.nextTick(yr,e,t),e._writableState.errorEmitted=!0,e.emit("error",n);else i(n),e._writableState.errorEmitted=!0,e.emit("error",n),yr(e,t)}function bd(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function xd(e,t){var r=e._writableState,{sync:n,writecb:i}=r;if(bd(r),t)wd(e,r,n,t,i);else{var a=$s(r);if(!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest)Ws(e,r);if(n)ud(zs,e,r,a,i);else zs(e,r,a,i)}}function zs(e,t,r,n){if(!r)Ed(e,t);t.pendingcb--,n(),yr(e,t)}function Ed(e,t){if(t.length===0&&t.needDrain)t.needDrain=!1,e.emit("drain")}function Ws(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=Array(n),a=t.corkedRequestsFree;a.entry=r;var s=0,o=!0;while(r){if(i[s]=r,!r.isBuf)o=!1;r=r.next,s+=1}if(i.allBuffers=o,xi(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next)t.corkedRequestsFree=a.next,a.next=null;else t.corkedRequestsFree=new Ls(t);t.bufferedRequestCount=0}else{while(r){var h=r.chunk,l=r.encoding,c=r.callback,p=t.objectMode?1:h.length;if(xi(e,t,!1,p,h,l,c),r=r.next,t.bufferedRequestCount--,t.writing)break}if(r===null)t.lastBufferedRequest=null}t.bufferedRequest=r,t.bufferProcessing=!1}Q.prototype._write=function(e,t,r){r(Error("_write() is not implemented"))};Q.prototype._writev=null;Q.prototype.end=function(e,t,r){var n=this._writableState;if(typeof e==="function")r=e,e=null,t=null;else if(typeof t==="function")r=t,t=null;if(e!==null&&e!==void 0)this.write(e,t);if(n.corked)n.corked=1,this.uncork();if(!n.ending)kd(this,n,r)};function $s(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Td(e,t){e._final(function(r){if(t.pendingcb--,r)e.emit("error",r);t.prefinished=!0,e.emit("prefinish"),yr(e,t)})}function Sd(e,t){if(!t.prefinished&&!t.finalCalled)if(typeof e._final==="function")t.pendingcb++,t.finalCalled=!0,dt.nextTick(Td,e,t);else t.prefinished=!0,e.emit("prefinish")}function yr(e,t){var r=$s(t);if(r){if(Sd(e,t),t.pendingcb===0)t.finished=!0,e.emit("finish")}return r}function kd(e,t,r){if(t.ending=!0,yr(e,t),r)if(t.finished)dt.nextTick(r);else e.once("finish",r);t.ended=!0,e.writable=!1}function Ad(e,t,r){var n=e.entry;e.entry=null;while(n){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Q.prototype,"destroyed",{get:function(){if(this._writableState===void 0)return!1;return this._writableState.destroyed},set:function(e){if(!this._writableState)return;this._writableState.destroyed=e}});Q.prototype.destroy=qs.destroy;Q.prototype._undestroy=qs.undestroy;Q.prototype._destroy=function(e,t){this.end(),t(e)}});var pt=I(function(ab,Vs){var Hs=mr(),Id=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Vs.exports=Ze;var Gs=Object.create(Rt());Gs.inherits=Nt();var Xs=Si(),Ti=Ei();Gs.inherits(Ze,Xs);{wn=Id(Ti.prototype);for(br=0;br<wn.length;br++)if(xr=wn[br],!Ze.prototype[xr])Ze.prototype[xr]=Ti.prototype[xr]}var wn,xr,br;function Ze(e){if(!(this instanceof Ze))return new Ze(e);if(Xs.call(this,e),Ti.call(this,e),e&&e.readable===!1)this.readable=!1;if(e&&e.writable===!1)this.writable=!1;if(this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1)this.allowHalfOpen=!1;this.once("end",Cd)}Object.defineProperty(Ze.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Cd(){if(this.allowHalfOpen||this._writableState.ended)return;Hs.nextTick(Dd,this)}function Dd(e){e.end()}Object.defineProperty(Ze.prototype,"destroyed",{get:function(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set:function(e){if(this._readableState===void 0||this._writableState===void 0)return;this._readableState.destroyed=e,this._writableState.destroyed=e}});Ze.prototype._destroy=function(e,t){this.push(null),this.end(),Hs.nextTick(t,e)}});var Ii=I(function($d){var Ai=vr().Buffer,Ks=Ai.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Od(e){if(!e)return"utf8";var t;while(!0)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Pd(e){var t=Od(e);if(typeof t!=="string"&&(Ai.isEncoding===Ks||!Ks(e)))throw Error("Unknown encoding: "+e);return t||e}$d.StringDecoder=Er;function Er(e){this.encoding=Pd(e);var t;switch(this.encoding){case"utf16le":this.text=zd,this.end=Ld,t=4;break;case"utf8":this.fillLast=Fd,t=4;break;case"base64":this.text=Ud,this.end=jd,t=3;break;default:this.write=qd,this.end=Wd;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ai.allocUnsafe(t)}Er.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;if(r<e.length)return t?t+this.text(e,r):this.text(e,r);return t||""};Er.prototype.end=Bd;Er.prototype.text=Md;Er.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function ki(e){if(e<=127)return 0;else if(e>>5===6)return 2;else if(e>>4===14)return 3;else if(e>>3===30)return 4;return e>>6===2?-1:-2}function Rd(e,t,r){var n=t.length-1;if(n<r)return 0;var i=ki(t[n]);if(i>=0){if(i>0)e.lastNeed=i-1;return i}if(--n<r||i===-2)return 0;if(i=ki(t[n]),i>=0){if(i>0)e.lastNeed=i-2;return i}if(--n<r||i===-2)return 0;if(i=ki(t[n]),i>=0){if(i>0)if(i===2)i=0;else e.lastNeed=i-3;return i}return 0}function Nd(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2){if((t[2]&192)!==128)return e.lastNeed=2,"�"}}}function Fd(e){var t=this.lastTotal-this.lastNeed,r=Nd(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Md(e,t){var r=Rd(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function Bd(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+"�";return t}function zd(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Ld(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function Ud(e,t){var r=(e.length-t)%3;if(r===0)return e.toString("base64",t);if(this.lastNeed=3-r,this.lastTotal=3,r===1)this.lastChar[0]=e[e.length-1];else this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1];return e.toString("base64",t,e.length-r)}function jd(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed)return t+this.lastChar.toString("base64",0,3-this.lastNeed);return t}function qd(e){return e.toString(this.encoding)}function Wd(e){return e&&e.length?this.write(e):""}});var Si=I(function(fb,fo){var Bt=mr();fo.exports=Z;var Hd=Cs(),Tr;Z.ReadableState=no;var ob=Ee("events").EventEmitter,eo=function(e,t){return e.listeners(t).length},Ri=Ee("stream"),Sr=vr().Buffer,Gd=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Xd(e){return Sr.from(e)}function Vd(e){return Sr.isBuffer(e)||e instanceof Gd}var to=Object.create(Rt());to.inherits=Nt();var Ci=Ee("util"),L=void 0;if(Ci&&Ci.debuglog)L=Ci.debuglog("stream");else L=function(){};var Kd=Ns(),ro=bi(),Mt;to.inherits(Z,Ri);var Di=["error","close","destroy","pause","resume"];function Yd(e,t,r){if(typeof e.prependListener==="function")return e.prependListener(t,r);if(!e._events||!e._events[t])e.on(t,r);else if(Hd(e._events[t]))e._events[t].unshift(r);else e._events[t]=[r,e._events[t]]}function no(e,t){Tr=Tr||pt(),e=e||{};var r=t instanceof Tr;if(this.objectMode=!!e.objectMode,r)this.objectMode=this.objectMode||!!e.readableObjectMode;var n=e.highWaterMark,i=e.readableHighWaterMark,a=this.objectMode?16:16384;if(n||n===0)this.highWaterMark=n;else if(r&&(i||i===0))this.highWaterMark=i;else this.highWaterMark=a;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new Kd,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding){if(!Mt)Mt=Ii().StringDecoder;this.decoder=new Mt(e.encoding),this.encoding=e.encoding}}function Z(e){if(Tr=Tr||pt(),!(this instanceof Z))return new Z(e);if(this._readableState=new no(e,this),this.readable=!0,e){if(typeof e.read==="function")this._read=e.read;if(typeof e.destroy==="function")this._destroy=e.destroy}Ri.call(this)}Object.defineProperty(Z.prototype,"destroyed",{get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function(e){if(!this._readableState)return;this._readableState.destroyed=e}});Z.prototype.destroy=ro.destroy;Z.prototype._undestroy=ro.undestroy;Z.prototype._destroy=function(e,t){this.push(null),t(e)};Z.prototype.push=function(e,t){var r=this._readableState,n;if(!r.objectMode){if(typeof e==="string"){if(t=t||r.defaultEncoding,t!==r.encoding)e=Sr.from(e,t),t="";n=!0}}else n=!0;return io(this,e,t,!1,n)};Z.prototype.unshift=function(e){return io(this,e,null,!0,!1)};function io(e,t,r,n,i){var a=e._readableState;if(t===null)a.reading=!1,tp(e,a);else{var s;if(!i)s=Jd(a,t);if(s)e.emit("error",s);else if(a.objectMode||t&&t.length>0){if(typeof t!=="string"&&!a.objectMode&&Object.getPrototypeOf(t)!==Sr.prototype)t=Xd(t);if(n)if(a.endEmitted)e.emit("error",Error("stream.unshift() after end event"));else Oi(e,a,t,!0);else if(a.ended)e.emit("error",Error("stream.push() after EOF"));else if(a.reading=!1,a.decoder&&!r)if(t=a.decoder.write(t),a.objectMode||t.length!==0)Oi(e,a,t,!1);else ao(e,a);else Oi(e,a,t,!1)}else if(!n)a.reading=!1}return Qd(a)}function Oi(e,t,r,n){if(t.flowing&&t.length===0&&!t.sync)e.emit("data",r),e.read(0);else{if(t.length+=t.objectMode?1:r.length,n)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)bn(e)}ao(e,t)}function Jd(e,t){var r;if(!Vd(t)&&typeof t!=="string"&&t!==void 0&&!e.objectMode)r=TypeError("Invalid non-string/buffer chunk");return r}function Qd(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Z.prototype.isPaused=function(){return this._readableState.flowing===!1};Z.prototype.setEncoding=function(e){if(!Mt)Mt=Ii().StringDecoder;return this._readableState.decoder=new Mt(e),this._readableState.encoding=e,this};var Ys=8388608;function ep(e){if(e>=Ys)e=Ys;else e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++;return e}function Js(e,t){if(e<=0||t.length===0&&t.ended)return 0;if(t.objectMode)return 1;if(e!==e)if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length;if(e>t.highWaterMark)t.highWaterMark=ep(e);if(e<=t.length)return e;if(!t.ended)return t.needReadable=!0,0;return t.length}Z.prototype.read=function(e){L("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0)t.emittedReadable=!1;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){if(L("read: emitReadable",t.length,t.ended),t.length===0&&t.ended)Pi(this);else bn(this);return null}if(e=Js(e,t),e===0&&t.ended){if(t.length===0)Pi(this);return null}var n=t.needReadable;if(L("need readable",n),t.length===0||t.length-e<t.highWaterMark)n=!0,L("length less than watermark",n);if(t.ended||t.reading)n=!1,L("reading or ended",n);else if(n){if(L("do read"),t.reading=!0,t.sync=!0,t.length===0)t.needReadable=!0;if(this._read(t.highWaterMark),t.sync=!1,!t.reading)e=Js(r,t)}var i;if(e>0)i=so(e,t);else i=null;if(i===null)t.needReadable=!0,e=0;else t.length-=e;if(t.length===0){if(!t.ended)t.needReadable=!0;if(r!==e&&t.ended)Pi(this)}if(i!==null)this.emit("data",i);return i};function tp(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();if(r&&r.length)t.buffer.push(r),t.length+=t.objectMode?1:r.length}t.ended=!0,bn(e)}function bn(e){var t=e._readableState;if(t.needReadable=!1,!t.emittedReadable)if(L("emitReadable",t.flowing),t.emittedReadable=!0,t.sync)Bt.nextTick(Qs,e);else Qs(e)}function Qs(e){L("emit readable"),e.emit("readable"),Ni(e)}function ao(e,t){if(!t.readingMore)t.readingMore=!0,Bt.nextTick(rp,e,t)}function rp(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark)if(L("maybeReadMore read 0"),e.read(0),r===t.length)break;else r=t.length;t.readingMore=!1}Z.prototype._read=function(e){this.emit("error",Error("_read() is not implemented"))};Z.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,L("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,a=i?o:b;if(n.endEmitted)Bt.nextTick(a);else r.once("end",a);e.on("unpipe",s);function s(S,T){if(L("onunpipe"),S===r){if(T&&T.hasUnpiped===!1)T.hasUnpiped=!0,c()}}function o(){L("onend"),e.end()}var h=np(r);e.on("drain",h);var l=!1;function c(){if(L("cleanup"),e.removeListener("close",w),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",_),e.removeListener("unpipe",s),r.removeListener("end",o),r.removeListener("end",b),r.removeListener("data",m),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain))h()}var p=!1;r.on("data",m);function m(S){L("ondata"),p=!1;var T=e.write(S);if(T===!1&&!p){if((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&oo(n.pipes,e)!==-1)&&!l)L("false write response, pause",n.awaitDrain),n.awaitDrain++,p=!0;r.pause()}}function _(S){if(L("onerror",S),b(),e.removeListener("error",_),eo(e,"error")===0)e.emit("error",S)}Yd(e,"error",_);function w(){e.removeListener("finish",v),b()}e.once("close",w);function v(){L("onfinish"),e.removeListener("close",w),b()}e.once("finish",v);function b(){L("unpipe"),r.unpipe(e)}if(e.emit("pipe",r),!n.flowing)L("pipe resume"),r.resume();return e};function np(e){return function(){var t=e._readableState;if(L("pipeOnDrain",t.awaitDrain),t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&eo(e,"data"))t.flowing=!0,Ni(e)}}Z.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;if(t.pipes=null,t.pipesCount=0,t.flowing=!1,e)e.emit("unpipe",this,r);return this}if(!e){var{pipes:n,pipesCount:i}=t;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)n[a].emit("unpipe",this,{hasUnpiped:!1});return this}var s=oo(t.pipes,e);if(s===-1)return this;if(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1)t.pipes=t.pipes[0];return e.emit("unpipe",this,r),this};Z.prototype.on=function(e,t){var r=Ri.prototype.on.call(this,e,t);if(e==="data"){if(this._readableState.flowing!==!1)this.resume()}else if(e==="readable"){var n=this._readableState;if(!n.endEmitted&&!n.readableListening){if(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,!n.reading)Bt.nextTick(ip,this);else if(n.length)bn(this)}}return r};Z.prototype.addListener=Z.prototype.on;function ip(e){L("readable nexttick read 0"),e.read(0)}Z.prototype.resume=function(){var e=this._readableState;if(!e.flowing)L("resume"),e.flowing=!0,ap(this,e);return this};function ap(e,t){if(!t.resumeScheduled)t.resumeScheduled=!0,Bt.nextTick(sp,e,t)}function sp(e,t){if(!t.reading)L("resume read 0"),e.read(0);if(t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Ni(e),t.flowing&&!t.reading)e.read(0)}Z.prototype.pause=function(){if(L("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)L("pause"),this._readableState.flowing=!1,this.emit("pause");return this};function Ni(e){var t=e._readableState;L("flow",t.flowing);while(t.flowing&&e.read()!==null);}Z.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(L("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();if(s&&s.length)t.push(s)}t.push(null)}),e.on("data",function(s){if(L("wrapped data"),r.decoder)s=r.decoder.write(s);if(r.objectMode&&(s===null||s===void 0))return;else if(!r.objectMode&&(!s||!s.length))return;var o=t.push(s);if(!o)n=!0,e.pause()});for(var i in e)if(this[i]===void 0&&typeof e[i]==="function")this[i]=function(s){return function(){return e[s].apply(e,arguments)}}(i);for(var a=0;a<Di.length;a++)e.on(Di[a],this.emit.bind(this,Di[a]));return this._read=function(s){if(L("wrapped _read",s),n)n=!1,e.resume()},this};Object.defineProperty(Z.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Z._fromList=so;function so(e,t){if(t.length===0)return null;var r;if(t.objectMode)r=t.buffer.shift();else if(!e||e>=t.length){if(t.decoder)r=t.buffer.join("");else if(t.buffer.length===1)r=t.buffer.head.data;else r=t.buffer.concat(t.length);t.buffer.clear()}else r=op(e,t.buffer,t.decoder);return r}function op(e,t,r){var n;if(e<t.head.data.length)n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e);else if(e===t.head.data.length)n=t.shift();else n=r?fp(e,t):lp(e,t);return n}function fp(e,t){var r=t.head,n=1,i=r.data;e-=i.length;while(r=r.next){var a=r.data,s=e>a.length?a.length:e;if(s===a.length)i+=a;else i+=a.slice(0,e);if(e-=s,e===0){if(s===a.length)if(++n,r.next)t.head=r.next;else t.head=t.tail=null;else t.head=r,r.data=a.slice(s);break}++n}return t.length-=n,i}function lp(e,t){var r=Sr.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;while(n=n.next){var a=n.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),e-=s,e===0){if(s===a.length)if(++i,n.next)t.head=n.next;else t.head=t.tail=null;else t.head=n,n.data=a.slice(s);break}++i}return t.length-=i,r}function Pi(e){var t=e._readableState;if(t.length>0)throw Error('"endReadable()" called on non-empty stream');if(!t.endEmitted)t.ended=!0,Bt.nextTick(up,t,e)}function up(e,t){if(!e.endEmitted&&e.length===0)e.endEmitted=!0,t.readable=!1,t.emit("end")}function oo(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Fi=I(function(lb,co){co.exports=He;var xn=pt(),uo=Object.create(Rt());uo.inherits=Nt();uo.inherits(He,xn);function cp(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",Error("write callback called multiple times"));if(r.writechunk=null,r.writecb=null,t!=null)this.push(t);n(e);var i=this._readableState;if(i.reading=!1,i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}function He(e){if(!(this instanceof He))return new He(e);if(xn.call(this,e),this._transformState={afterTransform:cp.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e){if(typeof e.transform==="function")this._transform=e.transform;if(typeof e.flush==="function")this._flush=e.flush}this.on("prefinish",hp)}function hp(){var e=this;if(typeof this._flush==="function")this._flush(function(t,r){lo(e,t,r)});else lo(this,null,null)}He.prototype.push=function(e,t){return this._transformState.needTransform=!1,xn.prototype.push.call(this,e,t)};He.prototype._transform=function(e,t,r){throw Error("_transform() is not implemented")};He.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};He.prototype._read=function(e){var t=this._transformState;if(t.writechunk!==null&&t.writecb&&!t.transforming)t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform);else t.needTransform=!0};He.prototype._destroy=function(e,t){var r=this;xn.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function lo(e,t,r){if(t)return e.emit("error",t);if(r!=null)e.push(r);if(e._writableState.length)throw Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw Error("Calling transform done when still transforming");return e.push(null)}});var mo=I(function(ub,go){go.exports=kr;var ho=Fi(),po=Object.create(Rt());po.inherits=Nt();po.inherits(kr,ho);function kr(e){if(!(this instanceof kr))return new kr(e);ho.call(this,e)}kr.prototype._transform=function(e,t,r){r(null,e)}});var Mi=I(function(se,En){var De=Ee("stream");if(process.env.READABLE_STREAM==="disable"&&De)En.exports=De,se=En.exports=De.Readable,se.Readable=De.Readable,se.Writable=De.Writable,se.Duplex=De.Duplex,se.Transform=De.Transform,se.PassThrough=De.PassThrough,se.Stream=De;else se=En.exports=Si(),se.Stream=De||se,se.Readable=se,se.Writable=Ei(),se.Duplex=pt(),se.Transform=Fi(),se.PassThrough=mo()});var Ge=I(function(pp){pp.base64=!0;pp.array=!0;pp.string=!0;pp.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";pp.nodebuffer=typeof Buffer<"u";pp.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")pp.blob=!1;else{Tn=new ArrayBuffer(0);try{pp.blob=new Blob([Tn],{type:"application/zip"}).size===0}catch(e){try{zi=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,Sn=new zi,Sn.append(Tn),pp.blob=Sn.getBlob("application/zip").size===0}catch(t){pp.blob=!1}}}var Tn,zi,Sn;try{pp.nodestream=!!Mi().Readable}catch(e){pp.nodestream=!1}});var Li=I(function(Ep){var bp=X(),xp=Ge(),Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";Ep.encode=function(e){var t=[],r,n,i,a,s,o,h,l=0,c=e.length,p=c,m=bp.getTypeOf(e)!=="string";while(l<e.length){if(p=c-l,!m)r=e.charCodeAt(l++),n=l<c?e.charCodeAt(l++):0,i=l<c?e.charCodeAt(l++):0;else r=e[l++],n=l<c?e[l++]:0,i=l<c?e[l++]:0;a=r>>2,s=(r&3)<<4|n>>4,o=p>1?(n&15)<<2|i>>6:64,h=p>2?i&63:64,t.push(Oe.charAt(a)+Oe.charAt(s)+Oe.charAt(o)+Oe.charAt(h))}return t.join("")};Ep.decode=function(e){var t,r,n,i,a,s,o,h=0,l=0,c="data:";if(e.substr(0,c.length)===c)throw Error("Invalid base64 input, it looks like a data url.");e=e.replace(/[^A-Za-z0-9+/=]/g,"");var p=e.length*3/4;if(e.charAt(e.length-1)===Oe.charAt(64))p--;if(e.charAt(e.length-2)===Oe.charAt(64))p--;if(p%1!==0)throw Error("Invalid base64 input, bad content length.");var m;if(xp.uint8array)m=new Uint8Array(p|0);else m=Array(p|0);while(h<e.length){if(i=Oe.indexOf(e.charAt(h++)),a=Oe.indexOf(e.charAt(h++)),s=Oe.indexOf(e.charAt(h++)),o=Oe.indexOf(e.charAt(h++)),t=i<<2|a>>4,r=(a&15)<<4|s>>2,n=(s&3)<<6|o,m[l++]=t,s!==64)m[l++]=r;if(o!==64)m[l++]=n}return m}});var Ar=I(function(db,vo){vo.exports={isNode:typeof Buffer<"u",newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);else{if(typeof e==="number")throw Error('The "data" argument must not be a number');return new Buffer(e,t)}},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);else{var t=new Buffer(e);return t.fill(0),t}},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&typeof e.on==="function"&&typeof e.pause==="function"&&typeof e.resume==="function"}}});var wo=I(function(gb,yo){var pb=global.MutationObserver||global.WebKitMutationObserver,_o;_o=function(){process.nextTick(Dp)};var kp,Ap,Ip,Cp,Ui,Ir=[];function Dp(){Ui=!0;var e,t,r=Ir.length;while(r){t=Ir,Ir=[],e=-1;while(++e<r)t[e]();r=Ir.length}Ui=!1}yo.exports=Op;function Op(e){if(Ir.push(e)===1&&!Ui)_o()}});var Ao=I(function(mb,ko){var bo=wo();function Lt(){}var fe={},xo=["REJECTED"],ji=["FULFILLED"],Eo=["PENDING"];zt=["UNHANDLED"];var zt;ko.exports=et;function et(e){if(typeof e!=="function")throw TypeError("resolver must be a function");if(this.state=Eo,this.queue=[],this.outcome=void 0,this.handled=zt,e!==Lt)To(this,e)}et.prototype.finally=function(e){if(typeof e!=="function")return this;var t=this.constructor;return this.then(r,n);function r(i){function a(){return i}return t.resolve(e()).then(a)}function n(i){function a(){throw i}return t.resolve(e()).then(a)}};et.prototype.catch=function(e){return this.then(null,e)};et.prototype.then=function(e,t){if(typeof e!=="function"&&this.state===ji||typeof t!=="function"&&this.state===xo)return this;var r=new this.constructor(Lt);if(this.handled===zt)this.handled=null;if(this.state!==Eo){var n=this.state===ji?e:t;qi(r,n,this.outcome)}else this.queue.push(new Cr(r,e,t));return r};function Cr(e,t,r){if(this.promise=e,typeof t==="function")this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled;if(typeof r==="function")this.onRejected=r,this.callRejected=this.otherCallRejected}Cr.prototype.callFulfilled=function(e){fe.resolve(this.promise,e)};Cr.prototype.otherCallFulfilled=function(e){qi(this.promise,this.onFulfilled,e)};Cr.prototype.callRejected=function(e){fe.reject(this.promise,e)};Cr.prototype.otherCallRejected=function(e){qi(this.promise,this.onRejected,e)};function qi(e,t,r){bo(function(){var n;try{n=t(r)}catch(i){return fe.reject(e,i)}if(n===e)fe.reject(e,TypeError("Cannot resolve promise with itself"));else fe.resolve(e,n)})}fe.resolve=function(e,t){var r=So(Pp,t);if(r.status==="error")return fe.reject(e,r.value);var n=r.value;if(n)To(e,n);else{e.state=ji,e.outcome=t;var i=-1,a=e.queue.length;while(++i<a)e.queue[i].callFulfilled(t)}return e};fe.reject=function(e,t){if(e.state=xo,e.outcome=t,e.handled===zt)bo(function(){if(e.handled===zt)process.emit("unhandledRejection",t,e)});var r=-1,n=e.queue.length;while(++r<n)e.queue[r].callRejected(t);return e};function Pp(e){var t=e&&e.then;if(e&&(typeof e==="object"||typeof e==="function")&&typeof t==="function")return function(){t.apply(e,arguments)}}function To(e,t){var r=!1;function n(o){if(r)return;r=!0,fe.reject(e,o)}function i(o){if(r)return;r=!0,fe.resolve(e,o)}function a(){t(i,n)}var s=So(a);if(s.status==="error")n(s.value)}function So(e,t){var r={};try{r.value=e(t),r.status="success"}catch(n){r.status="error",r.value=n}return r}et.resolve=Rp;function Rp(e){if(e instanceof this)return e;return fe.resolve(new this(Lt),e)}et.reject=Np;function Np(e){var t=new this(Lt);return fe.reject(t,e)}et.all=Fp;function Fp(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);var i=Array(r),a=0,s=-1,o=new this(Lt);while(++s<r)h(e[s],s);return o;function h(l,c){t.resolve(l).then(p,function(m){if(!n)n=!0,fe.reject(o,m)});function p(m){if(i[c]=m,++a===r&&!n)n=!0,fe.resolve(o,i)}}}et.race=Mp;function Mp(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);var i=-1,a=new this(Lt);while(++i<r)s(e[i]);return a;function s(o){t.resolve(o).then(function(h){if(!n)n=!0,fe.resolve(a,h)},function(h){if(!n)n=!0,fe.reject(a,h)})}}});var Ut=I(function(vb,Io){var Wi=null;if(typeof Promise<"u")Wi=Promise;else Wi=Ao();Io.exports={Promise:Wi}});var Do=I(function(Co){(function(e,t){if(e.setImmediate)return;var r=1,n={},i=!1,a=e.document,s;function o(T){if(typeof T!=="function")T=Function(""+T);var k=Array(arguments.length-1);for(var x=0;x<k.length;x++)k[x]=arguments[x+1];var A={callback:T,args:k};return n[r]=A,s(r),r++}function h(T){delete n[T]}function l(T){var{callback:k,args:x}=T;switch(x.length){case 0:k();break;case 1:k(x[0]);break;case 2:k(x[0],x[1]);break;case 3:k(x[0],x[1],x[2]);break;default:k.apply(t,x);break}}function c(T){if(i)setTimeout(c,0,T);else{var k=n[T];if(k){i=!0;try{l(k)}finally{h(T),i=!1}}}}function p(){s=function(T){process.nextTick(function(){c(T)})}}function m(){if(e.postMessage&&!e.importScripts){var T=!0,k=e.onmessage;return e.onmessage=function(){T=!1},e.postMessage("","*"),e.onmessage=k,T}}function _(){var T="setImmediate$"+Math.random()+"$",k=function(x){if(x.source===e&&typeof x.data==="string"&&x.data.indexOf(T)===0)c(+x.data.slice(T.length))};if(e.addEventListener)e.addEventListener("message",k,!1);else e.attachEvent("onmessage",k);s=function(x){e.postMessage(T+x,"*")}}function w(){var T=new MessageChannel;T.port1.onmessage=function(k){var x=k.data;c(x)},s=function(k){T.port2.postMessage(k)}}function v(){var T=a.documentElement;s=function(k){var x=a.createElement("script");x.onreadystatechange=function(){c(k),x.onreadystatechange=null,T.removeChild(x),x=null},T.appendChild(x)}}function b(){s=function(T){setTimeout(c,0,T)}}var S=Object.getPrototypeOf&&Object.getPrototypeOf(e);if(S=S&&S.setTimeout?S:e,{}.toString.call(e.process)==="[object process]")p();else if(m())_();else if(e.MessageChannel)w();else if(a&&"onreadystatechange"in a.createElement("script"))v();else b();S.setImmediate=o,S.clearImmediate=h})(typeof self>"u"?typeof global>"u"?Co:global:self)});var X=I(function(gt){var tt=Ge(),Bp=Li(),jt=Ar(),$i=Ut();Do();function zp(e){var t=null;if(tt.uint8array)t=new Uint8Array(e.length);else t=Array(e.length);return An(e,t)}gt.newBlob=function(e,t){gt.checkSupport("blob");try{return new Blob([e],{type:t})}catch(i){try{var r=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,n=new r;return n.append(e),n.getBlob(t)}catch(a){throw Error("Bug : can't construct the Blob.")}}};function Dr(e){return e}function An(e,t){for(var r=0;r<e.length;++r)t[r]=e.charCodeAt(r)&255;return t}var kn={stringifyByChunk:function(e,t,r){var n=[],i=0,a=e.length;if(a<=r)return String.fromCharCode.apply(null,e);while(i<a){if(t==="array"||t==="nodebuffer")n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,a))));else n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,a))));i+=r}return n.join("")},stringifyByChar:function(e){var t="";for(var r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return tt.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch(e){return!1}}(),nodebuffer:function(){try{return tt.nodebuffer&&String.fromCharCode.apply(null,jt.allocBuffer(1)).length===1}catch(e){return!1}}()}};function Or(e){var t=65536,r=gt.getTypeOf(e),n=!0;if(r==="uint8array")n=kn.applyCanBeUsed.uint8array;else if(r==="nodebuffer")n=kn.applyCanBeUsed.nodebuffer;if(n)while(t>1)try{return kn.stringifyByChunk(e,r,t)}catch(i){t=Math.floor(t/2)}return kn.stringifyByChar(e)}gt.applyFromCharCode=Or;function In(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}var rt={};rt.string={string:Dr,array:function(e){return An(e,Array(e.length))},arraybuffer:function(e){return rt.string.uint8array(e).buffer},uint8array:function(e){return An(e,new Uint8Array(e.length))},nodebuffer:function(e){return An(e,jt.allocBuffer(e.length))}};rt.array={string:Or,array:Dr,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return jt.newBufferFrom(e)}};rt.arraybuffer={string:function(e){return Or(new Uint8Array(e))},array:function(e){return In(new Uint8Array(e),Array(e.byteLength))},arraybuffer:Dr,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return jt.newBufferFrom(new Uint8Array(e))}};rt.uint8array={string:Or,array:function(e){return In(e,Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:Dr,nodebuffer:function(e){return jt.newBufferFrom(e)}};rt.nodebuffer={string:Or,array:function(e){return In(e,Array(e.length))},arraybuffer:function(e){return rt.nodebuffer.uint8array(e).buffer},uint8array:function(e){return In(e,new Uint8Array(e.length))},nodebuffer:Dr};gt.transformTo=function(e,t){if(!t)t="";if(!e)return t;gt.checkSupport(e);var r=gt.getTypeOf(t),n=rt[r][e](t);return n};gt.resolve=function(e){var t=e.split("/"),r=[];for(var n=0;n<t.length;n++){var i=t[n];if(i==="."||i===""&&n!==0&&n!==t.length-1)continue;else if(i==="..")r.pop();else r.push(i)}return r.join("/")};gt.getTypeOf=function(e){if(typeof e==="string")return"string";if(Object.prototype.toString.call(e)==="[object Array]")return"array";if(tt.nodebuffer&&jt.isBuffer(e))return"nodebuffer";if(tt.uint8array&&e instanceof Uint8Array)return"uint8array";if(tt.arraybuffer&&e instanceof ArrayBuffer)return"arraybuffer"};gt.checkSupport=function(e){var t=tt[e.toLowerCase()];if(!t)throw Error(e+" is not supported by this platform")};gt.MAX_VALUE_16BITS=65535;gt.MAX_VALUE_32BITS=-1;gt.pretty=function(e){var t="",r,n;for(n=0;n<(e||"").length;n++)r=e.charCodeAt(n),t+="\\x"+(r<16?"0":"")+r.toString(16).toUpperCase();return t};gt.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})};gt.inherits=function(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r};gt.extend=function(){var e={},t,r;for(t=0;t<arguments.length;t++)for(r in arguments[t])if(Object.prototype.hasOwnProperty.call(arguments[t],r)&&typeof e[r]>"u")e[r]=arguments[t][r];return e};gt.prepareContent=function(e,t,r,n,i){var a=$i.Promise.resolve(t).then(function(s){var o=tt.blob&&(s instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(s))!==-1);if(o&&typeof FileReader<"u")return new $i.Promise(function(h,l){var c=new FileReader;c.onload=function(p){h(p.target.result)},c.onerror=function(p){l(p.target.error)},c.readAsArrayBuffer(s)});else return s});return a.then(function(s){var o=gt.getTypeOf(s);if(!o)return $i.Promise.reject(Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));if(o==="arraybuffer")s=gt.transformTo("uint8array",s);else if(o==="string"){if(i)s=Bp.decode(s);else if(r){if(n!==!0)s=zp(s)}}return s})}});var ge=I(function(wb,No){function Ro(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}Ro.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){if(this.isFinished)return!1;if(this.isPaused)this.generatedError=e;else{if(this.isFinished=!0,this.emit("error",e),this.previous)this.previous.error(e);this.cleanUp()}return!0},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(r){t.processChunk(r)}),e.on("end",function(){t.end()}),e.on("error",function(r){t.error(r)}),this},pause:function(){if(this.isPaused||this.isFinished)return!1;if(this.isPaused=!0,this.previous)this.previous.pause();return!0},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;if(this.generatedError)this.error(this.generatedError),e=!0;if(this.previous)this.previous.resume();return!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo){if(!Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e))continue;this.streamInfo[e]=this.extraStreamInfo[e]}},lock:function(){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");if(this.isLocked=!0,this.previous)this.previous.lock()},toString:function(){var e="Worker "+this.name;if(this.previous)return this.previous+" -> "+e;else return e}};No.exports=Ro});var Wt=I(function(Qp){var qt=X(),mt=Ge(),Vp=Ar(),Cn=ge(),Pr=Array(256);for(Pe=0;Pe<256;Pe++)Pr[Pe]=Pe>=252?6:Pe>=248?5:Pe>=240?4:Pe>=224?3:Pe>=192?2:1;var Pe;Pr[254]=Pr[254]=1;var Kp=function(e){var t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++){if(r=e.charCodeAt(i),(r&64512)===55296&&i+1<s){if(n=e.charCodeAt(i+1),(n&64512)===56320)r=65536+(r-55296<<10)+(n-56320),i++}o+=r<128?1:r<2048?2:r<65536?3:4}if(mt.uint8array)t=new Uint8Array(o);else t=Array(o);for(a=0,i=0;a<o;i++){if(r=e.charCodeAt(i),(r&64512)===55296&&i+1<s){if(n=e.charCodeAt(i+1),(n&64512)===56320)r=65536+(r-55296<<10)+(n-56320),i++}if(r<128)t[a++]=r;else if(r<2048)t[a++]=192|r>>>6,t[a++]=128|r&63;else if(r<65536)t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63;else t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63}return t},Yp=function(e,t){var r;if(t=t||e.length,t>e.length)t=e.length;r=t-1;while(r>=0&&(e[r]&192)===128)r--;if(r<0)return t;if(r===0)return t;return r+Pr[e[r]]>t?r:t},Jp=function(e){var t,r,n,i,a=e.length,s=Array(a*2);for(r=0,t=0;t<a;){if(n=e[t++],n<128){s[r++]=n;continue}if(i=Pr[n],i>4){s[r++]=65533,t+=i-1;continue}n&=i===2?31:i===3?15:7;while(i>1&&t<a)n=n<<6|e[t++]&63,i--;if(i>1){s[r++]=65533;continue}if(n<65536)s[r++]=n;else n-=65536,s[r++]=55296|n>>10&1023,s[r++]=56320|n&1023}if(s.length!==r)if(s.subarray)s=s.subarray(0,r);else s.length=r;return qt.applyFromCharCode(s)};Qp.utf8encode=function(t){if(mt.nodebuffer)return Vp.newBufferFrom(t,"utf-8");return Kp(t)};Qp.utf8decode=function(t){if(mt.nodebuffer)return qt.transformTo("nodebuffer",t).toString("utf-8");return t=qt.transformTo(mt.uint8array?"uint8array":"array",t),Jp(t)};function Dn(){Cn.call(this,"utf-8 decode"),this.leftOver=null}qt.inherits(Dn,Cn);Dn.prototype.processChunk=function(e){var t=qt.transformTo(mt.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(mt.uint8array){var r=t;t=new Uint8Array(r.length+this.leftOver.length),t.set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=Yp(t),i=t;if(n!==t.length)if(mt.uint8array)i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length);else i=t.slice(0,n),this.leftOver=t.slice(n,t.length);this.push({data:Qp.utf8decode(i),meta:e.meta})};Dn.prototype.flush=function(){if(this.leftOver&&this.leftOver.length)this.push({data:Qp.utf8decode(this.leftOver),meta:{}}),this.leftOver=null};Qp.Utf8DecodeWorker=Dn;function Hi(){Cn.call(this,"utf-8 encode")}qt.inherits(Hi,Cn);Hi.prototype.processChunk=function(e){this.push({data:Qp.utf8encode(e.data),meta:e.meta})};Qp.Utf8EncodeWorker=Hi});var Lo=I(function(xb,zo){var Mo=ge(),Bo=X();function Xi(e){Mo.call(this,"ConvertWorker to "+e),this.destType=e}Bo.inherits(Xi,Mo);Xi.prototype.processChunk=function(e){this.push({data:Bo.transformTo(this.destType,e.data),meta:e.meta})};zo.exports=Xi});var qo=I(function(Eb,jo){var Uo=Mi().Readable,rg=X();rg.inherits(Vi,Uo);function Vi(e,t,r){Uo.call(this,t),this._helper=e;var n=this;e.on("data",function(i,a){if(!n.push(i))n._helper.pause();if(r)r(a)}).on("error",function(i){n.emit("error",i)}).on("end",function(){n.push(null)})}Vi.prototype._read=function(){this._helper.resume()};jo.exports=Vi});var Ki=I(function(Tb,Zo){var vt=X(),ng=Lo(),ig=ge(),ag=Li(),sg=Ge(),og=Ut(),Wo=null;if(sg.nodestream)try{Wo=qo()}catch(e){}function fg(e,t,r){switch(e){case"blob":return vt.newBlob(vt.transformTo("arraybuffer",t),r);case"base64":return ag.encode(t);default:return vt.transformTo(e,t)}}function lg(e,t){var r,n=0,i=null,a=0;for(r=0;r<t.length;r++)a+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":i=new Uint8Array(a);for(r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw Error("concat : unsupported type '"+e+"'")}}function ug(e,t){return new og.Promise(function(r,n){var i=[],{_internalType:a,_outputType:s,_mimeType:o}=e;e.on("data",function(h,l){if(i.push(h),t)t(l)}).on("error",function(h){i=[],n(h)}).on("end",function(){try{var h=fg(s,lg(a,i),o);r(h)}catch(l){n(l)}i=[]}).resume()})}function $o(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string";break}try{this._internalType=n,this._outputType=t,this._mimeType=r,vt.checkSupport(n),this._worker=e.pipe(new ng(n)),e.lock()}catch(i){this._worker=new ig("error"),this._worker.error(i)}}$o.prototype={accumulate:function(e){return ug(this,e)},on:function(e,t){var r=this;if(e==="data")this._worker.on(e,function(n){t.call(r,n.data,n.meta)});else this._worker.on(e,function(){vt.delay(t,arguments,r)});return this},resume:function(){return vt.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(vt.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new Wo(this,{objectMode:this._outputType!=="nodebuffer"},e)}};Zo.exports=$o});var Yi=I(function(cg){cg.base64=!1;cg.binary=!1;cg.dir=!1;cg.createFolders=!0;cg.date=null;cg.compression=null;cg.compressionOptions=null;cg.comment=null;cg.unixPermissions=null;cg.dosPermissions=null});var Ji=I(function(kb,Ho){var On=X(),Pn=ge(),xg=16384;function $t(e){Pn.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(r){if(t.dataIsReady=!0,t.data=r,t.max=r&&r.length||0,t.type=On.getTypeOf(r),!t.isPaused)t._tickAndRepeat()},function(r){t.error(r)})}On.inherits($t,Pn);$t.prototype.cleanUp=function(){Pn.prototype.cleanUp.call(this),this.data=null};$t.prototype.resume=function(){if(!Pn.prototype.resume.call(this))return!1;if(!this._tickScheduled&&this.dataIsReady)this._tickScheduled=!0,On.delay(this._tickAndRepeat,[],this);return!0};$t.prototype._tickAndRepeat=function(){if(this._tickScheduled=!1,this.isPaused||this.isFinished)return;if(this._tick(),!this.isFinished)On.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0};$t.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=xg,t=null,r=Math.min(this.max,this.index+e);if(this.index>=this.max)return this.end();else{switch(this.type){case"string":t=this.data.substring(this.index,r);break;case"uint8array":t=this.data.subarray(this.index,r);break;case"array":case"nodebuffer":t=this.data.slice(this.index,r);break}return this.index=r,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})}};Ho.exports=$t});var Rn=I(function(Ab,Xo){var Eg=X();function Tg(){var e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var Go=Tg();function Sg(e,t,r,n){var i=Go,a=n+r;e=e^-1;for(var s=n;s<a;s++)e=e>>>8^i[(e^t[s])&255];return e^-1}function kg(e,t,r,n){var i=Go,a=n+r;e=e^-1;for(var s=n;s<a;s++)e=e>>>8^i[(e^t.charCodeAt(s))&255];return e^-1}Xo.exports=function(t,r){if(typeof t>"u"||!t.length)return 0;var n=Eg.getTypeOf(t)!=="string";if(n)return Sg(r|0,t,t.length,0);else return kg(r|0,t,t.length,0)}});var ea=I(function(Ib,Ko){var Vo=ge(),Ag=Rn(),Ig=X();function Qi(){Vo.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}Ig.inherits(Qi,Vo);Qi.prototype.processChunk=function(e){this.streamInfo.crc32=Ag(e.data,this.streamInfo.crc32||0),this.push(e)};Ko.exports=Qi});var Jo=I(function(Cb,Yo){var Cg=X(),ta=ge();function ra(e){ta.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}Cg.inherits(ra,ta);ra.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}ta.prototype.processChunk.call(this,e)};Yo.exports=ra});var Nn=I(function(Db,tf){var Qo=Ut(),ef=Ji(),Dg=ea(),na=Jo();function ia(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}ia.prototype={getContentWorker:function(){var e=new ef(Qo.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new na("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new ef(Qo.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};ia.createWorkerFrom=function(e,t,r){return e.pipe(new Dg).pipe(new na("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new na("compressedSize")).withStreamInfo("compression",t)};tf.exports=ia});var sf=I(function(Ob,af){var Og=Ki(),Pg=Ji(),aa=Wt(),sa=Nn(),rf=ge(),oa=function(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}};oa.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw Error("No output type specified.");r=e.toLowerCase();var n=r==="string"||r==="text";if(r==="binarystring"||r==="text")r="string";t=this._decompressWorker();var i=!this._dataBinary;if(i&&!n)t=t.pipe(new aa.Utf8EncodeWorker);if(!i&&n)t=t.pipe(new aa.Utf8DecodeWorker)}catch(a){t=new rf("error"),t.error(a)}return new Og(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof sa&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();else{var r=this._decompressWorker();if(!this._dataBinary)r=r.pipe(new aa.Utf8EncodeWorker);return sa.createWorkerFrom(r,e,t)}},_decompressWorker:function(){if(this._data instanceof sa)return this._data.getContentWorker();else if(this._data instanceof rf)return this._data;else return new Pg(this._data)}};var nf=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],Rg=function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(Rr=0;Rr<nf.length;Rr++)oa.prototype[nf[Rr]]=Rg;var Rr;af.exports=oa});var Xe=I(function(Zt){var Bg=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function zg(e,t){return Object.prototype.hasOwnProperty.call(e,t)}Zt.assign=function(e){var t=Array.prototype.slice.call(arguments,1);while(t.length){var r=t.shift();if(!r)continue;if(typeof r!=="object")throw TypeError(r+"must be non-object");for(var n in r)if(zg(r,n))e[n]=r[n]}return e};Zt.shrinkBuf=function(e,t){if(e.length===t)return e;if(e.subarray)return e.subarray(0,t);return e.length=t,e};var Lg={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+n),i);return}for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){var t,r,n,i,a,s;n=0;for(t=0,r=e.length;t<r;t++)n+=e[t].length;s=new Uint8Array(n),i=0;for(t=0,r=e.length;t<r;t++)a=e[t],s.set(a,i),i+=a.length;return s}},Ug={arraySet:function(e,t,r,n,i){for(var a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};Zt.setTyped=function(e){if(e)Zt.Buf8=Uint8Array,Zt.Buf16=Uint16Array,Zt.Buf32=Int32Array,Zt.assign(Zt,Lg);else Zt.Buf8=Array,Zt.Buf16=Array,Zt.Buf32=Array,Zt.assign(Zt,Ug)};Zt.setTyped(Bg)});var Df=I(function(l0){var qg=Xe(),Wg=4,ff=0,lf=1,$g=2;function Gt(e){var t=e.length;while(--t>=0)e[t]=0}var Zg=0,gf=1,Hg=2,Gg=3,Xg=258,ga=29,Lr=256,Fr=Lr+1+ga,Ht=30,ma=19,mf=2*Fr+1,_t=15,la=16,Vg=7,va=256,vf=16,_f=17,yf=18,da=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Fn=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Kg=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],wf=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Yg=512,Ve=Array((Fr+2)*2);Gt(Ve);var Nr=Array(Ht*2);Gt(Nr);var Mr=Array(Yg);Gt(Mr);var Br=Array(Xg-Gg+1);Gt(Br);var _a=Array(ga);Gt(_a);var Mn=Array(Ht);Gt(Mn);function ua(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}var bf,xf,Ef;function ca(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Tf(e){return e<256?Mr[e]:Mr[256+(e>>>7)]}function zr(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function de(e,t,r){if(e.bi_valid>la-r)e.bi_buf|=t<<e.bi_valid&65535,zr(e,e.bi_buf),e.bi_buf=t>>la-e.bi_valid,e.bi_valid+=r-la;else e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r}function Re(e,t,r){de(e,r[t*2],r[t*2+1])}function Sf(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}function Jg(e){if(e.bi_valid===16)zr(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0;else if(e.bi_valid>=8)e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8}function Qg(e,t){var{dyn_tree:r,max_code:n}=t,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,h=t.stat_desc.max_length,l,c,p,m,_,w,v=0;for(m=0;m<=_t;m++)e.bl_count[m]=0;r[e.heap[e.heap_max]*2+1]=0;for(l=e.heap_max+1;l<mf;l++){if(c=e.heap[l],m=r[r[c*2+1]*2+1]+1,m>h)m=h,v++;if(r[c*2+1]=m,c>n)continue;if(e.bl_count[m]++,_=0,c>=o)_=s[c-o];if(w=r[c*2],e.opt_len+=w*(m+_),a)e.static_len+=w*(i[c*2+1]+_)}if(v===0)return;do{m=h-1;while(e.bl_count[m]===0)m--;e.bl_count[m]--,e.bl_count[m+1]+=2,e.bl_count[h]--,v-=2}while(v>0);for(m=h;m!==0;m--){c=e.bl_count[m];while(c!==0){if(p=e.heap[--l],p>n)continue;if(r[p*2+1]!==m)e.opt_len+=(m-r[p*2+1])*r[p*2],r[p*2+1]=m;c--}}}function kf(e,t,r){var n=Array(_t+1),i=0,a,s;for(a=1;a<=_t;a++)n[a]=i=i+r[a-1]<<1;for(s=0;s<=t;s++){var o=e[s*2+1];if(o===0)continue;e[s*2]=Sf(n[o]++,o)}}function e0(){var e,t,r,n,i,a=Array(_t+1);r=0;for(n=0;n<ga-1;n++){_a[n]=r;for(e=0;e<1<<da[n];e++)Br[r++]=n}Br[r-1]=n,i=0;for(n=0;n<16;n++){Mn[n]=i;for(e=0;e<1<<Fn[n];e++)Mr[i++]=n}i>>=7;for(;n<Ht;n++){Mn[n]=i<<7;for(e=0;e<1<<Fn[n]-7;e++)Mr[256+i++]=n}for(t=0;t<=_t;t++)a[t]=0;e=0;while(e<=143)Ve[e*2+1]=8,e++,a[8]++;while(e<=255)Ve[e*2+1]=9,e++,a[9]++;while(e<=279)Ve[e*2+1]=7,e++,a[7]++;while(e<=287)Ve[e*2+1]=8,e++,a[8]++;kf(Ve,Fr+1,a);for(e=0;e<Ht;e++)Nr[e*2+1]=5,Nr[e*2]=Sf(e,5);bf=new ua(Ve,da,Lr+1,Fr,_t),xf=new ua(Nr,Fn,0,Ht,_t),Ef=new ua([],Kg,0,ma,Vg)}function Af(e){var t;for(t=0;t<Fr;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Ht;t++)e.dyn_dtree[t*2]=0;for(t=0;t<ma;t++)e.bl_tree[t*2]=0;e.dyn_ltree[va*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function If(e){if(e.bi_valid>8)zr(e,e.bi_buf);else if(e.bi_valid>0)e.pending_buf[e.pending++]=e.bi_buf;e.bi_buf=0,e.bi_valid=0}function t0(e,t,r,n){if(If(e),n)zr(e,r),zr(e,~r);qg.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function uf(e,t,r,n){var i=t*2,a=r*2;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function ha(e,t,r){var n=e.heap[r],i=r<<1;while(i<=e.heap_len){if(i<e.heap_len&&uf(t,e.heap[i+1],e.heap[i],e.depth))i++;if(uf(t,n,e.heap[i],e.depth))break;e.heap[r]=e.heap[i],r=i,i<<=1}e.heap[r]=n}function cf(e,t,r){var n,i,a=0,s,o;if(e.last_lit!==0)do if(n=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,n===0)Re(e,i,t);else{if(s=Br[i],Re(e,s+Lr+1,t),o=da[s],o!==0)i-=_a[s],de(e,i,o);if(n--,s=Tf(n),Re(e,s,r),o=Fn[s],o!==0)n-=Mn[s],de(e,n,o)}while(a<e.last_lit);Re(e,va,t)}function pa(e,t){var r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,s,o,h=-1,l;e.heap_len=0,e.heap_max=mf;for(s=0;s<a;s++)if(r[s*2]!==0)e.heap[++e.heap_len]=h=s,e.depth[s]=0;else r[s*2+1]=0;while(e.heap_len<2)if(l=e.heap[++e.heap_len]=h<2?++h:0,r[l*2]=1,e.depth[l]=0,e.opt_len--,i)e.static_len-=n[l*2+1];t.max_code=h;for(s=e.heap_len>>1;s>=1;s--)ha(e,r,s);l=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ha(e,r,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,r[l*2]=r[s*2]+r[o*2],e.depth[l]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,r[s*2+1]=r[o*2+1]=l,e.heap[1]=l++,ha(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Qg(e,t),kf(r,h,e.bl_count)}function hf(e,t,r){var n,i=-1,a,s=t[1],o=0,h=7,l=4;if(s===0)h=138,l=3;t[(r+1)*2+1]=65535;for(n=0;n<=r;n++){if(a=s,s=t[(n+1)*2+1],++o<h&&a===s)continue;else if(o<l)e.bl_tree[a*2]+=o;else if(a!==0){if(a!==i)e.bl_tree[a*2]++;e.bl_tree[vf*2]++}else if(o<=10)e.bl_tree[_f*2]++;else e.bl_tree[yf*2]++;if(o=0,i=a,s===0)h=138,l=3;else if(a===s)h=6,l=3;else h=7,l=4}}function df(e,t,r){var n,i=-1,a,s=t[1],o=0,h=7,l=4;if(s===0)h=138,l=3;for(n=0;n<=r;n++){if(a=s,s=t[(n+1)*2+1],++o<h&&a===s)continue;else if(o<l)do Re(e,a,e.bl_tree);while(--o!==0);else if(a!==0){if(a!==i)Re(e,a,e.bl_tree),o--;Re(e,vf,e.bl_tree),de(e,o-3,2)}else if(o<=10)Re(e,_f,e.bl_tree),de(e,o-3,3);else Re(e,yf,e.bl_tree),de(e,o-11,7);if(o=0,i=a,s===0)h=138,l=3;else if(a===s)h=6,l=3;else h=7,l=4}}function r0(e){var t;hf(e,e.dyn_ltree,e.l_desc.max_code),hf(e,e.dyn_dtree,e.d_desc.max_code),pa(e,e.bl_desc);for(t=ma-1;t>=3;t--)if(e.bl_tree[wf[t]*2+1]!==0)break;return e.opt_len+=3*(t+1)+5+5+4,t}function n0(e,t,r,n){var i;de(e,t-257,5),de(e,r-1,5),de(e,n-4,4);for(i=0;i<n;i++)de(e,e.bl_tree[wf[i]*2+1],3);df(e,e.dyn_ltree,t-1),df(e,e.dyn_dtree,r-1)}function i0(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return ff;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return lf;for(r=32;r<Lr;r++)if(e.dyn_ltree[r*2]!==0)return lf;return ff}var pf=!1;function a0(e){if(!pf)e0(),pf=!0;e.l_desc=new ca(e.dyn_ltree,bf),e.d_desc=new ca(e.dyn_dtree,xf),e.bl_desc=new ca(e.bl_tree,Ef),e.bi_buf=0,e.bi_valid=0,Af(e)}function Cf(e,t,r,n){de(e,(Zg<<1)+(n?1:0),3),t0(e,t,r,!0)}function s0(e){de(e,gf<<1,3),Re(e,va,Ve),Jg(e)}function o0(e,t,r,n){var i,a,s=0;if(e.level>0){if(e.strm.data_type===$g)e.strm.data_type=i0(e);if(pa(e,e.l_desc),pa(e,e.d_desc),s=r0(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i)i=a}else i=a=r+5;if(r+4<=i&&t!==-1)Cf(e,t,r,n);else if(e.strategy===Wg||a===i)de(e,(gf<<1)+(n?1:0),3),cf(e,Ve,Nr);else de(e,(Hg<<1)+(n?1:0),3),n0(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),cf(e,e.dyn_ltree,e.dyn_dtree);if(Af(e),n)If(e)}function f0(e,t,r){if(e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0)e.dyn_ltree[r*2]++;else e.matches++,t--,e.dyn_ltree[(Br[r]+Lr+1)*2]++,e.dyn_dtree[Tf(t)*2]++;return e.last_lit===e.lit_bufsize-1}l0._tr_init=a0;l0._tr_stored_block=Cf;l0._tr_flush_block=o0;l0._tr_tally=f0;l0._tr_align=s0});var ya=I(function(Nb,Of){function g0(e,t,r,n){var i=e&65535|0,a=e>>>16&65535|0,s=0;while(r!==0){s=r>2000?2000:r,r-=s;do i=i+t[n++]|0,a=a+i|0;while(--s);i%=65521,a%=65521}return i|a<<16|0}Of.exports=g0});var wa=I(function(Fb,Pf){function m0(){var e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}var v0=m0();function _0(e,t,r,n){var i=v0,a=n+r;e^=-1;for(var s=n;s<a;s++)e=e>>>8^i[(e^t[s])&255];return e^-1}Pf.exports=_0});var Bn=I(function(Mb,Rf){Rf.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var qf=I(function(Y0){var le=Xe(),_e=Df(),Bf=ya(),nt=wa(),y0=Bn(),xt=0,w0=1,b0=3,ft=4,Nf=5,Fe=0,Ff=1,ye=-2,x0=-3,ba=-5,E0=-1,T0=1,zn=2,S0=3,k0=4,A0=0,I0=2,qn=8,C0=9,D0=15,O0=8,P0=29,R0=256,Ea=R0+1+P0,N0=30,F0=19,M0=2*Ea+1,B0=15,M=3,st=258,Te=st+M+1,z0=32,Wn=42,Ta=69,Ln=73,Un=91,jn=103,yt=113,jr=666,re=1,qr=2,wt=3,Kt=4,L0=3;function ot(e,t){return e.msg=y0[t],t}function Mf(e){return(e<<1)-(e>4?9:0)}function at(e){var t=e.length;while(--t>=0)e[t]=0}function it(e){var t=e.state,r=t.pending;if(r>e.avail_out)r=e.avail_out;if(r===0)return;if(le.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0)t.pending_out=0}function oe(e,t){_e._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,it(e.strm)}function z(e,t){e.pending_buf[e.pending++]=t}function Ur(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function U0(e,t,r,n){var i=e.avail_in;if(i>n)i=n;if(i===0)return 0;if(e.avail_in-=i,le.arraySet(t,e.input,e.next_in,i,r),e.state.wrap===1)e.adler=Bf(e.adler,t,i,r);else if(e.state.wrap===2)e.adler=nt(e.adler,t,i,r);return e.next_in+=i,e.total_in+=i,i}function zf(e,t){var{max_chain_length:r,strstart:n}=e,i,a,{prev_length:s,nice_match:o}=e,h=e.strstart>e.w_size-Te?e.strstart-(e.w_size-Te):0,{window:l,w_mask:c,prev:p}=e,m=e.strstart+st,_=l[n+s-1],w=l[n+s];if(e.prev_length>=e.good_match)r>>=2;if(o>e.lookahead)o=e.lookahead;do{if(i=t,l[i+s]!==w||l[i+s-1]!==_||l[i]!==l[n]||l[++i]!==l[n+1])continue;n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<m);if(a=st-(m-n),n=m-st,a>s){if(e.match_start=t,s=a,a>=o)break;_=l[n+s-1],w=l[n+s]}}while((t=p[t&c])>h&&--r!==0);if(s<=e.lookahead)return s;return e.lookahead}function bt(e){var t=e.w_size,r,n,i,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Te)){le.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,r=n;do i=e.head[--r],e.head[r]=i>=t?i-t:0;while(--n);n=t,r=n;do i=e.prev[--r],e.prev[r]=i>=t?i-t:0;while(--n);a+=t}if(e.strm.avail_in===0)break;if(n=U0(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=M){s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;while(e.insert)if(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+M-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,e.lookahead+e.insert<M)break}}while(e.lookahead<Te&&e.strm.avail_in!==0)}function j0(e,t){var r=65535;if(r>e.pending_buf_size-5)r=e.pending_buf_size-5;for(;;){if(e.lookahead<=1){if(bt(e),e.lookahead===0&&t===xt)return re;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if(e.strstart===0||e.strstart>=n){if(e.lookahead=e.strstart-n,e.strstart=n,oe(e,!1),e.strm.avail_out===0)return re}if(e.strstart-e.block_start>=e.w_size-Te){if(oe(e,!1),e.strm.avail_out===0)return re}}if(e.insert=0,t===ft){if(oe(e,!0),e.strm.avail_out===0)return wt;return Kt}if(e.strstart>e.block_start){if(oe(e,!1),e.strm.avail_out===0)return re}return re}function xa(e,t){var r,n;for(;;){if(e.lookahead<Te){if(bt(e),e.lookahead<Te&&t===xt)return re;if(e.lookahead===0)break}if(r=0,e.lookahead>=M)e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;if(r!==0&&e.strstart-r<=e.w_size-Te)e.match_length=zf(e,r);if(e.match_length>=M)if(n=_e._tr_tally(e,e.strstart-e.match_start,e.match_length-M),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=M){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=_e._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n){if(oe(e,!1),e.strm.avail_out===0)return re}}if(e.insert=e.strstart<M-1?e.strstart:M-1,t===ft){if(oe(e,!0),e.strm.avail_out===0)return wt;return Kt}if(e.last_lit){if(oe(e,!1),e.strm.avail_out===0)return re}return qr}function Xt(e,t){var r,n,i;for(;;){if(e.lookahead<Te){if(bt(e),e.lookahead<Te&&t===xt)return re;if(e.lookahead===0)break}if(r=0,e.lookahead>=M)e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;if(e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=M-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Te){if(e.match_length=zf(e,r),e.match_length<=5&&(e.strategy===T0||e.match_length===M&&e.strstart-e.match_start>4096))e.match_length=M-1}if(e.prev_length>=M&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-M,n=_e._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-M),e.lookahead-=e.prev_length-1,e.prev_length-=2;do if(++e.strstart<=i)e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.prev_length!==0);if(e.match_available=0,e.match_length=M-1,e.strstart++,n){if(oe(e,!1),e.strm.avail_out===0)return re}}else if(e.match_available){if(n=_e._tr_tally(e,0,e.window[e.strstart-1]),n)oe(e,!1);if(e.strstart++,e.lookahead--,e.strm.avail_out===0)return re}else e.match_available=1,e.strstart++,e.lookahead--}if(e.match_available)n=_e._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0;if(e.insert=e.strstart<M-1?e.strstart:M-1,t===ft){if(oe(e,!0),e.strm.avail_out===0)return wt;return Kt}if(e.last_lit){if(oe(e,!1),e.strm.avail_out===0)return re}return qr}function q0(e,t){var r,n,i,a,s=e.window;for(;;){if(e.lookahead<=st){if(bt(e),e.lookahead<=st&&t===xt)return re;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=M&&e.strstart>0){if(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+st;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);if(e.match_length=st-(a-i),e.match_length>e.lookahead)e.match_length=e.lookahead}}if(e.match_length>=M)r=_e._tr_tally(e,1,e.match_length-M),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0;else r=_e._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r){if(oe(e,!1),e.strm.avail_out===0)return re}}if(e.insert=0,t===ft){if(oe(e,!0),e.strm.avail_out===0)return wt;return Kt}if(e.last_lit){if(oe(e,!1),e.strm.avail_out===0)return re}return qr}function W0(e,t){var r;for(;;){if(e.lookahead===0){if(bt(e),e.lookahead===0){if(t===xt)return re;break}}if(e.match_length=0,r=_e._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r){if(oe(e,!1),e.strm.avail_out===0)return re}}if(e.insert=0,t===ft){if(oe(e,!0),e.strm.avail_out===0)return wt;return Kt}if(e.last_lit){if(oe(e,!1),e.strm.avail_out===0)return re}return qr}function Ne(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var Vt;Vt=[new Ne(0,0,0,0,j0),new Ne(4,4,8,4,xa),new Ne(4,5,16,8,xa),new Ne(4,6,32,32,xa),new Ne(4,4,16,16,Xt),new Ne(8,16,32,32,Xt),new Ne(8,16,128,128,Xt),new Ne(8,32,128,256,Xt),new Ne(32,128,258,1024,Xt),new Ne(32,258,258,4096,Xt)];function $0(e){e.window_size=2*e.w_size,at(e.head),e.max_lazy_match=Vt[e.level].max_lazy,e.good_match=Vt[e.level].good_length,e.nice_match=Vt[e.level].nice_length,e.max_chain_length=Vt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=M-1,e.match_available=0,e.ins_h=0}function Z0(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=qn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new le.Buf16(M0*2),this.dyn_dtree=new le.Buf16((2*N0+1)*2),this.bl_tree=new le.Buf16((2*F0+1)*2),at(this.dyn_ltree),at(this.dyn_dtree),at(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new le.Buf16(B0+1),this.heap=new le.Buf16(2*Ea+1),at(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new le.Buf16(2*Ea+1),at(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Lf(e){var t;if(!e||!e.state)return ot(e,ye);if(e.total_in=e.total_out=0,e.data_type=I0,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0)t.wrap=-t.wrap;return t.status=t.wrap?Wn:yt,e.adler=t.wrap===2?0:1,t.last_flush=xt,_e._tr_init(t),Fe}function Uf(e){var t=Lf(e);if(t===Fe)$0(e.state);return t}function H0(e,t){if(!e||!e.state)return ye;if(e.state.wrap!==2)return ye;return e.state.gzhead=t,Fe}function jf(e,t,r,n,i,a){if(!e)return ye;var s=1;if(t===E0)t=6;if(n<0)s=0,n=-n;else if(n>15)s=2,n-=16;if(i<1||i>C0||r!==qn||n<8||n>15||t<0||t>9||a<0||a>k0)return ot(e,ye);if(n===8)n=9;var o=new Z0;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+M-1)/M),o.window=new le.Buf8(o.w_size*2),o.head=new le.Buf16(o.hash_size),o.prev=new le.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new le.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=a,o.method=r,Uf(e)}function G0(e,t){return jf(e,t,qn,D0,O0,A0)}function X0(e,t){var r,n,i,a;if(!e||!e.state||t>Nf||t<0)return e?ot(e,ye):ye;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===jr&&t!==ft)return ot(e,e.avail_out===0?ba:ye);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===Wn)if(n.wrap===2)if(e.adler=0,z(n,31),z(n,139),z(n,8),!n.gzhead)z(n,0),z(n,0),z(n,0),z(n,0),z(n,0),z(n,n.level===9?2:n.strategy>=zn||n.level<2?4:0),z(n,L0),n.status=yt;else{if(z(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(!n.gzhead.extra?0:4)+(!n.gzhead.name?0:8)+(!n.gzhead.comment?0:16)),z(n,n.gzhead.time&255),z(n,n.gzhead.time>>8&255),z(n,n.gzhead.time>>16&255),z(n,n.gzhead.time>>24&255),z(n,n.level===9?2:n.strategy>=zn||n.level<2?4:0),z(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length)z(n,n.gzhead.extra.length&255),z(n,n.gzhead.extra.length>>8&255);if(n.gzhead.hcrc)e.adler=nt(e.adler,n.pending_buf,n.pending,0);n.gzindex=0,n.status=Ta}else{var s=qn+(n.w_bits-8<<4)<<8,o=-1;if(n.strategy>=zn||n.level<2)o=0;else if(n.level<6)o=1;else if(n.level===6)o=2;else o=3;if(s|=o<<6,n.strstart!==0)s|=z0;if(s+=31-s%31,n.status=yt,Ur(n,s),n.strstart!==0)Ur(n,e.adler>>>16),Ur(n,e.adler&65535);e.adler=1}if(n.status===Ta)if(n.gzhead.extra){i=n.pending;while(n.gzindex<(n.gzhead.extra.length&65535)){if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(it(e),i=n.pending,n.pending===n.pending_buf_size)break}z(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++}if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(n.gzindex===n.gzhead.extra.length)n.gzindex=0,n.status=Ln}else n.status=Ln;if(n.status===Ln)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(it(e),i=n.pending,n.pending===n.pending_buf_size){a=1;break}}if(n.gzindex<n.gzhead.name.length)a=n.gzhead.name.charCodeAt(n.gzindex++)&255;else a=0;z(n,a)}while(a!==0);if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(a===0)n.gzindex=0,n.status=Un}else n.status=Un;if(n.status===Un)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(it(e),i=n.pending,n.pending===n.pending_buf_size){a=1;break}}if(n.gzindex<n.gzhead.comment.length)a=n.gzhead.comment.charCodeAt(n.gzindex++)&255;else a=0;z(n,a)}while(a!==0);if(n.gzhead.hcrc&&n.pending>i)e.adler=nt(e.adler,n.pending_buf,n.pending-i,i);if(a===0)n.status=jn}else n.status=jn;if(n.status===jn)if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size)it(e);if(n.pending+2<=n.pending_buf_size)z(n,e.adler&255),z(n,e.adler>>8&255),e.adler=0,n.status=yt}else n.status=yt;if(n.pending!==0){if(it(e),e.avail_out===0)return n.last_flush=-1,Fe}else if(e.avail_in===0&&Mf(t)<=Mf(r)&&t!==ft)return ot(e,ba);if(n.status===jr&&e.avail_in!==0)return ot(e,ba);if(e.avail_in!==0||n.lookahead!==0||t!==xt&&n.status!==jr){var h=n.strategy===zn?W0(n,t):n.strategy===S0?q0(n,t):Vt[n.level].func(n,t);if(h===wt||h===Kt)n.status=jr;if(h===re||h===wt){if(e.avail_out===0)n.last_flush=-1;return Fe}if(h===qr){if(t===w0)_e._tr_align(n);else if(t!==Nf){if(_e._tr_stored_block(n,0,0,!1),t===b0){if(at(n.head),n.lookahead===0)n.strstart=0,n.block_start=0,n.insert=0}}if(it(e),e.avail_out===0)return n.last_flush=-1,Fe}}if(t!==ft)return Fe;if(n.wrap<=0)return Ff;if(n.wrap===2)z(n,e.adler&255),z(n,e.adler>>8&255),z(n,e.adler>>16&255),z(n,e.adler>>24&255),z(n,e.total_in&255),z(n,e.total_in>>8&255),z(n,e.total_in>>16&255),z(n,e.total_in>>24&255);else Ur(n,e.adler>>>16),Ur(n,e.adler&65535);if(it(e),n.wrap>0)n.wrap=-n.wrap;return n.pending!==0?Fe:Ff}function V0(e){var t;if(!e||!e.state)return ye;if(t=e.state.status,t!==Wn&&t!==Ta&&t!==Ln&&t!==Un&&t!==jn&&t!==yt&&t!==jr)return ot(e,ye);return e.state=null,t===yt?ot(e,x0):Fe}function K0(e,t){var r=t.length,n,i,a,s,o,h,l,c;if(!e||!e.state)return ye;if(n=e.state,s=n.wrap,s===2||s===1&&n.status!==Wn||n.lookahead)return ye;if(s===1)e.adler=Bf(e.adler,t,r,0);if(n.wrap=0,r>=n.w_size){if(s===0)at(n.head),n.strstart=0,n.block_start=0,n.insert=0;c=new le.Buf8(n.w_size),le.arraySet(c,t,r-n.w_size,n.w_size,0),t=c,r=n.w_size}o=e.avail_in,h=e.next_in,l=e.input,e.avail_in=r,e.next_in=0,e.input=t,bt(n);while(n.lookahead>=M){i=n.strstart,a=n.lookahead-(M-1);do n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+M-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++;while(--a);n.strstart=i,n.lookahead=M-1,bt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=M-1,n.match_available=0,e.next_in=h,e.input=l,e.avail_in=o,n.wrap=s,Fe}Y0.deflateInit=G0;Y0.deflateInit2=jf;Y0.deflateReset=Uf;Y0.deflateResetKeep=Lf;Y0.deflateSetHeader=H0;Y0.deflate=X0;Y0.deflateEnd=V0;Y0.deflateSetDictionary=K0;Y0.deflateInfo="pako deflate (from Nodeca project)"});var Sa=I(function(om){var $n=Xe(),Wf=!0,$f=!0;try{String.fromCharCode.apply(null,[0])}catch(e){Wf=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){$f=!1}var Wr=new $n.Buf8(256);for(Me=0;Me<256;Me++)Wr[Me]=Me>=252?6:Me>=248?5:Me>=240?4:Me>=224?3:Me>=192?2:1;var Me;Wr[254]=Wr[254]=1;om.string2buf=function(e){var t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++){if(r=e.charCodeAt(i),(r&64512)===55296&&i+1<s){if(n=e.charCodeAt(i+1),(n&64512)===56320)r=65536+(r-55296<<10)+(n-56320),i++}o+=r<128?1:r<2048?2:r<65536?3:4}t=new $n.Buf8(o);for(a=0,i=0;a<o;i++){if(r=e.charCodeAt(i),(r&64512)===55296&&i+1<s){if(n=e.charCodeAt(i+1),(n&64512)===56320)r=65536+(r-55296<<10)+(n-56320),i++}if(r<128)t[a++]=r;else if(r<2048)t[a++]=192|r>>>6,t[a++]=128|r&63;else if(r<65536)t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63;else t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63}return t};function Zf(e,t){if(t<65534){if(e.subarray&&$f||!e.subarray&&Wf)return String.fromCharCode.apply(null,$n.shrinkBuf(e,t))}var r="";for(var n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}om.buf2binstring=function(e){return Zf(e,e.length)};om.binstring2buf=function(e){var t=new $n.Buf8(e.length);for(var r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t};om.buf2string=function(e,t){var r,n,i,a,s=t||e.length,o=Array(s*2);for(n=0,r=0;r<s;){if(i=e[r++],i<128){o[n++]=i;continue}if(a=Wr[i],a>4){o[n++]=65533,r+=a-1;continue}i&=a===2?31:a===3?15:7;while(a>1&&r<s)i=i<<6|e[r++]&63,a--;if(a>1){o[n++]=65533;continue}if(i<65536)o[n++]=i;else i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|i&1023}return Zf(o,n)};om.utf8border=function(e,t){var r;if(t=t||e.length,t>e.length)t=e.length;r=t-1;while(r>=0&&(e[r]&192)===128)r--;if(r<0)return t;if(r===0)return t;return r+Wr[e[r]]>t?r:t}});var ka=I(function(Lb,Hf){function dm(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}Hf.exports=dm});var Kf=I(function(bm){var $r=qf(),Zr=Xe(),Ia=Sa(),Ca=Bn(),pm=ka(),Vf=Object.prototype.toString,gm=0,Aa=4,Yt=0,Gf=1,Xf=2,mm=-1,vm=0,_m=8;function Et(e){if(!(this instanceof Et))return new Et(e);this.options=Zr.assign({level:mm,method:_m,chunkSize:16384,windowBits:15,memLevel:8,strategy:vm,to:""},e||{});var t=this.options;if(t.raw&&t.windowBits>0)t.windowBits=-t.windowBits;else if(t.gzip&&t.windowBits>0&&t.windowBits<16)t.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pm,this.strm.avail_out=0;var r=$r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Yt)throw Error(Ca[r]);if(t.header)$r.deflateSetHeader(this.strm,t.header);if(t.dictionary){var n;if(typeof t.dictionary==="string")n=Ia.string2buf(t.dictionary);else if(Vf.call(t.dictionary)==="[object ArrayBuffer]")n=new Uint8Array(t.dictionary);else n=t.dictionary;if(r=$r.deflateSetDictionary(this.strm,n),r!==Yt)throw Error(Ca[r]);this._dict_set=!0}}Et.prototype.push=function(e,t){var r=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;if(a=t===~~t?t:t===!0?Aa:gm,typeof e==="string")r.input=Ia.string2buf(e);else if(Vf.call(e)==="[object ArrayBuffer]")r.input=new Uint8Array(e);else r.input=e;r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0)r.output=new Zr.Buf8(n),r.next_out=0,r.avail_out=n;if(i=$r.deflate(r,a),i!==Gf&&i!==Yt)return this.onEnd(i),this.ended=!0,!1;if(r.avail_out===0||r.avail_in===0&&(a===Aa||a===Xf))if(this.options.to==="string")this.onData(Ia.buf2binstring(Zr.shrinkBuf(r.output,r.next_out)));else this.onData(Zr.shrinkBuf(r.output,r.next_out))}while((r.avail_in>0||r.avail_out===0)&&i!==Gf);if(a===Aa)return i=$r.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Yt;if(a===Xf)return this.onEnd(Yt),r.avail_out=0,!0;return!0};Et.prototype.onData=function(e){this.chunks.push(e)};Et.prototype.onEnd=function(e){if(e===Yt)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=Zr.flattenChunks(this.chunks);this.chunks=[],this.err=e,this.msg=this.strm.msg};function Da(e,t){var r=new Et(t);if(r.push(e,!0),r.err)throw r.msg||Ca[r.err];return r.result}function ym(e,t){return t=t||{},t.raw=!0,Da(e,t)}function wm(e,t){return t=t||{},t.gzip=!0,Da(e,t)}bm.Deflate=Et;bm.deflate=Da;bm.deflateRaw=ym;bm.gzip=wm});var Jf=I(function(jb,Yf){var Zn=30,km=12;Yf.exports=function(t,r){var n,i,a,s,o,h,l,c,p,m,_,w,v,b,S,T,k,x,A,O,C,D,d,R,E;n=t.state,i=t.next_in,R=t.input,a=i+(t.avail_in-5),s=t.next_out,E=t.output,o=s-(r-t.avail_out),h=s+(t.avail_out-257),l=n.dmax,c=n.wsize,p=n.whave,m=n.wnext,_=n.window,w=n.hold,v=n.bits,b=n.lencode,S=n.distcode,T=(1<<n.lenbits)-1,k=(1<<n.distbits)-1;e:do{if(v<15)w+=R[i++]<<v,v+=8,w+=R[i++]<<v,v+=8;x=b[w&T];t:for(;;){if(A=x>>>24,w>>>=A,v-=A,A=x>>>16&255,A===0)E[s++]=x&65535;else if(A&16){if(O=x&65535,A&=15,A){if(v<A)w+=R[i++]<<v,v+=8;O+=w&(1<<A)-1,w>>>=A,v-=A}if(v<15)w+=R[i++]<<v,v+=8,w+=R[i++]<<v,v+=8;x=S[w&k];r:for(;;){if(A=x>>>24,w>>>=A,v-=A,A=x>>>16&255,A&16){if(C=x&65535,A&=15,v<A){if(w+=R[i++]<<v,v+=8,v<A)w+=R[i++]<<v,v+=8}if(C+=w&(1<<A)-1,C>l){t.msg="invalid distance too far back",n.mode=Zn;break e}if(w>>>=A,v-=A,A=s-o,C>A){if(A=C-A,A>p){if(n.sane){t.msg="invalid distance too far back",n.mode=Zn;break e}}if(D=0,d=_,m===0){if(D+=c-A,A<O){O-=A;do E[s++]=_[D++];while(--A);D=s-C,d=E}}else if(m<A){if(D+=c+m-A,A-=m,A<O){O-=A;do E[s++]=_[D++];while(--A);if(D=0,m<O){A=m,O-=A;do E[s++]=_[D++];while(--A);D=s-C,d=E}}}else if(D+=m-A,A<O){O-=A;do E[s++]=_[D++];while(--A);D=s-C,d=E}while(O>2)E[s++]=d[D++],E[s++]=d[D++],E[s++]=d[D++],O-=3;if(O){if(E[s++]=d[D++],O>1)E[s++]=d[D++]}}else{D=s-C;do E[s++]=E[D++],E[s++]=E[D++],E[s++]=E[D++],O-=3;while(O>2);if(O){if(E[s++]=E[D++],O>1)E[s++]=E[D++]}}}else if((A&64)===0){x=S[(x&65535)+(w&(1<<A)-1)];continue r}else{t.msg="invalid distance code",n.mode=Zn;break e}break}}else if((A&64)===0){x=b[(x&65535)+(w&(1<<A)-1)];continue t}else if(A&32){n.mode=km;break e}else{t.msg="invalid literal/length code",n.mode=Zn;break e}break}}while(i<a&&s<h);O=v>>3,i-=O,v-=O<<3,w&=(1<<v)-1,t.next_in=i,t.next_out=s,t.avail_in=i<a?5+(a-i):5-(i-a),t.avail_out=s<h?257+(h-s):257-(s-h),n.hold=w,n.bits=v;return}});var al=I(function(qb,il){var Qf=Xe(),Jt=15,el=852,tl=592,rl=0,Oa=1,nl=2,Am=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Im=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Cm=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Dm=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];il.exports=function(t,r,n,i,a,s,o,h){var l=h.bits,c=0,p=0,m=0,_=0,w=0,v=0,b=0,S=0,T=0,k=0,x,A,O,C,D,d=null,R=0,E,B=new Qf.Buf16(Jt+1),G=new Qf.Buf16(Jt+1),V=null,Ie=0,N,ne,ue;for(c=0;c<=Jt;c++)B[c]=0;for(p=0;p<i;p++)B[r[n+p]]++;w=l;for(_=Jt;_>=1;_--)if(B[_]!==0)break;if(w>_)w=_;if(_===0)return a[s++]=20971520,a[s++]=20971520,h.bits=1,0;for(m=1;m<_;m++)if(B[m]!==0)break;if(w<m)w=m;S=1;for(c=1;c<=Jt;c++)if(S<<=1,S-=B[c],S<0)return-1;if(S>0&&(t===rl||_!==1))return-1;G[1]=0;for(c=1;c<Jt;c++)G[c+1]=G[c]+B[c];for(p=0;p<i;p++)if(r[n+p]!==0)o[G[r[n+p]]++]=p;if(t===rl)d=V=o,E=19;else if(t===Oa)d=Am,R-=257,V=Im,Ie-=257,E=256;else d=Cm,V=Dm,E=-1;if(k=0,p=0,c=m,D=s,v=w,b=0,O=-1,T=1<<w,C=T-1,t===Oa&&T>el||t===nl&&T>tl)return 1;for(;;){if(N=c-b,o[p]<E)ne=0,ue=o[p];else if(o[p]>E)ne=V[Ie+o[p]],ue=d[R+o[p]];else ne=96,ue=0;x=1<<c-b,A=1<<v,m=A;do A-=x,a[D+(k>>b)+A]=N<<24|ne<<16|ue|0;while(A!==0);x=1<<c-1;while(k&x)x>>=1;if(x!==0)k&=x-1,k+=x;else k=0;if(p++,--B[c]===0){if(c===_)break;c=r[n+o[p]]}if(c>w&&(k&C)!==O){if(b===0)b=w;D+=m,v=c-b,S=1<<v;while(v+b<_){if(S-=B[v+b],S<=0)break;v++,S<<=1}if(T+=1<<v,t===Oa&&T>el||t===nl&&T>tl)return 1;O=k&C,a[O]=w<<24|v<<16|D-s|0}}if(k!==0)a[D+k]=c-b<<24|4194304|0;return h.bits=w,0}});var Ul=I(function(Vm){var me=Xe(),Ba=ya(),Be=wa(),Om=Jf(),Hr=al(),Pm=0,Ol=1,Pl=2,sl=4,Rm=5,Hn=6,Tt=0,Nm=1,Fm=2,we=-2,Rl=-3,za=-4,Mm=-5,ol=8,Nl=1,fl=2,ll=3,ul=4,cl=5,hl=6,dl=7,pl=8,gl=9,ml=10,Vn=11,Ke=12,Pa=13,vl=14,Ra=15,_l=16,yl=17,wl=18,bl=19,Gn=20,Xn=21,xl=22,El=23,Tl=24,Sl=25,kl=26,Na=27,Al=28,Il=29,H=30,La=31,Bm=32,zm=852,Lm=592,Um=15,jm=Um;function Cl(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function qm(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new me.Buf16(320),this.work=new me.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Fl(e){var t;if(!e||!e.state)return we;if(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap)e.adler=t.wrap&1;return t.mode=Nl,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new me.Buf32(zm),t.distcode=t.distdyn=new me.Buf32(Lm),t.sane=1,t.back=-1,Tt}function Ml(e){var t;if(!e||!e.state)return we;return t=e.state,t.wsize=0,t.whave=0,t.wnext=0,Fl(e)}function Bl(e,t){var r,n;if(!e||!e.state)return we;if(n=e.state,t<0)r=0,t=-t;else if(r=(t>>4)+1,t<48)t&=15;if(t&&(t<8||t>15))return we;if(n.window!==null&&n.wbits!==t)n.window=null;return n.wrap=r,n.wbits=t,Ml(e)}function zl(e,t){var r,n;if(!e)return we;if(n=new qm,e.state=n,n.window=null,r=Bl(e,t),r!==Tt)e.state=null;return r}function Wm(e){return zl(e,jm)}var Dl=!0,Fa,Ma;function $m(e){if(Dl){var t;Fa=new me.Buf32(512),Ma=new me.Buf32(32),t=0;while(t<144)e.lens[t++]=8;while(t<256)e.lens[t++]=9;while(t<280)e.lens[t++]=7;while(t<288)e.lens[t++]=8;Hr(Ol,e.lens,0,288,Fa,0,e.work,{bits:9}),t=0;while(t<32)e.lens[t++]=5;Hr(Pl,e.lens,0,32,Ma,0,e.work,{bits:5}),Dl=!1}e.lencode=Fa,e.lenbits=9,e.distcode=Ma,e.distbits=5}function Ll(e,t,r,n){var i,a=e.state;if(a.window===null)a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new me.Buf8(a.wsize);if(n>=a.wsize)me.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize;else{if(i=a.wsize-a.wnext,i>n)i=n;if(me.arraySet(a.window,t,r-n,i,a.wnext),n-=i,n)me.arraySet(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize;else{if(a.wnext+=i,a.wnext===a.wsize)a.wnext=0;if(a.whave<a.wsize)a.whave+=i}}return 0}function Zm(e,t){var r,n,i,a,s,o,h,l,c,p,m,_,w,v,b=0,S,T,k,x,A,O,C,D,d=new me.Buf8(4),R,E,B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return we;if(r=e.state,r.mode===Ke)r.mode=Pa;s=e.next_out,i=e.output,h=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,l=r.hold,c=r.bits,p=o,m=h,D=Tt;e:for(;;)switch(r.mode){case Nl:if(r.wrap===0){r.mode=Pa;break}while(c<16){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.wrap&2&&l===35615){r.check=0,d[0]=l&255,d[1]=l>>>8&255,r.check=Be(r.check,d,2,0),l=0,c=0,r.mode=fl;break}if(r.flags=0,r.head)r.head.done=!1;if(!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=H;break}if((l&15)!==ol){e.msg="unknown compression method",r.mode=H;break}if(l>>>=4,c-=4,C=(l&15)+8,r.wbits===0)r.wbits=C;else if(C>r.wbits){e.msg="invalid window size",r.mode=H;break}r.dmax=1<<C,e.adler=r.check=1,r.mode=l&512?ml:Ke,l=0,c=0;break;case fl:while(c<16){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.flags=l,(r.flags&255)!==ol){e.msg="unknown compression method",r.mode=H;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=H;break}if(r.head)r.head.text=l>>8&1;if(r.flags&512)d[0]=l&255,d[1]=l>>>8&255,r.check=Be(r.check,d,2,0);l=0,c=0,r.mode=ll;case ll:while(c<32){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.head)r.head.time=l;if(r.flags&512)d[0]=l&255,d[1]=l>>>8&255,d[2]=l>>>16&255,d[3]=l>>>24&255,r.check=Be(r.check,d,4,0);l=0,c=0,r.mode=ul;case ul:while(c<16){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.head)r.head.xflags=l&255,r.head.os=l>>8;if(r.flags&512)d[0]=l&255,d[1]=l>>>8&255,r.check=Be(r.check,d,2,0);l=0,c=0,r.mode=cl;case cl:if(r.flags&1024){while(c<16){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.length=l,r.head)r.head.extra_len=l;if(r.flags&512)d[0]=l&255,d[1]=l>>>8&255,r.check=Be(r.check,d,2,0);l=0,c=0}else if(r.head)r.head.extra=null;r.mode=hl;case hl:if(r.flags&1024){if(_=r.length,_>o)_=o;if(_){if(r.head){if(C=r.head.extra_len-r.length,!r.head.extra)r.head.extra=Array(r.head.extra_len);me.arraySet(r.head.extra,n,a,_,C)}if(r.flags&512)r.check=Be(r.check,n,_,a);o-=_,a+=_,r.length-=_}if(r.length)break e}r.length=0,r.mode=dl;case dl:if(r.flags&2048){if(o===0)break e;_=0;do if(C=n[a+_++],r.head&&C&&r.length<65536)r.head.name+=String.fromCharCode(C);while(C&&_<o);if(r.flags&512)r.check=Be(r.check,n,_,a);if(o-=_,a+=_,C)break e}else if(r.head)r.head.name=null;r.length=0,r.mode=pl;case pl:if(r.flags&4096){if(o===0)break e;_=0;do if(C=n[a+_++],r.head&&C&&r.length<65536)r.head.comment+=String.fromCharCode(C);while(C&&_<o);if(r.flags&512)r.check=Be(r.check,n,_,a);if(o-=_,a+=_,C)break e}else if(r.head)r.head.comment=null;r.mode=gl;case gl:if(r.flags&512){while(c<16){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(l!==(r.check&65535)){e.msg="header crc mismatch",r.mode=H;break}l=0,c=0}if(r.head)r.head.hcrc=r.flags>>9&1,r.head.done=!0;e.adler=r.check=0,r.mode=Ke;break;case ml:while(c<32){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}e.adler=r.check=Cl(l),l=0,c=0,r.mode=Vn;case Vn:if(r.havedict===0)return e.next_out=s,e.avail_out=h,e.next_in=a,e.avail_in=o,r.hold=l,r.bits=c,Fm;e.adler=r.check=1,r.mode=Ke;case Ke:if(t===Rm||t===Hn)break e;case Pa:if(r.last){l>>>=c&7,c-=c&7,r.mode=Na;break}while(c<3){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}switch(r.last=l&1,l>>>=1,c-=1,l&3){case 0:r.mode=vl;break;case 1:if($m(r),r.mode=Gn,t===Hn){l>>>=2,c-=2;break e}break;case 2:r.mode=yl;break;case 3:e.msg="invalid block type",r.mode=H}l>>>=2,c-=2;break;case vl:l>>>=c&7,c-=c&7;while(c<32){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=H;break}if(r.length=l&65535,l=0,c=0,r.mode=Ra,t===Hn)break e;case Ra:r.mode=_l;case _l:if(_=r.length,_){if(_>o)_=o;if(_>h)_=h;if(_===0)break e;me.arraySet(i,n,a,_,s),o-=_,a+=_,h-=_,s+=_,r.length-=_;break}r.mode=Ke;break;case yl:while(c<14){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(r.nlen=(l&31)+257,l>>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=H;break}r.have=0,r.mode=wl;case wl:while(r.have<r.ncode){while(c<3){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.lens[B[r.have++]]=l&7,l>>>=3,c-=3}while(r.have<19)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,R={bits:r.lenbits},D=Hr(Pm,r.lens,0,19,r.lencode,0,r.work,R),r.lenbits=R.bits,D){e.msg="invalid code lengths set",r.mode=H;break}r.have=0,r.mode=bl;case bl:while(r.have<r.nlen+r.ndist){for(;;){if(b=r.lencode[l&(1<<r.lenbits)-1],S=b>>>24,T=b>>>16&255,k=b&65535,S<=c)break;if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(k<16)l>>>=S,c-=S,r.lens[r.have++]=k;else{if(k===16){E=S+2;while(c<E){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(l>>>=S,c-=S,r.have===0){e.msg="invalid bit length repeat",r.mode=H;break}C=r.lens[r.have-1],_=3+(l&3),l>>>=2,c-=2}else if(k===17){E=S+3;while(c<E){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=S,c-=S,C=0,_=3+(l&7),l>>>=3,c-=3}else{E=S+7;while(c<E){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=S,c-=S,C=0,_=11+(l&127),l>>>=7,c-=7}if(r.have+_>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=H;break}while(_--)r.lens[r.have++]=C}}if(r.mode===H)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=H;break}if(r.lenbits=9,R={bits:r.lenbits},D=Hr(Ol,r.lens,0,r.nlen,r.lencode,0,r.work,R),r.lenbits=R.bits,D){e.msg="invalid literal/lengths set",r.mode=H;break}if(r.distbits=6,r.distcode=r.distdyn,R={bits:r.distbits},D=Hr(Pl,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R),r.distbits=R.bits,D){e.msg="invalid distances set",r.mode=H;break}if(r.mode=Gn,t===Hn)break e;case Gn:r.mode=Xn;case Xn:if(o>=6&&h>=258){if(e.next_out=s,e.avail_out=h,e.next_in=a,e.avail_in=o,r.hold=l,r.bits=c,Om(e,m),s=e.next_out,i=e.output,h=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,l=r.hold,c=r.bits,r.mode===Ke)r.back=-1;break}r.back=0;for(;;){if(b=r.lencode[l&(1<<r.lenbits)-1],S=b>>>24,T=b>>>16&255,k=b&65535,S<=c)break;if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(T&&(T&240)===0){x=S,A=T,O=k;for(;;){if(b=r.lencode[O+((l&(1<<x+A)-1)>>x)],S=b>>>24,T=b>>>16&255,k=b&65535,x+S<=c)break;if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=x,c-=x,r.back+=x}if(l>>>=S,c-=S,r.back+=S,r.length=k,T===0){r.mode=kl;break}if(T&32){r.back=-1,r.mode=Ke;break}if(T&64){e.msg="invalid literal/length code",r.mode=H;break}r.extra=T&15,r.mode=xl;case xl:if(r.extra){E=r.extra;while(c<E){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=El;case El:for(;;){if(b=r.distcode[l&(1<<r.distbits)-1],S=b>>>24,T=b>>>16&255,k=b&65535,S<=c)break;if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if((T&240)===0){x=S,A=T,O=k;for(;;){if(b=r.distcode[O+((l&(1<<x+A)-1)>>x)],S=b>>>24,T=b>>>16&255,k=b&65535,x+S<=c)break;if(o===0)break e;o--,l+=n[a++]<<c,c+=8}l>>>=x,c-=x,r.back+=x}if(l>>>=S,c-=S,r.back+=S,T&64){e.msg="invalid distance code",r.mode=H;break}r.offset=k,r.extra=T&15,r.mode=Tl;case Tl:if(r.extra){E=r.extra;while(c<E){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=H;break}r.mode=Sl;case Sl:if(h===0)break e;if(_=m-h,r.offset>_){if(_=r.offset-_,_>r.whave){if(r.sane){e.msg="invalid distance too far back",r.mode=H;break}}if(_>r.wnext)_-=r.wnext,w=r.wsize-_;else w=r.wnext-_;if(_>r.length)_=r.length;v=r.window}else v=i,w=s-r.offset,_=r.length;if(_>h)_=h;h-=_,r.length-=_;do i[s++]=v[w++];while(--_);if(r.length===0)r.mode=Xn;break;case kl:if(h===0)break e;i[s++]=r.length,h--,r.mode=Xn;break;case Na:if(r.wrap){while(c<32){if(o===0)break e;o--,l|=n[a++]<<c,c+=8}if(m-=h,e.total_out+=m,r.total+=m,m)e.adler=r.check=r.flags?Be(r.check,i,m,s-m):Ba(r.check,i,m,s-m);if(m=h,(r.flags?l:Cl(l))!==r.check){e.msg="incorrect data check",r.mode=H;break}l=0,c=0}r.mode=Al;case Al:if(r.wrap&&r.flags){while(c<32){if(o===0)break e;o--,l+=n[a++]<<c,c+=8}if(l!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=H;break}l=0,c=0}r.mode=Il;case Il:D=Nm;break e;case H:D=Rl;break e;case La:return za;case Bm:default:return we}if(e.next_out=s,e.avail_out=h,e.next_in=a,e.avail_in=o,r.hold=l,r.bits=c,r.wsize||m!==e.avail_out&&r.mode<H&&(r.mode<Na||t!==sl)){if(Ll(e,e.output,e.next_out,m-e.avail_out))return r.mode=La,za}if(p-=e.avail_in,m-=e.avail_out,e.total_in+=p,e.total_out+=m,r.total+=m,r.wrap&&m)e.adler=r.check=r.flags?Be(r.check,i,m,e.next_out-m):Ba(r.check,i,m,e.next_out-m);if(e.data_type=r.bits+(r.last?64:0)+(r.mode===Ke?128:0)+(r.mode===Gn||r.mode===Ra?256:0),(p===0&&m===0||t===sl)&&D===Tt)D=Mm;return D}function Hm(e){if(!e||!e.state)return we;var t=e.state;if(t.window)t.window=null;return e.state=null,Tt}function Gm(e,t){var r;if(!e||!e.state)return we;if(r=e.state,(r.wrap&2)===0)return we;return r.head=t,t.done=!1,Tt}function Xm(e,t){var r=t.length,n,i,a;if(!e||!e.state)return we;if(n=e.state,n.wrap!==0&&n.mode!==Vn)return we;if(n.mode===Vn){if(i=1,i=Ba(i,t,r,0),i!==n.check)return Rl}if(a=Ll(e,t,r,r),a)return n.mode=La,za;return n.havedict=1,Tt}Vm.inflateReset=Ml;Vm.inflateReset2=Bl;Vm.inflateResetKeep=Fl;Vm.inflateInit=Wm;Vm.inflateInit2=zl;Vm.inflate=Zm;Vm.inflateEnd=Hm;Vm.inflateGetHeader=Gm;Vm.inflateSetDictionary=Xm;Vm.inflateInfo="pako inflate (from Nodeca project)"});var Ua=I(function($b,jl){jl.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var Wl=I(function(Zb,ql){function sv(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}ql.exports=sv});var Zl=I(function(uv){var Qt=Ul(),Gr=Xe(),Kn=Sa(),Y=Ua(),ja=Bn(),ov=ka(),fv=Wl(),$l=Object.prototype.toString;function St(e){if(!(this instanceof St))return new St(e);this.options=Gr.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;if(t.raw&&t.windowBits>=0&&t.windowBits<16){if(t.windowBits=-t.windowBits,t.windowBits===0)t.windowBits=-15}if(t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits))t.windowBits+=32;if(t.windowBits>15&&t.windowBits<48){if((t.windowBits&15)===0)t.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ov,this.strm.avail_out=0;var r=Qt.inflateInit2(this.strm,t.windowBits);if(r!==Y.Z_OK)throw Error(ja[r]);if(this.header=new fv,Qt.inflateGetHeader(this.strm,this.header),t.dictionary){if(typeof t.dictionary==="string")t.dictionary=Kn.string2buf(t.dictionary);else if($l.call(t.dictionary)==="[object ArrayBuffer]")t.dictionary=new Uint8Array(t.dictionary);if(t.raw){if(r=Qt.inflateSetDictionary(this.strm,t.dictionary),r!==Y.Z_OK)throw Error(ja[r])}}}St.prototype.push=function(e,t){var r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,s,o,h,l,c=!1;if(this.ended)return!1;if(s=t===~~t?t:t===!0?Y.Z_FINISH:Y.Z_NO_FLUSH,typeof e==="string")r.input=Kn.binstring2buf(e);else if($l.call(e)==="[object ArrayBuffer]")r.input=new Uint8Array(e);else r.input=e;r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0)r.output=new Gr.Buf8(n),r.next_out=0,r.avail_out=n;if(a=Qt.inflate(r,Y.Z_NO_FLUSH),a===Y.Z_NEED_DICT&&i)a=Qt.inflateSetDictionary(this.strm,i);if(a===Y.Z_BUF_ERROR&&c===!0)a=Y.Z_OK,c=!1;if(a!==Y.Z_STREAM_END&&a!==Y.Z_OK)return this.onEnd(a),this.ended=!0,!1;if(r.next_out){if(r.avail_out===0||a===Y.Z_STREAM_END||r.avail_in===0&&(s===Y.Z_FINISH||s===Y.Z_SYNC_FLUSH))if(this.options.to==="string"){if(o=Kn.utf8border(r.output,r.next_out),h=r.next_out-o,l=Kn.buf2string(r.output,o),r.next_out=h,r.avail_out=n-h,h)Gr.arraySet(r.output,r.output,o,h,0);this.onData(l)}else this.onData(Gr.shrinkBuf(r.output,r.next_out))}if(r.avail_in===0&&r.avail_out===0)c=!0}while((r.avail_in>0||r.avail_out===0)&&a!==Y.Z_STREAM_END);if(a===Y.Z_STREAM_END)s=Y.Z_FINISH;if(s===Y.Z_FINISH)return a=Qt.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Y.Z_OK;if(s===Y.Z_SYNC_FLUSH)return this.onEnd(Y.Z_OK),r.avail_out=0,!0;return!0};St.prototype.onData=function(e){this.chunks.push(e)};St.prototype.onEnd=function(e){if(e===Y.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=Gr.flattenChunks(this.chunks);this.chunks=[],this.err=e,this.msg=this.strm.msg};function qa(e,t){var r=new St(t);if(r.push(e,!0),r.err)throw r.msg||ja[r.err];return r.result}function lv(e,t){return t=t||{},t.raw=!0,qa(e,t)}uv.Inflate=St;uv.inflate=qa;uv.inflateRaw=lv;uv.ungzip=qa});var Xl=I(function(Gb,Gl){var gv=Xe().assign,mv=Kf(),vv=Zl(),_v=Ua(),Hl={};gv(Hl,mv,vv,_v);Gl.exports=Hl});var Kl=I(function(xv){var yv=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",wv=Xl(),Vl=X(),Yn=ge(),bv=yv?"uint8array":"array";xv.magic="\b\x00";function kt(e,t){Yn.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}Vl.inherits(kt,Yn);kt.prototype.processChunk=function(e){if(this.meta=e.meta,this._pako===null)this._createPako();this._pako.push(Vl.transformTo(bv,e.data),!1)};kt.prototype.flush=function(){if(Yn.prototype.flush.call(this),this._pako===null)this._createPako();this._pako.push([],!0)};kt.prototype.cleanUp=function(){Yn.prototype.cleanUp.call(this),this._pako=null};kt.prototype._createPako=function(){this._pako=new wv[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}};xv.compressWorker=function(e){return new kt("Deflate",e)};xv.uncompressWorker=function(){return new kt("Inflate",{})}});var Wa=I(function(kv){var Yl=ge();kv.STORE={magic:"\x00\x00",compressWorker:function(){return new Yl("STORE compression")},uncompressWorker:function(){return new Yl("STORE decompression")}};kv.DEFLATE=Kl()});var $a=I(function(Cv){Cv.LOCAL_FILE_HEADER="PK\x03\x04";Cv.CENTRAL_FILE_HEADER="PK\x01\x02";Cv.CENTRAL_DIRECTORY_END="PK\x05\x06";Cv.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07";Cv.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06";Cv.DATA_DESCRIPTOR="PK\x07\b"});var tu=I(function(Yb,eu){var er=X(),tr=ge(),Za=Wt(),Jl=Rn(),Jn=$a(),W=function(e,t){var r="",n;for(n=0;n<t;n++)r+=String.fromCharCode(e&255),e=e>>>8;return r},Mv=function(e,t){var r=e;if(!e)r=t?16893:33204;return(r&65535)<<16},Bv=function(e){return(e||0)&63},Ql=function(e,t,r,n,i,a){var{file:s,compression:o}=e,h=a!==Za.utf8encode,l=er.transformTo("string",a(s.name)),c=er.transformTo("string",Za.utf8encode(s.name)),p=s.comment,m=er.transformTo("string",a(p)),_=er.transformTo("string",Za.utf8encode(p)),w=c.length!==s.name.length,v=_.length!==p.length,b,S,T="",k="",x="",{dir:A,date:O}=s,C={crc32:0,compressedSize:0,uncompressedSize:0};if(!t||r)C.crc32=e.crc32,C.compressedSize=e.compressedSize,C.uncompressedSize=e.uncompressedSize;var D=0;if(t)D|=8;if(!h&&(w||v))D|=2048;var d=0,R=0;if(A)d|=16;if(i==="UNIX")R=798,d|=Mv(s.unixPermissions,A);else R=20,d|=Bv(s.dosPermissions,A);if(b=O.getUTCHours(),b=b<<6,b=b|O.getUTCMinutes(),b=b<<5,b=b|O.getUTCSeconds()/2,S=O.getUTCFullYear()-1980,S=S<<4,S=S|O.getUTCMonth()+1,S=S<<5,S=S|O.getUTCDate(),w)k=W(1,1)+W(Jl(l),4)+c,T+="up"+W(k.length,2)+k;if(v)x=W(1,1)+W(Jl(m),4)+_,T+="uc"+W(x.length,2)+x;var E="";E+=`
12
+ \x00`,E+=W(D,2),E+=o.magic,E+=W(b,2),E+=W(S,2),E+=W(C.crc32,4),E+=W(C.compressedSize,4),E+=W(C.uncompressedSize,4),E+=W(l.length,2),E+=W(T.length,2);var B=Jn.LOCAL_FILE_HEADER+E+l+T,G=Jn.CENTRAL_FILE_HEADER+W(R,2)+E+W(m.length,2)+"\x00\x00\x00\x00"+W(d,4)+W(n,4)+l+T+m;return{fileRecord:B,dirRecord:G}},zv=function(e,t,r,n,i){var a="",s=er.transformTo("string",i(n));return a=Jn.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+W(e,2)+W(e,2)+W(t,4)+W(r,4)+W(s.length,2)+s,a},Lv=function(e){var t="";return t=Jn.DATA_DESCRIPTOR+W(e.crc32,4)+W(e.compressedSize,4)+W(e.uncompressedSize,4),t};function Se(e,t,r,n){tr.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}er.inherits(Se,tr);Se.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;if(this.accumulate)this.contentBuffer.push(e);else this.bytesWritten+=e.data.length,tr.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}})};Se.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=Ql(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0};Se.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=Ql(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:Lv(e),meta:{percent:100}});else{this.push({data:r.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};Se.prototype.flush=function(){var e=this.bytesWritten;for(var t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=zv(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})};Se.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};Se.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(r){t.processChunk(r)}),e.on("end",function(){if(t.closedSource(t.previous.streamInfo),t._sources.length)t.prepareNextSource();else t.end()}),e.on("error",function(r){t.error(r)}),this};Se.prototype.resume=function(){if(!tr.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};Se.prototype.error=function(e){var t=this._sources;if(!tr.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(n){}return!0};Se.prototype.lock=function(){tr.prototype.lock.call(this);var e=this._sources;for(var t=0;t<e.length;t++)e[t].lock()};eu.exports=Se});var ru=I(function(Wv){var Uv=Wa(),jv=tu(),qv=function(e,t){var r=e||t,n=Uv[r];if(!n)throw Error(r+" is not a valid compression method !");return n};Wv.generateWorker=function(e,t,r){var n=new jv(t.streamFiles,r,t.platform,t.encodeFileName),i=0;try{e.forEach(function(a,s){i++;var o=qv(s.options.compression,t.compression),h=s.options.compressionOptions||t.compressionOptions||{},{dir:l,date:c}=s;s._compressWorker(o,h).withStreamInfo("file",{name:a,dir:l,date:c,comment:s.comment||"",unixPermissions:s.unixPermissions,dosPermissions:s.dosPermissions}).pipe(n)}),n.entriesCount=i}catch(a){n.error(a)}return n}});var iu=I(function(Qb,nu){var Zv=X(),Qn=ge();function Xr(e,t){Qn.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}Zv.inherits(Xr,Qn);Xr.prototype._bindStream=function(e){var t=this;this._stream=e,e.pause(),e.on("data",function(r){t.push({data:r,meta:{percent:0}})}).on("error",function(r){if(t.isPaused)this.generatedError=r;else t.error(r)}).on("end",function(){if(t.isPaused)t._upstreamEnded=!0;else t.end()})};Xr.prototype.pause=function(){if(!Qn.prototype.pause.call(this))return!1;return this._stream.pause(),!0};Xr.prototype.resume=function(){if(!Qn.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};nu.exports=Xr});var pu=I(function(ex,du){var Hv=Wt(),Vr=X(),fu=ge(),Gv=Ki(),lu=Yi(),au=Nn(),Xv=sf(),Vv=ru(),su=Ar(),Kv=iu(),uu=function(e,t,r){var n=Vr.getTypeOf(t),i,a=Vr.extend(r||{},lu);if(a.date=a.date||new Date,a.compression!==null)a.compression=a.compression.toUpperCase();if(typeof a.unixPermissions==="string")a.unixPermissions=parseInt(a.unixPermissions,8);if(a.unixPermissions&&a.unixPermissions&16384)a.dir=!0;if(a.dosPermissions&&a.dosPermissions&16)a.dir=!0;if(a.dir)e=cu(e);if(a.createFolders&&(i=Yv(e)))hu.call(this,i,!0);var s=n==="string"&&a.binary===!1&&a.base64===!1;if(!r||typeof r.binary>"u")a.binary=!s;var o=t instanceof au&&t.uncompressedSize===0;if(o||a.dir||!t||t.length===0)a.base64=!1,a.binary=!0,t="",a.compression="STORE",n="string";var h=null;if(t instanceof au||t instanceof fu)h=t;else if(su.isNode&&su.isStream(t))h=new Kv(e,t);else h=Vr.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var l=new Xv(e,h,a);this.files[e]=l},Yv=function(e){if(e.slice(-1)==="/")e=e.substring(0,e.length-1);var t=e.lastIndexOf("/");return t>0?e.substring(0,t):""},cu=function(e){if(e.slice(-1)!=="/")e+="/";return e},hu=function(e,t){if(t=typeof t<"u"?t:lu.createFolders,e=cu(e),!this.files[e])uu.call(this,e,null,{dir:!0,createFolders:t});return this.files[e]};function ou(e){return Object.prototype.toString.call(e)==="[object RegExp]"}var Jv={load:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)if(n=this.files[t],r=t.slice(this.root.length,t.length),r&&t.slice(0,this.root.length)===this.root)e(r,n)},filter:function(e){var t=[];return this.forEach(function(r,n){if(e(r,n))t.push(n)}),t},file:function(e,t,r){if(arguments.length===1)if(ou(e)){var n=e;return this.filter(function(a,s){return!s.dir&&n.test(a)})}else{var i=this.files[this.root+e];if(i&&!i.dir)return i;else return null}else e=this.root+e,uu.call(this,e,t,r);return this},folder:function(e){if(!e)return this;if(ou(e))return this.filter(function(i,a){return a.dir&&e.test(i)});var t=this.root+e,r=hu.call(this,t),n=this.clone();return n.root=r.name,n},remove:function(e){e=this.root+e;var t=this.files[e];if(!t){if(e.slice(-1)!=="/")e+="/";t=this.files[e]}if(t&&!t.dir)delete this.files[e];else{var r=this.filter(function(i,a){return a.name.slice(0,e.length)===e});for(var n=0;n<r.length;n++)delete this.files[r[n].name]}return this},generate:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if(r=Vr.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:Hv.utf8encode}),r.type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),r.type==="binarystring")r.type="string";if(!r.type)throw Error("No output type specified.");if(Vr.checkSupport(r.type),r.platform==="darwin"||r.platform==="freebsd"||r.platform==="linux"||r.platform==="sunos")r.platform="UNIX";if(r.platform==="win32")r.platform="DOS";var n=r.comment||this.comment||"";t=Vv.generateWorker(this,r,n)}catch(i){t=new fu("error"),t.error(i)}return new Gv(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){if(e=e||{},!e.type)e.type="nodebuffer";return this.generateInternalStream(e).toNodejsStream(t)}};du.exports=Jv});var Ha=I(function(tx,mu){var Qv=X();function gu(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}gu.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t=0,r;this.checkOffset(e);for(r=this.index+e-1;r>=this.index;r--)t=(t<<8)+this.byteAt(r);return this.index+=e,t},readString:function(e){return Qv.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC((e>>25&127)+1980,(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(e&31)<<1))}};mu.exports=gu});var Ga=I(function(rx,_u){var vu=Ha(),e_=X();function rr(e){vu.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=e[t]&255}e_.inherits(rr,vu);rr.prototype.byteAt=function(e){return this.data[this.zero+e]};rr.prototype.lastIndexOfSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3);for(var a=this.length-4;a>=0;--a)if(this.data[a]===t&&this.data[a+1]===r&&this.data[a+2]===n&&this.data[a+3]===i)return a-this.zero;return-1};rr.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),a=this.readData(4);return t===a[0]&&r===a[1]&&n===a[2]&&i===a[3]};rr.prototype.readData=function(e){if(this.checkOffset(e),e===0)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};_u.exports=rr});var bu=I(function(nx,wu){var yu=Ha(),t_=X();function nr(e){yu.call(this,e)}t_.inherits(nr,yu);nr.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)};nr.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero};nr.prototype.readAndCheckSignature=function(e){var t=this.readData(4);return e===t};nr.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};wu.exports=nr});var Va=I(function(ix,Eu){var xu=Ga(),r_=X();function Xa(e){xu.call(this,e)}r_.inherits(Xa,xu);Xa.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};Eu.exports=Xa});var ku=I(function(ax,Su){var Tu=Va(),n_=X();function Ka(e){Tu.call(this,e)}n_.inherits(Ka,Tu);Ka.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};Su.exports=Ka});var Ya=I(function(sx,Iu){var ei=X(),Au=Ge(),i_=Ga(),a_=bu(),s_=ku(),o_=Va();Iu.exports=function(e){var t=ei.getTypeOf(e);if(ei.checkSupport(t),t==="string"&&!Au.uint8array)return new a_(e);if(t==="nodebuffer")return new s_(e);if(Au.uint8array)return new o_(ei.transformTo("uint8array",e));return new i_(ei.transformTo("array",e))}});var Pu=I(function(ox,Ou){var Ja=Ya(),lt=X(),f_=Nn(),Cu=Rn(),ti=Wt(),ri=Wa(),l_=Ge(),u_=0,c_=3,h_=function(e){for(var t in ri){if(!Object.prototype.hasOwnProperty.call(ri,t))continue;if(ri[t].magic===e)return ri[t]}return null};function Du(e,t){this.options=e,this.loadOptions=t}Du.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(t=h_(this.compressionMethod),t===null)throw Error("Corrupted zip : compression "+lt.pretty(this.compressionMethod)+" unknown (inner file : "+lt.transformTo("string",this.fileName)+")");this.decompressed=new f_(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;if(this.dir=this.externalFileAttributes&16?!0:!1,e===u_)this.dosPermissions=this.externalFileAttributes&63;if(e===c_)this.unixPermissions=this.externalFileAttributes>>16&65535;if(!this.dir&&this.fileNameStr.slice(-1)==="/")this.dir=!0},parseZIP64ExtraField:function(){if(!this.extraFields[1])return;var e=Ja(this.extraFields[1].value);if(this.uncompressedSize===lt.MAX_VALUE_32BITS)this.uncompressedSize=e.readInt(8);if(this.compressedSize===lt.MAX_VALUE_32BITS)this.compressedSize=e.readInt(8);if(this.localHeaderOffset===lt.MAX_VALUE_32BITS)this.localHeaderOffset=e.readInt(8);if(this.diskNumberStart===lt.MAX_VALUE_32BITS)this.diskNumberStart=e.readInt(4)},readExtraFields:function(e){var t=e.index+this.extraFieldsLength,r,n,i;if(!this.extraFields)this.extraFields={};while(e.index+4<t)r=e.readInt(2),n=e.readInt(2),i=e.readData(n),this.extraFields[r]={id:r,length:n,value:i};e.setIndex(t)},handleUTF8:function(){var e=l_.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=ti.utf8decode(this.fileName),this.fileCommentStr=ti.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(t!==null)this.fileNameStr=t;else{var r=lt.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(n!==null)this.fileCommentStr=n;else{var i=lt.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=Ja(e.value);if(t.readInt(1)!==1)return null;if(Cu(this.fileName)!==t.readInt(4))return null;return ti.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=Ja(e.value);if(t.readInt(1)!==1)return null;if(Cu(this.fileComment)!==t.readInt(4))return null;return ti.utf8decode(t.readData(e.length-5))}return null}};Ou.exports=Du});var Fu=I(function(fx,Nu){var d_=Ya(),Ye=X(),ke=$a(),p_=Pu(),g_=Ge();function Ru(e){this.files=[],this.loadOptions=e}Ru.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw Error("Corrupted zip or bug: unexpected signature ("+Ye.pretty(t)+", expected "+Ye.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4),i=n===t;return this.reader.setIndex(r),i},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=g_.uint8array?"uint8array":"array",r=Ye.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};var e=this.zip64EndOfCentralSize-44,t=0,r,n,i;while(t<e)r=this.reader.readInt(2),n=this.reader.readInt(4),i=this.reader.readData(n),this.zip64ExtensibleData[r]={id:r,length:n,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(ke.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;this.reader.setIndex(this.centralDirOffset);while(this.reader.readAndCheckSignature(ke.CENTRAL_FILE_HEADER))e=new p_({zip64:this.zip64},this.loadOptions),e.readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length){if(this.centralDirRecords!==0&&this.files.length===0)throw Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)}},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(ke.CENTRAL_DIRECTORY_END);if(e<0){var t=!this.isSignature(0,ke.LOCAL_FILE_HEADER);if(t)throw Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");else throw Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(e);var r=e;if(this.checkSignature(ke.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===Ye.MAX_VALUE_16BITS||this.diskWithCentralDirStart===Ye.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===Ye.MAX_VALUE_16BITS||this.centralDirRecords===Ye.MAX_VALUE_16BITS||this.centralDirSize===Ye.MAX_VALUE_32BITS||this.centralDirOffset===Ye.MAX_VALUE_32BITS){if(this.zip64=!0,e=this.reader.lastIndexOfSignature(ke.ZIP64_CENTRAL_DIRECTORY_LOCATOR),e<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(ke.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,ke.ZIP64_CENTRAL_DIRECTORY_END)){if(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(ke.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory")}this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(ke.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var n=this.centralDirOffset+this.centralDirSize;if(this.zip64)n+=20,n+=12+this.zip64EndOfCentralSize;var i=r-n;if(i>0)if(this.isSignature(r,ke.CENTRAL_FILE_HEADER));else this.reader.zero=i;else if(i<0)throw Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},prepareReader:function(e){this.reader=d_(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};Nu.exports=Ru});var zu=I(function(lx,Bu){var Qa=X(),ni=Ut(),m_=Wt(),v_=Fu(),__=ea(),Mu=Ar();function y_(e){return new ni.Promise(function(t,r){var n=e.decompressed.getContentWorker().pipe(new __);n.on("error",function(i){r(i)}).on("end",function(){if(n.streamInfo.crc32!==e.decompressed.crc32)r(Error("Corrupted zip : CRC32 mismatch"));else t()}).resume()})}Bu.exports=function(e,t){var r=this;if(t=Qa.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:m_.utf8decode}),Mu.isNode&&Mu.isStream(e))return ni.Promise.reject(Error("JSZip can't accept a stream when loading a zip file."));return Qa.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(n){var i=new v_(t);return i.load(n),i}).then(function(i){var a=[ni.Promise.resolve(i)],s=i.files;if(t.checkCRC32)for(var o=0;o<s.length;o++)a.push(y_(s[o]));return ni.Promise.all(a)}).then(function(i){var a=i.shift(),s=a.files;for(var o=0;o<s.length;o++){var h=s[o],l=h.fileNameStr,c=Qa.resolve(h.fileNameStr);if(r.file(c,h.decompressed,{binary:!0,optimizedBinaryString:!0,date:h.date,dir:h.dir,comment:h.fileCommentStr.length?h.fileCommentStr:null,unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions,createFolders:t.createFolders}),!h.dir)r.file(c).unsafeOriginalName=l}if(a.zipComment.length)r.comment=a.zipComment;return r})}});var Uu=I(function(ux,Lu){function be(){if(!(this instanceof be))return new be;if(arguments.length)throw Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new be;for(var t in this)if(typeof this[t]!=="function")e[t]=this[t];return e}}be.prototype=pu();be.prototype.loadAsync=zu();be.support=Ge();be.defaults=Yi();be.version="3.10.1";be.loadAsync=function(e,t){return new be().loadAsync(e,t)};be.external=Ut();Lu.exports=be});import{createRequire as w_}from"module";function Gu(e,t){return R_(e,{i:2},t&&t.out,t&&t.dictionary)}var b_,ar,x_,E_,xe,ir,T_,ju,qu,S_,Wu=function(e,t){var r=new ir(31);for(var n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new T_(r[30]);for(var n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return{b:r,r:i}},ar,$u,k_,Zu,A_,hx,rs,ze,F,Kr=function(e,t,r){var n=e.length,i=0,a=new ir(t);for(;i<n;++i)if(e[i])++a[e[i]-1];var s=new ir(t);for(i=1;i<t;++i)s[i]=s[i-1]+a[i-1]<<1;var o;if(r){o=new ir(1<<t);var h=15-t;for(i=0;i<n;++i)if(e[i]){var l=i<<4|e[i],c=t-e[i],p=s[e[i]-1]++<<c;for(var m=p|(1<<c)-1;p<=m;++p)o[rs[p]>>h]=l}}else{o=new ir(n);for(i=0;i<n;++i)if(e[i])o[i]=rs[s[e[i]-1]++]>>15-e[i]}return o},Yr,F,F,F,F,Hu,F,I_,C_,es=function(e){var t=e[0];for(var r=1;r<e.length;++r)if(e[r]>t)t=e[r];return t},Ae=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},ts=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},D_=function(e){return(e+7)/8|0},O_=function(e,t,r){if(t==null||t<0)t=0;if(r==null||r>e.length)r=e.length;return new xe(e.subarray(t,r))},P_,Je=function(e,t,r){var n=Error(t||P_[e]);if(n.code=e,Error.captureStackTrace)Error.captureStackTrace(n,Je);if(!r)throw n;return n},R_=function(e,t,r,n){var i=e.length,a=n?n.length:0;if(!i||t.f&&!t.l)return r||new xe(0);var s=!r,o=s||t.i!=2,h=t.i;if(s)r=new xe(i*3);var l=function(ln){var u=r.length;if(ln>u){var f=new xe(Math.max(u*2,ln));f.set(r),r=f}},c=t.f||0,p=t.p||0,m=t.b||0,{l:_,d:w,m:v,n:b}=t,S=i*8;do{if(!_){c=Ae(e,p,1);var T=Ae(e,p+1,3);if(p+=3,!T){var k=D_(p)+4,x=e[k-4]|e[k-3]<<8,A=k+x;if(A>i){if(h)Je(0);break}if(o)l(m+x);r.set(e.subarray(k,A),m),t.b=m+=x,t.p=p=A*8,t.f=c;continue}else if(T==1)_=I_,w=C_,v=9,b=5;else if(T==2){var O=Ae(e,p,31)+257,C=Ae(e,p+10,15)+4,D=O+Ae(e,p+5,31)+1;p+=14;var d=new xe(D),R=new xe(19);for(var E=0;E<C;++E)R[S_[E]]=Ae(e,p+E*3,7);p+=C*3;var B=es(R),G=(1<<B)-1,V=Kr(R,B,1);for(var E=0;E<D;){var Ie=V[Ae(e,p,G)];p+=Ie&15;var k=Ie>>4;if(k<16)d[E++]=k;else{var N=0,ne=0;if(k==16)ne=3+Ae(e,p,3),p+=2,N=d[E-1];else if(k==17)ne=3+Ae(e,p,7),p+=3;else if(k==18)ne=11+Ae(e,p,127),p+=7;while(ne--)d[E++]=N}}var ue=d.subarray(0,O),ee=d.subarray(O);v=es(ue),b=es(ee),_=Kr(ue,v,1),w=Kr(ee,b,1)}else Je(1);if(p>S){if(h)Je(0);break}}if(o)l(m+131072);var on=(1<<v)-1,U=(1<<b)-1,hr=p;for(;;hr=p){var N=_[ts(e,p)&on],Ce=N>>4;if(p+=N&15,p>S){if(h)Je(0);break}if(!N)Je(2);if(Ce<256)r[m++]=Ce;else if(Ce==256){hr=p,_=null;break}else{var Ct=Ce-254;if(Ce>264){var E=Ce-257,pe=ju[E];Ct=Ae(e,p,(1<<pe)-1)+$u[E],p+=pe}var ht=w[ts(e,p)&U],dr=ht>>4;if(!ht)Je(3);p+=ht&15;var ee=A_[dr];if(dr>3){var pe=qu[dr];ee+=ts(e,p)&(1<<pe)-1,p+=pe}if(p>S){if(h)Je(0);break}if(o)l(m+131072);var fn=m+Ct;if(m<ee){var pr=a-ee,gr=Math.min(ee,fn);if(pr+m<0)Je(3);for(;m<gr;++m)r[m]=n[pr+m]}for(;m<fn;++m)r[m]=r[m-ee]}}if(t.l=_,t.p=hr,t.b=m,t.f=c,_)c=1,t.m=v,t.d=w,t.n=b}while(!c);return m!=r.length&&s?O_(r,0,m):r.subarray(0,m)},N_,F_,M_=0;var Xu=pi(()=>{b_=w_("/");try{ar=b_("worker_threads"),x_=ar.Worker,E_=ar.isMarkedAsUntransferable}catch(e){}xe=Uint8Array,ir=Uint16Array,T_=Int32Array,ju=new xe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qu=new xe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),S_=new xe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ar=Wu(ju,2),$u=ar.b,k_=ar.r;$u[28]=258,k_[258]=28;Zu=Wu(qu,0),A_=Zu.b,hx=Zu.r,rs=new ir(32768);for(F=0;F<32768;++F)ze=(F&43690)>>1|(F&21845)<<1,ze=(ze&52428)>>2|(ze&13107)<<2,ze=(ze&61680)>>4|(ze&3855)<<4,rs[F]=((ze&65280)>>8|(ze&255)<<8)>>1;Yr=new xe(288);for(F=0;F<144;++F)Yr[F]=8;for(F=144;F<256;++F)Yr[F]=9;for(F=256;F<280;++F)Yr[F]=7;for(F=280;F<288;++F)Yr[F]=8;Hu=new xe(32);for(F=0;F<32;++F)Hu[F]=5;I_=Kr(Yr,9,1),C_=Kr(Hu,5,1),P_=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],N_=new xe(0);F_=typeof TextDecoder<"u"&&new TextDecoder;try{F_.decode(N_,{stream:!0}),M_=1}catch(e){}});import B_,{writeFileSync as z_,existsSync as L_,mkdirSync as U_,unlink as j_,readFileSync as q_}from"node:fs";import{Buffer as as}from"node:buffer";import ii from"node:crypto";function Qu(e,t,r){z_(e,t,r)}function W_(e,t){return q_(e)}function Vu(e){return L_(e)}function $_(e,t){return U_(e,t)}function Z_(e){j_(e,()=>{})}async function X_(e){let t=new ec(e);return await t.loadZip(),t}class ec{constructor(e){this.filePath=e,ns(this,"jsZip"),ns(this,"names"),ns(this,"pathToProcessors",{})}getNames(){return[...this.names.values()]}useDeprocessors(e){this.pathToProcessors={...this.pathToProcessors,...e}}async loadZip(){this.jsZip=await this.readZip(this.filePath),this.names=new Map(Object.keys(this.jsZip.files).map((e)=>[e.toLowerCase(),e]))}async readZip(e){return new Promise((t,r)=>{{let n=typeof e==="string"?new Uint8Array(B_.readFileSync(e)):e;new Ju.default().loadAsync(n).then((i)=>{t(i)})}})}async readFile(e){let t=await this.readResource(e);return new TextDecoder().decode(t)}async readResource(e){if(!this.hasFile(e))return console.warn(`${e} file was not exit in ${this.filePath}, return an empty uint8 array`),new Uint8Array;let t=this.getFileName(e),r=await this.jsZip.file(t).async("uint8array");if(this.pathToProcessors[t])for(let n of this.pathToProcessors[t])r=await n(r);return r}hasFile(e){return this.names.has(e.toLowerCase())}getFileName(e){return this.names.get(e.toLowerCase())}}function is(e){let t=new Set;for(let r of String(e).matchAll(/xmlns:([\w.-]+)\s*=\s*["']([^"']*)["']/g))if(J_.has(r[2].trim().replace(/\/+$/,"")))t.add(r[1]);return{tagNameProcessors:[(r)=>{let n=r.indexOf(":");return n>0&&t.has(r.slice(0,n))?r.slice(n+1):r}]}}function Q_(e){let t={};if(e.rsaPrivateKey)t.rsaPrivateKey=typeof e.rsaPrivateKey==="string"?Uint8Array.from(atob(e.rsaPrivateKey),(r)=>r.charCodeAt(0)):e.rsaPrivateKey;if(e.aesSymmetricKey)t.aesSymmetricKey=typeof e.aesSymmetricKey==="string"?Uint8Array.from(atob(e.aesSymmetricKey),(r)=>r.charCodeAt(0)):e.aesSymmetricKey;return t}function ey(e){let t=new Map;return(...r)=>{let n=JSON.stringify(r);if(t.has(n))return t.get(n);let i=e(...r);return t.set(n,i),i}}function ty(e){if(e.endsWith("s"))return Number.parseFloat(e);let t=e.split(":").map(Number);if(t.length===3){let[r,n,i]=t;return r*3600+n*60+i}else if(t.length===2){let[r,n]=t;return r*60+n}else return Number(e)}async function ry(e,t,r="sha256"){{let n=as.from(t,"base64"),i=ii.createPrivateKey({key:as.from(e),format:"der",type:"pkcs8"}),a=ii.privateDecrypt({key:i,padding:ii.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:r},n);return new Uint8Array(a)}}async function Yu(e,t,r){{let n=e.endsWith("gcm"),i=n?12:16,a=n?16:0,s=r.slice(0,i),o=n?r.slice(r.length-a):void 0,h=r.slice(i,r.length-a),l=ii.createDecipheriv(e,t,s);if(n&&o)l.setAuthTag(o);let c=as.concat([l.update(h),l.final()]);return new Uint8Array(c)}}function ny(e){let t=e.trim().toLowerCase();if(t!=="application/epub+zip")throw Error("Unsupported mime type. The mimetype file must be the application/epub+zip");return t}function iy(e){let t=e.container;if(!t||!t.rootfiles||t.rootfiles.length===0)throw Error("No <rootfiles></rootfiles> tag found in meta-inf/container.xml");let r=t.rootfiles[0].rootfile[0];if(r.$["media-type"]!=="application/oebps-package+xml")throw Error("media-type of <rootfile/> application/oebps-package+xml");let i=r.$["full-path"];if(J.isAbsolutePosix(i))throw Error("full-path must be a relative path");return i}function ay(e){let t={title:"",language:"",identifier:{id:""},packageIdentifier:{id:""},metas:{}},r=new Map;for(let s in e){let o=e[s],h=s.split(":").pop();switch(h){case"title":case"language":case"description":case"publisher":case"type":case"format":case"source":case"relation":case"coverage":case"rights":{t[h]=o[0]._??o[0];break}case"date":{t.date={};for(let l of o){let c=l.$?.["opf:event"]??"publication";t.date[c]=l._??l}break}case"identifier":{for(let l of o){let c={id:l._,scheme:l.$?.["opf:scheme"]??""},p=l.$&&l.$.id;if(p)t.packageIdentifier=c,r.set(p,c);else t.identifier=c}break}case"subject":{t.subject=[];for(let l of o){let c=l.$,p={subject:l._??l,authority:c?.authority??"",term:c?.term??""};if(t.subject.push(p),l.$?.id)r.set(l.$.id,p)}break}case"creator":case"contributor":{t[h]=[];for(let l of o){let c=l.$,p={contributor:l._??l,fileAs:c?.["opf:file-as"]??"",role:c?.["opf:role"]??""};if(t[h].push(p),c?.id)r.set(c.id,p)}break}}}let n=e.meta??[];for(let s of n){let o=s.$;if(s._)if(o.refines){let h=o.refines.slice(1),l=r.get(h);if(!l){console.warn(`No element with id "${h}" found when parsing <metadata>`);continue}let c=hn(o.property);if("contributor"in l)l[c]||(l[c]=s._);else if("subject"in l)l[c]||(l[c]=s._);else if("id"in l)l[c]||(l[c]=s._),l.scheme=l.scheme||o.scheme}else{let h=o.property;t.metas[h]=s._}else{let h=o.name;t.metas[h]=o.content}}let i=e.link??[],a=[];for(let s of i){let o=s.$;if(!o.refines){let h={href:"",rel:""};for(let l in o)h[hn(l)]=o[l];a.push(h)}else{let h=o.refines.slice(1),l=r.get(h);if(!l){console.warn(`No element with id "${h}" found when parsing <metadata>`);continue}let c=hn(o.rel),p=o.href;l[c]=p}}return t.links=a,t}function sy(e,t){let r=e.item;if(!r)throw Error("The manifest element must contain one or more item elements");let n={},i=[];for(let a of r){let s=a.$,{id:o,href:h,"media-type":l,"media-overlay":c,properties:p}=s;if(!s||!o||!h||!l){console.warn("The item in manifest must have attributes id, href and mediaType. So skip this item.");continue}if(n[o]={id:o,href:J.joinPosix(t,h),mediaType:l,properties:p||"",mediaOverlay:c||""},s.fallback)n[o].fallback=[s.fallback],i.push(n[o])}for(let a of i){let s=new Set;s.add(a.id);let o=n[a.fallback[0]];while(o&&o.fallback){s.add(o.id);let h=o.fallback;if(h.length>1){a.fallback.push(...h);break}let l=h[0];if(s.has(l)){console.warn(`Cycle references have appeard when next item id is "${l}". Therefore stop parsing.`);break}a.fallback.push(l),o=n[l]}}return n}function oy(e,t){let r="";if(e.$?.toc)r=t[e.$.toc]?.href??"";let n=[],i=e.itemref;if(!i)throw Error("The spine element must contain one or more itemref elements");for(let a of i){let s=a.$;if(s.idref){let o=t[s.idref];if(!o)continue;n.push({...o,href:`epub:${o.href}`,linear:s.linear||"yes"})}}return{tocPath:r,spine:n}}function fy(e,t){let r=[],n=e.reference;if(!n)return r;for(let i of n){let a=i.$;if(a.href&&a.href.length>0)a.href=or+J.joinPosix(t,a.href);r.push(a)}return r}function ly(e,t){let r=[];for(let n of e){let i=n.$.role,a=[];for(let s of n.link)a.push(J.joinPosix(t,s.$.href));r.push({role:i,links:a})}return r}function uy(e,t,r){let n=[];return tc(n,e?.navPoint??[],t,r),n}function tc(e,t,r,n){for(let i of t){let a={label:"",href:"",id:"",playOrder:""};if(i.navLabel){let s=J.joinPosix(n,decodeURIComponent(i.content[0].$?.src)),o=s.split("#")[0];a={label:i.navLabel[0].text?.[0]??"",href:or+s,id:r[o],playOrder:i.$?.playOrder??""},e.push(a)}if(i.navPoint)a.children=[],tc(a.children,i.navPoint,r,n)}}function cy(e,t,r){let n="";if(e.navLabel)n=e.navLabel[0].text[0];let i=[];for(let a of e.pageTarget){let s=J.joinPosix(r,decodeURIComponent(a.content[0].$?.src)),o=s.split("#")[0],h=a.$,l={label:a.navLabel[0].text[0]||"",value:h.value||"",href:or+s,playOrder:h.playOrder||"",type:h.type||"",correspondId:t[o]};i.push(l)}return{label:n,pageTargets:i}}function hy(e,t,r){let n="";if(e.navLabel)n=e.navLabel[0].text[0];let i=[];for(let a of e.navTarget){let s=J.joinPosix(r,decodeURIComponent(a.content[0].$?.src)),o=s.split("#")[0],h={label:a.navLabel[0]?.text?.[0]||"",href:or+s,correspondId:t[o]};i.push(h)}return{label:n,navTargets:i}}async function dy(e,t){if(!e)return{};let r={};for(let n of e){let i=n.$.Id,a=n.EncryptionMethod[0],s=a.$.Algorithm.split("#")[1];if(!s.startsWith("rsa"))throw Error(`Unsupported encryption algorithm: ${s}. Only RSA and AES algorithms are supported.`);let o="sha1";if(s==="rsa-oaep")o=a.DigestMethod[0].$.Algorithm.split("#")[1];let h=n.CipherData[0].CipherValue[0].trim(),l=await ry(t,h,o);r[i]=l}return r}function py(e=[],t,r){let n={};for(let i of e){let a=i.EncryptionMethod[0].$.Algorithm.split("#")[1];if(!a.startsWith("aes")){console.warn(`Unsupported encryption algorithm: ${a}. Only AES and RSA algorithms are supported.`);continue}let s=a.replace("aes","aes-"),o=i.CipherData[0].CipherReference[0].$.URI;n[o]=[];let h=n[o],l=i.KeyInfo?.[0];if(l&&l.RetrievalMethod){let p=l.RetrievalMethod[0].$.URI.slice(1),m=t[p];if(!m)throw Error(`No symmetric key found for id "${p}". Skipping decryption for file "${o}".`);let _=async(w)=>await Yu(s,m,w);h.push(_)}else{let p=async(m)=>await Yu(s,r,m);h.push(p)}let c=i.EncryptionProperties?.[0].EncryptionProperty;if(c)for(let p of c){let m=p.Compression[0];if(m&&m.$.Method==="8")h.push(Gu)}n[o]=h}return n}function my(e){let t=e.EncryptionMethod?.[0]?.$?.Algorithm;return!gy.includes(t)}async function vy(e,t){let r=e.encryption,n=r.EncryptedKey,i=r.EncryptedData??[],a=i?.filter(my);if(i.length!==a.length){if(console.warn("lingo-reader doesn't handle font obfuscation and it doesn't read the font file."),a.length===0)return{}}if(n&&!t.rsaPrivateKey)throw Error("Please provide the RSA private key to decrypt the encrypted AES keys.");if(!n&&a&&!t.aesSymmetricKey)throw Error("The file is encrypted with AES, but no symmetric key is provided. ");let s=await dy(n,t.rsaPrivateKey);return py(a,s,t.aesSymmetricKey)}function sr(e,t,r){let n=J.joinPosix(t,e).replace(/\//g,"_");return J.resolve(r,n)}function _y(e,t,r){return e=e.replace(/<(img|video|audio|source)[^>]*>/g,(n)=>{let i=n.match(/src="([^"]*)"/)?.[1];if(i){let s=sr(i,t,r);n=n.replace(i,s)}let a=n.match(/poster="([^"]*)"/)?.[1];if(a){let s=sr(a,t,r);n=n.replace(a,s)}return n}),e=e.replace(/<image[^>]*>/g,(n)=>{let i=n.match(/href="([^"]*)"/)?.[1];if(i){let a=sr(i,t,r);n=n.replace(i,a)}return n}),e=e.replace(/<a[^>]*>/g,(n)=>{let i=n.match(/href="([^"]*)"/)?.[1];if(i&&!/^https?|mailto/.test(i)){let a=J.joinPosix(t,i);n=n.replace(i,or+decodeURIComponent(a))}return n}),e}function yy(e,t,r){let n=e.match(/<head[^>]*>([\s\S]*)<\/head>/i),i=[];if(n){let o=n[1].match(/<link[^>]*>/g);if(o)for(let h of o){let l=h.match(/href=["']([^"']*)["']/)?.[1];if(!l)continue;if(l.endsWith(".css")){let c=J.joinPosix(t,l),p=c.replace(/\//g,"_"),m=J.resolve(r,p),_;try{_=new TextDecoder().decode(W_(m))}catch{continue}_=_.replace(/url\(([^)]*)\)/g,(w,v)=>(v=v.replace(/['"]/g,""),`url(${sr(v.trim(),J.dirname(c),r)})`)),Qu(m,new TextEncoder().encode(_)),i.push({id:p,href:m})}}}let a=e.match(/<body[^>]*>(.*?)<\/body>/is),s=a?_y(a[1],t,r):"";return{css:i,html:s}}function rc(e,t,r,n){for(let i of e)if(i["#name"]==="par"){let a=i.text[0].$.src.split("#")[1],s=i.audio[0].$,o=sr(s.src,t,r),h=Ku(s.clipBegin),l=Ku(s.clipEnd);if(!n[o])n[o]={audioSrc:o,pars:[]};n[o].pars.push({textDOMId:a,clipBegin:h,clipEnd:l})}else rc(i.children,t,r,n)}function wy(e,t,r){let n={},i=e.smil.body[0].children;return rc(i,t,r,n),Object.values(n)}async function nc(e,t="./images",r={}){let n=new ic(e,t,r);return await n.loadEpub(),await n.parse(),n}class ic{constructor(e,t="./images",r={}){if(this.epub=e,this.options=r,ie(this,"fileName",""),ie(this,"mimeType",""),ie(this,"metadata"),ie(this,"manifest",{}),ie(this,"spine",[]),ie(this,"guide",[]),ie(this,"collections",[]),ie(this,"navMap",[]),ie(this,"pageList"),ie(this,"navList"),ie(this,"zip"),ie(this,"opfPath",""),ie(this,"opfDir",""),ie(this,"resourceSaveDir"),ie(this,"encryptionKeys",{}),ie(this,"savedResourcePath",[]),ie(this,"hrefToIdMap",{}),ie(this,"chapterCache",new Map),typeof e==="string")this.fileName=J.basename(e);else if(e instanceof Uint8Array)this.fileName="";else this.fileName=e.name;if(this.resourceSaveDir=t,!Vu(this.resourceSaveDir))$_(this.resourceSaveDir,{recursive:!0});this.encryptionKeys=Q_(this.options)}getFileInfo(){return{fileName:this.fileName,mimetype:this.mimeType}}getMetadata(){return this.metadata}getManifest(){return this.manifest}getSpine(){return this.spine}getGuide(){return this.guide}getCollection(){return this.collections}getToc(){return this.navMap}getPageList(){return this.pageList}getNavList(){return this.navList}async loadEpub(){this.zip=await X_(this.epub)}async parse(){let e=await this.zip.readFile("mimetype");this.mimeType=ny(e);let t=await this.zip.readFile("meta-inf/container.xml"),r=await Ot(t,is(t));if(this.opfPath=iy(r),this.opfDir=J.dirname(this.opfPath),this.zip.hasFile("meta-inf/encryption.xml")){let n=await this.zip.readFile("meta-inf/encryption.xml"),i=await Ot(n,{tagNameProcessors:[(s)=>s.replace(Y_,"")]}),a=await vy(i,this.encryptionKeys);this.zip.useDeprocessors(a)}await this.parseRootFile()}async parseRootFile(){let e=await this.zip.readFile(this.opfPath),r=(await Ot(e,is(e))).package,n="";if(r.metadata)this.metadata=ay(r.metadata[0]);if(r.manifest){this.manifest=sy(r.manifest[0],this.opfDir);for(let i in this.manifest){let a=this.manifest[i];if(this.hrefToIdMap[a.href]=a.id,K_.has(a.mediaType)||a.mediaType.startsWith("text/css")){let s=a.href.replace(/\//g,"_"),o=J.resolve(this.resourceSaveDir,s);this.savedResourcePath.push(o),Qu(o,await this.zip.readResource(a.href))}}}if(r.spine){let i=oy(r.spine[0],this.manifest);n=i.tocPath,this.spine=i.spine}if(r.guide)this.guide=fy(r.guide[0],this.opfDir);if(r.collection)this.collections=ly(r.collection,this.opfDir);if(n.length>0){let i=J.dirname(n),a=await this.zip.readFile(n),s=(await Ot(a,is(a))).ncx;if(s.navMap)this.navMap=uy(s.navMap[0],this.hrefToIdMap,i);if(s.pageList)this.pageList=cy(s.pageList[0],this.hrefToIdMap,i);if(s.navList)this.navList=hy(s.navList[0],this.hrefToIdMap,i)}}async loadChapter(e){if(this.chapterCache.has(e))return this.chapterCache.get(e);let t=this.manifest[e],r=t.href,n=J.dirname(r),i=yy(await this.zip.readFile(r),n,this.resourceSaveDir),a=t.mediaOverlay;if(a){let o=this.manifest[a].href,h=wy(await Ot(await this.zip.readFile(o),{preserveChildrenOrder:!0,explicitChildren:!0,childkey:"children"}),J.dirname(o),this.resourceSaveDir);i.mediaOverlays=h}return this.chapterCache.set(e,i),i}resolveHref(e){if(!e.startsWith(or))return;e=e.slice(5).trim();let[t,r]=e.split("#"),n="";if(this.hrefToIdMap[t])n=this.hrefToIdMap[t];else return;let i="";if(r)i=`[id="${r}"]`;return{id:n,selector:i}}getCoverImage(){let e=this.guide.find((t)=>t.type==="cover");if(e){let t=this.resolveHref(e.href).id,r=this.manifest[t];return sr(r.href,"",this.resourceSaveDir)}return""}destroy(){this.savedResourcePath.forEach((e)=>{if(Vu(e))Z_(e)}),this.savedResourcePath.length=0}}var Ju,H_,G_=(e,t,r)=>(t in e)?H_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ns=(e,t,r)=>G_(e,typeof t!=="symbol"?t+"":t,r),V_,K_,Y_,J_,Ku,or="epub:",gy,by,xy=(e,t,r)=>(t in e)?by(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ie=(e,t,r)=>xy(e,typeof t!=="symbol"?t+"":t,r);var ac=pi(()=>{As();Xu();Ju=bs(Uu(),1);H_=Object.defineProperty;V_={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",tiff:"image/tiff",tif:"image/tiff",heic:"image/heic",avif:"image/avif",css:"text/css",mp4:"video/mp4",mkv:"video/mkv",webm:"video/webm",mp3:"audio/mp3",wav:"audio/wav",ogg:"audio/ogg",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",eot:"font/eot"},K_=new Set(Object.values(V_)),Y_=/(?!xmlns)^.*:/,J_=new Set(["http://www.idpf.org/2007/opf","http://www.daisy.org/z3986/2005/ncx","urn:oasis:names:tc:opendocument:xmlns:container"]);Ku=ey(ty);gy=["http://www.idpf.org/2008/embedding","http://ns.adobe.com/pdf/enc#RC"];by=Object.defineProperty});import{mkdir as Nw,writeFile as Fw}from"node:fs/promises";import{join as Hc}from"node:path";import Pw from"node:fs/promises";import{existsSync as sc,readdirSync as Ey,readFileSync as oc,statSync as Ty}from"node:fs";import*as At from"node:path";import{createHash as ih}from"node:crypto";import{inflateSync as ah}from"node:zlib";var sh=new Set(["image/png","image/jpeg","image/gif","image/webp"]),oh={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/tiff":"tif","image/svg+xml":"svg","image/emf":"emf","image/wmf":"wmf","image/x-pict":"pict"};function fh(e){let t=(n,...i)=>i.every((a,s)=>e[n+s]===a);if(t(0,137,80,78,71))return"image/png";if(t(0,255,216,255))return"image/jpeg";if(t(0,71,73,70,56))return"image/gif";if(t(0,82,73,70,70)&&t(8,87,69,66,80))return"image/webp";if(t(0,66,77))return"image/bmp";if(t(0,73,73,42,0)||t(0,77,77,0,42))return"image/tiff";if(t(40,32,69,77,70))return"image/emf";if(t(0,215,205,198,154)||t(0,1,0,9,0))return"image/wmf";if(t(10,0,17,2,255))return"image/x-pict";let r=Buffer.from(e.subarray(0,256)).toString("utf8").trimStart();if(r.startsWith("<svg")||r.startsWith("<?xml")&&r.includes("<svg"))return"image/svg+xml";return}function lh(e){if(e[0]!==120||![1,94,156,218].includes(e[1]??0))return e;try{return new Uint8Array(ah(e))}catch{return e}}class gi{linkDir;byHash=new Map;names=new Set;pending=[];constructor(e="images"){this.linkDir=e}add(e){if(e.data.byteLength===0)return;let t=lh(e.data),r=ih("sha1").update(t).digest("hex"),n=this.byHash.get(r);if(n)return n;let i=fh(t)??e.mediaType??"application/octet-stream",a=oh[i]??"bin",s=this.uniqueName(uh(e.stem),a),o={file:s,link:`${this.linkDir}/${s}`,mediaType:i,bytes:t.byteLength,...e.width?{width:e.width}:{},...e.height?{height:e.height}:{},...e.source?{source:e.source}:{},...e.alt?.trim()?{alt:e.alt.trim()}:{},...sh.has(i)||i==="image/svg+xml"?{}:{notViewable:!0},sha1:r};return this.byHash.set(r,o),this.pending.push({image:o,data:t}),o}get images(){return this.pending.map((e)=>e.image)}entries(){return this.pending}uniqueName(e,t){let r=`${e}.${t}`;for(let n=2;this.names.has(r);n++)r=`${e}-${n}.${t}`;return this.names.add(r),r}}function uh(e){return e.replace(/\.[a-z0-9]{2,4}$/i,"").replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"image"}function We(e){return`![${(e.alt??"").replace(/[[\]\n]/g," ").trim()}](${e.link})`}var Sy=/\.(png|jpe?g|gif|webp|bmp|svg|tiff?)$/i;function ky(e){if(e.length<90)return 0;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t.getUint32(78);if(r+14>e.length)return 0;return t.getUint16(r+12)}function Ay(e){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);return t.includes("META-INF/rights.xml")||t.includes("META-INF/license.lcpl")}function Iy(e){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(t.length<22||t.readUInt32LE(0)!==67324752)return"it does not start as a ZIP archive, which every EPUB is";let r=t.lastIndexOf(Buffer.from([80,75,5,6]),t.length-22);if(r<0||r<t.length-22-65535)return`it ends before its index (${t.length.toLocaleString("en-US")} bytes), so it was cut short when it was copied, downloaded or unpacked`;let n=t.readUInt32LE(r+12),i=t.readUInt32LE(r+16);if(i!==4294967295&&n!==4294967295&&i+n>r)return"its index points past the end of the file, so part of it is missing";return}var fc=120000;async function ai(e){let t;try{return await Promise.race([e,new Promise((r,n)=>{t=setTimeout(()=>n(Error(`The book could not be opened: the reader gave no answer in ${fc/1000}s, which is what it does with a damaged file. Check that the file is complete.`)),fc)})])}finally{clearTimeout(t)}}function lc(e,t=0,r=[]){for(let n of e){if(r.length>=200)break;let i=String(n.label??"").trim();if(i)r.push(`${" ".repeat(t)}${i}`);if(Array.isArray(n.children))lc(n.children,t+1,r)}return r}function si(e){if(typeof e==="string")return e.trim()||void 0;if(Array.isArray(e))for(let t of e){let r=si(typeof t==="object"&&t!==null?t.contributor??t.name:t);if(r)return r}if(typeof e==="object"&&e!==null){let t=e;return si(t.contributor??t.name??t.value)}return}async function Cy(e){let{default:t}=await import("turndown"),{gfm:r}=await import("@joplin/turndown-plugin-gfm"),n=new t({headingStyle:"atx",codeBlockStyle:"fenced",bulletListMarker:"-"});return n.use(r),n.remove(["script","style","head"]),n.addRule("image",{filter:"img",replacement:(i,a)=>{let s=a,o=s.getAttribute("src")??"";return e(o,s.getAttribute("alt")??"")??""}}),n.addRule("svgImage",{filter:(i)=>i.nodeName.toLowerCase()==="image",replacement:(i,a)=>{let s=a,o=s.getAttribute("xlink:href")??s.getAttribute("href")??"";return e(o,"")??""}}),n}async function uc(e,t,r,n){if((r==="mobi"||r==="azw3")&&ky(t)>1)throw Error("This Kindle book is DRM-protected. It can be read only in a Kindle app; nothing here can remove the protection.");if(r==="epub"&&Ay(t))throw Error("This EPUB is DRM-protected (Adobe ADEPT or Readium LCP). It can be read only in a reader app licensed for it.");if(r==="epub"){let p=Iy(t);if(p)throw Error(`This EPUB is damaged: ${p}. Nothing can be read from it; get the file again.`)}let i=n.scratchDir;await Promise.resolve().then(() => ac());let{initFb2File:s}=await import("@lingo-reader/fb2-parser"),{initKf8File:o,initMobiFile:h}=await import("@lingo-reader/mobi-parser"),l,c;if(r==="epub")l=await ai(nc(e,i)),c="lingo-reader (EPUB)";else if(r==="fb2")l=await ai(s(e,i)),c="lingo-reader (FB2)";else{let[p,m]=r==="azw3"?[o,h]:[h,o];try{l=await ai(p(e,i)),c=`lingo-reader (${p===o?"KF8":"MOBI"})`}catch{l=await ai(m(e,i)),c=`lingo-reader (${m===o?"KF8":"MOBI"})`}}try{let p=new Map,m=0,w=await Cy((O,C)=>{if(!n.wantImages||!O||/^(data:|https?:)/i.test(O))return;let D=O;try{D=decodeURI(O.replace(/^file:\/\//,""))}catch{}if(!At.isAbsolute(D)||!sc(D))return;if(!p.has(D))p.set(D,n.images.add({data:oc(D),stem:At.basename(D),source:`chapter ${m}`,...C?{alt:C}:{}}));let d=p.get(D);return d?We(d):void 0}),v=l.getSpine(),b=[],S=[];for(let O=0;O<v.length;O++){let C=O+1;if(n.selects&&!n.selects(C))continue;n.signal?.throwIfAborted(),m=C,n.onProgress?.({unit:"chapter",at:C,total:v.length,pictures:p.size}),b.push(C);let d=(await l.loadChapter(v[O].id))?.html??"",R=d?w.turndown(d).trim():"";if(R)S.push(R)}if(n.wantImages&&sc(i))for(let O of Ey(i,{recursive:!0})){let C=At.join(i,O);if(!Sy.test(O)||p.has(C)||!Ty(C).isFile())continue;p.set(C,n.images.add({data:oc(C),stem:At.basename(O)}))}let T=l.getMetadata()??{},k=si(T.title),x=si(T.creator??T.author),A=lc(l.getToc()??[]);return{markdown:S.join(`
13
+
14
+ `),reader:c,...k&&k!=="Unknown"?{title:k}:{},...x&&x!=="Unknown"?{author:x}:{},units:{name:"chapter",total:v.length,read:b},...A.length?{contents:A}:{}}}finally{l.destroy()}}import*as ss from"node:path";var Dy={pdf:"PDF",docx:"Word document (DOCX)",pptx:"PowerPoint presentation (PPTX)",xlsx:"Excel workbook (XLSX)",odt:"OpenDocument text (ODT)",odp:"OpenDocument presentation (ODP)",ods:"OpenDocument spreadsheet (ODS)",odg:"OpenDocument drawing (ODG)",rtf:"Rich Text (RTF)",csv:"CSV",html:"HTML",epub:"EPUB ebook",mobi:"Mobipocket / Kindle ebook (MOBI)",azw3:"Kindle KF8 ebook (AZW3)",fb2:"FictionBook (FB2)",doc:"Word 97-2003 document (DOC)",xls:"Excel 97-2003 workbook (XLS)",ppt:"PowerPoint 97-2003 presentation (PPT)"},cc={".pdf":"pdf",".docx":"docx",".docm":"docx",".dotx":"docx",".pptx":"pptx",".pptm":"pptx",".ppsx":"pptx",".xlsx":"xlsx",".xlsm":"xlsx",".odt":"odt",".odp":"odp",".ods":"ods",".odg":"odg",".rtf":"rtf",".csv":"csv",".html":"html",".htm":"html",".xhtml":"html",".epub":"epub",".mobi":"mobi",".prc":"mobi",".azw":"mobi",".azw3":"azw3",".kf8":"azw3",".fb2":"fb2",".doc":"doc",".dot":"doc",".xls":"xls",".ppt":"ppt",".pps":"ppt"},Oy={".djvu":"DjVu has no JavaScript reader.",".djv":"DjVu has no JavaScript reader.",".chm":"Compiled HTML Help (CHM) has no JavaScript reader.",".lit":"Microsoft Reader (LIT) has no JavaScript reader.",".lrf":"Sony BBeB (LRF) has no JavaScript reader.",".kfx":"KFX is Amazon's DRM-bound format and cannot be read.",".pages":"Apple Pages files have no JavaScript reader; export them as DOCX or PDF.",".key":"Apple Keynote files have no JavaScript reader; export them as PPTX or PDF.",".numbers":"Apple Numbers files have no JavaScript reader; export them as XLSX or CSV.",".xlsb":"Binary Excel workbooks (XLSB) are not read; save the workbook as XLSX.",".wps":"Microsoft Works documents are not read; save them as DOCX.",".cbz":"Comic archives are not read yet.",".cbr":"Comic archives are not read yet."},Ex=Object.keys(cc);function hc(e,t){let r=ss.extname(e).toLowerCase(),n=Oy[r];if(n)return{unsupported:n};let i=Buffer.from(t.subarray(0,512)).toString("latin1"),a=cc[r];if(i.startsWith("%PDF"))return{format:"pdf"};if(i.startsWith("{\\rtf"))return{format:"rtf"};if(i.slice(60,68)==="BOOKMOBI")return{format:a==="azw3"?"azw3":"mobi"};let s=i.startsWith("PK\x03\x04"),o=i.startsWith("ÐÏ\x11ࡱ\x1Aá");if(s){if(i.includes("mimetypeapplication/epub+zip"))return{format:"epub"};let h=/mimetypeapplication\/vnd\.oasis\.opendocument\.(text|presentation|spreadsheet|graphics)/.exec(i);if(h)return{format:{text:"odt",presentation:"odp",spreadsheet:"ods",graphics:"odg"}[h[1]]};if(a&&["docx","pptx","xlsx","epub","odt","odp","ods","odg"].includes(a))return{format:a};if(a==="doc")return{format:"docx"};if(a==="xls")return{format:"xlsx"};if(a==="ppt")return{format:"pptx"}}if(o){if(a==="doc"||a==="xls"||a==="ppt")return{format:a};if(a==="docx")return{format:"doc"};if(a==="xlsx")return{format:"xls"};if(a==="pptx")return{format:"ppt"};return{unsupported:"This is an OLE compound file, but its extension does not say which Office program wrote it; rename it to .doc, .xls or .ppt."}}if(a==="fb2"||/<FictionBook[\s>]/.test(i))return{format:"fb2"};if(a==="html"||a==="csv")return{format:a};if(a)return{unsupported:`The file is named as ${Dy[a]} but its contents are not; it may be damaged or a different format.`};return{unsupported:`No reader for ${r||"files without an extension"}. Readable: PDF, DOCX/DOC, PPTX/PPT, XLSX/XLS, ODT/ODP/ODS/ODG, RTF, CSV, HTML, EPUB, MOBI/AZW/AZW3, FB2.`}}import{existsSync as vc,readFileSync as Uy}from"node:fs";import{dirname as bc,join as _c}from"node:path";import{fileURLToPath as jy}from"node:url";class nn{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,dc.unregister(this),e}free(){let e=this.__destroy_into_raw();P.__wbg_wasmdocument_free(e,0)}formatName(){let e,t;try{let i=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_formatName(i,this.__wbg_ptr);var r=q().getInt32(i+0,!0),n=q().getInt32(i+4,!0);return e=r,t=n,ct(r,n)}finally{P.__wbindgen_add_to_stack_pointer(16),P.__wbindgen_export3(e,t,1)}}constructor(e,t){try{let a=P.__wbindgen_add_to_stack_pointer(-16),s=gc(e,P.__wbindgen_export),o=Ue,h=tn(t,P.__wbindgen_export,P.__wbindgen_export2),l=Ue;P.wasmdocument_new(a,s,o,h,l);var r=q().getInt32(a+0,!0),n=q().getInt32(a+4,!0),i=q().getInt32(a+8,!0);if(i)throw Le(n);return this.__wbg_ptr=r,dc.register(this,this.__wbg_ptr,this),this}finally{P.__wbindgen_add_to_stack_pointer(16)}}plainText(){let e,t;try{let i=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_plainText(i,this.__wbg_ptr);var r=q().getInt32(i+0,!0),n=q().getInt32(i+4,!0);return e=r,t=n,ct(r,n)}finally{P.__wbindgen_add_to_stack_pointer(16),P.__wbindgen_export3(e,t,1)}}toHtml(){let e,t;try{let i=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_toHtml(i,this.__wbg_ptr);var r=q().getInt32(i+0,!0),n=q().getInt32(i+4,!0);return e=r,t=n,ct(r,n)}finally{P.__wbindgen_add_to_stack_pointer(16),P.__wbindgen_export3(e,t,1)}}toIr(){try{let n=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_toIr(n,this.__wbg_ptr);var e=q().getInt32(n+0,!0),t=q().getInt32(n+4,!0),r=q().getInt32(n+8,!0);if(r)throw Le(t);return Le(e)}finally{P.__wbindgen_add_to_stack_pointer(16)}}toMarkdownWithImages(){let e,t;try{let i=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_toMarkdownWithImages(i,this.__wbg_ptr);var r=q().getInt32(i+0,!0),n=q().getInt32(i+4,!0);return e=r,t=n,ct(r,n)}finally{P.__wbindgen_add_to_stack_pointer(16),P.__wbindgen_export3(e,t,1)}}toMarkdown(){let e,t;try{let i=P.__wbindgen_add_to_stack_pointer(-16);P.wasmdocument_toMarkdown(i,this.__wbg_ptr);var r=q().getInt32(i+0,!0),n=q().getInt32(i+4,!0);return e=r,t=n,ct(r,n)}finally{P.__wbindgen_add_to_stack_pointer(16),P.__wbindgen_export3(e,t,1)}}}if(Symbol.dispose)nn.prototype[Symbol.dispose]=nn.prototype.free;class fs{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,pc.unregister(this),e}free(){let e=this.__destroy_into_raw();P.__wbg_wasmeditabledocument_free(e,0)}constructor(e,t){try{let a=P.__wbindgen_add_to_stack_pointer(-16),s=gc(e,P.__wbindgen_export),o=Ue,h=tn(t,P.__wbindgen_export,P.__wbindgen_export2),l=Ue;P.wasmeditabledocument_new(a,s,o,h,l);var r=q().getInt32(a+0,!0),n=q().getInt32(a+4,!0),i=q().getInt32(a+8,!0);if(i)throw Le(n);return this.__wbg_ptr=r,pc.register(this,this.__wbg_ptr,this),this}finally{P.__wbindgen_add_to_stack_pointer(16)}}replaceText(e,t){try{let a=P.__wbindgen_add_to_stack_pointer(-16),s=tn(e,P.__wbindgen_export,P.__wbindgen_export2),o=Ue,h=tn(t,P.__wbindgen_export,P.__wbindgen_export2),l=Ue;P.wasmeditabledocument_replaceText(a,this.__wbg_ptr,s,o,h,l);var r=q().getInt32(a+0,!0),n=q().getInt32(a+4,!0),i=q().getInt32(a+8,!0);if(i)throw Le(n);return r>>>0}finally{P.__wbindgen_add_to_stack_pointer(16)}}toBytes(){try{let a=P.__wbindgen_add_to_stack_pointer(-16);P.wasmeditabledocument_toBytes(a,this.__wbg_ptr);var e=q().getInt32(a+0,!0),t=q().getInt32(a+4,!0),r=q().getInt32(a+8,!0),n=q().getInt32(a+12,!0);if(n)throw Le(r);var i=Ny(e,t).slice();return P.__wbindgen_export3(e,t*1,1),i}finally{P.__wbindgen_add_to_stack_pointer(16)}}}if(Symbol.dispose)fs.prototype[Symbol.dispose]=fs.prototype.free;function Py(){return{__proto__:null,"./office_oxide_bg.js":{__proto__:null,__wbg_Error_67e7344beaa85059:function(t,r){let n=Error(ct(t,r));return ut(n)},__wbg_String_8564e559799eccda:function(t,r){let n=String(Qr(r)),i=tn(n,P.__wbindgen_export,P.__wbindgen_export2),a=Ue;q().setInt32(t+4,a,!0),q().setInt32(t+0,i,!0)},__wbg___wbindgen_throw_5d9e815e6fdf150f:function(t,r){throw Error(ct(t,r))},__wbg_new_bebc3f4757acf305:function(){return ut({})},__wbg_new_ffa92086ea89f79c:function(){return ut([])},__wbg_set_13d25b81ab403f5e:function(t,r,n){Qr(t)[r>>>0]=Le(n)},__wbg_set_6be42768c690e380:function(t,r,n){Qr(t)[Le(r)]=Le(n)},__wbindgen_generic_0000000000000001:function(t){return ut(t)},__wbindgen_generic_0000000000000002:function(t){return ut(t)},__wbindgen_generic_0000000000000003:function(t,r){let n=ct(t,r);return ut(n)},__wbindgen_generic_0000000000000004:function(t){let r=BigInt.asUintN(64,t);return ut(r)},__wbindgen_object_clone_ref:function(t){let r=Qr(t);return ut(r)},__wbindgen_object_drop_ref:function(t){Le(t)}}}}var dc=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>P.__wbg_wasmdocument_free(e,1)),pc=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>P.__wbg_wasmeditabledocument_free(e,1));function ut(e){if(en===Qe.length)Qe.push(Qe.length+1);let t=en;return en=Qe[t],Qe[t]=e,t}function Ry(e){if(e<1028)return;Qe[e]=en,en=e}function Ny(e,t){return e=e>>>0,fr().subarray(e/1,e/1+t)}var It=null;function q(){if(It===null||It.buffer.detached===!0||It.buffer.detached===void 0&&It.buffer!==P.memory.buffer)It=new DataView(P.memory.buffer);return It}function ct(e,t){return My(e>>>0,t)}var Jr=null;function fr(){if(Jr===null||Jr.byteLength===0)Jr=new Uint8Array(P.memory.buffer);return Jr}function Qr(e){return Qe[e]}var Qe=Array(1024).fill(void 0);Qe.push(void 0,null,!0,!1);var en=Qe.length;function gc(e,t){let r=t(e.length*1,1)>>>0;return fr().set(e,r/1),Ue=e.length,r}function tn(e,t,r){if(r===void 0){let o=rn.encode(e),h=t(o.length,1)>>>0;return fr().subarray(h,h+o.length).set(o),Ue=o.length,h}let n=e.length,i=t(n,1)>>>0,a=fr(),s=0;for(;s<n;s++){let o=e.charCodeAt(s);if(o>127)break;a[i+s]=o}if(s!==n){if(s!==0)e=e.slice(s);i=r(i,n,n=s+e.length*3,1)>>>0;let o=fr().subarray(i+s,i+n),h=rn.encodeInto(e,o);s+=h.written,i=r(i,n,s,1)>>>0}return Ue=s,i}function Le(e){let t=Qr(e);return Ry(e),t}var oi=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});oi.decode();var Fy=2146435072,os=0;function My(e,t){if(os+=t,os>=Fy)oi=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),oi.decode(),os=t;return oi.decode(fr().subarray(e,e+t))}var rn=new TextEncoder;if(!("encodeInto"in rn))rn.encodeInto=function(e,t){let r=rn.encode(e);return t.set(r),{read:e.length,written:r.length}};var Ue=0,By,zy,P;function Ly(e,t){return zy=e,P=e.exports,By=t,It=null,Jr=null,P}function mc(e){if(P!==void 0)return P;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module:e}=e);else console.warn("using deprecated parameters for `initSync()`; pass a single object instead");let t=Py();if(!(e instanceof WebAssembly.Module))e=new WebAssembly.Module(e);let r=new WebAssembly.Instance(e,t);return Ly(r,e)}var yc="office_oxide_bg.wasm",wc=!1;function qy(e=Wy()){let t=_c(e,"office-oxide",yc);if(vc(t))return t;let r=e;for(let n=0;n<7;n++){let i=_c(r,"assets","office-oxide",yc);if(vc(i))return i;let a=bc(r);if(a===r)break;r=a}return}function Wy(){try{return bc(jy(import.meta.url))}catch{return"."}}function xc(e,t){if(!wc){let r=qy();if(!r)throw Error("The reader for Word, Excel and PowerPoint 97-2003 files is missing from this installation (office_oxide_bg.wasm was not found).");mc({module:Uy(r)}),wc=!0}return new nn(e,t)}var $y=/\[image-base64:([A-Za-z0-9+/=\s]+)\]/g;function Zy(e){return e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"")}function Hy(e,t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t+8;while(n+12<=e.length){let i=r.getUint32(n),a=String.fromCharCode(...e.subarray(n+4,n+8));if(n+=12+i,a==="IEND")return n-t;if(i>e.length)return}return}function Gy(e,t){let r=t+2;while(r+4<=e.length){if(e[r]!==255)return;let n=e[r+1];if(n===217)return r+2-t;if(n===218){r+=2+(e[r+2]<<8|e[r+3]);while(r+1<e.length){if(e[r]===255){let i=e[r+1];if(i===217)return r+2-t;if(i!==0&&(i<208||i>215))break}r++}continue}r+=2+(e[r+2]<<8|e[r+3])}return}async function Xy(e){let t=await import("cfb"),r=t.default??t,n;try{n=r.read(Buffer.from(e),{type:"buffer"})}catch{return[]}let i=[];for(let a of n.FileIndex){let s=a.content;if(a.type!==2||!s||s.length<64)continue;let o=s instanceof Uint8Array?s:new Uint8Array(s);for(let h=0;h+8<o.length;h++){let l;if(o[h]===137&&o[h+1]===80&&o[h+2]===78&&o[h+3]===71)l=Hy(o,h);else if(o[h]===255&&o[h+1]===216&&o[h+2]===255)l=Gy(o,h);if(l&&l>64&&h+l<=o.length)i.push(o.slice(h,h+l)),h+=l-1}}return i}async function Ec(e,t,r){let n=xc(e,t),i;try{i=n.toMarkdownWithImages()}finally{n.free()}let a=0;i=i.replace($y,(o,h)=>{if(!r.wantImages)return"";a++;let l=r.images.add({data:Buffer.from(h.replace(/\s/g,""),"base64"),stem:`${t}-image-${a}`});return l?We(l):""}),i=Zy(i).replace(/\n{3,}/g,`
15
+
16
+ `).trim();let s=[];if(r.wantImages&&t==="doc"){let o=[];for(let h of await Xy(e)){let l=r.images.images.length;a++;let c=r.images.add({data:h,stem:`${t}-image-${a}`});if(c&&r.images.images.length>l)o.push(We(c))}if(o.length)i+=`
6
17
 
7
18
  ## Pictures not placed in the text
8
19
 
9
- ${Y.join(`
20
+ ${o.join(`
10
21
 
11
- `)}`,H.push(`${Y.length} picture(s) were found in the file but not at a place in its text; they are listed at the end.`)}return{markdown:Z,reader:"office_oxide",...H.length?{notes:H}:{}}}var o$={maxUncompressedBytes:268435456,maxZipEntries:20000},r$={pptx:{node:"slide",unit:"slide"},odp:{node:"slide",unit:"slide"},xlsx:{node:"sheet",unit:"sheet"},ods:{node:"sheet",unit:"sheet"}};async function a$(){let Q=await import("officeparser");return Q.OfficeParser??Q.default}function t$(Q,$){let J=Q?.message??"";if(!/password|encrypt/i.test(J))return;return Error($?"The document's password is not the one given in `password`.":"The document is password-protected. Ask the user for the password and call again with `password`.")}function e$(Q){return Q.replace(/^\s*---\n[\s\S]*?\n---\n/,"").trim()}async function mQ(Q,$,J){let q=await a$(),Z;try{Z=await q.parseOffice(Buffer.from(Q),{fileType:$,extractAttachments:J.wantImages,decompressionLimits:o$,...J.password?{password:J.password}:{}})}catch(V){throw t$(V,J.password)??V}let K=r$[$],H;if(K){let V=Z.content.filter((z)=>z.type===K.node),N=[],G=new Set;V.forEach((z,C)=>{if(!J.selects||J.selects(C+1))N.push(C+1),G.add(z)}),Z.content=Z.content.filter((z)=>z.type!==K.node||G.has(z)),H={name:K.unit,total:V.length,read:N}}let Y=new Map,X=(V,N)=>{if(Y.has(V))return Y.get(V);let G=Z.attachments?.find((C)=>C.name===V),z=G?J.images.add({data:Buffer.from(G.data,"base64"),stem:V,mediaType:G.mimeType,...N?{alt:N}:{}}):void 0;return Y.set(V,z),z},B=await Z.to("md",{mdConfig:{dialect:"github",fallbackToHtml:{textFormatting:!1,alignment:!1,anchors:!1,tables:!0,embeds:!1,cellLineBreaks:!0}},onNode:(V)=>{if(V.type!=="image")return;if(!J.wantImages)return!1;let N=V.metadata??{},G=N.attachmentName?X(N.attachmentName,N.altText):void 0;return G?x(G):!1}}),F=e$(String(B.value??""));if($==="rtf")F=F.replace(/^[ ]*\t[ \t]*(?![-*+] |\d+[.)] )/gm,"");if(J.wantImages){for(let V of Z.attachments??[])if(V.type==="image")X(V.name)}let U=Z.metadata??{};return{markdown:F,reader:"officeparser",...U.title?.trim()?{title:U.title.trim()}:{},...U.author?.trim()?{author:U.author.trim()}:{},...H?{units:H}:{}}}import{existsSync as VQ}from"node:fs";import{createRequire as QJ}from"node:module";import{dirname as pQ,join as l}from"node:path";import{fileURLToPath as $J}from"node:url";function FQ(){try{return pQ($J(import.meta.url))}catch{return"."}}function JJ(Q){try{let $=QJ(l(FQ(),"noop.js"));return pQ($.resolve(`${Q}/package.json`))}catch{return}}function CQ(Q,$,J,q){let Z=l(FQ(),Q);if(VQ(l(Z,q)))return Z;let K=JJ($),H=K?l(K,J):void 0;return H&&VQ(l(H,q))?H:void 0}function dQ(){return CQ("pdfjs/wasm","pdfjs-dist","wasm","jbig2.wasm")}function iQ(){return CQ("pdfjs/cmaps","pdfjs-dist","cmaps","UniJIS-UCS2-H.bcmap")}function nQ(){let Q=l(FQ(),"tesseract","worker.cjs");return VQ(Q)?Q:void 0}function sQ(){return CQ("tessdata","@tesseract.js-data/eng","4.0.0_best_int","eng.traineddata.gz")}var ZQ;function rQ(){return ZQ??=(async()=>{ZJ();let Q=globalThis;if(!Q.pdfjsWorker)Q.pdfjsWorker=await import("pdfjs-dist/legacy/build/pdf.worker.mjs");return await qJ(()=>import("pdfjs-dist/legacy/build/pdf.mjs"))})(),ZQ.catch(()=>{ZQ=void 0}),ZQ}async function qJ(Q){let $=console.warn;console.warn=(...J)=>{let q=String(J[0]??"");if(/^Warning: Cannot (load "@napi-rs\/canvas"|polyfill `(Path2D|DOMMatrix|ImageData)`)/.test(q))return;$(...J)};try{return await Q()}finally{console.warn=$}}function ZJ(){let Q=globalThis;if(Q.DOMMatrix)return;class ${a=1;b=0;c=0;d=1;e=0;f=0;constructor(J){if(J&&J.length>=6)[this.a,this.b,this.c,this.d,this.e,this.f]=Array.from(J).slice(0,6)}set(J){return[this.a,this.b,this.c,this.d,this.e,this.f]=J,this}product(J,q){return[J.a*q.a+J.c*q.b,J.b*q.a+J.d*q.b,J.a*q.c+J.c*q.d,J.b*q.c+J.d*q.d,J.a*q.e+J.c*q.f+J.e,J.b*q.e+J.d*q.f+J.f]}multiplySelf(J=new $){let q=J instanceof $?J:new $(J);return this.set(this.product(this,q))}preMultiplySelf(J=new $){let q=J instanceof $?J:new $(J);return this.set(this.product(q,this))}multiply(J){return new $(this.toArray()).multiplySelf(J)}translateSelf(J=0,q=0){return this.multiplySelf([1,0,0,1,J,q])}translate(J=0,q=0){return new $(this.toArray()).translateSelf(J,q)}scaleSelf(J=1,q=J){return this.multiplySelf([J,0,0,q,0,0])}scale(J=1,q=J){return new $(this.toArray()).scaleSelf(J,q)}invertSelf(){let J=this.a*this.d-this.b*this.c;if(!J)return this.set([Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN]);return this.set([this.d/J,-this.b/J,-this.c/J,this.a/J,(this.c*this.f-this.d*this.e)/J,(this.b*this.e-this.a*this.f)/J])}inverse(){return new $(this.toArray()).invertSelf()}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}}Q.DOMMatrix=$}function oQ(Q){return Q?`${Q.replace(/[\\/]+$/,"")}/`:void 0}function aQ(){let Q=oQ(dQ()),$=oQ(iQ());return{disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,verbosity:0,...Q?{wasmUrl:Q}:{},...$?{cMapUrl:$,cMapPacked:!0}:{}}}var KJ=100,HJ=0.5,YJ=200,tQ=4,XJ=0.1,zJ=1,BJ=2,WJ=3;function GJ(Q,$){let[J=1,q=0,Z=0,K=1,H=0,Y=0]=$;return[Q[0]*J+Q[2]*q,Q[1]*J+Q[3]*q,Q[0]*Z+Q[2]*K,Q[1]*Z+Q[3]*K,Q[0]*H+Q[2]*Y+Q[4],Q[1]*H+Q[3]*Y+Q[5]]}async function UJ(Q,$){let[J,q,Z,K]=Q.view,H=Math.abs((Z-J)*(K-q))||1,Y=await Q.getOperatorList(),X=[1,0,0,1,0,0],B=[],F=0,U=!1,V=0,N=[];for(let G=0;G<Y.fnArray.length;G++){let z=Y.fnArray[G],C=Y.argsArray[G],I=()=>Math.abs(X[0]*X[3]-X[1]*X[2]);if(z===$.save)B.push(X);else if(z===$.restore)X=B.pop()??X;else if(z===$.transform)X=GJ(X,C);else if(z===$.setTextRenderingMode){if(C[0]===3)U=!0}else if(z===$.paintImageXObject||z===$.paintImageXObjectRepeat){if(F+=I(),typeof C[0]==="string")N.push({key:C[0],area:I()/H})}else if(z===$.paintInlineImageXObject)F+=I(),N.push({image:C[0],mask:!1,area:I()/H});else if(z===$.paintImageMaskXObject)F+=I(),N.push({image:C[0],mask:!0,area:I()/H});else if(z===$.constructPath)V++}return{coverage:Math.min(1,F/H),invisibleText:U,pathOps:V,pageArea:H,draws:N}}function eQ(Q){let $=Q.replace(/\s/g,"");if($.length<20)return!1;return($.match(/[-�\u0000-\u0008]/g)?.length??0)/$.length>0.3}var Q$=20000,$$=60000,KQ=new Set,e;function VJ(Q){if(KQ.add(Q),!e){let $=console.log;e=$,console.log=(...J)=>{let q=typeof J[0]==="string"?J[0]:"";if(q.startsWith("Warning: ")){for(let Z of KQ)Z(q.slice(9));return}$(...J)}}return()=>{if(KQ.delete(Q),KQ.size===0&&e)console.log=e,e=void 0}}function J$(Q,$,J){let q=$.startsWith("g_")?Q.commonObjs:Q.objs;return new Promise((Z)=>{let K=setTimeout(()=>Z("no answer"),J),H=(Y)=>{clearTimeout(K),Z(Y)};try{q.get($,(Y)=>H(Y??null))}catch{H(null)}})}function FJ(Q,$,J){let{width:q,height:Z,data:K}=$;if(!K||!q||!Z)return;if(J||$.kind===zJ){let X=q+7>>3;if(K.length<X*Z)return;let B=new Uint8Array(q*Z);for(let F=0;F<Z;F++){let U=F*X;for(let V=0;V<q;V++)B[F*q+V]=(K[U+(V>>3)]??0)>>7-(V&7)&1?255:0}return Q({width:q,height:Z,data:B,channels:1,depth:8})}let Y=$.kind===BJ?3:$.kind===WJ?4:K.length/(q*Z);if(Y!==1&&Y!==3&&Y!==4)return;return Q({width:q,height:Z,data:new Uint8Array(K.buffer,K.byteOffset,q*Z*Y),channels:Y,depth:8})}function CJ(Q,$){let J=Q?.name,q=Q?.message??"";if(J!=="PasswordException"&&!/password/i.test(q))return;return Error($?"The PDF's password is not the one given in `password`.":"The PDF is password-protected. Ask the user for the password and call again with `password`.")}async function q$(Q,$){let J=await rQ(),{encode:q}=await import("fast-png"),Z=new Set,K=$.onNote?VJ((X)=>{if(Z.size>=60||Z.has(X))return;Z.add(X),$.onNote?.(`pdf.js: ${X}`)}):void 0,H=J.getDocument({...aQ(),...$.onNote?{verbosity:1}:{},data:Q.slice(),...$.password?{password:$.password}:{}}),Y;try{Y=await H.promise}catch(X){throw await H.destroy().catch(()=>{}),K?.(),CJ(X,$.password)??X}try{return await RJ(Y,J.OPS,q,$)}finally{await H.destroy().catch(()=>{}),K?.()}}async function RJ(Q,$,J,q){let K=(await Q.getMetadata().catch(()=>{return}))?.info??{},H=Q.numPages,Y=[],X=[],B=[],F=[],U=[],V=[],N=0,G=(z,C)=>q.onProgress?.({unit:"page",at:z,total:H,pictures:N,...C?{activity:C}:{}});for(let z=1;z<=H;z++){if(q.selects&&!q.selects(z))continue;q.signal?.throwIfAborted(),G(z),Y.push(z),G(z,"opening the page");let C=await Q.getPage(z);G(z,"reading its text");let I=await C.getTextContent(),P="";for(let j of I.items){if(typeof j.str!=="string")continue;if(P+=j.str,j.hasEOL)P+=`
12
- `}P=P.replace(/[ \t]+\n/g,`
22
+ `)}`,s.push(`${o.length} picture(s) were found in the file but not at a place in its text; they are listed at the end.`)}return{markdown:i,reader:"office_oxide",...s.length?{notes:s}:{}}}var Vy={maxUncompressedBytes:268435456,maxZipEntries:20000},Ky={pptx:{node:"slide",unit:"slide"},odp:{node:"slide",unit:"slide"},xlsx:{node:"sheet",unit:"sheet"},ods:{node:"sheet",unit:"sheet"}};async function Yy(){let e=await import("officeparser");return e.OfficeParser??e.default}function Jy(e,t){let r=e?.message??"";if(!/password|encrypt/i.test(r))return;return Error(t?"The document's password is not the one given in `password`.":"The document is password-protected. Ask the user for the password and call again with `password`.")}function Qy(e){return e.replace(/^\s*---\n[\s\S]*?\n---\n/,"").trim()}async function Tc(e,t,r){let n=await Yy(),i;try{i=await n.parseOffice(Buffer.from(e),{fileType:t,extractAttachments:r.wantImages,decompressionLimits:Vy,...r.password?{password:r.password}:{}})}catch(m){throw Jy(m,r.password)??m}let a=Ky[t],s;if(a){let m=i.content.filter((v)=>v.type===a.node),_=[],w=new Set;m.forEach((v,b)=>{if(!r.selects||r.selects(b+1))_.push(b+1),w.add(v)}),i.content=i.content.filter((v)=>v.type!==a.node||w.has(v)),s={name:a.unit,total:m.length,read:_}}let o=new Map,h=(m,_)=>{if(o.has(m))return o.get(m);let w=i.attachments?.find((b)=>b.name===m),v=w?r.images.add({data:Buffer.from(w.data,"base64"),stem:m,mediaType:w.mimeType,..._?{alt:_}:{}}):void 0;return o.set(m,v),v},l=await i.to("md",{mdConfig:{dialect:"github",fallbackToHtml:{textFormatting:!1,alignment:!1,anchors:!1,tables:!0,embeds:!1,cellLineBreaks:!0}},onNode:(m)=>{if(m.type!=="image")return;if(!r.wantImages)return!1;let _=m.metadata??{},w=_.attachmentName?h(_.attachmentName,_.altText):void 0;return w?We(w):!1}}),c=Qy(String(l.value??""));if(t==="rtf")c=c.replace(/^[ ]*\t[ \t]*(?![-*+] |\d+[.)] )/gm,"");if(r.wantImages){for(let m of i.attachments??[])if(m.type==="image")h(m.name)}let p=i.metadata??{};return{markdown:c,reader:"officeparser",...p.title?.trim()?{title:p.title.trim()}:{},...p.author?.trim()?{author:p.author.trim()}:{},...s?{units:s}:{}}}import{existsSync as ls}from"node:fs";import{createRequire as ew}from"node:module";import{dirname as Sc,join as lr}from"node:path";import{fileURLToPath as tw}from"node:url";function us(){try{return Sc(tw(import.meta.url))}catch{return"."}}function rw(e){try{let t=ew(lr(us(),"noop.js"));return Sc(t.resolve(`${e}/package.json`))}catch{return}}function cs(e,t,r,n){let i=lr(us(),e);if(ls(lr(i,n)))return i;let a=rw(t),s=a?lr(a,r):void 0;return s&&ls(lr(s,n))?s:void 0}function kc(){return cs("pdfjs/wasm","pdfjs-dist","wasm","jbig2.wasm")}function Ac(){return cs("pdfjs/cmaps","pdfjs-dist","cmaps","UniJIS-UCS2-H.bcmap")}function Ic(){let e=lr(us(),"tesseract","worker.cjs");return ls(e)?e:void 0}function Cc(){return cs("tessdata","@tesseract.js-data/eng","4.0.0_best_int","eng.traineddata.gz")}var fi;function Oc(){return fi??=(async()=>{iw();let e=globalThis;if(!e.pdfjsWorker)e.pdfjsWorker=await import("pdfjs-dist/legacy/build/pdf.worker.mjs");return await nw(()=>import("pdfjs-dist/legacy/build/pdf.mjs"))})(),fi.catch(()=>{fi=void 0}),fi}async function nw(e){let t=console.warn;console.warn=(...r)=>{let n=String(r[0]??"");if(/^Warning: Cannot (load "@napi-rs\/canvas"|polyfill `(Path2D|DOMMatrix|ImageData)`)/.test(n))return;t(...r)};try{return await e()}finally{console.warn=t}}function iw(){let e=globalThis;if(e.DOMMatrix)return;class t{a=1;b=0;c=0;d=1;e=0;f=0;constructor(r){if(r&&r.length>=6)[this.a,this.b,this.c,this.d,this.e,this.f]=Array.from(r).slice(0,6)}set(r){return[this.a,this.b,this.c,this.d,this.e,this.f]=r,this}product(r,n){return[r.a*n.a+r.c*n.b,r.b*n.a+r.d*n.b,r.a*n.c+r.c*n.d,r.b*n.c+r.d*n.d,r.a*n.e+r.c*n.f+r.e,r.b*n.e+r.d*n.f+r.f]}multiplySelf(r=new t){let n=r instanceof t?r:new t(r);return this.set(this.product(this,n))}preMultiplySelf(r=new t){let n=r instanceof t?r:new t(r);return this.set(this.product(n,this))}multiply(r){return new t(this.toArray()).multiplySelf(r)}translateSelf(r=0,n=0){return this.multiplySelf([1,0,0,1,r,n])}translate(r=0,n=0){return new t(this.toArray()).translateSelf(r,n)}scaleSelf(r=1,n=r){return this.multiplySelf([r,0,0,n,0,0])}scale(r=1,n=r){return new t(this.toArray()).scaleSelf(r,n)}invertSelf(){let r=this.a*this.d-this.b*this.c;if(!r)return this.set([Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN]);return this.set([this.d/r,-this.b/r,-this.c/r,this.a/r,(this.c*this.f-this.d*this.e)/r,(this.b*this.e-this.a*this.f)/r])}inverse(){return new t(this.toArray()).invertSelf()}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}}e.DOMMatrix=t}function Dc(e){return e?`${e.replace(/[\\/]+$/,"")}/`:void 0}function Pc(){let e=Dc(kc()),t=Dc(Ac());return{disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,verbosity:0,...e?{wasmUrl:e}:{},...t?{cMapUrl:t,cMapPacked:!0}:{}}}var aw=100,sw=0.5,ow=200,Rc=4,fw=0.1,lw=1,uw=2,cw=3;function hw(e,t){let[r=1,n=0,i=0,a=1,s=0,o=0]=t;return[e[0]*r+e[2]*n,e[1]*r+e[3]*n,e[0]*i+e[2]*a,e[1]*i+e[3]*a,e[0]*s+e[2]*o+e[4],e[1]*s+e[3]*o+e[5]]}async function dw(e,t){let[r,n,i,a]=e.view,s=Math.abs((i-r)*(a-n))||1,o=await e.getOperatorList(),h=[1,0,0,1,0,0],l=[],c=0,p=!1,m=0,_=[];for(let w=0;w<o.fnArray.length;w++){let v=o.fnArray[w],b=o.argsArray[w],S=()=>Math.abs(h[0]*h[3]-h[1]*h[2]);if(v===t.save)l.push(h);else if(v===t.restore)h=l.pop()??h;else if(v===t.transform)h=hw(h,b);else if(v===t.setTextRenderingMode){if(b[0]===3)p=!0}else if(v===t.paintImageXObject||v===t.paintImageXObjectRepeat){if(c+=S(),typeof b[0]==="string")_.push({key:b[0],area:S()/s})}else if(v===t.paintInlineImageXObject)c+=S(),_.push({image:b[0],mask:!1,area:S()/s});else if(v===t.paintImageMaskXObject)c+=S(),_.push({image:b[0],mask:!0,area:S()/s});else if(v===t.constructPath)m++}return{coverage:Math.min(1,c/s),invisibleText:p,pathOps:m,pageArea:s,draws:_}}function Nc(e){let t=e.replace(/\s/g,"");if(t.length<20)return!1;return(t.match(/[-�\u0000-\u0008]/g)?.length??0)/t.length>0.3}var Fc=20000,Mc=60000,li=new Set,an;function pw(e){if(li.add(e),!an){let t=console.log;an=t,console.log=(...r)=>{let n=typeof r[0]==="string"?r[0]:"";if(n.startsWith("Warning: ")){for(let i of li)i(n.slice(9));return}t(...r)}}return()=>{if(li.delete(e),li.size===0&&an)console.log=an,an=void 0}}function Bc(e,t,r){let n=t.startsWith("g_")?e.commonObjs:e.objs;return new Promise((i)=>{let a=setTimeout(()=>i("no answer"),r),s=(o)=>{clearTimeout(a),i(o)};try{n.get(t,(o)=>s(o??null))}catch{s(null)}})}function gw(e,t,r){let{width:n,height:i,data:a}=t;if(!a||!n||!i)return;if(r||t.kind===lw){let h=n+7>>3;if(a.length<h*i)return;let l=new Uint8Array(n*i);for(let c=0;c<i;c++){let p=c*h;for(let m=0;m<n;m++)l[c*n+m]=(a[p+(m>>3)]??0)>>7-(m&7)&1?255:0}return e({width:n,height:i,data:l,channels:1,depth:8})}let o=t.kind===uw?3:t.kind===cw?4:a.length/(n*i);if(o!==1&&o!==3&&o!==4)return;return e({width:n,height:i,data:new Uint8Array(a.buffer,a.byteOffset,n*i*o),channels:o,depth:8})}function mw(e,t){let r=e?.name,n=e?.message??"";if(r!=="PasswordException"&&!/password/i.test(n))return;return Error(t?"The PDF's password is not the one given in `password`.":"The PDF is password-protected. Ask the user for the password and call again with `password`.")}async function zc(e,t){let r=await Oc(),{encode:n}=await import("fast-png"),i=new Set,a=t.onNote?pw((h)=>{if(i.size>=60||i.has(h))return;i.add(h),t.onNote?.(`pdf.js: ${h}`)}):void 0,s=r.getDocument({...Pc(),...t.onNote?{verbosity:1}:{},data:e.slice(),...t.password?{password:t.password}:{}}),o;try{o=await s.promise}catch(h){throw await s.destroy().catch(()=>{}),a?.(),mw(h,t.password)??h}try{return await vw(o,r.OPS,n,t)}finally{await s.destroy().catch(()=>{}),a?.()}}async function vw(e,t,r,n){let a=(await e.getMetadata().catch(()=>{return}))?.info??{},s=e.numPages,o=[],h=[],l=[],c=[],p=[],m=[],_=0,w=(v,b)=>n.onProgress?.({unit:"page",at:v,total:s,pictures:_,...b?{activity:b}:{}});for(let v=1;v<=s;v++){if(n.selects&&!n.selects(v))continue;n.signal?.throwIfAborted(),w(v),o.push(v),w(v,"opening the page");let b=await e.getPage(v);w(v,"reading its text");let S=await b.getTextContent(),T="";for(let E of S.items){if(typeof E.str!=="string")continue;if(T+=E.str,E.hasEOL)T+=`
23
+ `}T=T.replace(/[ \t]+\n/g,`
13
24
  `).replace(/\n{3,}/g,`
14
25
 
15
- `).trim(),G(z,"reading its layout");let v=await UJ(C,$);G(z);let b=P.replace(/\s/g,"").length,d=v.coverage>=HJ,L=!1;if(d&&v.invisibleText&&b>0)F.push(z);else if(d&&(b<KJ||eQ(P)))L=!0;else if(b===0&&v.coverage===0&&v.pathOps>=YJ)U.push(z);else if(eQ(P))L=!0;if(L)X.push(z);let T=q.wantImages||L&&!!q.recognize,S=[];if(T){let j=0,O=0;for(let k of v.draws){if(O++,"key"in k)G(z,`decoding picture ${O} of ${v.draws.length}`);let A="key"in k?await J$(C,k.key,Q$):k.image;if(A==="no answer"&&"key"in k){let{key:f}=k;q.onNote?.(`page ${z}: picture ${O} of ${v.draws.length} (${f}) did not arrive in ${Q$/1000}s; asking for the page's pictures again`),G(z,`decoding picture ${O} of ${v.draws.length} again`),C.cleanup();let vQ=await Promise.race([C.getOperatorList().then(()=>!0),new Promise((zQ)=>setTimeout(()=>zQ(!1),$$))]).catch(()=>!1);if(A=vQ?await J$(C,f,$$):"no answer",A==="no answer"){let zQ=f.startsWith("g_")?C.commonObjs:C.objs,SQ="unknown";try{SQ=zQ.has(f)?"delivered late":"never delivered"}catch{}q.problems?.push(`page ${z}: picture ${O} of ${v.draws.length} (${f}) was left out, the PDF decoder gave no answer for it when asked twice (${vQ?SQ:"the page's drawing did not come back either"})`),q.onNote?.(`page ${z}: picture ${O} (${f}) left out after the second request`);continue}q.onNote?.(`page ${z}: picture ${O} (${f}) arrived on the second request`)}if(A==="no answer")continue;if(!A){q.problems?.push(`page ${z}: a picture was left out, the PDF decoder could not decode it`);continue}if(A.width<tQ||A.height<tQ)continue;let OQ=FJ(J,A,"mask"in k&&k.mask);if(!OQ){q.problems?.push(`page ${z}: a ${A.width}x${A.height} picture was left out, its pixel layout is one this cannot write`);continue}j++,N++,S.push({png:OQ,width:A.width,height:A.height,coverage:k.area,stem:`p${z}-${j}`})}}let w;if(L&&q.recognize){let j=S.filter((k)=>k.coverage>=XJ);if(j.length>0)G(z,"recognizing text");let O=j.length>0?await q.recognize(z,j):void 0;if(O?.text.trim())B.push(z),w=`[Text recognized from the page image by ${O.by}]
26
+ `).trim(),w(v,"reading its layout");let k=await dw(b,t);w(v);let x=T.replace(/\s/g,"").length,A=k.coverage>=sw,O=!1;if(A&&k.invisibleText&&x>0)c.push(v);else if(A&&(x<aw||Nc(T)))O=!0;else if(x===0&&k.coverage===0&&k.pathOps>=ow)p.push(v);else if(Nc(T))O=!0;if(O)h.push(v);let C=n.wantImages||O&&!!n.recognize,D=[];if(C){let E=0,B=0;for(let G of k.draws){if(B++,"key"in G)w(v,`decoding picture ${B} of ${k.draws.length}`);let V="key"in G?await Bc(b,G.key,Fc):G.image;if(V==="no answer"&&"key"in G){let{key:N}=G;n.onNote?.(`page ${v}: picture ${B} of ${k.draws.length} (${N}) did not arrive in ${Fc/1000}s; asking for the page's pictures again`),w(v,`decoding picture ${B} of ${k.draws.length} again`),b.cleanup();let ne=await Promise.race([b.getOperatorList().then(()=>!0),new Promise((ue)=>setTimeout(()=>ue(!1),Mc))]).catch(()=>!1);if(V=ne?await Bc(b,N,Mc):"no answer",V==="no answer"){let ue=N.startsWith("g_")?b.commonObjs:b.objs,ee="unknown";try{ee=ue.has(N)?"delivered late":"never delivered"}catch{}n.problems?.push(`page ${v}: picture ${B} of ${k.draws.length} (${N}) was left out, the PDF decoder gave no answer for it when asked twice (${ne?ee:"the page's drawing did not come back either"})`),n.onNote?.(`page ${v}: picture ${B} (${N}) left out after the second request`);continue}n.onNote?.(`page ${v}: picture ${B} (${N}) arrived on the second request`)}if(V==="no answer")continue;if(!V){n.problems?.push(`page ${v}: a picture was left out, the PDF decoder could not decode it`);continue}if(V.width<Rc||V.height<Rc)continue;let Ie=gw(r,V,"mask"in G&&G.mask);if(!Ie){n.problems?.push(`page ${v}: a ${V.width}x${V.height} picture was left out, its pixel layout is one this cannot write`);continue}E++,_++,D.push({png:Ie,width:V.width,height:V.height,coverage:G.area,stem:`p${v}-${E}`})}}let d;if(O&&n.recognize){let E=D.filter((G)=>G.coverage>=fw);if(E.length>0)w(v,"recognizing text");let B=E.length>0?await n.recognize(v,E):void 0;if(B?.text.trim())l.push(v),d=`[Text recognized from the page image by ${B.by}]
16
27
 
17
- ${O.text.trim()}`}let i=[];if(q.wantImages)for(let j of S){let O=q.images.add({data:j.png,stem:j.stem,mediaType:"image/png",width:j.width,height:j.height,source:`page ${z}`});if(O)i.push(x(O))}G(z),V.push([`## Page ${z}`,P,w??"",...i].filter((j)=>j.length>0).join(`
28
+ ${B.text.trim()}`}let R=[];if(n.wantImages)for(let E of D){let B=n.images.add({data:E.png,stem:E.stem,mediaType:"image/png",width:E.width,height:E.height,source:`page ${v}`});if(B)R.push(We(B))}w(v),m.push([`## Page ${v}`,T,d??"",...R].filter((E)=>E.length>0).join(`
18
29
 
19
- `)),C.cleanup()}return{markdown:V.join(`
30
+ `)),b.cleanup()}return{markdown:m.join(`
20
31
 
21
- `),reader:"pdf.js",...typeof K.Title==="string"&&K.Title.trim()?{title:K.Title.trim()}:{},...typeof K.Author==="string"&&K.Author.trim()?{author:K.Author.trim()}:{},units:{name:"page",total:H,read:Y},...X.length?{scannedPages:X}:{},...B.length?{recognizedPages:B}:{},...F.length?{ocrLayerPages:F}:{},...U.length?{vectorPages:U}:{}}}function Z$(Q){let $=Q?.trim();if(!$)return;let J=[];for(let q of $.split(",")){let Z=q.trim();if(!Z)continue;let K=/^(\d+)\s*(?:-\s*(\d*))?$/.exec(Z);if(!K)throw Error(`range "${Q}" is not understood: use one-based numbers, spans and an open end, like "1-5,9,12-".`);let H=Number(K[1]),Y=K[2]===void 0?H:K[2]===""?Number.POSITIVE_INFINITY:Number(K[2]);if(H<1||Y<H)throw Error(`range "${Z}" is empty: numbers start at 1 and a span runs low to high.`);J.push([H,Y])}if(J.length===0)return;return{selects:(q)=>J.some(([Z,K])=>q>=Z&&q<=K),spec:$.replace(/\s+/g,"")}}function m(Q){let $=[...new Set(Q)].sort((q,Z)=>q-Z),J=[];for(let q=0;q<$.length;){let Z=q;while(Z+1<$.length&&$[Z+1]===$[Z]+1)Z++;J.push(q===Z?`${$[q]}`:`${$[q]}-${$[Z]}`),q=Z+1}return J.join(", ")}import{existsSync as K$}from"node:fs";import{copyFile as NJ,mkdir as LJ,readdir as T0,rename as O0,rm as v0,writeFile as S0}from"node:fs/promises";import{join as HQ}from"node:path";import{resolveClineDataDir as jJ}from"@cerebriline/shared/storage";var QQ="eng",RQ=".traineddata.gz";function LQ(){return HQ(jJ(),"tessdata")}function H$(Q){let J=(typeof Q==="string"?Q.split(/[+,\s]+/):Q??[]).map((q)=>q.trim().toLowerCase()).filter(Boolean);return[...new Set(J)]}async function TJ(Q,$){let J=sQ();if(J&&Q.every((K)=>K===QQ))return J;let q=Q.filter((K)=>!K$(HQ($,`${K}${RQ}`))&&!(K===QQ&&J));if(q.length>0)throw new YQ(q);let Z=HQ($,`${QQ}${RQ}`);if(J&&Q.includes(QQ)&&!K$(Z))await LJ($,{recursive:!0}),await NJ(HQ(J,`${QQ}${RQ}`),Z);return $}class YQ extends Error{languages;constructor(Q){super(`OCR language${Q.length===1?"":"s"} ${Q.join(", ")} ${Q.length===1?"is":"are"} not installed.`);this.languages=Q}}var OJ=180000,vJ=120000,SJ=1e4;function NQ(Q,$,J){let q;return Promise.race([Q,new Promise((Z,K)=>{q=setTimeout(()=>K(Error(`${J} gave no answer in ${$/1000}s`)),$)})]).finally(()=>clearTimeout(q))}class XQ{worker;languages;failure;dead;constructor(Q,$,J){this.worker=Q;this.languages=$;this.failure=J}static async open(Q,$=LQ()){let J=await TJ(Q,$),q=await import("tesseract.js"),Z=q.default??q,K=nQ(),H={},Y=await NQ(Z.createWorker(Q.join("+"),Z.OEM.LSTM_ONLY,{langPath:J,gzip:!0,cacheMethod:"none",...K?{workerPath:K}:{},errorHandler:(X)=>{let B=X instanceof Error?X:Error(`the OCR worker failed: ${String(X)}`);H.error=B,H.raise?.(B)}}),vJ,"Starting the OCR worker");return new XQ(Y,Q,H)}async recognize(Q){if(this.dead)throw this.dead;if(this.failure.error)throw this.dead=this.failure.error,this.dead;try{let{data:$}=await NQ(Promise.race([this.worker.recognize(Buffer.from(Q)),new Promise((J,q)=>{this.failure.raise=q})]),OJ,"The OCR worker");return{text:$.text??"",confidence:Math.round($.confidence??0)}}catch($){if(this.failure.error||$ instanceof Error&&/gave no answer/.test($.message))this.dead=$ instanceof Error?$:Error(String($));throw $}finally{this.failure.raise=void 0}}async close(){await NQ(this.worker.terminate(),SJ,"Stopping the OCR worker").catch(()=>{})}}var PJ=40,AJ=12,IJ=4;var kJ="This is a scanned page from a document. Transcribe all of its text exactly as written, in reading order, keeping paragraphs, headings and lists, and table rows as Markdown tables. Do not describe the page, summarize or add anything. Reply with the text only, or with nothing if the page has no text.";var Y$="The user can change this under Settings > Features > Document Reader.";function DJ(Q){let $=Q.settings.ocr??"tesseract";if(Q.request==="none")return{kind:"none",reason:'Text recognition was skipped (ocr: "none").'};if($==="off")return{kind:"none",reason:`Text recognition (OCR) is turned off. ${Y$}`};let J=!Q.request||Q.request==="auto"?$:Q.request,q=H$(Q.languages??Q.settings.ocrLanguages??["eng"]);if(J==="tesseract")return{kind:"tesseract",languages:q.length?q:["eng"]};if(Q.describeImages)return{kind:"vision"};if(Q.modelSupportsImages)return{kind:"self",why:"no vision model is configured"};return{kind:"tesseract",languages:q.length?q:["eng"],fallback:"No vision model is configured and this model does not take images, so tesseract read the pages instead."}}function X$(Q){let $=DJ(Q),J=[],q=[],Z=[],K,H=0,Y=Q.pageLimit!==void 0?Q.pageLimit:$.kind==="tesseract"?PJ:$.kind==="vision"?AJ:IJ;return{recognize:$.kind==="none"?void 0:async(B,F)=>{if(H>=Y){q.push(B);return}H++;let U=[...F].sort((z,C)=>C.coverage-z.coverage);if($.kind==="self"){let z=U[0];if(z)J.push({page:B,png:z.png});return}if($.kind==="vision")return EJ(Q.describeImages,B,U,Z);K??=XQ.open($.languages,Q.settings.ocrDataDir??LQ());let V;try{V=await K}catch(z){if(!Z.length)Z.push(MJ(z));return}let N=[],G=0;for(let z of U)try{let C=await V.recognize(z.png);if(C.text.trim())N.push(C.text.trim()),G=Math.max(G,C.confidence)}catch(C){Z.push(`page ${B}: ${C instanceof Error?C.message:String(C)}`)}if(!N.length)return;return{text:N.join(`
32
+ `),reader:"pdf.js",...typeof a.Title==="string"&&a.Title.trim()?{title:a.Title.trim()}:{},...typeof a.Author==="string"&&a.Author.trim()?{author:a.Author.trim()}:{},units:{name:"page",total:s,read:o},...h.length?{scannedPages:h}:{},...l.length?{recognizedPages:l}:{},...c.length?{ocrLayerPages:c}:{},...p.length?{vectorPages:p}:{}}}function Lc(e){let t=e?.trim();if(!t)return;let r=[];for(let n of t.split(",")){let i=n.trim();if(!i)continue;let a=/^(\d+)\s*(?:-\s*(\d*))?$/.exec(i);if(!a)throw Error(`range "${e}" is not understood: use one-based numbers, spans and an open end, like "1-5,9,12-".`);let s=Number(a[1]),o=a[2]===void 0?s:a[2]===""?Number.POSITIVE_INFINITY:Number(a[2]);if(s<1||o<s)throw Error(`range "${i}" is empty: numbers start at 1 and a span runs low to high.`);r.push([s,o])}if(r.length===0)return;return{selects:(n)=>r.some(([i,a])=>n>=i&&n<=a),spec:t.replace(/\s+/g,"")}}function ur(e){let t=[...new Set(e)].sort((n,i)=>n-i),r=[];for(let n=0;n<t.length;){let i=n;while(i+1<t.length&&t[i+1]===t[i]+1)i++;r.push(n===i?`${t[n]}`:`${t[n]}-${t[i]}`),n=i+1}return r.join(", ")}import{existsSync as Uc}from"node:fs";import{copyFile as _w,mkdir as yw,readdir as Vx,rename as Kx,rm as Yx,writeFile as Jx}from"node:fs/promises";import{join as ui}from"node:path";import{resolveClineDataDir as ww}from"@cerebriline/shared/storage";var sn="eng",hs=".traineddata.gz";function ps(){return ui(ww(),"tessdata")}function jc(e){let r=(typeof e==="string"?e.split(/[+,\s]+/):e??[]).map((n)=>n.trim().toLowerCase()).filter(Boolean);return[...new Set(r)]}async function bw(e,t){let r=Cc();if(r&&e.every((a)=>a===sn))return r;let n=e.filter((a)=>!Uc(ui(t,`${a}${hs}`))&&!(a===sn&&r));if(n.length>0)throw new ci(n);let i=ui(t,`${sn}${hs}`);if(r&&e.includes(sn)&&!Uc(i))await yw(t,{recursive:!0}),await _w(ui(r,`${sn}${hs}`),i);return t}class ci extends Error{languages;constructor(e){super(`OCR language${e.length===1?"":"s"} ${e.join(", ")} ${e.length===1?"is":"are"} not installed.`);this.languages=e}}var xw=180000,Ew=120000,Tw=1e4;function ds(e,t,r){let n;return Promise.race([e,new Promise((i,a)=>{n=setTimeout(()=>a(Error(`${r} gave no answer in ${t/1000}s`)),t)})]).finally(()=>clearTimeout(n))}class hi{worker;languages;failure;dead;constructor(e,t,r){this.worker=e;this.languages=t;this.failure=r}static async open(e,t=ps()){let r=await bw(e,t),n=await import("tesseract.js"),i=n.default??n,a=Ic(),s={},o=await ds(i.createWorker(e.join("+"),i.OEM.LSTM_ONLY,{langPath:r,gzip:!0,cacheMethod:"none",...a?{workerPath:a}:{},errorHandler:(h)=>{let l=h instanceof Error?h:Error(`the OCR worker failed: ${String(h)}`);s.error=l,s.raise?.(l)}}),Ew,"Starting the OCR worker");return new hi(o,e,s)}async recognize(e){if(this.dead)throw this.dead;if(this.failure.error)throw this.dead=this.failure.error,this.dead;try{let{data:t}=await ds(Promise.race([this.worker.recognize(Buffer.from(e)),new Promise((r,n)=>{this.failure.raise=n})]),xw,"The OCR worker");return{text:t.text??"",confidence:Math.round(t.confidence??0)}}catch(t){if(this.failure.error||t instanceof Error&&/gave no answer/.test(t.message))this.dead=t instanceof Error?t:Error(String(t));throw t}finally{this.failure.raise=void 0}}async close(){await ds(this.worker.terminate(),Tw,"Stopping the OCR worker").catch(()=>{})}}var Sw=40,kw=12,Aw=4;var Iw="This is a scanned page from a document. Transcribe all of its text exactly as written, in reading order, keeping paragraphs, headings and lists, and table rows as Markdown tables. Do not describe the page, summarize or add anything. Reply with the text only, or with nothing if the page has no text.";var qc="The user can change this under Settings > Features > Document Reader.";function Cw(e){let t=e.settings.ocr??"tesseract";if(e.request==="none")return{kind:"none",reason:'Text recognition was skipped (ocr: "none").'};if(t==="off")return{kind:"none",reason:`Text recognition (OCR) is turned off. ${qc}`};let r=!e.request||e.request==="auto"?t:e.request,n=jc(e.languages??e.settings.ocrLanguages??["eng"]);if(r==="tesseract")return{kind:"tesseract",languages:n.length?n:["eng"]};if(e.describeImages)return{kind:"vision"};if(e.modelSupportsImages)return{kind:"self",why:"no vision model is configured"};return{kind:"tesseract",languages:n.length?n:["eng"],fallback:"No vision model is configured and this model does not take images, so tesseract read the pages instead."}}function Wc(e){let t=Cw(e),r=[],n=[],i=[],a,s=0,o=e.pageLimit!==void 0?e.pageLimit:t.kind==="tesseract"?Sw:t.kind==="vision"?kw:Aw;return{recognize:t.kind==="none"?void 0:async(l,c)=>{if(s>=o){n.push(l);return}s++;let p=[...c].sort((v,b)=>b.coverage-v.coverage);if(t.kind==="self"){let v=p[0];if(v)r.push({page:l,png:v.png});return}if(t.kind==="vision")return Ow(e.describeImages,l,p,i);a??=hi.open(t.languages,e.settings.ocrDataDir??ps());let m;try{m=await a}catch(v){if(!i.length)i.push(Dw(v));return}let _=[],w=0;for(let v of p)try{let b=await m.recognize(v.png);if(b.text.trim())_.push(b.text.trim()),w=Math.max(w,b.confidence)}catch(b){i.push(`page ${l}: ${b instanceof Error?b.message:String(b)}`)}if(!_.length)return;return{text:_.join(`
22
33
 
23
- `),by:`tesseract (${$.languages.join("+")}, ${G}% confidence)`}},attachments:J,notes(B,F){if(!B.length)return[];let U=[],V=B.filter((G)=>!F.includes(G));if($.kind==="none")return U.push(`Scanned pages ${m(B)}: an image of text with no text layer, so their words are not in this text. ${$.reason}`),U;if(F.length){let G=$.kind==="vision"?"the vision model":`tesseract (${$.kind==="tesseract"?$.languages.join("+"):"eng"})`;U.push(`Scanned pages ${m(F)}: their text was recognized from the page image by ${G}, and may contain recognition errors.`)}if($.kind==="tesseract"&&$.fallback)U.push($.fallback);if($.kind==="self"&&J.length)U.push(`Scanned pages ${m(J.map((G)=>G.page))} are attached below as images (${$.why}): read their text from them.`);if(q.length)U.push(`Scanned pages ${m(q)} were not read: one call reads at most ${Y} scanned pages. Call again with range: "${q[0]}-" for the rest.`);let N=V.filter((G)=>!q.includes(G)&&!($.kind==="self"&&J.some((z)=>z.page===G)));if(N.length)U.push(`Scanned pages ${m(N)}: no text could be recognized${Z.length?` (${Z.slice(0,3).join("; ")})`:""}.`);return U},problems(B,F){let U=[],V=new Map;for(let G of Z){let z=/^page (\d+): ([\s\S]*)$/.exec(G);if(z)V.set(Number(z[1]),z[2]??"")}let N=Z.filter((G)=>!/^page \d+: /.test(G));for(let G of B){if(F.includes(G))continue;let z=q.includes(G)?`past the ${Y} pages recognized in one call`:V.get(G)??N[0]??($.kind==="none"?$.reason:"nothing readable was found on it");U.push(`page ${G}: a scan with no recognized text, ${z}`)}return U},async close(){if(K)await(await K.catch(()=>{return}))?.close()}}}function MJ(Q){if(Q instanceof YQ)return`${Q.message} ${Y$} In the CLI, --ocr-languages installs them`;return`tesseract did not start: ${Q instanceof Error?Q.message:String(Q)}`}async function EJ(Q,$,J,q){if(!Q)return;let Z=J[0];if(!Z)return;try{let[K]=await Q([{image:Buffer.from(Z.png).toString("base64"),mediaType:"image/png",instruction:kJ}]);return K?.trim()?{text:K.trim(),by:"the vision model"}:void 0}catch(K){q.push(`page ${$}: ${K instanceof Error?K.message:String(K)}`);return}}function _J(Q,$,J,q){switch(J){case"pdf":return q$($,q);case"doc":case"xls":case"ppt":return lQ($,J,q);case"epub":case"mobi":case"azw3":case"fb2":return DQ(Q,$,J,q);default:return mQ($,J,q)}}async function z$(Q,$={}){let J=new Uint8Array(await xJ.readFile(Q.filePath)),q=EQ(Q.namedAs??Q.filePath,J.subarray(0,512));if("unsupported"in q)throw Error(q.unsupported);let{format:Z}=q,K=Z$(Q.range),H=Z==="pdf"?X$({request:Q.recognition.request,languages:Q.recognition.languages,settings:Q.recognition.settings,describeImages:$.describeImages,modelSupportsImages:Q.recognition.modelSupportsImages,...Q.recognition.everyPage?{pageLimit:Number.POSITIVE_INFINITY}:{}}):void 0,Y=[],X=new BQ("images"),B;try{B=await _J(Q.filePath,J,Z,{images:X,wantImages:Q.wantImages,scratchDir:Q.scratchDir,problems:Y,...Q.password?{password:Q.password}:{},...K?{selects:K.selects}:{},...$.signal?{signal:$.signal}:{},...$.onProgress?{onProgress:$.onProgress}:{},...$.onNote?{onNote:$.onNote}:{},...H?.recognize?{recognize:H.recognize}:{}})}finally{await H?.close()}let F=B.scannedPages??[],U=B.recognizedPages??[];return{format:Z,result:B,images:[...X.entries()],recognitionNotes:H?.notes(F,U)??[],recognitionProblems:H?.problems(F,U)??[],attachments:H?.attachments??[],problems:Y}}var B$=".out";var G$=process;function p(Q){return new Promise(($)=>{if(!process.connected||!G$.send){$();return}G$.send(Q,()=>$())})}var jQ=new AbortController,TQ=new Map,hJ=0;function bJ(Q){let $=hJ++;return new Promise((J,q)=>{TQ.set($,{resolve:J,reject:q}),p({type:"describe",id:$,images:[...Q]})})}async function fJ(Q,$){let J=Date.now();try{let q=await z$(Q,{signal:jQ.signal,onProgress:(H)=>void p({type:"progress",progress:H}),onNote:(H)=>void p({type:"note",line:H}),...$?{describeImages:bJ}:{}}),Z=W$(Q.scratchDir,B$);await wJ(Z,{recursive:!0});let K=[];for(let[H,{image:Y,data:X}]of q.images.entries()){let B=W$(Z,String(H));await yJ(B,X),K.push({image:Y,file:B})}await p({type:"done",format:q.format,result:q.result,images:K,recognitionNotes:q.recognitionNotes,recognitionProblems:q.recognitionProblems,attachments:q.attachments,problems:q.problems,usage:{ms:Date.now()-J,peakRssMb:Math.round(process.resourceUsage().maxRSS/1024)}})}catch(q){await p({type:"failed",message:q instanceof Error?q.message:String(q),aborted:jQ.signal.aborted})}await Promise.race([cJ,new Promise((q)=>setTimeout(q,uJ).unref())]),process.exit(0)}var uJ=60000,V$=()=>{},cJ=new Promise((Q)=>{V$=Q}),U$=!1;process.on("message",(Q)=>{if(Q.type==="start"&&!U$)U$=!0,fJ(Q.job,Q.hasVision);else if(Q.type==="received")V$();else if(Q.type==="abort")jQ.abort();else if(Q.type==="described"){let $=TQ.get(Q.id);if(TQ.delete(Q.id),!$)return;if(Q.error!==void 0)$.reject(Error(Q.error));else $.resolve(Q.descriptions??[])}});process.on("disconnect",()=>process.exit(0));p({type:"ready"});
34
+ `),by:`tesseract (${t.languages.join("+")}, ${w}% confidence)`}},attachments:r,notes(l,c){if(!l.length)return[];let p=[],m=l.filter((w)=>!c.includes(w));if(t.kind==="none")return p.push(`Scanned pages ${ur(l)}: an image of text with no text layer, so their words are not in this text. ${t.reason}`),p;if(c.length){let w=t.kind==="vision"?"the vision model":`tesseract (${t.kind==="tesseract"?t.languages.join("+"):"eng"})`;p.push(`Scanned pages ${ur(c)}: their text was recognized from the page image by ${w}, and may contain recognition errors.`)}if(t.kind==="tesseract"&&t.fallback)p.push(t.fallback);if(t.kind==="self"&&r.length)p.push(`Scanned pages ${ur(r.map((w)=>w.page))} are attached below as images (${t.why}): read their text from them.`);if(n.length)p.push(`Scanned pages ${ur(n)} were not read: one call reads at most ${o} scanned pages. Call again with range: "${n[0]}-" for the rest.`);let _=m.filter((w)=>!n.includes(w)&&!(t.kind==="self"&&r.some((v)=>v.page===w)));if(_.length)p.push(`Scanned pages ${ur(_)}: no text could be recognized${i.length?` (${i.slice(0,3).join("; ")})`:""}.`);return p},problems(l,c){let p=[],m=new Map;for(let w of i){let v=/^page (\d+): ([\s\S]*)$/.exec(w);if(v)m.set(Number(v[1]),v[2]??"")}let _=i.filter((w)=>!/^page \d+: /.test(w));for(let w of l){if(c.includes(w))continue;let v=n.includes(w)?`past the ${o} pages recognized in one call`:m.get(w)??_[0]??(t.kind==="none"?t.reason:"nothing readable was found on it");p.push(`page ${w}: a scan with no recognized text, ${v}`)}return p},async close(){if(a)await(await a.catch(()=>{return}))?.close()}}}function Dw(e){if(e instanceof ci)return`${e.message} ${qc} In the CLI, --ocr-languages installs them`;return`tesseract did not start: ${e instanceof Error?e.message:String(e)}`}async function Ow(e,t,r,n){if(!e)return;let i=r[0];if(!i)return;try{let[a]=await e([{image:Buffer.from(i.png).toString("base64"),mediaType:"image/png",instruction:Iw}]);return a?.trim()?{text:a.trim(),by:"the vision model"}:void 0}catch(a){n.push(`page ${t}: ${a instanceof Error?a.message:String(a)}`);return}}function Rw(e,t,r,n){switch(r){case"pdf":return zc(t,n);case"doc":case"xls":case"ppt":return Ec(t,r,n);case"epub":case"mobi":case"azw3":case"fb2":return uc(e,t,r,n);default:return Tc(t,r,n)}}async function $c(e,t={}){let r=new Uint8Array(await Pw.readFile(e.filePath)),n=hc(e.namedAs??e.filePath,r.subarray(0,512));if("unsupported"in n)throw Error(n.unsupported);let{format:i}=n,a=Lc(e.range),s=i==="pdf"?Wc({request:e.recognition.request,languages:e.recognition.languages,settings:e.recognition.settings,describeImages:t.describeImages,modelSupportsImages:e.recognition.modelSupportsImages,...e.recognition.everyPage?{pageLimit:Number.POSITIVE_INFINITY}:{}}):void 0,o=[],h=new gi("images"),l;try{l=await Rw(e.filePath,r,i,{images:h,wantImages:e.wantImages,scratchDir:e.scratchDir,problems:o,...e.password?{password:e.password}:{},...a?{selects:a.selects}:{},...t.signal?{signal:t.signal}:{},...t.onProgress?{onProgress:t.onProgress}:{},...t.onNote?{onNote:t.onNote}:{},...s?.recognize?{recognize:s.recognize}:{}})}finally{await s?.close()}let c=l.scannedPages??[],p=l.recognizedPages??[];return{format:i,result:l,images:[...h.entries()],recognitionNotes:s?.notes(c,p)??[],recognitionProblems:s?.problems(c,p)??[],attachments:s?.attachments??[],problems:o}}var Zc=".out";var Gc=process;function cr(e){return new Promise((t)=>{if(!process.connected||!Gc.send){t();return}Gc.send(e,()=>t())})}var gs=new AbortController,ms=new Map,Mw=0;function Bw(e){let t=Mw++;return new Promise((r,n)=>{ms.set(t,{resolve:r,reject:n}),cr({type:"describe",id:t,images:[...e]})})}async function zw(e,t){let r=Date.now();try{let n=await $c(e,{signal:gs.signal,onProgress:(s)=>void cr({type:"progress",progress:s}),onNote:(s)=>void cr({type:"note",line:s}),...t?{describeImages:Bw}:{}}),i=Hc(e.scratchDir,Zc);await Nw(i,{recursive:!0});let a=[];for(let[s,{image:o,data:h}]of n.images.entries()){let l=Hc(i,String(s));await Fw(l,h),a.push({image:o,file:l})}await cr({type:"done",format:n.format,result:n.result,images:a,recognitionNotes:n.recognitionNotes,recognitionProblems:n.recognitionProblems,attachments:n.attachments,problems:n.problems,usage:{ms:Date.now()-r,peakRssMb:Math.round(process.resourceUsage().maxRSS/1024)}})}catch(n){await cr({type:"failed",message:n instanceof Error?n.message:String(n),aborted:gs.signal.aborted})}await Promise.race([Uw,new Promise((n)=>setTimeout(n,Lw).unref())]),process.exit(0)}var Lw=60000,Vc=()=>{},Uw=new Promise((e)=>{Vc=e}),Xc=!1;process.on("message",(e)=>{if(e.type==="start"&&!Xc)Xc=!0,zw(e.job,e.hasVision);else if(e.type==="received")Vc();else if(e.type==="abort")gs.abort();else if(e.type==="described"){let t=ms.get(e.id);if(ms.delete(e.id),!t)return;if(e.error!==void 0)t.reject(Error(e.error));else t.resolve(e.descriptions??[])}});process.on("disconnect",()=>process.exit(0));cr({type:"ready"});