@pretextbook/import 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/convert-worker.cjs +1 -1
- package/dist/convert-worker.js +1 -1
- package/dist/import-mode-CV7gCDzF.cjs +3 -0
- package/dist/import-mode-DQ8g5P8P.js +122 -0
- package/dist/import.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +10 -6
- package/dist/index.js +524 -214
- package/dist/lib/assets/images.d.ts +49 -0
- package/dist/lib/detect-snippet-format.d.ts +32 -0
- package/dist/lib/import-mode.d.ts +22 -0
- package/dist/lib/insert/dedupe-ids.d.ts +36 -0
- package/dist/lib/insert/destination.d.ts +21 -0
- package/dist/lib/insert/index.d.ts +4 -0
- package/dist/lib/insert/prepare.d.ts +44 -0
- package/dist/lib/insert/retarget.d.ts +35 -0
- package/dist/lib/layout/xml-scan.d.ts +28 -0
- package/dist/lib/pandoc/formats.d.ts +40 -0
- package/dist/lib/pandoc/index.d.ts +3 -0
- package/dist/lib/pandoc/pandoc-engine.d.ts +24 -0
- package/dist/lib/pandoc/remote-pandoc.d.ts +74 -0
- package/dist/lib/pool/division-pool.d.ts +5 -0
- package/dist/lib/pool/index.d.ts +5 -1
- package/dist/lib/pool/place-divisions.d.ts +25 -0
- package/dist/lib/pool/placeholders.d.ts +4 -0
- package/dist/lib/pool/refs.d.ts +8 -0
- package/dist/lib/pool/serialize-destination.d.ts +24 -0
- package/dist/lib/pool/serialize-files.d.ts +1 -2
- package/dist/lib/pool/serialize-insert-records.d.ts +22 -0
- package/dist/lib/pool/serialize-insert.d.ts +44 -0
- package/dist/lib/pool/serialize-plus.d.ts +4 -4
- package/dist/lib/pool/serialize-records.d.ts +11 -0
- package/dist/lib/pretext-divisions.d.ts +25 -0
- package/dist/lib/select/divisions.d.ts +44 -0
- package/dist/lib/types.d.ts +82 -2
- package/dist/lib/upload.d.ts +56 -4
- package/dist/react/import-wizard.d.ts +45 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.js +655 -498
- package/dist/upload-BnRj1gU1.cjs +135 -0
- package/dist/upload-H_OCZBBn.js +7648 -0
- package/package.json +1 -1
- package/dist/import-mode-BCGuSwkM.js +0 -112
- package/dist/import-mode-D1gOJw3N.cjs +0 -3
- package/dist/upload-BmErkg8I.js +0 -7140
- package/dist/upload-BtS22hIH.cjs +0 -135
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";const Fi=require("@pretextbook/format"),qi=require("@pretextbook/latex-pretext"),Bi=require("@pretextbook/remark-pretext"),Lr=["\\documentclass","\\begin{document}","\\begin{","\\section","\\chapter","\\title","\\author"],$r=["# ","## ","### ","#### "];function ee(t){const r=t.trim();return!r||r.startsWith("<")?"pretext":Lr.some(n=>r.includes(n))?"latex":$r.some(n=>r.startsWith(n))?"markdown":"pretext"}const Ni=JSON.parse('[" ","!","\\"","#","&","\'","*",",",".",":",";","=",">","AA","AE","Alpha","And","Arrowvert","Bbb","Bbbk","Beta","Big","Bigg","Biggl","Biggm","Biggr","Bigl","Bigm","Bigr","Box","Bra","Bumpeq","C","Cap","Chi","Colonapprox","Coloneq","Coloneqq","Colonsim","Complex","Coppa","Cup","Dagger","Darr","DeclareMathOperator","Delta","Diamond","Digamma","Doteq","Downarrow","Epsilon","Eqcolon","Eqqcolon","Eta","Finv","Game","Gamma","H","Harr","Huge","Im","Iota","Join","KaTeX","Kappa","Ket","Koppa","L","LARGE","LaTeX","Lambda","Large","Larr","LeftArrow","Leftarrow","Leftrightarrow","Lleftarrow","Longleftarrow","Longleftrightarrow","Longrightarrow","Lrarr","Lsh","Mu","N","Newextarrow","Nu","O","OE","Omega","Omicron","Overrightarrow","P","Phi","Pi","Pr","Psi","Q","R","Rarr","Re","Reals","Rho","Rightarrow","Rrightarrow","Rsh","Rule","S","Sampi","Sigma","Space","Stigma","Subset","Supset","Tau","TeX","Theta","Tiny","Uarr","Uparrow","Updownarrow","Upsilon","Vdash","Vert","Vvdash","Xi","Z","Zeta","\\\\","^","_","`","aa","above","abovewithdelims","acute","add","ae","alef","alefsym","aleph","allowbreak","alpha","amalg","and","ang","angl","angle","angln","approx","approxcolon","approxcoloncolon","approxeq","arccos","arcctg","arcsin","arctan","arctg","arg","argmax","argmin","array","arraystretch","arrowvert","ast","asymp","atop","atopwithdelims","backepsilon","backprime","backsim","backsimeq","backslash","bar","barwedge","bbox","bcancel","because","begin","begingroup","beta","beth","between","bf","bfseries","big","bigcap","bigcirc","bigcup","bigg","biggl","biggm","biggr","bigl","bigm","bigodot","bigominus","bigoplus","bigoslash","bigotimes","bigr","bigsqcap","bigsqcup","bigstar","bigtriangledown","bigtriangleup","biguplus","bigvee","bigwedge","binom","blacklozenge","blacksquare","blacktriangle","blacktriangledown","blacktriangleleft","blacktriangleright","bm","bmod","bold","boldsymbol","bot","bowtie","boxdot","boxed","boxminus","boxplus","boxtimes","bra","brace","bracevert","brack","braket","breve","buildrel","bull","bullet","bumpeq","cal","cancel","cancelto","cap","cases","cdot","cdotp","cdots","ce","cee","centerdot","cf","cfrac","ch","char","check","checkmark","chi","chk","choose","circ","circeq","circlearrowleft","circlearrowright","circledR","circledS","circledast","circledcirc","circleddash","class","cline","clubs","clubsuit","cnums","colon","colonapprox","coloncolon","coloncolonapprox","coloncolonequals","coloncolonminus","coloncolonsim","coloneq","coloneqq","colonequals","colonminus","colonsim","color","colorbox","complement","cong","coppa","coprod","copyright","cos","cosec","cosh","cot","cotg","coth","cr","csc","cssId","ctg","cth","cup","curlyeqprec","curlyeqsucc","curlyvee","curlywedge","curvearrowleft","curvearrowright","dArr","dag","dagger","daleth","darr","dashleftarrow","dashrightarrow","dashv","dbinom","dblcolon","ddag","ddagger","ddddot","dddot","ddot","ddots","def","definecolor","deg","degree","delta","det","dfrac","diagdown","diagup","diamond","diamonds","diamondsuit","digamma","dim","displaylines","displaystyle","div","divideontimes","dot","doteq","doteqdot","dotplus","dots","dotsb","dotsc","dotsi","dotsm","dotso","doublebarwedge","doublecap","doublecup","downarrow","downdownarrows","downharpoonleft","downharpoonright","edef","ell","else","em","emph","empty","emptyset","enclose","end","endgroup","enspace","epsilon","eqalign","eqalignno","eqcirc","eqcolon","eqqcolon","eqref","eqsim","eqslantgtr","eqslantless","equalscolon","equalscoloncolon","equiv","eta","eth","euro","exist","exists","exp","expandafter","fallingdotseq","fbox","fcolorbox","fi","flat","foo","footnotesize","forall","frac","frak","frown","futurelet","gamma","gcd","gdef","ge","geneuro","geneuronarrow","geneurowide","genfrac","geq","geqq","geqslant","gets","gg","ggg","gggtr","gimel","global","gnapprox","gneq","gneqq","gnsim","grave","greet","gt","gtrapprox","gtrdot","gtreqless","gtreqqless","gtrless","gtrsim","gvertneqq","hArr","hail","harr","hat","hbar","hbox","hdashline","hearts","heartsuit","hfil","hfill","hline","hom","hookleftarrow","hookrightarrow","hphantom","href","hskip","hslash","hspace","htmlClass","htmlData","htmlId","htmlStyle","huge","i","iddots","idotsint","if","iff","ifmode","ifx","iiiint","iiint","iint","image","imageof","imath","impliedby","implies","in","includegraphics","inf","infin","infty","injlim","int","intercal","intop","iota","isin","it","itshape","j","jmath","kappa","ker","kern","ket","koppa","l","lArr","lBrace","lVert","label","lambda","land","lang","langle","large","larr","lbrace","lbrack","lceil","ldotp","ldots","le","leadsto","left","leftarrow","leftarrowtail","leftharpoondown","leftharpoonup","leftleftarrows","leftrightarrow","leftrightarrows","leftrightharpoons","leftrightsquigarrow","leftroot","leftthreetimes","leq","leqalignno","leqq","leqslant","lessapprox","lessdot","lesseqgtr","lesseqqgtr","lessgtr","lesssim","let","lfloor","lg","lgroup","lhd","lim","liminf","limits","limsup","ll","llap","llbracket","llcorner","lll","llless","lmoustache","ln","lnapprox","lneq","lneqq","lnot","lnsim","log","long","longleftarrow","longleftrightarrow","longmapsto","longrightarrow","looparrowleft","looparrowright","lor","lower","lozenge","lparen","lq","lrArr","lrarr","lrcorner","lt","ltimes","lvert","lvertneqq","maltese","mapsto","mathbb","mathbf","mathbin","mathcal","mathchoice","mathclap","mathclose","mathellipsis","mathfrak","mathinner","mathit","mathllap","mathnormal","mathop","mathopen","mathord","mathpunct","mathrel","mathring","mathrlap","mathrm","mathscr","mathsf","mathsterling","mathstrut","mathtip","mathtt","matrix","max","mbox","md","mdseries","measuredangle","medspace","mho","mid","middle","min","minuscolon","minuscoloncolon","minuso","mit","mkern","mmlToken","mod","models","moveleft","moveright","mp","mskip","mspace","mu","multicolumn","multimap","nLeftarrow","nLeftrightarrow","nRightarrow","nVDash","nVdash","nabla","natnums","natural","ncong","ne","nearrow","neg","negmedspace","negthickspace","negthinspace","neq","newcommand","newenvironment","newline","nexists","ngeq","ngeqq","ngeqslant","ngtr","ni","nleftarrow","nleftrightarrow","nleq","nleqq","nleqslant","nless","nmid","nobreak","nobreakspace","noexpand","nolimits","nonumber","normalfont","normalsize","not","notag","notin","notni","nparallel","nprec","npreceq","nrightarrow","nshortmid","nshortparallel","nsim","nsubseteq","nsubseteqq","nsucc","nsucceq","nsupseteq","nsupseteqq","ntriangleleft","ntrianglelefteq","ntriangleright","ntrianglerighteq","nu","nvDash","nvdash","nwarrow","o","odot","oe","officialeuro","oiiint","oiint","oint","oldstyle","omega","omicron","ominus","operatorname","operatornamewithlimits","oplus","or","origof","oslash","otimes","over","overbrace","overbracket","overgroup","overleftarrow","overleftharpoon","overleftrightarrow","overline","overlinesegment","overparen","overrightarrow","overrightharpoon","overset","overwithdelims","owns","pagecolor","parallel","part","partial","perp","phantom","phase","phi","pi","pitchfork","plim","plusmn","pm","pmatrix","pmb","pmod","pod","pounds","prec","precapprox","preccurlyeq","preceq","precnapprox","precneqq","precnsim","precsim","prime","prod","projlim","propto","providecommand","psi","pu","qquad","quad","r","rArr","rBrace","rVert","raise","raisebox","rang","rangle","rarr","ratio","rbrace","rbrack","rceil","real","reals","ref","relax","renewcommand","renewenvironment","require","restriction","rfloor","rgroup","rhd","rho","right","rightarrow","rightarrowtail","rightharpoondown","rightharpoonup","rightleftarrows","rightleftharpoons","rightrightarrows","rightsquigarrow","rightthreetimes","risingdotseq","rlap","rm","rmoustache","root","rotatebox","rparen","rq","rrbracket","rtimes","rule","rvert","sampi","sc","scalebox","scr","scriptscriptstyle","scriptsize","scriptstyle","sdot","searrow","sec","sect","setlength","setminus","sf","sh","sharp","shortmid","shortparallel","shoveleft","shoveright","sideset","sigma","sim","simcolon","simcoloncolon","simeq","sin","sinh","sixptsize","skew","skip","sl","small","smallfrown","smallint","smallsetminus","smallsmile","smash","smile","smiley","sout","space","spades","spadesuit","sphericalangle","sqcap","sqcup","sqrt","sqsubset","sqsubseteq","sqsupset","sqsupseteq","square","ss","stackrel","star","stigma","strut","style","sub","sube","subset","subseteq","subseteqq","subsetneq","subsetneqq","substack","succ","succapprox","succcurlyeq","succeq","succnapprox","succneqq","succnsim","succsim","sum","sup","supe","supset","supseteq","supseteqq","supsetneq","supsetneqq","surd","swarrow","tag","tan","tanh","tau","tbinom","text","textasciicircum","textasciitilde","textbackslash","textbar","textbardbl","textbf","textbraceleft","textbraceright","textcircled","textcolor","textdagger","textdaggerdbl","textdegree","textdollar","textellipsis","textemdash","textendash","textgreater","textit","textless","textmd","textnormal","textquotedblleft","textquotedblright","textquoteleft","textquoteright","textregistered","textrm","textsc","textsf","textsl","textsterling","textstyle","texttip","texttt","textunderscore","textup","textvisiblespace","tfrac","tg","th","therefore","theta","thetasym","thickapprox","thicksim","thickspace","thinspace","tilde","times","tiny","to","toggle","top","triangle","triangledown","triangleleft","trianglelefteq","triangleq","triangleright","trianglerighteq","tt","twoheadleftarrow","twoheadrightarrow","u","uArr","uarr","ulcorner","underbar","underbrace","underbracket","undergroup","underleftarrow","underleftrightarrow","underline","underlinesegment","underparen","underrightarrow","underset","unicode","unlhd","unrhd","up","uparrow","updownarrow","upharpoonleft","upharpoonright","uplus","uproot","upshape","upsilon","upuparrows","urcorner","url","utilde","v","vDash","varDelta","varGamma","varLambda","varOmega","varPhi","varPi","varPsi","varSigma","varTheta","varUpsilon","varXi","varcoppa","varepsilon","varinjlim","varkappa","varliminf","varlimsup","varnothing","varphi","varpi","varprojlim","varpropto","varrho","varsigma","varstigma","varsubsetneq","varsubsetneqq","varsupsetneq","varsupsetneqq","vartheta","vartriangle","vartriangleleft","vartriangleright","vcentcolon","vcenter","vdash","vdots","vec","vee","veebar","vert","vfil","vfill","vline","vphantom","wedge","weierp","widecheck","widehat","wideparen","widetilde","wp","wr","xLeftarrow","xLeftrightarrow","xRightarrow","xcancel","xdef","xhookleftarrow","xhookrightarrow","xi","xleftarrow","xleftharpoondown","xleftharpoonup","xleftrightarrow","xleftrightharpoons","xlongequal","xmapsto","xrightarrow","xrightharpoondown","xrightharpoonup","xrightleftharpoons","xtofrom","xtwoheadleftarrow","xtwoheadrightarrow","yen","zeta","{","|","}","~"]'),Mi=["align","align*","alignat","alignat*","aligned","alignedat","array","Bmatrix","bmatrix","Bmatrix*","bmatrix*","cases","CD","darray","dcases","drcases","equation","equation*","gather","gathered","matrix","matrix*","pmatrix","pmatrix*","rcases","smallmatrix","split","Vmatrix","vmatrix","Vmatrix*","vmatrix*"],Dr={KATEX_MACROS:Ni,KATEX_ENVIRONMENTS:Mi};new Set(Dr.KATEX_MACROS);const Ui=new Set(Dr.KATEX_ENVIRONMENTS),Wi=[{name:"enumerate",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
2
|
+
\\item $0
|
|
3
|
+
`,documentation:"Ordered list. Converts to `<ol>`."},{name:"itemize",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
4
|
+
\\item $0
|
|
5
|
+
`,documentation:"Unordered list. Converts to `<ul>`."},{name:"description",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
6
|
+
\\item[\${1:term}] $0
|
|
7
|
+
`,documentation:"Description list. Converts to `<dl>`; each `\\item[term]` becomes a `<li>` with a `<title>`."},{name:"tabular",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural",snippet:`{\${1:cc}}
|
|
8
|
+
$0
|
|
9
|
+
`,documentation:"Table body. Converts to a PreTeXt `<tabular>`."},{name:"center",aliases:[],requiresStatement:!1,titleArg:!1,kind:"block",documentation:"Converts to `<blockquote>`."},{name:"quote",aliases:[],requiresStatement:!1,titleArg:!1,kind:"block",documentation:"Converts to `<blockquote>`."},{name:"figure",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural",documentation:"Converts to `<figure>`. Use `\\caption{}` for the caption."},{name:"table",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural",documentation:"Converts to `<table>`. Use `\\caption{}` for the title."},{name:"code",aliases:[],requiresStatement:!1,titleArg:!1,kind:"verbatim",documentation:"Raw content emitted inside `<pre>`."},{name:"poem",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural",documentation:"Lines split on `\\\\`, stanzas on blank lines."},{name:"sidebyside",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural",childEnvironments:["stack"],documentation:"Side-by-side layout container."},{name:"program",aliases:[],requiresStatement:!1,titleArg:!1,kind:"verbatim",documentation:"Raw code inside `<program><input>`; optional `[language]`."},{name:"console",aliases:[],requiresStatement:!1,titleArg:!1,kind:"verbatim",documentation:"Raw content inside `<console>`."},{name:"sage",aliases:[],requiresStatement:!1,titleArg:!1,kind:"verbatim",documentation:"Raw input inside `<sage><input>`."},{name:"webwork",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural",documentation:"WeBWorK problem container."},{name:"slide",aliases:["frame"],requiresStatement:!1,titleArg:!1,kind:"structural",snippet:"{${1:Title}}{${2:Subtitle}}\n $0\n",documentation:"Beamer-style slide (`slide` or `frame`). Converts to `<slide>`; title/subtitle come from the two braced arguments (or `\\frametitle{}`/`\\framesubtitle{}` inside the body)."},{name:"preface",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"biography",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"dedication",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"glossary",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"biblio",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"gi",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"exercises",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"exercisegroup",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural",childEnvironments:["hint","answer","solution"]},{name:"subexercises",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"worksheet",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"handout",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"reading-questions",aliases:["readingquestions"],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"solutions",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"introduction",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"conclusion",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"paragraphs",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"objectives",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"outcomes",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"list",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural"},{name:"listing",aliases:[],requiresStatement:!1,titleArg:!1,kind:"structural"},{name:"sbsgroup",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"stack",aliases:[],requiresStatement:!1,titleArg:!0,kind:"structural"},{name:"questions",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
10
|
+
\\question $0
|
|
11
|
+
`,documentation:"Exam-class list of questions."},{name:"parts",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
12
|
+
\\part $0
|
|
13
|
+
`},{name:"subparts",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
14
|
+
\\subpart $0
|
|
15
|
+
`},{name:"subsubparts",aliases:[],requiresStatement:!1,titleArg:!1,kind:"list",snippet:`
|
|
16
|
+
\\subsubpart $0
|
|
17
|
+
`}],Xi={abstract:{requiresStatement:!1,aliases:["abs","abstr"]},acknowledgement:{requiresStatement:!1,aliases:["ack"]},algorithm:{requiresStatement:!0,aliases:["algo","alg"]},answer:{requiresStatement:!1,aliases:["ans"]},assumption:{requiresStatement:!0,aliases:["assu","ass"]},axiom:{requiresStatement:!0,aliases:["axm"]},claim:{requiresStatement:!0,aliases:["cla"]},conjecture:{requiresStatement:!0,aliases:["con","conj","conjec"]},activity:{requiresStatement:!1,aliases:[]},aside:{requiresStatement:!1,aliases:[]},assemblage:{requiresStatement:!1,aliases:[]},biographical:{requiresStatement:!1,aliases:[]},case:{requiresStatement:!1,aliases:[]},computation:{requiresStatement:!1,aliases:["comp"]},construction:{requiresStatement:!1,aliases:[]},convention:{requiresStatement:!1,aliases:["conv"]},corollary:{requiresStatement:!0,aliases:["cor","corr","coro","corol","corss"]},definition:{requiresStatement:!0,aliases:["def","defn","dfn","defi","defin","de"]},example:{requiresStatement:!0,aliases:["exam","exa","eg","exmp","expl","exm"]},exercise:{requiresStatement:!0,aliases:["exer","exers"]},data:{requiresStatement:!1,aliases:[]},exploration:{requiresStatement:!1,aliases:[]},fact:{requiresStatement:!0,aliases:[]},heuristic:{requiresStatement:!0,aliases:[]},hint:{requiresStatement:!1,aliases:[]},historical:{requiresStatement:!1,aliases:[]},hypothesis:{requiresStatement:!0,aliases:["hyp"]},identity:{requiresStatement:!0,aliases:["idnty"]},insight:{requiresStatement:!1,aliases:[]},investigation:{requiresStatement:!1,aliases:[]},lemma:{requiresStatement:!0,aliases:["lem","lma","lemm","lm"]},notation:{requiresStatement:!1,aliases:["no","nota","ntn","nt","notn","notat"]},note:{requiresStatement:!1,aliases:["notes"]},observation:{requiresStatement:!1,aliases:["obs"]},principle:{requiresStatement:!0,aliases:[]},problem:{requiresStatement:!0,aliases:["prob","prb"]},project:{requiresStatement:!1,aliases:[]},proof:{requiresStatement:!1,aliases:["pf","prf","demo"]},proposition:{requiresStatement:!0,aliases:["prop","pro","prp","props"]},question:{requiresStatement:!0,aliases:["qu","ques","quest","qsn"]},remark:{requiresStatement:!1,aliases:["rem","rmk","rema","bem","subrem"]},task:{requiresStatement:!0,aliases:[]},technology:{requiresStatement:!1,aliases:["tech"]},theorem:{requiresStatement:!0,aliases:["thm","theo","theor","thmss","thrm"]},solution:{requiresStatement:!1,aliases:["sol"]},warning:{requiresStatement:!1,aliases:["warn","wrn"]}},Zi=new Set(["exercise","problem","question","task","activity","exploration","investigation"]);function Vi(t,r){let n;return Zi.has(t)?n=["hint","answer","solution"]:r.requiresStatement&&(n=["proof"]),{name:t,aliases:r.aliases,requiresStatement:r.requiresStatement,titleArg:!0,kind:"block",childEnvironments:n}}const Gi=[...Wi,...Object.entries(Xi).map(([t,r])=>Vi(t,r))];(()=>{const t=new Map;for(const r of Gi){t.set(r.name,r);for(const n of r.aliases)t.set(n,r)}return t})();function vt(t,r){return t.map(n=>({name:n,signature:r,mode:"text"}))}const Hi=vt(["latex","Latex","LaTeX","latexe","today","tex","eg","ie","etc","XeTeX","XeLaTeX","xelatex","LuaTeX","luatex","PreTeXt","pretext","Pretext","PreFigure","webwork","WeBWorK","AD","ad","BC","bc","AM","am","PM","pm","nb","ps","vs","viz","etal","circa","ca","timeofday","mdash","ndash","nbsp","P","S","copyright","registered","trademark","degree","textdegree","dagger","ddagger","ldots","dots","textpm","textregistered","texttrademark","textsection","textpilcrow","textperiodcentered","texttildelow","textperthousand","centering","noindent"],""),Yi=vt(["emph","textrm","textsf","texttt","textsl","textit","textbf","underline","mbox","phantom","vspace","hspace","textsize","makebox","term","code","lstinline","fn","footnote","q","sq","enquote","enquotestar","abbr","ac","acro","init","foreign","booktitle","pubtitle","articletitle","xmltag","xmlattr","taxon","kbd","icon","sout","insert","stale","ref","eqref","cref","Cref","cite","index","url","appendix","caption"],"m"),Pr=[{name:"href",signature:"m m",mode:"text",snippet:"href{${1:url}}{$2}",documentation:"External link. `\\href{url}{text}` → `<url>`."},{name:"hyperref",signature:"o m",mode:"text",snippet:"hyperref[${1:label}]{$2}",documentation:"Internal link to a `\\label`. `\\hyperref[label]{text}`."},{name:"textcolor",signature:"m m",mode:"text",documentation:"No PreTeXt equivalent; converted to `<em>`."},{name:"includegraphics",signature:"o m",mode:"text",snippet:"includegraphics{${1:source}}",documentation:"Image. Converts to `<image>` with a `source` attribute."},{name:"alert",signature:"m",mode:"text",snippet:"alert{$1}",documentation:"Text that warns or demands attention. Converts to `<alert>`."},{name:"citep",signature:"o m",mode:"text",snippet:"citep{${1:key}}",documentation:"Parenthetical citation (natbib). Converts to `<xref>`, the same as `\\cite`."},{name:"foreignlanguage",signature:"m m",mode:"text",snippet:"foreignlanguage{${1:french}}{$2}",documentation:"Text in another language. `\\foreignlanguage{lang}{text}` → `<foreign>`."},{name:"term",signature:"m",mode:"text",snippet:"term{$1}",documentation:"A defined term. Converts to `<term>`."},{name:"fillin",signature:"",mode:"text",documentation:"A blank to fill in. Converts to `<fillin>`."},{name:"plus",signature:"o m m",mode:"text",snippet:"plus{${1:chapter}}{${2:ref}}",documentation:'PreTeXt Plus modular include. `\\plus{type}{ref}` → `<plus:type ref="ref"/>`, pulling in the division or asset stored under `ref`. An optional `\\plus[width=50,margin=auto]{image}{ref}` argument becomes attributes on the element.'}],Ji=vt(["preface","biography","dedication","glossary","handout","exercises","solutions","worksheet","paragraphs","readingquestions"],"s o m").map(t=>({...t,snippet:`${t.name}{$1}`,documentation:`PreTeXt division. \\${t.name}{title} opens a <${t.name==="readingquestions"?"reading-questions":t.name}> that runs to the next division of the same or higher level.`})),Ki=vt(["book","article","slideshow","part","chapter","section","subsection","subsubsection","paragraph","subparagraph","bibliography","references"],"m"),Qi=[...vt(["email","keywords"],"m"),...vt(["subjclass"],"o m"),...vt(["title","author","date","input","include","subtitle"],"m"),...vt(["documentclass","usepackage"],"o m"),...vt(["newcommand","renewcommand","providecommand"],"m m"),...vt(["maketitle","tableofcontents","frontmatter","mainmatter","backmatter","item","par","newline"],"")],ta=vt(["bfseries","itshape","rmfamily","scshape","sffamily","slshape","ttfamily","normalfont","color","Huge","huge","LARGE","Large","large","normalsize","small","footnotesize","scriptsize","tiny"],""),ea=vt(["question","subpart","subsubpart"],""),na=new Set(Pr.map(t=>t.name)),ra=[...Pr,...[...Hi,...Yi,...Ji,...Ki,...Qi,...ta,...ea].filter(t=>!na.has(t.name)).filter((t,r,n)=>n.findIndex(i=>i.name===t.name)===r)],ia=new Map(ra.map(t=>[t.name,t])),jr=new Set(["code","program","console","sage","verbatim","lstlisting","minted"]);function Ie(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function aa(t,r,n){return t.startsWith(n,r)?r+n.length:-1}function sa(t,r){if(t[r]!=="{")return null;const n=t.indexOf("}",r+1);return n===-1?null:{content:t.slice(r+1,n),end:n+1}}function Yt(t,r,n){const i=aa(t,r,"\\"+n);if(i===-1||Ie(t[i]??""))return null;let e=i;for(;t[e]===" "||t[e]===" ";)e++;const a=sa(t,e);return a?{group:a.content,groupStart:e+1,end:a.end}:null}function oa(t){const r=[],n=[],i=[],e=[],a=[],s=t.length;let o=0,c=null,l=0,f=null;const p=g=>({isMath:Ui.has(g),isVerbatim:jr.has(g)});for(;o<s;){if(f!==null){const d=Yt(t,o,"end");d&&d.group===f?(e.push({name:d.group,type:"end",start:o,end:d.end,...p(d.group)}),f=null,o=d.end):o++;continue}const g=t[o];if(g==="%"){const d=t.indexOf(`
|
|
18
|
+
`,o),w=d===-1?s:d;i.push({start:o,end:w}),o=w;continue}if(g==="\\"){if(t[o+1]==="("){c===null&&(c="\\)",l=o),o+=2;continue}if(t[o+1]==="["){c===null&&(c="\\]",l=o),o+=2;continue}if(t[o+1]===")"||t[o+1]==="]"){const v="\\"+t[o+1];c===v&&(n.push({start:l,end:o+2}),c=null),o+=2;continue}if(t[o+1]==="\\"){o+=2;continue}const d=Yt(t,o,"begin");if(d){const v=p(d.group);e.push({name:d.group,type:"begin",start:o,end:d.end,...v}),v.isVerbatim&&(f=d.group),o=d.end;continue}const w=Yt(t,o,"end");if(w){e.push({name:w.group,type:"end",start:o,end:w.end,...p(w.group)}),o=w.end;continue}const h=Yt(t,o,"label");if(h){r.push({name:h.group,offset:h.groupStart}),o=h.end;continue}if(Ie(t[o+1]??"")){let v=o+1;for(;v<s&&Ie(t[v]);)v++;a.push({name:t.slice(o+1,v),start:o,end:v}),o=v;continue}o+=2;continue}if(g==="$"){const d=t[o+1]==="$",w=d?"$$":"$",h=d?2:1;c===null?(c=w,l=o):c===w&&(n.push({start:l,end:o+h}),c=null),o+=h;continue}o++}return c!==null&&n.push({start:l,end:s}),{labels:r,mathRegions:n,commentRegions:i,environments:e,macros:a}}function Te(t,r){const n=Math.max(0,Math.min(r,t.length));let i=0,e=0;for(let a=0;a<n;a++)t[a]===`
|
|
19
|
+
`&&(i++,e=a+1);return{line:i,character:n-e}}function ne(t,r,n){return{start:Te(t,r),end:Te(t,n)}}var wn;(function(t){function r(n){return typeof n=="string"}t.is=r})(wn||(wn={}));var Re;(function(t){function r(n){return typeof n=="string"}t.is=r})(Re||(Re={}));var _n;(function(t){t.MIN_VALUE=-2147483648,t.MAX_VALUE=2147483647;function r(n){return typeof n=="number"&&t.MIN_VALUE<=n&&n<=t.MAX_VALUE}t.is=r})(_n||(_n={}));var re;(function(t){t.MIN_VALUE=0,t.MAX_VALUE=2147483647;function r(n){return typeof n=="number"&&t.MIN_VALUE<=n&&n<=t.MAX_VALUE}t.is=r})(re||(re={}));var wt;(function(t){function r(i,e){return i===Number.MAX_VALUE&&(i=re.MAX_VALUE),e===Number.MAX_VALUE&&(e=re.MAX_VALUE),{line:i,character:e}}t.create=r;function n(i){let e=i;return T.objectLiteral(e)&&T.uinteger(e.line)&&T.uinteger(e.character)}t.is=n})(wt||(wt={}));var ft;(function(t){function r(i,e,a,s){if(T.uinteger(i)&&T.uinteger(e)&&T.uinteger(a)&&T.uinteger(s))return{start:wt.create(i,e),end:wt.create(a,s)};if(wt.is(i)&&wt.is(e))return{start:i,end:e};throw new Error(`Range#create called with invalid arguments[${i}, ${e}, ${a}, ${s}]`)}t.create=r;function n(i){let e=i;return T.objectLiteral(e)&&wt.is(e.start)&&wt.is(e.end)}t.is=n})(ft||(ft={}));var ie;(function(t){function r(i,e){return{uri:i,range:e}}t.create=r;function n(i){let e=i;return T.objectLiteral(e)&&ft.is(e.range)&&(T.string(e.uri)||T.undefined(e.uri))}t.is=n})(ie||(ie={}));var yn;(function(t){function r(i,e,a,s){return{targetUri:i,targetRange:e,targetSelectionRange:a,originSelectionRange:s}}t.create=r;function n(i){let e=i;return T.objectLiteral(e)&&ft.is(e.targetRange)&&T.string(e.targetUri)&&ft.is(e.targetSelectionRange)&&(ft.is(e.originSelectionRange)||T.undefined(e.originSelectionRange))}t.is=n})(yn||(yn={}));var Ce;(function(t){function r(i,e,a,s){return{red:i,green:e,blue:a,alpha:s}}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&T.numberRange(e.red,0,1)&&T.numberRange(e.green,0,1)&&T.numberRange(e.blue,0,1)&&T.numberRange(e.alpha,0,1)}t.is=n})(Ce||(Ce={}));var xn;(function(t){function r(i,e){return{range:i,color:e}}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&ft.is(e.range)&&Ce.is(e.color)}t.is=n})(xn||(xn={}));var kn;(function(t){function r(i,e,a){return{label:i,textEdit:e,additionalTextEdits:a}}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&T.string(e.label)&&(T.undefined(e.textEdit)||Ct.is(e))&&(T.undefined(e.additionalTextEdits)||T.typedArray(e.additionalTextEdits,Ct.is))}t.is=n})(kn||(kn={}));var Sn;(function(t){t.Comment="comment",t.Imports="imports",t.Region="region"})(Sn||(Sn={}));var En;(function(t){function r(i,e,a,s,o,c){const l={startLine:i,endLine:e};return T.defined(a)&&(l.startCharacter=a),T.defined(s)&&(l.endCharacter=s),T.defined(o)&&(l.kind=o),T.defined(c)&&(l.collapsedText=c),l}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&T.uinteger(e.startLine)&&T.uinteger(e.startLine)&&(T.undefined(e.startCharacter)||T.uinteger(e.startCharacter))&&(T.undefined(e.endCharacter)||T.uinteger(e.endCharacter))&&(T.undefined(e.kind)||T.string(e.kind))}t.is=n})(En||(En={}));var Oe;(function(t){function r(i,e){return{location:i,message:e}}t.create=r;function n(i){let e=i;return T.defined(e)&&ie.is(e.location)&&T.string(e.message)}t.is=n})(Oe||(Oe={}));var Nt;(function(t){t.Error=1,t.Warning=2,t.Information=3,t.Hint=4})(Nt||(Nt={}));var An;(function(t){t.Unnecessary=1,t.Deprecated=2})(An||(An={}));var In;(function(t){function r(n){const i=n;return T.objectLiteral(i)&&T.string(i.href)}t.is=r})(In||(In={}));var ae;(function(t){function r(i,e,a,s,o,c){let l={range:i,message:e};return T.defined(a)&&(l.severity=a),T.defined(s)&&(l.code=s),T.defined(o)&&(l.source=o),T.defined(c)&&(l.relatedInformation=c),l}t.create=r;function n(i){var e;let a=i;return T.defined(a)&&ft.is(a.range)&&T.string(a.message)&&(T.number(a.severity)||T.undefined(a.severity))&&(T.integer(a.code)||T.string(a.code)||T.undefined(a.code))&&(T.undefined(a.codeDescription)||T.string((e=a.codeDescription)===null||e===void 0?void 0:e.href))&&(T.string(a.source)||T.undefined(a.source))&&(T.undefined(a.relatedInformation)||T.typedArray(a.relatedInformation,Oe.is))}t.is=n})(ae||(ae={}));var Rt;(function(t){function r(i,e,...a){let s={title:i,command:e};return T.defined(a)&&a.length>0&&(s.arguments=a),s}t.create=r;function n(i){let e=i;return T.defined(e)&&T.string(e.title)&&T.string(e.command)}t.is=n})(Rt||(Rt={}));var Ct;(function(t){function r(a,s){return{range:a,newText:s}}t.replace=r;function n(a,s){return{range:{start:a,end:a},newText:s}}t.insert=n;function i(a){return{range:a,newText:""}}t.del=i;function e(a){const s=a;return T.objectLiteral(s)&&T.string(s.newText)&&ft.is(s.range)}t.is=e})(Ct||(Ct={}));var ze;(function(t){function r(i,e,a){const s={label:i};return e!==void 0&&(s.needsConfirmation=e),a!==void 0&&(s.description=a),s}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&T.string(e.label)&&(T.boolean(e.needsConfirmation)||e.needsConfirmation===void 0)&&(T.string(e.description)||e.description===void 0)}t.is=n})(ze||(ze={}));var Ot;(function(t){function r(n){const i=n;return T.string(i)}t.is=r})(Ot||(Ot={}));var Tn;(function(t){function r(a,s,o){return{range:a,newText:s,annotationId:o}}t.replace=r;function n(a,s,o){return{range:{start:a,end:a},newText:s,annotationId:o}}t.insert=n;function i(a,s){return{range:a,newText:"",annotationId:s}}t.del=i;function e(a){const s=a;return Ct.is(s)&&(ze.is(s.annotationId)||Ot.is(s.annotationId))}t.is=e})(Tn||(Tn={}));var Le;(function(t){function r(i,e){return{textDocument:i,edits:e}}t.create=r;function n(i){let e=i;return T.defined(e)&&Fe.is(e.textDocument)&&Array.isArray(e.edits)}t.is=n})(Le||(Le={}));var $e;(function(t){function r(i,e,a){let s={kind:"create",uri:i};return e!==void 0&&(e.overwrite!==void 0||e.ignoreIfExists!==void 0)&&(s.options=e),a!==void 0&&(s.annotationId=a),s}t.create=r;function n(i){let e=i;return e&&e.kind==="create"&&T.string(e.uri)&&(e.options===void 0||(e.options.overwrite===void 0||T.boolean(e.options.overwrite))&&(e.options.ignoreIfExists===void 0||T.boolean(e.options.ignoreIfExists)))&&(e.annotationId===void 0||Ot.is(e.annotationId))}t.is=n})($e||($e={}));var De;(function(t){function r(i,e,a,s){let o={kind:"rename",oldUri:i,newUri:e};return a!==void 0&&(a.overwrite!==void 0||a.ignoreIfExists!==void 0)&&(o.options=a),s!==void 0&&(o.annotationId=s),o}t.create=r;function n(i){let e=i;return e&&e.kind==="rename"&&T.string(e.oldUri)&&T.string(e.newUri)&&(e.options===void 0||(e.options.overwrite===void 0||T.boolean(e.options.overwrite))&&(e.options.ignoreIfExists===void 0||T.boolean(e.options.ignoreIfExists)))&&(e.annotationId===void 0||Ot.is(e.annotationId))}t.is=n})(De||(De={}));var Pe;(function(t){function r(i,e,a){let s={kind:"delete",uri:i};return e!==void 0&&(e.recursive!==void 0||e.ignoreIfNotExists!==void 0)&&(s.options=e),a!==void 0&&(s.annotationId=a),s}t.create=r;function n(i){let e=i;return e&&e.kind==="delete"&&T.string(e.uri)&&(e.options===void 0||(e.options.recursive===void 0||T.boolean(e.options.recursive))&&(e.options.ignoreIfNotExists===void 0||T.boolean(e.options.ignoreIfNotExists)))&&(e.annotationId===void 0||Ot.is(e.annotationId))}t.is=n})(Pe||(Pe={}));var je;(function(t){function r(n){let i=n;return i&&(i.changes!==void 0||i.documentChanges!==void 0)&&(i.documentChanges===void 0||i.documentChanges.every(e=>T.string(e.kind)?$e.is(e)||De.is(e)||Pe.is(e):Le.is(e)))}t.is=r})(je||(je={}));var Rn;(function(t){function r(i){return{uri:i}}t.create=r;function n(i){let e=i;return T.defined(e)&&T.string(e.uri)}t.is=n})(Rn||(Rn={}));var Cn;(function(t){function r(i,e){return{uri:i,version:e}}t.create=r;function n(i){let e=i;return T.defined(e)&&T.string(e.uri)&&T.integer(e.version)}t.is=n})(Cn||(Cn={}));var Fe;(function(t){function r(i,e){return{uri:i,version:e}}t.create=r;function n(i){let e=i;return T.defined(e)&&T.string(e.uri)&&(e.version===null||T.integer(e.version))}t.is=n})(Fe||(Fe={}));var On;(function(t){function r(i,e,a,s){return{uri:i,languageId:e,version:a,text:s}}t.create=r;function n(i){let e=i;return T.defined(e)&&T.string(e.uri)&&T.string(e.languageId)&&T.integer(e.version)&&T.string(e.text)}t.is=n})(On||(On={}));var qe;(function(t){t.PlainText="plaintext",t.Markdown="markdown";function r(n){const i=n;return i===t.PlainText||i===t.Markdown}t.is=r})(qe||(qe={}));var Ut;(function(t){function r(n){const i=n;return T.objectLiteral(n)&&qe.is(i.kind)&&T.string(i.value)}t.is=r})(Ut||(Ut={}));var zn;(function(t){t.Text=1,t.Method=2,t.Function=3,t.Constructor=4,t.Field=5,t.Variable=6,t.Class=7,t.Interface=8,t.Module=9,t.Property=10,t.Unit=11,t.Value=12,t.Enum=13,t.Keyword=14,t.Snippet=15,t.Color=16,t.File=17,t.Reference=18,t.Folder=19,t.EnumMember=20,t.Constant=21,t.Struct=22,t.Event=23,t.Operator=24,t.TypeParameter=25})(zn||(zn={}));var Ln;(function(t){t.PlainText=1,t.Snippet=2})(Ln||(Ln={}));var $n;(function(t){t.Deprecated=1})($n||($n={}));var Dn;(function(t){function r(i,e,a){return{newText:i,insert:e,replace:a}}t.create=r;function n(i){const e=i;return e&&T.string(e.newText)&&ft.is(e.insert)&&ft.is(e.replace)}t.is=n})(Dn||(Dn={}));var Pn;(function(t){t.asIs=1,t.adjustIndentation=2})(Pn||(Pn={}));var jn;(function(t){function r(n){const i=n;return i&&(T.string(i.detail)||i.detail===void 0)&&(T.string(i.description)||i.description===void 0)}t.is=r})(jn||(jn={}));var Fn;(function(t){function r(n){return{label:n}}t.create=r})(Fn||(Fn={}));var qn;(function(t){function r(n,i){return{items:n||[],isIncomplete:!!i}}t.create=r})(qn||(qn={}));var se;(function(t){function r(i){return i.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}t.fromPlainText=r;function n(i){const e=i;return T.string(e)||T.objectLiteral(e)&&T.string(e.language)&&T.string(e.value)}t.is=n})(se||(se={}));var Bn;(function(t){function r(n){let i=n;return!!i&&T.objectLiteral(i)&&(Ut.is(i.contents)||se.is(i.contents)||T.typedArray(i.contents,se.is))&&(n.range===void 0||ft.is(n.range))}t.is=r})(Bn||(Bn={}));var Nn;(function(t){function r(n,i){return i?{label:n,documentation:i}:{label:n}}t.create=r})(Nn||(Nn={}));var Mn;(function(t){function r(n,i,...e){let a={label:n};return T.defined(i)&&(a.documentation=i),T.defined(e)?a.parameters=e:a.parameters=[],a}t.create=r})(Mn||(Mn={}));var Un;(function(t){t.Text=1,t.Read=2,t.Write=3})(Un||(Un={}));var Wn;(function(t){function r(n,i){let e={range:n};return T.number(i)&&(e.kind=i),e}t.create=r})(Wn||(Wn={}));var Xn;(function(t){t.File=1,t.Module=2,t.Namespace=3,t.Package=4,t.Class=5,t.Method=6,t.Property=7,t.Field=8,t.Constructor=9,t.Enum=10,t.Interface=11,t.Function=12,t.Variable=13,t.Constant=14,t.String=15,t.Number=16,t.Boolean=17,t.Array=18,t.Object=19,t.Key=20,t.Null=21,t.EnumMember=22,t.Struct=23,t.Event=24,t.Operator=25,t.TypeParameter=26})(Xn||(Xn={}));var Zn;(function(t){t.Deprecated=1})(Zn||(Zn={}));var Vn;(function(t){function r(n,i,e,a,s){let o={name:n,kind:i,location:{uri:a,range:e}};return s&&(o.containerName=s),o}t.create=r})(Vn||(Vn={}));var Gn;(function(t){function r(n,i,e,a){return a!==void 0?{name:n,kind:i,location:{uri:e,range:a}}:{name:n,kind:i,location:{uri:e}}}t.create=r})(Gn||(Gn={}));var Hn;(function(t){function r(i,e,a,s,o,c){let l={name:i,detail:e,kind:a,range:s,selectionRange:o};return c!==void 0&&(l.children=c),l}t.create=r;function n(i){let e=i;return e&&T.string(e.name)&&T.number(e.kind)&&ft.is(e.range)&&ft.is(e.selectionRange)&&(e.detail===void 0||T.string(e.detail))&&(e.deprecated===void 0||T.boolean(e.deprecated))&&(e.children===void 0||Array.isArray(e.children))&&(e.tags===void 0||Array.isArray(e.tags))}t.is=n})(Hn||(Hn={}));var zt;(function(t){t.Empty="",t.QuickFix="quickfix",t.Refactor="refactor",t.RefactorExtract="refactor.extract",t.RefactorInline="refactor.inline",t.RefactorRewrite="refactor.rewrite",t.Source="source",t.SourceOrganizeImports="source.organizeImports",t.SourceFixAll="source.fixAll"})(zt||(zt={}));var oe;(function(t){t.Invoked=1,t.Automatic=2})(oe||(oe={}));var Yn;(function(t){function r(i,e,a){let s={diagnostics:i};return e!=null&&(s.only=e),a!=null&&(s.triggerKind=a),s}t.create=r;function n(i){let e=i;return T.defined(e)&&T.typedArray(e.diagnostics,ae.is)&&(e.only===void 0||T.typedArray(e.only,T.string))&&(e.triggerKind===void 0||e.triggerKind===oe.Invoked||e.triggerKind===oe.Automatic)}t.is=n})(Yn||(Yn={}));var Jn;(function(t){function r(i,e,a){let s={title:i},o=!0;return typeof e=="string"?(o=!1,s.kind=e):Rt.is(e)?s.command=e:s.edit=e,o&&a!==void 0&&(s.kind=a),s}t.create=r;function n(i){let e=i;return e&&T.string(e.title)&&(e.diagnostics===void 0||T.typedArray(e.diagnostics,ae.is))&&(e.kind===void 0||T.string(e.kind))&&(e.edit!==void 0||e.command!==void 0)&&(e.command===void 0||Rt.is(e.command))&&(e.isPreferred===void 0||T.boolean(e.isPreferred))&&(e.edit===void 0||je.is(e.edit))}t.is=n})(Jn||(Jn={}));var Kn;(function(t){function r(i,e){let a={range:i};return T.defined(e)&&(a.data=e),a}t.create=r;function n(i){let e=i;return T.defined(e)&&ft.is(e.range)&&(T.undefined(e.command)||Rt.is(e.command))}t.is=n})(Kn||(Kn={}));var Qn;(function(t){function r(i,e){return{tabSize:i,insertSpaces:e}}t.create=r;function n(i){let e=i;return T.defined(e)&&T.uinteger(e.tabSize)&&T.boolean(e.insertSpaces)}t.is=n})(Qn||(Qn={}));var tr;(function(t){function r(i,e,a){return{range:i,target:e,data:a}}t.create=r;function n(i){let e=i;return T.defined(e)&&ft.is(e.range)&&(T.undefined(e.target)||T.string(e.target))}t.is=n})(tr||(tr={}));var er;(function(t){function r(i,e){return{range:i,parent:e}}t.create=r;function n(i){let e=i;return T.objectLiteral(e)&&ft.is(e.range)&&(e.parent===void 0||t.is(e.parent))}t.is=n})(er||(er={}));var nr;(function(t){t.namespace="namespace",t.type="type",t.class="class",t.enum="enum",t.interface="interface",t.struct="struct",t.typeParameter="typeParameter",t.parameter="parameter",t.variable="variable",t.property="property",t.enumMember="enumMember",t.event="event",t.function="function",t.method="method",t.macro="macro",t.keyword="keyword",t.modifier="modifier",t.comment="comment",t.string="string",t.number="number",t.regexp="regexp",t.operator="operator",t.decorator="decorator"})(nr||(nr={}));var rr;(function(t){t.declaration="declaration",t.definition="definition",t.readonly="readonly",t.static="static",t.deprecated="deprecated",t.abstract="abstract",t.async="async",t.modification="modification",t.documentation="documentation",t.defaultLibrary="defaultLibrary"})(rr||(rr={}));var ir;(function(t){function r(n){const i=n;return T.objectLiteral(i)&&(i.resultId===void 0||typeof i.resultId=="string")&&Array.isArray(i.data)&&(i.data.length===0||typeof i.data[0]=="number")}t.is=r})(ir||(ir={}));var ar;(function(t){function r(i,e){return{range:i,text:e}}t.create=r;function n(i){const e=i;return e!=null&&ft.is(e.range)&&T.string(e.text)}t.is=n})(ar||(ar={}));var sr;(function(t){function r(i,e,a){return{range:i,variableName:e,caseSensitiveLookup:a}}t.create=r;function n(i){const e=i;return e!=null&&ft.is(e.range)&&T.boolean(e.caseSensitiveLookup)&&(T.string(e.variableName)||e.variableName===void 0)}t.is=n})(sr||(sr={}));var or;(function(t){function r(i,e){return{range:i,expression:e}}t.create=r;function n(i){const e=i;return e!=null&&ft.is(e.range)&&(T.string(e.expression)||e.expression===void 0)}t.is=n})(or||(or={}));var cr;(function(t){function r(i,e){return{frameId:i,stoppedLocation:e}}t.create=r;function n(i){const e=i;return T.defined(e)&&ft.is(i.stoppedLocation)}t.is=n})(cr||(cr={}));var Be;(function(t){t.Type=1,t.Parameter=2;function r(n){return n===1||n===2}t.is=r})(Be||(Be={}));var Ne;(function(t){function r(i){return{value:i}}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&(e.tooltip===void 0||T.string(e.tooltip)||Ut.is(e.tooltip))&&(e.location===void 0||ie.is(e.location))&&(e.command===void 0||Rt.is(e.command))}t.is=n})(Ne||(Ne={}));var lr;(function(t){function r(i,e,a){const s={position:i,label:e};return a!==void 0&&(s.kind=a),s}t.create=r;function n(i){const e=i;return T.objectLiteral(e)&&wt.is(e.position)&&(T.string(e.label)||T.typedArray(e.label,Ne.is))&&(e.kind===void 0||Be.is(e.kind))&&e.textEdits===void 0||T.typedArray(e.textEdits,Ct.is)&&(e.tooltip===void 0||T.string(e.tooltip)||Ut.is(e.tooltip))&&(e.paddingLeft===void 0||T.boolean(e.paddingLeft))&&(e.paddingRight===void 0||T.boolean(e.paddingRight))}t.is=n})(lr||(lr={}));var ur;(function(t){function r(n){return{kind:"snippet",value:n}}t.createSnippet=r})(ur||(ur={}));var dr;(function(t){function r(n,i,e,a){return{insertText:n,filterText:i,range:e,command:a}}t.create=r})(dr||(dr={}));var fr;(function(t){function r(n){return{items:n}}t.create=r})(fr||(fr={}));var hr;(function(t){t.Invoked=0,t.Automatic=1})(hr||(hr={}));var pr;(function(t){function r(n,i){return{range:n,text:i}}t.create=r})(pr||(pr={}));var mr;(function(t){function r(n,i){return{triggerKind:n,selectedCompletionInfo:i}}t.create=r})(mr||(mr={}));var gr;(function(t){function r(n){const i=n;return T.objectLiteral(i)&&Re.is(i.uri)&&T.string(i.name)}t.is=r})(gr||(gr={}));var br;(function(t){function r(a,s,o,c){return new ca(a,s,o,c)}t.create=r;function n(a){let s=a;return!!(T.defined(s)&&T.string(s.uri)&&(T.undefined(s.languageId)||T.string(s.languageId))&&T.uinteger(s.lineCount)&&T.func(s.getText)&&T.func(s.positionAt)&&T.func(s.offsetAt))}t.is=n;function i(a,s){let o=a.getText(),c=e(s,(f,p)=>{let g=f.range.start.line-p.range.start.line;return g===0?f.range.start.character-p.range.start.character:g}),l=o.length;for(let f=c.length-1;f>=0;f--){let p=c[f],g=a.offsetAt(p.range.start),d=a.offsetAt(p.range.end);if(d<=l)o=o.substring(0,g)+p.newText+o.substring(d,o.length);else throw new Error("Overlapping edit");l=g}return o}t.applyEdits=i;function e(a,s){if(a.length<=1)return a;const o=a.length/2|0,c=a.slice(0,o),l=a.slice(o);e(c,s),e(l,s);let f=0,p=0,g=0;for(;f<c.length&&p<l.length;)s(c[f],l[p])<=0?a[g++]=c[f++]:a[g++]=l[p++];for(;f<c.length;)a[g++]=c[f++];for(;p<l.length;)a[g++]=l[p++];return a}})(br||(br={}));class ca{constructor(r,n,i,e){this._uri=r,this._languageId=n,this._version=i,this._content=e,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(r){if(r){let n=this.offsetAt(r.start),i=this.offsetAt(r.end);return this._content.substring(n,i)}return this._content}update(r,n){this._content=r.text,this._version=n,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let r=[],n=this._content,i=!0;for(let e=0;e<n.length;e++){i&&(r.push(e),i=!1);let a=n.charAt(e);i=a==="\r"||a===`
|
|
20
|
+
`,a==="\r"&&e+1<n.length&&n.charAt(e+1)===`
|
|
21
|
+
`&&e++}i&&n.length>0&&r.push(n.length),this._lineOffsets=r}return this._lineOffsets}positionAt(r){r=Math.max(Math.min(r,this._content.length),0);let n=this.getLineOffsets(),i=0,e=n.length;if(e===0)return wt.create(0,r);for(;i<e;){let s=Math.floor((i+e)/2);n[s]>r?e=s:i=s+1}let a=i-1;return wt.create(a,r-n[a])}offsetAt(r){let n=this.getLineOffsets();if(r.line>=n.length)return this._content.length;if(r.line<0)return 0;let i=n[r.line],e=r.line+1<n.length?n[r.line+1]:this._content.length;return Math.max(Math.min(i+r.character,e),i)}get lineCount(){return this.getLineOffsets().length}}var T;(function(t){const r=Object.prototype.toString;function n(d){return typeof d<"u"}t.defined=n;function i(d){return typeof d>"u"}t.undefined=i;function e(d){return d===!0||d===!1}t.boolean=e;function a(d){return r.call(d)==="[object String]"}t.string=a;function s(d){return r.call(d)==="[object Number]"}t.number=s;function o(d,w,h){return r.call(d)==="[object Number]"&&w<=d&&d<=h}t.numberRange=o;function c(d){return r.call(d)==="[object Number]"&&-2147483648<=d&&d<=2147483647}t.integer=c;function l(d){return r.call(d)==="[object Number]"&&0<=d&&d<=2147483647}t.uinteger=l;function f(d){return r.call(d)==="[object Function]"}t.func=f;function p(d){return d!==null&&typeof d=="object"}t.objectLiteral=p;function g(d,w){return Array.isArray(d)&&d.every(w)}t.typedArray=g})(T||(T={}));const la={unused:"LaTeX-specific markup",presentation:"Presentation does not go into PreTeXt source",accessibility:"Accessibility issue",mistake:"This feature should not have been added to LaTeX",archaic:"plain TeX that should not be in LaTeX source"},ua={textbf:[{macro:"alert",meaning:"something the reader must not miss"},{macro:"term",meaning:"a term being defined"},{macro:"emph",meaning:"ordinary emphasis"}],textit:[{macro:"emph",meaning:"ordinary emphasis"},{macro:"term",meaning:"a term being defined"},{macro:"foreign",meaning:"a word from another language"},{macro:"alert",meaning:"something the reader must not miss"}],texttt:[{macro:"code",meaning:"code or a literal value"},{macro:"kbd",meaning:"a key the reader presses"}],textsc:[{macro:"init",meaning:"an initialism read letter by letter"},{macro:"acro",meaning:"an acronym read as a word"},{macro:"term",meaning:"a term being defined"}],textrm:[{macro:"emph",meaning:"ordinary emphasis"}]};function bt(t,r){const{kind:n,category:i,scope:e="anywhere",action:a="delete",severity:s="info",form:o="bare",message:c,reportMatch:l,idPrefix:f=""}=r;return t.map(p=>({id:`${f}${p}`,kind:n,category:i,scope:e,match:{type:"macro",name:p,form:o},action:a,severity:s,message:c,reportMatch:l}))}const da=[{id:"paren-ref",label:"(\\ref{...})",replacementLabel:"\\eqref{...}",kind:"presentation",category:"math_refs",scope:"anywhere",match:{type:"regex",pattern:/\(\\ref\{([^{}]+)\}\)/},action:"replace",replacement:"\\eqref{$1}",severity:"info",message:"A parenthesized \\ref is an equation reference; \\eqref carries that meaning."},{id:"vfil-chain",label:"vfil",replacementLabel:"\\vspace{1in}",kind:"presentation",category:"spacing_vertical",scope:"anywhere",match:{type:"regex",pattern:/\\vfill?\b(\s*\\vfill?\b)*/},action:"replace",replacement:"\\vspace{1in}",severity:"info",message:"Vertical fill is presentational; PreTeXt handles page layout."},{id:"underline-blank",label:"\\underline{}",replacementLabel:"\\fillin",kind:"presentation",category:"blanks",scope:"anywhere",match:{type:"regex",pattern:/\\underline\{\s*\}/},action:"replace",replacement:"\\fillin",severity:"info",message:"An empty \\underline{} is a common hack for a fill-in-the-blank; \\fillin is the semantic PreTeXt equivalent."},{id:"vskip",label:"vskip",replacementLabel:"\\vspace{...}",kind:"presentation",category:"spacing_vertical",scope:"anywhere",match:{type:"regex",pattern:/\\vskip\*? *([0-9]+|-) *([a-zA-Z]+).*/},action:"replace",replacement:"\\vspace{$1$2}",severity:"info"},{id:"vspace-star",label:"vspace",replacementLabel:"\\vspace{...}",kind:"presentation",category:"spacing_vertical",scope:"anywhere",match:{type:"regex",pattern:/\\vspace\*? *\{ *([0-9]+|-) *([a-zA-Z]+)[^{}]*?\}/},action:"replace",replacement:"\\vspace{$1$2}",severity:"info"}],fa=[{from:"rm",to:"textrm"},{from:"em",to:"emph"},{from:"it",to:"textit"},{from:"itshape",to:"textit"},{from:"bf",to:"textbf"},{from:"bfseries",to:"textbf"},{from:"sf",to:"textsf"},{from:"sffamily",to:"textss"},{from:"textsl",to:"testsl"}],ha=fa.map(({from:t,to:r})=>({id:`tex-font-${t}`,label:t,replacementLabel:r,kind:"presentation",category:"tex_fonts",scope:"anywhere",match:{type:"regex",pattern:new RegExp(`\\{ *\\\\${t}\\b *`)},action:"replace",replacement:`\\${r}{`,severity:"info",message:`{\\${t} …} is a plain-TeX font directive; \\${r}{…} is its LaTeX form.`})),pa=[...bt(["if","fi","iffalse","then","else","loop","repeat"],{kind:"unused",category:"conditionals"}),...bt(["tiny","scriptsize","footnotesize","small","normalsize","large","Large","LARGE","huge","Huge","normalfont"],{kind:"presentation",category:"font_size"}),...bt(["smallskip","medskip","bigskip","vfil","vfill"],{kind:"presentation",category:"spacing_vertical"}),...bt(["centerline","centering","noindent","par","linebreak"],{kind:"presentation",category:"archaic_tex"}),...bt(["ensuremath"],{kind:"mistake",category:"nonstructural"}),...bt(["relax","makeatletter","makeatother","csname","endcsname","shipout","noexpand","expandafter","clearpage"],{kind:"archaic",category:"low_level_tex"}),...bt(["newwrite","newread","immediate","write","write18","read","readline","readfile","openin","openout","jobname"],{kind:"archaic",category:"file_manipulation"}),...bt(["renewcommand"],{kind:"accessibility",category:"consistency",form:"line",severity:"warning",reportMatch:!0,message:"Redefining an existing command changes meaning globally; PreTeXt has no equivalent."}),...bt(["def","let","edef","gdef","xdef","global","long"],{kind:"archaic",category:"use_newcommand_only",form:"line",severity:"warning",reportMatch:!0,message:"Use \\newcommand instead; plain-TeX definitions do not convert."}),{id:"hspace",kind:"presentation",category:"spacing_horizontal",scope:"anywhere",match:{type:"macro",name:"hspace",form:"args",arity:1},action:"delete",severity:"info",message:"Horizontal spacing is presentational."},{id:"date",kind:"other",category:"other",scope:"anywhere",match:{type:"macro",name:"date",form:"args",arity:1},action:"delete",severity:"info"},...[["color",1],["textcolor",1],["mathcolor",1],["definecolor",3]].map(([t,r])=>({id:t,kind:"accessibility",category:"colors",scope:"anywhere",match:{type:"macro",name:t,form:"args",arity:r},action:"delete",severity:"info",message:"Colour alone cannot carry meaning; use a PreTeXt element instead."})),...bt(["catcode","newtheorem","maketitle","setlength"],{kind:"archaic",category:"low_level_tex",form:"line"}),...bt(["theoremstyle","makeindex","allowdisplaybreaks","frontmatter","mainmatter","appendix","numberwithin","setcounter","tableofcontents","FloatBarrier"],{kind:"publisher",category:"zzzzz",form:"line",message:"this is a publisher choice in PreTeXt"}),...bt(["textrm","textit","textbf","textsc","texttt"],{kind:"presentation",category:"latex_fonts",scope:"body",action:"flag",severity:"warning"}).map(t=>({...t,alternatives:ua[t.id]})),...["center","minipage"].map(t=>({id:`env-${t}`,label:t,kind:"presentation",category:"nonstructural",scope:"body",match:{type:"environment",name:t},action:"delete",severity:"info"}))],Fr=[...da,...ha,...pa];function qr(t,r="auto"){const n={start:0,end:0};if(r==="preamble")return{preamble:{start:0,end:t.length},body:n,bibliography:null};const i=r==="body"?-1:t.indexOf("\\begin{document}"),e=i===-1?0:i+16,a=i===-1?n:{start:0,end:i},s=t.indexOf("\\begin{thebibliography}",e),o=s===-1?null:{start:s,end:t.length};return{preamble:a,body:{start:e,end:o?o.start:t.length},bibliography:o}}function ma(t){const r=oa(t),n=[];let i=null;for(const e of r.environments)jr.has(e.name)&&(e.type==="begin"?i===null&&(i=e.start):i!==null&&(n.push({start:i,end:e.end}),i=null));return i!==null&&n.push({start:i,end:t.length}),{math:r.mathRegions,comment:r.commentRegions,verbatim:n}}const ga=["comment","verbatim"];function ba(t,r,n){return t.some(i=>r<i.end&&n>i.start)}function vr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function va(t){const{match:r}=t;if(r.type==="regex")return new RegExp(r.pattern.source,r.pattern.flags.includes("g")?r.pattern.flags:r.pattern.flags+"g");if(r.type==="environment")return new RegExp(`\\\\(?:begin|end)\\{\\s*${vr(r.name)}\\}`,"g");const n=vr(r.name);if(r.form==="args"){let i=`\\\\${n}\\b\\*?`;for(let e=0;e<(r.arity??1);e+=1)i+="\\{[^{}]*\\}";return new RegExp(i,"g")}return r.form==="line"?new RegExp(`\\\\${n}\\b.*`,"g"):new RegExp(`\\\\${n}\\b`,"g")}function wa(t){if(t.label)return t.label;const{match:r}=t;return r.type==="macro"||r.type==="environment"?r.name:t.id}function _a(t,r){return t.replace(/\$(\d)/g,(n,i)=>r[Number(i)]??"")}function Tt(t,r={}){const{scope:n="auto",disable:i,only:e}=r,a=qr(t,n),s=ma(t),o=new Set(i??[]),c=e?new Set(e):null,l=[];return Fr.forEach((f,p)=>{if(o.has(f.id)||c&&!c.has(f.id))return;const d=(f.skipIn??ga).flatMap(v=>s[v]),w=va(f);let h;for(;(h=w.exec(t))!==null;){const v=h.index,b=v+h[0].length;if(h[0].length===0){w.lastIndex+=1;continue}if(!ya(f.scope,a,v)||ba(d,v,b))continue;const x=f.action==="flag"?void 0:f.action==="delete"?"":_a(f.replacement??"",h);x!==h[0]&&l.push({ruleId:f.id,action:f.action,severity:f.severity,kind:f.kind,category:f.category,macro:wa(f),start:v,end:b,matched:h[0],replacement:x,message:f.message,reportMatch:f.reportMatch,replacementLabel:f.replacementLabel,alternatives:f.alternatives,priority:p})}}),xa(l)}function ya(t,r,n){if(r.bibliography&&n>=r.bibliography.start)return!1;if(t==="anywhere")return!0;const i=t==="preamble"?r.preamble:r.body;return n>=i.start&&n<i.end}function xa(t){const r=t.filter(a=>a.replacement!==void 0).sort((a,s)=>a.start-s.start||s.end-s.start-(a.end-a.start)||a.priority-s.priority),n=[];let i=-1;for(const a of r)a.start<i||(n.push(a),i=a.end);const e=t.filter(a=>a.replacement===void 0&&!n.some(s=>a.start>=s.start&&a.end<=s.end));return[...n,...e].sort((a,s)=>a.start-s.start||a.priority-s.priority).map(({priority:a,...s})=>s)}function ka(t){return t!==void 0&&(t>="a"&&t<="z"||t>="A"&&t<="Z")}function wr(t,r,n,i){if(t[r]!==n)return null;let e=0;for(let a=r;a<t.length;a+=1){const s=t[a];if(s==="\\"){a+=1;continue}if(s===n)e+=1;else if(s===i&&(e-=1,e===0))return a+1}return null}function Sa(t,r){if(t[r]!=="\\")return null;let n=r+1;for(;ka(t[n]);)n+=1;if(n===r+1)return null;const i=t.slice(r+1,n),e=n,a=ia.get(i)?.signature??"m",s=[];let o=e;for(const c of a.split(/\s+/).filter(Boolean)){let l=o;for(;l<t.length&&/[ \t]/.test(t[l]);)l+=1;if(c==="s"){t[l]==="*"&&(o=l+1);continue}if(c==="o"){const p=wr(t,l,"[","]");p!==null&&(o=p);continue}const f=wr(t,l,"{","}");if(f===null)break;s.push({start:l+1,end:f-1}),o=f}return{name:i,start:r,nameEnd:e,end:o,mandatoryArguments:s}}function Ea(t,r){return r.mandatoryArguments.map(n=>t.slice(n.start,n.end)).join("")}function ke(t){return t.mandatoryArguments.length===0}function Br(t,r){const n=r.filter(s=>s.replacement!==void 0).sort((s,o)=>o.start-s.start),i=[];let e=t,a=Number.POSITIVE_INFINITY;for(const s of n)s.end>a||(e=e.slice(0,s.start)+s.replacement+e.slice(s.end),i.push(s),a=s.start);return{output:e,applied:i.reverse()}}function me(t,r={}){const{maxPasses:n=5,...i}=r,e=[];let a=t,s=0,o=!1;for(;s<n;s+=1){const l=Tt(a,i).filter(g=>g.replacement!==void 0);if(l.length===0)break;const{output:f,applied:p}=Br(a,l);if(f===a)break;e.push(...p),a=f,s===n-1&&(o=Tt(a,i).some(g=>g.replacement!==void 0))}return e.push(...Tt(a,i).filter(c=>c.replacement===void 0)),{output:a,fixes:e,passes:s,truncated:o}}const Aa="pretext-latex-clean",Ia={info:Nt.Information,warning:Nt.Warning,error:Nt.Error};function Ta(t){if(t.message)return t.message;const r=la[t.kind],n=t.ruleId.startsWith("env-")?`The ${t.macro} environment`:`\\${t.macro}`;if(t.action==="replace")return`${n} is rewritten on import.`;if(t.action==="delete")return r?`${n}: ${r}.`:`${n} does not convert to PreTeXt.`;if(t.alternatives?.length){const i=t.alternatives.map(e=>`\\${e.macro} (${e.meaning})`).join(", ");return`${n} marks appearance, not meaning. Consider ${i} instead.`}return r?`${n}: ${r}.`:`${n} is presentational.`}function Ge(t,r){return r.map(n=>({severity:Ia[n.severity],range:ne(t,n.start,n.end),source:Aa,code:n.ruleId,message:Ta(n),data:{ruleId:n.ruleId,start:n.start,end:n.end,replacement:n.replacement}}))}function Ra(t,r){return Ge(t,Tt(t,r))}function _r(t,r,n){let i=0;for(let e=0;e<r;e+=1){const a=t.indexOf(`
|
|
22
|
+
`,i);if(a===-1)return t.length;i=a+1}return Math.min(i+n,t.length)}function Ca(t,r,n){const i=_r(t,n.start.line,n.start.character),e=_r(t,n.end.line,n.end.character);return i===e?r.start<=i&&i<=r.end:r.start<e&&r.end>i}function Oa(t,r,n){const{uri:i,includeCleanAll:e=!0,...a}=n,s=Tt(t,a),o=[];for(const c of s)if(Ca(t,c,r)){if(c.replacement!==void 0){const l={range:ne(t,c.start,c.end),newText:c.replacement};o.push({title:La(c),kind:zt.QuickFix,diagnostics:Ge(t,[c]),edit:{changes:{[i]:[l]}}});continue}o.push(...za(t,s,c,i))}if(e){const c=me(t,a);if(c.output!==t){const l=c.fixes.filter(f=>f.replacement!==void 0).length;o.push({title:`Clean up LaTeX (${l} change${l===1?"":"s"})`,kind:zt.SourceFixAll,edit:{changes:{[i]:[{range:{start:{line:0,character:0},end:Te(t,t.length)},newText:c.output}]}}})}}return o}function za(t,r,n,i){const e=Ge(t,[n]),a=r.filter(f=>f.ruleId===n.ruleId),s=[],o=(f,p,g)=>{const d=g(n);if(!d||(s.push({title:f,kind:zt.QuickFix,diagnostics:e,edit:{changes:{[i]:[{range:ne(t,d.start,d.end),newText:d.newText}]}}}),a.length<2))return;const w=a.map(g).filter(h=>h!==null);w.length<2||s.push({title:p.replace("{n}",String(w.length)),kind:zt.QuickFix,diagnostics:e,edit:{changes:{[i]:w.map(h=>({range:ne(t,h.start,h.end),newText:h.newText}))}}})};for(const f of n.alternatives??[])o(`Replace \\${n.macro} with \\${f.macro} — ${f.meaning}`,`Replace all {n} \\${n.macro} with \\${f.macro}`,p=>({start:p.start,end:p.end,newText:`\\${f.macro}`}));const c=f=>Sa(t,f.start),l=c(n);return l&&!ke(l)&&o(`Remove \\${n.macro}, keep its text`,`Remove all {n} \\${n.macro}, keep their text`,f=>{const p=c(f);return!p||ke(p)?null:{start:p.start,end:p.end,newText:Ea(t,p)}}),o(l&&!ke(l)?`Delete \\${n.macro} and its text`:`Delete \\${n.macro}`,`Delete all {n} \\${n.macro} and their text`,f=>{const p=c(f);return p?{start:p.start,end:p.end,newText:""}:null}),s}function La(t){const r=t.ruleId.startsWith("env-")?`\\begin{${t.macro}}`:`\\${t.macro}`;return t.replacement===""?`Remove ${r}`:`Replace ${r} with ${t.replacementLabel??t.replacement?.trim()}`}function Nr(t){const{mainSource:r,publication:n,outputBase:i="output"}=t;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
23
|
+
<project ptx-version="2">
|
|
24
|
+
<targets>
|
|
25
|
+
<target name="web">
|
|
26
|
+
<format>html</format>
|
|
27
|
+
<source>${r}</source>
|
|
28
|
+
<publication>${n}</publication>
|
|
29
|
+
<output-dir>${i}/web</output-dir>
|
|
30
|
+
</target>
|
|
31
|
+
<target name="print">
|
|
32
|
+
<format>pdf</format>
|
|
33
|
+
<source>${r}</source>
|
|
34
|
+
<publication>${n}</publication>
|
|
35
|
+
<output-dir>${i}/print</output-dir>
|
|
36
|
+
</target>
|
|
37
|
+
</targets>
|
|
38
|
+
</project>
|
|
39
|
+
`}function He(){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
40
|
+
<publication>
|
|
41
|
+
<source>
|
|
42
|
+
<directories external="external" generated="generated"/>
|
|
43
|
+
</source>
|
|
44
|
+
<common>
|
|
45
|
+
<chunking level="1"/>
|
|
46
|
+
</common>
|
|
47
|
+
</publication>
|
|
48
|
+
`}function $a(){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
49
|
+
`}const Da="http://www.w3.org/2001/XInclude";function ge(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}function Vt(t,r){const n=String(r).length;return String(t).padStart(Math.max(n,2),"0")}function Dt(t,r){const n=[...r].sort((a,s)=>a.start-s.start);let i="",e=0;for(const a of n)i+=t.slice(e,a.start),i+=a.replacement,e=a.end;return i+=t.slice(e),i}function ce(t){return t.replace(/<([a-zA-Z_][\w:.-]*)\b([^>]*)>/,(r,n,i)=>/\bxmlns:xi\s*=/.test(i)?r:`<${n}${i} xmlns:xi="${Da}">`)}function le(t){return t.startsWith("<?xml")?t:$a()+t}const Ye=["part","chapter","section","subsection","subsubsection"];function Pa(t,r){let n=r;for(;n<t.length&&/\s/.test(t[n]);)n++;if(t[n]!=="{")return null;const i=n;let e=0;for(;n<t.length;n++){const a=t[n];if(a==="\\"){n++;continue}if(a==="{")e++;else if(a==="}"&&(e--,e===0))return{inner:t.slice(i+1,n),end:n+1}}return null}function ja(t,r){let n=r;for(;n<t.length&&/\s/.test(t[n]);)n++;if(t[n]!=="[")return r;let i=0;for(;n<t.length;n++){const e=t[n];if(e==="\\"){n++;continue}if(e==="[")i++;else if(e==="]"&&(i--,i===0))return n+1}return r}function Fa(t){return t.replace(/\\[a-zA-Z]+\{([^{}]*)\}/g,"$1").replace(/\\[a-zA-Z]+/g,"").replace(/[{}]/g,"").replace(/\s+/g," ").trim()}function be(t){const r=[],n=new Set(Ye);let i=0;for(let e=0;e<t.length;e++){const a=t[e];if(a==="{"){i++;continue}if(a==="}"){i--;continue}if(a!=="\\")continue;let s=e+1;for(;s<t.length&&/[a-zA-Z]/.test(t[s]);)s++;if(s===e+1){e++;continue}const o=t.slice(e+1,s);if(i!==0||!n.has(o)){e=s-1;continue}const c=t[s]==="*"?s+1:s,l=Pa(t,ja(t,c));if(!l){e=s-1;continue}let f=l.end,p;const g=/^\s*\\label\s*\{([^{}]*)\}/.exec(t.slice(l.end));g&&(p=g[1].trim(),f=l.end+g[0].length),r.push({command:o,start:e,rawTitle:l.inner,contentStart:f,labelId:p}),e=f-1}return r}function ve(t){const r=new Set(be(t).map(n=>n.command));return Ye.filter(n=>r.has(n))}function Je(t){const r=ve(t),n=new Map(r.map((s,o)=>[s,o+1])),i=be(t),e=[],a=[];for(const s of i){const o=n.get(s.command)??1,c={command:s.command,level:o,rawTitle:s.rawTitle,title:Fa(s.rawTitle),labelId:s.labelId,start:s.start,contentStart:s.contentStart,end:t.length,children:[]};for(;a.length>0&&a[a.length-1].level>=o;)a.pop().end=s.start;a.length===0?e.push(c):a[a.length-1].children.push(c),a.push(c)}return e}const qa=8e4,Ba=4e4,Na=3,Mr=3;function ue(t,r){return r<=1?t:t.flatMap(n=>ue(n.children,r-1))}function Ur(t,r){const n=Je(t);if(n.length===0)return 0;let i=r==="book"?1:0;const e=t.length>qa;for(;i<Mr&&!(ue(n,i+1).length<Na);){const s=i===0?e:ue(n,i).some(o=>o.end-o.start>Ba);if(!e&&!s)break;i+=1}return i}function Ma(t){let r=t;return r=r.replace(/\s+%.*/g,""),r=r.replace(/([^\\])%.*/g,"$1"),r=r.replace(/^%.*/,""),r}function Ua(t){return t.replace(/(.*\{)([^{}]+)(\}.*)/,(r,n,i,e)=>{const a=String(i).replace(/\s/g,"_").replace(/[^a-zA-Z0-9_]/g,"-");return`${n}${a}${e}`})}function Wa(t){let r=t;return r=r.replace(/> */g,"\\gt "),r=r.replace(/< */g,"\\lt "),r=r.replace(/(\\(ref|eqref|cref|Cref|label)\{([^{}]+)\})/g,Ua),r}function Wr(t){let r=t;return r=r.replace(/\\begin +/g,"\\begin"),r=r.replace(/\\chapter +/g,"\\chapter"),r=r.replace(/\\section +/g,"\\section"),r=r.replace(/\\section\*/g,"\\section"),r=Ma(r),r=Wa(r),r=r.replace(/\\end\{document\}.*/s,""),r=r.replace(/^\s+/,""),r=r.replace(/\n{3,}/g,`
|
|
50
|
+
|
|
51
|
+
`),r}function yr(t,r=0,n="{",i="}"){let e=t.trimStart();if(!e)return["",""];let a="",s="",o=r;if(o===0&&e[0]!==n)return["",e];for(o===0&&(s=n,o=1,e=e.substring(1));o>0&&e;){const c=e[0];c===n&&a!=="\\"?o+=1:c===i&&a!=="\\"&&(o-=1),s+=c,a==="\\"&&c==="\\"?a=`
|
|
52
|
+
`:a=c,e=e.substring(1)}return o===0?[s,e]:["",s.substring(1)]}function Xa(t,r={}){const n=Wr(t).replace(/(\n *){3,}/g,`
|
|
53
|
+
|
|
54
|
+
`),{output:i,fixes:e}=me(n,{scope:r.scope??"auto",disable:r.disable});return{output:i.replace(/(\n *){3,}/g,`
|
|
55
|
+
|
|
56
|
+
`),warnings:Ke(e),fixes:e}}function Ke(t){const r=new Map;for(const i of t){const e=r.get(i.ruleId);e?e.push(i):r.set(i.ruleId,[i])}const n=[];for(const i of r.values()){const[e]=i,a={severity:e.severity,kind:e.kind,category:e.category,macro:e.macro,occurrences:i.length,message:e.message};e.reportMatch&&n.push({...a,action:"save",examples:i.slice(0,5).map(s=>s.matched)}),e.action==="flag"?n.push({...a,action:"anomaly",examples:i.slice(0,5).map(s=>s.matched)}):e.action==="delete"?n.push({...a,action:"delete",severity:"info"}):n.push({...a,action:e.category==="tex_fonts"?"replace":"rewrite",replacement:e.replacementLabel??e.replacement})}return n}function Xr(t){const r=Wr(t).replace(/(\n *){3,}/g,`
|
|
57
|
+
|
|
58
|
+
`),n=qr(r,"auto"),i=[],e=r.slice(n.preamble.start,n.preamble.end);e&&i.push(Qt(e,{path:[],title:"",kind:"preamble",level:0},"preamble"));const a=r.slice(n.body.start,n.body.end);i.push(...Za(a));const s=n.bibliography?r.slice(n.bibliography.start,n.bibliography.end):"",o=r.includes("\\begin{document}"),c=i.filter(g=>g.kind!=="preamble").map(g=>g.after).join(""),l=i.find(g=>g.kind==="preamble")?.after??"",f=((o?l+"\\begin{document}":"")+c+s).replace(/(\n *){3,}/g,`
|
|
59
|
+
|
|
60
|
+
`),p=i.flatMap(g=>g.fixes);return{output:f,chunks:i,warnings:Ke(p),fixes:p}}function Qt(t,r,n){const{output:i,fixes:e}=me(t,{scope:n});return{...r,before:t,after:i,fixes:e}}function Za(t){const r=be(t),n=ve(t),i=new Map(n.map((c,l)=>[c,l+1]));if(r.length===0)return t?[Qt(t,{path:[],title:"",kind:"lead",level:0},"body")]:[];const e=[],a=t.slice(0,r[0].start);let s="";a.trim()?e.push(Qt(a,{path:[],title:"",kind:"lead",level:0},"body")):s=a;const o=[];return r.forEach((c,l)=>{const f=i.get(c.command)??1,p=Va(c.rawTitle);o.length=f-1,o[f-1]=p;const g=r[l+1]?.start??t.length,d=(l===0?s:"")+t.slice(c.start,g);e.push(Qt(d,{path:[...o],title:p,kind:"division",command:c.command,level:f},"body"))}),e}function Va(t){return t.replace(/\\[a-zA-Z]+\{([^{}]*)\}/g,"$1").replace(/\\[a-zA-Z]+/g,"").replace(/[{}]/g,"").replace(/\s+/g," ").trim()}function Ga(t,r){const n=[];for(const i of t){if(i.kind==="preamble"){n.push(i);continue}const e=i.kind==="division"&&i.level<=r&&r>0,a=n[n.length-1];if(a!==void 0&&a.kind!=="preamble"&&!e){n[n.length-1]={...a,before:a.before+i.before,after:a.after+i.after,fixes:[...a.fixes,...i.fixes]};continue}n.push({...i,path:i.path.slice(0,Math.max(r,0))})}return n}function Wt(t){const r="\\begin{document}",n="\\end{document}",i=t.indexOf(r);if(i===-1)return{preamble:"",body:t};const e=t.slice(0,i).trim(),a=t.slice(i+r.length),s=a.indexOf(n),o=(s===-1?a:a.slice(0,s)).trim();return{preamble:e,body:o}}function de(t,r){const i=new RegExp(`\\\\${r}(?![a-zA-Z])`).exec(t);if(!i)return"";let e=t.slice(i.index+i[0].length).trimStart();if(e.startsWith("[")){const[s,o]=yr(e,0,"[","]");s&&(e=o.trimStart())}const[a]=yr(e);return a?a.slice(1,-1).trim():""}const Ha=/^[ \t]*(\\(?:new|renew|provide)command\*?|\\DeclareMathOperator\*?|\\newenvironment\*?|\\def)\b/,Ya=/^[ \t]*\\def\b/;function xr(t){let r=0;for(let n=0;n<t.length;n++){if(t[n]==="\\"){n++;continue}t[n]==="{"?r++:t[n]==="}"&&r--}return r}function Zr(t){const r=t.split(`
|
|
61
|
+
`),n=[],i=[];let e=0;for(;e<r.length;){if(!Ha.test(r[e])){e++;continue}let s=r[e],o=xr(r[e]);for(e++;o>0&&e<r.length;)s+=`
|
|
62
|
+
`+r[e],o+=xr(r[e]),e++;const c=s.trim();n.push(c),Ya.test(c)&&i.push(c)}const a=i.length>0?[{action:"anomaly",severity:"warning",kind:"archaic",category:"use_newcommand_only",macro:"def",occurrences:i.length,message:"\\def defines a macro the way plain TeX does; PreTeXt tooling such as WeBWorK/PG macro extraction only recognizes \\newcommand. The definition is kept as-is so the document still builds — consider rewriting it as \\newcommand by hand.",examples:i.slice(0,5)}]:[];return{macros:n.join(`
|
|
63
|
+
`),warnings:a}}function Ja(t){const r=/\\documentclass(?:\[[^\]]*\])?\{([^}]+)\}/.exec(t);return r?r[1].trim():"article"}function Ka(t){const r=t.replace(/(^|[^\\])%[^\n]*/gm,"$1"),{macros:n,warnings:i}=Zr(r);return{info:{documentClass:Ja(r),title:de(r,"title"),author:de(r,"author"),macros:n},warnings:i}}function Qa(t){if(typeof t=="string")return t;if(typeof t=="object"&&t!==null&&"value"in t){const r=t.value;if(typeof r=="string")return r;if(r!=null)return String(r)}return String(t)}function Me(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Vr(t){return t.replace(/\\LaTeX\b/g,"LaTeX").replace(/\\TeX\b/g,"TeX").replace(/\\thanks\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g,"").replace(/\\inst\{[^{}]*\}/g,"").replace(/\\email\{[^{}]*\}/g,"").replace(/\\[a-zA-Z]+\{([^{}]*)\}/g,"$1").replace(/\\\s/g," ").replace(/~/g," ").replace(/\s+/g," ").trim()}function ts(t){const r=[];if(t.macros){const n=Me(t.macros).split(`
|
|
64
|
+
`).map(i=>` ${i}`).join(`
|
|
65
|
+
`);r.push(` <macros>
|
|
66
|
+
${n}
|
|
67
|
+
</macros>`)}if(t.author){const n=t.author.split(/\s+\\and\s+/)[0].trim(),i=Me(Vr(n));i&&r.push(` <author>
|
|
68
|
+
<personname>${i}</personname>
|
|
69
|
+
</author>`)}return r.length===0?"":`<docinfo>
|
|
70
|
+
${r.join(`
|
|
71
|
+
`)}
|
|
72
|
+
</docinfo>`}function es(t,r){const n=t.replace(/^\s*<p\s*\/>\s*/g,"").replace(/^\s*<p>\s*<\/p>\s*/g,"").trim();if(!n)return"";const e=/<chapter[\s>]/.test(n)?"book":"article",a=ts(r),s=r.title?` <title>${Me(Vr(r.title))}</title>
|
|
73
|
+
`:"",o=`<${e}>
|
|
74
|
+
${s}${n}
|
|
75
|
+
</${e}>`;return`<pretext>
|
|
76
|
+
${[a,o].filter(Boolean).join(`
|
|
77
|
+
`)}
|
|
78
|
+
</pretext>`}function we(t){const r=t.trim();return r?Fi.formatPretext(r):""}function Gr(t){const r=t.trim();if(!r)return{pretext:"",cleanedLatex:"",warnings:[],cleanChunks:[]};const{preamble:n,body:i}=Wt(r),{info:e,warnings:a}=Ka(n),s=i?[`\\documentclass{${e.documentClass}}`,e.macros,"\\begin{document}",i,"\\end{document}"].filter(Boolean).join(`
|
|
79
|
+
`):r,{output:o,warnings:c,chunks:l}=Xr(s),f=[...a,...c];if(!o.trim())return{pretext:"",cleanedLatex:o,warnings:f,cleanChunks:l};const p=i?o+`
|
|
80
|
+
\\end{document}`:o,g=Qa(qi.latexToPretext(p)).trim();if(!g)return{pretext:"",cleanedLatex:o,warnings:f,cleanChunks:l};const d=es(g,e);return{pretext:d?we(d):"",cleanedLatex:o,warnings:f,cleanChunks:l}}function Hr(t){const r=t.trim();if(!r)return{pretext:"",cleanedMarkdown:""};const n=String(Bi.markdownToPretext(r)).trim();return{pretext:n?we(n):"",cleanedMarkdown:r}}function Yr(t){return t instanceof Error&&t.message.trim()?t.message.trim():"Could not convert source content to PreTeXt."}function Jr(t,r){const n=ee(t),i=r??n;try{if(i==="pretext")return{sourceFormat:i,detectedSourceFormat:n,pretextSource:we(t),warnings:[]};if(i==="markdown"){const{pretext:c,cleanedMarkdown:l}=Hr(t);return{sourceFormat:i,detectedSourceFormat:n,pretextSource:c,cleanedNativeSource:l,warnings:[]}}const{pretext:e,cleanedLatex:a,warnings:s,cleanChunks:o}=Gr(t);return{sourceFormat:i,detectedSourceFormat:n,pretextSource:e,cleanedNativeSource:a,warnings:s,cleanChunks:o}}catch(e){return{sourceFormat:i,detectedSourceFormat:n,pretextError:Yr(e),warnings:[]}}}var Jt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ns(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Kt(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Se={exports:{}};var kr;function rs(){return kr||(kr=1,(function(t,r){(function(n){t.exports=n()})(function(){return(function n(i,e,a){function s(l,f){if(!e[l]){if(!i[l]){var p=typeof Kt=="function"&&Kt;if(!f&&p)return p(l,!0);if(o)return o(l,!0);var g=new Error("Cannot find module '"+l+"'");throw g.code="MODULE_NOT_FOUND",g}var d=e[l]={exports:{}};i[l][0].call(d.exports,function(w){var h=i[l][1][w];return s(h||w)},d,d.exports,n,i,e,a)}return e[l].exports}for(var o=typeof Kt=="function"&&Kt,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,i,e){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.encode=function(c){for(var l,f,p,g,d,w,h,v=[],b=0,x=c.length,S=x,I=a.getTypeOf(c)!=="string";b<c.length;)S=x-b,p=I?(l=c[b++],f=b<x?c[b++]:0,b<x?c[b++]:0):(l=c.charCodeAt(b++),f=b<x?c.charCodeAt(b++):0,b<x?c.charCodeAt(b++):0),g=l>>2,d=(3&l)<<4|f>>4,w=1<S?(15&f)<<2|p>>6:64,h=2<S?63&p:64,v.push(o.charAt(g)+o.charAt(d)+o.charAt(w)+o.charAt(h));return v.join("")},e.decode=function(c){var l,f,p,g,d,w,h=0,v=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var x,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&S--,c.charAt(c.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=s.uint8array?new Uint8Array(0|S):new Array(0|S);h<c.length;)l=o.indexOf(c.charAt(h++))<<2|(g=o.indexOf(c.charAt(h++)))>>4,f=(15&g)<<4|(d=o.indexOf(c.charAt(h++)))>>2,p=(3&d)<<6|(w=o.indexOf(c.charAt(h++))),x[v++]=l,d!==64&&(x[v++]=f),w!==64&&(x[v++]=p);return x}},{"./support":30,"./utils":32}],2:[function(n,i,e){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function l(f,p,g,d,w){this.compressedSize=f,this.uncompressedSize=p,this.crc32=g,this.compression=d,this.compressedContent=w}l.prototype={getContentWorker:function(){var f=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),p=this;return f.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(f,p,g){return f.pipe(new o).pipe(new c("uncompressedSize")).pipe(p.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",p)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,i,e){var a=n("./stream/GenericWorker");e.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},e.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,i,e){var a=n("./utils"),s=(function(){for(var o,c=[],l=0;l<256;l++){o=l;for(var f=0;f<8;f++)o=1&o?3988292384^o>>>1:o>>>1;c[l]=o}return c})();i.exports=function(o,c){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(l,f,p,g){var d=s,w=g+p;l^=-1;for(var h=g;h<w;h++)l=l>>>8^d[255&(l^f[h])];return-1^l})(0|c,o,o.length,0):(function(l,f,p,g){var d=s,w=g+p;l^=-1;for(var h=g;h<w;h++)l=l>>>8^d[255&(l^f.charCodeAt(h))];return-1^l})(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(n,i,e){e.base64=!1,e.binary=!1,e.dir=!1,e.createFolders=!0,e.date=null,e.compression=null,e.compressionOptions=null,e.comment=null,e.unixPermissions=null,e.dosPermissions=null},{}],6:[function(n,i,e){var a=null;a=typeof Promise<"u"?Promise:n("lie"),i.exports={Promise:a}},{lie:37}],7:[function(n,i,e){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),o=n("./utils"),c=n("./stream/GenericWorker"),l=a?"uint8array":"array";function f(p,g){c.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=g,this.meta={}}e.magic="\b\0",o.inherits(f,c),f.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(l,p.data),!1)},f.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(g){p.push({data:g,meta:p.meta})}},e.compressWorker=function(p){return new f("Deflate",p)},e.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,i,e){function a(d,w){var h,v="";for(h=0;h<w;h++)v+=String.fromCharCode(255&d),d>>>=8;return v}function s(d,w,h,v,b,x){var S,I,A=d.file,P=d.compression,$=x!==l.utf8encode,B=o.transformTo("string",x(A.name)),L=o.transformTo("string",l.utf8encode(A.name)),W=A.comment,J=o.transformTo("string",x(W)),k=o.transformTo("string",l.utf8encode(W)),D=L.length!==A.name.length,m=k.length!==W.length,F="",it="",M="",nt=A.dir,U=A.date,et={crc32:0,compressedSize:0,uncompressedSize:0};w&&!h||(et.crc32=d.crc32,et.compressedSize=d.compressedSize,et.uncompressedSize=d.uncompressedSize);var O=0;w&&(O|=8),$||!D&&!m||(O|=2048);var C=0,K=0;nt&&(C|=16),b==="UNIX"?(K=798,C|=(function(V,ut){var Q=V;return V||(Q=ut?16893:33204),(65535&Q)<<16})(A.unixPermissions,nt)):(K=20,C|=(function(V){return 63&(V||0)})(A.dosPermissions)),S=U.getUTCHours(),S<<=6,S|=U.getUTCMinutes(),S<<=5,S|=U.getUTCSeconds()/2,I=U.getUTCFullYear()-1980,I<<=4,I|=U.getUTCMonth()+1,I<<=5,I|=U.getUTCDate(),D&&(it=a(1,1)+a(f(B),4)+L,F+="up"+a(it.length,2)+it),m&&(M=a(1,1)+a(f(J),4)+k,F+="uc"+a(M.length,2)+M);var G="";return G+=`
|
|
81
|
+
\0`,G+=a(O,2),G+=P.magic,G+=a(S,2),G+=a(I,2),G+=a(et.crc32,4),G+=a(et.compressedSize,4),G+=a(et.uncompressedSize,4),G+=a(B.length,2),G+=a(F.length,2),{fileRecord:p.LOCAL_FILE_HEADER+G+B+F,dirRecord:p.CENTRAL_FILE_HEADER+a(K,2)+G+a(J.length,2)+"\0\0\0\0"+a(C,4)+a(v,4)+B+F+J}}var o=n("../utils"),c=n("../stream/GenericWorker"),l=n("../utf8"),f=n("../crc32"),p=n("../signature");function g(d,w,h,v){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=h,this.encodeFileName=v,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,c),g.prototype.push=function(d){var w=d.meta.percent||0,h=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:h?(w+100*(h-v-1))/h:100}}))},g.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var w=this.streamFiles&&!d.file.dir;if(w){var h=s(d,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(d){this.accumulate=!1;var w=this.streamFiles&&!d.file.dir,h=s(d,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),w)this.push({data:(function(v){return p.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var d=this.bytesWritten,w=0;w<this.dirRecords.length;w++)this.push({data:this.dirRecords[w],meta:{percent:100}});var h=this.bytesWritten-d,v=(function(b,x,S,I,A){var P=o.transformTo("string",A(I));return p.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(b,2)+a(b,2)+a(x,4)+a(S,4)+a(P.length,2)+P})(this.dirRecords.length,h,d,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(d){this._sources.push(d);var w=this;return d.on("data",function(h){w.processChunk(h)}),d.on("end",function(){w.closedSource(w.previous.streamInfo),w._sources.length?w.prepareNextSource():w.end()}),d.on("error",function(h){w.error(h)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(d){var w=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var h=0;h<w.length;h++)try{w[h].error(d)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,w=0;w<d.length;w++)d[w].lock()},i.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,i,e){var a=n("../compressions"),s=n("./ZipFileWorker");e.generateWorker=function(o,c,l){var f=new s(c.streamFiles,l,c.platform,c.encodeFileName),p=0;try{o.forEach(function(g,d){p++;var w=(function(x,S){var I=x||S,A=a[I];if(!A)throw new Error(I+" is not a valid compression method !");return A})(d.options.compression,c.compression),h=d.options.compressionOptions||c.compressionOptions||{},v=d.dir,b=d.date;d._compressWorker(w,h).withStreamInfo("file",{name:g,dir:v,date:b,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(f)}),f.entriesCount=p}catch(g){f.error(g)}return f}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,i,e){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),i.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,i,e){var a=n("./utils"),s=n("./external"),o=n("./utf8"),c=n("./zipEntries"),l=n("./stream/Crc32Probe"),f=n("./nodejsUtils");function p(g){return new s.Promise(function(d,w){var h=g.decompressed.getContentWorker().pipe(new l);h.on("error",function(v){w(v)}).on("end",function(){h.streamInfo.crc32!==g.decompressed.crc32?w(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(g,d){var w=this;return d=a.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),f.isNode&&f.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,d.optimizedBinaryString,d.base64).then(function(h){var v=new c(d);return v.load(h),v}).then(function(h){var v=[s.Promise.resolve(h)],b=h.files;if(d.checkCRC32)for(var x=0;x<b.length;x++)v.push(p(b[x]));return s.Promise.all(v)}).then(function(h){for(var v=h.shift(),b=v.files,x=0;x<b.length;x++){var S=b[x],I=S.fileNameStr,A=a.resolve(S.fileNameStr);w.file(A,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:d.createFolders}),S.dir||(w.file(A).unsafeOriginalName=I)}return v.zipComment.length&&(w.comment=v.zipComment),w})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,i,e){var a=n("../utils"),s=n("../stream/GenericWorker");function o(c,l){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}a.inherits(o,s),o.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(f){l.push({data:f,meta:{percent:0}})}).on("error",function(f){l.isPaused?this.generatedError=f:l.error(f)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,i,e){var a=n("readable-stream").Readable;function s(o,c,l){a.call(this,c),this._helper=o;var f=this;o.on("data",function(p,g){f.push(p)||f._helper.pause(),l&&l(g)}).on("error",function(p){f.emit("error",p)}).on("end",function(){f.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,i,e){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,i,e){function a(A,P,$){var B,L=o.getTypeOf(P),W=o.extend($||{},f);W.date=W.date||new Date,W.compression!==null&&(W.compression=W.compression.toUpperCase()),typeof W.unixPermissions=="string"&&(W.unixPermissions=parseInt(W.unixPermissions,8)),W.unixPermissions&&16384&W.unixPermissions&&(W.dir=!0),W.dosPermissions&&16&W.dosPermissions&&(W.dir=!0),W.dir&&(A=b(A)),W.createFolders&&(B=v(A))&&x.call(this,B,!0);var J=L==="string"&&W.binary===!1&&W.base64===!1;$&&$.binary!==void 0||(W.binary=!J),(P instanceof p&&P.uncompressedSize===0||W.dir||!P||P.length===0)&&(W.base64=!1,W.binary=!0,P="",W.compression="STORE",L="string");var k=null;k=P instanceof p||P instanceof c?P:w.isNode&&w.isStream(P)?new h(A,P):o.prepareContent(A,P,W.binary,W.optimizedBinaryString,W.base64);var D=new g(A,k,W);this.files[A]=D}var s=n("./utf8"),o=n("./utils"),c=n("./stream/GenericWorker"),l=n("./stream/StreamHelper"),f=n("./defaults"),p=n("./compressedObject"),g=n("./zipObject"),d=n("./generate"),w=n("./nodejsUtils"),h=n("./nodejs/NodejsStreamInputAdapter"),v=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var P=A.lastIndexOf("/");return 0<P?A.substring(0,P):""},b=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},x=function(A,P){return P=P!==void 0?P:f.createFolders,A=b(A),this.files[A]||a.call(this,A,null,{dir:!0,createFolders:P}),this.files[A]};function S(A){return Object.prototype.toString.call(A)==="[object RegExp]"}var I={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var P,$,B;for(P in this.files)B=this.files[P],($=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&A($,B)},filter:function(A){var P=[];return this.forEach(function($,B){A($,B)&&P.push(B)}),P},file:function(A,P,$){if(arguments.length!==1)return A=this.root+A,a.call(this,A,P,$),this;if(S(A)){var B=A;return this.filter(function(W,J){return!J.dir&&B.test(W)})}var L=this.files[this.root+A];return L&&!L.dir?L:null},folder:function(A){if(!A)return this;if(S(A))return this.filter(function(L,W){return W.dir&&A.test(L)});var P=this.root+A,$=x.call(this,P),B=this.clone();return B.root=$.name,B},remove:function(A){A=this.root+A;var P=this.files[A];if(P||(A.slice(-1)!=="/"&&(A+="/"),P=this.files[A]),P&&!P.dir)delete this.files[A];else for(var $=this.filter(function(L,W){return W.name.slice(0,A.length)===A}),B=0;B<$.length;B++)delete this.files[$[B].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var P,$={};try{if(($=o.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=$.type.toLowerCase(),$.compression=$.compression.toUpperCase(),$.type==="binarystring"&&($.type="string"),!$.type)throw new Error("No output type specified.");o.checkSupport($.type),$.platform!=="darwin"&&$.platform!=="freebsd"&&$.platform!=="linux"&&$.platform!=="sunos"||($.platform="UNIX"),$.platform==="win32"&&($.platform="DOS");var B=$.comment||this.comment||"";P=d.generateWorker(this,$,B)}catch(L){(P=new c("error")).error(L)}return new l(P,$.type||"string",$.mimeType)},generateAsync:function(A,P){return this.generateInternalStream(A).accumulate(P)},generateNodeStream:function(A,P){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(P)}};i.exports=I},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,i,e){i.exports=n("stream")},{stream:void 0}],17:[function(n,i,e){var a=n("./DataReader");function s(o){a.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),l=o.charCodeAt(1),f=o.charCodeAt(2),p=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===l&&this.data[g+2]===f&&this.data[g+3]===p)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),l=o.charCodeAt(1),f=o.charCodeAt(2),p=o.charCodeAt(3),g=this.readData(4);return c===g[0]&&l===g[1]&&f===g[2]&&p===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,i,e){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,l=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=o,l},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=s},{"../utils":32}],19:[function(n,i,e){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,i,e){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,i,e){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,i,e){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),c=n("./StringReader"),l=n("./NodeBufferReader"),f=n("./Uint8ArrayReader");i.exports=function(p){var g=a.getTypeOf(p);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new l(p):s.uint8array?new f(a.transformTo("uint8array",p)):new o(a.transformTo("array",p)):new c(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,i,e){e.LOCAL_FILE_HEADER="PK",e.CENTRAL_FILE_HEADER="PK",e.CENTRAL_DIRECTORY_END="PK",e.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",e.ZIP64_CENTRAL_DIRECTORY_END="PK",e.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,i,e){var a=n("./GenericWorker"),s=n("../utils");function o(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(o,a),o.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,i,e){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,i,e){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(o,s),o.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}s.prototype.processChunk.call(this,c)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,i,e){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(f){l.dataIsReady=!0,l.data=f,l.max=f&&f.length||0,l.type=a.getTypeOf(f),l.isPaused||l._tickAndRepeat()},function(f){l.error(f)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,i,e){function a(s){this.name=s||"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}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(c){o.processChunk(c)}),s.on("end",function(){o.end()}),s.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=a},{}],29:[function(n,i,e){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),c=n("../base64"),l=n("../support"),f=n("../external"),p=null;if(l.nodestream)try{p=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(w,h){return new f.Promise(function(v,b){var x=[],S=w._internalType,I=w._outputType,A=w._mimeType;w.on("data",function(P,$){x.push(P),h&&h($)}).on("error",function(P){x=[],b(P)}).on("end",function(){try{var P=(function($,B,L){switch($){case"blob":return a.newBlob(a.transformTo("arraybuffer",B),L);case"base64":return c.encode(B);default:return a.transformTo($,B)}})(I,(function($,B){var L,W=0,J=null,k=0;for(L=0;L<B.length;L++)k+=B[L].length;switch($){case"string":return B.join("");case"array":return Array.prototype.concat.apply([],B);case"uint8array":for(J=new Uint8Array(k),L=0;L<B.length;L++)J.set(B[L],W),W+=B[L].length;return J;case"nodebuffer":return Buffer.concat(B);default:throw new Error("concat : unsupported type '"+$+"'")}})(S,x),A);v(P)}catch($){b($)}x=[]}).resume()})}function d(w,h,v){var b=h;switch(h){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=h,this._mimeType=v,a.checkSupport(b),this._worker=w.pipe(new s(b)),w.lock()}catch(x){this._worker=new o("error"),this._worker.error(x)}}d.prototype={accumulate:function(w){return g(this,w)},on:function(w,h){var v=this;return w==="data"?this._worker.on(w,function(b){h.call(v,b.data,b.meta)}):this._worker.on(w,function(){a.delay(h,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(w){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new p(this,{objectMode:this._outputType!=="nodebuffer"},w)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,i,e){if(e.base64=!0,e.array=!0,e.string=!0,e.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",e.nodebuffer=typeof Buffer<"u",e.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")e.blob=!1;else{var a=new ArrayBuffer(0);try{e.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),e.blob=s.getBlob("application/zip").size===0}catch{e.blob=!1}}}try{e.nodestream=!!n("readable-stream").Readable}catch{e.nodestream=!1}},{"readable-stream":16}],31:[function(n,i,e){for(var a=n("./utils"),s=n("./support"),o=n("./nodejsUtils"),c=n("./stream/GenericWorker"),l=new Array(256),f=0;f<256;f++)l[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;l[254]=l[254]=1;function p(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}e.utf8encode=function(d){return s.nodebuffer?o.newBufferFrom(d,"utf-8"):(function(w){var h,v,b,x,S,I=w.length,A=0;for(x=0;x<I;x++)(64512&(v=w.charCodeAt(x)))==55296&&x+1<I&&(64512&(b=w.charCodeAt(x+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),x++),A+=v<128?1:v<2048?2:v<65536?3:4;for(h=s.uint8array?new Uint8Array(A):new Array(A),x=S=0;S<A;x++)(64512&(v=w.charCodeAt(x)))==55296&&x+1<I&&(64512&(b=w.charCodeAt(x+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),x++),v<128?h[S++]=v:(v<2048?h[S++]=192|v>>>6:(v<65536?h[S++]=224|v>>>12:(h[S++]=240|v>>>18,h[S++]=128|v>>>12&63),h[S++]=128|v>>>6&63),h[S++]=128|63&v);return h})(d)},e.utf8decode=function(d){return s.nodebuffer?a.transformTo("nodebuffer",d).toString("utf-8"):(function(w){var h,v,b,x,S=w.length,I=new Array(2*S);for(h=v=0;h<S;)if((b=w[h++])<128)I[v++]=b;else if(4<(x=l[b]))I[v++]=65533,h+=x-1;else{for(b&=x===2?31:x===3?15:7;1<x&&h<S;)b=b<<6|63&w[h++],x--;1<x?I[v++]=65533:b<65536?I[v++]=b:(b-=65536,I[v++]=55296|b>>10&1023,I[v++]=56320|1023&b)}return I.length!==v&&(I.subarray?I=I.subarray(0,v):I.length=v),a.applyFromCharCode(I)})(d=a.transformTo(s.uint8array?"uint8array":"array",d))},a.inherits(p,c),p.prototype.processChunk=function(d){var w=a.transformTo(s.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var h=w;(w=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),w.set(h,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var v=(function(x,S){var I;for((S=S||x.length)>x.length&&(S=x.length),I=S-1;0<=I&&(192&x[I])==128;)I--;return I<0||I===0?S:I+l[x[I]]>S?I:S})(w),b=w;v!==w.length&&(s.uint8array?(b=w.subarray(0,v),this.leftOver=w.subarray(v,w.length)):(b=w.slice(0,v),this.leftOver=w.slice(v,w.length))),this.push({data:e.utf8decode(b),meta:d.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:e.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},e.Utf8DecodeWorker=p,a.inherits(g,c),g.prototype.processChunk=function(d){this.push({data:e.utf8encode(d.data),meta:d.meta})},e.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,i,e){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),c=n("./external");function l(h){return h}function f(h,v){for(var b=0;b<h.length;++b)v[b]=255&h.charCodeAt(b);return v}n("setimmediate"),e.newBlob=function(h,v){e.checkSupport("blob");try{return new Blob([h],{type:v})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(h),b.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var p={stringifyByChunk:function(h,v,b){var x=[],S=0,I=h.length;if(I<=b)return String.fromCharCode.apply(null,h);for(;S<I;)v==="array"||v==="nodebuffer"?x.push(String.fromCharCode.apply(null,h.slice(S,Math.min(S+b,I)))):x.push(String.fromCharCode.apply(null,h.subarray(S,Math.min(S+b,I)))),S+=b;return x.join("")},stringifyByChar:function(h){for(var v="",b=0;b<h.length;b++)v+=String.fromCharCode(h[b]);return v},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(h){var v=65536,b=e.getTypeOf(h),x=!0;if(b==="uint8array"?x=p.applyCanBeUsed.uint8array:b==="nodebuffer"&&(x=p.applyCanBeUsed.nodebuffer),x)for(;1<v;)try{return p.stringifyByChunk(h,b,v)}catch{v=Math.floor(v/2)}return p.stringifyByChar(h)}function d(h,v){for(var b=0;b<h.length;b++)v[b]=h[b];return v}e.applyFromCharCode=g;var w={};w.string={string:l,array:function(h){return f(h,new Array(h.length))},arraybuffer:function(h){return w.string.uint8array(h).buffer},uint8array:function(h){return f(h,new Uint8Array(h.length))},nodebuffer:function(h){return f(h,o.allocBuffer(h.length))}},w.array={string:g,array:l,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(h)}},w.arraybuffer={string:function(h){return g(new Uint8Array(h))},array:function(h){return d(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:l,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(new Uint8Array(h))}},w.uint8array={string:g,array:function(h){return d(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:l,nodebuffer:function(h){return o.newBufferFrom(h)}},w.nodebuffer={string:g,array:function(h){return d(h,new Array(h.length))},arraybuffer:function(h){return w.nodebuffer.uint8array(h).buffer},uint8array:function(h){return d(h,new Uint8Array(h.length))},nodebuffer:l},e.transformTo=function(h,v){if(v=v||"",!h)return v;e.checkSupport(h);var b=e.getTypeOf(v);return w[b][h](v)},e.resolve=function(h){for(var v=h.split("/"),b=[],x=0;x<v.length;x++){var S=v[x];S==="."||S===""&&x!==0&&x!==v.length-1||(S===".."?b.pop():b.push(S))}return b.join("/")},e.getTypeOf=function(h){return typeof h=="string"?"string":Object.prototype.toString.call(h)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(h)?"nodebuffer":a.uint8array&&h instanceof Uint8Array?"uint8array":a.arraybuffer&&h instanceof ArrayBuffer?"arraybuffer":void 0},e.checkSupport=function(h){if(!a[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},e.MAX_VALUE_16BITS=65535,e.MAX_VALUE_32BITS=-1,e.pretty=function(h){var v,b,x="";for(b=0;b<(h||"").length;b++)x+="\\x"+((v=h.charCodeAt(b))<16?"0":"")+v.toString(16).toUpperCase();return x},e.delay=function(h,v,b){setImmediate(function(){h.apply(b||null,v||[])})},e.inherits=function(h,v){function b(){}b.prototype=v.prototype,h.prototype=new b},e.extend=function(){var h,v,b={};for(h=0;h<arguments.length;h++)for(v in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],v)&&b[v]===void 0&&(b[v]=arguments[h][v]);return b},e.prepareContent=function(h,v,b,x,S){return c.Promise.resolve(v).then(function(I){return a.blob&&(I instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(I))!==-1)&&typeof FileReader<"u"?new c.Promise(function(A,P){var $=new FileReader;$.onload=function(B){A(B.target.result)},$.onerror=function(B){P(B.target.error)},$.readAsArrayBuffer(I)}):I}).then(function(I){var A=e.getTypeOf(I);return A?(A==="arraybuffer"?I=e.transformTo("uint8array",I):A==="string"&&(S?I=s.decode(I):b&&x!==!0&&(I=(function(P){return f(P,a.uint8array?new Uint8Array(P.length):new Array(P.length))})(I))),I):c.Promise.reject(new Error("Can't read the data of '"+h+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,i,e){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),c=n("./zipEntry"),l=n("./support");function f(p){this.files=[],this.loadOptions=p}f.prototype={checkSignature:function(p){if(!this.reader.readAndCheckSignature(p)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(p)+")")}},isSignature:function(p,g){var d=this.reader.index;this.reader.setIndex(p);var w=this.reader.readString(4)===g;return this.reader.setIndex(d),w},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 p=this.reader.readData(this.zipCommentLength),g=l.uint8array?"uint8array":"array",d=s.transformTo(g,p);this.zipComment=this.loadOptions.decodeFileName(d)},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={};for(var p,g,d,w=this.zip64EndOfCentralSize-44;0<w;)p=this.reader.readInt(2),g=this.reader.readInt(4),d=this.reader.readData(g),this.zip64ExtensibleData[p]={id:p,length:g,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var p,g;for(p=0;p<this.files.length;p++)g=this.files[p],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var p;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(p=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(p);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var p=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(p<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new 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");this.reader.setIndex(p);var g=p;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(p=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(p),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var w=g-d;if(0<w)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=w);else if(w<0)throw new Error("Corrupted zip: missing "+Math.abs(w)+" bytes.")},prepareReader:function(p){this.reader=a(p)},load:function(p){this.prepareReader(p),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=f},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,i,e){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),c=n("./crc32"),l=n("./utf8"),f=n("./compressions"),p=n("./support");function g(d,w){this.options=d,this.loadOptions=w}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var w,h;if(d.skip(22),this.fileNameLength=d.readInt(2),h=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(h),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((w=(function(v){for(var b in f)if(Object.prototype.hasOwnProperty.call(f,b)&&f[b].magic===v)return f[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,w,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var w=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(w),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var w,h,v,b=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<b;)w=d.readInt(2),h=d.readInt(2),v=d.readData(h),this.extraFields[w]={id:w,length:h,value:v};d.setIndex(b)},handleUTF8:function(){var d=p.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var w=this.findExtraFieldUnicodePath();if(w!==null)this.fileNameStr=w;else{var h=s.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var b=s.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var w=a(d.value);return w.readInt(1)!==1||c(this.fileName)!==w.readInt(4)?null:l.utf8decode(w.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var w=a(d.value);return w.readInt(1)!==1||c(this.fileComment)!==w.readInt(4)?null:l.utf8decode(w.readData(d.length-5))}return null}},i.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,i,e){function a(w,h,v){this.name=w,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=h,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),c=n("./utf8"),l=n("./compressedObject"),f=n("./stream/GenericWorker");a.prototype={internalStream:function(w){var h=null,v="string";try{if(!w)throw new Error("No output type specified.");var b=(v=w.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),h=this._decompressWorker();var x=!this._dataBinary;x&&!b&&(h=h.pipe(new c.Utf8EncodeWorker)),!x&&b&&(h=h.pipe(new c.Utf8DecodeWorker))}catch(S){(h=new f("error")).error(S)}return new s(h,v,"")},async:function(w,h){return this.internalStream(w).accumulate(h)},nodeStream:function(w,h){return this.internalStream(w||"nodebuffer").toNodejsStream(h)},_compressWorker:function(w,h){if(this._data instanceof l&&this._data.compression.magic===w.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(v,w,h)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof f?this._data:new o(this._data)}};for(var p=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<p.length;d++)a.prototype[p[d]]=g;i.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,i,e){(function(a){var s,o,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var l=0,f=new c(w),p=a.document.createTextNode("");f.observe(p,{characterData:!0}),s=function(){p.data=l=++l%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var h=a.document.createElement("script");h.onreadystatechange=function(){w(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},a.document.documentElement.appendChild(h)}:function(){setTimeout(w,0)};else{var g=new a.MessageChannel;g.port1.onmessage=w,s=function(){g.port2.postMessage(0)}}var d=[];function w(){var h,v;o=!0;for(var b=d.length;b;){for(v=d,d=[],h=-1;++h<b;)v[h]();b=d.length}o=!1}i.exports=function(h){d.push(h)!==1||o||s()}}).call(this,typeof Jt<"u"?Jt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,i,e){var a=n("immediate");function s(){}var o={},c=["REJECTED"],l=["FULFILLED"],f=["PENDING"];function p(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,b!==s&&h(this,b)}function g(b,x,S){this.promise=b,typeof x=="function"&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function d(b,x,S){a(function(){var I;try{I=x(S)}catch(A){return o.reject(b,A)}I===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,I)})}function w(b){var x=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof x=="function")return function(){x.apply(b,arguments)}}function h(b,x){var S=!1;function I($){S||(S=!0,o.reject(b,$))}function A($){S||(S=!0,o.resolve(b,$))}var P=v(function(){x(A,I)});P.status==="error"&&I(P.value)}function v(b,x){var S={};try{S.value=b(x),S.status="success"}catch(I){S.status="error",S.value=I}return S}(i.exports=p).prototype.finally=function(b){if(typeof b!="function")return this;var x=this.constructor;return this.then(function(S){return x.resolve(b()).then(function(){return S})},function(S){return x.resolve(b()).then(function(){throw S})})},p.prototype.catch=function(b){return this.then(null,b)},p.prototype.then=function(b,x){if(typeof b!="function"&&this.state===l||typeof x!="function"&&this.state===c)return this;var S=new this.constructor(s);return this.state!==f?d(S,this.state===l?b:x,this.outcome):this.queue.push(new g(S,b,x)),S},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){d(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){o.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){d(this.promise,this.onRejected,b)},o.resolve=function(b,x){var S=v(w,x);if(S.status==="error")return o.reject(b,S.value);var I=S.value;if(I)h(b,I);else{b.state=l,b.outcome=x;for(var A=-1,P=b.queue.length;++A<P;)b.queue[A].callFulfilled(x)}return b},o.reject=function(b,x){b.state=c,b.outcome=x;for(var S=-1,I=b.queue.length;++S<I;)b.queue[S].callRejected(x);return b},p.resolve=function(b){return b instanceof this?b:o.resolve(new this(s),b)},p.reject=function(b){var x=new this(s);return o.reject(x,b)},p.all=function(b){var x=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,I=!1;if(!S)return this.resolve([]);for(var A=new Array(S),P=0,$=-1,B=new this(s);++$<S;)L(b[$],$);return B;function L(W,J){x.resolve(W).then(function(k){A[J]=k,++P!==S||I||(I=!0,o.resolve(B,A))},function(k){I||(I=!0,o.reject(B,k))})}},p.race=function(b){var x=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,I=!1;if(!S)return this.resolve([]);for(var A=-1,P=new this(s);++A<S;)$=b[A],x.resolve($).then(function(B){I||(I=!0,o.resolve(P,B))},function(B){I||(I=!0,o.reject(P,B))});var $;return P}},{immediate:36}],38:[function(n,i,e){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),i.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,i,e){var a=n("./zlib/deflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/messages"),l=n("./zlib/zstream"),f=Object.prototype.toString,p=0,g=-1,d=0,w=8;function h(b){if(!(this instanceof h))return new h(b);this.options=s.assign({level:g,method:w,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},b||{});var x=this.options;x.raw&&0<x.windowBits?x.windowBits=-x.windowBits:x.gzip&&0<x.windowBits&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var S=a.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(S!==p)throw new Error(c[S]);if(x.header&&a.deflateSetHeader(this.strm,x.header),x.dictionary){var I;if(I=typeof x.dictionary=="string"?o.string2buf(x.dictionary):f.call(x.dictionary)==="[object ArrayBuffer]"?new Uint8Array(x.dictionary):x.dictionary,(S=a.deflateSetDictionary(this.strm,I))!==p)throw new Error(c[S]);this._dict_set=!0}}function v(b,x){var S=new h(x);if(S.push(b,!0),S.err)throw S.msg||c[S.err];return S.result}h.prototype.push=function(b,x){var S,I,A=this.strm,P=this.options.chunkSize;if(this.ended)return!1;I=x===~~x?x:x===!0?4:0,typeof b=="string"?A.input=o.string2buf(b):f.call(b)==="[object ArrayBuffer]"?A.input=new Uint8Array(b):A.input=b,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new s.Buf8(P),A.next_out=0,A.avail_out=P),(S=a.deflate(A,I))!==1&&S!==p)return this.onEnd(S),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||I!==4&&I!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(A.output,A.next_out))):this.onData(s.shrinkBuf(A.output,A.next_out)))}while((0<A.avail_in||A.avail_out===0)&&S!==1);return I===4?(S=a.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===p):I!==2||(this.onEnd(p),!(A.avail_out=0))},h.prototype.onData=function(b){this.chunks.push(b)},h.prototype.onEnd=function(b){b===p&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},e.Deflate=h,e.deflate=v,e.deflateRaw=function(b,x){return(x=x||{}).raw=!0,v(b,x)},e.gzip=function(b,x){return(x=x||{}).gzip=!0,v(b,x)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,i,e){var a=n("./zlib/inflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/constants"),l=n("./zlib/messages"),f=n("./zlib/zstream"),p=n("./zlib/gzheader"),g=Object.prototype.toString;function d(h){if(!(this instanceof d))return new d(h);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},h||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||h&&h.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var b=a.inflateInit2(this.strm,v.windowBits);if(b!==c.Z_OK)throw new Error(l[b]);this.header=new p,a.inflateGetHeader(this.strm,this.header)}function w(h,v){var b=new d(v);if(b.push(h,!0),b.err)throw b.msg||l[b.err];return b.result}d.prototype.push=function(h,v){var b,x,S,I,A,P,$=this.strm,B=this.options.chunkSize,L=this.options.dictionary,W=!1;if(this.ended)return!1;x=v===~~v?v:v===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof h=="string"?$.input=o.binstring2buf(h):g.call(h)==="[object ArrayBuffer]"?$.input=new Uint8Array(h):$.input=h,$.next_in=0,$.avail_in=$.input.length;do{if($.avail_out===0&&($.output=new s.Buf8(B),$.next_out=0,$.avail_out=B),(b=a.inflate($,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&L&&(P=typeof L=="string"?o.string2buf(L):g.call(L)==="[object ArrayBuffer]"?new Uint8Array(L):L,b=a.inflateSetDictionary(this.strm,P)),b===c.Z_BUF_ERROR&&W===!0&&(b=c.Z_OK,W=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);$.next_out&&($.avail_out!==0&&b!==c.Z_STREAM_END&&($.avail_in!==0||x!==c.Z_FINISH&&x!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border($.output,$.next_out),I=$.next_out-S,A=o.buf2string($.output,S),$.next_out=I,$.avail_out=B-I,I&&s.arraySet($.output,$.output,S,I,0),this.onData(A)):this.onData(s.shrinkBuf($.output,$.next_out)))),$.avail_in===0&&$.avail_out===0&&(W=!0)}while((0<$.avail_in||$.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(x=c.Z_FINISH),x===c.Z_FINISH?(b=a.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):x!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!($.avail_out=0))},d.prototype.onData=function(h){this.chunks.push(h)},d.prototype.onEnd=function(h){h===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},e.Inflate=d,e.inflate=w,e.inflateRaw=function(h,v){return(v=v||{}).raw=!0,w(h,v)},e.ungzip=w},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,i,e){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";e.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var f=l.shift();if(f){if(typeof f!="object")throw new TypeError(f+"must be non-object");for(var p in f)f.hasOwnProperty(p)&&(c[p]=f[p])}}return c},e.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var s={arraySet:function(c,l,f,p,g){if(l.subarray&&c.subarray)c.set(l.subarray(f,f+p),g);else for(var d=0;d<p;d++)c[g+d]=l[f+d]},flattenChunks:function(c){var l,f,p,g,d,w;for(l=p=0,f=c.length;l<f;l++)p+=c[l].length;for(w=new Uint8Array(p),l=g=0,f=c.length;l<f;l++)d=c[l],w.set(d,g),g+=d.length;return w}},o={arraySet:function(c,l,f,p,g){for(var d=0;d<p;d++)c[g+d]=l[f+d]},flattenChunks:function(c){return[].concat.apply([],c)}};e.setTyped=function(c){c?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,s)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(a)},{}],42:[function(n,i,e){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new a.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function f(p,g){if(g<65537&&(p.subarray&&o||!p.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(p,g));for(var d="",w=0;w<g;w++)d+=String.fromCharCode(p[w]);return d}c[254]=c[254]=1,e.string2buf=function(p){var g,d,w,h,v,b=p.length,x=0;for(h=0;h<b;h++)(64512&(d=p.charCodeAt(h)))==55296&&h+1<b&&(64512&(w=p.charCodeAt(h+1)))==56320&&(d=65536+(d-55296<<10)+(w-56320),h++),x+=d<128?1:d<2048?2:d<65536?3:4;for(g=new a.Buf8(x),h=v=0;v<x;h++)(64512&(d=p.charCodeAt(h)))==55296&&h+1<b&&(64512&(w=p.charCodeAt(h+1)))==56320&&(d=65536+(d-55296<<10)+(w-56320),h++),d<128?g[v++]=d:(d<2048?g[v++]=192|d>>>6:(d<65536?g[v++]=224|d>>>12:(g[v++]=240|d>>>18,g[v++]=128|d>>>12&63),g[v++]=128|d>>>6&63),g[v++]=128|63&d);return g},e.buf2binstring=function(p){return f(p,p.length)},e.binstring2buf=function(p){for(var g=new a.Buf8(p.length),d=0,w=g.length;d<w;d++)g[d]=p.charCodeAt(d);return g},e.buf2string=function(p,g){var d,w,h,v,b=g||p.length,x=new Array(2*b);for(d=w=0;d<b;)if((h=p[d++])<128)x[w++]=h;else if(4<(v=c[h]))x[w++]=65533,d+=v-1;else{for(h&=v===2?31:v===3?15:7;1<v&&d<b;)h=h<<6|63&p[d++],v--;1<v?x[w++]=65533:h<65536?x[w++]=h:(h-=65536,x[w++]=55296|h>>10&1023,x[w++]=56320|1023&h)}return f(x,w)},e.utf8border=function(p,g){var d;for((g=g||p.length)>p.length&&(g=p.length),d=g-1;0<=d&&(192&p[d])==128;)d--;return d<0||d===0?g:d+c[p[d]]>g?d:g}},{"./common":41}],43:[function(n,i,e){i.exports=function(a,s,o,c){for(var l=65535&a|0,f=a>>>16&65535|0,p=0;o!==0;){for(o-=p=2e3<o?2e3:o;f=f+(l=l+s[c++]|0)|0,--p;);l%=65521,f%=65521}return l|f<<16|0}},{}],44:[function(n,i,e){i.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}},{}],45:[function(n,i,e){var a=(function(){for(var s,o=[],c=0;c<256;c++){s=c;for(var l=0;l<8;l++)s=1&s?3988292384^s>>>1:s>>>1;o[c]=s}return o})();i.exports=function(s,o,c,l){var f=a,p=l+c;s^=-1;for(var g=l;g<p;g++)s=s>>>8^f[255&(s^o[g])];return-1^s}},{}],46:[function(n,i,e){var a,s=n("../utils/common"),o=n("./trees"),c=n("./adler32"),l=n("./crc32"),f=n("./messages"),p=0,g=4,d=0,w=-2,h=-1,v=4,b=2,x=8,S=9,I=286,A=30,P=19,$=2*I+1,B=15,L=3,W=258,J=W+L+1,k=42,D=113,m=1,F=2,it=3,M=4;function nt(u,j){return u.msg=f[j],j}function U(u){return(u<<1)-(4<u?9:0)}function et(u){for(var j=u.length;0<=--j;)u[j]=0}function O(u){var j=u.state,z=j.pending;z>u.avail_out&&(z=u.avail_out),z!==0&&(s.arraySet(u.output,j.pending_buf,j.pending_out,z,u.next_out),u.next_out+=z,j.pending_out+=z,u.total_out+=z,u.avail_out-=z,j.pending-=z,j.pending===0&&(j.pending_out=0))}function C(u,j){o._tr_flush_block(u,0<=u.block_start?u.block_start:-1,u.strstart-u.block_start,j),u.block_start=u.strstart,O(u.strm)}function K(u,j){u.pending_buf[u.pending++]=j}function G(u,j){u.pending_buf[u.pending++]=j>>>8&255,u.pending_buf[u.pending++]=255&j}function V(u,j){var z,y,_=u.max_chain_length,E=u.strstart,q=u.prev_length,N=u.nice_match,R=u.strstart>u.w_size-J?u.strstart-(u.w_size-J):0,X=u.window,H=u.w_mask,Z=u.prev,tt=u.strstart+W,ot=X[E+q-1],at=X[E+q];u.prev_length>=u.good_match&&(_>>=2),N>u.lookahead&&(N=u.lookahead);do if(X[(z=j)+q]===at&&X[z+q-1]===ot&&X[z]===X[E]&&X[++z]===X[E+1]){E+=2,z++;do;while(X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&X[++E]===X[++z]&&E<tt);if(y=W-(tt-E),E=tt-W,q<y){if(u.match_start=j,N<=(q=y))break;ot=X[E+q-1],at=X[E+q]}}while((j=Z[j&H])>R&&--_!=0);return q<=u.lookahead?q:u.lookahead}function ut(u){var j,z,y,_,E,q,N,R,X,H,Z=u.w_size;do{if(_=u.window_size-u.lookahead-u.strstart,u.strstart>=Z+(Z-J)){for(s.arraySet(u.window,u.window,Z,Z,0),u.match_start-=Z,u.strstart-=Z,u.block_start-=Z,j=z=u.hash_size;y=u.head[--j],u.head[j]=Z<=y?y-Z:0,--z;);for(j=z=Z;y=u.prev[--j],u.prev[j]=Z<=y?y-Z:0,--z;);_+=Z}if(u.strm.avail_in===0)break;if(q=u.strm,N=u.window,R=u.strstart+u.lookahead,X=_,H=void 0,H=q.avail_in,X<H&&(H=X),z=H===0?0:(q.avail_in-=H,s.arraySet(N,q.input,q.next_in,H,R),q.state.wrap===1?q.adler=c(q.adler,N,H,R):q.state.wrap===2&&(q.adler=l(q.adler,N,H,R)),q.next_in+=H,q.total_in+=H,H),u.lookahead+=z,u.lookahead+u.insert>=L)for(E=u.strstart-u.insert,u.ins_h=u.window[E],u.ins_h=(u.ins_h<<u.hash_shift^u.window[E+1])&u.hash_mask;u.insert&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[E+L-1])&u.hash_mask,u.prev[E&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=E,E++,u.insert--,!(u.lookahead+u.insert<L)););}while(u.lookahead<J&&u.strm.avail_in!==0)}function Q(u,j){for(var z,y;;){if(u.lookahead<J){if(ut(u),u.lookahead<J&&j===p)return m;if(u.lookahead===0)break}if(z=0,u.lookahead>=L&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+L-1])&u.hash_mask,z=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),z!==0&&u.strstart-z<=u.w_size-J&&(u.match_length=V(u,z)),u.match_length>=L)if(y=o._tr_tally(u,u.strstart-u.match_start,u.match_length-L),u.lookahead-=u.match_length,u.match_length<=u.max_lazy_match&&u.lookahead>=L){for(u.match_length--;u.strstart++,u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+L-1])&u.hash_mask,z=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart,--u.match_length!=0;);u.strstart++}else u.strstart+=u.match_length,u.match_length=0,u.ins_h=u.window[u.strstart],u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+1])&u.hash_mask;else y=o._tr_tally(u,0,u.window[u.strstart]),u.lookahead--,u.strstart++;if(y&&(C(u,!1),u.strm.avail_out===0))return m}return u.insert=u.strstart<L-1?u.strstart:L-1,j===g?(C(u,!0),u.strm.avail_out===0?it:M):u.last_lit&&(C(u,!1),u.strm.avail_out===0)?m:F}function Y(u,j){for(var z,y,_;;){if(u.lookahead<J){if(ut(u),u.lookahead<J&&j===p)return m;if(u.lookahead===0)break}if(z=0,u.lookahead>=L&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+L-1])&u.hash_mask,z=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),u.prev_length=u.match_length,u.prev_match=u.match_start,u.match_length=L-1,z!==0&&u.prev_length<u.max_lazy_match&&u.strstart-z<=u.w_size-J&&(u.match_length=V(u,z),u.match_length<=5&&(u.strategy===1||u.match_length===L&&4096<u.strstart-u.match_start)&&(u.match_length=L-1)),u.prev_length>=L&&u.match_length<=u.prev_length){for(_=u.strstart+u.lookahead-L,y=o._tr_tally(u,u.strstart-1-u.prev_match,u.prev_length-L),u.lookahead-=u.prev_length-1,u.prev_length-=2;++u.strstart<=_&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+L-1])&u.hash_mask,z=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),--u.prev_length!=0;);if(u.match_available=0,u.match_length=L-1,u.strstart++,y&&(C(u,!1),u.strm.avail_out===0))return m}else if(u.match_available){if((y=o._tr_tally(u,0,u.window[u.strstart-1]))&&C(u,!1),u.strstart++,u.lookahead--,u.strm.avail_out===0)return m}else u.match_available=1,u.strstart++,u.lookahead--}return u.match_available&&(y=o._tr_tally(u,0,u.window[u.strstart-1]),u.match_available=0),u.insert=u.strstart<L-1?u.strstart:L-1,j===g?(C(u,!0),u.strm.avail_out===0?it:M):u.last_lit&&(C(u,!1),u.strm.avail_out===0)?m:F}function rt(u,j,z,y,_){this.good_length=u,this.max_lazy=j,this.nice_length=z,this.max_chain=y,this.func=_}function ct(){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=x,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 s.Buf16(2*$),this.dyn_dtree=new s.Buf16(2*(2*A+1)),this.bl_tree=new s.Buf16(2*(2*P+1)),et(this.dyn_ltree),et(this.dyn_dtree),et(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(B+1),this.heap=new s.Buf16(2*I+1),et(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*I+1),et(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 st(u){var j;return u&&u.state?(u.total_in=u.total_out=0,u.data_type=b,(j=u.state).pending=0,j.pending_out=0,j.wrap<0&&(j.wrap=-j.wrap),j.status=j.wrap?k:D,u.adler=j.wrap===2?0:1,j.last_flush=p,o._tr_init(j),d):nt(u,w)}function pt(u){var j=st(u);return j===d&&(function(z){z.window_size=2*z.w_size,et(z.head),z.max_lazy_match=a[z.level].max_lazy,z.good_match=a[z.level].good_length,z.nice_match=a[z.level].nice_length,z.max_chain_length=a[z.level].max_chain,z.strstart=0,z.block_start=0,z.lookahead=0,z.insert=0,z.match_length=z.prev_length=L-1,z.match_available=0,z.ins_h=0})(u.state),j}function ht(u,j,z,y,_,E){if(!u)return w;var q=1;if(j===h&&(j=6),y<0?(q=0,y=-y):15<y&&(q=2,y-=16),_<1||S<_||z!==x||y<8||15<y||j<0||9<j||E<0||v<E)return nt(u,w);y===8&&(y=9);var N=new ct;return(u.state=N).strm=u,N.wrap=q,N.gzhead=null,N.w_bits=y,N.w_size=1<<N.w_bits,N.w_mask=N.w_size-1,N.hash_bits=_+7,N.hash_size=1<<N.hash_bits,N.hash_mask=N.hash_size-1,N.hash_shift=~~((N.hash_bits+L-1)/L),N.window=new s.Buf8(2*N.w_size),N.head=new s.Buf16(N.hash_size),N.prev=new s.Buf16(N.w_size),N.lit_bufsize=1<<_+6,N.pending_buf_size=4*N.lit_bufsize,N.pending_buf=new s.Buf8(N.pending_buf_size),N.d_buf=1*N.lit_bufsize,N.l_buf=3*N.lit_bufsize,N.level=j,N.strategy=E,N.method=z,pt(u)}a=[new rt(0,0,0,0,function(u,j){var z=65535;for(z>u.pending_buf_size-5&&(z=u.pending_buf_size-5);;){if(u.lookahead<=1){if(ut(u),u.lookahead===0&&j===p)return m;if(u.lookahead===0)break}u.strstart+=u.lookahead,u.lookahead=0;var y=u.block_start+z;if((u.strstart===0||u.strstart>=y)&&(u.lookahead=u.strstart-y,u.strstart=y,C(u,!1),u.strm.avail_out===0)||u.strstart-u.block_start>=u.w_size-J&&(C(u,!1),u.strm.avail_out===0))return m}return u.insert=0,j===g?(C(u,!0),u.strm.avail_out===0?it:M):(u.strstart>u.block_start&&(C(u,!1),u.strm.avail_out),m)}),new rt(4,4,8,4,Q),new rt(4,5,16,8,Q),new rt(4,6,32,32,Q),new rt(4,4,16,16,Y),new rt(8,16,32,32,Y),new rt(8,16,128,128,Y),new rt(8,32,128,256,Y),new rt(32,128,258,1024,Y),new rt(32,258,258,4096,Y)],e.deflateInit=function(u,j){return ht(u,j,x,15,8,0)},e.deflateInit2=ht,e.deflateReset=pt,e.deflateResetKeep=st,e.deflateSetHeader=function(u,j){return u&&u.state?u.state.wrap!==2?w:(u.state.gzhead=j,d):w},e.deflate=function(u,j){var z,y,_,E;if(!u||!u.state||5<j||j<0)return u?nt(u,w):w;if(y=u.state,!u.output||!u.input&&u.avail_in!==0||y.status===666&&j!==g)return nt(u,u.avail_out===0?-5:w);if(y.strm=u,z=y.last_flush,y.last_flush=j,y.status===k)if(y.wrap===2)u.adler=0,K(y,31),K(y,139),K(y,8),y.gzhead?(K(y,(y.gzhead.text?1:0)+(y.gzhead.hcrc?2:0)+(y.gzhead.extra?4:0)+(y.gzhead.name?8:0)+(y.gzhead.comment?16:0)),K(y,255&y.gzhead.time),K(y,y.gzhead.time>>8&255),K(y,y.gzhead.time>>16&255),K(y,y.gzhead.time>>24&255),K(y,y.level===9?2:2<=y.strategy||y.level<2?4:0),K(y,255&y.gzhead.os),y.gzhead.extra&&y.gzhead.extra.length&&(K(y,255&y.gzhead.extra.length),K(y,y.gzhead.extra.length>>8&255)),y.gzhead.hcrc&&(u.adler=l(u.adler,y.pending_buf,y.pending,0)),y.gzindex=0,y.status=69):(K(y,0),K(y,0),K(y,0),K(y,0),K(y,0),K(y,y.level===9?2:2<=y.strategy||y.level<2?4:0),K(y,3),y.status=D);else{var q=x+(y.w_bits-8<<4)<<8;q|=(2<=y.strategy||y.level<2?0:y.level<6?1:y.level===6?2:3)<<6,y.strstart!==0&&(q|=32),q+=31-q%31,y.status=D,G(y,q),y.strstart!==0&&(G(y,u.adler>>>16),G(y,65535&u.adler)),u.adler=1}if(y.status===69)if(y.gzhead.extra){for(_=y.pending;y.gzindex<(65535&y.gzhead.extra.length)&&(y.pending!==y.pending_buf_size||(y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),O(u),_=y.pending,y.pending!==y.pending_buf_size));)K(y,255&y.gzhead.extra[y.gzindex]),y.gzindex++;y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),y.gzindex===y.gzhead.extra.length&&(y.gzindex=0,y.status=73)}else y.status=73;if(y.status===73)if(y.gzhead.name){_=y.pending;do{if(y.pending===y.pending_buf_size&&(y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),O(u),_=y.pending,y.pending===y.pending_buf_size)){E=1;break}E=y.gzindex<y.gzhead.name.length?255&y.gzhead.name.charCodeAt(y.gzindex++):0,K(y,E)}while(E!==0);y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),E===0&&(y.gzindex=0,y.status=91)}else y.status=91;if(y.status===91)if(y.gzhead.comment){_=y.pending;do{if(y.pending===y.pending_buf_size&&(y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),O(u),_=y.pending,y.pending===y.pending_buf_size)){E=1;break}E=y.gzindex<y.gzhead.comment.length?255&y.gzhead.comment.charCodeAt(y.gzindex++):0,K(y,E)}while(E!==0);y.gzhead.hcrc&&y.pending>_&&(u.adler=l(u.adler,y.pending_buf,y.pending-_,_)),E===0&&(y.status=103)}else y.status=103;if(y.status===103&&(y.gzhead.hcrc?(y.pending+2>y.pending_buf_size&&O(u),y.pending+2<=y.pending_buf_size&&(K(y,255&u.adler),K(y,u.adler>>8&255),u.adler=0,y.status=D)):y.status=D),y.pending!==0){if(O(u),u.avail_out===0)return y.last_flush=-1,d}else if(u.avail_in===0&&U(j)<=U(z)&&j!==g)return nt(u,-5);if(y.status===666&&u.avail_in!==0)return nt(u,-5);if(u.avail_in!==0||y.lookahead!==0||j!==p&&y.status!==666){var N=y.strategy===2?(function(R,X){for(var H;;){if(R.lookahead===0&&(ut(R),R.lookahead===0)){if(X===p)return m;break}if(R.match_length=0,H=o._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++,H&&(C(R,!1),R.strm.avail_out===0))return m}return R.insert=0,X===g?(C(R,!0),R.strm.avail_out===0?it:M):R.last_lit&&(C(R,!1),R.strm.avail_out===0)?m:F})(y,j):y.strategy===3?(function(R,X){for(var H,Z,tt,ot,at=R.window;;){if(R.lookahead<=W){if(ut(R),R.lookahead<=W&&X===p)return m;if(R.lookahead===0)break}if(R.match_length=0,R.lookahead>=L&&0<R.strstart&&(Z=at[tt=R.strstart-1])===at[++tt]&&Z===at[++tt]&&Z===at[++tt]){ot=R.strstart+W;do;while(Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&Z===at[++tt]&&tt<ot);R.match_length=W-(ot-tt),R.match_length>R.lookahead&&(R.match_length=R.lookahead)}if(R.match_length>=L?(H=o._tr_tally(R,1,R.match_length-L),R.lookahead-=R.match_length,R.strstart+=R.match_length,R.match_length=0):(H=o._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++),H&&(C(R,!1),R.strm.avail_out===0))return m}return R.insert=0,X===g?(C(R,!0),R.strm.avail_out===0?it:M):R.last_lit&&(C(R,!1),R.strm.avail_out===0)?m:F})(y,j):a[y.level].func(y,j);if(N!==it&&N!==M||(y.status=666),N===m||N===it)return u.avail_out===0&&(y.last_flush=-1),d;if(N===F&&(j===1?o._tr_align(y):j!==5&&(o._tr_stored_block(y,0,0,!1),j===3&&(et(y.head),y.lookahead===0&&(y.strstart=0,y.block_start=0,y.insert=0))),O(u),u.avail_out===0))return y.last_flush=-1,d}return j!==g?d:y.wrap<=0?1:(y.wrap===2?(K(y,255&u.adler),K(y,u.adler>>8&255),K(y,u.adler>>16&255),K(y,u.adler>>24&255),K(y,255&u.total_in),K(y,u.total_in>>8&255),K(y,u.total_in>>16&255),K(y,u.total_in>>24&255)):(G(y,u.adler>>>16),G(y,65535&u.adler)),O(u),0<y.wrap&&(y.wrap=-y.wrap),y.pending!==0?d:1)},e.deflateEnd=function(u){var j;return u&&u.state?(j=u.state.status)!==k&&j!==69&&j!==73&&j!==91&&j!==103&&j!==D&&j!==666?nt(u,w):(u.state=null,j===D?nt(u,-3):d):w},e.deflateSetDictionary=function(u,j){var z,y,_,E,q,N,R,X,H=j.length;if(!u||!u.state||(E=(z=u.state).wrap)===2||E===1&&z.status!==k||z.lookahead)return w;for(E===1&&(u.adler=c(u.adler,j,H,0)),z.wrap=0,H>=z.w_size&&(E===0&&(et(z.head),z.strstart=0,z.block_start=0,z.insert=0),X=new s.Buf8(z.w_size),s.arraySet(X,j,H-z.w_size,z.w_size,0),j=X,H=z.w_size),q=u.avail_in,N=u.next_in,R=u.input,u.avail_in=H,u.next_in=0,u.input=j,ut(z);z.lookahead>=L;){for(y=z.strstart,_=z.lookahead-(L-1);z.ins_h=(z.ins_h<<z.hash_shift^z.window[y+L-1])&z.hash_mask,z.prev[y&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=y,y++,--_;);z.strstart=y,z.lookahead=L-1,ut(z)}return z.strstart+=z.lookahead,z.block_start=z.strstart,z.insert=z.lookahead,z.lookahead=0,z.match_length=z.prev_length=L-1,z.match_available=0,u.next_in=N,u.input=R,u.avail_in=q,z.wrap=E,d},e.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,i,e){i.exports=function(){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}},{}],48:[function(n,i,e){i.exports=function(a,s){var o,c,l,f,p,g,d,w,h,v,b,x,S,I,A,P,$,B,L,W,J,k,D,m,F;o=a.state,c=a.next_in,m=a.input,l=c+(a.avail_in-5),f=a.next_out,F=a.output,p=f-(s-a.avail_out),g=f+(a.avail_out-257),d=o.dmax,w=o.wsize,h=o.whave,v=o.wnext,b=o.window,x=o.hold,S=o.bits,I=o.lencode,A=o.distcode,P=(1<<o.lenbits)-1,$=(1<<o.distbits)-1;t:do{S<15&&(x+=m[c++]<<S,S+=8,x+=m[c++]<<S,S+=8),B=I[x&P];e:for(;;){if(x>>>=L=B>>>24,S-=L,(L=B>>>16&255)===0)F[f++]=65535&B;else{if(!(16&L)){if((64&L)==0){B=I[(65535&B)+(x&(1<<L)-1)];continue e}if(32&L){o.mode=12;break t}a.msg="invalid literal/length code",o.mode=30;break t}W=65535&B,(L&=15)&&(S<L&&(x+=m[c++]<<S,S+=8),W+=x&(1<<L)-1,x>>>=L,S-=L),S<15&&(x+=m[c++]<<S,S+=8,x+=m[c++]<<S,S+=8),B=A[x&$];n:for(;;){if(x>>>=L=B>>>24,S-=L,!(16&(L=B>>>16&255))){if((64&L)==0){B=A[(65535&B)+(x&(1<<L)-1)];continue n}a.msg="invalid distance code",o.mode=30;break t}if(J=65535&B,S<(L&=15)&&(x+=m[c++]<<S,(S+=8)<L&&(x+=m[c++]<<S,S+=8)),d<(J+=x&(1<<L)-1)){a.msg="invalid distance too far back",o.mode=30;break t}if(x>>>=L,S-=L,(L=f-p)<J){if(h<(L=J-L)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break t}if(D=b,(k=0)===v){if(k+=w-L,L<W){for(W-=L;F[f++]=b[k++],--L;);k=f-J,D=F}}else if(v<L){if(k+=w+v-L,(L-=v)<W){for(W-=L;F[f++]=b[k++],--L;);if(k=0,v<W){for(W-=L=v;F[f++]=b[k++],--L;);k=f-J,D=F}}}else if(k+=v-L,L<W){for(W-=L;F[f++]=b[k++],--L;);k=f-J,D=F}for(;2<W;)F[f++]=D[k++],F[f++]=D[k++],F[f++]=D[k++],W-=3;W&&(F[f++]=D[k++],1<W&&(F[f++]=D[k++]))}else{for(k=f-J;F[f++]=F[k++],F[f++]=F[k++],F[f++]=F[k++],2<(W-=3););W&&(F[f++]=F[k++],1<W&&(F[f++]=F[k++]))}break}}break}}while(c<l&&f<g);c-=W=S>>3,x&=(1<<(S-=W<<3))-1,a.next_in=c,a.next_out=f,a.avail_in=c<l?l-c+5:5-(c-l),a.avail_out=f<g?g-f+257:257-(f-g),o.hold=x,o.bits=S}},{}],49:[function(n,i,e){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),c=n("./inffast"),l=n("./inftrees"),f=1,p=2,g=0,d=-2,w=1,h=852,v=592;function b(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function x(){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 a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(k){var D;return k&&k.state?(D=k.state,k.total_in=k.total_out=D.total=0,k.msg="",D.wrap&&(k.adler=1&D.wrap),D.mode=w,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new a.Buf32(h),D.distcode=D.distdyn=new a.Buf32(v),D.sane=1,D.back=-1,g):d}function I(k){var D;return k&&k.state?((D=k.state).wsize=0,D.whave=0,D.wnext=0,S(k)):d}function A(k,D){var m,F;return k&&k.state?(F=k.state,D<0?(m=0,D=-D):(m=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?d:(F.window!==null&&F.wbits!==D&&(F.window=null),F.wrap=m,F.wbits=D,I(k))):d}function P(k,D){var m,F;return k?(F=new x,(k.state=F).window=null,(m=A(k,D))!==g&&(k.state=null),m):d}var $,B,L=!0;function W(k){if(L){var D;for($=new a.Buf32(512),B=new a.Buf32(32),D=0;D<144;)k.lens[D++]=8;for(;D<256;)k.lens[D++]=9;for(;D<280;)k.lens[D++]=7;for(;D<288;)k.lens[D++]=8;for(l(f,k.lens,0,288,$,0,k.work,{bits:9}),D=0;D<32;)k.lens[D++]=5;l(p,k.lens,0,32,B,0,k.work,{bits:5}),L=!1}k.lencode=$,k.lenbits=9,k.distcode=B,k.distbits=5}function J(k,D,m,F){var it,M=k.state;return M.window===null&&(M.wsize=1<<M.wbits,M.wnext=0,M.whave=0,M.window=new a.Buf8(M.wsize)),F>=M.wsize?(a.arraySet(M.window,D,m-M.wsize,M.wsize,0),M.wnext=0,M.whave=M.wsize):(F<(it=M.wsize-M.wnext)&&(it=F),a.arraySet(M.window,D,m-F,it,M.wnext),(F-=it)?(a.arraySet(M.window,D,m-F,F,0),M.wnext=F,M.whave=M.wsize):(M.wnext+=it,M.wnext===M.wsize&&(M.wnext=0),M.whave<M.wsize&&(M.whave+=it))),0}e.inflateReset=I,e.inflateReset2=A,e.inflateResetKeep=S,e.inflateInit=function(k){return P(k,15)},e.inflateInit2=P,e.inflate=function(k,D){var m,F,it,M,nt,U,et,O,C,K,G,V,ut,Q,Y,rt,ct,st,pt,ht,u,j,z,y,_=0,E=new a.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return d;(m=k.state).mode===12&&(m.mode=13),nt=k.next_out,it=k.output,et=k.avail_out,M=k.next_in,F=k.input,U=k.avail_in,O=m.hold,C=m.bits,K=U,G=et,j=g;t:for(;;)switch(m.mode){case w:if(m.wrap===0){m.mode=13;break}for(;C<16;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(2&m.wrap&&O===35615){E[m.check=0]=255&O,E[1]=O>>>8&255,m.check=o(m.check,E,2,0),C=O=0,m.mode=2;break}if(m.flags=0,m.head&&(m.head.done=!1),!(1&m.wrap)||(((255&O)<<8)+(O>>8))%31){k.msg="incorrect header check",m.mode=30;break}if((15&O)!=8){k.msg="unknown compression method",m.mode=30;break}if(C-=4,u=8+(15&(O>>>=4)),m.wbits===0)m.wbits=u;else if(u>m.wbits){k.msg="invalid window size",m.mode=30;break}m.dmax=1<<u,k.adler=m.check=1,m.mode=512&O?10:12,C=O=0;break;case 2:for(;C<16;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(m.flags=O,(255&m.flags)!=8){k.msg="unknown compression method",m.mode=30;break}if(57344&m.flags){k.msg="unknown header flags set",m.mode=30;break}m.head&&(m.head.text=O>>8&1),512&m.flags&&(E[0]=255&O,E[1]=O>>>8&255,m.check=o(m.check,E,2,0)),C=O=0,m.mode=3;case 3:for(;C<32;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.head&&(m.head.time=O),512&m.flags&&(E[0]=255&O,E[1]=O>>>8&255,E[2]=O>>>16&255,E[3]=O>>>24&255,m.check=o(m.check,E,4,0)),C=O=0,m.mode=4;case 4:for(;C<16;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.head&&(m.head.xflags=255&O,m.head.os=O>>8),512&m.flags&&(E[0]=255&O,E[1]=O>>>8&255,m.check=o(m.check,E,2,0)),C=O=0,m.mode=5;case 5:if(1024&m.flags){for(;C<16;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.length=O,m.head&&(m.head.extra_len=O),512&m.flags&&(E[0]=255&O,E[1]=O>>>8&255,m.check=o(m.check,E,2,0)),C=O=0}else m.head&&(m.head.extra=null);m.mode=6;case 6:if(1024&m.flags&&(U<(V=m.length)&&(V=U),V&&(m.head&&(u=m.head.extra_len-m.length,m.head.extra||(m.head.extra=new Array(m.head.extra_len)),a.arraySet(m.head.extra,F,M,V,u)),512&m.flags&&(m.check=o(m.check,F,V,M)),U-=V,M+=V,m.length-=V),m.length))break t;m.length=0,m.mode=7;case 7:if(2048&m.flags){if(U===0)break t;for(V=0;u=F[M+V++],m.head&&u&&m.length<65536&&(m.head.name+=String.fromCharCode(u)),u&&V<U;);if(512&m.flags&&(m.check=o(m.check,F,V,M)),U-=V,M+=V,u)break t}else m.head&&(m.head.name=null);m.length=0,m.mode=8;case 8:if(4096&m.flags){if(U===0)break t;for(V=0;u=F[M+V++],m.head&&u&&m.length<65536&&(m.head.comment+=String.fromCharCode(u)),u&&V<U;);if(512&m.flags&&(m.check=o(m.check,F,V,M)),U-=V,M+=V,u)break t}else m.head&&(m.head.comment=null);m.mode=9;case 9:if(512&m.flags){for(;C<16;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(O!==(65535&m.check)){k.msg="header crc mismatch",m.mode=30;break}C=O=0}m.head&&(m.head.hcrc=m.flags>>9&1,m.head.done=!0),k.adler=m.check=0,m.mode=12;break;case 10:for(;C<32;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}k.adler=m.check=b(O),C=O=0,m.mode=11;case 11:if(m.havedict===0)return k.next_out=nt,k.avail_out=et,k.next_in=M,k.avail_in=U,m.hold=O,m.bits=C,2;k.adler=m.check=1,m.mode=12;case 12:if(D===5||D===6)break t;case 13:if(m.last){O>>>=7&C,C-=7&C,m.mode=27;break}for(;C<3;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}switch(m.last=1&O,C-=1,3&(O>>>=1)){case 0:m.mode=14;break;case 1:if(W(m),m.mode=20,D!==6)break;O>>>=2,C-=2;break t;case 2:m.mode=17;break;case 3:k.msg="invalid block type",m.mode=30}O>>>=2,C-=2;break;case 14:for(O>>>=7&C,C-=7&C;C<32;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if((65535&O)!=(O>>>16^65535)){k.msg="invalid stored block lengths",m.mode=30;break}if(m.length=65535&O,C=O=0,m.mode=15,D===6)break t;case 15:m.mode=16;case 16:if(V=m.length){if(U<V&&(V=U),et<V&&(V=et),V===0)break t;a.arraySet(it,F,M,V,nt),U-=V,M+=V,et-=V,nt+=V,m.length-=V;break}m.mode=12;break;case 17:for(;C<14;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(m.nlen=257+(31&O),O>>>=5,C-=5,m.ndist=1+(31&O),O>>>=5,C-=5,m.ncode=4+(15&O),O>>>=4,C-=4,286<m.nlen||30<m.ndist){k.msg="too many length or distance symbols",m.mode=30;break}m.have=0,m.mode=18;case 18:for(;m.have<m.ncode;){for(;C<3;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.lens[q[m.have++]]=7&O,O>>>=3,C-=3}for(;m.have<19;)m.lens[q[m.have++]]=0;if(m.lencode=m.lendyn,m.lenbits=7,z={bits:m.lenbits},j=l(0,m.lens,0,19,m.lencode,0,m.work,z),m.lenbits=z.bits,j){k.msg="invalid code lengths set",m.mode=30;break}m.have=0,m.mode=19;case 19:for(;m.have<m.nlen+m.ndist;){for(;rt=(_=m.lencode[O&(1<<m.lenbits)-1])>>>16&255,ct=65535&_,!((Y=_>>>24)<=C);){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(ct<16)O>>>=Y,C-=Y,m.lens[m.have++]=ct;else{if(ct===16){for(y=Y+2;C<y;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(O>>>=Y,C-=Y,m.have===0){k.msg="invalid bit length repeat",m.mode=30;break}u=m.lens[m.have-1],V=3+(3&O),O>>>=2,C-=2}else if(ct===17){for(y=Y+3;C<y;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}C-=Y,u=0,V=3+(7&(O>>>=Y)),O>>>=3,C-=3}else{for(y=Y+7;C<y;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}C-=Y,u=0,V=11+(127&(O>>>=Y)),O>>>=7,C-=7}if(m.have+V>m.nlen+m.ndist){k.msg="invalid bit length repeat",m.mode=30;break}for(;V--;)m.lens[m.have++]=u}}if(m.mode===30)break;if(m.lens[256]===0){k.msg="invalid code -- missing end-of-block",m.mode=30;break}if(m.lenbits=9,z={bits:m.lenbits},j=l(f,m.lens,0,m.nlen,m.lencode,0,m.work,z),m.lenbits=z.bits,j){k.msg="invalid literal/lengths set",m.mode=30;break}if(m.distbits=6,m.distcode=m.distdyn,z={bits:m.distbits},j=l(p,m.lens,m.nlen,m.ndist,m.distcode,0,m.work,z),m.distbits=z.bits,j){k.msg="invalid distances set",m.mode=30;break}if(m.mode=20,D===6)break t;case 20:m.mode=21;case 21:if(6<=U&&258<=et){k.next_out=nt,k.avail_out=et,k.next_in=M,k.avail_in=U,m.hold=O,m.bits=C,c(k,G),nt=k.next_out,it=k.output,et=k.avail_out,M=k.next_in,F=k.input,U=k.avail_in,O=m.hold,C=m.bits,m.mode===12&&(m.back=-1);break}for(m.back=0;rt=(_=m.lencode[O&(1<<m.lenbits)-1])>>>16&255,ct=65535&_,!((Y=_>>>24)<=C);){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(rt&&(240&rt)==0){for(st=Y,pt=rt,ht=ct;rt=(_=m.lencode[ht+((O&(1<<st+pt)-1)>>st)])>>>16&255,ct=65535&_,!(st+(Y=_>>>24)<=C);){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}O>>>=st,C-=st,m.back+=st}if(O>>>=Y,C-=Y,m.back+=Y,m.length=ct,rt===0){m.mode=26;break}if(32&rt){m.back=-1,m.mode=12;break}if(64&rt){k.msg="invalid literal/length code",m.mode=30;break}m.extra=15&rt,m.mode=22;case 22:if(m.extra){for(y=m.extra;C<y;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.length+=O&(1<<m.extra)-1,O>>>=m.extra,C-=m.extra,m.back+=m.extra}m.was=m.length,m.mode=23;case 23:for(;rt=(_=m.distcode[O&(1<<m.distbits)-1])>>>16&255,ct=65535&_,!((Y=_>>>24)<=C);){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if((240&rt)==0){for(st=Y,pt=rt,ht=ct;rt=(_=m.distcode[ht+((O&(1<<st+pt)-1)>>st)])>>>16&255,ct=65535&_,!(st+(Y=_>>>24)<=C);){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}O>>>=st,C-=st,m.back+=st}if(O>>>=Y,C-=Y,m.back+=Y,64&rt){k.msg="invalid distance code",m.mode=30;break}m.offset=ct,m.extra=15&rt,m.mode=24;case 24:if(m.extra){for(y=m.extra;C<y;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}m.offset+=O&(1<<m.extra)-1,O>>>=m.extra,C-=m.extra,m.back+=m.extra}if(m.offset>m.dmax){k.msg="invalid distance too far back",m.mode=30;break}m.mode=25;case 25:if(et===0)break t;if(V=G-et,m.offset>V){if((V=m.offset-V)>m.whave&&m.sane){k.msg="invalid distance too far back",m.mode=30;break}ut=V>m.wnext?(V-=m.wnext,m.wsize-V):m.wnext-V,V>m.length&&(V=m.length),Q=m.window}else Q=it,ut=nt-m.offset,V=m.length;for(et<V&&(V=et),et-=V,m.length-=V;it[nt++]=Q[ut++],--V;);m.length===0&&(m.mode=21);break;case 26:if(et===0)break t;it[nt++]=m.length,et--,m.mode=21;break;case 27:if(m.wrap){for(;C<32;){if(U===0)break t;U--,O|=F[M++]<<C,C+=8}if(G-=et,k.total_out+=G,m.total+=G,G&&(k.adler=m.check=m.flags?o(m.check,it,G,nt-G):s(m.check,it,G,nt-G)),G=et,(m.flags?O:b(O))!==m.check){k.msg="incorrect data check",m.mode=30;break}C=O=0}m.mode=28;case 28:if(m.wrap&&m.flags){for(;C<32;){if(U===0)break t;U--,O+=F[M++]<<C,C+=8}if(O!==(4294967295&m.total)){k.msg="incorrect length check",m.mode=30;break}C=O=0}m.mode=29;case 29:j=1;break t;case 30:j=-3;break t;case 31:return-4;default:return d}return k.next_out=nt,k.avail_out=et,k.next_in=M,k.avail_in=U,m.hold=O,m.bits=C,(m.wsize||G!==k.avail_out&&m.mode<30&&(m.mode<27||D!==4))&&J(k,k.output,k.next_out,G-k.avail_out)?(m.mode=31,-4):(K-=k.avail_in,G-=k.avail_out,k.total_in+=K,k.total_out+=G,m.total+=G,m.wrap&&G&&(k.adler=m.check=m.flags?o(m.check,it,G,k.next_out-G):s(m.check,it,G,k.next_out-G)),k.data_type=m.bits+(m.last?64:0)+(m.mode===12?128:0)+(m.mode===20||m.mode===15?256:0),(K==0&&G===0||D===4)&&j===g&&(j=-5),j)},e.inflateEnd=function(k){if(!k||!k.state)return d;var D=k.state;return D.window&&(D.window=null),k.state=null,g},e.inflateGetHeader=function(k,D){var m;return k&&k.state?(2&(m=k.state).wrap)==0?d:((m.head=D).done=!1,g):d},e.inflateSetDictionary=function(k,D){var m,F=D.length;return k&&k.state?(m=k.state).wrap!==0&&m.mode!==11?d:m.mode===11&&s(1,D,F,0)!==m.check?-3:J(k,D,F,F)?(m.mode=31,-4):(m.havedict=1,g):d},e.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,i,e){var a=n("../utils/common"),s=[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],o=[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],c=[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],l=[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];i.exports=function(f,p,g,d,w,h,v,b){var x,S,I,A,P,$,B,L,W,J=b.bits,k=0,D=0,m=0,F=0,it=0,M=0,nt=0,U=0,et=0,O=0,C=null,K=0,G=new a.Buf16(16),V=new a.Buf16(16),ut=null,Q=0;for(k=0;k<=15;k++)G[k]=0;for(D=0;D<d;D++)G[p[g+D]]++;for(it=J,F=15;1<=F&&G[F]===0;F--);if(F<it&&(it=F),F===0)return w[h++]=20971520,w[h++]=20971520,b.bits=1,0;for(m=1;m<F&&G[m]===0;m++);for(it<m&&(it=m),k=U=1;k<=15;k++)if(U<<=1,(U-=G[k])<0)return-1;if(0<U&&(f===0||F!==1))return-1;for(V[1]=0,k=1;k<15;k++)V[k+1]=V[k]+G[k];for(D=0;D<d;D++)p[g+D]!==0&&(v[V[p[g+D]]++]=D);if($=f===0?(C=ut=v,19):f===1?(C=s,K-=257,ut=o,Q-=257,256):(C=c,ut=l,-1),k=m,P=h,nt=D=O=0,I=-1,A=(et=1<<(M=it))-1,f===1&&852<et||f===2&&592<et)return 1;for(;;){for(B=k-nt,W=v[D]<$?(L=0,v[D]):v[D]>$?(L=ut[Q+v[D]],C[K+v[D]]):(L=96,0),x=1<<k-nt,m=S=1<<M;w[P+(O>>nt)+(S-=x)]=B<<24|L<<16|W|0,S!==0;);for(x=1<<k-1;O&x;)x>>=1;if(x!==0?(O&=x-1,O+=x):O=0,D++,--G[k]==0){if(k===F)break;k=p[g+v[D]]}if(it<k&&(O&A)!==I){for(nt===0&&(nt=it),P+=m,U=1<<(M=k-nt);M+nt<F&&!((U-=G[M+nt])<=0);)M++,U<<=1;if(et+=1<<M,f===1&&852<et||f===2&&592<et)return 1;w[I=O&A]=it<<24|M<<16|P-h|0}}return O!==0&&(w[P+O]=k-nt<<24|64<<16|0),b.bits=it,0}},{"../utils/common":41}],51:[function(n,i,e){i.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"}},{}],52:[function(n,i,e){var a=n("../utils/common"),s=0,o=1;function c(_){for(var E=_.length;0<=--E;)_[E]=0}var l=0,f=29,p=256,g=p+1+f,d=30,w=19,h=2*g+1,v=15,b=16,x=7,S=256,I=16,A=17,P=18,$=[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],B=[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],L=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],J=new Array(2*(g+2));c(J);var k=new Array(2*d);c(k);var D=new Array(512);c(D);var m=new Array(256);c(m);var F=new Array(f);c(F);var it,M,nt,U=new Array(d);function et(_,E,q,N,R){this.static_tree=_,this.extra_bits=E,this.extra_base=q,this.elems=N,this.max_length=R,this.has_stree=_&&_.length}function O(_,E){this.dyn_tree=_,this.max_code=0,this.stat_desc=E}function C(_){return _<256?D[_]:D[256+(_>>>7)]}function K(_,E){_.pending_buf[_.pending++]=255&E,_.pending_buf[_.pending++]=E>>>8&255}function G(_,E,q){_.bi_valid>b-q?(_.bi_buf|=E<<_.bi_valid&65535,K(_,_.bi_buf),_.bi_buf=E>>b-_.bi_valid,_.bi_valid+=q-b):(_.bi_buf|=E<<_.bi_valid&65535,_.bi_valid+=q)}function V(_,E,q){G(_,q[2*E],q[2*E+1])}function ut(_,E){for(var q=0;q|=1&_,_>>>=1,q<<=1,0<--E;);return q>>>1}function Q(_,E,q){var N,R,X=new Array(v+1),H=0;for(N=1;N<=v;N++)X[N]=H=H+q[N-1]<<1;for(R=0;R<=E;R++){var Z=_[2*R+1];Z!==0&&(_[2*R]=ut(X[Z]++,Z))}}function Y(_){var E;for(E=0;E<g;E++)_.dyn_ltree[2*E]=0;for(E=0;E<d;E++)_.dyn_dtree[2*E]=0;for(E=0;E<w;E++)_.bl_tree[2*E]=0;_.dyn_ltree[2*S]=1,_.opt_len=_.static_len=0,_.last_lit=_.matches=0}function rt(_){8<_.bi_valid?K(_,_.bi_buf):0<_.bi_valid&&(_.pending_buf[_.pending++]=_.bi_buf),_.bi_buf=0,_.bi_valid=0}function ct(_,E,q,N){var R=2*E,X=2*q;return _[R]<_[X]||_[R]===_[X]&&N[E]<=N[q]}function st(_,E,q){for(var N=_.heap[q],R=q<<1;R<=_.heap_len&&(R<_.heap_len&&ct(E,_.heap[R+1],_.heap[R],_.depth)&&R++,!ct(E,N,_.heap[R],_.depth));)_.heap[q]=_.heap[R],q=R,R<<=1;_.heap[q]=N}function pt(_,E,q){var N,R,X,H,Z=0;if(_.last_lit!==0)for(;N=_.pending_buf[_.d_buf+2*Z]<<8|_.pending_buf[_.d_buf+2*Z+1],R=_.pending_buf[_.l_buf+Z],Z++,N===0?V(_,R,E):(V(_,(X=m[R])+p+1,E),(H=$[X])!==0&&G(_,R-=F[X],H),V(_,X=C(--N),q),(H=B[X])!==0&&G(_,N-=U[X],H)),Z<_.last_lit;);V(_,S,E)}function ht(_,E){var q,N,R,X=E.dyn_tree,H=E.stat_desc.static_tree,Z=E.stat_desc.has_stree,tt=E.stat_desc.elems,ot=-1;for(_.heap_len=0,_.heap_max=h,q=0;q<tt;q++)X[2*q]!==0?(_.heap[++_.heap_len]=ot=q,_.depth[q]=0):X[2*q+1]=0;for(;_.heap_len<2;)X[2*(R=_.heap[++_.heap_len]=ot<2?++ot:0)]=1,_.depth[R]=0,_.opt_len--,Z&&(_.static_len-=H[2*R+1]);for(E.max_code=ot,q=_.heap_len>>1;1<=q;q--)st(_,X,q);for(R=tt;q=_.heap[1],_.heap[1]=_.heap[_.heap_len--],st(_,X,1),N=_.heap[1],_.heap[--_.heap_max]=q,_.heap[--_.heap_max]=N,X[2*R]=X[2*q]+X[2*N],_.depth[R]=(_.depth[q]>=_.depth[N]?_.depth[q]:_.depth[N])+1,X[2*q+1]=X[2*N+1]=R,_.heap[1]=R++,st(_,X,1),2<=_.heap_len;);_.heap[--_.heap_max]=_.heap[1],(function(at,gt){var jt,_t,Ft,dt,Gt,xe,xt=gt.dyn_tree,bn=gt.max_code,Di=gt.stat_desc.static_tree,Pi=gt.stat_desc.has_stree,ji=gt.stat_desc.extra_bits,vn=gt.stat_desc.extra_base,qt=gt.stat_desc.max_length,Ht=0;for(dt=0;dt<=v;dt++)at.bl_count[dt]=0;for(xt[2*at.heap[at.heap_max]+1]=0,jt=at.heap_max+1;jt<h;jt++)qt<(dt=xt[2*xt[2*(_t=at.heap[jt])+1]+1]+1)&&(dt=qt,Ht++),xt[2*_t+1]=dt,bn<_t||(at.bl_count[dt]++,Gt=0,vn<=_t&&(Gt=ji[_t-vn]),xe=xt[2*_t],at.opt_len+=xe*(dt+Gt),Pi&&(at.static_len+=xe*(Di[2*_t+1]+Gt)));if(Ht!==0){do{for(dt=qt-1;at.bl_count[dt]===0;)dt--;at.bl_count[dt]--,at.bl_count[dt+1]+=2,at.bl_count[qt]--,Ht-=2}while(0<Ht);for(dt=qt;dt!==0;dt--)for(_t=at.bl_count[dt];_t!==0;)bn<(Ft=at.heap[--jt])||(xt[2*Ft+1]!==dt&&(at.opt_len+=(dt-xt[2*Ft+1])*xt[2*Ft],xt[2*Ft+1]=dt),_t--)}})(_,E),Q(X,ot,_.bl_count)}function u(_,E,q){var N,R,X=-1,H=E[1],Z=0,tt=7,ot=4;for(H===0&&(tt=138,ot=3),E[2*(q+1)+1]=65535,N=0;N<=q;N++)R=H,H=E[2*(N+1)+1],++Z<tt&&R===H||(Z<ot?_.bl_tree[2*R]+=Z:R!==0?(R!==X&&_.bl_tree[2*R]++,_.bl_tree[2*I]++):Z<=10?_.bl_tree[2*A]++:_.bl_tree[2*P]++,X=R,ot=(Z=0)===H?(tt=138,3):R===H?(tt=6,3):(tt=7,4))}function j(_,E,q){var N,R,X=-1,H=E[1],Z=0,tt=7,ot=4;for(H===0&&(tt=138,ot=3),N=0;N<=q;N++)if(R=H,H=E[2*(N+1)+1],!(++Z<tt&&R===H)){if(Z<ot)for(;V(_,R,_.bl_tree),--Z!=0;);else R!==0?(R!==X&&(V(_,R,_.bl_tree),Z--),V(_,I,_.bl_tree),G(_,Z-3,2)):Z<=10?(V(_,A,_.bl_tree),G(_,Z-3,3)):(V(_,P,_.bl_tree),G(_,Z-11,7));X=R,ot=(Z=0)===H?(tt=138,3):R===H?(tt=6,3):(tt=7,4)}}c(U);var z=!1;function y(_,E,q,N){G(_,(l<<1)+(N?1:0),3),(function(R,X,H,Z){rt(R),K(R,H),K(R,~H),a.arraySet(R.pending_buf,R.window,X,H,R.pending),R.pending+=H})(_,E,q)}e._tr_init=function(_){z||((function(){var E,q,N,R,X,H=new Array(v+1);for(R=N=0;R<f-1;R++)for(F[R]=N,E=0;E<1<<$[R];E++)m[N++]=R;for(m[N-1]=R,R=X=0;R<16;R++)for(U[R]=X,E=0;E<1<<B[R];E++)D[X++]=R;for(X>>=7;R<d;R++)for(U[R]=X<<7,E=0;E<1<<B[R]-7;E++)D[256+X++]=R;for(q=0;q<=v;q++)H[q]=0;for(E=0;E<=143;)J[2*E+1]=8,E++,H[8]++;for(;E<=255;)J[2*E+1]=9,E++,H[9]++;for(;E<=279;)J[2*E+1]=7,E++,H[7]++;for(;E<=287;)J[2*E+1]=8,E++,H[8]++;for(Q(J,g+1,H),E=0;E<d;E++)k[2*E+1]=5,k[2*E]=ut(E,5);it=new et(J,$,p+1,g,v),M=new et(k,B,0,d,v),nt=new et(new Array(0),L,0,w,x)})(),z=!0),_.l_desc=new O(_.dyn_ltree,it),_.d_desc=new O(_.dyn_dtree,M),_.bl_desc=new O(_.bl_tree,nt),_.bi_buf=0,_.bi_valid=0,Y(_)},e._tr_stored_block=y,e._tr_flush_block=function(_,E,q,N){var R,X,H=0;0<_.level?(_.strm.data_type===2&&(_.strm.data_type=(function(Z){var tt,ot=4093624447;for(tt=0;tt<=31;tt++,ot>>>=1)if(1&ot&&Z.dyn_ltree[2*tt]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return o;for(tt=32;tt<p;tt++)if(Z.dyn_ltree[2*tt]!==0)return o;return s})(_)),ht(_,_.l_desc),ht(_,_.d_desc),H=(function(Z){var tt;for(u(Z,Z.dyn_ltree,Z.l_desc.max_code),u(Z,Z.dyn_dtree,Z.d_desc.max_code),ht(Z,Z.bl_desc),tt=w-1;3<=tt&&Z.bl_tree[2*W[tt]+1]===0;tt--);return Z.opt_len+=3*(tt+1)+5+5+4,tt})(_),R=_.opt_len+3+7>>>3,(X=_.static_len+3+7>>>3)<=R&&(R=X)):R=X=q+5,q+4<=R&&E!==-1?y(_,E,q,N):_.strategy===4||X===R?(G(_,2+(N?1:0),3),pt(_,J,k)):(G(_,4+(N?1:0),3),(function(Z,tt,ot,at){var gt;for(G(Z,tt-257,5),G(Z,ot-1,5),G(Z,at-4,4),gt=0;gt<at;gt++)G(Z,Z.bl_tree[2*W[gt]+1],3);j(Z,Z.dyn_ltree,tt-1),j(Z,Z.dyn_dtree,ot-1)})(_,_.l_desc.max_code+1,_.d_desc.max_code+1,H+1),pt(_,_.dyn_ltree,_.dyn_dtree)),Y(_),N&&rt(_)},e._tr_tally=function(_,E,q){return _.pending_buf[_.d_buf+2*_.last_lit]=E>>>8&255,_.pending_buf[_.d_buf+2*_.last_lit+1]=255&E,_.pending_buf[_.l_buf+_.last_lit]=255&q,_.last_lit++,E===0?_.dyn_ltree[2*q]++:(_.matches++,E--,_.dyn_ltree[2*(m[q]+p+1)]++,_.dyn_dtree[2*C(E)]++),_.last_lit===_.lit_bufsize-1},e._tr_align=function(_){G(_,2,3),V(_,S,J),(function(E){E.bi_valid===16?(K(E,E.bi_buf),E.bi_buf=0,E.bi_valid=0):8<=E.bi_valid&&(E.pending_buf[E.pending++]=255&E.bi_buf,E.bi_buf>>=8,E.bi_valid-=8)})(_)}},{"../utils/common":41}],53:[function(n,i,e){i.exports=function(){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}},{}],54:[function(n,i,e){(function(a){(function(s,o){if(!s.setImmediate){var c,l,f,p,g=1,d={},w=!1,h=s.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(s);v=v&&v.setTimeout?v:s,c={}.toString.call(s.process)==="[object process]"?function(I){process.nextTick(function(){x(I)})}:(function(){if(s.postMessage&&!s.importScripts){var I=!0,A=s.onmessage;return s.onmessage=function(){I=!1},s.postMessage("","*"),s.onmessage=A,I}})()?(p="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",S,!1):s.attachEvent("onmessage",S),function(I){s.postMessage(p+I,"*")}):s.MessageChannel?((f=new MessageChannel).port1.onmessage=function(I){x(I.data)},function(I){f.port2.postMessage(I)}):h&&"onreadystatechange"in h.createElement("script")?(l=h.documentElement,function(I){var A=h.createElement("script");A.onreadystatechange=function(){x(I),A.onreadystatechange=null,l.removeChild(A),A=null},l.appendChild(A)}):function(I){setTimeout(x,0,I)},v.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var A=new Array(arguments.length-1),P=0;P<A.length;P++)A[P]=arguments[P+1];var $={callback:I,args:A};return d[g]=$,c(g),g++},v.clearImmediate=b}function b(I){delete d[I]}function x(I){if(w)setTimeout(x,0,I);else{var A=d[I];if(A){w=!0;try{(function(P){var $=P.callback,B=P.args;switch(B.length){case 0:$();break;case 1:$(B[0]);break;case 2:$(B[0],B[1]);break;case 3:$(B[0],B[1],B[2]);break;default:$.apply(o,B)}})(A)}finally{b(I),w=!1}}}}function S(I){I.source===s&&typeof I.data=="string"&&I.data.indexOf(p)===0&&x(+I.data.slice(p.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Jt<"u"?Jt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Se)),Se.exports}var is=rs();const as=ns(is),Sr=/([a-zA-Z_:][\w:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function Xt(t){const r={};let n;for(Sr.lastIndex=0;(n=Sr.exec(t))!==null;)r[n[1]]=n[2]??n[3]??"";return r}function Qe(t){const r=[];let n=0;const i=t.length;for(;n<i;){const e=t.indexOf("<",n);if(e<0)break;if(t.startsWith("<!--",e)){const h=t.indexOf("-->",e+4);n=h<0?i:h+3;continue}if(t.startsWith("<![CDATA[",e)){const h=t.indexOf("]]>",e+9);n=h<0?i:h+3;continue}if(t.startsWith("<?",e)){const h=t.indexOf("?>",e+2);n=h<0?i:h+2;continue}if(t.startsWith("<!",e)){const h=t.indexOf(">",e+2);n=h<0?i:h+1;continue}let a=e+1,s=!1;t[a]==="/"&&(s=!0,a+=1);const o=/^[a-zA-Z_:][\w:.-]*/.exec(t.slice(a));if(!o){n=e+1;continue}const c=o[0];a+=c.length;let l=a,f=null;for(;a<i;){const h=t[a];if(f){h===f&&(f=null),a+=1;continue}if(h==='"'||h==="'"){f=h,a+=1;continue}if(h===">")break;a+=1}if(a>=i)break;const p=a+1,g=t.slice(l,a),d=!s&&g.trimEnd().endsWith("/"),w=d?g.replace(/\/\s*$/,""):g;s?r.push({kind:"close",name:c,pos:e,end:p}):d?r.push({kind:"selfclose",name:c,attrs:w,pos:e,end:p}):r.push({kind:"open",name:c,attrs:w,pos:e,end:p}),n=p}return r}function tn(t,r){return At(t,n=>n===r)}function At(t,r){const n=Qe(t),i=[];let e=0,a=null;for(const s of n){if(s.kind==="selfclose"){e===0&&r(s.name)&&i.push({name:s.name,start:s.pos,startTagEnd:s.end,contentEnd:s.end,end:s.end,inner:"",outer:t.slice(s.pos,s.end),attributes:Xt(s.attrs)});continue}if(s.kind==="open"){e===0&&r(s.name)&&!a&&(a=s),e+=1;continue}e-=1,e<0&&(e=0),a&&e===0&&s.name===a.name&&(i.push({name:a.name,start:a.pos,startTagEnd:a.end,contentEnd:s.pos,end:s.end,inner:t.slice(a.end,s.pos),outer:t.slice(a.pos,s.end),attributes:Xt(a.attrs)}),a=null)}return i}function lt(t,r){return tn(t,r)[0]??null}function Mt(t,r){const n=Qe(t);let i=0,e=null,a=-1;for(const s of n){if(s.kind==="selfclose"){if(!e&&s.name===r)return{name:r,start:s.pos,startTagEnd:s.end,contentEnd:s.end,end:s.end,inner:"",outer:t.slice(s.pos,s.end),attributes:Xt(s.attrs)};continue}if(s.kind==="open"){!e&&s.name===r&&(e=s,a=i),i+=1;continue}if(i-=1,i<0&&(i=0),e&&s.name===r&&i===a){const o=e.attrs;return{name:r,start:e.pos,startTagEnd:e.end,contentEnd:s.pos,end:s.end,inner:t.slice(e.end,s.pos),outer:t.slice(e.pos,s.end),attributes:Xt(o)}}}return null}function Kr(t){return Qe(t).map(r=>({name:r.name,kind:r.kind,start:r.pos,end:r.end,attributes:r.kind==="close"?{}:Xt(r.attrs)}))}function en(t){const r=lt(t,"title");return r?r.inner.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim():""}function nn(t){return Mt(t,"book")?"book":Mt(t,"article")?"article":Mt(t,"chapter")?"book":"article"}function mt(t){const r=t.replace(/\\/g,"/"),n=r.startsWith("/"),i=[];for(const e of r.split("/"))if(!(e===""||e===".")){if(e===".."){i.length>0&&i[i.length-1]!==".."?i.pop():n||i.push("..");continue}i.push(e)}return(n?"/":"")+i.join("/")}function rn(t){const r=t.lastIndexOf("/");return r>=0?t.slice(0,r):""}function yt(t){return t.split("/").pop()??t}function St(t){const r=yt(t).toLowerCase().match(/\.([^.]+)$/);return r?r[1]:""}function fe(t){return yt(t).replace(/\.[^.]+$/,"")}function kt(...t){return mt(t.filter(r=>!!r).join("/"))}function ss(t,r){if(!t)return r;const n=t.endsWith("/")?t:`${t}/`;return r.startsWith(n)?r.slice(n.length):r}const Ue=/(\\(input|include) *\{([^{}]+)\})/g;function an(t,r,n){const i=rn(r);return[t,`${t}.tex`,i?kt(i,t):t,i?kt(i,`${t}.tex`):`${t}.tex`].map(mt).find(a=>a in n)??null}function Er(t,r,n,i=3){let e=0;const a=[],s=new Set,o=l=>{let f=!1;return{output:l.replace(Ue,(g,d,w,h)=>{const v=an(h,r,n);return v?s.has(v)?"":(f=!0,e+=1,s.add(v),n[v]):(a.includes(h)||a.push(h),g)}),changed:f}};let c=t;for(let l=0;l<i;l+=1){const{output:f,changed:p}=o(c);if(c=f,!p)break}return{expandedText:c,expandedCount:e,missingInputs:a,consumedPaths:[...s]}}function os(t){const r=new Set;for(const[n,i]of Object.entries(t)){Ue.lastIndex=0;let e;for(;(e=Ue.exec(i))!==null;){const a=an(e[3],n,t);a&&a!==n&&r.add(a)}}return r}const Qr=String.raw`<xi:include\b[^>]*\bhref\s*=\s*(?:"([^"]+)"|'([^']+)')[^>]*\/>`,Ar=new RegExp(Qr,"g");function ti(t,r,n){const i=rn(r),e=[t,`${t}.ptx`,`${t}.xml`,i?kt(i,t):null,i?kt(i,`${t}.ptx`):`${t}.ptx`,i?kt(i,`${t}.xml`):`${t}.xml`].filter(a=>a!==null);for(const a of e){const s=mt(a);if(s in n)return s}return null}function cs(t){return t.replace(/^\s*<\?xml[^?]*\?>\s*/,"")}function ei(t,r,n,i=5){let e=0;const a=[],s=[r],o=new Set,c=(f,p)=>f.replace(new RegExp(Qr,"g"),(g,d,w)=>{const h=d??w??"",v=s[s.length-1],b=ti(h,v,n);if(!b)return a.includes(h)||a.push(h),g;if(s.includes(b)||p>=i)return g;e+=1,o.add(b),s.push(b);const x=c(cs(n[b]),p+1);return s.pop(),x});return{expandedText:c(t,1),expandedCount:e,missingIncludes:a,consumedPaths:[...o]}}function ls(t){const r=new Set;for(const[n,i]of Object.entries(t)){Ar.lastIndex=0;let e;for(;(e=Ar.exec(i))!==null;){const a=e[1]??e[2]??"",s=ti(a,n,t);s&&s!==n&&r.add(s)}}return r}const us=["book","article"],ni=["frontmatter","preface","acknowledgement","dedication","biography","contributors","part","introduction","chapter","section","subsection","subsubsection","conclusion","exercises","worksheet","handout","reading-questions","references","solutions","glossary","backmatter","appendix","index","colophon"],ds=new Set(ni);function It(t){return ds.has(t)}const fs={chapter:"ch",section:"sec",subsection:"subsec",subsubsection:"subsubsec",appendix:"app"};function _e(t){return fs[t]??t}const hs=new Set(["frontmatter","backmatter","preface","acknowledgement","dedication","biography","contributors","colophon","glossary","index"]);function ps(t){return hs.has(t)}const Lt=["part","chapter","section","subsection","subsubsection"],sn="paragraphs";function $t(t){return Lt.indexOf(t)}function ri(t,r){const n=$t(t);if(n<0)return t;const i=n+r;return i>=Lt.length?sn:Lt[Math.max(0,i)]}function Pt(t){return t.trim().replace(/[^a-zA-Z0-9\-_]+/g,"-").replace(/^[^a-zA-Z_]+/,"").replace(/-+$/,"")}class on{used;constructor(r){this.used=new Set(r??[])}claim(r){let n=r,i=2;for(;this.used.has(n);)n=`${r}-${i}`,i+=1;return this.used.add(n),n}has(r){return this.used.has(r)}}function We(t,r,n){if(t){const i=Pt(t)||n,e=r.claim(i);return e!==t?{ref:e,renamedFrom:t,generated:!1}:{ref:e,generated:!1}}return{ref:r.claim(n),generated:!0}}function he(t,r,n,i){r.renamedFrom!==void 0?t.push({action:"anomaly",severity:"warning",kind:"structure",category:"renamed_xml_id",macro:n,occurrences:1,message:`${n} id \`${r.renamedFrom}\` is not a valid ref (or collides with another); renamed to \`${r.ref}\`. Cross-references to the old id will break.`}):r.generated&&t.push({action:"anomaly",severity:"info",kind:"structure",category:"missing_xml_id",macro:n,occurrences:1,message:`${n} at position ${i} has no id; assigned \`${r.ref}\`.`})}function pe(t,r){return Object.entries(t).map(([n,i])=>{const e=n.split("/").pop()??n,a=e.replace(/\.[^.]+$/,"");return{ref:r.claim(Pt(a)||"asset"),fileName:e,data:i}})}function cn(t,r){return t.splitLevel!==void 0?Math.max(0,t.splitLevel):t.splitChapters===!1?0:t.splitSections?r==="book"?2:1:r==="book"?1:0}function ii(t,r,n){const i=t.slice(0,r),e=t.slice(r);return/\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/.test(i)?i.replace(/\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/,`xml:id="${n}"`)+e:i.replace(/^<([a-zA-Z_:][\w:.-]*)/,`<$1 xml:id="${n}"`)+e}function ai(t,r,n){return We(t.attributes["xml:id"],r,n)}function si(t,r){const n=t.outer.slice(0,t.startTagEnd-t.start),i=t.outer.slice(t.contentEnd-t.start);return n+r+i}function oi(t,r,n,i){if(n>i.maxDepth)return t;const e=At(t,It);if(e.length===0)return t;const a=e.map((s,o)=>{const c=o+1,f=`${_e(s.name)}-${Vt(c,e.length)}`,p=n===1?f:`${r}-${f}`,g=ai(s,i.refs,p);he(i.warnings,g,s.name,c);const d=oi(s.inner,g.ref,n+1,i);return i.divisions.push({xmlId:g.ref,type:s.name,title:en(s.inner),sourceFormat:"pretext",content:ii(si(s,d),s.startTagEnd-s.start,g.ref),isRoot:!1}),{start:s.start,end:s.end,replacement:`<plus:${s.name} ref="${g.ref}"/>`}});return Dt(t,a)}function ln(t,r={}){const n=[],i=r.documentKind??nn(t),e=cn(r,i),a=Mt(t,"pretext"),s=a?a.inner:t,o=lt(s,"docinfo"),c=o?.outer.trim()??"";let l=lt(s,"book")??lt(s,"article");if(!l){const b=i==="book"?"book":"article",x=(o?s.slice(0,o.start)+s.slice(o.end):s).trim();l=lt(`<${b}>
|
|
82
|
+
${x}
|
|
83
|
+
</${b}>`,b)}if(!l)throw new Error("Could not locate a root element for the division pool.");i==="book"&&l.name!=="book"&&n.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_root",macro:"book",occurrences:1,message:"Document was treated as a book but no <book> element found; importing with the existing root."});const f=new on(r.takenIds),p=[],g=ai(l,f,"document");g.renamedFrom!==void 0&&he(n,g,l.name,1);const d=en(l.inner),w=oi(l.inner,g.ref,1,{refs:f,divisions:p,warnings:n,maxDepth:e}),h={xmlId:g.ref,type:l.name==="book"?"book":"article",title:d,sourceFormat:"pretext",content:ii(si(l,w),l.startTagEnd-l.start,g.ref),isRoot:!0};p.unshift(h);const v=pe(r.assets??{},f);return{project:{title:d,docinfo:c,documentKind:i,divisions:p,assets:v},warnings:n}}function un(t,r,n={}){return r==="latex"?ms(t,n):gs(t,n)}function Ir(t){return Pt(ge(t))}function dn(t,r,n,i,e,a,s){if(t){const l=We(t,n,Ir(r)||i);return he(s,l,e,a),l.ref}const o=Ir(r);if(o)return n.claim(o);const c=We(void 0,n,i);return he(s,c,e,a),c.ref}function ms(t,r){const n=[],{body:i}=Wt(t),e=(i||t).trim(),a=Je(e),s=ve(e),o=r.documentKind??(s.includes("chapter")||s.includes("part")?"book":"article"),c=cn(r,o),l=new on,f=l.claim("document"),p=[],g=ci(e,a,0,e.length,1,{maxDepth:c,refs:l,divisions:p,warnings:n,parentRef:f}),d=o==="book"?"book":"article",w=r.title??"",h=`\\${d}{${w}}\\label{${f}}`;return p.unshift({xmlId:f,type:d,title:w,sourceFormat:"latex",content:g?`${h}
|
|
84
|
+
${g}`:h,isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:o,divisions:p,assets:pe(r.assets??{},l)},warnings:n}}function ci(t,r,n,i,e,a){if(e>a.maxDepth||r.length===0)return t.slice(n,i).trim();const s=[t.slice(n,r[0].start)];return r.forEach((o,c)=>{const f=`${_e(o.command)}-${Vt(c+1,r.length)}`,p=e===1?f:`${a.parentRef}-${f}`,g=dn(o.labelId,o.title,a.refs,p,o.command,c+1,a.warnings),d=ci(t,o.children,o.contentStart,o.end,e+1,{...a,parentRef:g});a.divisions.push({xmlId:g,type:o.command,title:o.title,sourceFormat:"latex",content:`\\${o.command}{${o.rawTitle}}\\label{${g}}
|
|
85
|
+
${d}`,isRoot:!1}),s.push(`\\plus{${o.command}}{${g}}`)}),s.join(`
|
|
86
|
+
|
|
87
|
+
`).trim()}function li(t,r){const n=new RegExp(`^#{${r}}\\s+(.*)$`),i=[],e=[];let a=null,s=!1,o="";for(const c of t.split(`
|
|
88
|
+
`)){const l=/^\s*(```+|~~~+)/.exec(c);if(l){const p=l[1][0];s?p===o&&(s=!1):(s=!0,o=p),(a?a.bodyLines:e).push(c);continue}const f=s?null:n.exec(c);f?(a&&i.push(a),a={headingText:f[1].trim(),bodyLines:[]}):(a?a.bodyLines:e).push(c)}return a&&i.push(a),{preamble:e.join(`
|
|
89
|
+
`).trim(),sections:i.map(c=>({headingText:c.headingText,body:c.bodyLines.join(`
|
|
90
|
+
`).trim()}))}}function te(t){return`---
|
|
91
|
+
${Object.entries(t).map(([n,i])=>`${n}: ${i}`).join(`
|
|
92
|
+
`)}
|
|
93
|
+
---`}function gs(t,r){const n=[],i=t.trim(),e=r.documentKind??"article",a=r.splitChapters??e==="book",s=r.splitSections??!1,o=new on,c=o.claim("document"),l=[];if(!(a&&e==="book"))return l.push({xmlId:c,type:e==="book"?"book":"article",title:r.title??"",sourceFormat:"markdown",content:`${te({division:e,id:c,title:r.title??""})}
|
|
94
|
+
|
|
95
|
+
${i}`.trim(),isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:e,divisions:l,assets:pe(r.assets??{},o)},warnings:n};const{preamble:f,sections:p}=li(i,1),g=f?[f]:[];return p.forEach((d,w)=>{const h=dn(void 0,d.headingText,o,`ch-${Vt(w+1,p.length)}`,"chapter",w+1,n);let v=d.body;s&&(v=bs(d.body,h,o,l,n)),l.push({xmlId:h,type:"chapter",title:d.headingText,sourceFormat:"markdown",content:`${te({division:"chapter",id:h,title:d.headingText})}
|
|
96
|
+
|
|
97
|
+
# ${d.headingText}
|
|
98
|
+
|
|
99
|
+
${v}`.trim(),isRoot:!1}),g.push(`::chapter{ref="${h}"}`)}),l.unshift({xmlId:c,type:"book",title:r.title??"",sourceFormat:"markdown",content:`${te({division:"book",id:c,title:r.title??""})}
|
|
100
|
+
|
|
101
|
+
${g.join(`
|
|
102
|
+
|
|
103
|
+
`)}`.trim(),isRoot:!0}),{project:{title:r.title??"",docinfo:r.docinfo??"",documentKind:e,divisions:l,assets:pe(r.assets??{},o)},warnings:n}}function bs(t,r,n,i,e){const{preamble:a,sections:s}=li(t,2);if(s.length===0)return t;const o=a?[a]:[];return s.forEach((c,l)=>{const f=dn(void 0,c.headingText,n,`${r}-sec-${Vt(l+1,s.length)}`,"section",l+1,e);i.push({xmlId:f,type:"section",title:c.headingText,sourceFormat:"markdown",content:`${te({division:"section",id:f,title:c.headingText})}
|
|
104
|
+
|
|
105
|
+
# ${c.headingText}
|
|
106
|
+
|
|
107
|
+
${c.body}`.trim(),isRoot:!1}),o.push(`::section{ref="${f}"}`)}),o.join(`
|
|
108
|
+
|
|
109
|
+
`).trim()}const Xe=/<plus:([a-zA-Z][a-zA-Z-]*)\s+ref="([^"]+)"\s*\/>/g;function Zt(t){const r=[];Xe.lastIndex=0;let n;for(;(n=Xe.exec(t))!==null;)r.push(n[2]);return r}function Ze(t,r){return t.replace(Xe,(n,i,e)=>{const a=r.get(e);return a?`<xi:include href="${a}"/>`:n})}function vs(t,r){const n=ge(t)||"division";return n.startsWith(`${r}-`)?n:`${r}-${n}`}function ws(t,r){let n=r,i=2;for(;t.has(n);)n=`${r}-${i}`,i+=1;return t.add(n),n}function _s(t,r){const n=`${r}-`;return t.startsWith(n)?t.slice(n.length):t}function ui(t,r){const n=new Map(t.divisions.map(f=>[f.xmlId,f])),i=[],e=new Set,a=new Map,s=new Map;function o(f,p){let g=s.get(f);return g||(g=new Set,s.set(f,g)),ws(g,p)}function c(f,p,g,d){if(e.has(f.xmlId))return;e.add(f.xmlId);const w=o(p,ps(f.type)?f.type:vs(_s(f.xmlId,d),_e(f.type)));a.set(f.xmlId,`${g}${w}.ptx`),i.push({division:f,filePath:`${p}${w}.ptx`});for(const h of Zt(f.content)){const v=n.get(h);v&&c(v,`${p}${w}/`,`${w}/`,f.xmlId)}}for(const f of r.entries)c(f,r.directory,"",r.parentXmlId);const l=new Set;for(const f of t.divisions)for(const p of Zt(f.content))l.add(p);for(const f of t.divisions)f.isRoot||e.has(f.xmlId)||l.has(f.xmlId)||c(f,r.directory,"",r.parentXmlId);return{placed:i,hrefByRef:a}}const Ee={mainSourcePath:"source/main.ptx",publicationPath:"publication/publication.ptx",projectFilePath:"project.ptx"};function di(t,r={}){const n=r.mainSourcePath??Ee.mainSourcePath,i=r.publicationPath??Ee.publicationPath,e=r.projectFilePath??Ee.projectFilePath,a=r.includeScaffold??!0,s={},o=new Map(t.divisions.map(v=>[v.xmlId,v])),c=t.divisions.find(v=>v.isRoot);if(!c)throw new Error("Division pool has no root division.");const l=n.includes("/")?n.slice(0,n.lastIndexOf("/")+1):"",{placed:f,hrefByRef:p}=ui(t,{entries:Zt(c.content).map(v=>o.get(v)).filter(v=>v!==void 0),directory:l,parentXmlId:c.xmlId});for(const{division:v,filePath:b}of f){const x=Ze(v.content,p),S=x===v.content?x:ce(x);s[b]=le(S)}const g=Ze(c.content,p),w=`<pretext>
|
|
110
|
+
${t.docinfo?`${t.docinfo}
|
|
111
|
+
`:""}${g}
|
|
112
|
+
</pretext>`;s[n]=le(g===c.content?w:ce(w)),a&&(s[e]=Nr({mainSource:n,publication:i}),s[i]=He());const h={[c.xmlId]:n};for(const{division:v,filePath:b}of f)h[v.xmlId]=b;return{files:s,pathByRef:h}}function ys(t,r,n){const i=lt(t,r);if(!i)return t;const e=t.slice(i.start,i.startTagEnd).replace(/^<\s*[^\s>/]+/,`<${n}`),a=t.slice(i.contentEnd,i.end).replace(/^<\/\s*[^\s>]+/,`</${n}`);return t.slice(0,i.start)+e+t.slice(i.startTagEnd,i.contentEnd)+a+t.slice(i.end)}function fi(t,r){const n=new Map(t.divisions.map(a=>[a.xmlId,a])),i=t.divisions.find(a=>a.isRoot);if(!i)throw new Error("Division pool has no root division.");const e=r.unwrapRoot?Zt(i.content).map(a=>n.get(a)).filter(a=>a!==void 0):[{...i,type:r.targetTag,content:ys(i.content,i.type,r.targetTag)}];return{root:i,entries:e}}function hi(t,r){const{root:n,entries:i}=fi(t,r),{placed:e,hrefByRef:a}=ui(t,{entries:i,directory:r.hrefBase,parentXmlId:n.xmlId}),s={},o={};for(const{division:l,filePath:f}of e){const p=Ze(l.content,a),g=p===l.content?p:ce(p);s[f]=le(g),o[l.xmlId]=f}const c=i.map(l=>a.get(l.xmlId)).filter(l=>l!==void 0).map(l=>`<xi:include href="${l}"/>`);return{files:s,includes:c,pathByRef:o}}function fn(t,r,n={}){if(r.kind==="insert")return hi(t,{targetTag:r.targetTag,hrefBase:r.hrefBase,unwrapRoot:n.unwrapRoot??!1});const{files:i,pathByRef:e}=di(t,n.layout);return{files:i,includes:[],pathByRef:e}}const pi={kind:"project"},xs=["ref","first","last"];function ks(t){let r=t.base,n=2;for(;t.isTaken(r)||r==="";)r=`${t.base||"id"}-${n}`,n+=1;return r}function Ss(t){return t.split(/([\s,]+)/)}function mi(t,r){const n=Kr(t),i=new Set(r.takenIds),e=c=>i.has(c),a=new Map,s=[];for(const c of n){const l=c.attributes["xml:id"];if(l===void 0||a.has(l))continue;const f=Pt(l);if(f===l&&!i.has(l)){i.add(l);continue}const p=ks({original:l,base:f,isTaken:e,fragmentRef:r.fragmentRef});i.add(p),a.set(l,p),s.push({from:l,to:p})}if(a.size===0)return{source:t,renamed:[]};const o=[];for(const c of n){const l=t.slice(c.start,c.end);let f=l;const p=c.attributes["xml:id"],g=p===void 0?void 0:a.get(p);g!==void 0&&(f=f.replace(/\bxml:id\s*=\s*(["'])[^"']*\1/,(d,w)=>`xml:id=${w}${g}${w}`));for(const d of xs){const w=c.attributes[d];if(w===void 0)continue;const h=Ss(w).map(v=>a.get(v)??v).join("");h!==w&&(f=f.replace(new RegExp(`\\b${d}\\s*=\\s*(["'])[^"']*\\1`),(v,b)=>`${d}=${b}${h}${b}`))}f!==l&&o.push({start:c.start,end:c.end,replacement:f})}return{source:Dt(t,o),renamed:s}}function Tr(t){const r=t.indexOf(":");return r<0?{prefix:"",local:t}:{prefix:t.slice(0,r+1),local:t.slice(r+1)}}function Es(t,r){return hn(t,$t(r))}function hn(t,r){const n=Kr(t);let i=-1;for(const l of n){const f=$t(Tr(l.name).local);f>=0&&(i<0||f<i)&&(i=f)}if(i<0||r<0)return{source:t,delta:0,overflowed:[]};const e=r-i,a=Lt[i];if(e===0)return{source:t,delta:0,topTag:a,overflowed:[]};const s=new Set,o=[];for(const l of n){const{prefix:f,local:p}=Tr(l.name),g=$t(p);if(g<0)continue;const d=ri(p,e);if(d===p)continue;d===sn&&s.add(g);const w=t.slice(l.start,l.end),h=l.kind==="close"?w.replace(/^<\/\s*[^\s>/]+/,`</${f}${d}`):w.replace(/^<\s*[^\s>/]+/,`<${f}${d}`);o.push({start:l.start,end:l.end,replacement:h})}const c=[...s].sort((l,f)=>l-f).map(l=>Lt[l]);return{source:Dt(t,o),delta:e,topTag:a,overflowed:c}}function As(t){if(lt(t,"title"))return!1;const r=At(t,()=>!0);return r.length===0||!r.every(n=>It(n.name))?!1:!gi(t)}function gi(t){const r=At(t,It);let n="",i=0;for(const e of r)n+=t.slice(i,e.start),i=e.end;return n+=t.slice(i),n.replace(/<!--[\s\S]*?-->/g,"").trim()!==""}function Is(t){const r=lt(t,"pretext"),n=r?r.inner:t,i=r?r.startTagEnd:0,e=lt(n,"book")??lt(n,"article");return e?{...e,start:e.start+i,startTagEnd:e.startTagEnd+i,contentEnd:e.contentEnd+i,end:e.end+i}:null}function Ts(t){const r=lt(t,"title");return r?r.inner.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim():""}function Rs(t,r,n){const i=new Set(n),e=[];for(const a of r){const s=a.attributes["xml:id"];if(s){i.add(s);continue}const o=Pt(ge(Ts(a.inner)))||"imported";let c=o,l=2;for(;i.has(c);)c=`${o}-${l}`,l+=1;i.add(c),e.push({start:a.start,end:a.startTagEnd,replacement:t.slice(a.start,a.startTagEnd).replace(/^<([a-zA-Z_:][\w:.-]*)/,`<$1 xml:id="${c}"`)})}return e.length===0?t:Dt(t,e)}function Cs(t,r){return r?At(t.inner,It).map(n=>({...n,start:n.start+t.startTagEnd,startTagEnd:n.startTagEnd+t.startTagEnd,contentEnd:n.contentEnd+t.startTagEnd,end:n.end+t.startTagEnd})):[t]}function bi(t){return t?1:0}function pn(t,r,n={}){const i=[],e=Is(t),a=e?.inner??null,s=a!==null&&As(a),o=a!==null&&(n.hasSelection||s);o&&!s&&a!==null&&gi(a)&&i.push({action:"delete",severity:"warning",kind:"structure",category:"dropped_wrapper_content",macro:"article",occurrences:1,message:"The selected divisions are inserted on their own, so the document's title and any text outside them are not carried across."});const c=e?Rs(t,Cs(e,o),r.takenIds):t,l=$t(r.targetTag),f=hn(c,l<0?-1:o?l:l+1),{source:p,renamed:g}=mi(f.source,{takenIds:r.takenIds});return f.overflowed.length>0&&i.push({action:"anomaly",severity:"warning",kind:"structure",category:"division_overflow",macro:r.targetTag,occurrences:f.overflowed.length,message:`Inserting at <${r.targetTag}> pushes ${f.overflowed.map(d=>`<${d}>`).join(", ")} past <subsubsection>; ${f.overflowed.length===1?"it becomes":"they become"} <paragraphs>, which stays inline rather than becoming its own file.`}),g.length>0&&i.push({action:"anomaly",severity:"warning",kind:"structure",category:"renamed_xml_id",macro:"xml:id",occurrences:g.length,message:`${g.length} imported id${g.length===1?"":"s"} already existed in this project and ${g.length===1?"was":"were"} renamed: ${g.map(d=>`\`${d.from}\` → \`${d.to}\``).join(", ")}.`}),!o&&a!==null&&!lt(a,"title")&&i.push({action:"anomaly",severity:"warning",kind:"structure",category:"missing_title",macro:r.targetTag,occurrences:1,message:`The imported document has no title, so the <${r.targetTag}> it becomes has none either. PreTeXt divisions need a title; add one before building.`}),{source:p,unwrapRoot:o,retarget:f,renamed:g,warnings:i}}const Os="source",zs="publication",Rr="main.ptx";function Bt(t,r){const n=lt(t.inner,r);if(!n)return;const i=n.inner.trim();return i.length>0?i:void 0}function Ae(t,r,n){const i=Bt(t,r);if(i!==void 0)return mt(i);const e=t.attributes[r];if(e!==void 0&&e.trim().length>0)return kt(n,e.trim())}function vi(t,r){const n=lt(t,"project");if(!n)return null;const i=rn(mt(r)),e=n.attributes.source?.trim()||Os,a=n.attributes.publication?.trim()||zs,s=n.attributes.output?.trim()||"output",o={manifestPath:mt(r),projectRoot:i,ptxVersion:n.attributes["ptx-version"],sourceDir:e,publicationDir:a,targets:[]},c=lt(n.inner,"targets"),l=c?tn(c.inner,"target"):[];for(const f of l)o.targets.push({name:f.attributes.name??"",format:f.attributes.format??Bt(f,"format")??"",source:Ae(f,"source",e)??kt(e,Rr),publication:Ae(f,"publication",a),outputDir:Ae(f,"output-dir",s),standalone:f.attributes.standalone!==void 0&&f.attributes.standalone!=="no"});if(o.targets.length===0){const f=Bt(n,"source");o.targets.push({name:"default",format:Bt(n,"format")??"",source:f?mt(f):kt(e,Rr),publication:Bt(n,"publication"),standalone:!1})}return o}function wi(t){const r=Object.keys(t).filter(n=>yt(n).toLowerCase()==="project.ptx").sort((n,i)=>{const e=n.split("/").length-i.split("/").length;return e!==0?e:n.localeCompare(i)});for(const n of r){const i=vi(t[n],n);if(i)return i}return null}function _i(t){return t.targets.find(r=>!r.standalone)??t.targets[0]}const Ls=new Set(["md","markdown"]),$s=new Set(["ptx","xml"]),Ds=new Set(["readme","changelog","contributing","license"]),Cr=["main","book","index","root","master","thesis","dissertation","article","paper"];function mn(t,r){return Object.fromEntries(Object.entries(t).filter(([n])=>r.has(St(n))))}function yi(t){const r=lt(t,"pretext")??lt(t,"book")??lt(t,"article"),n=r?r.inner:t;return lt(n,"title")?.inner.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()||void 0}function Ps(t){const r=/^#\s+(.+)$/m.exec(t);return r?r[1].trim():void 0}function Or(t){return de(t,"title")||void 0}function js(t){return/\\documentclass\b/.test(t)||/\\begin *\{document\}/.test(t)}const Fs=/<(pretext|book|article)\b/;function qs(t,r){const n=_i(t),i=n?[n,...t.targets.filter(s=>s!==n)]:t.targets,e=new Set,a=[];for(const s of i){const o=kt(t.projectRoot,s.source);e.has(o)||!(o in r)||(e.add(o),a.push({path:o,format:"pretext",reason:"manifest-target",title:yi(r[o]),targetName:s.name,targetFormat:s.format}))}return a}function Bs(t){const r=mn(t,new Set(["tex","ltx"])),n=os(r),i=Object.keys(r).filter(c=>!n.has(c)&&js(r[c])).sort(),e=c=>{let l=0;const f=r[c].match(/\\(input|include) *\{[^{}]+\}/g)??[];for(const p of f){const g=/\{([^{}]+)\}/.exec(p)?.[1];g&&an(g,c,r)&&(l+=1)}return l},a=c=>{const l=Cr.indexOf(fe(c).toLowerCase());return l>=0?l:Cr.length},o=[...i].sort((c,l)=>{const f=+!/\\documentclass\b/.test(r[c])-+!/\\documentclass\b/.test(r[l]);if(f!==0)return f;const p=a(c)-a(l);if(p!==0)return p;const g=e(l)-e(c);return g!==0?g:c.localeCompare(l)}).map(c=>({path:c,format:"latex",reason:"latex-root",title:Or(r[c])}));return o.length>0?o:Object.keys(r).sort().map(c=>({path:c,format:"latex",reason:"fallback",title:Or(r[c])}))}function Ns(t){const r=mn(t,Ls),n=Object.keys(r).sort(),i=s=>Ds.has(fe(s).toLowerCase()),e=["main","index","book","article"],a=s=>i(s)?2:e.indexOf(fe(s).toLowerCase())>=0?0:1;return[...n].sort((s,o)=>a(s)-a(o)||s.localeCompare(o)).map(s=>({path:s,format:"markdown",reason:"markdown-root",title:Ps(r[s])}))}function Ms(t){const r=mn(t,$s),n=ls(r);return Object.keys(r).filter(e=>!n.has(e)&&Fs.test(r[e])&&yt(e).toLowerCase()!=="project.ptx"&&yt(e).toLowerCase()!=="publication.ptx").sort().map(e=>({path:e,format:"pretext",reason:"pretext-root",title:yi(r[e])}))}function xi(t,r={}){const n=wi(t),i=[...n?qs(n,t):[],...Bs(t),...Ns(t),...Ms(t)],e=[],a=new Set;for(const p of i)a.has(p.path)||(a.add(p.path),e.push(p));const s=r.sourceFormat?e.filter(p=>p.format===r.sourceFormat):e,o=[];for(const p of e)o.includes(p.format)||o.push(p.format);let c=s[0]??null;if(r.mainFile){const p=r.mainFile;c=s.find(g=>g.path===p)??e.find(g=>g.path===p)??(p in t?{path:p,format:r.sourceFormat??ee(t[p]),reason:"fallback"}:c)}if(!c){const p=Object.keys(t).sort()[0];c=p?{path:p,format:r.sourceFormat??ee(t[p]),reason:"fallback"}:null}const l=c,f=l&&(l.format==="latex"||l.format==="markdown")?s.filter(p=>p.path!==l.path&&p.format===l.format&&p.reason!=="manifest-target"):[];return{manifest:n,candidates:s,formats:o,primary:c,extraRoots:f}}const zr="\\begin{document}",Us="\\end{document}",Ws=/\\documentclass\s*(?:\[[^\]]*\])?\s*\{(book|report|memoir|scrbook|scrreprt|amsbook)\}/;function ki(t){return fe(t).replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,r=>r.toUpperCase())||"Untitled"}function Ve(t,r){return{action:"anomaly",severity:"info",kind:"structure",category:"attached_root",macro:t.level,occurrences:1,message:r}}function Si(t){const{preamble:r,body:n}=Wt(t);return Ws.test(r)||/\\chapter\b/.test(n)?"chapter":"section"}function Xs(t,r){const n=t.replace(/^\s*(%[^\n]*\n\s*)*/,"");return r==="chapter"?/^\\(chapter|part)\b/.test(n):/^\\(section|chapter|part)\b/.test(n)}function Ei(t,r,n){const i=r.filter(w=>w.include!==!1);if(i.length===0)return{source:t,attached:[],warnings:[]};const e=t.includes(zr),{preamble:a,body:s}=Wt(t),o=Si(t),c=[],l=[],f=[],p=[];for(const w of i){const h=n[w.path];if(h===void 0){l.push({action:"anomaly",severity:"warning",kind:"structure",category:"attached_root_missing",macro:w.path,occurrences:1,message:`Cannot attach \`${w.path}\`: it is not among the uploaded files.`});continue}const v=w.level??o,b=w.title||de(h,"title")||ki(w.path),x={path:w.path,title:b,level:v},S=Wt(h),{macros:I,warnings:A}=Zr(S.preamble);I&&f.push(I),l.push(...A);const P=S.body.trim();if(!P){l.push(Ve(x,`\`${w.path}\` is empty; skipped.`));continue}p.push(Xs(P,v)?P:`\\${v}{${b}}
|
|
113
|
+
|
|
114
|
+
${P}`),c.push(x),l.push(Ve(x,`Attached \`${w.path}\` as a ${v}: “${b}”.`))}if(p.length===0)return{source:t,attached:c,warnings:l};const g=[s.trim(),...p].filter(Boolean).join(`
|
|
115
|
+
|
|
116
|
+
`);return e?{source:[[a,...f].filter(Boolean).join(`
|
|
117
|
+
`),zr,g,Us].join(`
|
|
118
|
+
`),attached:c,warnings:l}:{source:[a,...f,g].filter(Boolean).join(`
|
|
119
|
+
|
|
120
|
+
`),attached:c,warnings:l}}function Ai(t,r,n){const i=r.filter(o=>o.include!==!1),e=[],a=[],s=[];for(const o of i){const c=n[o.path];if(c===void 0){a.push({action:"anomaly",severity:"warning",kind:"structure",category:"attached_root_missing",macro:o.path,occurrences:1,message:`Cannot attach \`${o.path}\`: it is not among the uploaded files.`});continue}const l=c.trim();if(!l)continue;const f=/^#\s+(.+)$/m.exec(l),p=o.title||f?.[1]?.trim()||ki(o.path),g={path:o.path,title:p,level:o.level??"chapter"};s.push(l.startsWith("# ")?l:`# ${p}
|
|
121
|
+
|
|
122
|
+
${l}`),e.push(g),a.push(Ve(g,`Attached \`${o.path}\`: “${p}”.`))}return s.length===0?{source:t,attached:e,warnings:a}:{source:[t.trim(),...s].filter(Boolean).join(`
|
|
123
|
+
|
|
124
|
+
`),attached:e,warnings:a}}const Zs=["output",".git",".github/workflows/.cache","node_modules",".ptx","__pycache__",".venv","__MACOSX"];function Vs(t,r){const n=t.toLowerCase();return[...Zs,...r].some(i=>i.length>0&&n.startsWith(`${i.toLowerCase()}/`))}function Ii(t){const{manifest:r,files:n,assets:i}=t,e=r.projectRoot,a=new Set(t.consumedPaths),s=[...new Set(r.targets.map(l=>l.outputDir?.split("/")[0]).filter(l=>!!l))],o={files:{},assets:{},skipped:[]},c=(l,f)=>{if(e&&!l.startsWith(`${e}/`))return;const p=ss(e,l);if(!(a.has(l)||l===r.manifestPath)){if(Vs(p,s)){o.skipped.push(p);return}f(p)}};for(const[l,f]of Object.entries(n))c(l,p=>{o.files[p]=f});for(const[l,f]of Object.entries(i))c(l,p=>{o.assets[p]=f});return o}function Ti(t,r,n){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
125
|
+
<project ptx-version="2">
|
|
126
|
+
<targets>
|
|
127
|
+
${t.targets.map(e=>{const a=e.source===r.source,s=a?n.mainSource:e.source,o=a?n.publication??e.publication:e.publication;return[` <target name="${e.name}"${e.standalone?' standalone="yes"':""}>`,e.format?` <format>${e.format}</format>`:"",` <source>${s}</source>`,o?` <publication>${o}</publication>`:"",e.outputDir?` <output-dir>${e.outputDir}</output-dir>`:""," </target>"].filter(Boolean).join(`
|
|
128
|
+
`)}).join(`
|
|
129
|
+
`)}
|
|
130
|
+
</targets>
|
|
131
|
+
</project>
|
|
132
|
+
`}const Ri="external";function Gs(t,r,n){const i=r.replace(/\/+$/,"");return i?`${t}${i}/${n}`:`${t}${n}`}function Hs(t,r,n=Ri){const i={},e={},a=new Set;for(const s of t){const o=yt(s);let c=o;if(a.has(c)){const l=o.lastIndexOf("."),f=l>0?o.slice(0,l):o,p=l>0?o.slice(l):"";let g=2;for(;a.has(`${f}-${g}${p}`);)g+=1;c=`${f}-${g}${p}`}a.add(c),i[s]=Gs(r,n,c),o in e||(e[o]=c)}return{pathByOriginal:i,sourceByBaseName:e}}const Ys=["image","video","audio"],Js=new RegExp(`(<(?:${Ys.join("|")})\\b[^>]*?\\bsource\\s*=\\s*)(["'])([^"']*)\\2`,"g");function Ks(t,r){const n=[],i=[];return{source:t.replace(Js,(a,s,o,c)=>{if(c===""||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(c))return a;const l=r[yt(c)];return l===void 0?(i.push(c),a):(l!==c&&n.push({from:c,to:l}),`${s}${o}${l}${o}`)}),rewritten:n,unresolved:i}}function Qs(t){const r=lt(t,"pretext"),n=r?r.inner:t,i=lt(n,"book")??lt(n,"article");return i?i.inner:n}function to(t){function r(n,i){return At(n,It).map((e,a)=>{const s=i?`${i}.${a}`:String(a);return{path:s,tag:e.name,title:en(e.inner),xmlId:e.attributes["xml:id"],children:r(e.inner,s)}})}return r(Qs(t),"")}function eo(t,r){if(r.has(t))return!0;for(const n of r)if(n.startsWith(`${t}.`)||t.startsWith(`${n}.`))return!0;return!1}function gn(t,r){if(!r||r.length===0)return{source:t,removed:[]};const n=new Set(r),i=[];function e(p,g,d){const w=[];return At(p,It).forEach((h,v)=>{const b=g?`${g}.${v}`:String(v);if(!eo(b,n)){i.push(b),w.push({start:d+h.start,end:d+h.end,replacement:""});return}n.has(b)||w.push(...e(h.inner,b,d+h.startTagEnd))}),w}const a=lt(t,"pretext"),s=a?a.inner:t,o=a?a.startTagEnd:0,c=lt(s,"book")??lt(s,"article"),l=o+(c?c.startTagEnd:0),f=c?c.inner:s;return{source:Dt(t,e(f,"",l)),removed:i}}const no=/\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i,ro=["tex","md","markdown","ptx","xml","bib","sty","txt","pdf","eps","png","ps","bbl"],io=new Set(["png","jpg","jpeg","gif","pdf","eps","ps","bmp","tiff","tif","webp","ico"]),ao=new Set(["png","jpg","jpeg","gif","svg","bmp","tiff","tif","webp","ico","pdf","eps","ps"]);function Ci(t){return io.has(t.toLowerCase())}function so(t){return ao.has(St(yt(t)))}function oo(t){const r=yt(t);return St(r)==="bib"?`source/${r}`:null}function Et(t){return t.replace(/\r\n?/g,`
|
|
133
|
+
`).replace(/(\n *){3,}/g,`
|
|
134
|
+
|
|
135
|
+
`)}function co(t){const r=t.toLowerCase();return r.endsWith(".tar.gz")||r.endsWith(".tgz")?"tar.gz":r.endsWith(".zip")?"zip":r.endsWith(".tex")?"tex":r.endsWith(".md")||r.endsWith(".markdown")?"markdown":r.endsWith(".ptx")||r.endsWith(".xml")?"pretext":null}function lo(t){const r=(n,i)=>new TextDecoder().decode(t.slice(n,i)).split("\0")[0];return{name:r(0,100),size:parseInt(r(124,136),8)||0,type:r(156,157)}}async function uo(t){if(typeof DecompressionStream>"u")throw new Error("This runtime does not support gzip decompression.");const i=new ReadableStream({start(c){c.enqueue(new Uint8Array(t)),c.close()}}).pipeThrough(new DecompressionStream("gzip")).getReader(),e=[];for(;;){const{done:c,value:l}=await i.read();if(c)break;e.push(l)}const a=e.reduce((c,l)=>c+l.length,0),s=new Uint8Array(a);let o=0;for(const c of e)s.set(c,o),o+=c.length;return s.buffer}function fo(t){const r={},n={};let i=0;for(;i<t.length&&!(i+512>t.length);){const e=t.slice(i,i+512),a=lo(e);if(!a.name)break;i+=512;const s=a.size,o=Math.ceil(s/512)*512;if(a.type==="0"||a.type===""){const c=t.slice(i,i+s),l=mt(a.name);if(Ci(St(l)))n[l]=c;else{const f=new TextDecoder().decode(c);r[l]=Et(f)}}i+=o}return{files:r,assets:n}}async function Oi(t){const r=co(t.name);if(!r)throw new Error("File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.");if(r==="tex"||r==="markdown"||r==="pretext"){const e=await t.text();return{files:{[mt(t.name)]:Et(e)},assets:{}}}if(r==="zip"){const a=await new as().loadAsync(t),s={},o={};for(const[c,l]of Object.entries(a.files)){if(l.dir)continue;const f=mt(c);if(Ci(St(f)))o[f]=await l.async("uint8array");else{const p=await l.async("string");s[f]=Et(p)}}return{files:s,assets:o}}const n=await t.arrayBuffer(),i=await uo(n);return fo(new Uint8Array(i))}function ho(t){const r={other:0};for(const n of ro)r[n]=0;for(const n of Object.keys(t)){const i=St(n);i in r?r[i]+=1:r.other+=1}return r}function po(t,r){const n=ho(r);t.push({type:"success",message:"File types:"});for(const i of Object.keys(n).sort())n[i]&&t.push({type:"success",message:`${i}: ${n[i]}`})}function mo(t){return t==="latex"?"tex":t==="markdown"?"markdown":"pretext"}function go(t,r){return t.targets.find(n=>n.source===r)}function bo(t,r){return t===!1?[]:Array.isArray(t)?t.filter(n=>n.include!==!1):r.extraRoots.map(n=>({path:n.path}))}function vo(t){if(t.reason==="manifest-target"){const r=t.targetName?` (target \`${t.targetName}\`)`:"";return`Main source file: ${t.path}${r}`}return`Main source file: ${t.path}`}function zi(t,r={}){const n=[],i=r.destination??pi;let e=[];try{const a=Object.fromEntries(Object.entries(t).map(([Q,Y])=>[mt(Q),Et(Y)])),s=Object.keys(a).length;n.push({type:"success",message:`Found ${s} file${s===1?"":"s"}.`}),po(n,a);const o=xi(a,{sourceFormat:r.sourceFormat,mainFile:r.mainFile?mt(r.mainFile):void 0}),c=o.primary;if(!c)throw new Error("No files were found in the uploaded source.");const l=c.path,f=mo(c.format);let p=a[l]??"";const g=new Set([l]);if(o.manifest){const Q=o.manifest.targets.length;n.push({type:"success",message:`Found ${o.manifest.manifestPath} with ${Q} target${Q===1?"":"s"}: ${o.manifest.targets.map(Y=>Y.name).join(", ")}.`})}const d=bo(r.attachRoots,o);let w=[];const h=[],v=[];if(c.format==="latex"){const Q=Object.fromEntries(Object.entries(a).filter(([rt])=>St(rt)==="tex")),Y=Er(p,l,Q);if(p=Et(Y.expandedText),Y.consumedPaths.forEach(rt=>g.add(rt)),Y.expandedCount>0&&n.push({type:"success",message:`Expanded ${Y.expandedCount} input/include reference${Y.expandedCount===1?"":"s"}.`}),Y.missingInputs.length>0&&n.push({type:"error",message:`Missing input/include files: ${Y.missingInputs.join(", ")}.`}),d.length>0){const rt={};for(const st of d){const pt=a[st.path];if(pt===void 0)continue;const ht=Er(pt,st.path,Q);rt[st.path]=ht.expandedText,ht.consumedPaths.forEach(u=>g.add(u)),g.add(st.path)}const ct=Ei(p,d,rt);p=Et(ct.source),w=ct.attached,h.push(...ct.warnings)}}else if(c.format==="markdown"){if(d.length>0){const Q=Ai(p,d,a);p=Et(Q.source),w=Q.attached,h.push(...Q.warnings),w.forEach(Y=>g.add(Y.path))}}else{const Q=Object.fromEntries(Object.entries(a).filter(([rt])=>{const ct=St(rt);return ct==="ptx"||ct==="xml"})),Y=ei(p,l,Q);p=Y.expandedText,Y.consumedPaths.forEach(rt=>g.add(rt)),Y.expandedCount>0&&n.push({type:"success",message:`Expanded ${Y.expandedCount} xi:include reference${Y.expandedCount===1?"":"s"}.`}),Y.missingIncludes.length>0&&(n.push({type:"error",message:`Missing xi:include targets: ${Y.missingIncludes.join(", ")}.`}),v.push({action:"anomaly",severity:"error",kind:"structure",category:"missing_include",macro:"xi:include",occurrences:Y.missingIncludes.length,examples:Y.missingIncludes,message:`Missing xi:include targets: ${Y.missingIncludes.join(", ")}. This content is missing from the import.`}))}n.push({type:"success",message:vo(c)});for(const Q of w)n.push({type:"success",message:`Attached ${Q.path} as a ${Q.level}: ${Q.title}`});const b=Jr(p,c.format);if("pretextError"in b)return{pretextError:b.pretextError,statusMessages:n,warnings:[...b.warnings,...h,...v]};const{buildLayout:x=!0,assets:S={},...I}=r,A=o.manifest,P=A&&c.reason==="manifest-target"?go(A,c.path.slice(A.projectRoot?A.projectRoot.length+1:0)):void 0,$=x&&A!==null&&P!==void 0&&(r.preserveProjectLayout??!0),B={mainSourcePath:I.mainSourcePath??($&&P?P.source:"source/main.ptx"),publicationPath:I.publicationPath??($&&P?.publication?P.publication:"publication/publication.ptx"),projectFilePath:I.projectFilePath??"project.ptx",preserved:$},L={},W={},J={},k=r.externalDir??Ri;let D;if($&&A&&P){const Q=Ii({manifest:A,target:P,files:a,assets:S,consumedPaths:g});Object.assign(J,Q.files),Object.assign(L,Q.assets);for(const[Y,rt]of Object.entries(S))W[Y]=rt;n.push({type:"success",message:`Carried over ${Object.keys(Q.files).length} project file${Object.keys(Q.files).length===1?"":"s"} and ${Object.keys(Q.assets).length} asset${Object.keys(Q.assets).length===1?"":"s"} unchanged.`}),Q.skipped.length>0&&n.push({type:"success",message:`Skipped build output: ${Q.skipped.length} file${Q.skipped.length===1?"":"s"}.`})}else{D=Hs(Object.keys(S).filter(so),_o(B.mainSourcePath),k);for(const[Q,Y]of Object.entries(D.pathByOriginal))L[Y]=S[Q],W[Q]=S[Q]}const m=I.documentKind??nn(b.pretextSource),F=D?Ks(b.pretextSource,D.sourceByBaseName):void 0,it=F?.source??b.pretextSource,M=gn(it,r.selection),nt=i.kind==="insert"?pn(M.source,i,{hasSelection:(r.selection?.length??0)>0}):void 0,U=nt?.source??M.source,et=[...$i(M),...nt?.warnings??[]],O=x?Math.max(Li(I,{format:b.sourceFormat,latexSource:b.cleanedNativeSource,documentKind:m}),bi(nt?.unwrapRoot??!1)):0,C=ln(U,{documentKind:m,splitLevel:O,assets:W,takenIds:i.kind==="insert"?i.takenIds:void 0});if(x){const Q=fn(C.project,i,{layout:{mainSourcePath:B.mainSourcePath,publicationPath:B.publicationPath,projectFilePath:B.projectFilePath,includeScaffold:!$},unwrapRoot:nt?.unwrapRoot});e=Q.includes,Object.assign(J,Q.files),i.kind==="project"&&$&&A&&P&&(J[B.projectFilePath]=Ti(A,P,{mainSource:B.mainSourcePath,publication:B.publicationPath}),B.publicationPath in J||(J[B.publicationPath]=He()))}else J["source/main.ptx"]=b.pretextSource;for(const[Q,Y]of Object.entries(a)){const rt=oo(Q);rt&&!(rt in J)&&(J[rt]=Y)}const K=C.project.documentKind,G=[...b.warnings,...h,...v,...yo(F),...et,...C.warnings];let V,ut;return b.cleanedNativeSource!==void 0&&b.cleanedNativeSource.length>0&&(b.sourceFormat==="latex"||b.sourceFormat==="markdown")&&(V={[b.sourceFormat==="latex"?"source/main.tex":"source/main.md"]:b.cleanedNativeSource},ut=un(b.cleanedNativeSource,b.sourceFormat,{documentKind:K,splitLevel:O,title:C.project.title,docinfo:C.project.docinfo,assets:W}).project),Object.keys(S).length>0&&n.push({type:"success",message:`Routed ${Object.keys(L).length} binary asset${Object.keys(L).length===1?"":"s"}.`}),{...b,pretextSource:it,warnings:G,destination:i,selection:r.selection,rebuiltWarnings:et,insert:nt?{unwrapRoot:nt.unwrapRoot,includes:e,renamed:nt.renamed,retargetDelta:nt.retarget.delta,preparedSource:U}:void 0,sourcePath:l,sourceName:yt(l),sourceType:f,analysis:o,attachedRoots:w,projectLayout:B,project:C.project,nativeProject:ut,files:a,assets:S,outputFiles:J,outputAssets:L,nativeOutputFiles:V,documentKind:K,cleanChunks:b.cleanChunks??[],splitLevel:O,statusMessages:n}}catch(a){const s=a instanceof Error?a.message:String(a);return n.push({type:"error",message:s}),{pretextError:s,statusMessages:n,warnings:[]}}}async function wo(t,r={}){const n=[],i=mt(t.name);if(!no.test(i.toLowerCase()))return{pretextError:"File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.",statusMessages:[{type:"error",message:"File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz."}],warnings:[]};n.push({type:"loading",message:`Processing ${i}...`});try{const{files:e,assets:a}=await Oi(t),s=zi(e,{...r,assets:a});return{...s,statusMessages:[...n,...s.statusMessages]}}catch(e){const a=e instanceof Error?e.message:String(e);return{pretextError:a,statusMessages:[...n,{type:"error",message:a}],warnings:[]}}}function Li(t,r){return t.splitLevel!==void 0?Math.max(0,t.splitLevel):t.splitChapters===!1?0:t.splitSections?r.documentKind==="book"?2:1:t.splitChapters?1:r.format==="latex"&&r.latexSource?Ur(r.latexSource,r.documentKind??(r.latexSource.includes("\\chapter")?"book":"article")):r.documentKind==="book"?1:0}function _o(t){const r=t.lastIndexOf("/");return r<0?"":t.slice(0,r+1)}function yo(t){if(!t||t.unresolved.length===0)return[];const r=[...new Set(t.unresolved)];return[{action:"anomaly",severity:"warning",kind:"structure",category:"missing_image",macro:"image",occurrences:r.length,message:`The document refers to ${r.length} image${r.length===1?"":"s"} the upload did not include (${r.slice(0,5).join(", ")}${r.length>5?", …":""}); ${r.length===1?"its reference was":"their references were"} left as written, so add the file${r.length===1?"":"s"} to the project's external directory.`}]}function $i(t){return t.removed.length===0?[]:[{action:"delete",severity:"info",kind:"structure",category:"unselected_divisions",macro:"division",occurrences:t.removed.length,message:`${t.removed.length} division${t.removed.length===1?" was":"s were"} left out of this import; only the divisions you selected were converted.`}]}function ye(t,r={}){const n=r.targetTag!==void 0&&t.destination.kind==="insert"?{...t.destination,targetTag:r.targetTag}:t.destination,i=r.selection??t.selection,e=gn(t.pretextSource,i),a=n.kind==="insert"?pn(e.source,n,{hasSelection:(i?.length??0)>0}):void 0,s=Math.max(bi(a?.unwrapRoot??!1),r.splitLevel??t.splitLevel),o=t.destination.kind!=="insert"||n.kind!=="insert"||n.targetTag===t.destination.targetTag,c=(i??[]).join(" ")===(t.selection??[]).join(" ");if(s===t.splitLevel&&o&&c)return t;const l=ln(a?.source??e.source,{documentKind:t.documentKind,splitLevel:s,assets:t.assets,takenIds:n.kind==="insert"?n.takenIds:void 0}),f={};if(n.kind==="project")for(const[v,b]of Object.entries(t.outputFiles))Eo(v,t.projectLayout.mainSourcePath)||(f[v]=b);const p=fn(l.project,n,{layout:{mainSourcePath:t.projectLayout.mainSourcePath,publicationPath:t.projectLayout.publicationPath,projectFilePath:t.projectLayout.projectFilePath,includeScaffold:!t.projectLayout.preserved},unwrapRoot:t.insert?.unwrapRoot});Object.assign(f,p.files);let g=t.nativeProject;t.cleanedNativeSource&&(t.sourceFormat==="latex"||t.sourceFormat==="markdown")&&(g=un(t.cleanedNativeSource,t.sourceFormat,{documentKind:t.documentKind,splitLevel:s,title:l.project.title,docinfo:l.project.docinfo,assets:t.assets}).project);const d=[...$i(e),...a?.warnings??[]],w=new Set(t.rebuiltWarnings),h=[...t.warnings.filter(v=>!w.has(v)),...d];return{...t,splitLevel:s,project:l.project,nativeProject:g,outputFiles:f,destination:n,selection:i,warnings:h,rebuiltWarnings:d,insert:a&&t.insert?{unwrapRoot:a.unwrapRoot,includes:p.includes,renamed:a.renamed,retargetDelta:a.retarget.delta,preparedSource:a.source}:t.insert}}function xo(t,r){return ye(t,{selection:r})}function ko(t,r){return ye(t,{splitLevel:r})}function So(t,r){return ye(t,{targetTag:r})}function Eo(t,r){if(t===r)return!0;const n=r.includes("/")?r.slice(0,r.lastIndexOf("/")+1):"";return t.startsWith(n)&&t.endsWith(".ptx")}exports.CLEAN_RULES=Fr;exports.DIVISION_LADDER=Lt;exports.LADDER_OVERFLOW_TAG=sn;exports.LATEX_DIVISION_COMMANDS=Ye;exports.LATEX_FORMAT_MARKERS=Lr;exports.MARKDOWN_FORMAT_MARKERS=$r;exports.MAX_SUGGESTED_SPLIT_LEVEL=Mr;exports.PRETEXT_DIVISION_TAGS=ni;exports.PRETEXT_ROOT_TAGS=us;exports.PROJECT_DESTINATION=pi;exports.analyzeImportSources=xi;exports.applyLatexFixes=Br;exports.attachLatexRoots=Ei;exports.attachMarkdownRoots=Ai;exports.buildDivisionPool=ln;exports.buildNativeDivisionPool=un;exports.carryOverProjectFiles=Ii;exports.cleanLatex=Xa;exports.cleanLatexInChunks=Xr;exports.cleanLatexText=me;exports.convertLatexToPretext=Gr;exports.convertMarkdownToPretext=Hr;exports.convertSourceToPretext=Jr;exports.dedupeXmlIds=mi;exports.defaultAttachLevel=Si;exports.defaultManifestTarget=_i;exports.detectDocumentKind=nn;exports.detectSourceFormat=ee;exports.divisionChildRefs=Zt;exports.divisionsAtLevel=ue;exports.ensureXIncludeNamespace=ce;exports.expandPretextIncludes=ei;exports.extractUpload=Oi;exports.filePrefixForDivision=_e;exports.findAnyElement=Mt;exports.findLatexFixes=Tt;exports.findLatexHeaders=be;exports.findProjectManifest=wi;exports.findTopLevelElements=tn;exports.fixesToWarnings=Ke;exports.getConversionErrorMessage=Yr;exports.getLatexCleanDiagnostics=Ra;exports.handleImportUploadFile=wo;exports.importProjectFromFiles=zi;exports.insertEntries=fi;exports.isDivisionTag=It;exports.ladderDepth=$t;exports.latexDivisionHierarchy=ve;exports.latexFixesToCodeActions=Oa;exports.mergeChunksAtLevel=Ga;exports.normalizePretextSource=we;exports.outlineDivisions=to;exports.padIndex=Vt;exports.parseLatexDivisions=Je;exports.parseProjectManifest=vi;exports.prepareInsertSource=pn;exports.pruneDivisions=gn;exports.rebuildImport=ye;exports.relayoutImport=ko;exports.renderProjectPtx=Nr;exports.renderProjectPtxFromManifest=Ti;exports.renderPublicationPtx=He;exports.reselectImport=xo;exports.resolveImportSplitLevel=Li;exports.resolveSplitLevel=cn;exports.retargetFragment=Es;exports.retargetFragmentToDepth=hn;exports.retargetImport=So;exports.sanitizeRef=Pt;exports.serializeForDestination=fn;exports.serializeInsertFiles=hi;exports.serializeProjectToFiles=di;exports.shiftLadderTag=ri;exports.slugify=ge;exports.spliceReplacements=Dt;exports.suggestSplitLevel=Ur;exports.withProlog=le;
|