// ==UserScript== // @name Atomi AI Marking // @namespace atomi-ai-marking // @version 1.0.2 // @author Callum Wong // @description Mark Atomi written answers against marking guidelines with an LLM (any OpenAI-compatible API) // @license MIT // @homepageURL https://github.com/wongcallum/atomi-userscripts // @downloadURL https://raw.githubusercontent.com/wongcallum/atomi-userscripts/releases/atomi-ai-marking.user.js // @updateURL https://raw.githubusercontent.com/wongcallum/atomi-userscripts/releases/atomi-ai-marking.user.js // @match https://learn.getatomi.com/* // @connect openrouter.ai // @connect * // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_xmlhttpRequest // @run-at document-idle // @noframes // ==/UserScript== (function(){"use strict";var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),t,n,r,i,a,o,s,c,l,u,d,f={},p=[],m=/^m(i|n|o|s|text|space)$/,h=Array.isArray,g=p.slice,_=Object.assign;function v(e){e&&e.parentNode&&e.remove()}function ee(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++n,__i:-1,__u:0};return!o&&t.vnode&&t.vnode(s),s}function y(e){return e.children}function b(e,t){this.props=e,this.context=t,this.__g=0}function te(e,t){if(t==null)return e.__?te(e.__,e.__i+1):null;for(var n;tn&&i.sort(s),e=i.shift(),n=i.length,8&e.__g&&(a=void 0,c=void 0,l=(c=(r=e).__v).__e,u=[],d=[],(f=r.__P)&&((a=_({constructor:void 0},c)).__v=c.__v+1,t.vnode&&t.vnode(a),le(f,a,c,r.__n,f.namespaceURI,32&c.__u?[l]:null,u,l||te(c),32&c.__u,d),a.__v=c.__v,a.__.__k[a.__i]=a,de(u,a,d),c.__=c.__e=null,a.__e!=l&&x(a)))}finally{i.length=o=0}}function ie(e,t,n,r,i,a,o,s,c,l,u){var d,m,h,g,_,v,ee=r.__k||p,y=t.length;for(c=ae(n,t,ee,c,y),d=0;dc?v--:v++,b=!0)):(~l||(i>g?v--:i>1]+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function oe(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function se(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||oe(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||oe(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=d[t]||(d[t]=ce(t)),(e.__a||={})[t]=u,a=t!=(t=t.replace(l,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ce(e){return function(n){if(this.__e){var r=this.__e[e];if(n[c]==null)n[c]=u++;else if(n[c]=n.__.length&&n.__.push({}),n.__[e]}function Ie(e,t){var n=Fe(xe++,3);!w.__s&&Ke(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,Se.__H.__h.push(n))}function Le(e,t){var n=Fe(xe++,4);!w.__s&&Ke(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,Se.__h.push(n))}function Re(e){return Ee=5,ze(function(){return{current:e}},[])}function ze(e,t){var n=Fe(xe++,7);return Ke(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Be(){var e;do{for(;e=Oe.shift();)try{We(e)}catch(t){w.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=De.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(We),t.__h.some(Ge),t.__h=[]}catch(n){t.__h=[],w.__e(n,e.__v)}}}while(Oe.length)}w.__b=function(e){Se=null,ke&&ke(e)},w.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pe&&Pe(e,t)},w.__r=function(e){Ae&&Ae(e),xe=0;var t=(Se=e.__c).__H;t&&(Ce==Se?Se.__h=[]:(t.__h.some(We),t.__h.some(Ge),xe=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Ce=Se},w.diffed=function(e){je&&je(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Ue(De.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Ce=Se=null},w.__c=function(e,t){t.some(function(e){try{e.__h.some(We),e.__h=e.__h.filter(function(e){return!e.__||Ge(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],w.__e(n,e.__v)}}),Me&&Me(e,t)},w.unmount=function(e){Ne&&Ne(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Ue(Oe.push(r))}else We(r)}catch(e){t=e}}),r.__H=void 0,t&&w.__e(t,r.__v))};var Ve=typeof requestAnimationFrame==`function`;function He(e){var t,n=function(){clearTimeout(r),Ve&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ve&&(t=requestAnimationFrame(n))}function Ue(e){e!=1&&we==w.requestAnimationFrame||((we=w.requestAnimationFrame)||He)(Be)}function We(e){var t=Se,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Se=t}function Ge(e){var t=Se;e.__c=e.__(),Se=t}function Ke(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!Te(t,e[n])})}var qe=Symbol.for(`preact-signals`);function Je(){if($e>1)$e--;else{var e,t=!1;for((function(){var e=rt;for(rt=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Qe!==void 0;){var n=Qe;for(Qe=void 0,et++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ct(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(et=0,$e--,t)throw e}}function Ye(e){if($e>0)return e();nt=++tt,$e++;try{return e()}finally{Je()}}var Xe,T=void 0;function Ze(e){var t=T,n=Xe;T=void 0,Xe=void 0;try{return e()}finally{T=t,Xe=n}}var Qe=void 0,$e=0,et=0,tt=0,nt=0,rt=void 0,it=0;function at(e){if(T!==void 0){var t=e.n;if(t===void 0||t.t!==T)return t={i:0,S:e,p:T.s,n:void 0,t:T,e:void 0,x:void 0,r:t},T.s!==void 0&&(T.s.n=t),T.s=t,e.n=t,32&T.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=T.s,t.n=void 0,T.s.n=t,T.s=t),t}}function ot(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ot.prototype.brand=qe,ot.prototype.h=function(){return!0},ot.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ze(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},ot.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ze(function(){var e;(e=t.Z)==null||e.call(t)}))}},ot.prototype.subscribe=function(e){var t=this;return _t(function(){var n=t.value;Ze(function(){return e(n)})},{name:`sub`})},ot.prototype.valueOf=function(){return this.value},ot.prototype.toString=function(){return this.value+``},ot.prototype.toJSON=function(){return this.value},ot.prototype.peek=function(){var e=this;return Ze(function(){return e.value})},Object.defineProperty(ot.prototype,"value",{get:function(){var e=at(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(et>100)throw Error(`Cycle detected`);(function(e){$e!==0&&et===0&&e.l!==nt&&(e.l=nt,rt={S:e,v:e.v,i:e.i,o:rt})})(this),this.v=e,this.i++,it++,$e++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Je()}}}});function st(e,t){return new ot(e,t)}function ct(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function lt(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ut(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function dt(e,t){ot.call(this,void 0,t),this.x=e,this.s=void 0,this.g=it-1,this.f=4}dt.prototype=new ot,dt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===it))return!0;if(this.g=it,this.f|=1,this.i>0&&!ct(this))return this.f&=-2,!0;var e=T;try{lt(this),T=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return T=e,ut(this),this.f&=-2,!0},dt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ot.prototype.S.call(this,e)},dt.prototype.U=function(e){if(this.t!==void 0&&(ot.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},dt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(dt.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=at(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ft(e,t){return new dt(e,t)}function pt(e){var t=e.m;if(e.m=void 0,typeof t==`function`){$e++;var n=T;T=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,mt(e),t}finally{T=n,Je()}}}function mt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,pt(e)}function ht(e){if(T!==this)throw Error(`Out-of-order effect`);ut(this),T=e,this.f&=-2,8&this.f&&mt(this),Je()}function gt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Xe&&Xe.push(this)}gt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},gt.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,pt(this),lt(this),$e++;var e=T;return T=this,ht.bind(this,e)},gt.prototype.N=function(){2&this.f||(this.f|=2,this.u=Qe,Qe=this)},gt.prototype.d=function(){this.f|=8,1&this.f||mt(this)},gt.prototype.dispose=function(){this.d()};function _t(e,t){var n=new gt(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var vt,yt,bt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,xt=[];_t(function(){vt=this.N})();function St(e,n){t[e]=n.bind(null,t[e]||function(){})}function Ct(e){if(yt){var t=yt;yt=void 0,t()}yt=e&&e.S()}function wt(e){var t=this,n=e.data,i=Et(n);i.name=`ReactiveDom`,i.value=n;var a=ze(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var a=ft(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=ft(function(){return!Array.isArray(a.value)&&!r(a.value)}),s=_t(function(){if(this.N=kt,o.value){var t=a.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),c=t.__$u.d;return t.__$u.d=function(){s(),c.call(this)},[o,a]},[]),o=a[0],s=a[1];return o.value?s.peek():s.value}wt.displayName=`ReactiveTextNode`,Object.defineProperties(ot.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:wt},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),St(`__b`,function(e,t){if(Ct(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof ot&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),St(`__r`,function(e,t){if(e(t),t.type!==y){Ct();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return _t(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;bt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),Ct(n)}}),St(`__e`,function(e,t,n,r){Ct(),e(t,n,r)}),St(`diffed`,function(e,t){Ct();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=Tt(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function Tt(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=st(n);return{o:function(e,t){a.value=e,r=t},d:_t(function(){this.N=kt;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}St(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),St(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),b.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function Et(e,t){return ze(function(){return st(e,t)},[])}var Dt=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Ot(){Ye(function(){for(var e;e=xt.shift();)vt.call(e)})}function kt(){xt.push(this)===1&&(t.requestAnimationFrame||Dt)(Ot)}var At=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.ALL=e.COLLECTION=e.ATOM=e.SPECIAL=e.INF=e._INFINITY=e.INFINITY=e.NAN=e.BOOL=e.NULL=e.OBJ=e.ARR=e.NUM=e.STR=void 0,e.STR=1,e.NUM=2,e.ARR=4,e.OBJ=8,e.NULL=16,e.BOOL=32,e.NAN=64,e.INFINITY=128,e._INFINITY=256,e.INF=e.INFINITY|e._INFINITY,e.SPECIAL=e.NULL|e.BOOL|e.INF|e.NAN,e.ATOM=e.STR|e.NUM|e.SPECIAL,e.COLLECTION=e.ARR|e.OBJ,e.ALL=e.ATOM|e.COLLECTION,e.Allow={STR:e.STR,NUM:e.NUM,ARR:e.ARR,OBJ:e.OBJ,NULL:e.NULL,BOOL:e.BOOL,NAN:e.NAN,INFINITY:e.INFINITY,_INFINITY:e._INFINITY,INF:e.INF,SPECIAL:e.SPECIAL,ATOM:e.ATOM,COLLECTION:e.COLLECTION,ALL:e.ALL},e.default=e.Allow})),jt=e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;var a=At();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return a.Allow}}),i(At(),e);var o=class extends Error{};e.PartialJSON=o;var s=class extends Error{};e.MalformedJSON=s;function c(e,t=a.Allow.ALL){if(typeof e!=`string`)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return l(e.trim(),t)}e.parseJSON=c;var l=(e,t)=>{let n=e.length,r=0,i=e=>{throw new o(`${e} at position ${r}`)},c=e=>{throw new s(`${e} at position ${r}`)},l=()=>(m(),r>=n&&i(`Unexpected end of input`),e[r]===`"`?u():e[r]===`{`?d():e[r]===`[`?f():e.substring(r,r+4)===`null`||a.Allow.NULL&t&&n-r<4&&`null`.startsWith(e.substring(r))?(r+=4,null):e.substring(r,r+4)===`true`||a.Allow.BOOL&t&&n-r<4&&`true`.startsWith(e.substring(r))?(r+=4,!0):e.substring(r,r+5)===`false`||a.Allow.BOOL&t&&n-r<5&&`false`.startsWith(e.substring(r))?(r+=5,!1):e.substring(r,r+8)===`Infinity`||a.Allow.INFINITY&t&&n-r<8&&`Infinity`.startsWith(e.substring(r))?(r+=8,1/0):e.substring(r,r+9)===`-Infinity`||a.Allow._INFINITY&t&&1{let o=r,s=!1;for(r++;r{r++,m();let o={};try{for(;e[r]!==`}`;){if(m(),r>=n&&a.Allow.OBJ&t)return o;let i=u();m(),r++;try{o[i]=l()}catch(e){if(a.Allow.OBJ&t)return o;throw e}m(),e[r]===`,`&&r++}}catch{if(a.Allow.OBJ&t)return o;i(`Expected '}' at end of object`)}return r++,o},f=()=>{r++;let n=[];try{for(;e[r]!==`]`;)n.push(l()),m(),e[r]===`,`&&r++}catch{if(a.Allow.ARR&t)return n;i(`Expected ']' at end of array`)}return r++,n},p=()=>{if(r===0){e===`-`&&c(`Not sure what '-' is`);try{return JSON.parse(e)}catch(n){if(a.Allow.NUM&t)try{return JSON.parse(e.substring(0,e.lastIndexOf(`e`)))}catch{}c(String(n))}}let o=r;for(e[r]===`-`&&r++;e[r]&&`,]}`.indexOf(e[r])===-1;)r++;r==n&&!(a.Allow.NUM&t)&&i(`Unterminated number literal`);try{return JSON.parse(e.substring(o,r))}catch{e.substring(o,r)===`-`&&i(`Not sure what '-' is`);try{return JSON.parse(e.substring(o,e.lastIndexOf(`e`)))}catch(e){c(String(e))}}},m=()=>{for(;r0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0,t=n+1,n=e.indexOf(` `,t);continue}let r=e.charCodeAt(t);if(Rt(e,t,r)){let r=e.charCodeAt(t+5)===Ft?t+6:t+5,o=e.slice(r,n);if(f===0&&e.charCodeAt(n+1)===Nt){u!==void 0&&a?.(u),i?.({id:u,event:p,data:o}),u=void 0,d=``,p=void 0,t=n+2,n=e.indexOf(` `,t);continue}d=f===0?o:`${d}\n${o}`,f++}else zt(e,t,r)?p=e.slice(e.charCodeAt(t+6)===Ft?t+7:t+6,n)||void 0:x(e,t,n);if(b())return``;t=n+1,n=e.indexOf(` `,t)}return e.slice(t)}for(;t20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function re(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function ie(e={}){if(e.consume&&s.length>0){let e=s.join(``);x(e,0,e.length)}l=``,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:ie}}function Rt(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function zt(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}function Bt(e,t){let n=1;for(;n=300)?`Request failed with HTTP ${t}${n?`: ${n.slice(0,300)}`:``}`:n?n.slice(0,300):`The model returned an empty response.`}function Gt({url:e,apiKey:t,body:n,onDelta:r,onUsage:i}){let{promise:a,resolve:o,reject:s}=Promise.withResolvers(),c=``,l=!1,u=``,d=0,f=!1,p=!1,m,h=Lt({onEvent({data:e}){if(l=!0,e===`[DONE]`&&(f=!0),f)return;let t;try{t=JSON.parse(e)}catch{return}if(t.error)throw new Ht(t.error.message||JSON.stringify(t.error),d);let n=t.choices?.[0]?.delta?.content;n&&(u+=n,r(n));let{usage:a}=t;a&&i({prompt:a.prompt_tokens??0,cached:a.prompt_tokens_details?.cached_tokens??0,completion:a.completion_tokens??0})},onComment:()=>l=!0}),g=e=>{p||(p=!0,!e&&!u&&(e=new Ht(Wt(l?``:c,d),d)),e?(m?.abort(),s(e)):o(u))},_=(e,t=!1)=>{if(!p){d=e.status||d;try{let n=typeof e.responseText==`string`?e.responseText:``;n.length>c.length&&(h.feed(n.slice(c.length)),c=n),t&&h.feed(` `),(f||t)&&g()}catch(e){g(e)}}},v={"Content-Type":`application/json`,Accept:`text/event-stream`};return t&&(v.Authorization=`Bearer ${t}`),m=be({method:`POST`,url:e,headers:v,data:JSON.stringify(n),onprogress:_,onload:e=>_(e,!0),onerror:e=>g(new Ht(c?`The connection closed before the reply finished.`:`Network error${e.error?`: ${e.error}`:``}. Check the API endpoint.`)),ontimeout:()=>g(new Ht(`The request timed out.`))}),{done:a,abort:()=>g(new DOMException(`Stopped`,`AbortError`))}}var Kt=()=>document.evaluate(`//footer//*[not(*)][normalize-space()="I got"]`,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,qt=()=>document.querySelector(`main a[href*="/view/marking-guidelines"]`),Jt=()=>document.querySelector(`main textarea#answer`)??document.querySelector(`main math-field`)??document.querySelector(`main textarea`),Yt=()=>document.querySelector(`[role="dialog"][aria-label="Draw"] canvas`),Xt=()=>document.querySelector(`footer select`),Zt=()=>document.querySelector(`footer button[aria-haspopup="listbox"]`);function Qt(e){let t=e;for(;t.parentElement&&t.parentElement.childElementCount===1&&!t.parentElement.matches(`main, article`);)t=t.parentElement;return t}function $t(){let e=Xt();return e?[...e.options].map(e=>({value:e.value,label:e.textContent.trim(),n:Number(e.value)})).filter(e=>e.value!==``&&Number.isFinite(e.n)):[]}var en=e=>new Promise(t=>setTimeout(t,e));async function tn(e,t=1500){for(let n=Date.now();Date.now()-nMath.abs(n.n-e)r?.textContent.trim()===n.label;if(i())return;let a=Xt();Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,`value`).set.call(a,n.value),a.dispatchEvent(new Event(`change`,{bubbles:!0})),await en(100),!i()&&r&&(r.click(),(await tn(()=>[...document.querySelectorAll(`[role="listbox"] [role="option"]`)].find(e=>e.textContent.trim()===n.label)))?.click())}var rn=2e3,an=new Set([`SCRIPT`,`STYLE`,`SVG`,`BUTTON`,`NOSCRIPT`,`TEXTAREA`,`SELECT`,`TEMPLATE`,`MATH-FIELD`,`CANVAS`]),on=new Set([`P`,`DIV`,`LI`,`TR`,`TABLE`,`UL`,`OL`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`HR`,`SECTION`,`ARTICLE`,`FIGURE`,`FIGCAPTION`,`HEADER`,`FOOTER`,`DL`,`DT`,`DD`]);function sn(e,t,n){let r;try{r=new URL(t,location.href).href}catch{return n||``}return e.push(r),`[Image ${e.length}${n?`: ${n}`:``}]`}var cn=e=>/\.pdf$/i.test(e.pathname);function ln(e){let t=e.querySelector(`annotation[encoding="application/x-tex"]`)?.textContent;return t==null?e.textContent:e.closest(`.katex-display`)?`\n$$${t}$$\n`:`$${t}$`}function un(e,t,n){let r=new Set;for(let t of e.querySelectorAll(`[aria-hidden="true"][aria-describedby]`))if(t.querySelector(`.katex`))for(let e of t.getAttribute(`aria-describedby`).split(/\s+/))r.add(e);let i=``,a=e=>{if(e.nodeType===Node.TEXT_NODE){i+=e.nodeValue;return}if(e.nodeType===Node.DOCUMENT_FRAGMENT_NODE){for(let t of e.childNodes)a(t);return}if(e.nodeType!==Node.ELEMENT_NODE)return;let o=e,s=o.tagName.toUpperCase();if(o.classList.contains(`katex`))i+=ln(o);else if(!(an.has(s)||o.hidden||r.has(o.id))){if(o.getAttribute(`aria-hidden`)===`true`)for(let e of o.querySelectorAll(`.katex`))i+=ln(e);else if(s===`IMG`){let e=o;e.src&&(i+=sn(t,e.src,e.alt))}else if(s===`A`&&n&&cn(o))n.push(o.href),i+=`[PDF ${n.length}: ${o.textContent.trim()}]`;else if(s===`BR`)i+=` `;else{if(s===`LI`){let e=o.parentElement;i+=e?.tagName===`OL`?`\n${[...e.children].indexOf(o)+1}. `:` - `}else s===`TR`?i+=` |`:on.has(s)&&(i+=` `);(s===`TD`||s===`TH`)&&(i+=` `);for(let e of o.childNodes)a(e);s===`TD`||s===`TH`?i+=` |`:on.has(s)&&(i+=` `)}}};return a(e),i.replace(/[ \t]+\n/g,` `).replace(/\n{3,}/g,` `).trim()}function dn(e,t,n){let r=e.closest(`article`)??document.querySelector(`main`),i=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):null,a=document.createRange();return a.setStart(r,0),a.setEndBefore(i&&r.contains(i)?i:e),un(a.cloneContents(),t,n)}function fn(e){try{let t=new URL(e.href).searchParams.get(`markdown`).replace(/ /g,`+`).replace(/-/g,`+`).replace(/_/g,`/`);return new TextDecoder().decode(Uint8Array.from(atob(t),e=>e.charCodeAt(0))).trim()||null}catch{return null}}function pn(e,t){let n=fn(e);if(n)return n.replace(/!\[([^\]]*)\]\(\s*]+)>?(?:\s+["'][^"']*["'])?\s*\)/g,(e,n,r)=>sn(t,r,n)).replace(/]*?\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi,(e,n)=>sn(t,n,/\balt\s*=\s*["']([^"']*)["']/i.exec(e)?.[1]));let r=Qt(e),i=document.createRange();return i.setStartAfter(r),i.setEndAfter(r.parentElement.lastChild),un(i.cloneContents(),t)}var mn=e=>(typeof e.getValue==`function`?e.getValue(`latex`):e.textContent).trim();function hn(){let e=Yt();if(!e?.width||!e.height)return null;let{width:t,height:n}=e,r;try{r=new Uint32Array(e.getContext(`2d`).getImageData(0,0,t,n).data.buffer)}catch(e){return console.warn(`[Atomi AI marking] Couldn't read the drawing`,e),null}let i=n,a=-1,o=t,s=-1;for(let e=0;e>>24&&(es&&(s=c))}if(a<0)return null;let c=Math.round(t/100),l=Math.max(0,o-c),u=Math.max(0,i-c),d=Math.min(t,s+c+1)-l,f=Math.min(n,a+c+1)-u,p=Math.min(1,rn/Math.max(d,f)),m=document.createElement(`canvas`);m.width=Math.round(d*p),m.height=Math.round(f*p);let h=m.getContext(`2d`);return h.fillStyle=`#fff`,h.fillRect(0,0,m.width,m.height),h.drawImage(e,l,u,d,f,0,0,m.width,m.height),m.toDataURL(`image/png`)}var gn=e=>e.tagName===`MATH-FIELD`;function _n(e,t){let n=gn(e)?mn(e):e.value.trim(),r=hn();return[n,r&&sn(t,r,`the student's drawing`)].filter(Boolean).join(` `)}function vn(e){let t=Jt();if(!t)throw Error(`Couldn't find your answer on this page.`);let n=[],r=_n(t,n),i=[],a=dn(t,n,i),o=pn(e,n),s=$t(),c=s.length?Math.max(...s.map(e=>e.n)):Number(/(\d+)\s*marks?\b/i.exec(a)?.[1])||null;return{topic:document.querySelector(`main h1`)?.textContent.trim()??``,question:a,guidelines:o,answer:r,latex:gn(t),max:c,images:n,pdfs:i}}var yn=10,bn=2,xn=1e7,Sn=/^data:image\/(png|jpeg|webp|gif)[;,]/i;function Cn(e){return new Promise((t,n)=>{be({method:`GET`,url:e,responseType:`blob`,timeout:2e4,onload:e=>e.status>=200&&e.status<300&&e.response?t(e.response):n(Error(`HTTP ${e.status}`)),onerror:()=>n(Error(`network error`)),ontimeout:()=>n(Error(`timed out`))})})}var wn=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)});async function Tn(e){if(Sn.test(e))return e;let t=e.startsWith(`data:`)?e:await wn(await Cn(e));if(Sn.test(t))return t;let n=new Image;n.src=t,await n.decode();let r=document.createElement(`canvas`);r.width=n.naturalWidth||1024,r.height=n.naturalHeight||768;let i=r.getContext(`2d`);return i.fillStyle=`#fff`,i.fillRect(0,0,r.width,r.height),i.drawImage(n,0,0,r.width,r.height),r.toDataURL(`image/png`)}async function En(e){return(await Promise.all(e.slice(0,yn).map(async(e,t)=>{try{return{n:t+1,url:await Tn(e)}}catch(t){return console.warn(`[Atomi AI marking] Skipping image`,e,t),null}}))).filter(e=>e!==null)}async function Dn(e){return(await Promise.all(e.slice(0,bn).map(async(e,t)=>{try{let n=await Cn(e);if(n.size>xn)throw Error(`too large (${n.size} bytes)`);let r=(await wn(n)).replace(/^data:[^;,]*/,`data:application/pdf`),i=decodeURIComponent(new URL(e).pathname.split(`/`).pop()||`document-${t+1}.pdf`);return{n:t+1,filename:i,url:r}}catch(t){return console.warn(`[Atomi AI marking] Skipping PDF`,e,t),null}}))).filter(e=>e!==null)}var On=`You are marking a student's answer to an exam-style question against the marking guidelines. Marking rules: - Award marks only for what is written, not for what they may have meant. - The sample answer is not the only acceptable response. - For banded criteria (e.g. 5–6 marks, 3–4 marks), decide which band the answer best fits, then where it sits within that band. Reply with only a JSON object of this form: { "criteria": [{ "criterion": string, "status": "met" | "partial" | "not_met", "comment": string }], "improvement": string | null, "mark": integer } - criteria: the guidelines are usually a table where each row is a mark level for the whole question (e.g. 3, 2, 1), not a separate criterion. Then take the entries from the top level only, one for each of its points, judged against that level. The lower levels only help decide the mark. When the guidelines instead list separate criteria whose marks add up, give one entry for each. Keep the order of the guidelines. - criterion: a short name for the point or criterion, a few words long, without marks. - comment: one or two sentences on why, briefly quoting the answer where useful. - improvement: specifically what was missing and how to improve the answer. Use null only when you award full marks. - criterion, comment and improvement are inline Markdown. Write any maths in LaTeX ($...$), escaping backslashes as JSON requires. `,kn={type:`json_schema`,json_schema:{name:`marking`,strict:!0,schema:{type:`object`,properties:{criteria:{type:`array`,items:{type:`object`,properties:{criterion:{type:`string`},status:{type:`string`,enum:[`met`,`partial`,`not_met`]},comment:{type:`string`}},required:[`criterion`,`status`,`comment`],additionalProperties:!1}},improvement:{type:[`string`,`null`]},mark:{type:`integer`}},required:[`criteria`,`improvement`,`mark`],additionalProperties:!1}}},An=` The student is now asking you follow-up questions about your marking. Talk to them directly ("you", "your answer", "I marked…"). Get straight to answering the question they asked, briefly, in Markdown (with $...$ maths), not JSON. Explain concepts freely, but don't write a full-marks answer for them. Don't bring up their mark or repeat your feedback unless they ask about it. If they question the mark, or you realise you made a mistake, say honestly whether you'd change it (though the recorded mark can't be changed). `;function jn(e,t,n,r,i){let a=[e.topic&&`Topic: ${e.topic}`,`\n${e.question}\n`,`\n${e.guidelines}\n`,e.latex&&e.answer&&`The student typed their answer in a maths editor, so it is LaTeX, and words may be written in maths mode. Read it as the student intended, ignoring the formatting.`,`\n${e.answer||`(blank)`}\n`,t.length>0&&`The images referred to as [Image N] are attached below.`,n.length>0&&`The PDFs referred to as [PDF N] are attached below.`].filter(Boolean).join(` `),o=t.length||n.length?[{type:`text`,text:a},...t.flatMap(e=>[{type:`text`,text:`[Image ${e.n}]`},{type:`image_url`,image_url:{url:e.url}}]),...n.flatMap(e=>[{type:`text`,text:`[PDF ${e.n}]`},{type:`file`,file:{filename:e.filename,file_data:e.url}}])]:a,s={model:r,messages:[{role:`system`,content:On.trim()},{role:`user`,content:o}],stream:!0,response_format:kn};return i&&(s.reasoning_effort=i),r.startsWith(`anthropic/`)&&(s.cache_control={type:`ephemeral`}),s}function Mn(e,t,n,r){let{response_format:i,...a}=e,o=[...n.map(e=>e.question),r];return{...a,messages:[...e.messages,{role:`assistant`,content:t},...o.flatMap((e,t)=>[{role:`user`,content:t===0?[{type:`text`,text:An},{type:`text`,text:e}]:e},...t!t||`"\\/bfnrtu`.includes(t)?e:`\\${e}`),r;try{r=(0,Vt.parse)(n)}catch{return null}return r&&typeof r==`object`&&!Array.isArray(r)?{json:r}:null}return e?{markdown:e}:null}function Pn(e){let t=[...e.matchAll(/\bmarks?\W{0,4}(\d+(?:\.\d+)?)\s*(?:\/|out of)\s*\d+/gi)];return t.length?Number(t[t.length-1][1]):null}function Fn(e){if(!e)return null;let t=`json`in e?e.json.mark:Pn(e.markdown);return typeof t==`number`&&Number.isFinite(t)?Math.round(t):null}var In={key:null,phase:`done`,text:``,model:``,max:null,error:null,usage:null,chat:[]},Ln=st(In),Rn=st(``),zn=null,Bn=null;function Vn(){Bn&&(Bn.aborted=!0,Bn.request?.abort())}function Hn(){Vn(),Bn=null,zn=null,Ln.value=In,Rn.value=``}var Un=()=>new DOMException(`Stopped`,`AbortError`),Wn=e=>console.info(`[Atomi AI marking] tokens: ${e.prompt} prompt (${e.cached} cached), ${e.completion} completion`);async function Gn(e,t){Vn();let n={aborted:!1,request:null};Bn=n;let r=e=>{Bn===n&&(Ln.value={...Ln.value,...e})};zn=null,r({...In,key:e.href,phase:`working`,model:t.model});let i=``;try{let a=vn(e);r({max:a.max});let[o,s]=await Promise.all([En(a.images),Dn(a.pdfs)]);if(n.aborted)throw Un();let c=jn(a,o,s,t.model,t.effort),l=Ut(t.endpoint),u=t.apiKey??``;for(;;){console.debug(`[Atomi AI marking] request`,c),n.request=Gt({url:l,apiKey:u,body:c,onDelta(e){i+=e,r({text:i})},onUsage(e){Wn(e),r({usage:e})}});try{await n.request.done;break}catch(e){if(i||n.aborted||!(e instanceof Ht)||![400,422].includes(e.status))throw e;if(c.response_format)console.warn(`[Atomi AI marking] Retrying without response_format:`,e.message),delete c.response_format;else if(s.length)console.warn(`[Atomi AI marking] Retrying without PDFs:`,e.message),s.length=0,c=jn(a,o,s,t.model,t.effort),delete c.response_format;else throw e}}if(n.aborted)throw Un();Bn===n&&(zn={url:l,apiKey:u,body:c,reply:i}),r({phase:`done`});let d=Fn(Nn(i));d!==null&&Bn===n&&await nn(d)}catch(e){n.aborted?r({phase:`stopped`}):(console.error(`[Atomi AI marking]`,e),r({phase:`error`,error:e instanceof Error?e.message:String(e)}))}finally{Bn===n&&(Bn=null)}}async function Kn(e){let t=zn,n=e.trim();if(!t||!n||Bn)return;let r={aborted:!1,request:null};Bn=r;let i=e=>{if(Bn!==r)return;let{chat:t}=Ln.value;Ln.value={...Ln.value,chat:[...t.slice(0,-1),{...t[t.length-1],...e}]}},a=Ln.value.chat.filter(e=>e.phase===`done`);Ln.value={...Ln.value,chat:[...a,{question:n,reply:``,phase:`working`,error:null,usage:null}]},Rn.value=``;let o=``;try{let e=Mn(t.body,t.reply,a,n);if(console.debug(`[Atomi AI marking] request`,e),r.request=Gt({url:t.url,apiKey:t.apiKey,body:e,onDelta(e){o+=e,i({reply:o})},onUsage(e){Wn(e),i({usage:e})}}),await r.request.done,r.aborted)throw Un();i({phase:`done`})}catch(e){Bn===r&&!Rn.value&&(Rn.value=n),r.aborted?i({phase:`stopped`}):(console.error(`[Atomi AI marking]`,e),i({phase:`error`,error:e instanceof Error?e.message:String(e)}))}finally{Bn===r&&(Bn=null)}}function qn(){return{apiKey:_e(`apiKey`,void 0),endpoint:_e(`endpoint`,``),model:_e(`model`,``),effort:_e(`reasoningEffort`,`low`)}}function Jn(){let e=qn(),t=e.endpoint.trim(),n=e.model.trim();return{apiKey:e.apiKey?.trim(),endpoint:t||`https://openrouter.ai/api/v1`,model:n||`google/gemini-3.8-flash`,effort:e.effort.trim()}}function Yn(e){ye(`apiKey`,e.apiKey?.trim()??``),ye(`endpoint`,e.endpoint.trim()),ye(`model`,e.model.trim()),ye(`reasoningEffort`,e.effort.trim())}var Xn=`:host{--accent:#0057ff;--good:#1a7f37;--warn:#b26a00;--bad:#c62828;--line:#8080804d;--tint:#8080800f;--accent-text:var(--lightningcss-light,#0057ff)var(--lightningcss-dark,#5c9bff);--bad-text:var(--lightningcss-light,#c62828)var(--lightningcss-dark,#ff6a5e);--ink:var(--lightningcss-light,#1a1a1a)var(--lightningcss-dark,#e1e3e7);--surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#1c1e22)}*,:before,:after{box-sizing:border-box}button,input,textarea{font:inherit;color:inherit}button{cursor:pointer}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.mark{white-space:nowrap;background:0 0;border:1.5px solid;border-radius:999px;flex:none;margin-right:12px;padding:4px 14px;font-size:14px;font-weight:600}.panel{overflow-wrap:anywhere;border:1px solid var(--line);border-radius:12px;flex-direction:column;max-height:60vh;margin-bottom:24px;line-height:1.5;display:flex;overflow:hidden}.panel-head{background:var(--tint);border-bottom:1px solid var(--line);align-items:center;gap:8px;padding:10px 16px;font-size:14px;font-weight:600;display:flex}.panel-head .model{text-overflow:ellipsis;white-space:nowrap;opacity:.6;margin-left:auto;font-weight:400;overflow:hidden}.panel-head button{background:var(--surface);border:1px solid var(--line);border-radius:999px;flex:none;padding:2px 10px;font-size:13px}.panel-scroll{flex:auto;min-height:0;overflow-y:auto}.panel-body{padding:16px}.panel-body>:first-child{margin-top:0}.panel-body>:last-child{margin-bottom:0}.note{margin:8px 0 0}.error{color:var(--bad-text)}.muted{opacity:.6}.criterion{align-items:baseline;gap:8px;margin-bottom:10px;display:flex}.status{color:#fff;flex:none}.status svg{vertical-align:calc(.35em - 10px);background:var(--line);border-radius:50%}.status.met svg{background:var(--good)}.status.partial svg{background:var(--warn)}.status.not_met svg{background:var(--bad)}.status.pending{animation:2s ease-in-out infinite pulse}@keyframes pulse{50%{opacity:.5}}.improvement{background:#0057ff0f;border-radius:8px;margin-top:14px;padding:10px 14px}.improvement b{color:var(--accent-text)}.score{background:var(--tint);border-top:1px solid var(--line);align-items:center;gap:12px;padding:12px 16px;display:flex}.score h3{margin:0;font-size:16px}.score p{opacity:.7;margin:0;font-size:14px}.ring{flex:none;place-items:center;width:52px;height:52px;font-weight:800;display:grid;position:relative}.ring:before{content:"";background:conic-gradient(var(--tone) calc(var(--p) * 1%), var(--line) 0);border-radius:50%;position:absolute;inset:0;-webkit-mask:radial-gradient(farthest-side,#0000 calc(100% - 6px),#000 calc(100% - 5px));mask:radial-gradient(farthest-side,#0000 calc(100% - 6px),#000 calc(100% - 5px))}.chat{border-top:1px solid var(--line);padding:16px}.turn+.turn{margin-top:16px}.question{white-space:pre-wrap}.answer{margin:10px 0 0}.question{background:#0057ff14;border-radius:12px 12px 4px;width:fit-content;max-width:85%;margin-left:auto;padding:6px 12px}.ask{border-top:1px solid var(--line);flex:none;align-items:flex-end;gap:8px;padding:10px 12px;display:flex}.ask textarea{resize:none;field-sizing:content;background:var(--surface);border:1px solid #80808080;border-radius:8px;flex:1;min-height:2.25em;max-height:9em;padding:.375em 10px;line-height:1.5}.ask textarea:focus-visible{outline-offset:-1px}.ask button{color:#fff;background:var(--accent);border:0;border-radius:50%;flex:none;place-items:center;width:2.25em;height:2.25em;padding:0;display:grid}.ask button:disabled{cursor:default;opacity:.4}.shimmer{color:#0000;background-image:linear-gradient(90deg,#808080e6 30%,#8080804d 50%,#808080e6 70%);background-size:200% 100%;-webkit-background-clip:text;background-clip:text;animation:1.6s linear infinite shimmer;display:inline-block}@keyframes shimmer{to{background-position:-200% 0}}dialog{width:min(440px,100vw - 32px);color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:20px 24px;font-size:15px}dialog::backdrop{background:#0000004d}dialog h2{margin:0 0 12px;font-size:18px}dialog .message{color:var(--accent-text);margin:0 0 12px}dialog label{margin-bottom:14px;font-weight:600;display:block}dialog input{background:var(--surface);border:1px solid #80808080;border-radius:4px;width:100%;margin:4px 0 2px;padding:4px 8px;font-weight:400;display:block}dialog small{opacity:.65;font-size:13px;font-weight:400;display:block}.actions{justify-content:flex-end;gap:8px;margin-top:18px;display:flex}.actions button{background:0 0;border:1px solid #80808080;border-radius:4px;padding:4px 16px;font-weight:600}.actions button[type=submit]{color:#fff;background:var(--accent);border-color:var(--accent)}.html a{color:var(--accent-text)}.html code{background:#80808026;border-radius:4px;padding:.1em .3em}.html pre{background:#8080801f;border-radius:4px;padding:8px 12px;overflow-x:auto}.html pre code{background:0 0;padding:0}.html math{font-size:1.1em}.html math[display=block]{margin:.5em 0;overflow:auto hidden}.markdown :is(p,ul,ol,pre,blockquote,table){margin:0 0 .75em}.markdown>:last-child{margin-bottom:0}.markdown :is(ul,ol){padding-left:1.5em}.markdown :is(h1,h2,h3,h4){margin:1em 0 .5em;font-size:1em}.markdown blockquote{border-left:3px solid var(--line);margin-left:0;padding-left:12px}.markdown table{border-collapse:collapse}.markdown :is(th,td){border:1px solid var(--line);padding:4px 8px}.markdown hr{border:0;border-top:1px solid var(--line)}`,Zn=0;Array.isArray;function E(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l&&typeof e!=`function`)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zn,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),t.vnode&&t.vnode(u),u}function Qn({onMark:e,onStop:t}){let n=Ln.value.phase===`working`;return E(`button`,{type:`button`,class:`mark`,title:n?`Stop AI marking`:`Mark your answer with AI`,onClick:n?t:e,children:n?`Stop`:`Mark with AI`})}function $n(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var er=$n();function tr(e){er=e}var nr={exec:()=>null};function rr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function D(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(O.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ir=((e=``)=>{try{return!!RegExp(`(?<=1)(?/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:rr(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:rr(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:rr(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:rr(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:rr(e=>RegExp(`^ {0,${e}}(?:)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|RegExp(`^ {0,${e}}>`))},ar=/^(?:[ \t]*(?:\n|$))+/,or=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,sr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,cr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ur=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,dr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fr=D(dr).replace(/bull/g,ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pr=D(dr).replace(/bull/g,ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),mr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,hr=/^[^\n]+/,gr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,_r=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,gr).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),vr=D(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ur).getRegex(),yr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,br=/|$))/,xr=D(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|[^\\n]*\\n*|$)|[^\\n]*\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,br).replace(`tag`,yr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sr=e=>D(mr).replace(`hr`,cr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?| ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,wr).getRegex(),code:or,def:_r,fences:sr,heading:lr,hr:cr,html:xr,lheading:fr,list:vr,newline:ar,paragraph:Cr,table:nr,text:hr},Er=D(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,cr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?| *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,br).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:nr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(mr).replace(`hr`,cr).replace(`heading`,` *#{1,6} *[^ ]`).replace(`lheading`,fr).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},kr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ar=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,jr=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Mr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ir?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Hr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ur=D(Hr,`u`).replace(/punct/g,Nr).getRegex(),Wr=D(Hr,`u`).replace(/punct/g,Rr).getRegex(),Gr=D(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Lr).replace(/punct/g,Nr).getRegex(),Kr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,qr=D(Kr,`gu`).replace(/notPunctSpace/g,Fr).replace(/punctSpace/g,Pr).replace(/punct/g,Nr).getRegex(),Jr=D(Kr,`gu`).replace(/notPunctSpace/g,Br).replace(/punctSpace/g,zr).replace(/punct/g,Rr).getRegex(),Yr=D(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Fr).replace(/punctSpace/g,Pr).replace(/punct/g,Nr).getRegex(),Xr=D(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Fr).replace(/punctSpace/g,Pr).replace(/punct/g,Nr).getRegex(),Zr=D(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Fr).replace(/punctSpace/g,Pr).replace(/punct/g,Nr).getRegex(),Qr=D(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Nr).getRegex(),$r=D(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Fr).replace(/punctSpace/g,Pr).replace(/punct/g,Nr).getRegex(),ei=D(/\\(punct)/,`gu`).replace(/punct/g,Nr).getRegex(),ti=D(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,Nr).getRegex(),ni=D(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ri=D(br).replace(`(?:-->|$)`,`-->`).getRegex(),ii=D(`^comment|^|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,ri).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ai=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,oi=D(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,ai).getRegex(),si=D(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,oi).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ci=D(/^!?\[(label)\]\[(ref)\]/).replace(`label`,oi).replace(`ref`,gr).getRegex(),li=D(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,gr).getRegex(),ui=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,di=D(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,ai).getRegex(),fi=D(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,D(/^!?\[(label)\]\[(ref)\]/).replace(`label`,di).replace(`ref`,ui).getRegex()).replace(`nolink`,D(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ui).getRegex()).getRegex(),pi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,mi=D(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),hi={_backpedal:nr,anyPunctuation:ei,anyPunctuationOutsideCode:ti,autolink:ni,blockSkip:Vr,br:jr,code:Ar,del:nr,delLDelim:nr,delRDelim:nr,emStrongLDelim:Ur,emStrongRDelimAst:qr,emStrongRDelimUnd:Xr,escape:kr,link:si,nolink:li,punctuation:Ir,reflink:ci,reflinkSearch:fi,tag:ii,text:Mr,url:nr},gi={...hi,emStrongLDelim:Gr,emStrongRDelimAst:Yr,emStrongRDelimUnd:Zr,link:D(/^!?\[(label)\]\((.*?)\)/).replace(`label`,oi).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,oi).getRegex()},_i={...hi,emStrongRDelimAst:Jr,emStrongLDelim:Wr,delLDelim:Qr,delRDelim:$r,url:D(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,mi).replace(`protocol`,pi).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:D(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},Si=e=>xi[e];function Ci(e,t){if(t){if(O.escapeTest.test(e))return e.replace(O.escapeReplace,Si)}else if(O.escapeTestNoEncode.test(e))return e.replace(O.escapeReplaceNoEncode,Si);return e}function wi(e){return O.numericCharacterReference.test(e)?e.replace(O.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function Ti(e){try{e=encodeURI(e).replace(O.percentDecode,`%`)}catch{return null}return e}function Ei(e,t){let n=e.replace(O.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(O.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length=0&&O.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(` `)}function ki(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function Ai(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r0?-2:-1}function ji(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Mi(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function Ni(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(` `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(` `)}function Pi(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;it.length-i)return!0;i+=o[0].length-1}}return!1}var Fi=class{options;rules;lexer;constructor(e){this.options=e||er}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Oi(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Ni(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Di(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Di(t[0],` `),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Di(t[0],` `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Di(t[0],` `).split(` `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o0&&(n=`${n} ${d.join(` `)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+` `+e.join(` `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(` `)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(` `,1)[0],d=t[1].length,f=this.options.pedantic?ji(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>ji(e,d)),p=e.split(` `,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h);for(;e;){let c=e.split(` `,1)[0],l;if(p=c,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),l=p):l=p.replace(this.rules.other.leadingSpaceTab,e=>ji(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(l.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=` `+l.slice(h);else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||n.test(f))break;a+=` `+p}m=!p.trim(),e=e.substring(c.length+1),f=l.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();for(let e of o.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Oi(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&Ai(t[2],`()`)!==-1)return;let e=ki(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Di(t[0],` `),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ei(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(` `):[],a={type:`table`,raw:Di(t[0],` `),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Di(t[0],` `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===` `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Pi(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=Di(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=Ai(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),Mi(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Pi(e,n[1],r,this.rules))return;let i=t[ki((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Mi(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:wi(t[0]),escaped:e}}}},Ii=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||er,this.options.tokenizer=this.options.tokenizer||new Fi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:O,block:yi.normal,inline:bi.normal};this.options.pedantic?(t.block=yi.pedantic,t.inline=bi.pedantic):this.options.gfm&&(t.block=yi.gfm,t.inline=this.options.breaks?bi.breaks:bi.gfm),this.tokenizer.rules=t}static get rules(){return{block:yi,inline:bi}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(O.carriageReturn,` `),this.blockTokens(e,this.tokens);for(let e=0;e(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=` `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(` `)?``:` `)+i.raw,n.text+=` `+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if((i=this.tokenizer.fences(e))||(i=this.tokenizer.heading(e))||(i=this.tokenizer.hr(e))||(i=this.tokenizer.blockquote(e))||(i=this.tokenizer.list(e))||(i=this.tokenizer.html(e))){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(` `)?``:` `)+i.raw,n.text+=` `+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(` `)?``:` `)+i.raw,r.text+=` `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(` `)?``:` `)+i.raw,n.text+=` `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,ki(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,ki(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if((o=this.tokenizer.emStrong(e,n,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,n,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Li=class{options;parser;constructor(e){this.options=e||er}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(O.notSpaceStart)?.[0],i=e?e.replace(O.endingNewline,``)+` `:``;return r?`
`+(n?i:Ci(i,!0))+`
`:`
`+(n?i:Ci(i,!0))+`
`}blockquote({tokens:e}){return`
${this.parser.parse(e)}
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} `}hr(e){return`
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t `+r+` `}listitem(e){return`
  • ${this.parser.parse(e.tokens)}
  • `}checkbox({checked:e}){return` `}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    `}table(e){let t=``,n=``;for(let t=0;t${r}`,` `+t+` `+r+`
    `}tablerow({text:e}){return` ${e} `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` `}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${Ci(e,!0)}`}br(e){return`
    `}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Ci(n,!0):this.parser.parseInline(r),o=Ti(e);if(o===null)return a;e=Ci(o,i);let s=`
    `+a+``,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ti(e);if(i===null)return Ci(n);e=i;let a=`${Ci(n)}`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Ci(e.text)}},Ri=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},zi=class e{options;renderer;textRenderer;constructor(e){this.options=e||er,this.options.renderer=this.options.renderer||new Li,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ri}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n{let i=e[r].flat(1/0);Vi(n,this.walkTokens(i,t))}):e.tokens&&Vi(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Li(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Fi(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Bi;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Bi.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Bi.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&Vi(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ii.lex(e,t??this.defaults)}parser(e,t){return zi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Ii.lex:Ii.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?zi.parse:zi.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Ii.lex:Ii.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?zi.parse:zi.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,e){let e=`

    An error occurred:

    `+Ci(n.message+``,!0)+`
    `;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Ui=new Hi;function k(e,t){return Ui.parse(e,t)}k.options=k.setOptions=function(e){return Ui.setOptions(e),k.defaults=Ui.defaults,tr(k.defaults),k},k.getDefaults=$n,k.defaults=er;function Wi(...e){return Ui.use(...e),k.defaults=Ui.defaults,tr(k.defaults),k}k.use=Wi,k.walkTokens=function(e,t){return Ui.walkTokens(e,t)},k.parseInline=Ui.parseInline,k.Parser=zi,k.parser=zi.parse,k.Renderer=Li,k.TextRenderer=Ri,k.Lexer=Ii,k.lexer=Ii.lex,k.Tokenizer=Fi,k.Hooks=Bi,k.parse=k,k.options,k.setOptions,k.walkTokens,k.parseInline,zi.parse,Ii.lex;var A=class e{constructor(t,n){let r=` `+t,i,a=n&&n.loc;if(a&&a.start<=a.end){let e=a.lexer.input;i=a.start;let t=a.end;i===e.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;let n=e.slice(i,t).replace(/[^]/g,`$&̲`),o;o=i>15?`…`+e.slice(i-15,i):e.slice(0,i);let s;s=t+15":`>`,"<":`<`,'"':`"`,"'":`'`},Yi=/[&><"']/g;function Xi(e){return String(e).replace(Yi,e=>Ji[e])}var Zi=function(e){return e.type===`ordgroup`||e.type===`color`?e.body.length===1?Zi(e.body[0]):e:e.type===`font`?Zi(e.body):e},Qi=function(e){let t=Zi(e);return t.type===`mathord`||t.type===`textord`||t.type===`atom`},$i=function(e){if(!e)throw Error(`Expected non-null, but got `+String(e));return e},ea=function(e){let t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},ta=function(e){return+e.toFixed(4)},na=`acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳`,ra=[`__proto__`,`prototype`,`constructor`],ia=e=>{if(typeof e!=`object`||!e)return Object.create(null);for(let t of ra)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return Object.setPrototypeOf(e,null)},aa=class{constructor(e){e||={},this.displayMode=Gi(e,`displayMode`,!1),this.annotate=Gi(e,`annotate`,!1),this.leqno=Gi(e,`leqno`,!1),this.throwOnError=Gi(e,`throwOnError`,!1),this.errorColor=Gi(e,`errorColor`,`#b22222`),this.macros=ia(Object.prototype.hasOwnProperty.call(e,`macros`)?e.macros:void 0),this.wrap=Gi(e,`wrap`,`none`),this.xml=Gi(e,`xml`,!1),this.colorIsTextColor=Gi(e,`colorIsTextColor`,!1),this.strict=Gi(e,`strict`,!1),this.trust=Gi(e,`trust`,!1);let t=Object.prototype.hasOwnProperty.call(e,`maxSize`)?e.maxSize:void 0;this.maxSize=t===void 0?[1/0,1/0]:Array.isArray(t)?t:[1/0,1/0],this.maxExpand=Math.max(0,Gi(e,`maxExpand`,1e3)),this.wrapDelimiterPairs=!0}isTrusted(e){if(e.url&&!e.protocol){let t=ea(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},oa={},sa={};function j({type:e,names:t,props:n,handler:r,mathmlBuilder:i}){let a={type:e,numArgs:n.numArgs,argTypes:n.argTypes,allowedInArgument:!!n.allowedInArgument,allowedInText:!!n.allowedInText,allowedInMath:n.allowedInMath===void 0||n.allowedInMath,numOptionalArgs:n.numOptionalArgs||0,infix:!!n.infix,primitive:!!n.primitive,handler:r};for(let e=0;ee.toText()).join(``)}},da=function(e){return e.filter(e=>e).join(` `)},fa=function(e,t){this.classes=e||[],this.attributes={},this.style=t||{}},pa=function(e){let t=document.createElement(e);t.className=da(this.classes);for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t.style[e]=this.style[e]);for(let e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);for(let e=0;e`;for(let e=0;e`,t},ha=class{constructor(e,t,n){fa.call(this,e,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}toNode(){return pa.call(this,`span`)}toMarkup(){return ma.call(this,`span`)}},ga=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return Xi(this.text)}},_a=class{constructor(e,t,n){this.href=e,this.classes=t,this.children=n||[]}toNode(){let e=document.createElement(`a`);e.setAttribute(`href`,this.href),this.classes.length>0&&(e.className=da(this.classes));for(let t=0;t0&&(e+=` class="${Xi(da(this.classes))}"`),e+=`>`;for(let t=0;t`,e}},va=class{constructor(e,t,n){this.alt=t,this.src=e,this.classes=[`mord`],this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){let e=document.createElement(`img`);e.src=this.src,e.alt=this.alt,e.className=`mord`;for(let t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);return e}toMarkup(){let e=`${this.alt}`,e}};function ya(e){return new ua(e)}var N=class{constructor(e,t,n,r){this.type=e,this.attributes={},this.children=t||[],this.classes=n||[],this.style=r||{},this.label=``}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}setLabel(e){this.label=e}toNode(){let e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(let t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=da(this.classes));for(let t in this.style)Object.prototype.hasOwnProperty.call(this.style,t)&&(e.style[t]=this.style[t]);for(let t=0;t0&&(e+=` class="${Xi(da(this.classes))}"`);let t=``;for(let e in this.style)Object.prototype.hasOwnProperty.call(this.style,e)&&(t+=`${qi(e)}:${this.style[e]};`);t&&(e+=` style="${t}"`),e+=`>`;for(let t=0;t`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},ba=class{constructor(e){this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return Xi(this.toText())}toText(){return this.text}},xa=e=>{let t;return e.length===1&&e[0].type===`mrow`?(t=e.pop(),t.type=`mstyle`):t=new N(`mstyle`,e),t},Sa=e=>{let t=0;if(e.body&&Array.isArray(e.body))for(let n of e.body)t+=Sa(n);else if(e.body)t+=Sa(e.body);else if(e.type===`supsub`)t+=Sa(e.base),e.sub&&(t+=.7*Sa(e.sub)),e.sup&&(t+=.7*Sa(e.sup));else if(e.type===`mathord`||e.type===`textord`)for(let n of e.text.split(``)){let e=n.codePointAt(0);t+=96{let t=wa(e.label);if(e.label.indexOf(`tilde`)>-1){let n=Sa(e.base);1`,`\\gt`,!0),F(I,W,`∈`,`\\in`,!0),F(I,W,`∉`,`\\notin`,!0),F(I,W,``,`\\@not`),F(I,W,`⊂`,`\\subset`,!0),F(I,W,`⊃`,`\\supset`,!0),F(I,W,`⊆`,`\\subseteq`,!0),F(I,W,`⊇`,`\\supseteq`,!0),F(I,W,`⊈`,`\\nsubseteq`,!0),F(I,W,`⊈`,`\\nsubseteqq`),F(I,W,`⊉`,`\\nsupseteq`,!0),F(I,W,`⊉`,`\\nsupseteqq`),F(I,W,`⊨`,`\\models`),F(I,W,`←`,`\\leftarrow`,!0),F(I,W,`≤`,`\\le`),F(I,W,`≤`,`\\leq`,!0),F(I,W,`<`,`\\lt`,!0),F(I,W,`→`,`\\rightarrow`,!0),F(I,W,`→`,`\\to`),F(I,W,`≱`,`\\ngeq`,!0),F(I,W,`≱`,`\\ngeqq`),F(I,W,`≱`,`\\ngeqslant`),F(I,W,`≰`,`\\nleq`,!0),F(I,W,`≰`,`\\nleqq`),F(I,W,`≰`,`\\nleqslant`),F(I,W,`⫫`,`\\Perp`,!0),F(I,ja,`\xA0`,`\\ `),F(I,ja,`\xA0`,`\\space`),F(I,ja,`\xA0`,`\\nobreakspace`),F(L,ja,`\xA0`,`\\ `),F(L,ja,`\xA0`,` `),F(L,ja,`\xA0`,`\\space`),F(L,ja,`\xA0`,`\\nobreakspace`),F(I,ja,null,`\\nobreak`),F(I,ja,null,`\\allowbreak`),F(I,Aa,`,`,`,`),F(L,Aa,`:`,`:`),F(I,Aa,`;`,`;`),F(I,z,`⊼`,`\\barwedge`),F(I,z,`⊻`,`\\veebar`),F(I,z,`⊙`,`\\odot`,!0),F(I,z,`⊕︎`,`\\oplus`),F(I,z,`⊗`,`\\otimes`,!0),F(I,G,`∂`,`\\partial`,!0),F(I,z,`⊘`,`\\oslash`,!0),F(I,z,`⊚`,`\\circledcirc`,!0),F(I,z,`⊡`,`\\boxdot`,!0),F(I,z,`△`,`\\bigtriangleup`),F(I,z,`▽`,`\\bigtriangledown`),F(I,z,`†`,`\\dagger`),F(I,z,`⋄`,`\\diamond`),F(I,z,`◃`,`\\triangleleft`),F(I,z,`▹`,`\\triangleright`),F(I,U,`{`,`\\{`),F(L,G,`{`,`\\{`),F(L,G,`{`,`\\textbraceleft`),F(I,B,`}`,`\\}`),F(L,G,`}`,`\\}`),F(L,G,`}`,`\\textbraceright`),F(I,U,`{`,`\\lbrace`),F(I,B,`}`,`\\rbrace`),F(I,U,`[`,`\\lbrack`,!0),F(L,G,`[`,`\\lbrack`,!0),F(I,B,`]`,`\\rbrack`,!0),F(L,G,`]`,`\\rbrack`,!0),F(I,U,`(`,`\\lparen`,!0),F(I,B,`)`,`\\rparen`,!0),F(I,U,`⦇`,`\\llparenthesis`,!0),F(I,B,`⦈`,`\\rrparenthesis`,!0),F(L,G,`<`,`\\textless`,!0),F(L,G,`>`,`\\textgreater`,!0),F(I,U,`⌊`,`\\lfloor`,!0),F(I,B,`⌋`,`\\rfloor`,!0),F(I,U,`⌈`,`\\lceil`,!0),F(I,B,`⌉`,`\\rceil`,!0),F(I,G,`\\`,`\\backslash`),F(I,G,`|`,`|`),F(I,G,`|`,`\\vert`),F(L,G,`|`,`\\textbar`,!0),F(I,G,`‖`,`\\|`),F(I,G,`‖`,`\\Vert`),F(L,G,`‖`,`\\textbardbl`),F(L,G,`~`,`\\textasciitilde`),F(L,G,`\\`,`\\textbackslash`),F(L,G,`^`,`\\textasciicircum`),F(I,W,`↑`,`\\uparrow`,!0),F(I,W,`⇑`,`\\Uparrow`,!0),F(I,W,`↓`,`\\downarrow`,!0),F(I,W,`⇓`,`\\Downarrow`,!0),F(I,W,`↕`,`\\updownarrow`,!0),F(I,W,`⇕`,`\\Updownarrow`,!0),F(I,H,`∐`,`\\coprod`),F(I,H,`⋁`,`\\bigvee`),F(I,H,`⋀`,`\\bigwedge`),F(I,H,`⨄`,`\\biguplus`),F(I,H,`⨄`,`\\bigcupplus`),F(I,H,`⨃`,`\\bigcupdot`),F(I,H,`⨇`,`\\bigdoublevee`),F(I,H,`⨈`,`\\bigdoublewedge`),F(I,H,`⋂`,`\\bigcap`),F(I,H,`⋃`,`\\bigcup`),F(I,H,`∫`,`\\int`),F(I,H,`∫`,`\\intop`),F(I,H,`∬`,`\\iint`),F(I,H,`∭`,`\\iiint`),F(I,H,`∏`,`\\prod`),F(I,H,`∑`,`\\sum`),F(I,H,`⨂`,`\\bigotimes`),F(I,H,`⨁`,`\\bigoplus`),F(I,H,`⨀`,`\\bigodot`),F(I,H,`⨉`,`\\bigtimes`),F(I,H,`∮`,`\\oint`),F(I,H,`∯`,`\\oiint`),F(I,H,`∰`,`\\oiiint`),F(I,H,`∱`,`\\intclockwise`),F(I,H,`∲`,`\\varointclockwise`),F(I,H,`⨌`,`\\iiiint`),F(I,H,`⨍`,`\\intbar`),F(I,H,`⨎`,`\\intBar`),F(I,H,`⨏`,`\\fint`),F(I,H,`⨒`,`\\rppolint`),F(I,H,`⨓`,`\\scpolint`),F(I,H,`⨕`,`\\pointint`),F(I,H,`⨖`,`\\sqint`),F(I,H,`⨗`,`\\intlarhk`),F(I,H,`⨘`,`\\intx`),F(I,H,`⨙`,`\\intcap`),F(I,H,`⨚`,`\\intcup`),F(I,H,`⨅`,`\\bigsqcap`),F(I,H,`⨆`,`\\bigsqcup`),F(I,H,`∫`,`\\smallint`),F(L,ka,`…`,`\\textellipsis`),F(I,ka,`…`,`\\mathellipsis`),F(L,ka,`…`,`\\ldots`,!0),F(I,ka,`…`,`\\dotso`),F(I,ka,`…`,`\\dotsc`),F(I,ka,`…`,`\\ldots`,!0),F(I,ka,`⋰`,`\\iddots`,!0),F(I,ka,`⋯`,`\\cdots`,!0),F(I,ka,`⋱`,`\\ddots`,!0),F(I,G,`⋮`,`\\varvdots`),F(L,G,`⋮`,`\\varvdots`),F(I,R,`´`,`\\acute`),F(I,R,"`",`\\grave`),F(I,R,`¨`,`\\ddot`),F(I,R,`…`,`\\dddot`),F(I,R,`….`,`\\ddddot`),F(I,R,`~`,`\\tilde`),F(I,R,`‾`,`\\bar`),F(I,R,`˘`,`\\breve`),F(I,R,`ˇ`,`\\check`),F(I,R,`ˆ`,`\\hat`),F(I,R,`→`,`\\vec`),F(I,R,`˙`,`\\dot`),F(I,R,`˚`,`\\mathring`),F(I,V,`ı`,`\\imath`,!0),F(I,V,`ȷ`,`\\jmath`,!0),F(I,G,`ı`,`ı`),F(I,G,`ȷ`,`ȷ`),F(L,G,`ı`,`\\i`,!0),F(L,G,`ȷ`,`\\j`,!0),F(L,G,`ø`,`\\o`,!0),F(I,V,`ø`,`\\o`,!0),F(L,G,`Ø`,`\\O`,!0),F(I,V,`Ø`,`\\O`,!0),F(L,R,`ˊ`,`\\'`),F(L,R,`ˋ`,"\\`"),F(L,R,`ˆ`,`\\^`),F(L,R,`~`,`\\~`),F(L,R,`ˉ`,`\\=`),F(L,R,`˘`,`\\u`),F(L,R,`˙`,`\\.`),F(L,R,`¸`,`\\c`),F(L,R,`˚`,`\\r`),F(L,R,`ˇ`,`\\v`),F(L,R,`¨`,`\\"`),F(L,R,`˝`,`\\H`),F(I,R,`ˊ`,`\\'`),F(I,R,`ˋ`,"\\`"),F(I,R,`ˆ`,`\\^`),F(I,R,`~`,`\\~`),F(I,R,`ˉ`,`\\=`),F(I,R,`˘`,`\\u`),F(I,R,`˙`,`\\.`),F(I,R,`¸`,`\\c`),F(I,R,`˚`,`\\r`),F(I,R,`ˇ`,`\\v`),F(I,R,`¨`,`\\"`),F(I,R,`˝`,`\\H`);var Ma={"--":!0,"---":!0,"``":!0,"''":!0};F(L,G,`–`,`--`,!0),F(L,G,`–`,`\\textendash`),F(L,G,`—`,`---`,!0),F(L,G,`—`,`\\textemdash`),F(L,G,`‘`,"`",!0),F(L,G,`‘`,`\\textquoteleft`),F(L,G,`’`,`'`,!0),F(L,G,`’`,`\\textquoteright`),F(L,G,`“`,"``",!0),F(L,G,`“`,`\\textquotedblleft`),F(L,G,`”`,`''`,!0),F(L,G,`”`,`\\textquotedblright`),F(I,G,`°`,`\\degree`,!0),F(L,G,`°`,`\\degree`),F(L,G,`°`,`\\textdegree`,!0),F(I,G,`£`,`\\pounds`),F(I,G,`£`,`\\mathsterling`,!0),F(L,G,`£`,`\\pounds`),F(L,G,`£`,`\\textsterling`,!0),F(I,G,`✠`,`\\maltese`),F(L,G,`✠`,`\\maltese`),F(I,G,`€`,`\\euro`,!0),F(L,G,`€`,`\\euro`,!0),F(L,G,`€`,`\\texteuro`),F(I,G,`©`,`\\copyright`,!0),F(L,G,`©`,`\\textcopyright`),F(I,G,`⌀`,`\\diameter`,!0),F(L,G,`⌀`,`\\diameter`),F(I,G,`𝛤`,`\\varGamma`),F(I,G,`𝛥`,`\\varDelta`),F(I,G,`𝛩`,`\\varTheta`),F(I,G,`𝛬`,`\\varLambda`),F(I,G,`𝛯`,`\\varXi`),F(I,G,`𝛱`,`\\varPi`),F(I,G,`𝛴`,`\\varSigma`),F(I,G,`𝛶`,`\\varUpsilon`),F(I,G,`𝛷`,`\\varPhi`),F(I,G,`𝛹`,`\\varPsi`),F(I,G,`𝛺`,`\\varOmega`),F(L,G,`𝛤`,`\\varGamma`),F(L,G,`𝛥`,`\\varDelta`),F(L,G,`𝛩`,`\\varTheta`),F(L,G,`𝛬`,`\\varLambda`),F(L,G,`𝛯`,`\\varXi`),F(L,G,`𝛱`,`\\varPi`),F(L,G,`𝛴`,`\\varSigma`),F(L,G,`𝛶`,`\\varUpsilon`),F(L,G,`𝛷`,`\\varPhi`),F(L,G,`𝛹`,`\\varPsi`),F(L,G,`𝛺`,`\\varOmega`);var Na=`0123456789/@."`;for(let e=0;e<14;e++){let t=Na.charAt(e);F(I,G,t,t)}var Pa=`0123456789!@*()-=+";:?/.,`;for(let e=0;e<25;e++){let t=Pa.charAt(e);F(L,G,t,t)}var Fa=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;for(let e=0;e<52;e++){let t=Fa.charAt(e);F(I,V,t,t),F(L,G,t,t)}var Ia=`ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ`;for(let e=0;e<30;e++){let t=Ia.charAt(e);F(I,V,t,t),F(L,G,t,t)}var K=``;for(let e=0;e<52;e++){K=String.fromCharCode(55349,56320+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56372+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56424+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56580+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56736+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56788+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56840+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56944+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,56632+e),F(I,V,K,K),F(L,G,K,K);let t=Fa.charAt(e);K=String.fromCharCode(55349,56476+e),F(I,V,t,K),F(L,G,t,K)}for(let e=0;e<10;e++)K=String.fromCharCode(55349,57294+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,57314+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,57324+e),F(I,V,K,K),F(L,G,K,K),K=String.fromCharCode(55349,57334+e),F(I,V,K,K),F(L,G,K,K);function La(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(;s0&&i.push(new N(`mrow`,a)),i.push(n),a=[];let e=new N(`mtd`,i);e.style.textAlign=`left`,r.push(new N(`mtr`,[e])),i=[],s+=1}else{if(a.push(n),n.type&&n.type===`mo`&&n.children.length===1&&!(n.attributes.form&&n.attributes.form===`prefix`)&&!Object.prototype.hasOwnProperty.call(n.attributes,`movablelimits`)){let r=n.children[0].text;if(t===`=`&&r===`=`){if(o+=1,o>1){a.pop();let e=new N(`mrow`,a);i.push(e),a=[n]}}else if(t===`tex`){let t=s0){let e=new N(`mrow`,a);i.push(e)}if(r.length>0){let e=new N(`mtd`,i);e.style.textAlign=`left`;let t=new N(`mtr`,[e]);r.push(t);let a=new N(`mtable`,r);return n||(a.setAttribute(`columnalign`,`left`),a.setAttribute(`rowspacing`,`0em`)),a}return ya(i)}var Ra=function(e,t,n){return P[t][e]&&P[t][e].replace&&e.charCodeAt(0)!==55349&&!(Object.prototype.hasOwnProperty.call(Ma,e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)===`tt`||n.font&&n.font.slice(4,6)===`tt`))&&(e=P[t][e].replace),new ba(e)},za=(e,t)=>{if(e.children.length===0||e.children[e.children.length-1].type!==`mtext`){let n=new N(`mtext`,[new ba(t.children[0].text)]);e.children.push(n)}else e.children[e.children.length-1].children[0].text+=t.children[0].text},Ba=e=>{if(e.type!==`mrow`&&e.type!==`mstyle`||e.children.length===0)return e;let t=new N(`mrow`);for(let n=0;n0&&r.children[0].text.charAt(i-1)===` `&&(r.children[0].text=r.children[0].text.slice(0,-1)+`\xA0`);for(let[t,n]of Object.entries(e.attributes))r.attributes[t]=n}return t.children.length===1&&t.children[0].type===`mtext`?t.children[0]:t},Va=function(e,t=!1){if(e.length===1&&!(e[0]instanceof ua))return e[0];if(!t){e[0]instanceof N&&e[0].type===`mo`&&!e[0].attributes.fence&&(e[0].attributes.lspace=`0em`,e[0].attributes.rspace=`0em`);let t=e.length-1;e[t]instanceof N&&e[t].type===`mo`&&!e[t].attributes.fence&&(e[t].attributes.lspace=`0em`,e[t].attributes.rspace=`0em`)}return new N(`mrow`,e)};function Ha(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){let t=e.children[0];return t instanceof ba&&t.text===`.`}if(e.type===`mtext`&&e.children.length===1){let t=e.children[0];return t instanceof ba&&t.text===` `}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){let t=e.children[0];return t instanceof ba&&t.text===`,`}return!1}var Ua=(e,t)=>{let n=e[t],r=e[t+1];return n.type===`atom`&&n.text===`,`&&n.loc&&r.loc&&n.loc.end===r.loc.start},Wa=e=>e.type===`atom`&&e.family===`rel`||e.type===`mclass`&&e.mclass===`mrel`,Ga=function(e,t,n=!1){if(!n&&e.length===1){let n=q(e[0],t);return n instanceof N&&n.type===`mo`&&(n.setAttribute(`lspace`,`0em`),n.setAttribute(`rspace`,`0em`)),[n]}let r=[],i=[],a;for(let n=0;n0&&Wa(e[t])&&Wa(e[t-1])&&n.setAttribute(`lspace`,`0em`),n.type===`mn`&&a&&a.type===`mn`)a.children.push(...n.children);else if(Ha(n)&&a&&a.type===`mn`)a.children.push(...n.children);else if(a&&a.type===`mn`&&t=1&&a&&(a.type===`mn`||Ha(a))){let e=n.children[0];e instanceof N&&e.type===`mn`&&a&&(e.children=[...a.children,...e.children],r.pop())}r.push(n),a=n}}return r},Ka=function(e,t,n=!1){return Va(Ga(e,t,n),n)},q=function(e,t){if(!e)return new N(`mrow`);if(sa[e.type])return sa[e.type](e,t);throw new A(`Got group of unknown type: '`+e.type+`'`)},qa=e=>new N(`mtd`,[],[],{padding:`0`,width:`50%`}),Ja=[`mrow`,`mtd`,`mtable`,`mtr`],Ya=e=>{for(let t of e.children)if(t.type&&Ja.includes(t.type)){if(t.classes&&t.classes[0]===`tml-label`)return t.label;{let e=Ya(t);if(e)return e}}else if(!t.type){let e=Ya(t);if(e)return e}},Xa=(e,t,n,r)=>{t=Ka(t[0].body,n),t=Ba(t),t.classes.push(`tml-tag`);let i=Ya(e);e=new N(`mtd`,[e]);let a=[qa(),e,qa()];a[r?0:2].children.push(t);let o=new N(`mtr`,a,[`tml-tageqn`]);i&&o.setAttribute(`id`,i);let s=new N(`mtable`,[o]);return s.style.width=`100%`,s.setAttribute(`displaystyle`,`true`),s};function Za(e,t,n,r){let i=null;e.length===1&&e[0].type===`tag`&&(i=e[0].tag,e=e[0].body);let a=Ga(e,n);if(a.length===1&&a[0]instanceof _a)return a[0];let o=r.displayMode||r.annotate?`none`:r.wrap,s=a.length===0?null:a[0],c=a.length===1&&i===null&&s instanceof N?a[0]:La(a,o,r.displayMode);if(i&&(c=Xa(c,i,n,r.leqno)),r.annotate){let e=new N(`annotation`,[new ba(t)]);e.setAttribute(`encoding`,`application/x-tex`),c=new N(`semantics`,[c,e])}let l=new N(`math`,[c]);return r.xml&&l.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r.displayMode&&(l.setAttribute(`display`,`block`),l.style.display=`block math`,l.classes=[`tml-display`]),l}var Qa=`DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ`,$a=`BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ`,eo=`AFJdfΔΛ`,to=(e,t)=>{let n=e.isStretchy?Ea(e):new N(`mo`,[Ra(e.label,e.mode)]);e.isStretchy||n.setAttribute(`stretchy`,`false`),e.label!==`\\vec`&&(n.style.mathDepth=`0`);let r=e.label===`\\c`?`munder`:`mover`,i=ro.has(e.label);if(r===`mover`&&e.mode===`math`&&!e.isStretchy&&e.base.text&&e.base.text.length===1){let t=e.base.text,r=e.label===`\\vec`,a=r===`\\vec`?`-vec`:``;r&&n.classes.push(`tml-vec`);let o=r?`-vec`:i?`-acc`:``;Qa.indexOf(t)>-1?(n.classes.push(`chr-sml${a}`),n.classes.push(`wbk-sml${o}`)):$a.indexOf(t)>-1?(n.classes.push(`chr-med${a}`),n.classes.push(`wbk-med${o}`)):eo.indexOf(t)>-1?(n.classes.push(`chr-lrg${a}`),n.classes.push(`wbk-lrg${o}`)):r?n.classes.push(`wbk-vec`):i&&n.classes.push(`wbk-acc`)}else i&&n.classes.push(`wbk-acc`);return new N(r,[q(e.base,t),n])},no=new Set([`\\acute`,`\\check`,`\\grave`,`\\ddot`,`\\dddot`,`\\ddddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`]),ro=new Set([`\\acute`,`\\bar`,`\\breve`,`\\check`,`\\dot`,`\\ddot`,`\\grave`,`\\hat`,`\\mathring`,"\\`",`\\'`,`\\^`,`\\=`,`\\u`,`\\.`,`\\"`,`\\r`,`\\H`,`\\v`]),io={"\\`":`̀`,"\\'":`́`,"\\^":`̂`,"\\~":`̃`,"\\=":`̄`,"\\u":`̆`,"\\.":`̇`,'\\"':`̈`,"\\r":`̊`,"\\H":`̋`,"\\v":`̌`,"\\c":`̧`};j({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\dddot`,`\\ddddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\overparen`,`\\widecheck`,`\\widehat`,`\\wideparen`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overleftharpoon`,`\\overrightharpoon`],props:{numArgs:1},handler:(e,t)=>{let n=la(t[0]),r=!no.has(e.funcName);return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,base:n}},mathmlBuilder:to}),j({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\c`,`\\u`,`\\.`,`\\"`,`\\r`,`\\H`,`\\v`],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`]},handler:(e,t)=>{let n=la(t[0]),r=e.parser.mode;return r===`math`&&e.parser.settings.strict&&console.log(`Temml parse error: Command ${e.funcName} is invalid in math mode.`),r===`text`&&n.text&&n.text.length===1&&e.funcName in io&&na.indexOf(n.text)>-1?{type:`textord`,mode:`text`,text:n.text+io[e.funcName]}:e.funcName===`\\c`&&r===`text`&&n.text&&n.text.length===1?{type:`textord`,mode:`text`,text:n.text+`̧`}:{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,base:n}},mathmlBuilder:to}),j({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underparen`,`\\utilde`],props:{numArgs:1},handler:({parser:e,funcName:t},n)=>{let r=n[0];return{type:`accentUnder`,mode:e.mode,label:t,base:r}},mathmlBuilder:(e,t)=>{let n=Ea(e);return n.style[`math-depth`]=0,new N(`munder`,[q(e.base,t),n])}});var ao={pt:800/803,pc:9600/803,dd:1238/1157*800/803,cc:14856/1157*800/803,nd:685/642*800/803,nc:1370/107*800/803,sp:1/65536*800/803,mm:25.4/72,cm:2.54/72,in:1/72,px:96/72},oo=[`em`,`ex`,`mu`,`pt`,`mm`,`cm`,`in`,`px`,`bp`,`pc`,`dd`,`cc`,`nd`,`nc`,`sp`],so=function(e){return typeof e!=`string`&&(e=e.unit),oo.indexOf(e)>-1},co=e=>[1,.7,.5][Math.max(e-1,0)],lo=function(e,t){let n=e.number;if(t.maxSize[0]<0&&n>0)return{number:0,unit:`em`};let r=e.unit;switch(r){case`mm`:case`cm`:case`in`:case`px`:return n*ao[r]>t.maxSize[1]?{number:t.maxSize[1],unit:`pt`}:{number:n,unit:r};case`em`:case`ex`:return r===`ex`&&(n*=.431),n=Math.min(n/co(t.level),t.maxSize[0]),{number:ta(n),unit:`em`};case`bp`:return n>t.maxSize[1]&&(n=t.maxSize[1]),{number:n,unit:`pt`};case`pt`:case`pc`:case`dd`:case`cc`:case`nd`:case`nc`:case`sp`:return n=Math.min(n*ao[r],t.maxSize[1]),{number:ta(n),unit:`pt`};case`mu`:return n=Math.min(n/18,t.maxSize[0]),{number:ta(n),unit:`em`};default:throw new A(`Invalid unit: '`+r+`'`)}},J=e=>{let t=new N(`mspace`);return t.setAttribute(`width`,e+`em`),t},uo=(e,t=.3,n=0,r=!1)=>{if(e==null&&n===0)return J(t);let i=e?[e]:[];if(t!==0&&i.unshift(J(t)),n>0&&i.push(J(n)),r){let e=new N(`mpadded`,i);return e.setAttribute(`height`,`0.1px`),e}return new N(`mrow`,i)},fo=(e,t)=>Number(e)/co(t),po=(e,t,n,r)=>{let i=wa(e),a=e.slice(1,3)===`eq`,o=e.charAt(1)===`x`?`1.75`:e.slice(2,4)===`cd`?`3.0`:a?`1.0`:`2.0`;i.setAttribute(`lspace`,`0`),i.setAttribute(`rspace`,a?`0.5em`:`0`);let s=r.withLevel(r.level<2?2:3),c=fo(o,s.level),l=fo(o,3),u=uo(null,c.toFixed(4),0),d=uo(null,l.toFixed(4),0),f=fo(a?0:.3,s.level).toFixed(4),p,m,h=t&&t.body&&(t.body.body||t.body.length>0);if(h){let n=q(t,s);n=uo(n,f,f,e===`\\\\cdrightarrow`||e===`\\\\cdleftarrow`),p=new N(`mover`,[n,d])}let g=n&&n.body&&(n.body.body||n.body.length>0);if(g){let e=q(n,s);e=uo(e,f,f),m=new N(`munder`,[e,d])}let _;return _=!h&&!g?new N(`mover`,[i,u]):h&&g?new N(`munderover`,[i,m,p]):h?new N(`mover`,[i,p]):new N(`munder`,[i,m]),o===`3.0`&&(_.style.height=`1em`),_.setAttribute(`accent`,`false`),_};j({type:`xArrow`,names:`\\xleftarrow.\\xrightarrow.\\xLeftarrow.\\xRightarrow.\\xleftrightarrow.\\xLeftrightarrow.\\xhookleftarrow.\\xhookrightarrow.\\xmapsto.\\xrightharpoondown.\\xrightharpoonup.\\xleftharpoondown.\\xleftharpoonup.\\xlongequal.\\xtwoheadrightarrow.\\xtwoheadleftarrow.\\xtofrom.\\xleftrightharpoons.\\xrightleftharpoons.\\yields.\\yieldsLeft.\\mesomerism.\\longrightharpoonup.\\longleftharpoondown.\\yieldsLeftRight.\\chemequilibrium.\\\\cdrightarrow.\\\\cdleftarrow.\\\\cdlongequal`.split(`.`),props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,r){return{type:`xArrow`,mode:e.mode,name:t,body:n[0],below:r[0]}},mathmlBuilder(e,t){let n=[po(e.name,e.body,e.below,t)];return n.unshift(J(.2778)),n.push(J(.2778)),new N(`mrow`,n)}});var mo={"\\equilibriumRight":[`\\longrightharpoonup`,`\\eqleftharpoondown`],"\\equilibriumLeft":[`\\eqrightharpoonup`,`\\longleftharpoondown`]};j({type:`stackedArrow`,names:[`\\equilibriumRight`,`\\equilibriumLeft`],props:{numArgs:1,numOptionalArgs:1},handler({parser:e,funcName:t},n,r){let i=n[0]?{type:`hphantom`,mode:e.mode,body:n[0]}:null,a=r[0]?{type:`hphantom`,mode:e.mode,body:r[0]}:null;return{type:`stackedArrow`,mode:e.mode,name:t,body:n[0],upperArrowBelow:a,lowerArrowBody:i,below:r[0]}},mathmlBuilder(e,t){let n=mo[e.name][0],r=mo[e.name][1],i=po(n,e.body,e.upperArrowBelow,t),a=po(r,e.lowerArrowBody,e.below,t),o,s=new N(`mpadded`,[i]);if(s.setAttribute(`voffset`,`0.3em`),s.setAttribute(`height`,`+0.3em`),s.setAttribute(`depth`,`-0.3em`),e.name===`\\equilibriumLeft`){let e=new N(`mpadded`,[a]);e.setAttribute(`width`,`0.5em`),o=new N(`mpadded`,[J(.2778),e,s,J(.2778)])}else s.setAttribute(`width`,e.name===`\\equilibriumRight`?`0.5em`:`0`),o=new N(`mpadded`,[J(.2778),s,a,J(.2778)]);return o.setAttribute(`voffset`,`-0.18em`),o.setAttribute(`height`,`-0.18em`),o.setAttribute(`depth`,`+0.18em`),o}});var ho={};function go({type:e,names:t,props:n,handler:r,mathmlBuilder:i}){let a={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:r};for(let e=0;e":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},bo=()=>({type:`styling`,body:[],mode:`math`,scriptLevel:`display`}),xo=e=>e.type===`textord`&&e.text===`@`,So=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function Co(e,t,n){let r=yo[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:{let e=n.callFunction(`\\\\cdleft`,[t[0]],[]),i={type:`atom`,text:r,mode:`math`,family:`rel`},a={type:`ordgroup`,mode:`math`,body:[e,n.callFunction(`\\Big`,[i],[]),n.callFunction(`\\\\cdright`,[t[1]],[])],semisimple:!0};return n.callFunction(`\\\\cdparent`,[a],[])}case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function wo(e){let t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();let n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new A(`Expected \\\\ or \\cr or \\end`,e.nextToken)}let n=[],r=[n];for(let i=0;i-1)){if(`<>AV`.indexOf(r)>-1)for(let e=0;e<2;e++){let n=!0;for(let o=t+1;oAV=|." after @.`)}let s=Co(r,i,e);n.push(s),o=bo()}i%2==0?n.push(o):n.shift(),n=[],r.push(n)}return r.pop(),e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:r,tags:null,labels:Array(r.length+1).fill(``),envClasses:[`jot`,`cd`],cols:[],hLinesBeforeRow:Array(r.length+1).fill([])}}j({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],props:{numArgs:1},handler({parser:e,funcName:t},n){return{type:`cdlabel`,mode:e.mode,side:t.slice(4),label:n[0]}},mathmlBuilder(e,t){if(e.label.body.length===0)return new N(`mrow`,t);let n=q(e.label,t);e.side===`left`&&n.classes.push(`tml-shift-left`);let r=new N(`mtd`,[n]);r.style.padding=`0`;let i=new N(`mpadded`,[new N(`mtable`,[new N(`mtr`,[r])])]);return i.setAttribute(`width`,`0.1px`),i.setAttribute(`displaystyle`,`false`),i.setAttribute(`scriptlevel`,`1`),i}}),j({type:`cdlabelparent`,names:[`\\\\cdparent`],props:{numArgs:1},handler({parser:e},t){return{type:`cdlabelparent`,mode:e.mode,fragment:t[0]}},mathmlBuilder(e,t){return new N(`mrow`,[q(e.fragment,t)])}});var To=e=>({type:`ordgroup`,mode:`math`,body:e,semisimple:!0}),Eo=(e,t)=>({type:t,mode:`math`,body:To(e)}),Do=(e,t)=>{let n=e.body;n[0].shift();let r=Array(n.length-1).fill().map(()=>[]);for(let e=1;e[]);for(let e=0;e[]),envClasses:[],scriptLevel:`text`,arraystretch:1,labels:Array(r.length).fill(``),arraycolsep:{number:.04,unit:`em`}},o={type:`styling`,mode:`math`,scriptLevel:`text`,body:[{type:`array`,mode:`math`,body:i,cols:Array(i.length).fill({type:`align`,align:`c`}),rowGaps:Array(i.length-1).fill(null),hLinesBeforeRow:Array(i.length+1).fill().map(()=>[]),envClasses:[],scriptLevel:`text`,arraystretch:1,labels:Array(i.length).fill(``),arraycolsep:null}]};return To([a,{type:`supsub`,mode:`math`,stack:!0,base:{type:`op`,mode:`math`,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!0,symbol:!1,suppressBaseShift:!0,body:[{type:`leftright`,mode:`math`,body:[e],left:t?t[0]:`(`,right:t?t[1]:`)`,rightColor:void 0}]},sup:o,sub:null}])},Oo=class e{constructor(e,t,n){this.lexer=e,this.start=t,this.end=n}static range(t,n){return n?!t||!t.loc||!n.loc||t.loc.lexer!==n.loc.lexer?null:new e(t.loc.lexer,t.loc.start,n.loc.end):t&&t.loc}},ko=class e{constructor(e,t){this.text=e,this.loc=t}range(t,n){return new e(n,Oo.range(this,t))}},X={DISPLAY:0,TEXT:1,SCRIPT:2,SCRIPTSCRIPT:3},Ao=Object.create(null);function Z(e,t){Ao[e]=t}var jo=Ao;Z(`\\noexpand`,function(e){let t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Z(`\\expandafter`,function(e){let t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Z(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Z(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Z(`\\@ifnextchar`,function(e){let t=e.consumeArgs(3);e.consumeSpaces();let n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Z(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),Z(`\\TextOrMath`,function(e){let t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Mo=e=>{let t=``;for(let n=e.length-1;n>-1;n--)t+=e[n].text;return t},No={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},Po=e=>{let t=e.future().text;return t===`EOF`?[null,``]:[No[t.charAt(0)],t]},Fo=(e,t,n)=>{for(let r=1;r=n)throw new A(`Invalid base-${n} digit ${t.text}`);r=Fo(r,i,n);let a;for([a,i]=Po(e);a!=null&&a=0;e--){let i=t[e].loc.start;i>r&&(n+=` `,r=i),n+=t[e].text,r+=t[e].text.length}return n}Z(`\\surd`,`\\sqrt{\\vphantom{|}}`),Z(`⊕`,`\\oplus`),Z(`\\long`,``),Z(`\\bgroup`,`{`),Z(`\\egroup`,`}`),Z(`~`,`\\nobreakspace`),Z(`\\lq`,"`"),Z(`\\rq`,`'`),Z(`\\aa`,`\\r a`),Z(`\\Bbbk`,`\\Bbb{k}`),Z(`\\mathstrut`,`\\vphantom{(}`),Z(`\\underbar`,`\\underline{\\text{#1}}`),Z(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),Z(`⋮`,`\\vdots`),Z(`\\arraystretch`,`1`),Z(`\\arraycolsep`,`6pt`),Z(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),Z(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),Z(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),Z(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`);var Lo={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcap":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\bigtimes":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\DOTSX":`\\dotsx`};Z(`\\dots`,function(e){let t=`\\dotso`,n=e.expandAfterFuture().text;return n in Lo?t=Lo[n]:(n.slice(0,4)===`\\not`||n in P.math&&[`bin`,`rel`].includes(P.math[n].group))&&(t=`\\dotsb`),t}),Z(`\\dotsb`,`\\cdots`),Z(`\\dotsm`,`\\cdots`),Z(`\\dotsi`,`\\!\\cdots`),Z(`\\idotsint`,`\\int\\!\\cdots\\!\\int`),Z(`\\dotsx`,`\\ldots\\,`),Z(`\\DOTSI`,`\\relax`),Z(`\\DOTSB`,`\\relax`),Z(`\\DOTSX`,`\\relax`),Z(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),Z(`\\,`,`{\\tmspace+{3mu}{.1667em}}`),Z(`\\thinspace`,`\\,`),Z(`\\>`,`\\mskip{4mu}`),Z(`\\:`,`{\\tmspace+{4mu}{.2222em}}`),Z(`\\medspace`,`\\:`),Z(`\\;`,`{\\tmspace+{5mu}{.2777em}}`),Z(`\\thickspace`,`\\;`),Z(`\\!`,`{\\tmspace-{3mu}{.1667em}}`),Z(`\\negthinspace`,`\\!`),Z(`\\negmedspace`,`{\\tmspace-{4mu}{.2222em}}`),Z(`\\negthickspace`,`{\\tmspace-{5mu}{.277em}}`),Z(`\\enspace`,`\\kern.5em `),Z(`\\enskip`,`\\hskip.5em\\relax`),Z(`\\quad`,`\\hskip1em\\relax`),Z(`\\qquad`,`\\hskip2em\\relax`),Z(`\\AA`,`\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax`),Z(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),Z(`\\tag@paren`,`\\tag@literal{({#1})}`),Z(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new A(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),Z(`\\notag`,`\\nonumber`),Z(`\\nonumber`,`\\gdef\\@eqnsw{0}`),Z(`\\bmod`,`\\mathbin{\\text{mod}}`),Z(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),Z(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),Z(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),Z(`\\newline`,`\\\\\\relax`),Z(`\\TeX`,`\\textrm{T}\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125em\\textrm{X}`),Z(`\\LaTeX`,`\\textrm{L}\\kern-.35em\\raisebox{0.2em}{\\scriptstyle A}\\kern-.15em\\TeX`),Z(`\\Temml`,`\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}`),Z(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),Z(`\\@hspace`,`\\hskip #1\\relax`),Z(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),Z(`\\colon`,`\\mathpunct{\\char"3a}`),Z(`\\prescript`,`\\pres@cript{^{#1}_{#2}}{}{#3}`),Z(`\\ordinarycolon`,`\\char"3a`),Z(`\\vcentcolon`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}}`),Z(`\\coloneq`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2212}`),Z(`\\Coloneq`,`\\mathrel{\\char"2237\\char"2212}`),Z(`\\Eqqcolon`,`\\mathrel{\\char"3d\\char"2237}`),Z(`\\Eqcolon`,`\\mathrel{\\char"2212\\char"2237}`),Z(`\\colonapprox`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"2248}`),Z(`\\Colonapprox`,`\\mathrel{\\char"2237\\char"2248}`),Z(`\\colonsim`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}`),Z(`\\Colonsim`,`\\mathrel{\\raisebox{0.035em}{\\ordinarycolon}\\char"223c}`),Z(`\\ratio`,`\\vcentcolon`),Z(`\\coloncolon`,`\\dblcolon`),Z(`\\colonequals`,`\\coloneqq`),Z(`\\coloncolonequals`,`\\Coloneqq`),Z(`\\equalscolon`,`\\eqqcolon`),Z(`\\equalscoloncolon`,`\\Eqqcolon`),Z(`\\colonminus`,`\\coloneq`),Z(`\\coloncolonminus`,`\\Coloneq`),Z(`\\minuscolon`,`\\eqcolon`),Z(`\\minuscoloncolon`,`\\Eqcolon`),Z(`\\coloncolonapprox`,`\\Colonapprox`),Z(`\\coloncolonsim`,`\\Colonsim`),Z(`\\notni`,"\\mathrel{\\char`∌}"),Z(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),Z(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),Z(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),Z(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),Z(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{\\text{lim}}}`),Z(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{\\text{lim}}}`),Z(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{\\text{lim}}}`),Z(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{\\text{lim}}}`),Z(`\\centerdot`,`{\\medspace\\rule{0.167em}{0.189em}\\medspace}`),Z(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),Z(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),Z(`\\plim`,`\\DOTSB\\operatorname*{plim}`),Z(`\\leftmodels`,`\\mathop{\\reflectbox{$\\models$}}`),Z(`\\bra`,`\\mathinner{\\langle{#1}|}`),Z(`\\ket`,`\\mathinner{|{#1}\\rangle}`),Z(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),Z(`\\Bra`,`\\left\\langle#1\\right|`),Z(`\\Ket`,`\\left|#1\\right\\rangle`);var Ro=(e,t)=>{let n=`}\\,\\middle${t[0]===`|`?`\\vert`:`\\Vert`}\\,{`;return e.slice(0,t.index)+n+e.slice(t.index+t[0].length)};Z(`\\Braket`,function(e){let t=Io(e),n=/\|\||\||\\\|/g,r;for(;(r=n.exec(t))!==null;)t=Ro(t,r);return`\\left\\langle{`+t+`}\\right\\rangle`}),Z(`\\Set`,function(e){let t=Io(e),n=/\|\||\||\\\|/.exec(t);return n&&(t=Ro(t,n)),`\\left\\{\\:{`+t+`}\\:\\right\\}`}),Z(`\\set`,function(e){return`\\{{`+Io(e).replace(/\|/,`}\\mid{`)+`}\\}`}),Z(`\\angln`,`{\\angl n}`),Z(`\\odv`,`\\@ifstar\\odv@next\\odv@numerator`),Z(`\\odv@numerator`,`\\frac{\\mathrm{d}#1}{\\mathrm{d}#2}`),Z(`\\odv@next`,`\\frac{\\mathrm{d}}{\\mathrm{d}#2}#1`),Z(`\\pdv`,`\\@ifstar\\pdv@next\\pdv@numerator`);var zo=e=>{let t=e[0][0].text,n=Mo(e[1]).split(`,`),r=String(n.length),i=r===`1`?`\\partial`:`\\partial^${r}`,a=``;return n.map(e=>{a+=`\\partial `+e.trim()+`\\,`}),[t,i,a.replace(/\\,$/,``)]};Z(`\\pdv@numerator`,function(e){let[t,n,r]=zo(e.consumeArgs(2));return`\\frac{${n} ${t}}{${r}}`}),Z(`\\pdv@next`,function(e){let[t,n,r]=zo(e.consumeArgs(2));return`\\frac{${n}}{${r}} ${t}`}),Z(`\\upalpha`,`\\up@greek{\\alpha}`),Z(`\\upbeta`,`\\up@greek{\\beta}`),Z(`\\upgamma`,`\\up@greek{\\gamma}`),Z(`\\updelta`,`\\up@greek{\\delta}`),Z(`\\upepsilon`,`\\up@greek{\\epsilon}`),Z(`\\upzeta`,`\\up@greek{\\zeta}`),Z(`\\upeta`,`\\up@greek{\\eta}`),Z(`\\uptheta`,`\\up@greek{\\theta}`),Z(`\\upiota`,`\\up@greek{\\iota}`),Z(`\\upkappa`,`\\up@greek{\\kappa}`),Z(`\\uplambda`,`\\up@greek{\\lambda}`),Z(`\\upmu`,`\\up@greek{\\mu}`),Z(`\\upnu`,`\\up@greek{\\nu}`),Z(`\\upxi`,`\\up@greek{\\xi}`),Z(`\\upomicron`,`\\up@greek{\\omicron}`),Z(`\\uppi`,`\\up@greek{\\pi}`),Z(`\\upalpha`,`\\up@greek{\\alpha}`),Z(`\\uprho`,`\\up@greek{\\rho}`),Z(`\\upsigma`,`\\up@greek{\\sigma}`),Z(`\\uptau`,`\\up@greek{\\tau}`),Z(`\\upupsilon`,`\\up@greek{\\upsilon}`),Z(`\\upphi`,`\\up@greek{\\phi}`),Z(`\\upchi`,`\\up@greek{\\chi}`),Z(`\\uppsi`,`\\up@greek{\\psi}`),Z(`\\upomega`,`\\up@greek{\\omega}`),Z(`\\invamp`,`\\mathbin{\\char"214b}`),Z(`\\parr`,`\\mathbin{\\char"214b}`),Z(`\\upand`,`\\mathbin{\\char"214b}`),Z(`\\with`,`\\mathbin{\\char"26}`),Z(`\\multimapinv`,`\\mathrel{\\char"27dc}`),Z(`\\multimapboth`,`\\mathrel{\\char"29df}`),Z(`\\scoh`,`{\\mkern5mu\\char"2322\\mkern5mu}`),Z(`\\sincoh`,`{\\mkern5mu\\char"2323\\mkern5mu}`),Z(`\\coh`,`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2322}}} {\\smash{\\lower4mu{\\char"2323}}}\\mkern5mu}`),Z(`\\incoh`,`{\\mkern5mu\\rule{}{0.7em}\\mathrlap{\\smash{\\raise2mu{\\char"2323}}} {\\smash{\\lower4mu{\\char"2322}}}\\mkern5mu}`),Z(`\\standardstate`,"\\text{\\tiny\\char`⦵}"),Z(`\\ce`,function(e){return Bo(e.consumeArgs(1)[0],`ce`)}),Z(`\\pu`,function(e){return Bo(e.consumeArgs(1)[0],`pu`)}),Z(`\\uniDash`,`{\\rule{0.672em}{0.06em}}`),Z(`\\triDash`,`{\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}\\kern2mu\\rule{0.15em}{0.06em}}`),Z(`\\tripleDash`,`\\kern0.075em\\raise0.25em{\\triDash}\\kern0.075em`),Z(`\\tripleDashOverLine`,`\\kern0.075em\\mathrlap{\\raise0.125em{\\uniDash}}\\raise0.34em{\\triDash}\\kern0.075em`),Z(`\\tripleDashOverDoubleLine`,`\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\triDash}}\\raise0.27em{\\uniDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em`),Z(`\\tripleDashBetweenDoubleLine`,`\\kern0.075em\\mathrlap{\\mathrlap{\\raise0.48em{\\uniDash}}\\raise0.27em{\\triDash}}{\\raise0.05em{\\uniDash}}\\kern0.075em`);var Bo=function(e,t){for(var n=``,r=e.length&&e[e.length-1].loc.start,i=e.length-1;i>=0;i--)e[i].loc.start>r&&(n+=` `,r=e[i].loc.start),n+=e[i].text,r+=e[i].text.length;return $.go(Q.go(n,t))},Q={go:function(e,t){if(!e)return[];t===void 0&&(t=`ce`);var n=`0`,r={};r.parenthesisLevel=0,e=e.replace(/\n/g,` `),e=e.replace(/[\u2212\u2013\u2014\u2010]/g,`-`),e=e.replace(/[\u2026]/g,`...`);for(var i,a=10,o=[];;){i===e?a--:(a=10,i=e);var s=Q.stateMachines[t],c=s.transitions[n]||s.transitions[`*`];iterateTransitions:for(var l=0;l0){if(d.revisit||(e=u.remainder),!d.toContinue)break iterateTransitions}else return o}}if(a<=0)throw[`MhchemBugU`,`mhchem bug U. Please report.`]}},concatArray:function(e,t){if(t){if(Array.isArray(t))for(var n=0;n":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\bond{`,``,``,`}`)},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(e){return Q.patterns.findObserveGroups(e,`[`,``,``,`]`)},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(e){return Q.patterns.findObserveGroups(e,``,/^\\[a-zA-Z]+\{/,`}`,``,``,`{`,`}`,``,!0)},"\\x{}":function(e){return Q.patterns.findObserveGroups(e,``,/^\\[a-zA-Z]+\{/,`}`,``)},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\frac{`,``,``,`}`,`{`,``,``,`}`)},"\\overset{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\overset{`,``,``,`}`,`{`,``,``,`}`)},"\\underset{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\underset{`,``,``,`}`,`{`,``,``,`}`)},"\\underbrace{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\underbrace{`,``,``,`}_`,`{`,``,``,`}`)},"\\color{(...)}0":function(e){return Q.patterns.findObserveGroups(e,`\\color{`,``,``,`}`)},"\\color{(...)}{(...)}1":function(e){return Q.patterns.findObserveGroups(e,`\\color{`,``,``,`}`,`{`,``,``,`}`)},"\\color(...){(...)}2":function(e){return Q.patterns.findObserveGroups(e,`\\color`,`\\`,``,/^(?=\{)/,`{`,``,``,`}`)},"\\ce{(...)}":function(e){return Q.patterns.findObserveGroups(e,`\\ce{`,``,``,`}`)},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(e){var t=e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);if(t)return{match_:t[0],remainder:e.substr(t[0].length)};var n=Q.patterns.findObserveGroups(e,``,`$`,`$`,``);return n&&(t=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),t)?{match_:t[0],remainder:e.substr(t[0].length)}:null},amount2:function(e){return this.amount(e)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(e){if(e.match(/^\([a-z]+\)$/))return null;var t=e.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return t?{match_:t[0],remainder:e.substr(t[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(e,t,n,r,i,a,o,s,c,l){var u=function(e,t){if(typeof t==`string`)return e.indexOf(t)===0?t:null;var n=e.match(t);return n?n[0]:null},d=function(e,t,n){for(var r=0;t":{"0|1|2|3":{action_:`r=`,nextState:`r`},"a|as":{action_:[`output`,`r=`],nextState:`r`},"*":{action_:[`output`,`r=`],nextState:`r`}},"+":{o:{action_:`d= kv`,nextState:`d`},"d|D":{action_:`d=`,nextState:`d`},q:{action_:`d=`,nextState:`qd`},"qd|qD":{action_:`d=`,nextState:`qd`},dq:{action_:[`output`,`d=`],nextState:`d`},3:{action_:[`sb=false`,`output`,`operator`],nextState:`0`}},amount:{"0|2":{action_:`a=`,nextState:`a`}},"pm-operator":{"0|1|2|a|as":{action_:[`sb=false`,`output`,{type_:`operator`,option:`\\pm`}],nextState:`0`}},operator:{"0|1|2|a|as":{action_:[`sb=false`,`output`,`operator`],nextState:`0`}},"-$":{"o|q":{action_:[`charge or bond`,`output`],nextState:`qd`},d:{action_:`d=`,nextState:`d`},D:{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`},q:{action_:`d=`,nextState:`qd`},qd:{action_:`d=`,nextState:`qd`},"qD|dq":{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`}},"-9":{"3|o":{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`3`}},"- orbital overlap":{o:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`},d:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`}},"-":{"0|1|2":{action_:[{type_:`output`,option:1},`beginsWithBond=true`,{type_:`bond`,option:`-`}],nextState:`3`},3:{action_:{type_:`bond`,option:`-`}},a:{action_:[`output`,{type_:`insert`,option:`hyphen`}],nextState:`2`},as:{action_:[{type_:`output`,option:2},{type_:`bond`,option:`-`}],nextState:`3`},b:{action_:`b=`},o:{action_:{type_:`- after o/d`,option:!1},nextState:`2`},q:{action_:{type_:`- after o/d`,option:!1},nextState:`2`},"d|qd|dq":{action_:{type_:`- after o/d`,option:!0},nextState:`2`},"D|qD|p":{action_:[`output`,{type_:`bond`,option:`-`}],nextState:`3`}},amount2:{"1|3":{action_:`a=`,nextState:`a`}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:`o=`,nextState:`o`},"q|dq":{action_:[`output`,`o=`],nextState:`o`},"d|D|qd|qD":{action_:`o after d`,nextState:`o`}},digits:{o:{action_:`q=`,nextState:`q`},"d|D":{action_:`q=`,nextState:`dq`},q:{action_:[`output`,`o=`],nextState:`o`},a:{action_:`o=`,nextState:`o`}},"space A":{"b|p|bp":{}},space:{a:{nextState:`as`},0:{action_:`sb=false`},"1|2":{action_:`sb=true`},"r|rt|rd|rdt|rdq":{action_:`output`,nextState:`0`},"*":{action_:[`output`,`sb=true`],nextState:`1`}},"1st-level escape":{"1|2":{action_:[`output`,{type_:`insert+p1`,option:`1st-level escape`}]},"*":{action_:[`output`,{type_:`insert+p1`,option:`1st-level escape`}],nextState:`0`}},"[(...)]":{"r|rt":{action_:`rd=`,nextState:`rd`},"rd|rdt":{action_:`rq=`,nextState:`rdq`}},"...":{"o|d|D|dq|qd|qD":{action_:[`output`,{type_:`bond`,option:`...`}],nextState:`3`},"*":{action_:[{type_:`output`,option:1},{type_:`insert`,option:`ellipsis`}],nextState:`1`}},". |* ":{"*":{action_:[`output`,{type_:`insert`,option:`addition compound`}],nextState:`1`}},"state of aggregation $":{"*":{action_:[`output`,`state of aggregation`],nextState:`1`}},"{[(":{"a|as|o":{action_:[`o=`,`output`,`parenthesisLevel++`],nextState:`2`},"0|1|2|3":{action_:[`o=`,`output`,`parenthesisLevel++`],nextState:`2`},"*":{action_:[`output`,`o=`,`output`,`parenthesisLevel++`],nextState:`2`}},")]}":{"0|1|2|3|b|p|bp|o":{action_:[`o=`,`parenthesisLevel--`],nextState:`o`},"a|as|d|D|q|qd|qD|dq":{action_:[`output`,`o=`,`parenthesisLevel--`],nextState:`o`}},", ":{"*":{action_:[`output`,`comma`],nextState:`0`}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:`b=`,nextState:`b`},p:{action_:`b=`,nextState:`bp`},"3|o":{action_:`d= kv`,nextState:`D`},q:{action_:`d=`,nextState:`qD`},"d|D|qd|qD|dq":{action_:[`output`,`d=`],nextState:`D`}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:`b=`,nextState:`b`},p:{action_:`b=`,nextState:`bp`},"3|o":{action_:`d= kv`,nextState:`d`},q:{action_:`d=`,nextState:`qd`},"d|qd|D|qD":{action_:`d=`},dq:{action_:[`output`,`d=`],nextState:`d`}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:[`output`,`q=`],nextState:`q`}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:`p=`,nextState:`p`},b:{action_:`p=`,nextState:`bp`},"3|o":{action_:`q=`,nextState:`q`},"d|D":{action_:`q=`,nextState:`dq`},"q|qd|qD|dq":{action_:[`output`,`q=`],nextState:`q`}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:`output`,option:2},`bond`],nextState:`3`}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:`output`,option:2},{type_:`bond`,option:`#`}],nextState:`3`}},"{}":{"*":{action_:{type_:`output`,option:1},nextState:`1`}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:`o=`,nextState:`o`},"o|d|D|q|qd|qD|dq":{action_:[`output`,`o=`],nextState:`o`}},"$...$":{a:{action_:`a=`},"0|1|2|3|as|b|p|bp|o":{action_:`o=`,nextState:`o`},"as|o":{action_:`o=`},"q|d|D|qd|qD|dq":{action_:[`output`,`o=`],nextState:`o`}},"\\bond{(...)}":{"*":{action_:[{type_:`output`,option:2},`bond`],nextState:`3`}},"\\frac{(...)}":{"*":{action_:[{type_:`output`,option:1},`frac-output`],nextState:`3`}},"\\overset{(...)}":{"*":{action_:[{type_:`output`,option:2},`overset-output`],nextState:`3`}},"\\underset{(...)}":{"*":{action_:[{type_:`output`,option:2},`underset-output`],nextState:`3`}},"\\underbrace{(...)}":{"*":{action_:[{type_:`output`,option:2},`underbrace-output`],nextState:`3`}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:`output`,option:2},`color-output`],nextState:`3`}},"\\color{(...)}0":{"*":{action_:[{type_:`output`,option:2},`color0-output`]}},"\\ce{(...)}":{"*":{action_:[{type_:`output`,option:2},`ce`],nextState:`3`}},"\\,":{"*":{action_:[{type_:`output`,option:1},`copy`],nextState:`1`}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:[`o=`,`output`],nextState:`3`},"*":{action_:[`output`,`o=`,`output`],nextState:`3`}},others:{"*":{action_:[{type_:`output`,option:1},`copy`],nextState:`3`}},else2:{a:{action_:`a to o`,nextState:`o`,revisit:!0},as:{action_:[`output`,`sb=true`],nextState:`1`,revisit:!0},"r|rt|rd|rdt|rdq":{action_:[`output`],nextState:`0`,revisit:!0},"*":{action_:[`output`,`copy`],nextState:`3`}}}),actions:{"o after d":function(e,t){var n;if((e.d||``).match(/^[0-9]+$/)){var r=e.d;e.d=void 0,n=this.output(e),e.b=r}else n=this.output(e);return Q.actions[`o=`](e,t),n},"d= kv":function(e,t){e.d=t,e.dType=`kv`},"charge or bond":function(e,t){if(e.beginsWithBond){var n=[];return Q.concatArray(n,this.output(e)),Q.concatArray(n,Q.actions.bond(e,t,`-`)),n}e.d=t},"- after o/d":function(e,t,n){var r=Q.patterns.match_(`orbital`,e.o||``),i=Q.patterns.match_(`one lowercase greek letter $`,e.o||``),a=Q.patterns.match_(`one lowercase latin letter $`,e.o||``),o=Q.patterns.match_(`$one lowercase latin letter$ $`,e.o||``),s=t===`-`&&(r&&r.remainder===``||i||a||o);s&&!e.a&&!e.b&&!e.p&&!e.d&&!e.q&&!r&&a&&(e.o=`$`+e.o+`$`);var c=[];return s?(Q.concatArray(c,this.output(e)),c.push({type_:`hyphen`})):(r=Q.patterns.match_(`digits`,e.d||``),n&&r&&r.remainder===``?(Q.concatArray(c,Q.actions[`d=`](e,t)),Q.concatArray(c,this.output(e))):(Q.concatArray(c,this.output(e)),Q.concatArray(c,Q.actions.bond(e,t,`-`)))),c},"a to o":function(e){e.o=e.a,e.a=void 0},"sb=true":function(e){e.sb=!0},"sb=false":function(e){e.sb=!1},"beginsWithBond=true":function(e){e.beginsWithBond=!0},"beginsWithBond=false":function(e){e.beginsWithBond=!1},"parenthesisLevel++":function(e){e.parenthesisLevel++},"parenthesisLevel--":function(e){e.parenthesisLevel--},"state of aggregation":function(e,t){return{type_:`state of aggregation`,p1:Q.go(t,`o`)}},comma:function(e,t){var n=t.replace(/\s*$/,``);return n!==t&&e.parenthesisLevel===0?{type_:`comma enumeration L`,p1:n}:{type_:`comma enumeration M`,p1:n}},output:function(e,t,n){var r;if(!e.r)r=[],!e.a&&!e.b&&!e.p&&!e.o&&!e.q&&!e.d&&!n||(e.sb&&r.push({type_:`entitySkip`}),!e.o&&!e.q&&!e.d&&!e.b&&!e.p&&n!==2?(e.o=e.a,e.a=void 0):!e.o&&!e.q&&!e.d&&(e.b||e.p)?(e.o=e.a,e.d=e.b,e.q=e.p,e.a=e.b=e.p=void 0):e.o&&e.dType===`kv`&&Q.patterns.match_(`d-oxidation$`,e.d||``)?e.dType=`oxidation`:e.o&&e.dType===`kv`&&!e.q&&(e.dType=void 0),r.push({type_:`chemfive`,a:Q.go(e.a,`a`),b:Q.go(e.b,`bd`),p:Q.go(e.p,`pq`),o:Q.go(e.o,`o`),q:Q.go(e.q,`pq`),d:Q.go(e.d,e.dType===`oxidation`?`oxidation`:`bd`),dType:e.dType}));else{var i=e.rdt===`M`?Q.go(e.rd,`tex-math`):e.rdt===`T`?[{type_:`text`,p1:e.rd||``}]:Q.go(e.rd),a=e.rqt===`M`?Q.go(e.rq,`tex-math`):e.rqt===`T`?[{type_:`text`,p1:e.rq||``}]:Q.go(e.rq);r={type_:`arrow`,r:e.r,rd:i,rq:a}}for(var o in e)o!==`parenthesisLevel`&&o!==`beginsWithBond`&&delete e[o];return r},"oxidation-output":function(e,t){var n=[`{`];return Q.concatArray(n,Q.go(t,`oxidation`)),n.push(`}`),n},"frac-output":function(e,t){return{type_:`frac-ce`,p1:Q.go(t[0]),p2:Q.go(t[1])}},"overset-output":function(e,t){return{type_:`overset`,p1:Q.go(t[0]),p2:Q.go(t[1])}},"underset-output":function(e,t){return{type_:`underset`,p1:Q.go(t[0]),p2:Q.go(t[1])}},"underbrace-output":function(e,t){return{type_:`underbrace`,p1:Q.go(t[0]),p2:Q.go(t[1])}},"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:Q.go(t[1])}},"r=":function(e,t){e.r=t},"rdt=":function(e,t){e.rdt=t},"rd=":function(e,t){e.rd=t},"rqt=":function(e,t){e.rqt=t},"rq=":function(e,t){e.rq=t},operator:function(e,t,n){return{type_:`operator`,kind_:n||t}}}},a:{transitions:Q.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`1`,revisit:!0}},"$(...)$":{"*":{action_:`tex-math tight`,nextState:`1`}},",":{"*":{action_:{type_:`insert`,option:`commaDecimal`}}},else2:{"*":{action_:`copy`}}}),actions:{}},o:{transitions:Q.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`1`,revisit:!0}},letters:{"*":{action_:`rm`}},"\\ca":{"*":{action_:{type_:`insert`,option:`circa`}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`{text}`}},else2:{"*":{action_:`copy`}}}),actions:{}},text:{transitions:Q.createTransitions({empty:{"*":{action_:`output`}},"{...}":{"*":{action_:`text=`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"\\greek":{"*":{action_:[`output`,`rm`]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:[`output`,`copy`]}},else:{"*":{action_:`text=`}}}),actions:{output:function(e){if(e.text_){var t={type_:`text`,p1:e.text_};for(var n in e)delete e[n];return t}}}},pq:{transitions:Q.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:`state of aggregation`}},i$:{0:{nextState:`!f`,revisit:!0}},"(KV letters),":{0:{action_:`rm`,nextState:`0`}},formula$:{0:{nextState:`f`,revisit:!0}},"1/2$":{0:{action_:`1/2`}},else:{0:{nextState:`!f`,revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`text`}},"a-z":{f:{action_:`tex-math`}},letters:{"*":{action_:`rm`}},"-9.,9":{"*":{action_:`9,9`}},",":{"*":{action_:{type_:`insert+p1`,option:`comma enumeration S`}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:`color-output`}},"\\color{(...)}0":{"*":{action_:`color0-output`}},"\\ce{(...)}":{"*":{action_:`ce`}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},else2:{"*":{action_:`copy`}}}),actions:{"state of aggregation":function(e,t){return{type_:`state of aggregation subscript`,p1:Q.go(t,`o`)}},"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:Q.go(t[1],`pq`)}}}},bd:{transitions:Q.createTransitions({empty:{"*":{}},x$:{0:{nextState:`!f`,revisit:!0}},formula$:{0:{nextState:`f`,revisit:!0}},else:{0:{nextState:`!f`,revisit:!0}},"-9.,9 no missing 0":{"*":{action_:`9,9`}},".":{"*":{action_:{type_:`insert`,option:`electron dot`}}},"a-z":{f:{action_:`tex-math`}},x:{"*":{action_:{type_:`insert`,option:`KV x`}}},letters:{"*":{action_:`rm`}},"'":{"*":{action_:{type_:`insert`,option:`prime`}}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},"{(...)}":{"*":{action_:`text`}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:`color-output`}},"\\color{(...)}0":{"*":{action_:`color0-output`}},"\\ce{(...)}":{"*":{action_:`ce`}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`copy`}},else2:{"*":{action_:`copy`}}}),actions:{"color-output":function(e,t){return{type_:`color`,color1:t[0],color2:Q.go(t[1],`bd`)}}}},oxidation:{transitions:Q.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:`roman-numeral`}},"${(...)}$|$(...)$":{"*":{action_:`tex-math`}},else:{"*":{action_:`copy`}}}),actions:{"roman-numeral":function(e,t){return{type_:`roman numeral`,p1:t||``}}}},"tex-math":{transitions:Q.createTransitions({empty:{"*":{action_:`output`}},"\\ce{(...)}":{"*":{action_:[`output`,`ce`]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`o=`}},else:{"*":{action_:`o=`}}}),actions:{output:function(e){if(e.o){var t={type_:`tex-math`,p1:e.o};for(var n in e)delete e[n];return t}}}},"tex-math tight":{transitions:Q.createTransitions({empty:{"*":{action_:`output`}},"\\ce{(...)}":{"*":{action_:[`output`,`ce`]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:`o=`}},"-|+":{"*":{action_:`tight operator`}},else:{"*":{action_:`o=`}}}),actions:{"tight operator":function(e,t){e.o=(e.o||``)+`{`+t+`}`},output:function(e){if(e.o){var t={type_:`tex-math`,p1:e.o};for(var n in e)delete e[n];return t}}}},"9,9":{transitions:Q.createTransitions({empty:{"*":{}},",":{"*":{action_:`comma`}},else:{"*":{action_:`copy`}}}),actions:{comma:function(){return{type_:`commaDecimal`}}}},pu:{transitions:Q.createTransitions({empty:{"*":{action_:`output`}},space$:{"*":{action_:[`output`,`space`]}},"{[(|)]}":{"0|a":{action_:`copy`}},"(-)(9)^(-9)":{0:{action_:`number^`,nextState:`a`}},"(-)(9.,9)(e)(99)":{0:{action_:`enumber`,nextState:`a`}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:`operator`,option:`\\pm`},nextState:`0`}},operator:{"0|a":{action_:`copy`,nextState:`0`}},"//":{d:{action_:`o=`,nextState:`/`}},"/":{d:{action_:`o=`,nextState:`/`}},"{...}|else":{"0|d":{action_:`d=`,nextState:`d`},a:{action_:[`space`,`d=`],nextState:`d`},"/|q":{action_:`q=`,nextState:`q`}}}),actions:{enumber:function(e,t){var n=[];return t[0]===`+-`||t[0]===`+/-`?n.push(`\\pm `):t[0]&&n.push(t[0]),t[1]&&(Q.concatArray(n,Q.go(t[1],`pu-9,9`)),t[2]&&(t[2].match(/[,.]/)?Q.concatArray(n,Q.go(t[2],`pu-9,9`)):n.push(t[2])),t[3]=t[4]||t[3],t[3]&&(t[3]=t[3].trim(),t[3]===`e`||t[3].substr(0,1)===`*`?n.push({type_:`cdot`}):n.push({type_:`times`}))),t[3]&&n.push(`10^{`+t[5]+`}`),n},"number^":function(e,t){var n=[];return t[0]===`+-`||t[0]===`+/-`?n.push(`\\pm `):t[0]&&n.push(t[0]),Q.concatArray(n,Q.go(t[1],`pu-9,9`)),n.push(`^{`+t[2]+`}`),n},operator:function(e,t,n){return{type_:`operator`,kind_:n||t}},space:function(){return{type_:`pu-space-1`}},output:function(e){var t,n=Q.patterns.match_(`{(...)}`,e.d||``);n&&n.remainder===``&&(e.d=n.match_);var r=Q.patterns.match_(`{(...)}`,e.q||``);if(r&&r.remainder===``&&(e.q=r.match_),e.d&&=(e.d=e.d.replace(/\u00B0C|\^oC|\^{o}C/g,`{}^{\\circ}C`),e.d.replace(/\u00B0F|\^oF|\^{o}F/g,`{}^{\\circ}F`)),e.q){e.q=e.q.replace(/\u00B0C|\^oC|\^{o}C/g,`{}^{\\circ}C`),e.q=e.q.replace(/\u00B0F|\^oF|\^{o}F/g,`{}^{\\circ}F`);var i={d:Q.go(e.d,`pu`),q:Q.go(e.q,`pu`)};e.o===`//`?t={type_:`pu-frac`,p1:i.d,p2:i.q}:(t=i.d,i.d.length>1||i.q.length>1?t.push({type_:` / `}):t.push({type_:`/`}),Q.concatArray(t,i.q))}else t=Q.go(e.d,`pu-2`);for(var a in e)delete e[a];return t}}},"pu-2":{transitions:Q.createTransitions({empty:{"*":{action_:`output`}},"*":{"*":{action_:[`output`,`cdot`],nextState:`0`}},"\\x":{"*":{action_:`rm=`}},space:{"*":{action_:[`output`,`space`],nextState:`0`}},"^{(...)}|^(-1)":{1:{action_:`^(-1)`}},"-9.,9":{0:{action_:`rm=`,nextState:`0`},1:{action_:`^(-1)`,nextState:`0`}},"{...}|else":{"*":{action_:`rm=`,nextState:`1`}}}),actions:{cdot:function(){return{type_:`tight cdot`}},"^(-1)":function(e,t){e.rm+=`^{`+t+`}`},space:function(){return{type_:`pu-space-2`}},output:function(e){var t=[];if(e.rm){var n=Q.patterns.match_(`{(...)}`,e.rm||``);t=n&&n.remainder===``?Q.go(n.match_,`pu`):{type_:`rm`,p1:e.rm}}for(var r in e)delete e[r];return t}}},"pu-9,9":{transitions:Q.createTransitions({empty:{0:{action_:`output-0`},o:{action_:`output-o`}},",":{0:{action_:[`output-0`,`comma`],nextState:`o`}},".":{0:{action_:[`output-0`,`copy`],nextState:`o`}},else:{"*":{action_:`text=`}}}),actions:{comma:function(){return{type_:`commaDecimal`}},"output-0":function(e){var t=[];if(e.text_=e.text_||``,e.text_.length>4){var n=e.text_.length%3;n===0&&(n=3);for(var r=e.text_.length-3;r>0;r-=3)t.push(e.text_.substr(r,3)),t.push({type_:`1000 separator`});t.push(e.text_.substr(0,n)),t.reverse()}else t.push(e.text_);for(var i in e)delete e[i];return t},"output-o":function(e){var t=[];if(e.text_=e.text_||``,e.text_.length>4){for(var n=e.text_.length-3,r=0;r`:return`\\yields`;case`→`:return`\\yields`;case`⟶`:return`\\yields`;case`<-`:return`\\yieldsLeft`;case`<->`:return`\\mesomerism`;case`<-->`:return`\\yieldsLeftRight`;case`<=>`:return`\\chemequilibrium`;case`⇌`:return`\\chemequilibrium`;case`<=>>`:return`\\equilibriumRight`;case`<<=>`:return`\\equilibriumLeft`;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}},_getBond:function(e){switch(e){case`-`:return`{-}`;case`1`:return`{-}`;case`=`:return`{=}`;case`2`:return`{=}`;case`#`:return`{\\equiv}`;case`3`:return`{\\equiv}`;case`~`:return`{\\tripleDash}`;case`~-`:return`{\\tripleDashOverLine}`;case`~=`:return`{\\tripleDashOverDoubleLine}`;case`~--`:return`{\\tripleDashOverDoubleLine}`;case`-~-`:return`{\\tripleDashBetweenDoubleLine}`;case`...`:return`{{\\cdot}{\\cdot}{\\cdot}}`;case`....`:return`{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}`;case`->`:return`{\\rightarrow}`;case`<-`:return`{\\leftarrow}`;case`<`:return`{<}`;case`>`:return`{>}`;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}},_getOperator:function(e){switch(e){case`+`:return` {}+{} `;case`-`:return` {}-{} `;case`=`:return` {}={} `;case`<`:return` {}<{} `;case`>`:return` {}>{} `;case`<<`:return` {}\\ll{} `;case`>>`:return` {}\\gg{} `;case`\\pm`:return` {}\\pm{} `;case`\\approx`:return` {}\\approx{} `;case`$\\approx$`:return` {}\\approx{} `;case`v`:return` \\downarrow{} `;case`(v)`:return` \\downarrow{} `;case`^`:return` \\uparrow{} `;case`(^)`:return` \\uparrow{} `;default:throw[`MhchemBugT`,`mhchem bug T. Please report.`]}}};Z(`\\darr`,`\\downarrow`),Z(`\\dArr`,`\\Downarrow`),Z(`\\Darr`,`\\Downarrow`),Z(`\\lang`,`\\langle`),Z(`\\rang`,`\\rangle`),Z(`\\uarr`,`\\uparrow`),Z(`\\uArr`,`\\Uparrow`),Z(`\\Uarr`,`\\Uparrow`),Z(`\\N`,`\\mathbb{N}`),Z(`\\R`,`\\mathbb{R}`),Z(`\\Z`,`\\mathbb{Z}`),Z(`\\alef`,`\\aleph`),Z(`\\alefsym`,`\\aleph`),Z(`\\bull`,`\\bullet`),Z(`\\clubs`,`\\clubsuit`),Z(`\\cnums`,`\\mathbb{C}`),Z(`\\Complex`,`\\mathbb{C}`),Z(`\\Dagger`,`\\ddagger`),Z(`\\diamonds`,`\\diamondsuit`),Z(`\\empty`,`\\emptyset`),Z(`\\exist`,`\\exists`),Z(`\\harr`,`\\leftrightarrow`),Z(`\\hArr`,`\\Leftrightarrow`),Z(`\\Harr`,`\\Leftrightarrow`),Z(`\\hearts`,`\\heartsuit`),Z(`\\image`,`\\Im`),Z(`\\infin`,`\\infty`),Z(`\\isin`,`\\in`),Z(`\\larr`,`\\leftarrow`),Z(`\\lArr`,`\\Leftarrow`),Z(`\\Larr`,`\\Leftarrow`),Z(`\\lrarr`,`\\leftrightarrow`),Z(`\\lrArr`,`\\Leftrightarrow`),Z(`\\Lrarr`,`\\Leftrightarrow`),Z(`\\natnums`,`\\mathbb{N}`),Z(`\\plusmn`,`\\pm`),Z(`\\rarr`,`\\rightarrow`),Z(`\\rArr`,`\\Rightarrow`),Z(`\\Rarr`,`\\Rightarrow`),Z(`\\real`,`\\Re`),Z(`\\reals`,`\\mathbb{R}`),Z(`\\Reals`,`\\mathbb{R}`),Z(`\\sdot`,`\\cdot`),Z(`\\sect`,`\\S`),Z(`\\spades`,`\\spadesuit`),Z(`\\sub`,`\\subset`),Z(`\\sube`,`\\subseteq`),Z(`\\supe`,`\\supseteq`),Z(`\\thetasym`,`\\vartheta`),Z(`\\weierp`,`\\wp`),Z(`\\quantity`,`{\\left\\{ #1 \\right\\}}`),Z(`\\qty`,`{\\left\\{ #1 \\right\\}}`),Z(`\\pqty`,`{\\left( #1 \\right)}`),Z(`\\bqty`,`{\\left[ #1 \\right]}`),Z(`\\vqty`,`{\\left\\vert #1 \\right\\vert}`),Z(`\\Bqty`,`{\\left\\{ #1 \\right\\}}`),Z(`\\absolutevalue`,`{\\left\\vert #1 \\right\\vert}`),Z(`\\abs`,`{\\left\\vert #1 \\right\\vert}`),Z(`\\norm`,`{\\left\\Vert #1 \\right\\Vert}`),Z(`\\evaluated`,`{\\left.#1 \\right\\vert}`),Z(`\\eval`,`{\\left.#1 \\right\\vert}`),Z(`\\order`,`{\\mathcal{O} \\left( #1 \\right)}`),Z(`\\commutator`,`{\\left[ #1 , #2 \\right]}`),Z(`\\comm`,`{\\left[ #1 , #2 \\right]}`),Z(`\\anticommutator`,`{\\left\\{ #1 , #2 \\right\\}}`),Z(`\\acomm`,`{\\left\\{ #1 , #2 \\right\\}}`),Z(`\\poissonbracket`,`{\\left\\{ #1 , #2 \\right\\}}`),Z(`\\pb`,`{\\left\\{ #1 , #2 \\right\\}}`),Z(`\\vectorbold`,`{\\boldsymbol{ #1 }}`),Z(`\\vb`,`{\\boldsymbol{ #1 }}`),Z(`\\vectorarrow`,`{\\vec{\\boldsymbol{ #1 }}}`),Z(`\\va`,`{\\vec{\\boldsymbol{ #1 }}}`),Z(`\\vectorunit`,`{{\\boldsymbol{\\hat{ #1 }}}}`),Z(`\\vu`,`{{\\boldsymbol{\\hat{ #1 }}}}`),Z(`\\dotproduct`,`\\mathbin{\\boldsymbol\\cdot}`),Z(`\\vdot`,`{\\boldsymbol\\cdot}`),Z(`\\crossproduct`,`\\mathbin{\\boldsymbol\\times}`),Z(`\\cross`,`\\mathbin{\\boldsymbol\\times}`),Z(`\\cp`,`\\mathbin{\\boldsymbol\\times}`),Z(`\\gradient`,`{\\boldsymbol\\nabla}`),Z(`\\grad`,`{\\boldsymbol\\nabla}`),Z(`\\divergence`,`{\\grad\\vdot}`),Z(`\\curl`,`{\\grad\\cross}`),Z(`\\laplacian`,`\\nabla^2`),Z(`\\tr`,`{\\operatorname{tr}}`),Z(`\\Tr`,`{\\operatorname{Tr}}`),Z(`\\rank`,`{\\operatorname{rank}}`),Z(`\\erf`,`{\\operatorname{erf}}`),Z(`\\Res`,`{\\operatorname{Res}}`),Z(`\\principalvalue`,`{\\mathcal{P}}`),Z(`\\pv`,`{\\mathcal{P}}`),Z(`\\PV`,`{\\operatorname{P.V.}}`),Z(`\\qqtext`,`{\\quad\\text{ #1 }\\quad}`),Z(`\\qq`,`{\\quad\\text{ #1 }\\quad}`),Z(`\\qcomma`,`{\\text{,}\\quad}`),Z(`\\qc`,`{\\text{,}\\quad}`),Z(`\\qcc`,`{\\quad\\text{c.c.}\\quad}`),Z(`\\qif`,`{\\quad\\text{if}\\quad}`),Z(`\\qthen`,`{\\quad\\text{then}\\quad}`),Z(`\\qelse`,`{\\quad\\text{else}\\quad}`),Z(`\\qotherwise`,`{\\quad\\text{otherwise}\\quad}`),Z(`\\qunless`,`{\\quad\\text{unless}\\quad}`),Z(`\\qgiven`,`{\\quad\\text{given}\\quad}`),Z(`\\qusing`,`{\\quad\\text{using}\\quad}`),Z(`\\qassume`,`{\\quad\\text{assume}\\quad}`),Z(`\\qsince`,`{\\quad\\text{since}\\quad}`),Z(`\\qlet`,`{\\quad\\text{let}\\quad}`),Z(`\\qfor`,`{\\quad\\text{for}\\quad}`),Z(`\\qall`,`{\\quad\\text{all}\\quad}`),Z(`\\qeven`,`{\\quad\\text{even}\\quad}`),Z(`\\qodd`,`{\\quad\\text{odd}\\quad}`),Z(`\\qinteger`,`{\\quad\\text{integer}\\quad}`),Z(`\\qand`,`{\\quad\\text{and}\\quad}`),Z(`\\qor`,`{\\quad\\text{or}\\quad}`),Z(`\\qas`,`{\\quad\\text{as}\\quad}`),Z(`\\qin`,`{\\quad\\text{in}\\quad}`),Z(`\\differential`,`{\\text{d}}`),Z(`\\dd`,`{\\text{d}}`),Z(`\\derivative`,`{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}`),Z(`\\dv`,`{\\frac{\\text{d}{ #1 }}{\\text{d}{ #2 }}}`),Z(`\\partialderivative`,`{\\frac{\\partial{ #1 }}{\\partial{ #2 }}}`),Z(`\\variation`,`{\\delta}`),Z(`\\var`,`{\\delta}`),Z(`\\functionalderivative`,`{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}`),Z(`\\fdv`,`{\\frac{\\delta{ #1 }}{\\delta{ #2 }}}`),Z(`\\innerproduct`,`{\\left\\langle {#1} \\mid { #2} \\right\\rangle}`),Z(`\\outerproduct`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Z(`\\dyad`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Z(`\\ketbra`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Z(`\\op`,`{\\left\\vert { #1 } \\right\\rangle\\left\\langle { #2} \\right\\vert}`),Z(`\\expectationvalue`,`{\\left\\langle {#1 } \\right\\rangle}`),Z(`\\expval`,`{\\left\\langle {#1 } \\right\\rangle}`),Z(`\\ev`,`{\\left\\langle {#1 } \\right\\rangle}`),Z(`\\matrixelement`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`),Z(`\\matrixel`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`),Z(`\\mel`,`{\\left\\langle{ #1 }\\right\\vert{ #2 }\\left\\vert{#3}\\right\\rangle}`);function Vo(e){let t=[];e.consumeSpaces();let n=e.fetch().text;for(n===`\\relax`&&(e.consume(),e.consumeSpaces(),n=e.fetch().text);n===`\\hline`||n===`\\hdashline`;)e.consume(),t.push(n===`\\hdashline`),e.consumeSpaces(),n=e.fetch().text;return t}var Ho=e=>{if(!e.parser.settings.displayMode)throw new A(`{${e.envName}} can be used only in display mode.`)},Uo=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,Wo=e=>{let t=e.get(`\\arraystretch`);typeof t!=`string`&&(t=Mo(t.tokens)),t=isNaN(t)?null:Number(t);let n=e.get(`\\arraycolsep`);typeof n!=`string`&&(n=Mo(n.tokens));let r=Uo.exec(n),i=r?{number:+(r[1]+r[2]),unit:r[3]}:null;return[t,i]},Go=e=>{let t=``;for(let n=0;n1||!a)&&p.pop(),h.push(Go(t.body)),g.length{let t=new N(`mtd`,[]);return t.style={padding:`0`,width:`50%`},e.envClasses.includes(`multline`)&&(t.style.width=`7.5%`),t},Zo=function(e,t){let n=[],r=e.body.length,i=e.hLinesBeforeRow,a=e.tags&&e.tags.some(e=>e);for(let o=0;o0&&(i[0].length===2?d.children.forEach(e=>{e.style.borderTop=`0.15em double`}):d.children.forEach(e=>{e.style.borderTop=i[0][0]?`0.06em dashed`:`0.06em solid`})),i[o+1].length>0&&(i[o+1].length===2?d.children.forEach(e=>{e.style.borderBottom=`0.15em double`}):d.children.forEach(e=>{e.style.borderBottom=i[o+1][0]?`0.06em dashed`:`0.06em solid`}));let p=!0;for(let e=0;e0&&(o=e.envClasses.includes(`abut`)||e.envClasses.includes(`cases`)?`0`:e.envClasses.includes(`small`)?`0.1389`:e.envClasses.includes(`cd`)?`0.25`:`0.4`,s=`em`),e.arraycolsep){let n=lo(e.arraycolsep,t);o=n.number.toFixed(4),s=n.unit}if(o){let t=n.length===0?0:n[0].children.length,r=(n,r)=>n===0&&r===0||n===t-1&&r===1?`0`:e.envClasses[0]===`align`?r===1?`0`:a?n%2?`1`:`0`:n%2?`0`:`1`:o;for(let e=0;e0){let t=e.envClasses.includes(`align`)||e.envClasses.includes(`alignat`);for(let r=0;r1&&e.envClasses.includes(`cases`)&&(i.children[1].style.paddingLeft=`1em`),e.envClasses.includes(`cases`)||e.envClasses.includes(`subarray`))for(let e of i.children)e.classes.push(`tml-left`)}}let c=new N(`mtable`,n);if(e.envClasses.length>0&&(e.envClasses.includes(`jot`)?c.classes.push(`tml-jot`):e.envClasses.includes(`small`)&&c.classes.push(`tml-small`)),e.scriptLevel===`display`&&c.setAttribute(`displaystyle`,`true`),(e.autoTag||e.envClasses.includes(`multline`))&&(c.style.width=`100%`),e.cols&&e.cols.length>0){let t=e.cols,n=!1,r=0,i=t.length;for(;t[r].type===`separator`;)r+=1;for(;t[i-1].type===`separator`;)--i;if(t[0].type===`separator`){let e=t[1].type===`separator`?`0.15em double`:t[0].separator===`|`?`0.06em solid `:`0.06em dashed `;for(let t of c.children)t.children[0].style.borderLeft=e}let o=a?0:-1;for(let e=r;e-1;if(t[0]&&s){let e=``;for(let n=0;n0?Array(i.body[0].length).fill({type:`align`,align:n}):[];let[a,o]=Wo(e.parser.gullet.macros);return i.arraystretch=a,o&&(o!==6||o!==`pt`)&&(i.arraycolsep=o),t?{type:`leftright`,mode:e.mode,body:[i],left:t[0],right:t[1],rightColor:void 0}:i},mathmlBuilder:Zo}),go({type:`array`,names:[`bordermatrix`],props:{numArgs:0},handler(e){let t=qo(e.parser,{cols:[],envClasses:[`bordermatrix`]},`text`);return t.cols=t.body.length>0?Array(t.body[0].length).fill({type:`align`,align:`c`}):[],t.envClasses=[],t.arraystretch=1,e.envName===`matrix`?t:Do(t,e.delimiters)},mathmlBuilder:Zo}),go({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){return qo(e.parser,{envClasses:[`small`]},`script`)},mathmlBuilder:Zo}),go({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){let n=(vo(t[0])?[t[0]]:Y(t[0],`ordgroup`).body).map(function(e){let t=_o(e).text;if(`lc`.indexOf(t)!==-1)return{type:`align`,align:t};throw new A(`Unknown column alignment: `+t,e)});if(n.length>1)throw new A(`{subarray} can contain only one column`);let r={cols:n,envClasses:[`small`]};if(r=qo(e.parser,r,`script`),r.body.length>0&&r.body[0].length>1)throw new A(`{subarray} can contain only one column`);return r},mathmlBuilder:Zo}),go({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){let t=qo(e.parser,{cols:[],envClasses:[`cases`]},Jo(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.indexOf(`r`)>-1?`.`:`\\{`,right:e.envName.indexOf(`r`)>-1?`\\}`:`.`,rightColor:void 0}},mathmlBuilder:Zo}),go({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:Qo,mathmlBuilder:Zo}),go({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:Qo,mathmlBuilder:Zo}),go({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){e.envName!==`gathered`&&Ho(e);let t={cols:[],envClasses:[`abut`,`jot`],autoTag:Ko(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return qo(e.parser,t,`display`)},mathmlBuilder:Zo}),go({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){Ho(e);let t={autoTag:Ko(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,envClasses:[`align`],leqno:e.parser.settings.leqno};return qo(e.parser,t,`display`)},mathmlBuilder:Zo}),go({type:`array`,names:[`multline`,`multline*`],props:{numArgs:0},handler(e){Ho(e);let t={autoTag:e.envName===`multline`,maxNumCols:1,envClasses:[`jot`,`multline`],leqno:e.parser.settings.leqno};return qo(e.parser,t,`display`)},mathmlBuilder:Zo}),go({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return Ho(e),wo(e.parser)},mathmlBuilder:Zo}),j({type:`text`,names:[`\\hline`,`\\hdashline`],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(e,t){throw new A(`${e.funcName} valid only within array environment`)}});var $o=ho;j({type:`bordermatrix`,names:[`\\bordermatrix`,`\\matrix`],props:{numArgs:0,numOptionalArgs:1},handler:({parser:e,funcName:t},n,r)=>{let i=[`(`,`)`];if(t===`\\bordermatrix`&&r[0]&&r[0].body){let e=r[0].body;e.length===1&&e[0].type===`delimiter`&&(i=[e[0].left,e[0].right])}e.consumeSpaces(),e.consume();let a=$o.bordermatrix,o={mode:e.mode,envName:t.slice(1),delimiters:i,parser:e},s=a.handler(o);return e.expect(`}`,!0),s}}),j({type:`cancelto`,names:[`\\cancelto`],props:{numArgs:2},handler({parser:e},t){let n=t[0],r=t[1];return{type:`cancelto`,mode:e.mode,body:r,to:n,isCharacterBox:Qi(r)}},mathmlBuilder(e,t){let n=new N(`mrow`,[q(e.body,t)],[`ff-narrow`]),r=new N(`mphantom`,[q(e.body,t)]),i=new N(`mrow`,[r],[`tml-cancelto`]);i.style.color=t.color,e.isCharacterBox&&na.indexOf(e.body.body[0].text)>-1&&(i.style.left=`0.1em`,i.style.width=`90%`);let a=new N(`mrow`,[n,i],[`menclose`]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text))r.style.paddingRight=`0.2em`;else{r.style.padding=`0.5ex 0.1em 0 0`;let e=new N(`mspace`,[]);e.setAttribute(`height`,`0.85em`),n.children.push(e)}let o;if(e.isCharacterBox)o=new N(`mspace`,[]),o.setAttribute(`height`,`1em`);else{let n=new N(`mpadded`,[q(e.body,t)]);n.setAttribute(`width`,`0.1px`),o=new N(`mphantom`,[n])}let s=q(e.to,t);s.style.color=t.color;let c=new N(`mpadded`,[s]);if(!e.isCharacterBox||/[f∫∑]/.test(e.body.body[0].text)){let e=new N(`mspace`,[]);e.setAttribute(`width`,`0.2em`),c.children.unshift(e)}c.setAttribute(`width`,`0.1px`);let l=new N(`mover`,[o,c]),u=new N(`mrow`,[],[`ff-nudge-left`]);return ya([Va([a,l]),u])}}),j({type:`textord`,names:[`\\@char`],props:{numArgs:1,allowedInText:!0},handler({parser:e,token:t},n){let r=Y(n[0],`ordgroup`).body,i=``;for(let e=0;e{let t=e.toString(16);return t.length===1&&(t=`0`+t),t},os=JSON.parse(`{ "Apricot": "#ffb484", "Aquamarine": "#08b4bc", "Bittersweet": "#c84c14", "blue": "#0000FF", "Blue": "#303494", "BlueGreen": "#08b4bc", "BlueViolet": "#503c94", "BrickRed": "#b8341c", "brown": "#BF8040", "Brown": "#802404", "BurntOrange": "#f8941c", "CadetBlue": "#78749c", "CarnationPink": "#f884b4", "Cerulean": "#08a4e4", "CornflowerBlue": "#40ace4", "cyan": "#00FFFF", "Cyan": "#08acec", "Dandelion": "#ffbc44", "darkgray": "#404040", "DarkOrchid": "#a8548c", "Emerald": "#08ac9c", "ForestGreen": "#089c54", "Fuchsia": "#90348c", "Goldenrod": "#ffdc44", "gray": "#808080", "Gray": "#98949c", "green": "#00FF00", "Green": "#08a44c", "GreenYellow": "#e0e474", "JungleGreen": "#08ac9c", "Lavender": "#f89cc4", "lightgray": "#c0c0c0", "lime": "#BFFF00", "LimeGreen": "#90c43c", "magenta": "#FF00FF", "Magenta": "#f0048c", "Mahogany": "#b0341c", "Maroon": "#b03434", "Melon": "#f89c7c", "MidnightBlue": "#086494", "Mulberry": "#b03c94", "NavyBlue": "#086cbc", "olive": "#7F7F00", "OliveGreen": "#407c34", "orange": "#FF8000", "Orange": "#f8843c", "OrangeRed": "#f0145c", "Orchid": "#b074ac", "Peach": "#f8945c", "Periwinkle": "#8074bc", "PineGreen": "#088c74", "pink": "#ff7f7f", "Plum": "#98248c", "ProcessBlue": "#08b4ec", "purple": "#BF0040", "Purple": "#a0449c", "RawSienna": "#983c04", "red": "#ff0000", "Red": "#f01c24", "RedOrange": "#f86434", "RedViolet": "#a0246c", "Rhodamine": "#f0549c", "Royallue": "#0874bc", "RoyalPurple": "#683c9c", "RubineRed": "#f0047c", "Salmon": "#f8948c", "SeaGreen": "#30bc9c", "Sepia": "#701404", "SkyBlue": "#48c4dc", "SpringGreen": "#c8dc64", "Tan": "#e09c74", "teal": "#007F7F", "TealBlue": "#08acb4", "Thistle": "#d884b4", "Turquoise": "#08b4cc", "violet": "#800080", "Violet": "#60449c", "VioletRed": "#f054a4", "WildStrawberry": "#f0246c", "yellow": "#FFFF00", "Yellow": "#fff404", "YellowGreen": "#98cc6c", "YellowOrange": "#ffa41c" }`),ss=(e,t)=>{let n=``;if(e===`HTML`){if(!es.test(t))throw new A(`Invalid HTML input.`);n=t}else if(e===`RGB`){if(!ns.test(t))throw new A(`Invalid RGB input.`);t.split(`,`).map(e=>{n+=as(Number(e.trim()))})}else{if(!rs.test(t))throw new A(`Invalid rbg input.`);t.split(`,`).map(e=>{let t=Number(e.trim());if(t>1)throw new A(`Color rgb input must be < 1.`);n+=as(Number((t*255).toFixed(0)))})}return n.charAt(0)!==`#`&&(n=`#`+n),n},cs=(e,t,n)=>{let r=`\\\\color@${e}`;if(!ts.exec(e))throw new A(`Invalid color: '`+e+`'`,n);return is.test(e)?`#`+e:(e.charAt(0)===`#`||(t.has(r)?e=t.get(r).tokens[0].text:os[e]&&(e=os[e])),e)},ls=(e,t)=>{let n=Ga(e.body,t.withColor(e.color));return n.length===0&&n.push(new N(`mrow`)),n=n.map(t=>(t.style.color=e.color,t)),ya(n)};j({type:`color`,names:[`\\textcolor`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`original`]},handler({parser:e,token:t},n,r){let i=r[0]&&Y(r[0],`raw`).string,a=``;if(i){let e=Y(n[0],`raw`).string;a=ss(i,e)}else a=cs(Y(n[0],`raw`).string,e.gullet.macros,t);let o=n[1];return{type:`color`,mode:e.mode,color:a,isTextColor:!0,body:M(o)}},mathmlBuilder:ls}),j({type:`color`,names:[`\\color`],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`]},handler({parser:e,breakOnTokenText:t,token:n},r,i){let a=i[0]&&Y(i[0],`raw`).string,o=``;if(a){let e=Y(r[0],`raw`).string;o=ss(a,e)}else o=cs(Y(r[0],`raw`).string,e.gullet.macros,n);let s=e.parseExpression(!0,t,!0);return{type:`color`,mode:e.mode,color:o,isTextColor:!1,body:s}},mathmlBuilder:ls}),j({type:`color`,names:[`\\definecolor`],props:{numArgs:3,allowedInText:!0,argTypes:[`raw`,`raw`,`raw`]},handler({parser:e,funcName:t,token:n},r){let i=Y(r[0],`raw`).string;if(!/^[A-Za-z]+$/.test(i))throw new A(`Color name must be latin letters.`,n);let a=Y(r[1],`raw`).string;if(![`HTML`,`RGB`,`rgb`].includes(a))throw new A(`Color model must be HTML, RGB, or rgb.`,n);let o=Y(r[2],`raw`).string,s=ss(a,o);return e.gullet.macros.set(`\\\\color@${i}`,{tokens:[{text:s}],numArgs:0}),{type:`internal`,mode:e.mode}}}),j({type:`cr`,names:[`\\\\`],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler({parser:e},t,n){let r=e.gullet.future().text===`[`?e.parseSizeGroup(!0):null,i=!e.settings.displayMode;return{type:`cr`,mode:e.mode,newLine:i,size:r&&Y(r,`size`).value}},mathmlBuilder(e,t){let n=new N(`mo`);if(e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size)){let r=lo(e.size,t);n.setAttribute(`height`,r.number+r.unit)}return n}});var us={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},ds=e=>{let t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new A(`Expected a control sequence`,e);return t},fs=e=>{let t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},ps=(e,t,n,r)=>{let i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};j({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],props:{numArgs:0,allowedInText:!0},handler({parser:e,funcName:t}){e.consumeSpaces();let n=e.fetch();if(us[n.text])return(t===`\\global`||t===`\\\\globallong`)&&(n.text=us[n.text]),Y(e.parseFunction(),`internal`);throw new A(`Invalid token after macro prefix`,n)}}),j({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=e.gullet.popToken(),r=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(r))throw new A(`Expected a control sequence`,n);let i=0,a,o=[[]];for(;e.gullet.future().text!==`{`;)if(n=e.gullet.popToken(),n.text===`#`){if(e.gullet.future().text===`{`){a=e.gullet.future(),o[i].push(`{`);break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new A(`Invalid argument number "${n.text}"`);if(parseInt(n.text)!==i+1)throw new A(`Argument number "${n.text}" out of order`);i++,o.push([])}else if(n.text===`EOF`)throw new A(`Expected a macro definition`);else o[i].push(n.text);let{tokens:s}=e.gullet.consumeArg();if(a&&s.unshift(a),t===`\\edef`||t===`\\xdef`){if(s=e.gullet.expandTokens(s),s.length>e.gullet.settings.maxExpand)throw new A(`Too many expansions in an `+t);s.reverse()}return e.gullet.macros.set(r,{tokens:s,numArgs:i,delimiters:o},t===us[t]),{type:`internal`,mode:e.mode}}}),j({type:`internal`,names:[`\\let`,`\\\\globallet`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=ds(e.gullet.popToken());return e.gullet.consumeSpaces(),ps(e,n,fs(e),t===`\\\\globallet`),{type:`internal`,mode:e.mode}}}),j({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=ds(e.gullet.popToken()),r=e.gullet.popToken(),i=e.gullet.popToken();return ps(e,n,i,t===`\\\\globalfuture`),e.gullet.pushToken(i),e.gullet.pushToken(r),{type:`internal`,mode:e.mode}}}),j({type:`internal`,names:[`\\newcommand`,`\\renewcommand`,`\\providecommand`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({parser:e,funcName:t}){let n=``,r=e.gullet.popToken();r.text===`{`?(n=ds(e.gullet.popToken()),e.gullet.popToken()):n=ds(r);let i=e.gullet.isDefined(n);if(i&&t===`\\newcommand`)throw new A(`\\newcommand{${n}} attempting to redefine ${n}; use \\renewcommand`);if(!i&&t===`\\renewcommand`)throw new A(`\\renewcommand{${n}} when command ${n} does not yet exist; use \\newcommand`);let a=0;if(e.gullet.future().text===`[`){let t=e.gullet.popToken();if(t=e.gullet.popToken(),!/^[0-9]$/.test(t.text))throw new A(`Invalid number of arguments: "${t.text}"`);if(a=parseInt(t.text),t=e.gullet.popToken(),t.text!==`]`)throw new A(`Invalid argument "${t.text}"`)}let{tokens:o}=e.gullet.consumeArg();return t===`\\providecommand`&&e.gullet.macros.has(n)||e.gullet.macros.set(n,{tokens:o,numArgs:a}),{type:`internal`,mode:e.mode}}});var ms={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},hs={"(":`)`,"\\lparen":`\\rparen`,"[":`]`,"\\lbrack":`\\rbrack`,"\\{":`\\}`,"\\lbrace":`\\rbrace`,"⦇":`⦈`,"\\llparenthesis":`\\rrparenthesis`,"\\lfloor":`\\rfloor`,"⌊":`⌋`,"\\lceil":`\\rceil`,"⌈":`⌉`,"\\langle":`\\rangle`,"⟨":`⟩`,"\\lAngle":`\\rAngle`,"⟪":`⟫`,"\\llangle":`\\rrangle`,"⦉":`⦊`,"\\lvert":`\\rvert`,"\\lVert":`\\rVert`,"\\lgroup":`\\rgroup`,"⟮":`⟯`,"\\lmoustache":`\\rmoustache`,"⎰":`⎱`,"\\llbracket":`\\rrbracket`,"⟦":`⟧`,"\\lBrace":`\\rBrace`,"⦃":`⦄`},gs=new Set(Object.keys(hs));new Set(Object.values(hs));var _s=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,⦇,\\llparenthesis,⦈,\\rrparenthesis,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lAngle,⟪,\\rAngle,⟫,\\llangle,⦉,\\rrangle,⦊,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,\\llbracket,\\rrbracket,⟦,⟧,\\lBrace,\\rBrace,⦃,⦄,/,\\backslash,|,\\vert,\\|,\\Vert,‖,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`)),vs=new Set([`}`,`\\left`,`\\middle`,`\\right`]),ys=e=>e.length>0&&(_s.has(e)||ms[e]||vs.has(e)),bs=[0,1.2,1.8,2.4,3];function xs(e,t){e.type===`ordgroup`&&e.body.length===1&&(e=e.body[0]);let n=vo(e);if(n&&_s.has(n.text))return(n.text===`<`||n.text===`\\lt`)&&(n.text=`⟨`),(n.text===`>`||n.text===`\\gt`)&&(n.text=`⟩`),n;throw n?new A(`Invalid delimiter '${n.text}' after '${t.funcName}'`,e):new A(`Invalid delimiter type '${e.type}'`,e)}var Ss=new Set([`/`,`\\`,`\\backslash`,`∖`,`\\vert`,`|`]),Cs=(e,t,n,r)=>{let i=new N(`mo`,[Ra(e===`.`?``:e,t)]);return i.setAttribute(`fence`,`true`),i.setAttribute(`form`,n),i.setAttribute(`stretchy`,r?`true`:`false`),i};j({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=xs(t[0],e),r={type:`delimsizing`,mode:e.parser.mode,size:ms[e.funcName].size,mclass:ms[e.funcName].mclass,delim:n.text},i=e.parser.fetch().text;return i!==`^`&&i!==`_`?r:{type:`ordgroup`,mode:`math`,body:[r,{type:`ordgroup`,mode:`math`,body:[]}]}},mathmlBuilder:e=>{let t=[],n=e.delim===`.`?``:e.delim;t.push(Ra(n,e.mode));let r=new N(`mo`,t);return e.mclass===`mopen`||e.mclass===`mclose`?r.setAttribute(`fence`,`true`):r.setAttribute(`fence`,`false`),(Ss.has(n)||n.indexOf(`arrow`)>-1)&&r.setAttribute(`stretchy`,`true`),r.setAttribute(`symmetric`,`true`),r.setAttribute(`minsize`,bs[e.size]+`em`),r.setAttribute(`maxsize`,bs[e.size]+`em`),r}});function ws(e){if(!e.body)throw Error(`Bug: The delim ParseNode wasn't fully parsed.`)}j({type:`leftright-right`,names:[`\\right`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>({type:`leftright-right`,mode:e.parser.mode,delim:xs(t[0],e).text})}),j({type:`leftright`,names:[`\\left`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=xs(t[0],e),r=e.parser;++r.leftrightDepth;let i=r.parseExpression(!1,`\\right`,!0),a=r.fetch();for(;a.text===`\\middle`;){r.consume();let e=r.fetch().text;if(!P.math[e])throw new A(`Invalid delimiter '${e}' after '\\middle'`);xs({type:`atom`,mode:`math`,text:e},{funcName:`\\middle`}),i.push({type:`middle`,mode:`math`,delim:e}),r.consume(),i=i.concat(r.parseExpression(!1,`\\right`,!0)),a=r.fetch()}--r.leftrightDepth,r.expect(`\\right`,!1);let o=Y(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:o.delim,isStretchy:!0}},mathmlBuilder:(e,t)=>{ws(e);let n=Ga(e.body,t),r=Cs(e.left,e.mode,`prefix`,!0);n.unshift(r);let i=Cs(e.right,e.mode,`postfix`,!0);if(e.body.length>0){let t=e.body[e.body.length-1];t.type===`color`&&!t.isTextColor&&i.setAttribute(`mathcolor`,t.color)}return n.push(i),Va(n)}}),j({type:`delimiter`,names:Array.from(gs),props:{numArgs:0,allowedInText:!0,allowedInMath:!0,allowedInArgument:!0},handler:({parser:e,funcName:t,token:n})=>{if(e.mode===`text`)return{type:`textord`,mode:`text`,text:t,loc:n.loc};if(!e.settings.wrapDelimiterPairs)return{type:`atom`,mode:`math`,family:`open`,loc:n.loc,text:t};let r=hs[t],i=e.parseExpression(!1,r,!1);if(e.fetch().text!==r)throw new A(`Unmatched delimiter`);return e.consume(),{type:`delimiter`,mode:e.mode,body:i,left:t,right:r}},mathmlBuilder:(e,t)=>{ws(e);let n=Ga(e.body,t),r=Cs(e.left,e.mode,`prefix`,!1);n.unshift(r);let i=Cs(e.right,e.mode,`postfix`,!1);if(e.body.length>0){let t=e.body[e.body.length-1];t.type===`color`&&!t.isTextColor&&i.setAttribute(`mathcolor`,t.color)}return n.push(i),Va(n)}}),j({type:`middle`,names:[`\\middle`],props:{numArgs:1,argTypes:[`primitive`]},handler:(e,t)=>{let n=xs(t[0],e);if(!e.parser.leftrightDepth)throw new A(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},mathmlBuilder:e=>{let t=Ra(e.delim,e.mode),n=new N(`mo`,[t]);return n.setAttribute(`stretchy`,`true`),n.setAttribute(`form`,`infix`),t.text!==`/`&&(n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`)),n}});var Ts=[`\\boxed`,`\\fcolorbox`,`\\colorbox`],Es=(e,t)=>{let n=new N(Ts.includes(e.label)?`mrow`:`menclose`,[q(e.body,t)]);switch(e.label){case`\\overline`:n.setAttribute(`notation`,`top`),n.classes.push(`tml-overline`);break;case`\\underline`:n.setAttribute(`notation`,`bottom`),n.classes.push(`tml-underline`);break;case`\\cancel`:n.setAttribute(`notation`,`updiagonalstrike`),n.children.push(new N(`mrow`,[],[`tml-cancel`,`upstrike`]));break;case`\\bcancel`:n.setAttribute(`notation`,`downdiagonalstrike`),n.children.push(new N(`mrow`,[],[`tml-cancel`,`downstrike`]));break;case`\\sout`:n.setAttribute(`notation`,`horizontalstrike`),n.children.push(new N(`mrow`,[],[`tml-cancel`,`sout`]));break;case`\\xcancel`:n.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`),n.children.push(new N(`mrow`,[],[`tml-cancel`,`tml-xcancel`]));break;case`\\longdiv`:n.setAttribute(`notation`,`longdiv`),n.classes.push(`longdiv-top`),n.children.push(new N(`mrow`,[],[`longdiv-arc`]));break;case`\\phase`:n.setAttribute(`notation`,`phasorangle`),n.classes.push(`phasor-bottom`),n.children.push(new N(`mrow`,[],[`phasor-angle`]));break;case`\\textcircled`:n.setAttribute(`notation`,`circle`),n.classes.push(`circle-pad`),n.children.push(new N(`mrow`,[],[`textcircle`]));break;case`\\angl`:n.setAttribute(`notation`,`actuarial`),n.classes.push(`actuarial`);break;case`\\boxed`:n.style.padding=`3pt`,n.style.border=`1px solid`,n.setAttribute(`scriptlevel`,`0`),n.setAttribute(`displaystyle`,`true`);break;case`\\fbox`:n.setAttribute(`notation`,`box`),n.classes.push(`tml-fbox`);break;case`\\fcolorbox`:case`\\colorbox`:n.style.padding=`0.3em`,e.label===`\\fcolorbox`&&(n.style.border=`0.0667em solid `+String(e.borderColor))}return e.backgroundColor&&n.setAttribute(`mathbackground`,e.backgroundColor),n};j({type:`enclose`,names:[`\\colorbox`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`text`]},handler({parser:e,funcName:t},n,r){let i=r[0]&&Y(r[0],`raw`).string,a=``;if(i){let e=Y(n[0],`raw`).string;a=ss(i,e)}else a=cs(Y(n[0],`raw`).string,e.gullet.macros);let o=n[1];return{type:`enclose`,mode:e.mode,label:t,backgroundColor:a,body:o}},mathmlBuilder:Es}),j({type:`enclose`,names:[`\\fcolorbox`],props:{numArgs:3,numOptionalArgs:1,allowedInText:!0,argTypes:[`raw`,`raw`,`raw`,`text`]},handler({parser:e,funcName:t},n,r){let i=r[0]&&Y(r[0],`raw`).string,a=``,o;if(i){let e=Y(n[0],`raw`).string,t=Y(n[0],`raw`).string;a=ss(i,e),o=ss(i,t)}else a=cs(Y(n[0],`raw`).string,e.gullet.macros),o=cs(Y(n[1],`raw`).string,e.gullet.macros);let s=n[2];return{type:`enclose`,mode:e.mode,label:t,backgroundColor:o,borderColor:a,body:s}},mathmlBuilder:Es}),j({type:`enclose`,names:[`\\fbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInText:!0},handler({parser:e},t){return{type:`enclose`,mode:e.mode,label:`\\fbox`,body:t[0]}}}),j({type:`enclose`,names:[`\\angl`,`\\cancel`,`\\bcancel`,`\\xcancel`,`\\overline`,`\\boxed`,`\\longdiv`,`\\phase`],props:{numArgs:1},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:Es}),j({type:`enclose`,names:[`\\sout`],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:Es}),j({type:`enclose`,names:[`\\underline`],props:{numArgs:1,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:Es}),j({type:`enclose`,names:[`\\textcircled`],props:{numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`enclose`,mode:e.mode,label:t,body:r}},mathmlBuilder:Es}),j({type:`environment`,names:[`\\begin`,`\\end`],props:{numArgs:1,argTypes:[`text`]},handler({parser:e,funcName:t},n){let r=n[0];if(r.type!==`ordgroup`)throw new A(`Invalid environment name`,r);let i=``;for(let e=0;e0,bold:e=>119743,italic:e=>119795,"bold-italic":e=>119847,script:e=>Ds[e]||119899,"script-bold":e=>119951,fraktur:e=>Os[e]||120003,"fraktur-bold":e=>120107,"double-struck":e=>ks[e]||120055,"sans-serif":e=>120159,"sans-serif-bold":e=>120211,"sans-serif-italic":e=>120263,"sans-serif-bold-italic":e=>120380,monospace:e=>120367},lowerCaseLatin:{normal:e=>0,bold:e=>119737,italic:e=>e===`h`?8358:119789,"bold-italic":e=>119841,script:e=>Ds[e]||119893,"script-bold":e=>119945,fraktur:e=>119997,"fraktur-bold":e=>120101,"double-struck":e=>120049,"sans-serif":e=>120153,"sans-serif-bold":e=>120205,"sans-serif-italic":e=>120257,"sans-serif-bold-italic":e=>120309,monospace:e=>120361},upperCaseGreek:{normal:e=>0,bold:e=>119575,italic:e=>119633,"bold-italic":e=>119575,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119749,"sans-serif-bold":e=>119749,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119807,monospace:e=>0},lowerCaseGreek:{normal:e=>0,bold:e=>119569,italic:e=>119627,"bold-italic":e=>e===`ϕ`?119678:119685,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>119743,"sans-serif-bold":e=>119743,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>119801,monospace:e=>0},varGreek:{normal:e=>0,bold:e=>As[e]||-51,italic:e=>0,"bold-italic":e=>js[e]||58,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>0,"sans-serif":e=>Ms[e]||116,"sans-serif-bold":e=>Ms[e]||116,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>Ns[e]||174,monospace:e=>0},numeral:{normal:e=>0,bold:e=>120734,italic:e=>0,"bold-italic":e=>0,script:e=>0,"script-bold":e=>0,fraktur:e=>0,"fraktur-bold":e=>0,"double-struck":e=>120744,"sans-serif":e=>120754,"sans-serif-bold":e=>120764,"sans-serif-italic":e=>0,"sans-serif-bold-italic":e=>0,monospace:e=>120774}}),Fs=(e,t)=>{let n=e.codePointAt(0),r=64{if(!Ls.includes(t)||!e.body||e.body.type!==`ordgroup`||e.body.body.length===1||e.body.body[0].type!==`mathord`)return!1;for(let t=1;t{let n=e.font,r=t.withFont(n),i=q(e.body,r);if(i.children.length===0)return i;if(n===`boldsymbol`&&[`mo`,`mpadded`,`mrow`].includes(i.type))return i.style.fontWeight=`bold`,i;if(Rs(e,n)){let e=i.children[0].children[0].children?i.children[0].children[0]:i.children[0];delete e.attributes.mathvariant;for(let t=1;tFs(e,`italic`)).join(``),e;let t=new N(`mpadded`,[e]);return t.setAttribute(`lspace`,`0`),t}let a=i.children[0].type===`mo`;for(let e=1;e{let r=la(n[0]),i=t;return i in Bs&&(i=Bs[i]),{type:`font`,mode:e.mode,font:i.slice(1),body:r}},mathmlBuilder:zs}),j({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],props:{numArgs:0,allowedInText:!0},handler:({parser:e,funcName:t,breakOnTokenText:n},r)=>{let{mode:i}=e,a=e.parseExpression(!0,n,!0);return{type:`font`,mode:i,font:`math${t.slice(1)}`,body:{type:`ordgroup`,mode:e.mode,body:a}}},mathmlBuilder:zs});var Vs=[`display`,`text`,`script`,`scriptscript`],Hs={auto:-1,display:0,text:0,script:1,scriptscript:2},Us=(e,t)=>{let n=t;if(e===`display`){let e=n.level>=X.SCRIPT?X.TEXT:X.DISPLAY;n=n.withLevel(e)}else e===`text`&&n.level===X.DISPLAY?n=n.withLevel(X.TEXT):e===`auto`?n=n.incrementLevel():e===`script`?n=n.withLevel(X.SCRIPT):e===`scriptscript`&&(n=n.withLevel(X.SCRIPTSCRIPT));return n},Ws=(e,t)=>{t=Us(e.scriptLevel,t);let n=q(e.numer,t),r=q(e.denom,t);t.level===3&&(n.style.mathDepth=`2`,n.setAttribute(`scriptlevel`,`2`),r.style.mathDepth=`2`,r.setAttribute(`scriptlevel`,`2`));let i=new N(`mfrac`,[n,r]);if(!e.hasBarLine)i.setAttribute(`linethickness`,`0px`);else if(e.barSize){let n=lo(e.barSize,t);i.setAttribute(`linethickness`,n.number+n.unit)}if(e.leftDelim!=null||e.rightDelim!=null){let t=[];if(e.leftDelim!=null){let n=new N(`mo`,[new ba(e.leftDelim.replace(`\\`,``))]);n.setAttribute(`fence`,`true`),t.push(n)}if(t.push(i),e.rightDelim!=null){let n=new N(`mo`,[new ba(e.rightDelim.replace(`\\`,``))]);n.setAttribute(`fence`,`true`),t.push(n)}i=Va(t)}return e.scriptLevel!==`auto`&&(i=new N(`mstyle`,[i]),i.setAttribute(`displaystyle`,String(e.scriptLevel===`display`)),i.setAttribute(`scriptlevel`,Hs[e.scriptLevel])),i};j({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],props:{numArgs:2,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=n[1],a=!1,o=null,s=null,c=`auto`;switch(t){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:a=!0;break;case`\\\\atopfrac`:a=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=`(`,s=`)`;break;case`\\\\bracefrac`:o=`\\{`,s=`\\}`;break;case`\\\\brackfrac`:o=`[`,s=`]`;break;default:throw Error(`Unrecognized genfrac command`)}return t===`\\cfrac`||t.startsWith(`\\d`)?c=`display`:t.startsWith(`\\t`)&&(c=`text`),{type:`genfrac`,mode:e.mode,continued:!1,numer:r,denom:i,hasBarLine:a,leftDelim:o,rightDelim:s,scriptLevel:c,barSize:null}},mathmlBuilder:Ws}),j({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],props:{numArgs:0,infix:!0},handler({parser:e,funcName:t,token:n}){let r;switch(t){case`\\over`:r=`\\frac`;break;case`\\choose`:r=`\\binom`;break;case`\\atop`:r=`\\\\atopfrac`;break;case`\\brace`:r=`\\\\bracefrac`;break;case`\\brack`:r=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:e.mode,replaceWith:r,token:n}}});var Gs=function(e){let t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};j({type:`genfrac`,names:[`\\genfrac`],props:{numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`]},handler({parser:e},t){let n=t[4],r=t[5],i=la(t[0]),a=i.type===`atom`&&i.family===`open`?Gs(i.text):null,o=la(t[1]),s=o.type===`atom`&&o.family===`close`?Gs(o.text):null,c=Y(t[2],`size`),l,u=null;c.isBlank?l=!0:(u=c.value,l=u.number>0);let d=`auto`,f=t[3];if(f.type===`ordgroup`){if(f.body.length>0){let e=Y(f.body[0],`textord`);d=Vs[Number(e.text)]}}else f=Y(f,`textord`),d=Vs[Number(f.text)];return{type:`genfrac`,mode:e.mode,numer:n,denom:r,continued:!1,hasBarLine:l,barSize:u,leftDelim:a,rightDelim:s,scriptLevel:d}},mathmlBuilder:Ws}),j({type:`infix`,names:[`\\above`],props:{numArgs:1,argTypes:[`size`],infix:!0},handler({parser:e,funcName:t,token:n},r){return{type:`infix`,mode:e.mode,replaceWith:`\\\\abovefrac`,barSize:Y(r[0],`size`).value,token:n}}}),j({type:`genfrac`,names:[`\\\\abovefrac`],props:{numArgs:3,argTypes:[`math`,`size`,`math`]},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=$i(Y(n[1],`infix`).barSize),a=n[2],o=i.number>0;return{type:`genfrac`,mode:e.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null,scriptLevel:`auto`}},mathmlBuilder:Ws}),j({type:`hbox`,names:[`\\hbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInArgument:!0,allowedInText:!1},handler({parser:e},t){return{type:`hbox`,mode:e.mode,body:M(t[0])}},mathmlBuilder(e,t){let n=t.withLevel(X.TEXT);return Ba(Ka(e.body,n))}}),j({type:`horizBracket`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],props:{numArgs:1},handler({parser:e,funcName:t},n){return{type:`horizBracket`,mode:e.mode,label:t,isOver:/^\\over/.test(t),base:n[0]}},mathmlBuilder:(e,t)=>{let n=wa(e.label);return n.style[`math-depth`]=0,new N(e.isOver?`mover`:`munder`,[q(e.base,t),n])}}),j({type:`html`,names:[`\\class`,`\\id`,`\\style`,`\\data`],props:{numArgs:2,argTypes:[`raw`,`original`],allowedInText:!0},handler:({parser:e,funcName:t,token:n},r)=>{let i=Y(r[0],`raw`).string,a=r[1];if(e.settings.strict)throw new A(`Function "${t}" is disabled in strict mode`,n);let o,s={};switch(t){case`\\class`:s.class=i,o={command:`\\class`,class:i};break;case`\\id`:s.id=i,o={command:`\\id`,id:i};break;case`\\style`:s.style=i,o={command:`\\style`,style:i};break;case`\\data`:{let e=i.split(`,`);for(let t=0;t{let n=Ka(e.body,t),r=[];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/)),n.classes=r;for(let t in e.attributes)t!==`class`&&Object.prototype.hasOwnProperty.call(e.attributes,t)&&n.setAttribute(t,e.attributes[t]);return n}});var Ks=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};{let t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new A(`Invalid size: '`+e+`' in \\includegraphics`);let n={number:+(t[1]+t[2]),unit:t[3]};if(!so(n))throw new A(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n}};j({type:`includegraphics`,names:[`\\includegraphics`],props:{numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1},handler:({parser:e,token:t},n,r)=>{let i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(r[0]){let e=Y(r[0],`raw`).string.split(`,`);for(let t=0;t{let n=lo(e.height,t),r={number:0,unit:`em`};e.totalheight.number>0&&e.totalheight.unit===n.unit&&e.totalheight.number>n.number&&(r.number=e.totalheight.number-n.number,r.unit=n.unit);let i=0;e.width.number>0&&(i=lo(e.width,t));let a={height:n.number+r.number+`em`};i.number>0&&(a.width=i.number+i.unit),r.number>0&&(a.verticalAlign=-r.number+r.unit);let o=new va(e.src,e.alt,a);return o.height=n,o.depth=r,new N(`mtext`,[o])}}),j({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],props:{numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0},handler({parser:e,funcName:t,token:n},r){let i=Y(r[0],`size`);if(e.settings.strict){let r=t[1]===`m`,a=i.value.unit===`mu`;if(r){if(!a)throw new A(`LaTeX's ${t} supports only mu units, not ${i.value.unit} units`,n);if(e.mode!==`math`)throw new A(`LaTeX's ${t} works only in math mode`,n)}else if(a)throw new A(`LaTeX's ${t} doesn't support mu units`,n)}return{type:`kern`,mode:e.mode,dimension:i.value}},mathmlBuilder(e,t){let n=lo(e.dimension,t),r=n.number>0&&n.unit===`em`?qs(n.number):``;if(e.mode===`text`&&r.length>0)return new N(`mtext`,[new ba(r)]);if(n.number>=0){let e=new N(`mspace`);return e.setAttribute(`width`,n.number+n.unit),e}{let e=new N(`mrow`);return e.style.marginLeft=n.number+n.unit,e}}});var qs=function(e){return e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:``},Js=/[^A-Za-z_0-9-]/g;j({type:`label`,names:[`\\label`],props:{numArgs:1,argTypes:[`raw`]},handler({parser:e},t){return{type:`label`,mode:e.mode,string:t[0].string.replace(Js,``)}},mathmlBuilder(e,t){let n=new N(`mrow`,[],[`tml-label`]);return e.string.length>0&&n.setLabel(e.string),n}});var Ys=[`\\clap`,`\\llap`,`\\rlap`];j({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`,`\\clap`,`\\llap`,`\\rlap`],props:{numArgs:1,allowedInText:!0},handler:({parser:e,funcName:t,token:n},r)=>{if(Ys.includes(t)){if(e.settings.strict&&e.mode!==`text`)throw new A(`{${t}} can be used only in text mode. Try \\math${t.slice(1)}`,n);t=t.slice(1)}else t=t.slice(5);let i=r[0];return{type:`lap`,mode:e.mode,alignment:t,body:i}},mathmlBuilder:(e,t)=>{let n;e.alignment===`llap`&&(n=new N(`mpadded`,[new N(`mphantom`,Ga(M(e.body),t))]),n.setAttribute(`width`,`0.1px`));let r=q(e.body,t),i;if(e.alignment===`llap`?(r.style.position=`absolute`,r.style.right=`0`,r.style.bottom=`0`,i=new N(`mpadded`,[n,r])):i=new N(`mpadded`,[r]),e.alignment===`rlap`)e.body.body.length>0&&e.body.body[0].type===`genfrac`&&i.setAttribute(`lspace`,`0.16667em`);else{let t=e.alignment===`llap`?`-1`:`-0.5`;i.setAttribute(`lspace`,t+`width`),e.alignment===`llap`?i.style.position=`relative`:(i.style.display=`flex`,i.style.justifyContent=`center`)}return i.setAttribute(`width`,`0.1px`),i}}),j({type:`ordgroup`,names:[`\\(`,`$`],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler({funcName:e,parser:t},n){let r=t.mode;t.switchMode(`math`);let i=e===`\\(`?`\\)`:`$`,a=t.parseExpression(!1,i);return t.expect(i),t.switchMode(r),{type:`ordgroup`,mode:t.mode,body:a}}}),j({type:`text`,names:[`\\)`,`\\]`],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new A(`Mismatched ${e.funcName}`,t)}});var Xs=(e,t)=>{switch(t.level){case X.DISPLAY:return e.display;case X.TEXT:return e.text;case X.SCRIPT:return e.script;case X.SCRIPTSCRIPT:return e.scriptscript;default:return e.text}};j({type:`mathchoice`,names:[`\\mathchoice`],props:{numArgs:4,primitive:!0},handler:({parser:e},t)=>({type:`mathchoice`,mode:e.mode,display:M(t[0]),text:M(t[1]),script:M(t[2]),scriptscript:M(t[3])}),mathmlBuilder:(e,t)=>Ka(Xs(e,t),t)});var Zs=[`text`,`textord`,`mathord`,`atom`];function Qs(e,t){let n,r=Ga(e.body,t);if(e.mclass===`minner`)n=new N(`mpadded`,r);else if(e.mclass===`mord`)e.isCharacterBox||r[0].type===`mathord`?(n=r[0],n.type=`mi`,n.children.length===1&&n.children[0].text&&n.children[0].text===`∇`&&n.setAttribute(`mathvariant`,`normal`)):n=new N(`mi`,r);else{n=new N(`mrow`,r),e.mustPromote?(n=r[0],n.type=`mo`,e.isCharacterBox&&e.body[0].text&&/[A-Za-z]/.test(e.body[0].text)&&n.setAttribute(`mathvariant`,`italic`)):n=new N(`mrow`,r);let i=t.level<2;n.type===`mrow`?i&&(e.mclass===`mbin`?(n.children.unshift(J(.2222)),n.children.push(J(.2222))):e.mclass===`mrel`?(n.children.unshift(J(.2778)),n.children.push(J(.2778))):e.mclass===`mpunct`?n.children.push(J(.1667)):e.mclass===`minner`&&(n.children.unshift(J(.0556)),n.children.push(J(.0556)))):e.mclass===`mbin`?(n.attributes.lspace=i?`0.2222em`:`0`,n.attributes.rspace=i?`0.2222em`:`0`):e.mclass===`mrel`?(n.attributes.lspace=i?`0.2778em`:`0`,n.attributes.rspace=i?`0.2778em`:`0`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=i?`0.1667em`:`0`):e.mclass===`mopen`||e.mclass===`mclose`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`):e.mclass===`minner`&&i&&(n.attributes.lspace=`0.0556em`,n.attributes.width=`+0.1111em`),e.mclass!==`mopen`&&e.mclass!==`mclose`&&(delete n.attributes.stretchy,delete n.attributes.form)}return n}j({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],props:{numArgs:1,primitive:!0},handler({parser:e,funcName:t},n){let r=n[0],i=Qi(r),a=!0,o={type:`mathord`,text:``,mode:e.mode},s=r.body?r.body:[r];for(let t of s)if(Zs.includes(t.type))P[e.mode][t.text]?o.text+=P[e.mode][t.text].replace:t.text?o.text+=t.text:t.body&&t.body.map(e=>{o.text+=e.text});else{a=!1;break}return a&&t===`\\mathord`&&o.type===`mathord`&&o.text.length>1?o:{type:`mclass`,mode:e.mode,mclass:`m`+t.slice(5),body:M(a?o:r),isCharacterBox:i,mustPromote:a}},mathmlBuilder:Qs});var $s=e=>{let t=e.type===`ordgroup`&&e.body.length&&e.body.length===1?e.body[0]:e;if(t.type===`atom`){let n=e.body.length>0&&e.body[0].text&&P.math[e.body[0].text]?P.math[e.body[0].text].group:t.family;return n===`bin`||n===`rel`?`m`+n:`mord`}return`mord`};j({type:`mclass`,names:[`\\@binrel`],props:{numArgs:2},handler({parser:e},t){return{type:`mclass`,mode:e.mode,mclass:$s(t[0]),body:M(t[1]),isCharacterBox:Qi(t[1])}}}),j({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],props:{numArgs:2},handler({parser:e,funcName:t},n){let r=n[1],i=n[0],a;a=t===`\\stackrel`?`mrel`:$s(r);let o={type:a===`mrel`||a===`mbin`?`op`:`ordgroup`,mode:r.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:t!==`\\stackrel`,body:M(r)};return{type:`supsub`,mode:i.mode,stack:!0,base:o,sup:t===`\\underset`?null:i,sub:t===`\\underset`?i:null}},mathmlBuilder:Qs});var ec=(e,t,n)=>{if(!e)return n;let r=q(e,t);return r.type===`mrow`&&r.children.length===0?n:r};j({type:`multiscript`,names:[`\\sideset`,`\\pres@cript`],props:{numArgs:3},handler({parser:e,funcName:t,token:n},r){if(r[2].body.length===0)throw new A(t+`cannot parse an empty base.`);let i=r[2].body[0];if(e.settings.strict&&t===`\\sideset`&&!i.symbol)throw new A(`The base of \\sideset must be a big operator. Try \\prescript.`);if(r[0].body.length>0&&r[0].body[0].type!==`supsub`||r[1].body.length>0&&r[1].body[0].type!==`supsub`)throw new A(`\\sideset can parse only subscripts and superscripts in its first two arguments`,n);let a=r[0].body.length>0?r[0].body[0]:null,o=r[1].body.length>0?r[1].body[0]:null;return!a&&!o?i:a?{type:`multiscript`,mode:e.mode,isSideset:t===`\\sideset`,prescripts:a,postscripts:o,base:i}:{type:`styling`,mode:e.mode,scriptLevel:`text`,body:[{type:`supsub`,mode:e.mode,base:i,sup:o.sup,sub:o.sub}]}},mathmlBuilder(e,t){let n=q(e.base,t),r=new N(`mprescripts`),i=new N(`none`),a=[],o=ec(e.prescripts.sub,t,i),s=ec(e.prescripts.sup,t,i);return e.isSideset&&(o.setAttribute(`style`,`text-align: left;`),s.setAttribute(`style`,`text-align: left;`)),a=e.postscripts?[n,ec(e.postscripts.sub,t,i),ec(e.postscripts.sup,t,i),r,o,s]:[n,r,o,s],new N(`mmultiscripts`,a)}}),j({type:`not`,names:[`\\not`],props:{numArgs:1,primitive:!0,allowedInText:!1},handler({parser:e},t){let n=Qi(t[0]),r;return n?(r=M(t[0]),r[0].text.charAt(0)===`\\`&&(r[0].text=P.math[r[0].text].replace),r[0].text=r[0].text.slice(0,1)+`̸`+r[0].text.slice(1)):r=[{type:`textord`,mode:`math`,text:`̸`},{type:`kern`,mode:`math`,dimension:{number:-.6,unit:`em`}},t[0]],{type:`not`,mode:e.mode,body:r,isCharacterBox:n}},mathmlBuilder(e,t){return e.isCharacterBox?Ga(e.body,t,!0)[0]:Ka(e.body,t)}});var tc=[`textord`,`mathord`,`atom`],nc=[`\\smallint`],rc=[`textord`,`mathord`,`ordgroup`,`close`,`leftright`,`font`],ic=e=>{e.attributes.lspace=`0.1667em`,e.attributes.rspace=`0.1667em`},ac=(e,t)=>{let n;if(e.symbol)n=new N(`mo`,[Ra(e.name,e.mode)]),nc.includes(e.name)?n.setAttribute(`largeop`,`false`):n.setAttribute(`movablelimits`,`false`),e.fromMathOp&&ic(n);else if(e.body)n=new N(`mo`,Ga(e.body,t)),e.fromMathOp&&ic(n);else if(n=new N(`mi`,[new ba(e.name.slice(1))]),!e.parentIsSupSub){let t=new N(`mo`,[Ra(`⁡`,`text`)]),r=[n,t];if(e.needsLeadingSpace){let e=new N(`mspace`);e.setAttribute(`width`,`0.1667em`),r.unshift(e)}if(!e.isFollowedByDelimiter){let e=new N(`mspace`);e.setAttribute(`width`,`0.1667em`),r.push(e)}n=new N(`mrow`,r)}return n},oc={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨅":`\\bigsqcap`,"⨆":`\\bigsqcup`,"⨃":`\\bigcupdot`,"⨇":`\\bigdoublevee`,"⨈":`\\bigdoublewedge`,"⨉":`\\bigtimes`};j({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcupplus.\\bigcupdot.\\bigcap.\\bigcup.\\bigdoublevee.\\bigdoublewedge.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcap.\\bigsqcup.\\bigtimes.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨃.⨄.⨅.⨆.⨇.⨈.⨉`.split(`.`),props:{numArgs:0},handler:({parser:e,funcName:t},n)=>{let r=t;return r.length===1&&(r=oc[r]),{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!0,stack:!1,name:r}},mathmlBuilder:ac}),j({type:`op`,names:[`\\mathop`],props:{numArgs:1,primitive:!0},handler:({parser:e},t)=>{let n=t[0],r=n.body?n.body:[n],i=r.length===1&&tc.includes(r[0].type);return{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:i,fromMathOp:!0,stack:!1,name:i?r[0].text:null,body:i?null:M(n)}},mathmlBuilder:ac});var sc={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`,"∱":`\\intclockwise`,"∲":`\\varointclockwise`,"⨌":`\\iiiint`,"⨍":`\\intbar`,"⨎":`\\intBar`,"⨏":`\\fint`,"⨒":`\\rppolint`,"⨓":`\\scpolint`,"⨕":`\\pointint`,"⨖":`\\sqint`,"⨗":`\\intlarhk`,"⨘":`\\intx`,"⨙":`\\intcap`,"⨚":`\\intcup`};j({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\sgn.\\tan.\\tanh.\\tg.\\th`.split(`.`),props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,r=e.gullet.future().text;return{type:`op`,mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:ys(r),needsLeadingSpace:n.length>0&&rc.includes(n),name:t}},mathmlBuilder:ac}),j({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],props:{numArgs:0},handler({parser:e,funcName:t}){let n=e.prevAtomType,r=e.gullet.future().text;return{type:`op`,mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,stack:!1,isFollowedByDelimiter:ys(r),needsLeadingSpace:n.length>0&&rc.includes(n),name:t}},mathmlBuilder:ac}),j({type:`op`,names:`\\int.\\iint.\\iiint.\\iiiint.\\oint.\\oiint.\\oiiint.\\intclockwise.\\varointclockwise.\\intbar.\\intBar.\\fint.\\rppolint.\\scpolint.\\pointint.\\sqint.\\intlarhk.\\intx.\\intcap.\\intcup.∫.∬.∭.∮.∯.∰.∱.∲.⨌.⨍.⨎.⨏.⨒.⨓.⨕.⨖.⨗.⨘.⨙.⨚`.split(`.`),props:{numArgs:0,allowedInArgument:!0},handler({parser:e,funcName:t}){let n=t;return n.length===1&&(n=sc[n]),{type:`op`,mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,stack:!1,name:n}},mathmlBuilder:ac}),j({type:`operatorname`,names:[`\\operatorname@`,`\\operatornamewithlimits`],props:{numArgs:1,allowedInArgument:!0},handler:({parser:e,funcName:t},n)=>{let r=n[0],i=e.prevAtomType,a=e.gullet.future().text;return{type:`operatorname`,mode:e.mode,body:M(r),alwaysHandleSupSub:t===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1,isFollowedByDelimiter:ys(a),needsLeadingSpace:i.length>0&&rc.includes(i)}},mathmlBuilder:(e,t)=>{let n=Ga(e.body,t.withFont(`mathrm`)),r=!0;for(let e=0;ee.toText()).join(``))];else if(n.length===1&&[`mover`,`munder`].includes(n[0].type)&&(n[0].children[0].type===`mi`||n[0].children[0].type===`mtext`)){if(n[0].children[0].type=`mi`,e.parentIsSupSub)return new N(`mrow`,n);{let e=new N(`mo`,[Ra(`⁡`,`text`)]);return ya([n[0],e])}}let i;if(r?(i=new N(`mi`,n),n[0].text.length===1&&i.setAttribute(`mathvariant`,`normal`)):i=new N(`mrow`,n),!e.parentIsSupSub){let t=new N(`mo`,[Ra(`⁡`,`text`)]),n=[i,t];if(e.needsLeadingSpace){let e=new N(`mspace`);e.setAttribute(`width`,`0.1667em`),n.unshift(e)}if(!e.isFollowedByDelimiter){let e=new N(`mspace`);e.setAttribute(`width`,`0.1667em`),n.push(e)}return ya(n)}return i}}),Z(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),ca({type:`ordgroup`,mathmlBuilder(e,t){return Ka(e.body,t,e.semisimple)}}),j({type:`phantom`,names:[`\\phantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`phantom`,mode:e.mode,body:M(n)}},mathmlBuilder:(e,t)=>new N(`mphantom`,Ga(e.body,t))}),j({type:`hphantom`,names:[`\\hphantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`hphantom`,mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=new N(`mpadded`,[new N(`mphantom`,Ga(M(e.body),t))]);return n.setAttribute(`height`,`0px`),n.setAttribute(`depth`,`0px`),n}}),j({type:`vphantom`,names:[`\\vphantom`],props:{numArgs:1,allowedInText:!0},handler:({parser:e},t)=>{let n=t[0];return{type:`vphantom`,mode:e.mode,body:n}},mathmlBuilder:(e,t)=>{let n=new N(`mpadded`,[new N(`mphantom`,Ga(M(e.body),t))]);return n.setAttribute(`width`,`0.1px`),n}}),j({type:`pmb`,names:[`\\pmb`],props:{numArgs:1,allowedInText:!0},handler({parser:e},t){return{type:`pmb`,mode:e.mode,body:M(t[0])}},mathmlBuilder(e,t){let n=xa(Ga(e.body,t));return n.setAttribute(`style`,`font-weight:bold`),n}});var cc=(e,t)=>{let n=t.withLevel(X.TEXT),r=new N(`mpadded`,[q(e.body,n)]),i=lo(e.dy,t);return r.setAttribute(`voffset`,i.number+i.unit),i.number>0?r.style.padding=i.number+i.unit+` 0 0 0`:r.style.padding=`0 0 `+Math.abs(i.number)+i.unit+` 0`,r};j({type:`raise`,names:[`\\raise`,`\\lower`],props:{numArgs:2,argTypes:[`size`,`primitive`],primitive:!0},handler({parser:e,funcName:t},n){let r=Y(n[0],`size`).value;t===`\\lower`&&(r.number*=-1);let i=n[1];return{type:`raise`,mode:e.mode,dy:r,body:i}},mathmlBuilder:cc}),j({type:`raise`,names:[`\\raisebox`],props:{numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0},handler({parser:e,funcName:t},n){let r=Y(n[0],`size`).value,i=n[1];return{type:`raise`,mode:e.mode,dy:r,body:i}},mathmlBuilder:cc}),j({type:`ref`,names:[`\\ref`,`\\eqref`],props:{numArgs:1,argTypes:[`raw`]},handler({parser:e,funcName:t},n){return{type:`ref`,mode:e.mode,funcName:t,string:n[0].string.replace(Js,``)}},mathmlBuilder(e,t){let n=e.funcName===`\\ref`?[`tml-ref`]:[`tml-ref`,`tml-eqref`];return new _a(`#`+e.string,n,null)}}),j({type:`reflect`,names:[`\\reflectbox`],props:{numArgs:1,argTypes:[`hbox`],allowedInText:!0},handler({parser:e},t){return{type:`reflect`,mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let n=q(e.body,t);return n.style.transform=`scaleX(-1)`,n}}),j({type:`internal`,names:[`\\relax`],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler({parser:e}){return{type:`internal`,mode:e.mode}}}),j({type:`rule`,names:[`\\rule`],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`]},handler({parser:e},t,n){let r=n[0],i=Y(t[0],`size`),a=Y(t[1],`size`);return{type:`rule`,mode:e.mode,shift:r&&Y(r,`size`).value,width:i.value,height:a.value}},mathmlBuilder(e,t){let n=lo(e.width,t),r=lo(e.height,t),i=e.shift?lo(e.shift,t):{number:0,unit:`em`},a=t.color&&t.getColor()||`black`,o=new N(`mspace`);if(n.number>0&&r.number>0&&o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,n.number+n.unit),o.setAttribute(`height`,r.number+r.unit),i.number===0)return o;let s=new N(`mpadded`,[o]);return i.number>=0?s.setAttribute(`height`,`+`+i.number+i.unit):(s.setAttribute(`height`,i.number+i.unit),s.setAttribute(`depth`,`+`+-i.number+i.unit)),s.setAttribute(`voffset`,i.number+i.unit),s}});var lc=/^[0-9]$/,uc={0:`₀`,1:`₁`,2:`₂`,3:`₃`,4:`₄`,5:`₅`,6:`₆`,7:`₇`,8:`₈`,9:`₉`},dc={0:`⁰`,1:`¹`,2:`²`,3:`³`,4:`⁴`,5:`⁵`,6:`⁶`,7:`⁷`,8:`⁸`,9:`⁹`};j({type:`sfrac`,names:[`\\sfrac`],props:{numArgs:2,allowedInText:!0,allowedInMath:!0},handler({parser:e},t){let n=``;for(let e of t[0].body){if(e.type!==`textord`||!lc.test(e.text))throw new A(`Numerator must be an integer.`,e);n+=e.text}let r=``;for(let e of t[1].body){if(e.type!==`textord`||!lc.test(e.text))throw new A(`Denominator must be an integer.`,e);r+=e.text}return{type:`sfrac`,mode:e.mode,numerator:n,denominator:r}},mathmlBuilder(e,t){let n=e.numerator.split(``).map(e=>dc[e]).join(``),r=e.denominator.split(``).map(e=>uc[e]).join(``);return new N(`mn`,[new ba(n+`⁄`+r,e.mode,t)],[`special-fraction`])}});var fc={"\\tiny":.5,"\\sixptsize":.6,"\\Tiny":.6,"\\scriptsize":.7,"\\footnotesize":.8,"\\small":.9,"\\normalsize":1,"\\large":1.2,"\\Large":1.44,"\\LARGE":1.728,"\\huge":2.074,"\\Huge":2.488};j({type:`sizing`,names:[`\\tiny`,`\\sixptsize`,`\\Tiny`,`\\scriptsize`,`\\footnotesize`,`\\small`,`\\normalsize`,`\\large`,`\\Large`,`\\LARGE`,`\\huge`,`\\Huge`],props:{numArgs:0,allowedInText:!0},handler:({breakOnTokenText:e,funcName:t,parser:n},r)=>{n.settings.strict&&n.mode===`math`&&console.log(`Temml strict-mode warning: Command ${t} is invalid in math mode.`);let i=n.parseExpression(!1,e,!0);return{type:`sizing`,mode:n.mode,funcName:t,body:i}},mathmlBuilder:(e,t)=>{let n=t.withFontSize(fc[e.funcName]),r=xa(Ga(e.body,n)),i=(fc[e.funcName]/t.fontSize).toFixed(4);return r.setAttribute(`mathsize`,i+`em`),r}}),j({type:`smash`,names:[`\\smash`],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:({parser:e},t,n)=>{let r=!1,i=!1,a=n[0]&&Y(n[0],`ordgroup`);if(a){let e=``;for(let t=0;t{let n=new N(`mpadded`,[q(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}});var pc=`a.c.e.ı.m.n.o.r.s.u.v.w.x.z.α.ε.ι.κ.ν.ο.π.σ.τ.υ.ω.\\alpha.\\epsilon.\\iota.\\kappa.\\nu.\\omega.\\pi.\\tau.\\omega`.split(`.`);j({type:`sqrt`,names:[`\\sqrt`],props:{numArgs:1,numOptionalArgs:1},handler({parser:e},t,n){let r=n[0],i=t[0];return i.body&&i.body.length===1&&i.body[0].text&&pc.includes(i.body[0].text)&&i.body.push({type:`rule`,mode:`math`,shift:null,width:{number:0,unit:`pt`},height:{number:.5,unit:`em`}}),{type:`sqrt`,mode:e.mode,body:i,index:r}},mathmlBuilder(e,t){let{body:n,index:r}=e;return r?new N(`mroot`,[q(n,t),q(r,t.incrementLevel())]):new N(`msqrt`,[q(n,t)])}});var mc={display:0,text:1,script:2,scriptscript:3},hc={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]};j({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],props:{numArgs:0,allowedInText:!0,primitive:!0},handler({breakOnTokenText:e,funcName:t,parser:n},r){let i=n.parseExpression(!0,e,!0),a=t.slice(1,t.length-5);return{type:`styling`,mode:n.mode,scriptLevel:a,body:i}},mathmlBuilder(e,t){let n=t.withLevel(mc[e.scriptLevel]),r=xa(Ga(e.body,n)),i=hc[e.scriptLevel];return r.setAttribute(`scriptlevel`,i[0]),r.setAttribute(`displaystyle`,i[1]),r}});var gc=/^m(over|under|underover)$/,_c=`DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ`,vc=`BCEFGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ`,yc=`AJdfΔΛ`;ca({type:`supsub`,mathmlBuilder(e,t){let n=!1,r,i,a=!1,o=!1,s=!1;e.base&&e.base.type===`horizBracket`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&!e.stack&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0,a=!e.base.symbol,o=a&&!e.isFollowedByDelimiter,s=e.base.needsLeadingSpace);let c=e.stack&&e.base.body.length===1?[q(e.base.body[0],t)]:[q(e.base,t)],l=t.inSubOrSup();if(e.sub){let n=q(e.sub,l);t.level===3&&n.setAttribute(`scriptlevel`,`2`),c.push(n)}if(e.sup){let n=q(e.sup,l);if(t.level===3&&n.setAttribute(`scriptlevel`,`2`),e.base&&e.base.text&&e.base.text.length===1){let t=e.base.text;_c.indexOf(t)>-1?n.classes.push(`tml-sml-pad`):vc.indexOf(t)>-1?n.classes.push(`tml-med-pad`):yc.indexOf(t)>-1&&n.classes.push(`tml-lrg-pad`)}c.push(n)}let u;if(n)u=r?`mover`:`munder`;else if(!e.sub){let n=e.base;u=n&&n.type===`op`&&n.limits&&(t.level===X.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(n.limits||t.level===X.DISPLAY)?`mover`:`msup`}else if(e.sup){let n=e.base;u=n&&(n.type===`op`&&n.limits||n.type===`multiscript`)&&(t.level===X.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(t.level===X.DISPLAY||n.limits)?`munderover`:`msubsup`}else{let n=e.base;u=e.stack||n&&n.type===`op`&&n.limits&&(t.level===X.DISPLAY||n.alwaysHandleSupSub)||n&&n.type===`operatorname`&&n.alwaysHandleSupSub&&(n.limits||t.level===X.DISPLAY)?`munder`:`msub`}let d=new N(u,c);if(a){let e=new N(`mo`,[Ra(`⁡`,`text`)]);if(s){let t=new N(`mspace`);t.setAttribute(`width`,`0.1667em`),d=ya([t,d,e])}else d=ya([d,e]);if(o){let e=new N(`mspace`);e.setAttribute(`width`,`0.1667em`),d.children.push(e)}}else gc.test(u)&&(d=new N(`mrow`,[d]));return d}});var bc=[`\\shortmid`,`\\nshortmid`,`\\shortparallel`,`\\nshortparallel`,`\\smallsetminus`],xc=[`\\Rsh`,`\\Lsh`,`\\restriction`],Sc=e=>{if(e.length===1){let t=e.codePointAt(0);return 8591-1||e.indexOf(`harpoon`)>-1||xc.includes(e)};ca({type:`atom`,mathmlBuilder(e,t){if(e.family===`inner`)return new N(e.mode===`text`?`mtext`:`mi`,[Ra(e.text,e.mode)]);let n=new N(`mo`,[Ra(e.text,e.mode)]);if(e.family===`punct`)n.setAttribute(`separator`,`true`);else if(e.family===`open`||e.family===`close`)e.family===`open`?(n.setAttribute(`form`,`prefix`),n.setAttribute(`stretchy`,`false`)):e.family===`close`&&(n.setAttribute(`form`,`postfix`),n.setAttribute(`stretchy`,`false`));else if(e.text===`\\mid`)n.setAttribute(`lspace`,`0.22em`),n.setAttribute(`rspace`,`0.22em`),n.setAttribute(`stretchy`,`false`);else if(e.family===`rel`&&Sc(e.text))n.setAttribute(`stretchy`,`false`);else if(bc.includes(e.text))n.setAttribute(`mathsize`,`70%`);else if(e.text===`:`)n.attributes.lspace=`0.2222em`,n.attributes.rspace=`0.2222em`;else if(e.needsSpacing)return e.family===`bin`?new N(`mrow`,[J(.222),n,J(.222)]):new N(`mrow`,[J(.2778),n,J(.2778)]);return n}});var Cc={mathbf:`bold`,mathrm:`normal`,textit:`italic`,mathit:`italic`,mathnormal:`italic`,mathbb:`double-struck`,mathcal:`script`,mathfrak:`fraktur`,mathscr:`script`,mathsf:`sans-serif`,mathtt:`monospace`},wc=function(e,t){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsc`)return`normal`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`sans-serif-bold`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`;let n=t.font;if(!n||n===`mathnormal`)return null;let r=e.mode;switch(n){case`mathit`:return`italic`;case`mathrm`:{let t=e.text.codePointAt(0);return 939{let r=new N(`mstyle`,[new N(n,[e])]);return r.style[`font-style`]=`italic`,r.style[`font-family`]=`Cambria, 'Times New Roman', serif`,t===`bold-italic`&&(r.style[`font-weight`]=`bold`),r};ca({type:`mathord`,mathmlBuilder(e,t){let n=Ra(e.text,e.mode,t),r=n.text.codePointAt(0),i=912Fs(e,a)).join(``)),o=new N(t,[i])}else if(e.mode===`text`)a!==`normal`&&(i.text=Fs(i.text,a)),o=new N(`mtext`,[i]);else if(Dc.has(e.text))o=new N(`mo`,[i]),o.classes.push(`tml-prime`);else{let e=i.text;a!==`italic`&&(i.text=Fs(i.text,a)),o=new N(`mi`,[i]),i.text===e&&Ec.test(e)&&o.setAttribute(`mathvariant`,`italic`)}return o}});var kc={"\\nobreak":`nobreak`,"\\allowbreak":`allowbreak`},Ac={" ":{},"\\ ":{},"~":{className:`nobreak`},"\\space":{},"\\nobreakspace":{className:`nobreak`}};ca({type:`spacing`,mathmlBuilder(e,t){let n;if(Object.prototype.hasOwnProperty.call(Ac,e.text))n=new N(`mtext`,[new ba(`\xA0`)]);else if(Object.prototype.hasOwnProperty.call(kc,e.text))n=new N(`mo`),e.text===`\\nobreak`&&n.setAttribute(`linebreak`,`nobreak`);else throw new A(`Unknown type of space "${e.text}"`);return n}}),ca({type:`tag`});var jc={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`,"\\textsc":`textsc`},Mc={"\\textbf":`textbf`,"\\textmd":`textmd`},Nc={"\\textit":`textit`,"\\textup":`textup`},Pc=(e,t)=>{let n=e.font;return n?jc[n]?t.withTextFontFamily(jc[n]):Mc[n]?t.withTextFontWeight(Mc[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(Nc[n]):t};j({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textsc`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],props:{numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0},handler({parser:e,funcName:t},n){let r=n[0];return{type:`text`,mode:e.mode,body:M(r),font:t}},mathmlBuilder(e,t){let n=Pc(e,t);return Ba(Ka(e.body,n))}}),j({type:`vcenter`,names:[`\\vcenter`],props:{numArgs:1,argTypes:[`original`],allowedInText:!1},handler({parser:e},t){return{type:`vcenter`,mode:e.mode,body:t[0]}},mathmlBuilder(e,t){let n=new N(`mtd`,[q(e.body,t)]);return n.style.padding=`0`,new N(`mtable`,[new N(`mtr`,[n])])}}),j({type:`verb`,names:[`\\verb`],props:{numArgs:0,allowedInText:!0},handler(e,t,n){throw new A(`\\verb ended by end of line instead of matching delimiter`)},mathmlBuilder(e,t){let n=new N(`mtext`,[new ba(Fc(e))]);return n.setAttribute(`mathvariant`,`monospace`),n}});var Fc=e=>e.body.replace(/ /g,e.star?`␣`:`\xA0`),Ic=oa,Lc=`[ \r ]`,Rc=`\\\\[a-zA-Z@]+`,zc=`\\\\[^\ud800-\udfff]`,Bc=`(${Rc})${Lc}*`,Vc=`\\\\( |[ \r ]+ ?)[ \r ]*`,Hc=`[̀-ͯ]`,Uc=RegExp(`${Hc}+$`),Wc=`(${Lc}+)|${Vc}|([!-\\[\\]-‧‪-퟿豈-￿]${Hc}*|[\ud800-\udbff][\udc00-\udfff]${Hc}*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|${Bc}|${zc})`,Gc=class{constructor(e,t){this.input=e,this.settings=t,this.tokenRegex=new RegExp(Wc,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){let e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new ko(`EOF`,new Oo(this,t,t));let n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new A(`Unexpected character: '${e[t]}'`,new ko(e[t],new Oo(this,t,t+1)));let r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){let t=e.indexOf(` `,this.tokenRegex.lastIndex);if(t===-1){if(this.tokenRegex.lastIndex=e.length,this.settings.strict)throw new A(`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode`)}else this.tokenRegex.lastIndex=t+1;return this.lex()}return new ko(r,new Oo(this,t,this.tokenRegex.lastIndex))}},Kc=class{constructor(e=Object.create(null),t=Object.create(null)){this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push(Object.create(null))}endGroup(){if(this.undefStack.length===0)throw new A(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);let e=this.undefStack.pop();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]===void 0?delete this.current[t]:this.current[t]=e[t])}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:this.builtins[e]}set(e,t,n=!1){if(n){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{let t=this.undefStack[this.undefStack.length-1];t&&!Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=this.current[e])}this.current[e]=t}},qc={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Jc=class{constructor(e,t,n){this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Kc(jo,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Gc(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken(),{tokens:r,end:n}=this.consumeArg([`]`])}else({tokens:r,start:t,end:n}=this.consumeArg());return this.pushToken(new ko(`EOF`,n.loc)),this.pushTokens(r),new ko(``,Oo.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){let t=[],n=e&&e.length>0;n||this.consumeSpaces();let r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new A(`Extra }`,i)}else if(i.text===`EOF`)throw new A(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new A(`The length of delimiters doesn't match the number of args!`);let n=t[0];for(let e=0;ethis.settings.maxExpand)throw new A(`Too many expansions: infinite loop or need to increase maxExpand setting`);let i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(let e=i.length-1;e>=0;--e){let t=i[e];if(t.text===`#`){if(e===0)throw new A(`Incomplete placeholder at end of macro body`,t);if(t=i[--e],t.text===`#`)i.splice(e+1,1);else if(/^[1-9]$/.test(t.text))i.splice(e,2,...a[t.text-1]);else throw new A(`Not a valid argument number`,t)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){let e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}throw Error()}expandMacro(e){return this.macros.has(e)?this.expandTokens([new ko(e)]):void 0}expandTokens(e){let t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){let e=this.stack.pop();e.treatAsRelax&&=(e.noexpand=!1,!1),t.push(e)}return t}expandMacroAsText(e){let t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){let t=this.macros.get(e);if(t==null)return t;if(e.length===1){let t=this.lexer.catcodes[e];if(t!=null&&t!==13)return}let n=typeof t==`function`?t(this):t;if(typeof n==`string`){let e=0;if(n.indexOf(`#`)!==-1){let t=n.replace(/##/g,``);for(;t.indexOf(`#`+(e+1))!==-1;)++e}let t=new Gc(n,this.settings),r=[],i=t.lex();for(;i.text!==`EOF`;)r.push(i),i=t.lex();return r.reverse(),{tokens:r,numArgs:e}}return n}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Ic,e)||Object.prototype.hasOwnProperty.call(P.math,e)||Object.prototype.hasOwnProperty.call(P.text,e)||Object.prototype.hasOwnProperty.call(qc,e)}isExpandable(e){let t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(Ic,e)&&!Ic[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},Yc=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Xc=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),Zc=Object.freeze({𝒜:`A`,ℬ:`B`,𝒞:`C`,𝒟:`D`,ℰ:`E`,ℱ:`F`,𝒢:`G`,ℋ:`H`,ℐ:`I`,𝒥:`J`,𝒦:`K`,ℒ:`L`,ℳ:`M`,𝒩:`N`,𝒪:`O`,𝒫:`P`,𝒬:`Q`,ℛ:`R`,𝒮:`S`,𝒯:`T`,𝒰:`U`,𝒱:`V`,𝒲:`W`,𝒳:`X`,𝒴:`Y`,𝒵:`Z`}),Qc={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},$c={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ď:`ď`,ḋ:`ḋ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ĺ:`ĺ`,ľ:`ľ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ď:`Ď`,Ḋ:`Ḋ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ť:`Ť`,Ṫ:`Ṫ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},el=[`bin`,`op`,`open`,`punct`,`rel`],tl=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/,nl=/^ *\\text/,rl=class e{constructor(e,t,n=!1){this.mode=`math`,this.gullet=new Jc(e,t,this.mode),this.settings=t,this.isPreamble=n,this.leftrightDepth=0,this.prevAtomType=``}expect(e,t=!0){if(this.fetch().text!==e)throw new A(`Expected '${e}', got '${this.fetch().text}'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);let e=this.parseExpression(!1);if(this.expect(`EOF`),this.isPreamble){let e=Object.create(null);return Object.entries(this.gullet.macros.current).forEach(([t,n])=>{e[t]=n}),this.gullet.endGroup(),e}let t=this.gullet.macros.get(`\\df@tag`);return this.gullet.endGroup(),t&&(this.gullet.macros.current[`\\df@tag`]=t),e}static get endOfExpression(){return[`}`,`\\endgroup`,`\\end`,`\\right`,`\\endtoggle`,`&`]}subparse(e){let t=this.nextToken;this.consume(),this.gullet.pushToken(new ko(`}`)),this.gullet.pushTokens(e);let n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n,r){let i=[];for(this.prevAtomType=``;;){this.mode===`math`&&this.consumeSpaces();let a=this.fetch();if(e.endOfExpression.indexOf(a.text)!==-1||n&&a.text===n||r&&a.text===`\\middle`||t&&Ic[a.text]&&Ic[a.text].infix)break;let o=this.parseAtom(n);if(!o)break;o.type!==`internal`&&(i.push(o),this.prevAtomType=o.type===`atom`?o.family:o.type)}return this.mode===`text`&&this.formLigatures(i),this.handleInfixNodes(i)}handleInfixNodes(e){let t=-1,n;for(let r=0;r=128||Uc.exec(t)){if(this.settings.strict&&this.mode===`math`)throw new A(`Unicode text character "${t[0]}" used in math mode`,e);r={type:`textord`,mode:`text`,loc:Oo.range(e),text:t}}else return null;if(this.consume(),n)for(let t=0;t0&&n[0].type&&n[0].type===`array`&&n[0].addEqnNum)&&r.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new A(`\\tag works only in display mode`);r.gullet.feed(`\\df@tag`),n=[{type:`tag`,mode:`text`,body:n,tag:r.parse()}]}return n},al=[2,2,3,3],ol=class e{constructor(e){this.level=e.level,this.color=e.color,this.font=e.font||``,this.fontFamily=e.fontFamily||``,this.fontSize=e.fontSize||1,this.fontWeight=e.fontWeight||``,this.fontShape=e.fontShape||``,this.maxSize=e.maxSize}extend(t){let n={level:this.level,color:this.color,font:this.font,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return new e(n)}withLevel(e){return this.extend({level:e})}incrementLevel(){return this.extend({level:Math.min(this.level+1,3)})}inSubOrSup(){return this.extend({level:al[this.level]})}withColor(e){return this.extend({color:e})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withFontSize(e){return this.extend({fontSize:e})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}getColor(){return this.color}},sl=`0.14.0`;function cl(e){let t={},n=0,r=document.getElementsByClassName(`tml-eqn`);for(let e of r)for(n+=1,e.setAttribute(`id`,`tml-eqn-`+String(n));e.tagName!==`mtable`;){if(e.getElementsByClassName(`tml-label`).length>0){let r=e.attributes.id.value;t[r]=String(n);break}e=e.parentElement}let i=document.getElementsByClassName(`tml-tageqn`);for(let e of i)if(e.getElementsByClassName(`tml-label`).length>0){let n=e.getElementsByClassName(`tml-tag`);if(n.length>0){let r=e.attributes.id.value;t[r]=n[0].textContent}}[...e.getElementsByClassName(`tml-ref`)].forEach(e=>{let n=e.getAttribute(`href`),r=t[n.slice(1)];e.className.indexOf(`tml-eqref`)===-1?(r=r.replace(/^\(/,``),r=r.replace(/\)$/,``)):(r.charAt(0)!==`(`&&(r=`(`+r),r.slice(-1)!==`)`&&(r+=`)`));let i=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mtext`);i.appendChild(document.createTextNode(r));let a=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`math`);a.appendChild(i),e.textContent=``,e.appendChild(a)})}var ll=function(e,t,n){let r=n,i=0,a=e.length;for(;rul(e.left)).join(`|`)+`)`);for(;n=e.search(i),n!==-1;){n>0&&(r.push({type:`text`,data:e.slice(0,n)}),e=e.slice(n));let i=t.findIndex(t=>e.startsWith(t.left));if(n=ll(t[i].right,e,t[i].left.length),n===-1)break;let a=e.slice(0,n+t[i].right.length),o=dl.test(a)?a:e.slice(t[i].left.length,n);r.push({type:`math`,data:o,rawData:a,display:t[i].display}),e=e.slice(n+t[i].right.length)}return e!==``&&r.push({type:`text`,data:e}),r},pl=[{left:`$$`,right:`$$`,display:!0},{left:`\\(`,right:`\\)`,display:!1},{left:`\\begin{equation}`,right:`\\end{equation}`,display:!0},{left:`\\begin{equation*}`,right:`\\end{equation*}`,display:!0},{left:`\\begin{align}`,right:`\\end{align}`,display:!0},{left:`\\begin{align*}`,right:`\\end{align*}`,display:!0},{left:`\\begin{alignat}`,right:`\\end{alignat}`,display:!0},{left:`\\begin{alignat*}`,right:`\\end{alignat*}`,display:!0},{left:`\\begin{gather}`,right:`\\end{gather}`,display:!0},{left:`\\begin{gather*}`,right:`\\end{gather*}`,display:!0},{left:`\\begin{CD}`,right:`\\end{CD}`,display:!0},{left:`\\ref{`,right:`}`,display:!1},{left:`\\eqref{`,right:`}`,display:!1},{left:`\\[`,right:`\\]`,display:!0}],ml={$:[{left:`$$`,right:`$$`,display:!0},{left:"$`",right:"`$",display:!1},{left:`$`,right:`$`,display:!1}],"(":[{left:`\\[`,right:`\\]`,display:!0},{left:`\\(`,right:`\\)`,display:!1}]},hl=[{left:`\\begin{equation}`,right:`\\end{equation}`,display:!0},{left:`\\begin{equation*}`,right:`\\end{equation*}`,display:!0},{left:`\\begin{align}`,right:`\\end{align}`,display:!0},{left:`\\begin{align*}`,right:`\\end{align*}`,display:!0},{left:`\\begin{alignat}`,right:`\\end{alignat}`,display:!0},{left:`\\begin{alignat*}`,right:`\\end{alignat*}`,display:!0},{left:`\\begin{gather}`,right:`\\end{gather}`,display:!0},{left:`\\begin{gather*}`,right:`\\end{gather*}`,display:!0},{left:`\\begin{CD}`,right:`\\end{CD}`,display:!0},{left:`\\ref{`,right:`}`,display:!1},{left:`\\eqref{`,right:`}`,display:!1}],gl=e=>e===`$`||e===`(`?ml[e]:e===`$+`||e===`(+`?ml[e.slice(0,1)].concat(hl):e===`ams`?hl:e===`all`?ml[`(`].concat(ml.$).concat(hl):pl,_l=function(e,t){let n=fl(e,t.delimiters);if(n.length===1&&n[0].type===`text`)return null;let r=document.createDocumentFragment();for(let e=0;ee.indexOf(` `+t+` `)===-1)&&vl(r,t)}}},yl=function(e,t){if(!e)throw Error(`No element provided to render`);let n={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);n.delimiters=n.fences?gl(n.fences):n.delimiters||pl,n.ignoredTags=n.ignoredTags||[`script`,`noscript`,`style`,`textarea`,`pre`,`code`,`option`],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||Object.create(null),vl(e,n),cl(e)},bl=function(e,t,n={}){t.textContent=``;let r=t.tagName.toLowerCase()===`math`;r&&(n.wrap=`none`);let i=Tl(e,n);r||i.children.length>1?(t.textContent=``,i.children.forEach(e=>{t.appendChild(e.toNode())})):t.appendChild(i.toNode())};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: Temml doesn't work in quirks mode. Make sure your website has a suitable doctype.`),bl=function(){throw new A(`Temml doesn't work in quirks mode.`)});var xl=function(e,t){return Tl(e,t).toMarkup()},Sl=function(e,t){return il(e,new aa(t))},Cl=function(e,t){let n=new aa(t);if(n.macros=Object.create(null),!(typeof e==`string`||e instanceof String))throw TypeError(`Temml can only parse string typed expression`);let r=new rl(e,n,!0);return delete r.gullet.macros.current[`\\df@tag`],r.parse()},wl=function(e,t,n){if(n.throwOnError||!(e instanceof A))throw e;let r=new ha([`temml-error`],[new ga(t+` `+e.toString())]);return r.style.color=n.errorColor,r.style.whiteSpace=`pre-line`,r},Tl=function(e,t){let n=new aa(t);try{return Za(il(e,n),e,new ol({level:n.displayMode?X.DISPLAY:X.TEXT,maxSize:n.maxSize}),n)}catch(t){return wl(t,e,n)}},El={version:sl,render:bl,renderToString:xl,renderMathInElement:yl,postProcess:cl,ParseError:A,definePreamble:Cl,__parse:Sl,__renderToMathMLTree:Tl,__defineSymbol:F,__defineMacro:Z},Dl=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/,Ol=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/,kl=/^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;function Al(e={}){return{extensions:[Ml(e,jl(e,!1)),Nl(e,jl(e,!0))]}}function jl(e,t){return n=>El.renderToString(n.text,{...e,displayMode:n.displayMode})+(t?` `:``)}function Ml(e,t){let n=e&&e.nonStandard,r=n?Ol:Dl;return{name:`inlineKatex`,level:`inline`,start(e){let t,i=e;for(;i;){if(t=i.indexOf(`$`),t===-1)return;if((n?t>-1:t===0||i.charAt(t-1)===` `)&&i.substring(t).match(r))return t;i=i.substring(t+1).replace(/^\$+/,``)}},tokenizer(e,t){let n=e.match(r);if(n)return{type:`inlineKatex`,raw:n[0],text:n[2].trim(),displayMode:n[1].length===2}},renderer:t}}function Nl(e,t){return{name:`blockKatex`,level:`block`,tokenizer(e,t){let n=e.match(kl);if(n)return{type:`blockKatex`,raw:n[0],text:n[2].trim(),displayMode:n[1].length===2}},renderer:t}}var Pl=e=>e.replace(/[&<>"']/g,e=>`&#${e.charCodeAt(0)};`),Fl=new Hi({gfm:!0});Fl.use(Al({throwOnError:!1,strict:!1,nonStandard:!0}));var Il=/^\\\((.+?)\\\)|^\\\[(.+?)\\\]/s;Fl.use({extensions:[{name:`bracketedKatex`,level:`inline`,start:e=>e.search(/\\[([]/),tokenizer(e){let t=Il.exec(e);if(!t)return;let[n,r,i]=t;return{type:`inlineKatex`,raw:n,text:(r??i).trim(),displayMode:i!==void 0}}}]}),Fl.use({renderer:{html:({text:e})=>Pl(e),link({href:e,tokens:t}){let n=this.parser.parseInline(t);return/^(https?:|mailto:)/i.test(e)?`${n}`:n},image:({text:e})=>Pl(e)}});var Ll=new Map,Rl=e=>Fl.parse(e,{async:!1});function zl(e){let t=Ll.get(e);return t===void 0&&(Ll.size>500&&Ll.clear(),t=Fl.parseInline(e,{async:!1}),Ll.set(e,t)),t}var Bl=st({open:0,message:null,onSave:null}),Vl=0;function Hl(e=null,t=null){Bl.value={open:++Vl,message:e,onSave:t}}var Ul=()=>{Bl.value={...Bl.value,open:0,onSave:null}},Wl=({label:e,hint:t,children:n})=>E(`label`,{children:[e,n,E(`small`,{children:t})]});function Gl(){let{open:e,message:t,onSave:n}=Bl.value,r=Re(null);Ie(()=>{let t=r.current;e&&!t.open?t.showModal():!e&&t.open&&t.close()},[e]);let i=qn();return E(`dialog`,{ref:r,"aria-labelledby":`aiam-settings-title`,onClose:Ul,children:e>0&&E(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),r=e=>String(t.get(e)??``);Yn({apiKey:r(`apiKey`),endpoint:r(`endpoint`),model:r(`model`),effort:r(`effort`)}),Ul(),n?.()},children:[E(`h2`,{id:`aiam-settings-title`,children:`AI marking settings`}),t&&E(`p`,{class:`message`,children:t}),E(Wl,{label:`API key`,hint:`Leave blank for endpoints that don't need one.`,children:E(`input`,{name:`apiKey`,type:`password`,autocomplete:`off`,defaultValue:i.apiKey??``})}),E(Wl,{label:`API endpoint`,hint:`Any OpenAI-compatible base URL.`,children:E(`input`,{name:`endpoint`,placeholder:`https://openrouter.ai/api/v1`,defaultValue:i.endpoint})}),E(Wl,{label:`Model`,hint:`Vision-capable models are preferred, and needed to mark drawings.`,children:E(`input`,{name:`model`,placeholder:`google/gemini-3.8-flash`,defaultValue:i.model})}),E(Wl,{label:`Reasoning effort`,hint:`Leave blank if your endpoint rejects the reasoning_effort parameter.`,children:E(`input`,{name:`effort`,list:`aiam-efforts`,defaultValue:i.effort})}),E(`datalist`,{id:`aiam-efforts`,children:[`minimal`,`low`,`medium`,`high`].map(e=>E(`option`,{value:e},e))}),E(`div`,{class:`actions`,children:[E(`button`,{type:`button`,onClick:Ul,children:`Cancel`}),E(`button`,{type:`submit`,children:`Save`})]})]},e)})}var Kl=({d:e})=>E(`svg`,{viewBox:`0 0 20 20`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.4`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:e&&E(`path`,{d:e})}),ql={met:{label:`Met`,icon:`M6 10.4l2.7 2.7L14.2 7.3`},partial:{label:`Partly met`,icon:`M6.5 10h7`},not_met:{label:`Not met`,icon:`M7 7l6 6M13 7l-6 6`}};function Jl(e,t){return t==null?[`var(--accent)`,`AI mark`]:e>=t?[`var(--good)`,`Full marks`]:e>=t/2?[`var(--warn)`,`Nearly there`]:[`var(--bad)`,e>0?`Keep going`:`Not yet`]}function Yl({criterion:e,done:t}){let n=t||e.comment!==void 0?e.status:void 0,r=n!==void 0&&Object.hasOwn(ql,n)?ql[n]:null;return E(`div`,{class:`criterion`,children:[E(`span`,{class:`status ${r?n:``} ${r||t?``:`pending`}`,title:r?.label,children:E(Kl,{d:r?.icon})}),E(`div`,{children:[e.criterion&&E(`b`,{class:`html`,dangerouslySetInnerHTML:{__html:`${zl(String(e.criterion))}: `}}),typeof e.comment==`string`&&E(`span`,{class:`html`,dangerouslySetInnerHTML:{__html:zl(e.comment)}})]})]})}function Xl({mark:e,max:t,criteria:n}){let[r,i]=Jl(e,t),a=n.filter(e=>e.status===`met`).length,o=n.filter(e=>e.status===`partial`).length,s=n.length?`${a} of ${n.length} ${n.length===1?`criterion`:`criteria`} met${o?` · ${o} partly met`:``}`:``;return E(`div`,{class:`score`,children:[E(`div`,{class:`ring`,style:{"--p":t?Math.min(100,Math.max(0,100*e/t)):100,"--tone":r},children:[e,t!=null&&`/${t}`]}),E(`div`,{children:[E(`h3`,{children:i}),s&&E(`p`,{children:s})]})]})}var Zl=e=>e<1e3?String(e):`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`,Ql=e=>`${Zl(e.prompt)} in · ${Zl(e.cached)} cached · ${Zl(e.completion)} out`;function $l({turn:e}){return E(`div`,{class:`turn`,children:[E(`div`,{class:`question`,children:e.question}),e.reply&&E(`div`,{class:`html markdown answer`,dangerouslySetInnerHTML:{__html:Rl(e.reply)}}),!e.reply&&e.phase===`working`&&E(`p`,{class:`shimmer answer`,children:`Thinking...`}),e.phase===`stopped`&&E(`p`,{class:`note muted`,children:`Stopped.`}),e.phase===`error`&&E(`p`,{class:`note error`,children:e.error})]})}function eu({busy:e,onSend:t}){let n=()=>{!e&&Rn.value.trim()&&t(Rn.value)};return E(`form`,{class:`ask`,onSubmit:t=>{t.preventDefault(),e?Vn():n()},children:[E(`textarea`,{rows:1,placeholder:`Ask a follow-up…`,"aria-label":`Ask a follow-up question`,value:Rn.value,onInput:e=>Rn.value=e.currentTarget.value,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),n())}}),E(`button`,{type:`submit`,title:e?`Stop`:`Send`,disabled:!e&&!Rn.value.trim(),children:E(Kl,{d:e?`M7 7h6v6H7z`:`M10 15V5M5.5 9.5L10 5l4.5 4.5`})})]})}function tu(){let e=Ln.value,t=Re(null),n=Re(!0);if(Le(()=>{let e=t.current;e&&n.current&&(e.scrollTop=e.scrollHeight)}),!e.key)return null;let r=e.phase!==`working`,i=Nn(e.text),a=i&&`json`in i&&Array.isArray(i.json.criteria)?i.json.criteria.filter(e=>e&&typeof e==`object`&&(!r||e.criterion||e.comment)):[],o=i&&`json`in i&&typeof i.json.improvement==`string`?i.json.improvement.trim():``,s=e.phase===`done`?Fn(i):null,{chat:c}=e,l=c[c.length-1],u=l?l.usage:e.usage;return E(`div`,{class:`panel`,children:[E(`div`,{class:`panel-head`,children:[`AI marking`,E(`span`,{class:`model`,title:u?`${e.model}\n${Ql(u)}`:e.model,children:e.model.split(`/`).pop()}),E(`button`,{type:`button`,onClick:()=>Hl(),children:`Settings`})]}),E(`div`,{class:`panel-scroll`,ref:t,onScroll:e=>{let t=e.currentTarget;n.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},children:[E(`div`,{class:`panel-body`,children:[a.map((e,t)=>E(Yl,{criterion:e,done:r},t)),o&&E(`div`,{class:`improvement`,children:[E(`b`,{children:`To improve:`}),` `,E(`span`,{class:`html`,dangerouslySetInnerHTML:{__html:zl(o)}})]}),i&&`markdown`in i&&E(`div`,{class:`html markdown`,dangerouslySetInnerHTML:{__html:Rl(i.markdown)}}),!i&&e.phase===`working`&&E(`p`,{class:`shimmer`,children:`Marking your answer...`}),!i&&e.phase===`done`&&E(`p`,{class:`note error`,children:`The model's response couldn't be read.`}),e.phase===`stopped`&&E(`p`,{class:`note muted`,children:`Stopped.`}),e.phase===`error`&&E(`p`,{class:`note error`,children:e.error})]}),s!==null&&E(Xl,{mark:s,max:e.max,criteria:a}),c.length>0&&E(`div`,{class:`chat`,children:c.map((e,t)=>E($l,{turn:e},t))})]}),e.phase===`done`&&i&&E(eu,{busy:l?.phase===`working`,onSend:e=>{n.current=!0,Kn(e)}})]})}function nu(e,t){let n=e.attachShadow({mode:`open`});return n.append(Object.assign(document.createElement(`style`),{textContent:Xn})),ge(t,n),e}var ru=document.createElement(`span`);ru.style.display=`contents`;var iu=document.createElement(`div`);function au(){let e=qt();if(!e)return;let t=Jn();t.apiKey===void 0?Hl(`Enter your API key to start marking.`,au):(Gn(e,t),ou())}function ou(){let e=Kt(),t=qt();e&&t&&Jt()?ru.nextElementSibling!==e&&e.before(ru):ru.remove();let{key:n}=Ln.value;if(t&&n&&t.href!==n&&Hn(),t&&Ln.value.key){let e=Qt(t);iu.nextElementSibling!==e&&e.before(iu)}else iu.remove()}nu(ru,E(Qn,{onMark:au,onStop:Vn})),nu(iu,E(tu,{})),document.body.append(nu(document.createElement(`div`),E(Gl,{}))),ve(`Settings`,()=>Hl());var su=0;new MutationObserver(()=>{clearTimeout(su),su=setTimeout(ou,50)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`href`]}),ou()})();