From b052505306485bd8fdfdaf42d6f648f92602aea5 Mon Sep 17 00:00:00 2001 From: Lee McPherson Date: Sat, 16 Nov 2024 17:04:23 -0800 Subject: [PATCH] Clean up a lot of !-- undefined and !== '' --- siunitx.js | 2 +- src/angMethods.ts | 21 ++++++++------------- src/complexMethods.ts | 4 +--- src/error/errors.ts | 2 ++ src/error/resource.en.json | 3 ++- src/numDisplayMethods.ts | 10 +++++----- src/numMethods.ts | 21 +++++++++------------ src/numPostProcessMethods.ts | 11 +++++------ src/options/options.ts | 29 ++++------------------------- src/qtyMethods.ts | 32 +++++++++++--------------------- src/unitMethods.ts | 5 +---- 11 files changed, 49 insertions(+), 91 deletions(-) diff --git a/siunitx.js b/siunitx.js index f7e858d..c9aae92 100644 --- a/siunitx.js +++ b/siunitx.js @@ -1 +1 @@ -(function(){"use strict";var __webpack_modules__={660:function(e,n,t){t.d(n,{W:function(){return s}});var r=t(516),i=JSON.parse('{"Bi":"Invalid control sequence at the end of the %1 option.","lJ":"A comparator has already been set. %1 is already present, but you\'re trying to add %2.","L$":"Couldn\'t parse %1. Option \\"exponent-threshold\\" must be in the form of \\"min-number:max-number\\".","xg":"There are two many semi-colons. Should only be two at most.","Gx":"%1 contains invalid characters and cannot be parsed by siunitx for the ang macro.","Kv":"%1 contains invalid characters and cannot be parsed by siunitx for the num macro.","sT":"Key %1 accepts only values of type %2.","kq":"%1 is detected as a literal unit. These are forbidden globally. Use interpreted units instead (i.e. \\\\kilo\\\\gram).","Eh":"The unit macro, %1, has not been defined.","mu":"Trying to close an uncertainty that doesn\'t exist.","P4":"Uncertainty was already closed."}');function a(e,n){for(var t=0;te.length)&&(n=e.length);for(var t=0,r=new Array(n);t=o)for(var d=-1!==c?c:t,f=-1!==p?p:t,g=i(l?[d,f+1]:[m.length-d,-f],2),h=g[0],b=g[1],v=h;v>=0&&v0?(e.fractional=e.whole.slice(r,e.whole.length),e.whole=e.whole.slice(0,r),""!==e.fractional&&(e.decimal=t["output-decimal-marker"])):r<0&&"full"===t["uncertainty-mode"]&&(e.fractional="".padEnd(Math.abs(r),"0")+e.whole,e.whole="0",e.decimal=t["output-decimal-marker"])}}else if(+(e.whole+e.decimal+e.fractional)<1){for(var i=0,a=0;a=0){for(var i=0;ie.length)&&(n=e.length);for(var t=0,r=new Array(n);t0?e.uncertainty[e.uncertainty.length-1]:e}function parseDigits(e,n){var t=getLastNumPiece(n);""!==t.exponentMarker?t.exponent+=e:""!==t.decimal?t.fractional+=e:t.whole+=e}function parseDecimals(e,n){getLastNumPiece(n).decimal+=e}function parseComparators(e,n){var t=getLastNumPiece(n);if(""!==t.prefix)throw _error_errors__WEBPACK_IMPORTED_MODULE_5__.W.ComparatorAlreadySet(t.prefix,e);t.prefix+=e}function parseExponentMarkers(e,n){n.exponentMarker+=e}function parseSigns(e,n){var t=getLastNumPiece(n);""!==t.exponentMarker?t.exponentSign+=e:t.sign+=e}function parseOpenUncertainty(e,n){var t=Object.assign(Object.assign({},UncertaintyDefault),{type:"bracket"});n.uncertainty.push(t)}function parseCloseUncertainty(e,n){if(0===n.uncertainty.length)throw new mathjax_full_js_input_tex_TexError__WEBPACK_IMPORTED_MODULE_0__.Z("50","Trying to close an uncertainty that doesn't exist.");var t=n.uncertainty[n.uncertainty.length-1];if(t.completed)throw new mathjax_full_js_input_tex_TexError__WEBPACK_IMPORTED_MODULE_0__.Z("51","Uncertainty was already closed.");t.completed=!0}function parseUncertaintySigns(e,n){var t=Object.assign(Object.assign({},UncertaintyDefault),{type:"pm"});n.uncertainty.push(t)}function parseIgnore(){}function generateNumberMapping(e){for(var n=new Map,t=/\\(?:[a-zA-Z]+|[\uD800-\uDBFF].|.)|[\uD800-\uDBFF].|[^\s\\]/g,r=function(){var r=_slicedToArray(a[i],2),o=r[0],s=r[1],l=e[o];if(l.match(/(?:^|[^\\])(?:\\\\)*\\$/))throw _error_errors__WEBPACK_IMPORTED_MODULE_5__.W.BadOptionChars(o);(l.match(t)||[]).forEach((function(e){if(n.has(e)&&"input-uncertainty-signs"===o){var t=n.get(e);n.set(e,(function(e,n){(""===n.whole&&""===n.decimal?t:parseUncertaintySigns)(e,n)}))}else n.set(e,s)}))},i=0,a=[["input-comparators",parseComparators],["input-signs",parseSigns],["input-digits",parseDigits],["input-decimal-markers",parseDecimals],["input-open-uncertainty",parseOpenUncertainty],["input-close-uncertainty",parseCloseUncertainty],["input-uncertainty-signs",parseUncertaintySigns],["input-exponent-markers",parseExponentMarkers],["input-ignore",parseIgnore]];i>","\\gg").replace("<=","\\le").replace(">=","\\ge").replace("+-","\\pm");var i,a=generateNumberPiece(),o=new mathjax_full_js_input_tex_TexParser__WEBPACK_IMPORTED_MODULE_1__.Z(n,e.stack.env,e.configuration);for(o.i=0;o.i=0;s--){0===+(a.uncertainty[s].whole+(""!==a.uncertainty[s].decimal?".":"")+a.uncertainty[s].fractional)&&a.uncertainty.splice(s,1)}return a}function processNumber(parser){var globalOptions=Object.assign({},parser.options.siunitx),localOptions=(0,_options_options__WEBPACK_IMPORTED_MODULE_4__.b9)(parser,globalOptions);Object.assign(globalOptions,localOptions);var text=parser.GetArgument("num");if(globalOptions["parse-numbers"]){if(globalOptions["evaluate-expression"]){var expression=globalOptions.expression;expression=expression.replace("#1",text),text=eval(expression).toString()}var num=parseNumber(parser,text,globalOptions);(0,_numPostProcessMethods__WEBPACK_IMPORTED_MODULE_3__.V)(parser,num,globalOptions);var mmlNode=(0,_numDisplayMethods__WEBPACK_IMPORTED_MODULE_2__.co)(num,parser,globalOptions);return mmlNode}var mml=new mathjax_full_js_input_tex_TexParser__WEBPACK_IMPORTED_MODULE_1__.Z(text,parser.stack.env,parser.configuration).mml();return mml}},569:function(e,n,t){t.d(n,{V:function(){return m},c:function(){return s}});var r=t(660),i=t(759);function a(e,n,t){var r=JSON.parse(JSON.stringify(n)),a=(+(r.sign+r.whole+r.decimal+r.fractional+(""!==r.exponent?"e"+r.exponentSign+r.exponent:""))).toExponential(),o=(0,i.p3)(e,a,t),s=0;if(""!==r.fractional)for(var l=r.fractional.length-1;l>=0&&"0"===r.fractional[l];l--)s++;if(""!==r.whole&&r.fractional.length===s)for(var u=r.whole.length-1;u>=0&&"0"===r.whole[u];u--)s++;for(var c=0;c0&&(o.decimal="."),r)r[p]=o[p];return r}function o(e,n){if(e){for(var t=n-+(e.exponentSign+e.exponent),r=Math.sign(t),i=0;i0?(e.whole=e.whole+e.fractional.slice(0,1),e.fractional=e.fractional.slice(1,e.fractional.length)):e.whole=e.whole+"0":e.whole.length>0?(e.fractional=e.whole.slice(e.whole.length-1,e.whole.length)+e.fractional,e.whole=e.whole.slice(0,e.whole.length-1)):e.fractional="0"+e.fractional;""!==e.fractional&&""===e.decimal&&(e.decimal="."),e.exponent=Math.abs(n).toString(),e.exponentSign=Math.sign(n)<0?"-":""}}function s(e,n,t){var r=a(e,n,t);Object.assign(n,r),o(n,t["fixed-exponent"])}var l=new Map([["input",function(){}],["fixed",s],["engineering",function(e,n,t){var r=a(e,n,t);Object.assign(n,r);for(var i=+(n.exponentSign+n.exponent);i%3!=0;)i--;o(n,i)}],["scientific",function(e,n,t){var r=a(e,n,t);Object.assign(n,r)}],["threshold",function(e,n,t){var i=t["exponent-thresholds"].split(":");if(2!==i.length)throw r.W.ExponentThresholdsError(t["exponent-thresholds"]);var o=a(e,n,t),s=+(o.exponentSign+o.exponent);s>+i[0]&&s<+i[1]||Object.assign(n,o)}]]);function u(e,n,t){var r=!1;return n>5?r=!0:5===n&&(r=!t||e%2!=0),r}function c(e,n){var t="",r=new Array,i=+e[n]+1,a=0===i;r.push(i);for(var o=n-1;o>=0;o--)a?(a=0===(i=+e[o]+1),r.push(i)):(i=+e[o],r.push(i));return r.reverse(),r.forEach((function(e){return t+=e})),t}function p(e,n,t){if(0===Math.abs(+(n.whole+n.decimal+n.fractional+(""!==n.exponentMarker?"e":"")+n.exponentSign+n.exponent)))if("0"!==t["round-minimum"]){n.prefix="\\lt";var r=(0,i.p3)(e,t["round-minimum"],t);n.sign=r.sign,n.whole=r.whole,n.decimal=r.decimal,n.fractional=r.fractional,n.exponentMarker=r.exponentMarker,n.exponentSign=r.exponentSign,n.exponent=r.exponent}else t["round-zero-positive"]&&(n.sign="")}var _=new Map([["none",function(){}],["places",function(e,n,t){if(0===n.uncertainty.length){if(n.fractional.length>t["round-precision"]){var r=+n.fractional.slice(t["round-precision"],t["round-precision"]+1),i=+n.fractional.slice(t["round-precision"]-1,t["round-precision"]),a="0"===n.whole?0:n.whole.length;if(u(i,r,"even"===t["round-half"])){var o=c(("0"===n.whole?"":n.whole)+n.fractional,a+t["round-precision"]-1);n.whole=o.slice(0,a),n.fractional=o.slice(a,o.length)}else n.fractional=n.fractional.slice(0,t["round-precision"])}else if(n.fractional.lengtht["round-precision"]){var i,a=+r.slice(t["round-precision"],t["round-precision"]+1);i=u(+r.slice(t["round-precision"]-1,t["round-precision"]),a,"even"===t["round-half"])?c(r,t["round-precision"]-1):r.slice(0,t["round-precision"]);var o="0"===n.whole?0:n.whole.length;if(i.length>=o)n.fractional=0===o?"".padEnd(n.fractional.length-(+n.fractional).toString().length,"0"):"",n.fractional+=i.slice(o,i.length);else{n.fractional="",n.decimal="";var s=o-i.length;n.whole=i;for(var l=0;l0){n.uncertainty.forEach((function(e){if("pm"===e.type&&+(e.whole+e.decimal+e.fractional)<1){for(var n=0,t=0;t0){var n=+e.whole.slice(t["round-precision"],t["round-precision"]+1);u(+e.whole.slice(t["round-precision"]-1,t["round-precision"]),n,"even"===t["round-half"])?e.whole=c(e.whole,t["round-precision"]-1):e.whole=e.whole.slice(0,t["round-precision"])}}));var i=r-t["round-precision"];if(i>0){var a,o=n.whole+n.fractional,s=o.length-i,l=+o.slice(s,s+1);if((a=u(+o.slice(s-1,s),l,"even"===t["round-half"])?c(o,s-1):o.slice(0,s)).length>=n.whole.length)n.fractional=a.slice(n.whole.length,a.length);else{n.fractional="",n.decimal="";var p=n.whole.length-a.length;n.whole=a;for(var _=0;_0&&n.uncertainty[0].fractional.length>n.fractional.length&&(n.decimal||(n.decimal="."),n.fractional=n.fractional.padEnd(n.uncertainty[0].fractional.length,"0")),t["drop-uncertainty"]&&n.uncertainty.splice(0,n.uncertainty.length),t["drop-exponent"]&&(n.exponentMarker="",n.exponentSign="",n.exponent=""),_.get(t["round-mode"])(e,n,t),t["drop-zero-decimal"]&&0==+n.fractional&&(n.fractional="",n.decimal=""),t["minimum-integer-digits"]>0){var r=t["minimum-integer-digits"]-n.whole.length;if(r>0)for(var i=0;i0){var a=t["minimum-decimal-digits"]-n.fractional.length;if(a>0)for(var o=0;o\\approx\\ge\\geq\\gg\\le\\leq\\ll\\sim","input-decimal-markers":".,","input-digits":"0123456789","input-exponent-markers":"dDeE","input-ignore":"","input-open-uncertainty":"(","input-signs":"+-\\pm\\mp","input-uncertainty-signs":"\\pm\\mp","parse-numbers":!0,"retain-explicit-decimal-marker":!1,"retain-explicit-plus":!1,"retain-negative-zero":!1,"retain-zero-uncertainty":!1}),{"drop-exponent":!1,"drop-uncertainty":!1,"drop-zero-decimal":!1,"exponent-mode":"input","exponent-thresholds":"-3:3","fixed-exponent":0,"minimum-integer-digits":0,"minimum-decimal-digits":0,"round-half":"up","round-minimum":"0","round-mode":"none","round-pad":!0,"round-precision":2,"round-zero-positive":!0}),{"bracket-ambiguous-numbers":!0,"bracket-negative-numbers":!1,"digit-group-size":3,"digit-group-first-size":-1,"digit-group-other-size":-1,"exponent-base":"10","exponent-product":"\\times","group-digits":"all","group-minimum-digits":5,"group-separator":"\\,","negative-color":"","output-close-uncertainty":")","output-decimal-marker":".","output-exponent-marker":"","output-open-uncertainty":"(","print-implicit-plus":!1,"print-unity-mantissa":!0,"print-zero-exponent":!1,"print-zero-integer":!0,"tight-spacing":!1,"uncertainty-descriptor-mode":"bracket-separator","uncertainty-descriptor-separator":"\\","uncertainty-descriptors":"","uncertainty-mode":"compact","uncertainty-separator":"","zero-decimal-as-symbol":!1,"zero-symbol":"\\mbox{---}"}),o=Object.assign(Object.assign({},a),{"angle-mode":"input","angle-symbol-degree":"\\degree","angle-symbol-minute":"'","angle-symbol-over-decimal":!1,"angle-symbol-second":"''","angle-separator":"","fill-angle-degrees":!1,"fill-angle-minutes":!1,"fill-angle-seconds":!1,"number-angle-product":""}),s=Object.assign(Object.assign(Object.assign({},a),i),{"allow-quantity-breaks":!1,"extract-mass-in-kilograms":!0,"prefix-mode":"input","quantity-product":"\\,","separate-uncertainty-units":"bracket"}),l=t(660);t(106);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var r,i,a=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(a.push(r.value),!n||a.length!==n);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw i}}return a}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return p(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);te.length)&&(n=e.length);for(var t=0,r=new Array(n);t1&&void 0!==arguments[1]&&arguments[1],o={},s=e,l=!0;s;){var c=u(s,["=",","],i,l),p=a(c,3);if(t=p[0],n=p[1],s=p[2],l=!1,"="===n){var _=u(s,[","],i),m=a(_,3);r=m[0],n=m[1],s=m[2],r="false"===r||"true"===r?JSON.parse(r):r,o[t]=r}else t&&(o[t]=!0)}return o}function l(e,n){if(0===n)return e.replace(/^\s+/,"").replace(/([^\\\s]|^)((?:\\\\)*(?:\\\s)?)?\s+$/,"$1$2");for(;n>0;)e=e.trim().slice(1,-1),n--;return e}function u(e,n){for(var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.length,o=0,s="",u=0,c=0,p=!0;uo&&(c=o),p=!1}s+=_}if(o)throw new r.Z("ExtraOpenMissingClose","Extra open brace or missing close brace");return i&&c?["","",l(s,1)]:[l(s,t?Math.min(1,c):c),"",e.slice(u)]}t(128).Z.keyvalOptions=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=s(e,i);if(n)for(var o=0,l=Object.keys(a);o2&&void 0!==arguments[2]&&arguments[2];if("["!==this.GetNext())return n;for(var i=++this.i,a=0,o=0;this.i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==t.return||t.return()}finally{if(s)throw a}}}}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=o))break;i=l}}catch(e){s.e(e)}finally{s.f()}var u=t[0];if(""!==u.prefix){var c=(null!==u.power?+u.power:1)*("denominator"===u.position?-1:1);for(i+=(u.prefix?_units__WEBPACK_IMPORTED_MODULE_6__.g5.get(u.prefix):1)*c;!_units__WEBPACK_IMPORTED_MODULE_6__.g5.revHas(i);)i++}u.prefix=_units__WEBPACK_IMPORTED_MODULE_6__.g5.revGet(i);var p=i-o;n.exponent=Math.abs(p).toString(),n.exponentSign=Math.sign(p)>0?"":"-",(0,_numPostProcessMethods__WEBPACK_IMPORTED_MODULE_3__.c)(e,n,r)}}function extractExponent(e,n,t,r){if(null!==t){for(var i=0,a=0;a0?"":"-",n.exponentMarker||(n.exponentMarker="e")}}var prefixModeMap=new Map([["input",function(){}],["combine-exponent",combineExponent],["extract-exponent",extractExponent]]);function findUncertaintyNode(e){var n,t=_createForOfIteratorHelper(e.childNodes);try{for(t.s();!(n=t.n()).done;){var r=n.value;if(r){if(null!==r.attributes)if(-1!==r.attributes.getExplicitNames().indexOf("data-siunitx-uncertainty"))return r;var i=findUncertaintyNode(r);if(null!==i)return i}}}catch(e){t.e(e)}finally{t.f()}return null}var separateUncertaintyUnitsMmlMap=new Map([["single",function(e,n,t,r,i){var a=r.create("node","inferredMrow",[],{});return a.appendChild(e),a.appendChild(t),a.appendChild(n),a}],["bracket",function(e,n,t,r,i){var a,o=r.create("node","inferredMrow",[],{}),s=null,l=_createForOfIteratorHelper(e.childNodes);try{for(l.s();!(a=l.n()).done;){var u=findUncertaintyNode(a.value);if(null!==u){s=u;break}}}catch(e){l.e(e)}finally{l.f()}if(null!==s){var c=r.create("token","mo",{},i["output-open-uncertainty"]),p=r.create("token","mo",{},i["output-close-uncertainty"]);return o.appendChild(c),o.appendChild(e),o.appendChild(p),o.appendChild(t),o.appendChild(n),o}return o.appendChild(e),o.appendChild(t),o.appendChild(n),o}],["repeat",function(e,n,t,r,i){var a,o=null,s=_createForOfIteratorHelper(e.childNodes);try{for(s.s();!(a=s.n()).done;){var l=findUncertaintyNode(a.value);if(null!==l){o=l;break}}}catch(e){s.e(e)}finally{s.f()}if(null!==o){var u=o.parent,c=u.childNodes.indexOf(o);return t?(u.childNodes.splice(c,0,t,n),u.appendChild(t),u.appendChild(n)):(u.childNodes.splice(c,0,n),u.appendChild(n)),e}var p=r.create("node","inferredMrow",[],{});return p.appendChild(e),p.appendChild(t),p.appendChild(n),p}]]),separateUncertaintyUnitsMap=new Map([["single",function(e,n,t){return e+t["quantity-product"]+n}],["bracket",function(e,n,t){return-1===e.indexOf("\\pm")?e+t["quantity-product"]+n:t["output-open-uncertainty"]+e+t["output-close-uncertainty"]+t["quantity-product"]+n}],["repeat",function(e,n,t){for(var r=e.split("\\pm"),i="",a=0;a0){var l=s[0],u=l.childNodes[0].getText().split(r["output-decimal-marker"]);if(u.length>1){var c=e.create("node","inferredMrow",[],{});c.appendChild(e.create("token","mn",{},u[0]));var p=e.create("node","mover",[],{accent:i});c.appendChild(p),p.appendChild(e.create("token","mo",{},".")),p.appendChild(new a.Z("\\class{MathML-Unit}{\\mathrm{"+t+"}}",e.stack.env,e.configuration).mml()),c.appendChild(e.create("token","mn",{},u[1])),l.parent.replaceChild(c,l),o=n}}return o}var _=new Map([["input",function(){}],["arc",function(e){if(null===e.minutes&&null===e.seconds&&""!==e.degrees.decimal){var n=+("0."+e.degrees.fractional);if(e.degrees.fractional="",e.degrees.decimal="",0!==n){var t=60*n;e.minutes=(0,l.Fw)(),e.minutes.whole=Math.floor(t).toString();var r=(t+"").split(".");if(r.length>1){var i=60*+("."+r[1]);e.seconds=(0,l.Fw)(),e.seconds.whole=Math.floor(i).toString();var a=(i+"").split(".");a.length>1&&(e.seconds.decimal=".",e.seconds.fractional=a[1])}}}}],["decimal",function(e){var n=0;void 0!==e.seconds&&null!==e.seconds&&(n=+e.seconds.whole/60,e.seconds=null),void 0!==e.minutes&&null!==e.minutes&&(n=(+e.minutes.whole+n)/60,e.minutes=null);var t=((n=+e.degrees.whole+n)+"").split(".");e.degrees.whole=t[0],t.length>1&&(e.degrees.decimal=".",e.degrees.fractional=t[1])}]]);function m(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("ang"),i=c(e,r,n);_.get(n["angle-mode"])(i);var o=function(e,n,t){var r,i,o,l=e.create("node","inferredMrow",[],{}),u=+(n.degrees.whole+(""!==n.degrees.decimal?".":"")+n.degrees.fractional);if(!n.degrees.whole&&t["fill-angle-degrees"]&&("-"===n.minutes.sign?(n.degrees.sign="-",n.minutes.sign=""):"-"===n.seconds.sign&&(n.degrees.sign="-",n.seconds.sign=""),n.degrees.whole="0"),0!==u||"0"===n.degrees.whole||t["fill-angle-degrees"]){var c=(0,s.rW)(n.degrees,e,t);t["angle-symbol-over-decimal"]&&(r=p(e,c,t["angle-symbol-degree"],t,!0)),r||((r=e.create("node","inferredMrow",[],{})).appendChild(c),r.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+t["angle-symbol-degree"]+"}}",e.stack.env,e.configuration).mml()))}if(void 0!==n.minutes&&null!==n.minutes){var _=+(n.minutes.whole+(""!==n.minutes.decimal?".":"")+n.minutes.fractional),m="\\mathrm{"+t["angle-symbol-minute"]+"}";if("\\mathrm{'}"===m&&(m=1===_?"\\arialabel{degree-minute}{\\degreeminute}":"\\arialabel{degree-minutes}{\\degreeminute}"),0!==_||"0"===n.minutes.whole||t["fill-angle-minutes"]){0===_&&t["fill-angle-minutes"]&&("-"===n.seconds.sign&&(n.minutes.sign="-",n.seconds.sign=""),n.minutes.whole="0");var d=(0,s.rW)(n.minutes,e,t);t["angle-symbol-over-decimal"]&&(i=p(e,d,m,t,!1)),i||((i=e.create("node","inferredMrow",[],{})).appendChild(d),i.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+m+"}}",e.stack.env,e.configuration).mml()))}}if(void 0!==n.seconds&&null!==n.seconds){var f=+(n.seconds.whole+(""!==n.seconds.decimal?".":"")+n.seconds.fractional),g="\\mathrm{"+t["angle-symbol-second"]+"}";if("\\mathrm{''}"===g&&(g=1===f?"\\arialabel{degree-second}{\\degreesecond}":"\\arialabel{degree-seconds}{\\degreesecond}"),0!==f||"0"===n.seconds.whole||t["fill-angle-seconds"]){0===f&&t["fill-angle-seconds"]&&(n.seconds.whole="0");var h=(0,s.rW)(n.seconds,e,t);t["angle-symbol-over-decimal"]&&(o=p(e,h,g,t,!1)),o||((o=e.create("node","inferredMrow",[],{})).appendChild(h),o.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+g+"}}",e.stack.env,e.configuration).mml()))}}return r&&l.appendChild(r),r&&(i||o)&&""!==t["angle-separator"]&&l.appendChild(new a.Z(t["angle-separator"],e.stack.env,e.configuration).mml()),i&&l.appendChild(i),i&&o&&""!==t["angle-separator"]&&l.appendChild(new a.Z(t["angle-separator"],e.stack.env,e.configuration).mml()),o&&l.appendChild(o),l}(e,i,n);return o}var d=t(679),f=t(489),g=t(196),h=function(e,n){var t=e.ParseArg(n);if(!g.Z.isInferred(t))return t;var r=g.Z.getChildren(t);if(1===r.length)return r[0];var i=e.create("node","mrow");return g.Z.copyChildren(t,i),g.Z.copyAttributes(t,i),i},b=t(564),v=t(569),x={real:Object.assign({},l.$4),imaginary:Object.assign({},l.$4),inputMode:"cartesian"};function y(e,n,t){var r=Object.assign({},x);if(n.includes(":")){r.inputMode="polar";var i=n.match(/(.+):(.+)/);r.real=(0,l.p3)(e,i[1],t),r.imaginary=(0,l.p3)(e,i[2],t)}else{var a=new RegExp("[".concat(t["input-complex-root"],"]"));if(n.match(a)){var o=/[+-](?![^+-]*[+-])/,s=n.match(o),u=n.split(o);if(u.length>1){r.real=(0,l.p3)(e,u[0].trim(),t);var c=u[1].replace(a,"").trim();c||(c="1"),r.imaginary=(0,l.p3)(e,s+c,t)}else{var p=u[0].replace(a,"");p||(p="1"),r.imaginary=(0,l.p3)(e,p,t)}}else r.real=(0,l.p3)(e,n,t)}return r}function M(e,n,t){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=(0,l.Yc)(n.real),a=(0,l.Yc)(n.imaginary),o=Math.hypot(i,a),s=Math.atan2(a,i);r&&(s=s/2/Math.PI*360),n.real=(0,l.p3)(e,o.toString(),t),n.imaginary=(0,l.p3)(e,s.toString(),t)}function O(e,n,t){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=(0,l.Yc)(n.real),a=(0,l.Yc)(n.imaginary);r&&(a=2*a*Math.PI/360);var o=i*Math.cos(a),s=i*Math.sin(a);n.real=(0,l.p3)(e,o.toString(),t),n.imaginary=(0,l.p3)(e,s.toString(),t)}function w(e,n,t){var r=(0,s.co)(e.real,n,t),i=n.create("node","inferredMrow",[],{});i.appendChild(r);var o=(0,l.Yc)(e.imaginary);if(0!==o)if("polar"===e.inputMode&&"input"===t["complex-mode"]||"polar"===t["complex-mode"]){var u=new a.Z(t["complex-symbol-angle"],n.stack.env,n.configuration).mml();i.appendChild(u);var c=(0,s.co)(e.imaginary,n,t);if(i.appendChild(c),"degrees"===t["complex-angle-unit"]){var p=new a.Z(t["complex-symbol-degree"],n.stack.env,n.configuration).mml();i.appendChild(p)}}else{var _="-"===e.imaginary.sign?"-":"+";if(e.imaginary.sign="",0!==(0,l.Yc)(e.real)||"-"===_){var m=new a.Z(_,n.stack.env,n.configuration).mml();i.appendChild(m)}if("before-number"===t["complex-root-position"]){var d=new a.Z(t["output-complex-root"],n.stack.env,n.configuration).mml();i.appendChild(d)}if(1!==o||t["print-complex-unity"]){var f=(0,s.co)(e.imaginary,n,t);i.appendChild(f)}if("after-number"===t["complex-root-position"]){var g=new a.Z(t["output-complex-root"],n.stack.env,n.configuration).mml();i.appendChild(g)}}return i}var E=t(286),P=t(599);var k=t(278);var C=t(460);t(106);function D(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var A={"\\num":function(e){e.Push((0,l.tL)(e))},"\\ang":function(e){e.Push(m(e))},"\\unit":function(e){e.Push((0,f.PM)(e))},"\\qty":function(e){(0,d.Pm)(e)},"\\numlist":function(e){(0,E.e5)(e)},"\\qtylist":function(e){(0,k._)(e)},"\\numproduct":function(e){(0,P._)(e)},"\\qtyproduct":function(e){(0,C.E)(e)},"\\numrange":function(e){!function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("firstNum"),i=e.GetArgument("lastNum");if(n["parse-numbers"]){var o=(0,l.p3)(e,r,n),c=(0,l.p3)(e,i,n);if("individual"===n["range-exponents"])(0,v.V)(e,o,n),(0,v.V)(e,c,n);else{var p=o.exponentSign+o.exponent,_=Object.assign(n,{exponentMode:"fixed",fixedExponent:p});(0,v.V)(e,o,n),(0,v.V)(e,c,_)}var m=E.OH.get(n["range-exponents"])([o,c],e,n),d=(0,s.co)(m.numbers[0],e,n),f=new a.Z("\\text{".concat(n["range-phrase"],"}"),e.stack.env,e.configuration).mml(),g=(0,s.co)(m.numbers[1],e,n),h=[];m.leading&&h.push(m.leading),h=h.concat(d).concat(f).concat(g),m.trailing&&(h=h.concat(m.trailing)),h.forEach((function(n){e.Push(n)}))}else{var b=new a.Z(r+i,e.stack.env,e.configuration).mml();e.Push(b)}}(e)},"\\qtyrange":function(e){!function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("firstNum"),i=e.GetArgument("lastNum"),o=e.GetArgument("unit"),s=-1===o.indexOf("\\"),c=(0,f.n2)(e,o,n,t,s);if(n["parse-numbers"]){var p=(0,l.p3)(e,r,n),_=(0,l.p3)(e,i,n);if("individual"===n["range-exponents"])(0,v.V)(e,p,n),(0,v.V)(e,_,n);else{var m=p.exponentSign+p.exponent,g=Object.assign(n,{exponentMode:"fixed",fixedExponent:m});(0,v.V)(e,p,n),(0,v.V)(e,_,g)}var h=(0,f.Ho)(e,c,n,s),b=new a.Z(h,e.stack.env,e.configuration).mml(),x=(0,d.mD)(e,n);if(x){var y=e.create("node","inferredMrow",[],{});y.appendChild(x),y.appendChild(b),b=y}var M=E.OH.get(n["range-exponents"])([p,_],e,n),O=k.N.get(n["range-units"])(M,b,e,n),w=new a.Z("\\text{".concat(n["range-phrase"],"}"),e.stack.env,e.configuration).mml(),P=e.create("node","inferredMrow",[],{});M.leading&&P.appendChild(M.leading),P.appendChild(O.numbers[0]),P.appendChild(w),P.appendChild(O.numbers[1]),M.trailing&&P.appendChild(M.trailing),e.Push(P)}else{var C=new a.Z(r+i,e.stack.env,e.configuration).mml();e.Push(C)}}(e)},"\\complexnum":function(e){e.Push(function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("complexnum");if(n["parse-numbers"]){var i=y(e,r,n);return"polar"===n["complex-mode"]&&"polar"!==i.inputMode?M(e,i,n,"degrees"===n["complex-angle-unit"]):"cartesian"===n["complex-mode"]&&"cartesian"!==i.inputMode&&O(e,i,n,"degrees"===n["complex-angle-unit"]),(0,v.V)(e,i.real,n),(0,v.V)(e,i.imaginary,n),w(i,e,n)}return new a.Z(r,e.stack.env,e.configuration).mml()}(e))},"\\complexqty":function(e){!function(e){var n,t,r=Object.assign({},e.options.siunitx),i=(0,u.b9)(e,r);Object.assign(r,i);var o,l=e.GetArgument("complexnum"),c=e.GetArgument("unit"),p=-1===c.indexOf("\\"),_=(0,f.n2)(e,c,r,i,p),m=y(e,l,r);"polar"===r["complex-mode"]&&"polar"!==m.inputMode?M(e,m,r):"cartesian"===r["complex-mode"]&&"cartesian"!==m.inputMode&&O(e,m,r),null===(n=d.pk.get(r["prefix-mode"]))||void 0===n||n(e,m.real,_,r),null===(t=d.pk.get(r["prefix-mode"]))||void 0===t||t(e,m.imaginary,_,r),(0,v.V)(e,m.real,r),(0,v.V)(e,m.imaginary,r);var g=w(m,e,r);e.Push(g);var h=null,b=r["quantity-product"].trimStart();if(""!==b){var x=new a.Z(b,e.stack.env,e.configuration).mml(),E=(0,s.uI)(x);h=e.create("token","mo",{},E)}e.Push(h),o=(0,f.Ho)(e,_,r,p);var P=new a.Z(o,e.stack.env,e.configuration).mml();e.Push(P)}(e)},"@{}S":function(e){},"\\tablenum":function(e){},"\\sisetup":function(e){(0,u.hD)(e)},"\\DeclareSIUnit":function(e){var n=e.configuration.packageData.get("siunitx"),t=n[T],r=n[I],i=(0,u.b9)(e,u.Sk),a=e.GetArgument("DeclareSIUnit"),o=e.GetArgument("DeclareSIUnit");t.set(a,o),void 0!==i&&r.set(a,i)},"\\DeclareSIQualifier":function(e){},"\\DeclareSIPower":function(e){}},T="siunitxUnits",I="siunitxUnitOptions";new i.eJ("angchar-symbols",(function(e,n){var t=n.attributes||{};t.mathvariant=b.d.Variant.NORMAL,t.class="MathML-Unit";var r=e.create("token","mi"),i=e.create("token","mi",t,n.char),a=e.create("node","msup",[r,i]);e.Push(a)}),{degreeminute:["\u2032",{}],degreesecond:["\u2033",{}]}),new i.QQ("siunitxMap",{num:["siunitxToken","num"],ang:["siunitxToken","ang"],complexnum:["siunitxToken","complexnum"],unit:["siunitxToken","unit"],qty:["siunitxToken","qty"],complexqty:["siunitxToken","complexqty"],numlist:["siunitxToken","numlist"],numproduct:["siunitxToken","numproduct"],numrange:["siunitxToken","numrange"],qtylist:["siunitxToken","qtylist"],qtyrange:["siunitxToken","qtyrange"],qtyproduct:["siunitxToken","qtyproduct"],DeclareSIUnit:["siunitxToken","DeclareSIUnit"],sisetup:["siunitxToken","sisetup"],arialabel:["Arialabel","arialabel"],data:["Dataset","data"]},{siunitxToken:function(e,n){var t;null===(t=A[n])||void 0===t||t.call(A,e)},Arialabel:function(e,n){var t=e.GetArgument(n),r=h(e,n);g.Z.setAttribute(r,"aria-label",t),e.Push(r)},Dataset:function(e,n){var t=e.GetArgument(n),r=h(e,n),i=t.split("=");g.Z.setAttribute(r,"data-"+i[0],i[1]),e.Push(r)}});r.VK.create("siunitx",{handler:{macro:["angchar-symbols","siunitxMap"]},options:{siunitx:u.Sk},config:function(e,n){var t;n.parseOptions.packageData.set("siunitx",(D(t={},T,new Map),D(t,I,new Map),t))}})},489:function(e,n,t){t.d(n,{Ho:function(){return g},PM:function(){return b},n2:function(){return h}});var r=t(516),i=t(693),a=t(660),o=t(124),s=t(936),l=t(763);function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return c(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t2&&void 0!==arguments[2]&&arguments[2],i="";e.cancel&&(i+="\\cancel{"),e.highlight&&(i+="{\\color{".concat(e.highlight,"}")),i+=n["unit-font-command"]+"{",n["power-half-as-sqrt"]&&e.power&&.5===e.power?(i+="\\sqrt{\\class{MathML-Unit}{".concat(e.prefix).concat(e.symbol,"}}"),e.power=null):i+="\\class{MathML-Unit}{".concat(e.prefix).concat(e.symbol,"}"),e.qualifier&&(i+=null===(t=d.get(n["qualifier-mode"]))||void 0===t?void 0:t(e.qualifier,n["qualifier-phrase"])),i+="}";var a=void 0!==e.power&&null!==e.power?r?Math.abs(e.power*("denominator"===e.position?-1:1)):e.power*("denominator"===e.position?-1:1):r?Math.abs(1*("denominator"===e.position?-1:1)):1*("denominator"===e.position?-1:1);return null!=a&&1!==a&&(i+="^{"+a+"}"),e.cancel&&(i+="}"),e.highlight&&(i+="}"),{latex:i,superscriptPresent:1!==a}}function g(e,n,t,r){var i=!1,a="";""!==t["unit-color"]?(a+="{\\color{".concat(t["unit-color"],"}"),i=!0):""!==t.color&&(a+="{\\color{".concat(t.color,"}"),i=!0);var o=!1;if(n.length>=2&&1===n.filter((function(e){var n=null!==e.power&&void 0!==e.power?e.power*("denominator"===e.position?-1:1):1;return-1===Math.sign(n)})).length&&"single-symbol"===t["per-mode"]&&(o=!0),r){var s="",l=null;n.every((function(e){return"denominator"!==e.position||(l=e,!1)})),n.forEach((function(e){e===l&&(s+=" / ");var n=f(e,t);""!==s&&(s+=t["inter-unit-product"]),s+=n.latex})),a+=s}else{var u=0,c=0;if(n.forEach((function(e){"denominator"===e.position||null!==e.power&&void 0!==e.power&&e.power<0?c++:u++}),0),"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||o||"single-symbol"===t["per-mode"]&&1===c&&u>0){var p="",_="",m=!1;n.forEach((function(e){var n;"denominator"===e.position||null!==e.power&&void 0!==e.power&&e.power<0?(n=f(e,t,"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||"single-symbol"===t["per-mode"]||o),""!==_&&("repeated-symbol"===t["per-mode"]?(n.superscriptPresent&&(_+=t["per-symbol-script-correction"]),_+=t["per-symbol"]):_+=t["inter-unit-product"]),_+=n.latex):(n=f(e,t,"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||"single-symbol"===t["per-mode"]||o),m=n.superscriptPresent,""!==p&&(p+=t["inter-unit-product"]),p+=n.latex)})),""===p&&""!==_&&(p="1"),""!==_?(c>1&&"symbol"===t["per-mode"]&&t["bracket-unit-denominator"]&&(_="("+_+")"),"fraction"===t["per-mode"]?a+=t["fraction-command"]+"{"+p+"}{"+_+"}":"repeated-symbol"===t["per-mode"]||"symbol"===t["per-mode"]||o||"single-symbol"===t["per-mode"]?a+=p+(m?t["per-symbol-script-correction"]:"")+t["per-symbol"]+_:console.log("shouldn't be here")):a+=p}else{"power-positive-first"===t["per-mode"]&&(n=n.sort((function(e,n){var t=null!==e.power&&void 0!==e.power?e:1;"denominator"===e.position&&(t=-t);var r=null!==n.power&&void 0!==n.power?n:1;return"denominator"===n.position&&(r=-r),tr?-1:0})));var d="";n.forEach((function(e){var n=f(e,t);""!==d&&(d+=t["inter-unit-product"]),d+=n.latex})),a+=d}}return i&&(a+="}"),a}function h(e,n,t,a,o){var s=new Array;if(o)s.push.apply(s,u(function(e,n){var t=new Array,r=new i.Z(n,e.stack.env,e.configuration);r.i=0;var a={position:"numerator"},o=!1,s="";for(;r.ie.length)&&(n=e.length);for(var t=0,r=new Array(n);te.length)&&(n=e.length);for(var t=0,r=new Array(n);te.length)&&(n=e.length);for(var t=0,r=new Array(n);t=o)for(var d=-1!==c?c:t,f=-1!==p?p:t,g=i(l?[d,f+1]:[m.length-d,-f],2),h=g[0],b=g[1],v=h;v>=0&&v0?(e.fractional=e.whole.slice(r,e.whole.length),e.whole=e.whole.slice(0,r),e.fractional&&(e.decimal=t["output-decimal-marker"])):r<0&&"full"===t["uncertainty-mode"]&&(e.fractional="".padEnd(Math.abs(r),"0")+e.whole,e.whole="0",e.decimal=t["output-decimal-marker"])}}else if(+(e.whole+e.decimal+e.fractional)<1){for(var i=0,a=0;a=0){for(var i=0;ie.length)&&(n=e.length);for(var t=0,r=new Array(n);t0?e.uncertainty[e.uncertainty.length-1]:e}function parseDigits(e,n){var t=getLastNumPiece(n);t.exponentMarker?t.exponent+=e:t.decimal?t.fractional+=e:t.whole+=e}function parseDecimals(e,n){getLastNumPiece(n).decimal+=e}function parseComparators(e,n){var t=getLastNumPiece(n);if(t.prefix)throw _error_errors__WEBPACK_IMPORTED_MODULE_5__.W.ComparatorAlreadySet(t.prefix,e);t.prefix+=e}function parseExponentMarkers(e,n){n.exponentMarker+=e}function parseSigns(e,n){var t=getLastNumPiece(n);t.exponentMarker?t.exponentSign+=e:t.sign+=e}function parseOpenUncertainty(e,n){var t=Object.assign(Object.assign({},UncertaintyDefault),{type:"bracket"});n.uncertainty.push(t)}function parseCloseUncertainty(e,n){if(0===n.uncertainty.length)throw new mathjax_full_js_input_tex_TexError__WEBPACK_IMPORTED_MODULE_0__.Z("50","Trying to close an uncertainty that doesn't exist.");var t=n.uncertainty[n.uncertainty.length-1];if(t.completed)throw new mathjax_full_js_input_tex_TexError__WEBPACK_IMPORTED_MODULE_0__.Z("51","Uncertainty was already closed.");t.completed=!0}function parseUncertaintySigns(e,n){var t=Object.assign(Object.assign({},UncertaintyDefault),{type:"pm"});n.uncertainty.push(t)}function parseIgnore(){}function generateNumberMapping(e){for(var n=new Map,t=/\\(?:[a-zA-Z]+|[\uD800-\uDBFF].|.)|[\uD800-\uDBFF].|[^\s\\]/g,r=function(){var r=_slicedToArray(a[i],2),o=r[0],s=r[1],l=e[o];if(l.match(/(?:^|[^\\])(?:\\\\)*\\$/))throw _error_errors__WEBPACK_IMPORTED_MODULE_5__.W.BadOptionChars(o);(l.match(t)||[]).forEach((function(e){if(n.has(e)&&"input-uncertainty-signs"===o){var t=n.get(e);n.set(e,(function(e,n){(""===n.whole&&""===n.decimal?t:parseUncertaintySigns)(e,n)}))}else n.set(e,s)}))},i=0,a=[["input-comparators",parseComparators],["input-signs",parseSigns],["input-digits",parseDigits],["input-decimal-markers",parseDecimals],["input-open-uncertainty",parseOpenUncertainty],["input-close-uncertainty",parseCloseUncertainty],["input-uncertainty-signs",parseUncertaintySigns],["input-exponent-markers",parseExponentMarkers],["input-ignore",parseIgnore]];i>","\\gg").replace("<=","\\le").replace(">=","\\ge").replace("+-","\\pm");var i,a=generateNumberPiece(),o=new mathjax_full_js_input_tex_TexParser__WEBPACK_IMPORTED_MODULE_1__.Z(n,e.stack.env,e.configuration);for(o.i=0;o.i=0;s--){0===+(a.uncertainty[s].whole+(a.uncertainty[s].decimal?".":"")+a.uncertainty[s].fractional)&&a.uncertainty.splice(s,1)}return a}function processNumber(parser){var globalOptions=Object.assign({},parser.options.siunitx),localOptions=(0,_options_options__WEBPACK_IMPORTED_MODULE_4__.b9)(parser,globalOptions);Object.assign(globalOptions,localOptions);var text=parser.GetArgument("num");if(globalOptions["parse-numbers"]){if(globalOptions["evaluate-expression"]){var expression=globalOptions.expression;expression=expression.replace("#1",text),text=eval(expression).toString()}var num=parseNumber(parser,text,globalOptions);(0,_numPostProcessMethods__WEBPACK_IMPORTED_MODULE_3__.V)(parser,num,globalOptions);var mmlNode=(0,_numDisplayMethods__WEBPACK_IMPORTED_MODULE_2__.co)(num,parser,globalOptions);return mmlNode}var mml=new mathjax_full_js_input_tex_TexParser__WEBPACK_IMPORTED_MODULE_1__.Z(text,parser.stack.env,parser.configuration).mml();return mml}},569:function(e,n,t){t.d(n,{V:function(){return m},c:function(){return s}});var r=t(660),i=t(759);function a(e,n,t){var r=JSON.parse(JSON.stringify(n)),a=(+(r.sign+r.whole+r.decimal+r.fractional+(r.exponent?"e"+r.exponentSign+r.exponent:""))).toExponential(),o=(0,i.p3)(e,a,t),s=0;if(r.fractional)for(var l=r.fractional.length-1;l>=0&&"0"===r.fractional[l];l--)s++;if(r.whole&&r.fractional.length===s)for(var u=r.whole.length-1;u>=0&&"0"===r.whole[u];u--)s++;for(var c=0;c0&&(o.decimal="."),r)r[p]=o[p];return r}function o(e,n){if(e){for(var t=n-+(e.exponentSign+e.exponent),r=Math.sign(t),i=0;i0?(e.whole=e.whole+e.fractional.slice(0,1),e.fractional=e.fractional.slice(1,e.fractional.length)):e.whole=e.whole+"0":e.whole.length>0?(e.fractional=e.whole.slice(e.whole.length-1,e.whole.length)+e.fractional,e.whole=e.whole.slice(0,e.whole.length-1)):e.fractional="0"+e.fractional;""!==e.fractional&&""===e.decimal&&(e.decimal="."),e.exponent=Math.abs(n).toString(),e.exponentSign=Math.sign(n)<0?"-":""}}function s(e,n,t){var r=a(e,n,t);Object.assign(n,r),o(n,t["fixed-exponent"])}var l=new Map([["input",function(){}],["fixed",s],["engineering",function(e,n,t){var r=a(e,n,t);Object.assign(n,r);for(var i=+(n.exponentSign+n.exponent);i%3!=0;)i--;o(n,i)}],["scientific",function(e,n,t){var r=a(e,n,t);Object.assign(n,r)}],["threshold",function(e,n,t){var i=t["exponent-thresholds"].split(":");if(2!==i.length)throw r.W.ExponentThresholdsError(t["exponent-thresholds"]);var o=a(e,n,t),s=+(o.exponentSign+o.exponent);s>+i[0]&&s<+i[1]||Object.assign(n,o)}]]);function u(e,n,t){var r=!1;return n>5?r=!0:5===n&&(r=!t||e%2!=0),r}function c(e,n){var t="",r=new Array,i=+e[n]+1,a=0===i;r.push(i);for(var o=n-1;o>=0;o--)a?(a=0===(i=+e[o]+1),r.push(i)):(i=+e[o],r.push(i));return r.reverse(),r.forEach((function(e){return t+=e})),t}function p(e,n,t){if(0===Math.abs(+(n.whole+n.decimal+n.fractional+(""!==n.exponentMarker?"e":"")+n.exponentSign+n.exponent)))if("0"!==t["round-minimum"]){n.prefix="\\lt";var r=(0,i.p3)(e,t["round-minimum"],t);n.sign=r.sign,n.whole=r.whole,n.decimal=r.decimal,n.fractional=r.fractional,n.exponentMarker=r.exponentMarker,n.exponentSign=r.exponentSign,n.exponent=r.exponent}else t["round-zero-positive"]&&(n.sign="")}var _=new Map([["none",function(){}],["places",function(e,n,t){if(0===n.uncertainty.length){if(n.fractional.length>t["round-precision"]){var r=+n.fractional.slice(t["round-precision"],t["round-precision"]+1),i=+n.fractional.slice(t["round-precision"]-1,t["round-precision"]),a="0"===n.whole?0:n.whole.length;if(u(i,r,"even"===t["round-half"])){var o=c(("0"===n.whole?"":n.whole)+n.fractional,a+t["round-precision"]-1);n.whole=o.slice(0,a),n.fractional=o.slice(a,o.length)}else n.fractional=n.fractional.slice(0,t["round-precision"])}else if(n.fractional.lengtht["round-precision"]){var i,a=+r.slice(t["round-precision"],t["round-precision"]+1);i=u(+r.slice(t["round-precision"]-1,t["round-precision"]),a,"even"===t["round-half"])?c(r,t["round-precision"]-1):r.slice(0,t["round-precision"]);var o="0"===n.whole?0:n.whole.length;if(i.length>=o)n.fractional=0===o?"".padEnd(n.fractional.length-(+n.fractional).toString().length,"0"):"",n.fractional+=i.slice(o,i.length);else{n.fractional="",n.decimal="";var s=o-i.length;n.whole=i;for(var l=0;l0){n.uncertainty.forEach((function(e){if("pm"===e.type&&+(e.whole+e.decimal+e.fractional)<1){for(var n=0,t=0;t0){var n=+e.whole.slice(t["round-precision"],t["round-precision"]+1);u(+e.whole.slice(t["round-precision"]-1,t["round-precision"]),n,"even"===t["round-half"])?e.whole=c(e.whole,t["round-precision"]-1):e.whole=e.whole.slice(0,t["round-precision"])}}));var i=r-t["round-precision"];if(i>0){var a,o=n.whole+n.fractional,s=o.length-i,l=+o.slice(s,s+1);if((a=u(+o.slice(s-1,s),l,"even"===t["round-half"])?c(o,s-1):o.slice(0,s)).length>=n.whole.length)n.fractional=a.slice(n.whole.length,a.length);else{n.fractional="",n.decimal="";var p=n.whole.length-a.length;n.whole=a;for(var _=0;_0&&n.uncertainty[0].fractional.length>n.fractional.length&&(n.decimal||(n.decimal="."),n.fractional=n.fractional.padEnd(n.uncertainty[0].fractional.length,"0")),t["drop-uncertainty"]&&n.uncertainty.splice(0,n.uncertainty.length),t["drop-exponent"]&&(n.exponentMarker="",n.exponentSign="",n.exponent=""),_.get(t["round-mode"])(e,n,t),t["drop-zero-decimal"]&&0==+n.fractional&&(n.fractional="",n.decimal=""),t["minimum-integer-digits"]>0){var r=t["minimum-integer-digits"]-n.whole.length;if(r>0)for(var i=0;i0){var a=t["minimum-decimal-digits"]-n.fractional.length;if(a>0)for(var o=0;o\\approx\\ge\\geq\\gg\\le\\leq\\ll\\sim","input-decimal-markers":".,","input-digits":"0123456789","input-exponent-markers":"dDeE","input-ignore":"","input-open-uncertainty":"(","input-signs":"+-\\pm\\mp","input-uncertainty-signs":"\\pm\\mp","parse-numbers":!0,"retain-explicit-decimal-marker":!1,"retain-explicit-plus":!1,"retain-negative-zero":!1,"retain-zero-uncertainty":!1}),{"drop-exponent":!1,"drop-uncertainty":!1,"drop-zero-decimal":!1,"exponent-mode":"input","exponent-thresholds":"-3:3","fixed-exponent":0,"minimum-integer-digits":0,"minimum-decimal-digits":0,"round-half":"up","round-minimum":"0","round-mode":"none","round-pad":!0,"round-precision":2,"round-zero-positive":!0}),{"bracket-ambiguous-numbers":!0,"bracket-negative-numbers":!1,"digit-group-size":3,"digit-group-first-size":-1,"digit-group-other-size":-1,"exponent-base":"10","exponent-product":"\\times","group-digits":"all","group-minimum-digits":5,"group-separator":"\\,","negative-color":"","output-close-uncertainty":")","output-decimal-marker":".","output-exponent-marker":"","output-open-uncertainty":"(","print-implicit-plus":!1,"print-unity-mantissa":!0,"print-zero-exponent":!1,"print-zero-integer":!0,"tight-spacing":!1,"uncertainty-descriptor-mode":"bracket-separator","uncertainty-descriptor-separator":"\\","uncertainty-descriptors":"","uncertainty-mode":"compact","uncertainty-separator":"","zero-decimal-as-symbol":!1,"zero-symbol":"\\mbox{---}"}),o=Object.assign(Object.assign({},a),{"angle-mode":"input","angle-symbol-degree":"\\degree","angle-symbol-minute":"'","angle-symbol-over-decimal":!1,"angle-symbol-second":"''","angle-separator":"","fill-angle-degrees":!1,"fill-angle-minutes":!1,"fill-angle-seconds":!1,"number-angle-product":""}),s=Object.assign(Object.assign(Object.assign({},a),i),{"allow-quantity-breaks":!1,"extract-mass-in-kilograms":!0,"prefix-mode":"input","quantity-product":"\\,","separate-uncertainty-units":"bracket"}),l=t(660);t(106);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var r,i,a=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(a.push(r.value),!n||a.length!==n);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw i}}return a}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return p(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);te.length)&&(n=e.length);for(var t=0,r=new Array(n);t1&&void 0!==arguments[1]&&arguments[1],o={},s=e,l=!0;s;){var c=u(s,["=",","],i,l),p=a(c,3);if(t=p[0],n=p[1],s=p[2],l=!1,"="===n){var _=u(s,[","],i),m=a(_,3);r=m[0],n=m[1],s=m[2],r="false"===r||"true"===r?JSON.parse(r):r,o[t]=r}else t&&(o[t]=!0)}return o}function l(e,n){if(0===n)return e.replace(/^\s+/,"").replace(/([^\\\s]|^)((?:\\\\)*(?:\\\s)?)?\s+$/,"$1$2");for(;n>0;)e=e.trim().slice(1,-1),n--;return e}function u(e,n){for(var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.length,o=0,s="",u=0,c=0,p=!0;uo&&(c=o),p=!1}s+=_}if(o)throw new r.Z("ExtraOpenMissingClose","Extra open brace or missing close brace");return i&&c?["","",l(s,1)]:[l(s,t?Math.min(1,c):c),"",e.slice(u)]}t(128).Z.keyvalOptions=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=s(e,i);if(n)for(var o=0,l=Object.keys(a);o2&&void 0!==arguments[2]&&arguments[2];if("["!==this.GetNext())return n;for(var i=++this.i,a=0,o=0;this.i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==t.return||t.return()}finally{if(s)throw a}}}}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=o))break;i=l}}catch(e){s.e(e)}finally{s.f()}var u=t[0];if(u.prefix){var c=(null!==u.power?+u.power:1)*("denominator"===u.position?-1:1);for(i+=(u.prefix?_units__WEBPACK_IMPORTED_MODULE_6__.g5.get(u.prefix):1)*c;!_units__WEBPACK_IMPORTED_MODULE_6__.g5.revHas(i);)i++}u.prefix=_units__WEBPACK_IMPORTED_MODULE_6__.g5.revGet(i);var p=i-o;n.exponent=Math.abs(p).toString(),n.exponentSign=Math.sign(p)>0?"":"-",(0,_numPostProcessMethods__WEBPACK_IMPORTED_MODULE_3__.c)(e,n,r)}}function extractExponent(e,n,t,r){if(null!==t){for(var i=0,a=0;a0?"":"-",n.exponentMarker||(n.exponentMarker="e")}}var prefixModeMap=new Map([["input",function(){}],["combine-exponent",combineExponent],["extract-exponent",extractExponent]]);function findUncertaintyNode(e){var n,t=_createForOfIteratorHelper(e.childNodes);try{for(t.s();!(n=t.n()).done;){var r=n.value;if(r){if(r.attributes)if(-1!==r.attributes.getExplicitNames().indexOf("data-siunitx-uncertainty"))return r;var i=findUncertaintyNode(r);if(i)return i}}}catch(e){t.e(e)}finally{t.f()}return null}var separateUncertaintyUnitsMmlMap=new Map([["single",function(e,n,t,r,i){var a=r.create("node","inferredMrow",[],{});return a.appendChild(e),a.appendChild(t),a.appendChild(n),a}],["bracket",function(e,n,t,r,i){var a,o=r.create("node","inferredMrow",[],{}),s=null,l=_createForOfIteratorHelper(e.childNodes);try{for(l.s();!(a=l.n()).done;){var u=findUncertaintyNode(a.value);if(u){s=u;break}}}catch(e){l.e(e)}finally{l.f()}if(s){var c=r.create("token","mo",{},i["output-open-uncertainty"]),p=r.create("token","mo",{},i["output-close-uncertainty"]);return o.appendChild(c),o.appendChild(e),o.appendChild(p),o.appendChild(t),o.appendChild(n),o}return o.appendChild(e),o.appendChild(t),o.appendChild(n),o}],["repeat",function(e,n,t,r,i){var a,o=null,s=_createForOfIteratorHelper(e.childNodes);try{for(s.s();!(a=s.n()).done;){var l=findUncertaintyNode(a.value);if(l){o=l;break}}}catch(e){s.e(e)}finally{s.f()}if(o){var u=o.parent,c=u.childNodes.indexOf(o);return t?(u.childNodes.splice(c,0,t,n),u.appendChild(t),u.appendChild(n)):(u.childNodes.splice(c,0,n),u.appendChild(n)),e}var p=r.create("node","inferredMrow",[],{});return p.appendChild(e),p.appendChild(t),p.appendChild(n),p}]]),separateUncertaintyUnitsMap=new Map([["single",function(e,n,t){return e+t["quantity-product"]+n}],["bracket",function(e,n,t){return-1===e.indexOf("\\pm")?e+t["quantity-product"]+n:t["output-open-uncertainty"]+e+t["output-close-uncertainty"]+t["quantity-product"]+n}],["repeat",function(e,n,t){for(var r=e.split("\\pm"),i="",a=0;a0){var l=s[0],u=l.childNodes[0].getText().split(r["output-decimal-marker"]);if(u.length>1){var c=e.create("node","inferredMrow",[],{});c.appendChild(e.create("token","mn",{},u[0]));var p=e.create("node","mover",[],{accent:i});c.appendChild(p),p.appendChild(e.create("token","mo",{},".")),p.appendChild(new a.Z("\\class{MathML-Unit}{\\mathrm{"+t+"}}",e.stack.env,e.configuration).mml()),c.appendChild(e.create("token","mn",{},u[1])),l.parent.replaceChild(c,l),o=n}}return o}var _=new Map([["input",function(){}],["arc",function(e){if(!e.minutes&&!e.seconds&&!e.degrees.decimal){var n=+("0."+e.degrees.fractional);if(e.degrees.fractional="",e.degrees.decimal="",0!==n){var t=60*n;e.minutes=(0,l.Fw)(),e.minutes.whole=Math.floor(t).toString();var r=(t+"").split(".");if(r.length>1){var i=60*+("."+r[1]);e.seconds=(0,l.Fw)(),e.seconds.whole=Math.floor(i).toString();var a=(i+"").split(".");a.length>1&&(e.seconds.decimal=".",e.seconds.fractional=a[1])}}}}],["decimal",function(e){var n=0;e.seconds&&null!==e.seconds&&(n=+e.seconds.whole/60,e.seconds=null),e.minutes&&null!==e.minutes&&(n=(+e.minutes.whole+n)/60,e.minutes=null);var t=((n=+e.degrees.whole+n)+"").split(".");e.degrees.whole=t[0],t.length>1&&(e.degrees.decimal=".",e.degrees.fractional=t[1])}]]);function m(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("ang"),i=c(e,r,n);_.get(n["angle-mode"])(i);var o=function(e,n,t){var r,i,o,l=e.create("node","inferredMrow",[],{}),u=+(n.degrees.whole+(""!==n.degrees.decimal?".":"")+n.degrees.fractional);if(!n.degrees.whole&&t["fill-angle-degrees"]&&("-"===n.minutes.sign?(n.degrees.sign="-",n.minutes.sign=""):"-"===n.seconds.sign&&(n.degrees.sign="-",n.seconds.sign=""),n.degrees.whole="0"),0!==u||"0"===n.degrees.whole||t["fill-angle-degrees"]){var c=(0,s.rW)(n.degrees,e,t);t["angle-symbol-over-decimal"]&&(r=p(e,c,t["angle-symbol-degree"],t,!0)),r||((r=e.create("node","inferredMrow",[],{})).appendChild(c),r.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+t["angle-symbol-degree"]+"}}",e.stack.env,e.configuration).mml()))}if(void 0!==n.minutes&&null!==n.minutes){var _=+(n.minutes.whole+(""!==n.minutes.decimal?".":"")+n.minutes.fractional),m="\\mathrm{"+t["angle-symbol-minute"]+"}";if("\\mathrm{'}"===m&&(m=1===_?"\\arialabel{degree-minute}{\\degreeminute}":"\\arialabel{degree-minutes}{\\degreeminute}"),0!==_||"0"===n.minutes.whole||t["fill-angle-minutes"]){0===_&&t["fill-angle-minutes"]&&("-"===n.seconds.sign&&(n.minutes.sign="-",n.seconds.sign=""),n.minutes.whole="0");var d=(0,s.rW)(n.minutes,e,t);t["angle-symbol-over-decimal"]&&(i=p(e,d,m,t,!1)),i||((i=e.create("node","inferredMrow",[],{})).appendChild(d),i.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+m+"}}",e.stack.env,e.configuration).mml()))}}if(n.seconds&&null!==n.seconds){var f=+(n.seconds.whole+(n.seconds.decimal?".":"")+n.seconds.fractional),g="\\mathrm{"+t["angle-symbol-second"]+"}";if("\\mathrm{''}"===g&&(g=1===f?"\\arialabel{degree-second}{\\degreesecond}":"\\arialabel{degree-seconds}{\\degreesecond}"),0!==f||"0"===n.seconds.whole||t["fill-angle-seconds"]){0===f&&t["fill-angle-seconds"]&&(n.seconds.whole="0");var h=(0,s.rW)(n.seconds,e,t);t["angle-symbol-over-decimal"]&&(o=p(e,h,g,t,!1)),o||((o=e.create("node","inferredMrow",[],{})).appendChild(h),o.appendChild(new a.Z(t["number-angle-product"]+"\\class{MathML-Unit}{\\mathrm{"+g+"}}",e.stack.env,e.configuration).mml()))}}return r&&l.appendChild(r),r&&(i||o)&&""!==t["angle-separator"]&&l.appendChild(new a.Z(t["angle-separator"],e.stack.env,e.configuration).mml()),i&&l.appendChild(i),i&&o&&""!==t["angle-separator"]&&l.appendChild(new a.Z(t["angle-separator"],e.stack.env,e.configuration).mml()),o&&l.appendChild(o),l}(e,i,n);return o}var d=t(679),f=t(489),g=t(196),h=function(e,n){var t=e.ParseArg(n);if(!g.Z.isInferred(t))return t;var r=g.Z.getChildren(t);if(1===r.length)return r[0];var i=e.create("node","mrow");return g.Z.copyChildren(t,i),g.Z.copyAttributes(t,i),i},b=t(564),v=t(569),x={real:Object.assign({},l.$4),imaginary:Object.assign({},l.$4),inputMode:"cartesian"};function y(e,n,t){var r=Object.assign({},x);if(n.includes(":")){r.inputMode="polar";var i=n.match(/(.+):(.+)/);r.real=(0,l.p3)(e,i[1],t),r.imaginary=(0,l.p3)(e,i[2],t)}else{var a=new RegExp("[".concat(t["input-complex-root"],"]"));if(n.match(a)){var o=/[+-](?![^+-]*[+-])/,s=n.match(o),u=n.split(o);if(u.length>1){r.real=(0,l.p3)(e,u[0].trim(),t);var c=u[1].replace(a,"").trim();c||(c="1"),r.imaginary=(0,l.p3)(e,s+c,t)}else{var p=u[0].replace(a,"");p||(p="1"),r.imaginary=(0,l.p3)(e,p,t)}}else r.real=(0,l.p3)(e,n,t)}return r}function M(e,n,t){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=(0,l.Yc)(n.real),a=(0,l.Yc)(n.imaginary),o=Math.hypot(i,a),s=Math.atan2(a,i);r&&(s=s/2/Math.PI*360),n.real=(0,l.p3)(e,o.toString(),t),n.imaginary=(0,l.p3)(e,s.toString(),t)}function O(e,n,t){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=(0,l.Yc)(n.real),a=(0,l.Yc)(n.imaginary);r&&(a=2*a*Math.PI/360);var o=i*Math.cos(a),s=i*Math.sin(a);n.real=(0,l.p3)(e,o.toString(),t),n.imaginary=(0,l.p3)(e,s.toString(),t)}function w(e,n,t){var r=(0,s.co)(e.real,n,t),i=n.create("node","inferredMrow",[],{});i.appendChild(r);var o=(0,l.Yc)(e.imaginary);if(0!==o)if("polar"===e.inputMode&&"input"===t["complex-mode"]||"polar"===t["complex-mode"]){var u=new a.Z(t["complex-symbol-angle"],n.stack.env,n.configuration).mml();i.appendChild(u);var c=(0,s.co)(e.imaginary,n,t);if(i.appendChild(c),"degrees"===t["complex-angle-unit"]){var p=new a.Z(t["complex-symbol-degree"],n.stack.env,n.configuration).mml();i.appendChild(p)}}else{var _="-"===e.imaginary.sign?"-":"+";if(e.imaginary.sign="",0!==(0,l.Yc)(e.real)||"-"===_){var m=new a.Z(_,n.stack.env,n.configuration).mml();i.appendChild(m)}if("before-number"===t["complex-root-position"]){var d=new a.Z(t["output-complex-root"],n.stack.env,n.configuration).mml();i.appendChild(d)}if(1!==o||t["print-complex-unity"]){var f=(0,s.co)(e.imaginary,n,t);i.appendChild(f)}if("after-number"===t["complex-root-position"]){var g=new a.Z(t["output-complex-root"],n.stack.env,n.configuration).mml();i.appendChild(g)}}return i}var E=t(286),P=t(599);var k=t(278);var C=t(460);t(106);function D(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var A={"\\num":function(e){e.Push((0,l.tL)(e))},"\\ang":function(e){e.Push(m(e))},"\\unit":function(e){e.Push((0,f.PM)(e))},"\\qty":function(e){(0,d.Pm)(e)},"\\numlist":function(e){(0,E.e5)(e)},"\\qtylist":function(e){(0,k._)(e)},"\\numproduct":function(e){(0,P._)(e)},"\\qtyproduct":function(e){(0,C.E)(e)},"\\numrange":function(e){!function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("firstNum"),i=e.GetArgument("lastNum");if(n["parse-numbers"]){var o=(0,l.p3)(e,r,n),c=(0,l.p3)(e,i,n);if("individual"===n["range-exponents"])(0,v.V)(e,o,n),(0,v.V)(e,c,n);else{var p=o.exponentSign+o.exponent,_=Object.assign(n,{exponentMode:"fixed",fixedExponent:p});(0,v.V)(e,o,n),(0,v.V)(e,c,_)}var m=E.OH.get(n["range-exponents"])([o,c],e,n),d=(0,s.co)(m.numbers[0],e,n),f=new a.Z("\\text{".concat(n["range-phrase"],"}"),e.stack.env,e.configuration).mml(),g=(0,s.co)(m.numbers[1],e,n),h=[];m.leading&&h.push(m.leading),h=h.concat(d).concat(f).concat(g),m.trailing&&(h=h.concat(m.trailing)),h.forEach((function(n){e.Push(n)}))}else{var b=new a.Z(r+i,e.stack.env,e.configuration).mml();e.Push(b)}}(e)},"\\qtyrange":function(e){!function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("firstNum"),i=e.GetArgument("lastNum"),o=e.GetArgument("unit"),s=-1===o.indexOf("\\"),c=(0,f.n2)(e,o,n,t,s);if(n["parse-numbers"]){var p=(0,l.p3)(e,r,n),_=(0,l.p3)(e,i,n);if("individual"===n["range-exponents"])(0,v.V)(e,p,n),(0,v.V)(e,_,n);else{var m=p.exponentSign+p.exponent,g=Object.assign(n,{exponentMode:"fixed",fixedExponent:m});(0,v.V)(e,p,n),(0,v.V)(e,_,g)}var h=(0,f.Ho)(e,c,n,s),b=new a.Z(h,e.stack.env,e.configuration).mml(),x=(0,d.mD)(e,n);if(x){var y=e.create("node","inferredMrow",[],{});y.appendChild(x),y.appendChild(b),b=y}var M=E.OH.get(n["range-exponents"])([p,_],e,n),O=k.N.get(n["range-units"])(M,b,e,n),w=new a.Z("\\text{".concat(n["range-phrase"],"}"),e.stack.env,e.configuration).mml(),P=e.create("node","inferredMrow",[],{});M.leading&&P.appendChild(M.leading),P.appendChild(O.numbers[0]),P.appendChild(w),P.appendChild(O.numbers[1]),M.trailing&&P.appendChild(M.trailing),e.Push(P)}else{var C=new a.Z(r+i,e.stack.env,e.configuration).mml();e.Push(C)}}(e)},"\\complexnum":function(e){e.Push(function(e){var n=Object.assign({},e.options.siunitx),t=(0,u.b9)(e,n);Object.assign(n,t);var r=e.GetArgument("complexnum");if(n["parse-numbers"]){var i=y(e,r,n);return"polar"===n["complex-mode"]&&"polar"!==i.inputMode?M(e,i,n,"degrees"===n["complex-angle-unit"]):"cartesian"===n["complex-mode"]&&"cartesian"!==i.inputMode&&O(e,i,n,"degrees"===n["complex-angle-unit"]),(0,v.V)(e,i.real,n),(0,v.V)(e,i.imaginary,n),w(i,e,n)}return new a.Z(r,e.stack.env,e.configuration).mml()}(e))},"\\complexqty":function(e){!function(e){var n,t,r=Object.assign({},e.options.siunitx),i=(0,u.b9)(e,r);Object.assign(r,i);var o,l=e.GetArgument("complexnum"),c=e.GetArgument("unit"),p=-1===c.indexOf("\\"),_=(0,f.n2)(e,c,r,i,p),m=y(e,l,r);"polar"===r["complex-mode"]&&"polar"!==m.inputMode?M(e,m,r):"cartesian"===r["complex-mode"]&&"cartesian"!==m.inputMode&&O(e,m,r),null===(n=d.pk.get(r["prefix-mode"]))||void 0===n||n(e,m.real,_,r),null===(t=d.pk.get(r["prefix-mode"]))||void 0===t||t(e,m.imaginary,_,r),(0,v.V)(e,m.real,r),(0,v.V)(e,m.imaginary,r);var g=w(m,e,r);e.Push(g);var h=null,b=r["quantity-product"].trimStart();if(b){var x=new a.Z(b,e.stack.env,e.configuration).mml(),E=(0,s.uI)(x);h=e.create("token","mo",{},E)}e.Push(h),o=(0,f.Ho)(e,_,r,p);var P=new a.Z(o,e.stack.env,e.configuration).mml();e.Push(P)}(e)},"@{}S":function(e){},"\\tablenum":function(e){},"\\sisetup":function(e){(0,u.hD)(e)},"\\DeclareSIUnit":function(e){var n=e.configuration.packageData.get("siunitx"),t=n[T],r=n[I],i=(0,u.b9)(e,u.Sk),a=e.GetArgument("DeclareSIUnit"),o=e.GetArgument("DeclareSIUnit");t.set(a,o),void 0!==i&&r.set(a,i)},"\\DeclareSIQualifier":function(e){},"\\DeclareSIPower":function(e){}},T="siunitxUnits",I="siunitxUnitOptions";new i.eJ("angchar-symbols",(function(e,n){var t=n.attributes||{};t.mathvariant=b.d.Variant.NORMAL,t.class="MathML-Unit";var r=e.create("token","mi"),i=e.create("token","mi",t,n.char),a=e.create("node","msup",[r,i]);e.Push(a)}),{degreeminute:["\u2032",{}],degreesecond:["\u2033",{}]}),new i.QQ("siunitxMap",{num:["siunitxToken","num"],ang:["siunitxToken","ang"],complexnum:["siunitxToken","complexnum"],unit:["siunitxToken","unit"],qty:["siunitxToken","qty"],complexqty:["siunitxToken","complexqty"],numlist:["siunitxToken","numlist"],numproduct:["siunitxToken","numproduct"],numrange:["siunitxToken","numrange"],qtylist:["siunitxToken","qtylist"],qtyrange:["siunitxToken","qtyrange"],qtyproduct:["siunitxToken","qtyproduct"],DeclareSIUnit:["siunitxToken","DeclareSIUnit"],sisetup:["siunitxToken","sisetup"],arialabel:["Arialabel","arialabel"],data:["Dataset","data"]},{siunitxToken:function(e,n){var t;null===(t=A[n])||void 0===t||t.call(A,e)},Arialabel:function(e,n){var t=e.GetArgument(n),r=h(e,n);g.Z.setAttribute(r,"aria-label",t),e.Push(r)},Dataset:function(e,n){var t=e.GetArgument(n),r=h(e,n),i=t.split("=");g.Z.setAttribute(r,"data-"+i[0],i[1]),e.Push(r)}});r.VK.create("siunitx",{handler:{macro:["angchar-symbols","siunitxMap"]},options:{siunitx:u.Sk},config:function(e,n){var t;n.parseOptions.packageData.set("siunitx",(D(t={},T,new Map),D(t,I,new Map),t))}})},489:function(e,n,t){t.d(n,{Ho:function(){return g},PM:function(){return b},n2:function(){return h}});var r=t(516),i=t(693),a=t(660),o=t(124),s=t(936),l=t(763);function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return c(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t2&&void 0!==arguments[2]&&arguments[2],i="";e.cancel&&(i+="\\cancel{"),e.highlight&&(i+="{\\color{".concat(e.highlight,"}")),i+=n["unit-font-command"]+"{",n["power-half-as-sqrt"]&&e.power&&.5===e.power?(i+="\\sqrt{\\class{MathML-Unit}{".concat(e.prefix).concat(e.symbol,"}}"),e.power=null):i+="\\class{MathML-Unit}{".concat(e.prefix).concat(e.symbol,"}"),e.qualifier&&(i+=null===(t=d.get(n["qualifier-mode"]))||void 0===t?void 0:t(e.qualifier,n["qualifier-phrase"])),i+="}";var a=void 0!==e.power&&null!==e.power?r?Math.abs(e.power*("denominator"===e.position?-1:1)):e.power*("denominator"===e.position?-1:1):r?Math.abs(1*("denominator"===e.position?-1:1)):1*("denominator"===e.position?-1:1);return null!=a&&1!==a&&(i+="^{"+a+"}"),e.cancel&&(i+="}"),e.highlight&&(i+="}"),{latex:i,superscriptPresent:1!==a}}function g(e,n,t,r){var i=!1,o="";""!==t["unit-color"]?(o+="{\\color{".concat(t["unit-color"],"}"),i=!0):""!==t.color&&(o+="{\\color{".concat(t.color,"}"),i=!0);var s=!1;if(n.length>=2&&1===n.filter((function(e){var n=null!==e.power&&void 0!==e.power?e.power*("denominator"===e.position?-1:1):1;return-1===Math.sign(n)})).length&&"single-symbol"===t["per-mode"]&&(s=!0),r){var l="",u=null;n.every((function(e){return"denominator"!==e.position||(u=e,!1)})),n.forEach((function(e){e===u&&(l+=" / ");var n=f(e,t);""!==l&&(l+=t["inter-unit-product"]),l+=n.latex})),o+=l}else{var c=0,p=0;if(n.forEach((function(e){"denominator"===e.position||null!==e.power&&void 0!==e.power&&e.power<0?p++:c++}),0),"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||s||"single-symbol"===t["per-mode"]&&1===p&&c>0){var _="",m="",d=!1;if(n.forEach((function(e){var n;"denominator"===e.position||null!==e.power&&void 0!==e.power&&e.power<0?(n=f(e,t,"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||"single-symbol"===t["per-mode"]||s),""!==m&&("repeated-symbol"===t["per-mode"]?(n.superscriptPresent&&(m+=t["per-symbol-script-correction"]),m+=t["per-symbol"]):m+=t["inter-unit-product"]),m+=n.latex):(n=f(e,t,"fraction"===t["per-mode"]||"symbol"===t["per-mode"]||"repeated-symbol"===t["per-mode"]||"single-symbol"===t["per-mode"]||s),d=n.superscriptPresent,""!==_&&(_+=t["inter-unit-product"]),_+=n.latex)})),""===_&&""!==m&&(_="1"),""!==m)if(p>1&&"symbol"===t["per-mode"]&&t["bracket-unit-denominator"]&&(m="("+m+")"),"fraction"===t["per-mode"])o+=t["fraction-command"]+"{"+_+"}{"+m+"}";else{if("repeated-symbol"!==t["per-mode"]&&"symbol"!==t["per-mode"]&&!s&&"single-symbol"!==t["per-mode"])throw a.W.DenominatorParsingError(m,t["per-mode"]);o+=_+(d?t["per-symbol-script-correction"]:"")+t["per-symbol"]+m}else o+=_}else{"power-positive-first"===t["per-mode"]&&(n=n.sort((function(e,n){var t=null!==e.power&&void 0!==e.power?e:1;"denominator"===e.position&&(t=-t);var r=null!==n.power&&void 0!==n.power?n:1;return"denominator"===n.position&&(r=-r),tr?-1:0})));var g="";n.forEach((function(e){var n=f(e,t);""!==g&&(g+=t["inter-unit-product"]),g+=n.latex})),o+=g}}return i&&(o+="}"),o}function h(e,n,t,a,o){var s=new Array;if(o)s.push.apply(s,u(function(e,n){var t=new Array,r=new i.Z(n,e.stack.env,e.configuration);r.i=0;var a={position:"numerator"},o=!1,s="";for(;r.ie.length)&&(n=e.length);for(var t=0,r=new Array(n);te.length)&&(n=e.length);for(var t=0,r=new Array(n);t globalOptions[k] = v); + Object.assign(globalOptions, localOptions); - + const text = parser.GetArgument('ang'); - // FIXME: processOption here twice in processAngle? - //processOptions(globalOptions, localOptionString); const ang = parseAngle(parser, text, globalOptions); // TODO: consider error checking result // Is there an exponent?? Throw an error... or ignore it? diff --git a/src/complexMethods.ts b/src/complexMethods.ts index 79499af..469bbb3 100644 --- a/src/complexMethods.ts +++ b/src/complexMethods.ts @@ -20,8 +20,6 @@ const ComplexDefault: IComplex = { }; export function parseComplexNumber(parser: TexParser, text: string, options: IOptions): IComplex { - // console.log("Complex text: "); - // console.log(text); const complex = { ...ComplexDefault }; // Check if polar input @@ -214,7 +212,7 @@ export function processComplexQuantity(parser: TexParser): void { let quantityProductNode = null; const trimmedQuantityProduct = globalOptions["quantity-product"].trimStart(); - if (trimmedQuantityProduct !== '') { + if (trimmedQuantityProduct) { const spacerNode = (new TexParser(trimmedQuantityProduct, parser.stack.env, parser.configuration)).mml(); const spacerUnicode = findInnerText(spacerNode); quantityProductNode = parser.create('token', 'mo', {}, spacerUnicode); diff --git a/src/error/errors.ts b/src/error/errors.ts index 43f48b3..0d8ea8d 100644 --- a/src/error/errors.ts +++ b/src/error/errors.ts @@ -24,5 +24,7 @@ export class siunitxError { static NoUncertaintyToClose = () => new TexError('siunitx:noUncertaintyToClose', data.noUncertaintyToClose); static UncertaintyAlreadyClosed = () => new TexError('siunitx:uncertaintyAlreadyClosed', data.uncertaintyAlreadyClosed); + + static DenominatorParsingError = (denominator:string, permode:string) => new TexError('siunitx:denominatorParsingError', data.denominatorParsingError, denominator, permode); } diff --git a/src/error/resource.en.json b/src/error/resource.en.json index 8fa56b3..4933771 100644 --- a/src/error/resource.en.json +++ b/src/error/resource.en.json @@ -9,5 +9,6 @@ "literalUnitsForbidden": "%1 is detected as a literal unit. These are forbidden globally. Use interpreted units instead (i.e. \\kilo\\gram).", "macroNotDefined": "The unit macro, %1, has not been defined.", "noUncertaintyToClose": "Trying to close an uncertainty that doesn't exist.", - "uncertaintyAlreadyClosed": "Uncertainty was already closed." + "uncertaintyAlreadyClosed": "Uncertainty was already closed.", + "denominatorParsingError": "Couldn't parse %1 using per-mode option of %2." } \ No newline at end of file diff --git a/src/numDisplayMethods.ts b/src/numDisplayMethods.ts index 20406ab..75b33a2 100644 --- a/src/numDisplayMethods.ts +++ b/src/numDisplayMethods.ts @@ -120,7 +120,7 @@ export function convertUncertaintyToBracket(uncertainty: IUncertainty, piece: IN if (diff > 0) { uncertainty.fractional = uncertainty.whole.slice(diff, uncertainty.whole.length); uncertainty.whole = uncertainty.whole.slice(0, diff); - if (uncertainty.fractional !== '') { + if (uncertainty.fractional) { uncertainty.decimal = options["output-decimal-marker"]; } } else if (diff < 0 && options["uncertainty-mode"] === 'full') { @@ -155,7 +155,7 @@ function displayUncertaintyBracketMml(uncertainty: IUncertainty, parser: TexPars const openUncertainty = (new TexParser(options["output-open-uncertainty"], parser.stack.env, parser.configuration)).mml(); let number = uncertainty.whole; - number += (options["uncertainty-mode"] === 'compact-marker' || options["uncertainty-mode"] === 'full') && uncertainty.decimal !== '' ? options["output-decimal-marker"] : ''; + number += (options["uncertainty-mode"] === 'compact-marker' || options["uncertainty-mode"] === 'full') && uncertainty.decimal ? options["output-decimal-marker"] : ''; number += uncertainty.fractional; const numberNode = parser.create('token', 'mn', {}, number); const closeUncertainty = (new TexParser(options["output-close-uncertainty"], parser.stack.env, parser.configuration)).mml(); @@ -214,7 +214,7 @@ export function createExponentMml(num: INumberPiece, parser: TexParser, options: } root.appendChild(exponential); } - } else if (num.exponent !== '' && num.exponent !== '0') { + } else if (num.exponent && num.exponent !== '0') { const exponentSignNode = parser.create('token', 'mo', {}, num.exponentSign); const exponentValueNode = parser.create('token', 'mn', {}, num.exponent); const supPart = num.exponentSign === '-' @@ -225,13 +225,13 @@ export function createExponentMml(num: INumberPiece, parser: TexParser, options: if (num.whole === '1' && num.fractional === '' && !options["print-unity-mantissa"]) { root.appendChild(exponential); } else { - if (num.exponentMarker !== '') { + if (num.exponentMarker) { if (options["output-exponent-marker"] !== '') { const customExponentMarker = (new TexParser(options["output-exponent-marker"], parser.stack.env, parser.configuration)).mml(); root.appendChild(customExponentMarker); root.appendChild(supPart); } else { - if (num.whole !== '' || num.fractional !== '') { + if (num.whole || num.fractional) { if (options["tight-spacing"]) { exponentProductNode.attributes.set('lspace', '0em'); exponentProductNode.attributes.set('rspace', '0em'); diff --git a/src/numMethods.ts b/src/numMethods.ts index 56820ca..7b2f18b 100644 --- a/src/numMethods.ts +++ b/src/numMethods.ts @@ -55,10 +55,10 @@ export function generateNumberPiece(): INumberPiece { export function pieceToNumber(piece: INumberPiece): number { let build = piece.sign + piece.whole; - if (piece.fractional !== '') { + if (piece.fractional) { build += '.' + piece.fractional; } - if (piece.exponent !== '') { + if (piece.exponent) { build += 'e' + piece.exponentSign + piece.exponent; } try { @@ -83,9 +83,9 @@ function getLastNumPiece(numPiece: INumberPiece):INumberPiece{ function parseDigits(text: string, numPiece: INumberPiece) { const num = getLastNumPiece(numPiece); - if (num.exponentMarker !== '') { + if (num.exponentMarker) { num.exponent += text; - } else if (num.decimal !== '') { + } else if (num.decimal) { num.fractional += text; } else { num.whole += text; @@ -100,7 +100,7 @@ function parseDecimals(text: string, numPiece: INumberPiece) { function parseComparators(text: string, numPiece: INumberPiece) { const num = getLastNumPiece(numPiece); - if (num.prefix !== ''){ + if (num.prefix){ throw siunitxError.ComparatorAlreadySet(num.prefix, text); } num.prefix += text; @@ -119,7 +119,7 @@ function parseExponentMarkers(text: string, numPiece: INumberPiece) { function parseSigns(text: string, numPiece: INumberPiece) { const num = getLastNumPiece(numPiece); - if (num.exponentMarker !== '') { + if (num.exponentMarker) { num.exponentSign += text; } else { num.sign += text; @@ -218,21 +218,21 @@ export function parseNumber(parser: TexParser, text: string, options: INumOption } - if (!options["retain-explicit-decimal-marker"] && num.decimal !== '' && num.fractional === '') { + if (!options["retain-explicit-decimal-marker"] && num.decimal && !num.fractional) { num.decimal = ''; } if (!options["retain-explicit-plus"] && num.sign === '+') { num.sign = ''; } // adding exponent to value check here. Without it, exponentials without a base won't stay negative. (-e10) - const value = +(num.whole + (num.decimal !== '' ? '.' : '') + num.fractional + (num.exponent === '' ? '' : 'e' + num.exponentSign + num.exponent)); + const value = +(num.whole + (num.decimal ? '.' : '') + num.fractional + (num.exponent === '' ? '' : 'e' + num.exponentSign + num.exponent)); if (value === 0 && !options["retain-negative-zero"] && num.sign === '-') { num.sign = ''; } if (!options["retain-zero-uncertainty"]) { for (let i = num.uncertainty.length - 1; i >= 0; i--) { - const uncertaintyValue = +(num.uncertainty[i].whole + (num.uncertainty[i].decimal !== '' ? '.' : '') + num.uncertainty[i].fractional); + const uncertaintyValue = +(num.uncertainty[i].whole + (num.uncertainty[i].decimal ? '.' : '') + num.uncertainty[i].fractional); if (uncertaintyValue === 0) { num.uncertainty.splice(i, 1); } @@ -247,9 +247,6 @@ export function processNumber(parser: TexParser): MmlNode { const localOptions = findOptions(parser, globalOptions); - //processOptions(globalOptions, localOptionString); - //const options = processOptions(globalOptions, localOptionString); - //options.forEach((v,k)=> globalOptions[k] = v); Object.assign(globalOptions, localOptions); let text = parser.GetArgument('num'); diff --git a/src/numPostProcessMethods.ts b/src/numPostProcessMethods.ts index 8fd7e45..bf5f283 100644 --- a/src/numPostProcessMethods.ts +++ b/src/numPostProcessMethods.ts @@ -7,15 +7,15 @@ import { IOptions } from "./options/options"; function convertToScientific(parser: TexParser, numOriginal: INumberPiece, options: INumPostOptions): INumberPiece { //convert to actual number and use formating to print scientific - const num = JSON.parse(JSON.stringify(numOriginal)); - const val = (+(num.sign + num.whole + num.decimal + num.fractional + (num.exponent !== '' ? ('e' + num.exponentSign + num.exponent) : ''))).toExponential(); + const num :INumberPiece = JSON.parse(JSON.stringify(numOriginal)); + const val = (+(num.sign + num.whole + num.decimal + num.fractional + (num.exponent ? ('e' + num.exponentSign + num.exponent) : ''))).toExponential(); // parse that back in const newNum = parseNumber(parser, val, options as IOptions); //don't forget to check for trailing zeros and put them back let trailingZeros = 0; // count trailing zeros in original fractional part - if (num.fractional !== '') { + if (num.fractional) { for (let i = num.fractional.length - 1; i >= 0; i--) { if (num.fractional[i] === '0') { trailingZeros++; @@ -25,7 +25,7 @@ function convertToScientific(parser: TexParser, numOriginal: INumberPiece, optio } } // count trailing zeros in original whole part (if all of fractional part was zeros) - if (num.whole !== '' && num.fractional.length === trailingZeros) { + if (num.whole && num.fractional.length === trailingZeros) { for (let i = num.whole.length - 1; i >= 0; i--) { if (num.whole[i] === '0') { trailingZeros++; @@ -39,7 +39,7 @@ function convertToScientific(parser: TexParser, numOriginal: INumberPiece, optio newNum.fractional += '0'; } // add a decimal if the original didn't have one, but we need it. - if (newNum.decimal === '' && trailingZeros > 0) { + if (!newNum.decimal && trailingZeros > 0) { newNum.decimal = '.'; } // copy the new values to the original reference @@ -205,7 +205,6 @@ function roundFigures(parser: TexParser, num: INumberPiece, options: INumPostOpt // whole can't be '0', and converting fractional to number and back to string gets rid of leading zeros. const combined = num.whole === '0' ? (+num.fractional).toString() : num.whole + (+num.fractional).toString(); if (combined.length > options["round-precision"]) { - //console.log(num.whole + num.decimal + num.fractional); const firstDrop = +combined.slice(options["round-precision"], options["round-precision"] + 1); const toRound = +combined.slice(options["round-precision"] - 1, options["round-precision"]); diff --git a/src/options/options.ts b/src/options/options.ts index 55c8487..cdd5e68 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -49,17 +49,17 @@ export function processSISetup(parser: TexParser): void { const optionsString = parser.GetArgument('sisetup'); - const options = processOptions(globalOptions, optionsString); + const options = optionStringToObject(optionsString, globalOptions); Object.assign(parser.options.siunitx, options); // We are adding the sisetup options to the parser options. These are global once the page is loaded. // (the globalOptions variable is just a copy and will reset between each siunitx command) - // TODO: Figure out a how to limit these to grouping curly braces. - // For now, you'll have to reset the options manually with another sisetup command. - + // In LaTeX, you can limit these options to grouping curly braces. + // For MathJAx, you just need to write new delimiters for text: $$ ... $$ } +// LaTeX commands (in the value portion) MUST end with a space before using a comma to add another option function optionStringToObject(optionString: string, globalOptions: IOptions): Partial { // No good way to extend typing for patch // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -77,26 +77,5 @@ function optionStringToObject(optionString: string, globalOptions: IOptions): Pa options[key] = value; } - return options; -} - -// LaTeX commands (in the value portion) MUST end with a space before using a comma to add another option -export function processOptions(globalOptions: IOptions, optionString: string): Record { - // No good way to extend typing for patch - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const optionObject : EnvList = (ParseUtil.keyvalOptions as any)(optionString, globalOptions as unknown as { [key: string]: number }, true, true) ; - const options = {}; - - for (let [key, value] of Object.entries(optionObject)) { - const type = typeof globalOptions[key]; - if (typeof value !== type) { - if (type === 'number' && value.toString().match(/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[-+]\d+)?$/)) { - value = parseFloat(value.toString()); - } else { - throw siunitxError.InvalidOptionValue(key, type); - } - } - options[key] = value; - } return options; } \ No newline at end of file diff --git a/src/qtyMethods.ts b/src/qtyMethods.ts index b5b13b0..6eaa345 100644 --- a/src/qtyMethods.ts +++ b/src/qtyMethods.ts @@ -25,7 +25,7 @@ function combineExponent(parser: TexParser, num: INumberPiece, units: IUnitPiece const firstUnit = units[0]; // prefix can be undefined, empty, or string... this specifically checks for empty - if (firstUnit.prefix !== '') { + if (firstUnit.prefix) { const unitPower = (firstUnit.power !== null ? +(firstUnit.power) : 1) * (firstUnit.position === 'denominator' ? -1 : 1); const addedPower = firstUnit.prefix ? prefixPower.get(firstUnit.prefix) : 1; targetExponent += addedPower * unitPower; @@ -35,11 +35,7 @@ function combineExponent(parser: TexParser, num: INumberPiece, units: IUnitPiece } } // set new prefix - //console.log(JSON.parse(JSON.stringify(units))); - //console.log(targetExponent); firstUnit.prefix = prefixPower.revGet(targetExponent); - //console.log(firstUnit.prefix); - //console.log(JSON.parse(JSON.stringify(units))); const newExponent = targetExponent - exponent; num.exponent = (Math.abs(newExponent)).toString(); num.exponentSign = Math.sign(newExponent) > 0 ? '' : '-'; @@ -86,7 +82,7 @@ function extractExponent(parser: TexParser, num: INumberPiece, units: IUnitPiece unit.prefix = 'k'; } } - const currentExponent = (num.exponent !== '' ? +(num.exponentSign + num.exponent) : 0); + const currentExponent = (num.exponent ? +(num.exponentSign + num.exponent) : 0); const newExponent = currentExponent + powersOfTen; num.exponent = Math.abs(newExponent).toString(); num.exponentSign = Math.sign(newExponent) > 0 ? '' : '-'; @@ -106,14 +102,14 @@ function findUncertaintyNode(root: MmlNode): MmlNode | null { for (const x of root.childNodes) { const mmlNode = x as MmlNode; if (mmlNode) { - if (mmlNode.attributes !== null) { + if (mmlNode.attributes) { const names = mmlNode.attributes.getExplicitNames(); if (names.indexOf('data-siunitx-uncertainty') !== -1) { return mmlNode; } } const result = findUncertaintyNode(mmlNode); - if (result !== null) { + if (result) { return result; } } @@ -134,13 +130,13 @@ const separateUncertaintyUnitsMmlMap = new Map globalOptions[k] = v); + Object.assign(globalOptions, localOptions); const num = parseNumber(parser, numString, globalOptions); - //console.log(JSON.parse(JSON.stringify(unitPieces))); // convert number and unit if necessary prefixModeMap.get(globalOptions["prefix-mode"])?.(parser, num, unitPieces, globalOptions); - //console.log(JSON.parse(JSON.stringify(unitPieces))); - + postProcessNumber(parser, num, globalOptions); - //console.log(JSON.parse(JSON.stringify(unitPieces))); - const numDisplay = displayOutputMml(num, parser, globalOptions); // Need to process this after number because some options alter unit prefixes diff --git a/src/unitMethods.ts b/src/unitMethods.ts index d5268b2..653f5a2 100644 --- a/src/unitMethods.ts +++ b/src/unitMethods.ts @@ -241,7 +241,7 @@ export function displayUnits(parser: TexParser, unitPieces: Array, o texString += numerator + (lastNumeratorHadSuperscript ? options["per-symbol-script-correction"] : '') + options["per-symbol"] + denominator; } else { - console.log("shouldn't be here"); + throw siunitxError.DenominatorParsingError(denominator, options["per-mode"]); } } else { texString += numerator; @@ -300,9 +300,6 @@ export function parseUnit(parser: TexParser, text: string, globalOptions: IOptio const processedMacro = processUnitMacro(macro, subParser); // check for user defined options if (processedMacro.options !== undefined) { - //processOptions(globalOptions, processedMacro.options); - //const options = processOptions(globalOptions, processedMacro.options); - //options.forEach((v, k) => globalOptions[k] = v); Object.assign(globalOptions, processedMacro.options); } // apply immediate options here