mathpix-markdown-it
Version:
Mathpix-markdown-it is an open source implementation of the mathpix-markdown spec written in Typescript. It relies on the following open source libraries: MathJax v3 (to render math with SVGs), markdown-it (for standard Markdown parsing)
1 lines • 342 kB
JavaScript
(()=>{var __webpack_modules__={606:e=>{var t,n,r=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var a,c=[],l=!1,u=-1;function d(){l&&a&&(l=!1,a.length?c=a.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(a=c,c=[];++u<t;)a&&a[u].run();u=-1,t=c.length}a=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new p(e,t)),1!==c.length||l||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},453:function(module,__unused_webpack_exports,__webpack_require__){var __dirname="/",process=__webpack_require__(606),t;t=()=>(()=>{"use strict";var __webpack_modules__={4601:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractAudioRenderer=void 0;const r=n(3684);t.AbstractAudioRenderer=class{constructor(){this.separator_=" "}setSeparator(e){this.separator_=e}getSeparator(){return"braille"===r.default.getInstance().modality?"":this.separator_}error(e){return null}merge(e){let t="";const n=e.length-1;for(let r,i=0;r=e[i];i++)if(t+=r.speech,i<n){const e=r.attributes.separator;t+=void 0!==e?e:this.getSeparator()}return t}finalize(e){return e}pauseValue(e){let t;switch(e){case"long":t=750;break;case"medium":t=500;break;case"short":t=250;break;default:t=parseInt(e,10)}return Math.floor(t*r.default.getInstance().getRate()/100)}}},2575:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AcssRenderer=void 0;const r=n(9686),i=n(5390),o=n(3778),s=n(9569);class a extends s.MarkupRenderer{markup(e){this.setScaleFunction(-2,2,0,10,0);const t=o.personalityMarkup(e),n=[],r={open:[]};let i=null,s=!1;for(let e,a=0;e=t[a];a++){if(o.isMarkupElement(e)){o.mergeMarkup(r,e);continue}if(o.isPauseElement(e)){s&&(i=o.mergePause(i,e,Math.max));continue}const t='"'+this.merge(e.span)+'"';s=!0,i&&(n.push(this.pause(i)),i=null);const a=this.prosody_(r);n.push(a?"(text ("+a+") "+t+")":t)}return"(exp "+n.join(" ")+")"}error(e){return'(error "'+i.Move.get(e)+'")'}prosodyElement(e,t){switch(t=this.applyScaleFunction(t),e){case r.personalityProps.RATE:return"(richness . "+t+")";case r.personalityProps.PITCH:return"(average-pitch . "+t+")";case r.personalityProps.VOLUME:return"(stress . "+t+")"}return"(value . "+t+")"}pause(e){return"(pause . "+this.pauseValue(e[r.personalityProps.PAUSE])+")"}prosody_(e){const t=e.open,n=[];for(let r,i=0;r=t[i];i++)n.push(this.prosodyElement(r,e[r]));return n.join(" ")}}t.AcssRenderer=a},3778:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSpanElement=t.isPauseElement=t.isMarkupElement=t.personalityMarkup=t.sortClose=t.mergeMarkup=t.mergePause=void 0;const r=n(4422),i=n(9686),o=n(4752);function s(e,t,n){return(n||function(n,r){return"number"==typeof n&&"number"==typeof r?n+r:"number"==typeof n?r:"number"==typeof r?n:[e,t].sort()[0]}).call(null,e,t)}t.mergePause=function(e,t,n){return e?{pause:s(e.pause,t.pause,n)}:t},t.mergeMarkup=function(e,t){delete e.open,t.close.forEach((t=>delete e[t])),t.open.forEach((n=>e[n]=t[n]));const n=Object.keys(e);e.open=n},t.sortClose=function(e,t){if(e.length<=1)return e;const n=[];for(let r,i=0;r=t[i],e.length;i++)r.close&&r.close.length&&r.close.forEach((function(t){const r=e.indexOf(t);-1!==r&&(n.unshift(t),e.splice(r,1))}));return n};let a={},c=[];function l(e,t){const n=e[e.length-1];if(n){if(p(t)&&p(n)){if(void 0===n.join)return void(n.span=n.span.concat(t.span));const e=n.span.pop(),r=t.span.shift();return n.span.push(e+n.join+r),n.span=n.span.concat(t.span),void(n.join=t.join)}h(t)&&h(n)?n.pause=s(n.pause,t.pause):e.push(t)}else e.push(t)}function u(e,t){e.rate&&(t.rate=e.rate),e.pitch&&(t.pitch=e.pitch),e.volume&&(t.volume=e.volume)}function d(e){return"object"==typeof e&&e.open}function h(e){return"object"==typeof e&&1===Object.keys(e).length&&Object.keys(e)[0]===i.personalityProps.PAUSE}function p(e){const t=Object.keys(e);return"object"==typeof e&&(1===t.length&&"span"===t[0]||2===t.length&&("span"===t[0]&&"join"===t[1]||"span"===t[1]&&"join"===t[0]))}function f(e,t,n,r,a,c=!1){if(c){const c=e[e.length-1];let l;if(c&&(l=c[i.personalityProps.JOIN]),c&&!t.speech&&a&&h(c)){const e=i.personalityProps.PAUSE;c[e]=s(c[e],a[e]),a=null}if(c&&t.speech&&0===Object.keys(n).length&&p(c)){if(void 0!==l){const e=c.span.pop();t=new o.Span(e.speech+l+t.speech,e.attributes)}c.span.push(t),t=new o.Span("",{}),c[i.personalityProps.JOIN]=r}}0!==Object.keys(n).length&&e.push(n),t.speech&&e.push({span:[t],join:r}),a&&e.push(a)}function m(e,t){if(!t)return e;const n={};for(const r of i.personalityPropList){const i=e[r],o=t[r];if(!i&&!o||i&&o&&i===o)continue;const s=i||0;d(n)||(n.open=[],n.close=[]),i||n.close.push(r),o||n.open.push(r),o&&i&&(n.close.push(r),n.open.push(r)),t[r]=s,n[r]=s,a[r]?a[r].push(s):a[r]=[s]}if(d(n)){let e=n.close.slice();for(;e.length>0;){let i=c.pop();const o=(0,r.setdifference)(i,e);if(e=(0,r.setdifference)(e,i),i=o,0!==e.length){if(0!==i.length){n.close=n.close.concat(i),n.open=n.open.concat(i);for(let e,r=0;e=i[r];r++)n[e]=t[e]}}else 0!==i.length&&c.push(i)}c.push(n.open)}return n}t.personalityMarkup=function(e){a={},c=[];let t=[];const n={};for(let r,o=0;r=e[o];o++){let e=null;const o=r.descriptionSpan(),s=r.personality,a=s[i.personalityProps.JOIN];delete s[i.personalityProps.JOIN],void 0!==s[i.personalityProps.PAUSE]&&(e={[i.personalityProps.PAUSE]:s[i.personalityProps.PAUSE]},delete s[i.personalityProps.PAUSE]),f(t,o,m(s,n),a,e,!0)}return t=t.concat(function(){const e=[];for(let t=c.length-1;t>=0;t--){const n=c[t];if(n.length){const t={open:[],close:[]};for(let e=0;e<n.length;e++){const r=n[e];t.close.push(r),t[r]=0}e.push(t)}}return e}()),t=function(e){const t={},n=[];for(let r,i=0;r=e[i];i++){if(!d(r)){l(n,r);continue}if(!r.close||1!==r.close.length||r.open.length){u(r,t),n.push(r);continue}let o=e[i+1];if(!o||p(o)){u(r,t),n.push(r);continue}const s=h(o)?o:null;s&&(o=e[i+2]),o&&d(o)&&o.open[0]===r.close[0]&&!o.close.length&&o[o.open[0]]===t[o.open[0]]?s?(l(n,s),i+=2):i+=1:(u(r,t),n.push(r))}return n}(t),t},t.isMarkupElement=d,t.isPauseElement=h,t.isSpanElement=p},2975:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AuditoryDescription=void 0;const r=n(7534),i=n(4752);class o{constructor({context:e,text:t,userValue:n,annotation:r,attributes:i,personality:o,layout:s}){this.context=e||"",this.text=t||"",this.userValue=n||"",this.annotation=r||"",this.attributes=i||{},this.personality=o||{},this.layout=s||""}static create(e,t={}){return e.text=r.Grammar.getInstance().apply(e.text,t),new o(e)}isEmpty(){return 0===this.context.length&&0===this.text.length&&0===this.userValue.length&&0===this.annotation.length}clone(){let e,t;if(this.personality){e={};for(const t in this.personality)e[t]=this.personality[t]}if(this.attributes){t={};for(const e in this.attributes)t[e]=this.attributes[e]}return new o({context:this.context,text:this.text,userValue:this.userValue,annotation:this.annotation,personality:e,attributes:t,layout:this.layout})}toString(){return'AuditoryDescription(context="'+this.context+'" text="'+this.text+'" userValue="'+this.userValue+'" annotation="'+this.annotation+'")'}descriptionString(){return this.context&&this.text?this.context+" "+this.text:this.context||this.text}descriptionSpan(){return new i.Span(this.descriptionString(),this.attributes)}equals(e){return this.context===e.context&&this.text===e.text&&this.userValue===e.userValue&&this.annotation===e.annotation}}t.AuditoryDescription=o},840:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isXml=t.registerRenderer=t.error=t.finalize=t.merge=t.markup=t.getSeparator=t.setSeparator=void 0;const r=n(3684),i=n(9686),o=n(2575),s=n(9413),a=n(3064),c=n(9815),l=n(4752),u=n(4238),d=n(1990),h=n(6310),p=n(8155),f=new u.SsmlRenderer,m=new Map([[i.Markup.NONE,new h.StringRenderer],[i.Markup.PUNCTUATION,new a.PunctuationRenderer],[i.Markup.LAYOUT,new s.LayoutRenderer],[i.Markup.ACSS,new o.AcssRenderer],[i.Markup.SABLE,new c.SableRenderer],[i.Markup.VOICEXML,f],[i.Markup.SSML,f],[i.Markup.SSML_STEP,new d.SsmlStepRenderer]]);t.setSeparator=function(e){const t=m.get(r.default.getInstance().markup);t&&t.setSeparator(e)},t.getSeparator=function(){const e=m.get(r.default.getInstance().markup);return e?e.getSeparator():""},t.markup=function(e){const t=m.get(r.default.getInstance().markup);return t?t.markup(e):""},t.merge=function(e){const t=e.map((e=>"string"==typeof e?new l.Span(e,{}):e)),n=m.get(r.default.getInstance().markup);return n?n.merge(t):e.join()},t.finalize=function(e){const t=m.get(r.default.getInstance().markup);return t?t.finalize(e):e},t.error=function(e){const t=m.get(r.default.getInstance().markup);return t?t.error(e):""},t.registerRenderer=function(e,t){m.set(e,t)},t.isXml=function(){return m.get(r.default.getInstance().markup)instanceof p.XmlRenderer}},9413:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LayoutRenderer=void 0;const r=n(5605),i=n(7041),o=n(9686),s=n(3778),a=n(8155);class c extends a.XmlRenderer{finalize(e){return function(e){l="";const t=i.parseInput(`<all>${e}</all>`);return r.Debugger.getInstance().output(i.formatXml(t.toString())),l=p(t),l}(e)}pause(e){return""}prosodyElement(e,t){return e===o.personalityProps.LAYOUT?`<${t}>`:""}closeTag(e){return`</${e}>`}markup(e){const t=[];let n=[];for(const r of e){if(!r.layout){n.push(r);continue}t.push(this.processContent(n)),n=[];const e=r.layout;e.match(/^begin/)?t.push("<"+e.replace(/^begin/,"")+">"):e.match(/^end/)?t.push("</"+e.replace(/^end/,"")+">"):console.warn("Something went wrong with layout markup: "+e)}return t.push(this.processContent(n)),t.join("")}processContent(e){const t=[],n=s.personalityMarkup(e);for(let e,r=0;e=n[r];r++)e.span?t.push(this.merge(e.span)):s.isPauseElement(e);return t.join("")}}t.LayoutRenderer=c;let l="";const u={TABLE:function(e){let t=S(e);t.forEach((e=>{e.cells=e.cells.slice(1).slice(0,-1),e.width=e.width.slice(1).slice(0,-1)}));const[n,r]=b(t);return t=y(t,r),N(t,n)},CASES:function(e){let t=S(e);t.forEach((e=>{e.cells=e.cells.slice(0,-1),e.width=e.width.slice(0,-1)}));const[n,r]=b(t);return t=y(t,r),N(t,n)},CAYLEY:function(e){let t=S(e);t.forEach((e=>{e.cells=e.cells.slice(1).slice(0,-1),e.width=e.width.slice(1).slice(0,-1),e.sep=e.sep+e.sep}));const[n,r]=b(t),i={lfence:"",rfence:"",cells:r.map((e=>"⠐"+new Array(e).join("⠒"))),width:r,height:1,sep:t[0].sep};return t.splice(1,0,i),t=y(t,r),N(t,n)},MATRIX:function(e){let t=S(e);const[n,r]=b(t);return t=y(t,r),N(t,n)},CELL:p,FENCE:p,ROW:p,FRACTION:function(e){const[t,n,,r,i]=Array.from(e.childNodes),o=d(n),s=d(r),a=m(o),c=m(s);let l=Math.max(a,c);const u=t+new Array(l+1).join("⠒")+i;return l=u.length,`${C(o,l)}\n${u}\n${C(s,l)}`},NUMERATOR:T,DENOMINATOR:T};function d(e){const t=i.tagName(e),n=u[t];return n?n(e):e.textContent}function h(e,t){if(!e||!t)return e+t;const n=f(e),r=f(t),i=n-r;e=i<0?g(e,r,m(e)):e,t=i>0?g(t,n,m(t)):t;const o=e.split(/\r\n|\r|\n/),s=t.split(/\r\n|\r|\n/),a=[];for(let e=0;e<o.length;e++)a.push(o[e]+s[e]);return a.join("\n")}function p(e){let t="";for(const n of Array.from(e.childNodes))t=n.nodeType!==i.NodeType.TEXT_NODE?h(t,d(n)):h(t,n.textContent);return t}function f(e){return e.split(/\r\n|\r|\n/).length}function m(e){return e.split(/\r\n|\r|\n/).reduce(((e,t)=>Math.max(t.length,e)),0)}function g(e,t,n){return e=function(e,t){const n=t-f(e);return e+(n>0?new Array(n+1).join("\n"):"")}(e,t),function(e,t){const n=e.split(/\r\n|\r|\n/),r=[];for(const e of n){const n=t-e.length;r.push(e+(n>0?new Array(n+1).join("⠀"):""))}return r.join("\n")}(e,n)}function S(e){const t=Array.from(e.childNodes),n=[];for(const e of t)e.nodeType===i.NodeType.ELEMENT_NODE&&n.push(_(e));return n}function b(e){const t=e.reduce(((e,t)=>Math.max(t.height,e)),0),n=[];for(let t=0;t<e[0].width.length;t++)n.push(e.map((e=>e.width[t])).reduce(((e,t)=>Math.max(e,t)),0));return[t,n]}function y(e,t){const n=[];for(const r of e){if(0===r.height)continue;const e=[];for(let n=0;n<r.cells.length;n++)e.push(g(r.cells[n],r.height,t[n]));r.cells=e,n.push(r)}return n}function N(e,t){if(1===t)return e.map((e=>e.lfence+e.cells.join(e.sep)+e.rfence)).join("\n");const n=[];for(const t of e){const e=E(t.sep,t.height);let r=t.cells.shift();for(;t.cells.length;)r=h(r,e),r=h(r,t.cells.shift());r=h(E(t.lfence,t.height),r),r=h(r,E(t.rfence,t.height)),n.push(r),n.push(t.lfence+new Array(m(r)-3).join(t.sep)+t.rfence)}return n.slice(0,-1).join("\n")}function E(e,t){let n="";for(;t;)n+=e+"\n",t--;return n.slice(0,-1)}function A(e){return e.nodeType===i.NodeType.ELEMENT_NODE&&"FENCE"===i.tagName(e)?d(e):""}function _(e){const t=Array.from(e.childNodes),n=A(t[0]),r=A(t[t.length-1]);n&&t.shift(),r&&t.pop();let o="";const s=[];for(const e of t){if(e.nodeType===i.NodeType.TEXT_NODE){o=e.textContent;continue}const t=d(e);s.push(t)}return{lfence:n,rfence:r,sep:o,cells:s,height:s.reduce(((e,t)=>Math.max(f(t),e)),0),width:s.map(m)}}function C(e,t){const n=(t-m(e))/2,[r,i]=Math.floor(n)===n?[n,n]:[Math.floor(n),Math.ceil(n)],o=e.split(/\r\n|\r|\n/),s=[],[a,c]=[new Array(r+1).join("⠀"),new Array(i+1).join("⠀")];for(const e of o)s.push(a+e+c);return s.join("\n")}function T(e){const t=e.firstChild,n=p(e);if(t&&t.nodeType===i.NodeType.ELEMENT_NODE){if("ENGLISH"===i.tagName(t))return"⠰"+n;if("NUMBER"===i.tagName(t))return"⠼"+n}return n}},9569:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MarkupRenderer=void 0;const r=n(9686),i=n(4601);class o extends i.AbstractAudioRenderer{constructor(){super(...arguments),this.ignoreElements=[r.personalityProps.LAYOUT],this.scaleFunction=null}setScaleFunction(e,t,n,r,i=0){this.scaleFunction=o=>{const s=(o-e)/(t-e),a=n*(1-s)+r*s;return+(Math.round(a+"e+"+i)+"e-"+i)}}applyScaleFunction(e){return this.scaleFunction?this.scaleFunction(e):e}ignoreElement(e){return-1!==this.ignoreElements.indexOf(e)}}t.MarkupRenderer=o},3064:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PunctuationRenderer=void 0;const r=n(9686),i=n(4601),o=n(3778);class s extends i.AbstractAudioRenderer{markup(e){const t=o.personalityMarkup(e);let n="",i=null,s=!1;for(let e,a=0;e=t[a];a++)o.isMarkupElement(e)||(o.isPauseElement(e)?s&&(i=o.mergePause(i,e,Math.max)):(i&&(n+=this.pause(i[r.personalityProps.PAUSE]),i=null),n+=(s?this.getSeparator():"")+this.merge(e.span),s=!0));return n}pause(e){let t;return t="number"==typeof e?e<=250?"short":e<=500?"medium":"long":e,s.PAUSE_PUNCTUATION.get(t)||""}}t.PunctuationRenderer=s,s.PAUSE_PUNCTUATION=new Map([["short",","],["medium",";"],["long","."]])},9815:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SableRenderer=void 0;const r=n(9686),i=n(8155);class o extends i.XmlRenderer{finalize(e){return'<?xml version="1.0"?><!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN" "Sable.v0_2.dtd" []><SABLE>'+this.getSeparator()+e+this.getSeparator()+"</SABLE>"}pause(e){return'<BREAK MSEC="'+this.pauseValue(e[r.personalityProps.PAUSE])+'"/>'}prosodyElement(e,t){switch(t=this.applyScaleFunction(t),e){case r.personalityProps.PITCH:return'<PITCH RANGE="'+t+'%">';case r.personalityProps.RATE:return'<RATE SPEED="'+t+'%">';case r.personalityProps.VOLUME:return'<VOLUME LEVEL="'+t+'%">';default:return"<"+e.toUpperCase()+' VALUE="'+t+'">'}}closeTag(e){return"</"+e.toUpperCase()+">"}}t.SableRenderer=o},4752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Span=void 0,t.Span=class{constructor(e,t){this.speech=e,this.attributes=t}}},4238:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SsmlRenderer=void 0;const r=n(3684),i=n(9686),o=n(8155);class s extends o.XmlRenderer{finalize(e){return'<?xml version="1.0"?><speak version="1.1" xmlns="http://www.w3.org/2001/10/synthesis"><prosody rate="'+r.default.getInstance().getRate()+'%">'+this.getSeparator()+e+this.getSeparator()+"</prosody></speak>"}pause(e){return'<break time="'+this.pauseValue(e[i.personalityProps.PAUSE])+'ms"/>'}prosodyElement(e,t){const n=(t=Math.floor(this.applyScaleFunction(t)))<0?t.toString():"+"+t.toString();return"<prosody "+e.toLowerCase()+'="'+n+(e===i.personalityProps.VOLUME?">":'%">')}closeTag(e){return"</prosody>"}}t.SsmlRenderer=s},1990:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SsmlStepRenderer=void 0;const r=n(4238);class i extends r.SsmlRenderer{markup(e){return i.MARKS={},super.markup(e)}merge(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n],o=r.attributes.extid;o&&!i.MARKS[o]&&(t.push('<mark name="'+o+'"/>'),i.MARKS[o]=!0),1===r.speech.length&&r.speech.match(/[a-zA-Z]/)?t.push('<say-as interpret-as="'+i.CHARACTER_ATTR+'">'+r.speech+"</say-as>"):t.push(r.speech)}return t.join(this.getSeparator())}}t.SsmlStepRenderer=i,i.CHARACTER_ATTR="character",i.MARKS={}},6310:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringRenderer=void 0;const r=n(4601),i=n(3778);class o extends r.AbstractAudioRenderer{markup(e){let t="";const n=(0,i.personalityMarkup)(e).filter((e=>e.span));if(!n.length)return t;const r=n.length-1;for(let e,i=0;e=n[i];i++){if(e.span&&(t+=this.merge(e.span)),i>=r)continue;const n=e.join;t+=void 0===n?this.getSeparator():n}return t}}t.StringRenderer=o},8155:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XmlRenderer=void 0;const r=n(3684),i=n(3778),o=n(9569);class s extends o.MarkupRenderer{markup(e){this.setScaleFunction(-2,2,-100,100,2);const t=i.personalityMarkup(e),n=[],o=[];for(let e,s=0;e=t[s];s++)if(e.span)n.push(this.merge(e.span));else if(i.isPauseElement(e))n.push(this.pause(e));else{if(e.close.length)for(let t=0;t<e.close.length;t++){const t=o.pop();if(-1===e.close.indexOf(t))throw new r.SREError("Unknown closing markup element: "+t);n.push(this.closeTag(t))}e.open.length&&i.sortClose(e.open.slice(),t.slice(s+1)).forEach((t=>{n.push(this.prosodyElement(t,e[t])),o.push(t)}))}return n.join(" ")}}t.XmlRenderer=s},4422:(e,t)=>{function n(e,t){return e?t?e.filter((e=>t.indexOf(e)<0)):e:[]}Object.defineProperty(t,"__esModule",{value:!0}),t.union=t.setdifference=t.interleaveLists=t.removeEmpty=void 0,t.removeEmpty=function(e){return e.filter((e=>e))},t.interleaveLists=function(e,t){const n=[];for(;e.length||t.length;)e.length&&n.push(e.shift()),t.length&&n.push(t.shift());return n},t.setdifference=n,t.union=function(e,t){return e&&t?e.concat(n(t,e)):e||t||[]}},4698:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.loadScript=t.loadMapsForIE_=t.installWGXpath_=t.loadWGXpath_=t.mapsForIE=t.detectEdge=t.detectIE=void 0;const r=n(495),i=n(1746);function o(e){c(r.default.WGXpath),s(e)}function s(e,t){let n=t||1;"undefined"==typeof wgxpath&&n<10?setTimeout((function(){s(e,n++)}),200):n>=10||(r.default.wgxpath=wgxpath,e?r.default.wgxpath.install({document}):r.default.wgxpath.install(),i.xpath.evaluate=document.evaluate,i.xpath.result=XPathResult,i.xpath.createNSResolver=document.createNSResolver)}function a(){c(r.default.mathmapsIePath)}function c(e){const t=r.default.document.createElement("script");t.type="text/javascript",t.src=e,r.default.document.head?r.default.document.head.appendChild(t):r.default.document.body.appendChild(t)}t.detectIE=function(){return"undefined"!=typeof window&&"ActiveXObject"in window&&"clipboardData"in window&&(a(),o(),!0)},t.detectEdge=function(){var e;return"undefined"!=typeof window&&"MSGestureEvent"in window&&null===(null===(e=window.chrome)||void 0===e?void 0:e.loadTimes)&&(document.evaluate=null,o(!0),!0)},t.mapsForIE=null,t.loadWGXpath_=o,t.installWGXpath_=s,t.loadMapsForIE_=a,t.loadScript=c},7090:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Cli=void 0;const i=n(3113),o=n(8844),s=n(5124),a=n(9050),c=n(5605),l=n(3684),u=n(9686),d=n(9190),h=n(2114),p=n(495),f=n(6948);t.Cli=class{constructor(){this.process=p.default.extRequire("process"),this.setup={mode:u.Mode.SYNC},this.processors=[],this.output=this.process.stdout,this.dp=new p.default.xmldom.DOMParser({errorHandler:(e,t)=>{throw new l.SREError("XML DOM error!")}})}set(e,t,n){this.setup[e]=void 0===t||t}processor(e){this.processors.push(e)}loadLocales(){return r(this,void 0,void 0,(function*(){for(const e of f.Variables.LOCALES.keys())yield h.setupEngine({locale:e})}))}enumerate(e=!1){return r(this,void 0,void 0,(function*(){const t=h.setupEngine(this.setup);return(e?this.loadLocales():t).then((()=>l.EnginePromise.getall().then((()=>{const e=i.DynamicCstr.DEFAULT_ORDER.map((e=>e.length)),t=(t,n)=>{e[n]=Math.max.apply(null,Object.keys(t).map((e=>e.length)).concat(e[n]))},n=(e,t)=>e+new Array(t-e.length+1).join(" ");let r=s.SpeechRuleEngine.getInstance().enumerate();r=o.enumerate(r);const c=[];t(r,0);for(const i in r){let o=!0;const s=r[i];t(s,1);for(const l in s){let u=!0;const d=s[l];t(d,2);for(const t in d){const s=Object.keys(d[t]).sort();if("clearspeak"===t){let s=!0;const d=a.ClearspeakPreferences.getLocalePreferences(r)[i];for(const r in d)c.push([n(o?i:"",e[0]),n(u?l:"",e[1]),n(s?t:"",e[2]),d[r].join(", ")]),o=!1,u=!1,s=!1}else c.push([n(o?i:"",e[0]),n(u?l:"",e[1]),n(t,e[2]),s.join(", ")]);o=!1,u=!1}}}let l=0,u="";u+=i.DynamicCstr.DEFAULT_ORDER.slice(0,-1).map((t=>n(t,e[l++]))).join(" | "),u+="\n",e.forEach((e=>u+=new Array(e+3).join("="))),u+="========================\n",u+=c.map((e=>e.join(" | "))).join("\n"),console.info(u)}))))}))}execute(e){l.EnginePromise.getall().then((()=>{this.runProcessors_(((e,t)=>this.output.write(h.processFile(e,t)+"\n")),e)}))}readline(){this.process.stdin.setEncoding("utf8");const e=p.default.extRequire("readline").createInterface({input:this.process.stdin,output:this.output});let t="";e.on("line",(n=>{t+=n,this.readExpression_(t)&&e.close()}).bind(this)),e.on("close",(()=>{this.runProcessors_(((t,n)=>{e.output.write(d.output(t,n)+"\n")}),t),h.engineReady().then((()=>c.Debugger.getInstance().exit((()=>h.exit(0)))))}).bind(this))}commandLine(){return r(this,void 0,void 0,(function*(){const e=p.default.commander,t=h,n=(e=>(t,n)=>this.set(e,t,n)).bind(this),r=this.processor.bind(this);e.version(t.version).usage("[options] <file ...>").option("-i, --input [name]","Input file [name]. (Deprecated)").option("-o, --output [name]","Output file [name]. Defaults to stdout.").option("-d, --domain [name]","Speech rule set [name]. See --options for details.",n(i.Axis.DOMAIN),i.DynamicCstr.DEFAULT_VALUES[i.Axis.DOMAIN]).option("-t, --style [name]","Speech style [name]. See --options for details.",n(i.Axis.STYLE),i.DynamicCstr.DEFAULT_VALUES[i.Axis.STYLE]).option("-c, --locale [code]","Locale [code].",n(i.Axis.LOCALE),i.DynamicCstr.DEFAULT_VALUES[i.Axis.LOCALE]).option("-b, --modality [name]","Modality [name].",n(i.Axis.MODALITY),i.DynamicCstr.DEFAULT_VALUES[i.Axis.MODALITY]).option("-k, --markup [name]","Generate speech output with markup tags.",n("markup"),"none").option("-r, --rate [value]","Base rate [value] for tagged speech output.",n("rate"),"100").option("-p, --speech","Generate speech output (default).",(()=>r("speech"))).option("-a, --audit","Generate auditory descriptions (JSON format).",(()=>r("description"))).option("-j, --json","Generate JSON of semantic tree.",(()=>r("json"))).option("-x, --xml","Generate XML of semantic tree.",(()=>r("semantic"))).option("-m, --mathml","Generate enriched MathML.",(()=>r("enriched"))).option("-g, --generate <depth>","Include generated speech in enriched MathML (with -m option only).",n("speech"),"none").option("-w, --structure","Include structure attribute in enriched MathML (with -m option only).",n("structure")).option("-P, --pprint","Pretty print output whenever possible.",n("pprint")).option("-f, --rules [name]","Loads a local rule file [name].",n("rules")).option("-C, --subiso [name]","Supplementary country code (or similar) for the given locale.",n("subiso")).option("-N, --number","Translate number to word.",(()=>r("number"))).option("-O, --ordinal","Translate number to ordinal.",(()=>r("ordinal")),"ordinal").option("-S, --numeric","Translate number to numeric ordinal.",(()=>r("numericOrdinal"))).option("-F, --vulgar","Translate vulgar fraction to word. Provide vulgar fraction as slash seperated numbers.",(()=>r("vulgar"))).option("-v, --verbose","Verbose mode.").option("-l, --log [name]","Log file [name].").option("--opt","List engine setup options.").option("--opt-all","List engine setup options for all available locales.").on("option:opt",(()=>{this.enumerate().then((()=>h.exit(0)))})).on("option:opt-all",(()=>{this.enumerate(!0).then((()=>h.exit(0)))})).parse(this.process.argv),yield h.engineReady().then((()=>h.setupEngine(this.setup)));const o=e.opts();o.output&&(this.output=p.default.fs.createWriteStream(o.output)),o.verbose&&(yield c.Debugger.getInstance().init(o.log)),o.input&&this.execute(o.input),e.args.length?(e.args.forEach(this.execute.bind(this)),h.engineReady().then((()=>c.Debugger.getInstance().exit((()=>h.exit(0)))))):this.readline()}))}runProcessors_(e,t){try{this.processors.length||this.processors.push("speech"),t&&this.processors.forEach((n=>e(n,t)))}catch(e){console.error(e.name+": "+e.message),c.Debugger.getInstance().exit((()=>this.process.exit(1)))}}readExpression_(e){try{const t=e.replace(/(&|#|;)/g,"");this.dp.parseFromString(t,"text/xml")}catch(e){return!1}return!0}}},5605:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Debugger=void 0;const r=n(495);class i{constructor(){this.isActive_=!1,this.outputFunction_=console.info,this.fileHandle=Promise.resolve(),this.stream_=null}static getInstance(){return i.instance=i.instance||new i,i.instance}init(e){return e&&this.startDebugFile_(e),this.isActive_=!0,this.fileHandle}output(...e){this.isActive_&&this.output_(e)}generateOutput(e){this.isActive_&&this.output_(e.apply(e,[]))}exit(e=(()=>{})){this.fileHandle.then((()=>{this.isActive_&&this.stream_&&this.stream_.end("","",e)}))}startDebugFile_(e){this.fileHandle=r.default.fs.promises.open(e,"w"),this.fileHandle=this.fileHandle.then((t=>{this.stream_=t.createWriteStream(e),this.outputFunction_=function(...e){this.stream_.write(e.join(" ")),this.stream_.write("\n")}.bind(this),this.stream_.on("error",function(e){console.info("Invalid log file. Debug information sent to console."),this.outputFunction_=console.info}.bind(this)),this.stream_.on("finish",(function(){console.info("Finalizing debug file.")}))}))}output_(e){console.info!==this.outputFunction_?this.fileHandle.then((()=>this.outputFunction_.apply(this.outputFunction_,["Speech Rule Engine Debugger:"].concat(e)))):this.outputFunction_.apply(console,["Speech Rule Engine Debugger:"].concat(e))}}t.Debugger=i},7041:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.serializeXml=t.cloneNode=t.tagName=t.querySelectorAll=t.querySelectorAllByAttrValue=t.querySelectorAllByAttr=t.formatXml=t.createTextNode=t.createElementNS=t.createElement=t.replaceNode=t.NodeType=t.parseInput=t.XML_ENTITIES=t.trimInput_=t.toArray=void 0;const r=n(3684),i=n(9686),o=n(495),s=n(1746);function a(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}function c(e){return(e=e.replace(/ /g," ")).replace(/>[ \f\n\r\t\v\u200b]+</g,"><").trim()}function l(e,t){if(!t)return[!1,""];const n=e.match(/^<([^> ]+).*>/),r=t.match(/^<\/([^>]+)>(.*)/);return n&&r&&n[1]===r[1]?[!0,r[2]]:[!1,""]}t.toArray=a,t.trimInput_=c,t.XML_ENTITIES={"<":!0,">":!0,"&":!0,""":!0,"'":!0},t.parseInput=function(e){const t=new o.default.xmldom.DOMParser,n=c(e),a=!!n.match(/&(?!lt|gt|amp|quot|apos)\w+;/g);if(!n)throw new Error("Empty input!");try{const e=t.parseFromString(n,a?"text/html":"text/xml");return r.default.getInstance().mode===i.Mode.HTTP?(s.xpath.currentDocument=e,a?e.body.childNodes[0]:e.documentElement):e.documentElement}catch(e){throw new r.SREError("Illegal input: "+e.message)}},function(e){e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",e[e.NOTATION_NODE=12]="NOTATION_NODE"}(t.NodeType||(t.NodeType={})),t.replaceNode=function(e,t){e.parentNode&&(e.parentNode.insertBefore(t,e),e.parentNode.removeChild(e))},t.createElement=function(e){return o.default.document.createElement(e)},t.createElementNS=function(e,t){return o.default.document.createElementNS(e,t)},t.createTextNode=function(e){return o.default.document.createTextNode(e)},t.formatXml=function(e){let t="",n=/(>)(<)(\/*)/g,r=0,i=(e=e.replace(n,"$1\r\n$2$3")).split("\r\n");for(n=/(\.)*(<)(\/*)/g,i=i.map((e=>e.replace(n,"$1\r\n$2$3").split("\r\n"))).reduce(((e,t)=>e.concat(t)),[]);i.length;){let e=i.shift();if(!e)continue;let n=0;if(e.match(/^<\w[^>/]*>[^>]+$/)){const t=l(e,i[0]);t[0]?t[1]?(e+=i.shift().slice(0,-t[1].length),t[1].trim()&&i.unshift(t[1])):e+=i.shift():n=1}else if(e.match(/^<\/\w/))0!==r&&(r-=1);else if(e.match(/^<\w[^>]*[^/]>.*$/))n=1;else if(e.match(/^<\w[^>]*\/>.+$/)){const t=e.indexOf(">")+1;e.slice(t).trim()&&i.unshift(),e=e.slice(0,t)}else n=0;t+=new Array(r+1).join(" ")+e+"\r\n",r+=n}return t},t.querySelectorAllByAttr=function(e,t){return e.querySelectorAll?a(e.querySelectorAll(`[${t}]`)):s.evalXPath(`.//*[@${t}]`,e)},t.querySelectorAllByAttrValue=function(e,t,n){return e.querySelectorAll?a(e.querySelectorAll(`[${t}="${n}"]`)):s.evalXPath(`.//*[@${t}="${n}"]`,e)},t.querySelectorAll=function(e,t){return e.querySelectorAll?a(e.querySelectorAll(t)):s.evalXPath(`.//${t}`,e)},t.tagName=function(e){return e.tagName.toUpperCase()},t.cloneNode=function(e){return e.cloneNode(!0)},t.serializeXml=function(e){return(new o.default.xmldom.XMLSerializer).serializeToString(e)}},3684:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnginePromise=t.SREError=void 0;const r=n(3113),i=n(9686),o=n(5605),s=n(6948);class a extends Error{constructor(e=""){super(),this.message=e,this.name="SRE Error"}}t.SREError=a;class c{constructor(){this.customLoader=null,this.parsers={},this.comparator=null,this.mode=i.Mode.SYNC,this.init=!0,this.delay=!1,this.comparators={},this.domain="mathspeak",this.style=r.DynamicCstr.DEFAULT_VALUES[r.Axis.STYLE],this._defaultLocale=r.DynamicCstr.DEFAULT_VALUES[r.Axis.LOCALE],this.locale=this.defaultLocale,this.subiso="",this.modality=r.DynamicCstr.DEFAULT_VALUES[r.Axis.MODALITY],this.speech=i.Speech.NONE,this.markup=i.Markup.NONE,this.walker="Table",this.structure=!1,this.ruleSets=[],this.strict=!1,this.isIE=!1,this.isEdge=!1,this.rate="100",this.pprint=!1,this.config=!1,this.rules="",this.prune="",this.evaluator=c.defaultEvaluator,this.defaultParser=new r.DynamicCstrParser(r.DynamicCstr.DEFAULT_ORDER),this.parser=this.defaultParser,this.dynamicCstr=r.DynamicCstr.defaultCstr()}set defaultLocale(e){this._defaultLocale=s.Variables.ensureLocale(e,this._defaultLocale)}get defaultLocale(){return this._defaultLocale}static getInstance(){return c.instance=c.instance||new c,c.instance}static defaultEvaluator(e,t){return e}static evaluateNode(e){return c.nodeEvaluator(e)}getRate(){const e=parseInt(this.rate,10);return isNaN(e)?100:e}setDynamicCstr(e){if(this.defaultLocale&&(r.DynamicCstr.DEFAULT_VALUES[r.Axis.LOCALE]=this.defaultLocale),e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const i=t[n];if(-1!==r.DynamicCstr.DEFAULT_ORDER.indexOf(i)){const t=e[i];this[i]=t}}}i.DOMAIN_TO_STYLES[this.domain]=this.style;const t=[this.locale,this.modality,this.domain,this.style].join("."),n=r.DynamicProperties.createProp([r.DynamicCstr.DEFAULT_VALUES[r.Axis.LOCALE]],[r.DynamicCstr.DEFAULT_VALUES[r.Axis.MODALITY]],[r.DynamicCstr.DEFAULT_VALUES[r.Axis.DOMAIN]],[r.DynamicCstr.DEFAULT_VALUES[r.Axis.STYLE]]),o=this.comparators[this.domain],s=this.parsers[this.domain];this.parser=s||this.defaultParser,this.dynamicCstr=this.parser.parse(t),this.dynamicCstr.updateProperties(n.getProperties()),this.comparator=o?o():new r.DefaultComparator(this.dynamicCstr)}configurate(e){this.mode!==i.Mode.HTTP||this.config||(function(e){const t=document.documentElement.querySelectorAll('script[type="text/x-sre-config"]');for(let n=0,r=t.length;n<r;n++){let r;try{r=t[n].innerHTML;const i=JSON.parse(r);for(const t in i)e[t]=i[t]}catch(e){o.Debugger.getInstance().output("Illegal configuration ",r)}}}(e),this.config=!0),function(e){if("undefined"!=typeof SREfeature)for(const[t,n]of Object.entries(SREfeature))e[t]=n}(e)}setCustomLoader(e){e&&(this.customLoader=e)}}t.default=c,c.BINARY_FEATURES=["strict","structure","pprint"],c.STRING_FEATURES=["markup","style","domain","speech","walker","defaultLocale","locale","delay","modality","rate","rules","subiso","prune"],c.nodeEvaluator=function(e){return[]};class l{static get(e=c.getInstance().locale){return l.promises[e]||Promise.resolve("")}static getall(){return Promise.all(Object.values(l.promises))}}t.EnginePromise=l,l.loaded={},l.promises={}},9686:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DOMAIN_TO_STYLES=t.Markup=t.Speech=t.personalityPropList=t.personalityProps=t.Mode=void 0,function(e){e.SYNC="sync",e.ASYNC="async",e.HTTP="http"}(t.Mode||(t.Mode={})),function(e){e.PITCH="pitch",e.RATE="rate",e.VOLUME="volume",e.PAUSE="pause",e.JOIN="join",e.LAYOUT="layout"}(n=t.personalityProps||(t.personalityProps={})),t.personalityPropList=[n.PITCH,n.RATE,n.VOLUME,n.PAUSE,n.JOIN],function(e){e.NONE="none",e.SHALLOW="shallow",e.DEEP="deep"}(t.Speech||(t.Speech={})),function(e){e.NONE="none",e.LAYOUT="layout",e.PUNCTUATION="punctuation",e.SSML="ssml",e.SSML_STEP="ssml_step",e.ACSS="acss",e.SABLE="sable",e.VOICEXML="voicexml"}(t.Markup||(t.Markup={})),t.DOMAIN_TO_STYLES={mathspeak:"default",clearspeak:"default"}},317:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.setup=void 0;const i=n(2420),o=n(2741),s=n(4698),a=n(5605),c=n(3684),l=n(3633),u=n(495);t.setup=function(e){return r(this,void 0,void 0,(function*(){const t=c.default.getInstance();"default"!==e.domain||"speech"!==e.modality&&e.modality&&"speech"!==t.modality||(e.domain="mathspeak");const n=n=>{void 0!==e[n]&&(t[n]=e[n])};return n("mode"),t.configurate(e),c.default.BINARY_FEATURES.forEach((n=>{void 0!==e[n]&&(t[n]=!!e[n])})),c.default.STRING_FEATURES.forEach(n),e.debug&&a.Debugger.getInstance().init(),e.json&&(u.default.jsonPath=l.makePath(e.json)),e.xpath&&(u.default.WGXpath=e.xpath),t.setCustomLoader(e.custom),function(e){e.isIE=s.detectIE(),e.isEdge=s.detectEdge()}(t),i.setLocale(),t.setDynamicCstr(),t.init?(c.EnginePromise.promises.init=new Promise(((e,t)=>{setTimeout((()=>{e("init")}),10)})),t.init=!1,c.EnginePromise.get()):t.delay?(t.delay=!1,c.EnginePromise.get()):o.loadLocale()}))}},5390:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Event=t.EventType=t.Move=t.KeyCode=void 0,function(e){e[e.ENTER=13]="ENTER",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.PAGE_UP=33]="PAGE_UP",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.END=35]="END",e[e.HOME=36]="HOME",e[e.LEFT=37]="LEFT",e[e.UP=38]="UP",e[e.RIGHT=39]="RIGHT",e[e.DOWN=40]="DOWN",e[e.TAB=9]="TAB",e[e.LESS=188]="LESS",e[e.GREATER=190]="GREATER",e[e.DASH=189]="DASH",e[e.ZERO=48]="ZERO",e[e.ONE=49]="ONE",e[e.TWO=50]="TWO",e[e.THREE=51]="THREE",e[e.FOUR=52]="FOUR",e[e.FIVE=53]="FIVE",e[e.SIX=54]="SIX",e[e.SEVEN=55]="SEVEN",e[e.EIGHT=56]="EIGHT",e[e.NINE=57]="NINE",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z"}(t.KeyCode||(t.KeyCode={})),t.Move=new Map([[13,"ENTER"],[27,"ESC"],[32,"SPACE"],[33,"PAGE_UP"],[34,"PAGE_DOWN"],[35,"END"],[36,"HOME"],[37,"LEFT"],[38,"UP"],[39,"RIGHT"],[40,"DOWN"],[9,"TAB"],[188,"LESS"],[190,"GREATER"],[189,"DASH"],[48,"ZERO"],[49,"ONE"],[50,"TWO"],[51,"THREE"],[52,"FOUR"],[53,"FIVE"],[54,"SIX"],[55,"SEVEN"],[56,"EIGHT"],[57,"NINE"],[65,"A"],[66,"B"],[67,"C"],[68,"D"],[69,"E"],[70,"F"],[71,"G"],[72,"H"],[73,"I"],[74,"J"],[75,"K"],[76,"L"],[77,"M"],[78,"N"],[79,"O"],[80,"P"],[81,"Q"],[82,"R"],[83,"S"],[84,"T"],[85,"U"],[86,"V"],[87,"W"],[88,"X"],[89,"Y"],[90,"Z"]]),function(e){e.CLICK="click",e.DBLCLICK="dblclick",e.MOUSEDOWN="mousedown",e.MOUSEUP="mouseup",e.MOUSEOVER="mouseover",e.MOUSEOUT="mouseout",e.MOUSEMOVE="mousemove",e.SELECTSTART="selectstart",e.KEYPRESS="keypress",e.KEYDOWN="keydown",e.KEYUP="keyup",e.TOUCHSTART="touchstart",e.TOUCHMOVE="touchmove",e.TOUCHEND="touchend",e.TOUCHCANCEL="touchcancel"}(t.EventType||(t.EventType={})),t.Event=class{constructor(e,t,n){this.src=e,this.type=t,this.callback=n}add(){this.src.addEventListener(this.type,this.callback)}remove(){this.src.removeEventListener(this.type,this.callback)}}},3633:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localePath=t.makePath=void 0;const r=n(495);function i(e){return e.match("/$")?e:e+"/"}t.makePath=i,t.localePath=function(e,t="json"){return i(r.default.jsonPath)+e+(t.match(/^\./)?t:"."+t)}},8231:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeyProcessor=t.Processor=void 0;const r=n(5390);class i{constructor(e,t){this.name=e,this.process=t.processor,this.postprocess=t.postprocessor||((e,t)=>e),this.processor=this.postprocess?function(e){return this.postprocess(this.process(e),e)}:this.process,this.print=t.print||i.stringify_,this.pprint=t.pprint||this.print}static stringify_(e){return e?e.toString():e}}t.Processor=i,i.LocalState={walker:null,speechGenerator:null,highlighter:null};class o extends i{constructor(e,t){super(e,t),this.key=t.key||o.getKey_}static getKey_(e){return"string"==typeof e?r.KeyCode[e.toUpperCase()]:e}}t.KeyProcessor=o},9190:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.keypress=t.output=t.print=t.process=t.set=void 0;const r=n(840),i=n(7059),o=n(7022),s=n(3826),a=n(6256),c=n(4493),l=n(2421),u=n(2338),d=n(3294),h=n(7041),p=n(3684),f=n(9686),m=n(8231),g=n(1746),S=new Map;function b(e){S.set(e.name,e)}function y(e){const t=S.get(e);if(!t)throw new p.SREError("Unknown processor "+e);return t}function N(e,t){const n=y(e);try{return n.processor(t)}catch(e){throw new p.SREError("Processing error for expression "+t)}}function E(e,t){const n=y(e);return p.default.getInstance().pprint?n.pprint(t):n.print(t)}t.set=b,t.process=N,t.print=E,t.output=function(e,t){const n=y(e);try{const e=n.processor(t);return p.default.getInstance().pprint?n.pprint(e):n.print(e)}catch(e){throw new p.SREError("Processing error for expression "+t)}},t.keypress=function(e,t){const n=y(e),r=n instanceof m.KeyProcessor?n.key(t):t,i=n.processor(r);return p.default.getInstance().pprint?n.pprint(i):n.print(i)},b(new m.Processor("semantic",{processor:function(e){const t=h.parseInput(e);return a.xmlTree(t)},postprocessor:function(e,t){const n=p.default.getInstance().speech;if(n===f.Speech.NONE)return e;const i=h.cloneNode(e);let o=l.computeMarkup(i);if(n===f.Speech.SHALLOW)return e.setAttribute("speech",r.finalize(o)),e;const s=g.evalXPath(".//*[@id]",e),a=g.evalXPath(".//*[@id]",i);for(let e,t,n=0;e=s[n],t=a[n];n++)o=l.computeMarkup(t),e.setAttribute("speech",r.finalize(o));return e},pprint:function(e){return h.formatXml(e.toString())}})),b(new m.Processor("speech",{processor:function(e){const t=h.parseInput(e),n=a.xmlTree(t),i=l.computeSpeech(n);return r.finalize(r.markup(i))},pprint:function(e){const t=e.toString();return r.isXml()?h.formatXml(t):t}})),b(new m.Processor("json",{processor:function(e){const t=h.parseInput(e);return a.getTree(t).toJson()},postprocessor:function(e,t){const n=p.default.getInstance().speech;if(n===f.Speech.NONE)return e;const i=h.parseInput(t),o=a.xmlTree(i),s=l.computeMarkup(o);if(n===f.Speech.SHALLOW)return e.stree.speech=r.finalize(s),e;const c=e=>{const t=g.evalXPath(`.//*[@id=${e.id}]`,o)[0],n=l.computeMarkup(t);e.speech=r.finalize(n),e.children&&e.children.forEach(c)};return c(e.stree),e},print:function(e){return JSON.stringify(e)},pprint:function(e){return JSON.stringify(e,null,2)}})),b(new m.Processor("description",{processor:function(e){const t=h.parseInput(e),n=a.xmlTree(t);return l.computeSpeech(n)},print:function(e){return JSON.stringify(e)},pprint:function(e){return JSON.stringify(e,null,2)}})),b(new m.Processor("enriched",{processor:function(e){return i.semanticMathmlSync(e)},postprocessor:function(e,t){const n=d.getSemanticRoot(e);let r;switch(p.default.getInstance().speech){case f.Speech.NONE:break;case f.Speech.SHALLOW:r=c.generator("Adhoc"),r.getSpeech(n,e);break;case f.Speech.DEEP:r=c.generator("Tree"),r.getSpeech(e,e)}return e},pprint:function(e){return h.formatXml(e.toString())}})),b(new m.Processor("walker",{processor:function(e){const t=c.generator("Node");m.Processor.LocalState.speechGenerator=t,t.setOptions({modality:p.default.getInstance().modality,locale:p.default.getInstance().locale,domain:p.default.getInstance().domain,style:p.default.getInstance().style}),m.Processor.LocalState.highlighter=o.highlighter({color:"black"},{color:"white"},{renderer:"NativeMML"});const n=N("enriched",e),r=E("enriched",n);return m.Processor.LocalState.walker=u.walker(p.default.getInstance().walker,n,t,m.Processor.LocalState.highlighter,r),m.Processor.LocalState.walker},print:function(e){return m.Processor.LocalState.walker.speech()}})),b(new m.KeyProcessor("move",{processor:function(e){return m.Processor.LocalState.walker?!1===m.Processor.LocalState.walker.move(e)?r.error(e):m.Processor.LocalState.walker.speech():null}})),b(new m.Processor("number",{processor:function(e){const t=parseInt(e,10);return isNaN(t)?"":s.LOCALE.NUMBERS.numberToWords(t)}})),b(new m.Processor("ordinal",{processor:function(e){const t=parseInt(e,10);return isNaN(t)?"":s.LOCALE.NUMBERS.wordOrdinal(t)}})),b(new m.Processor("numericOrdinal",{processor:function(e){const t=parseInt(e,10);return isNaN(t)?"":s.LOCALE.NUMBERS.numericOrdinal(t)}})),b(new m.Processor("vulgar",{processor:function(e){const[t,n]=e.split("/").map((e=>parseInt(e,10)));return isNaN(t)||isNaN(n)?"":N("speech",`<mfrac><mn>${t}</mn><mn>${n}</mn></mfrac>`)}}))},2114:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.localePath=t.exit=t.move=t.walk=t.processFile=t.file=t.vulgar=t.numericOrdinal=t.ordinal=t.number=t.toEnriched=t.toDescription=t.toJson=t.toSemantic=t.toSpeech=t.localeLoader=t.engineReady=t.engineSetup=t.setupEngine=t.version=void 0;const i=n(3684),o=n(317),s=n(9686),a=n(3633),c=n(9190),l=n(495),u=n(6948),d=n(2741);function h(e){return r(this,void 0,void 0,(function*(){return(0,o.setup)(e)}))}function p(e,t){return c.process(e,t)}function f(e,t,n){switch(i.default.getInstance().mode){case s.Mode.ASYNC:return function(e,t,n){return r(this,void 0,void 0,(function*(){const r=yield l.default.fs.promises.readFile(t,{encoding:"utf8"}),o=c.output(e,r);if(n)try{l.default.fs.promises.writeFile(n,o)}catch(e){throw new i.SREError("Can not write to file: "+n)}return o}))}(e,t,n);case s.Mode.SYNC:return function(e,t,n){const r=function(e){let t;try{t=l.default.fs.readFileSync(e,{encoding:"utf8"})}catch(t){throw new i.SREError("Can not open file: "+e)}return t}(t),o=c.output(e,r);if(n)try{l.default.fs.writeFileSync(n,o)}catch(e){throw new i.SREError("Can not write to file: "+n)}return o}(e,t,n);default:throw new i.SREError(`Can process files in ${i.default.getInstance().mode} mode`)}}t.version=u.Variables.VERSION,t.setupEngine=h,t.engineSetup=function(){const e=["mode"].concat(i.default.STRING_FEATURES,i.default.BINARY_FEATURES),t=i.default.getInstance(),n={};return e.forEach((function(e){n[e]=t[e]})),n.json=l.default.jsonPath,n.xpath=l.default.WGXpath,n.rules=t.ruleSets.slice(),n},t.engineReady=function(){return r(this,void 0,void 0,(function*(){return h({}).then((()=>i.EnginePromise.getall()))}))},t.localeLoader=d.standardLoader,t.toSpeech=function(e){return p("speech",e)},t.toSemantic=function(e){return p("semantic",e)},t.toJson=function(e){return p("json",e)},t.toDescription=function(e){return p("description",e)},t.toEnriched=function(e){return p("enriched",e)},t.number=function(e){return p("number",e)},t.ordinal=function(e){return p("ordinal",e)},t.numericOrdinal=function(e){return p("numericOrdinal",e)},t.vulgar=function(e){return p("vulgar",e)},t.file={},t.file.toSpeech=function(e,t){return f("speech",e,t)},t.file.toSemantic=function(e,t){return f("semantic",e,t)},t.file.toJson=function(e,t){return f("json",e,t)},t.file.toDescription=function(e,t){return f("description",e,t)},t.file.toEnriched=function(e,t){return f("enriched",e,t)},t.processFile=f,t.walk=function(e){return c.output("walker",e)},t.move=function(e){return c.keypress("move",e)},t.exit=function(e){const t=e||0;i.EnginePromise.getall().then((()=>process.exit(t)))},t.localePath=a.localePath,l.default.documentSupported?h({mode:s.Mode.HTTP}).then((()=>h({}))):h({mode:s.Mode.SYNC}).then((()=>h({mode:s.Mode.ASYNC})))},495:(__unused_webpack_module,exports,__nested_webpack_require_45537__)=>{Object.defineProperty(exports,"__esModule",{value:!0});const variables_1=__nested_webpack_require_45537__(6948);class SystemExternal{static extRequire(library){if(void 0!==process){const nodeRequire=eval("require");return nodeRequire(library)}return null}}exports.default=SystemExternal,SystemExternal.windowSupported=!("undefined"==typeof window),SystemExternal.documentSupported=SystemExternal.windowSupported&&!(void 0===window.document),SystemExternal.xmldom=SystemExternal.documentSupported?window:SystemExternal.extRequire("xmldom-sre"),SystemExternal.document=SystemExternal.documentSupported?window.document:(new SystemExternal.xmldom.DOMImplementation).createDocument("","",0),SystemExternal.xpath=SystemExternal.documentSupported?document:function(){const e={document:{},XPathResult:{}};return SystemExternal.extRequire("wicked-good-xpath").install(e),e.document.XPathResult=e.XPathResult,e.document}(),SystemExternal.mathmapsIePath="https://cdn.jsdelivr.net/npm/sre-mathmaps-ie@"+variables_1.Variables.VERSION+"mathmaps_ie.js",SystemExternal.commander=SystemExternal.documentSupported?null:SystemExternal.extRequire("commander"),SystemExternal.fs=SystemExternal.documentSupported?null:SystemExternal.extRequire("fs"),SystemExternal.url=variables_1.Variables.url,SystemExternal.jsonPath=(SystemExternal.documentSupported?SystemExternal.url:process.env.SRE_JSON_PATH||__nested_webpack_require_45537__.g.SRE_JSON_PATH||__dirname+"/mathmaps")+"/",SystemExternal.WGXpath=variables_1.Variables.WGXpath,SystemExternal.wgxpath=null},6948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Variables=void 0;class n{static ensureLocale(e,t){return n.LOCALES.get(e)?e:(console.error(`Locale ${e} does not exist! Using ${n.LOCALES.get(t)} instead.`),t)}}t.Variables=n,n.VERSION="4.0.6",n.LOCALES=new Map([["ca","Catalan"],["da","Danish"],["de","German"],["en","English"],["es","Spanish"],["fr","French"],["hi","Hindi"],["it","Italian"],["nb","Bokmål"],["nn","Nynorsk"],["sv","Swedish"],["nemeth","Nemeth"]]),n.mathjaxVersion="3.2.1",n.url="https://cdn.jsdelivr.net/npm/speech-rule-engine@"+n.VERSION+"/lib/mathmaps",n.WGXpath="https://cdn.jsdelivr.net/npm/wicked-good-xpath@1.3.0/dist/wgxpath.install.js"},1746:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateEvaluator=t.evaluateString=t.evaluateBoolean=t.getLeafNodes=t.evalXPath=t.resolveNameSpace=t.xpath=void 0;const r=n(3684),i=n(9686),o=n(495);function s(){return"undefined"!=typeof XPathResult}t.xpath={currentDocument:null,evaluate:s()?document.evaluate:o.default.xpath.evaluate,result:s()?XPathResult:o.default.xpath.XPathResult,createNSResolver:s()?document.createNSResolver:o.default.xpath.createNSResolver};const a={xhtml:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",mml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2