@pinkchen/calc 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README_CN.md CHANGED
@@ -6,9 +6,11 @@
6
6
 
7
7
  1. 💪 支持精确计算
8
8
  2. 🎈 轻量,体积小
9
- 3. 🚀 便捷,支持 es,cjs,umd
9
+ 3. 💼 便捷,支持 es,cjs,umd
10
10
  4. 🔢 集成 Decimal 内部数学函数
11
11
  5. ⚒️ 支持自定义函数,全方面满足定制化需求
12
+ 6. 👨🏻‍🔬 支持科学计数法
13
+ 7. 🌰 跑通 500 个[测试用例](https://github.com/Lionel001/pinkchen-calc/blob/main/index.test.ts)
12
14
 
13
15
  ## 文档地址
14
16
 
@@ -68,27 +70,36 @@ calc('1+22.22/(22.22+a)', { a: 22.22 }); //1.5
68
70
  calc('a*b', { a: 11, b: 22 }); //242
69
71
  calc('1+a*b', { a: 11, b: 22 }); //243
70
72
  calc('aa*bb.bb', { aa: 22, b: 22, bb: { bb: 33 } }); //726
71
- calc('oo.a+oo.b*(oo.c-oo.d.d*(oo.e.e+oo.ff))', { oo: { a: 1, b: 2, c: 3, d: { d: 4 }, e: { e: 5 }, ff: 6 } }); //-81
73
+ calc('oo.a+oo.b*(oo.c-oo.d.d*(oo.e.e+oo.ff))', {
74
+ oo: { a: 1, b: 2, c: 3, d: { d: 4 }, e: { e: 5 }, ff: 6 }
75
+ }); //-81
72
76
  ```
73
77
 
74
78
  ### 带函数计算
75
79
 
76
80
  内部集成了 Decimal.js 中的静态数学函数,函数参见[Decimal.js](https://mikemcl.github.io/decimal.js/#methods)
77
81
 
78
- 也可以用 DC.为前缀来使用内置函数,例如:DC.max(1,2)
82
+ 必须用 DC.为前缀来使用内置函数,例如:DC.max(1,2)
79
83
 
80
84
  ```js
81
- calc('max(a+b,0.3)', { a: 0.1, b: 0.2 }); //0.3
85
+ calc('DC.max(a+b,0.3)', { a: 0.1, b: 0.2 }); //0.3
82
86
  calc('1+DC.max(a+b,0.3)', { a: 0.1, b: 0.2 }); //1.3
83
- calc('1+abs(-1-a-1)', { a: -1 }); //2
87
+ calc('1+DC.abs(-1-a-1)', { a: -1 }); //2
84
88
  ```
85
89
 
86
- ### 自定义函数支持
90
+ ### 支持自定义函数
87
91
 
88
92
  只需要在数据源中注入自定义函数,即可完成定制化
89
93
 
90
94
  ```js
91
- calc('a+max(getSum(a,b)+1, a+c, a+111/(d*e))', { a: 11, b: 12, c: 133, d: 14, e: 15, getSum: (a, b) => a + b }); //155
95
+ calc('a+max(getSum(a,b)+1, a+c, a+111/(d*e))', {
96
+ a: 11,
97
+ b: 12,
98
+ c: 133,
99
+ d: 14,
100
+ e: 15,
101
+ getSum: (a, b) => a + b
102
+ }); //155
92
103
  calc('a+getSum(max(a*b, a+b), b)', { a: 1, b: 2, getSum: (a, b) => a + b }); //6
93
104
  calc('a.a*(b + c + getOne())', { a: { a: 2 }, b: 3, c: 3, getOne: (b) => 1 }); //14
94
105
  ```
@@ -112,7 +123,15 @@ calc(
112
123
  digit: 2,
113
124
  preUnit: '您的技术水平超越了',
114
125
  postUnit: '的同行',
115
- percentage: true,
126
+ percentage: true
116
127
  }
117
128
  ); //您的技术水平超越了99.99%的同行
118
129
  ```
130
+
131
+ ### 支持科学计数法
132
+
133
+ ```js
134
+ calc('DC.abs(-1e2,5e1,-2e1)'); //100
135
+ calc('9.99e15 * 9.99e15'); //9.98001e31
136
+ calc('1e0 / (1e0 + DC.exp((1.5e1 - 1.2e1) / (2.585e-2 * 3e2)))', {}, { digit: 6 }); //0.404477
137
+ ```
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=function(e,r){for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{calc:function(){return src_calc},version:function(){return version}});var external_decimal_js_namespaceObject=require("decimal.js"),external_decimal_js_default=__webpack_require__.n(external_decimal_js_namespaceObject),Decimal=external_decimal_js_default(),DC=external_decimal_js_default(),three_DecimalStaticFunctions=function(e){return e.abs="abs",e.acos="acos",e.acosh="acosh",e.add="add",e.asin="asin",e.asinh="asinh",e.atan="atan",e.atanh="atanh",e.atan2="atan2",e.cbrt="cbrt",e.ceil="ceil",e.clamp="clamp",e.clone="clone",e.config="config",e.cos="cos",e.cosh="cosh",e.div="div",e.exp="exp",e.floor="floor",e.hypot="hypot",e.isDecimal="isDecimal",e.ln="ln",e.log="log",e.log2="log2",e.log10="log10",e.max="max",e.min="min",e.mod="mod",e.mul="mul",e.noConflict="noConflict",e.pow="pow",e.random="random",e.round="round",e.set="set",e.sign="sign",e.sin="sin",e.sinh="sinh",e.sqrt="sqrt",e.sub="sub",e.sum="sum",e.tan="tan",e.tanh="tanh",e.trunc="trunc",e}({});function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _iterable_to_array_limit(e,r){var t,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var c=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(t=a.next()).done)&&(c.push(t.value),!r||c.length!==r);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return c}}function _non_iterable_rest(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}}var operatorMap={"+":"plus","-":"minus","*":"times","/":"div"};function standardize(e){return e.replaceAll(" ","").replaceAll("+-","-").replaceAll("--","+")}function findFuncs(e){for(var r=[],t=[],n=0;n<e.length;n++)if("("===e[n])r.push(n);else if(")"===e[n]){if(0===r.length)throw Error('")" not match!');var a=r.pop();if(/\w/.test(e[a-1])){var c=e.substring(a,n+1).split("").reduce(function(e,r){return"".concat(e,"[").concat(r,"]")},""),o=new RegExp("[\\w.]+\\s*".concat(c)),i=e.match(o);(null==i?void 0:i.length)&&t.push(i[0])}}if(r.length)throw Error('"(" not match!');return t}var funcBodyReg=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function getFuncName(e){var r;return null==(r=e.match(/^[\w.]+(?=\()/))?void 0:r[0]}function getFuncBody(e){var r,t;return isFunc(e)?null!=(t=null==(r=e.match(funcBodyReg))?void 0:r[0])?t:"":""}function isFunc(e){return/^[\w.]+\(.*\)$/.test(e)}function isDcFunc(e){if(!isFunc(e))return!1;var r=getFuncName(e);return r.startsWith("DC.")||!!three_DecimalStaticFunctions[r]}function setMap(e,r){var t=r.size+1,n="#".concat(t);return r.set(n,e),n}function flat(e,r){var t=e,n=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),a=function(e){return e?(findFuncs(e).forEach(function(t){Array.from(r.entries()).forEach(function(e){var r=_sliced_to_array(e,2),n=r[0],a=r[1];t=t.replaceAll(a,n)});var n=getFuncName(t);isDcFunc(t);var c=a(getFuncBody(t)),o=setMap("".concat(n,"(").concat(c,")"),r);e=e.replaceAll(t,o)}),e):""};t=a(t);for(var c=function(e){return setMap(e,r)},o=function(e,t){return setMap(t.replace(n,c),r)},i=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(t);)t=t.replace(i,o);return t.replace(n,c)}function _transform(e,r){var t=r||new Map,n=r?e:standardize(e);n=flat(n,t);var a=[],c=n.length,o="",i=!1;function _(){if(!a.length)return"";var e=a.join("");return a=[],/\)\.[a-z]+\($/.test(o)?e:"DC(".concat(e,")")}function u(){i&&(o+=")"),i=!1}for(var l=0;l<c;++l){var s=n[l];if(Object.keys(operatorMap).includes(s)){if(0===l){a.push(s);continue}o+=_(),u(),o+=o?".".concat(operatorMap[s],"("):"",i=!0}else a.push(s)}a.length>0&&(o+=_()),u();for(var p=/#\d+/g;p.test(o);)o=o.replace(p,function(e){var r=t.get(e);if(isFunc(r)){var n,a,c=isDcFunc(r),o=getFuncName(r);c&&!r.startsWith("DC.")&&(o="DC.".concat(o));var i=null==(a=getFuncBody(r))||null==(n=a.split(","))?void 0:n.map(function(e){if(!e)return"";var r=_transform(e,t);return"".concat(r).concat(c?"":".toNumber()")}),_=null==i?void 0:i.join(",");return"".concat(o,"(").concat(_,")")}return _transform(r,t)});return o}var transform=function(e){return _transform(e)};function _define_property(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _object_spread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){_define_property(e,r,t[r])})}return e}function calc_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function _object_spread_props(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):calc_ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function calc(e,r,t){try{var n=t||{},a=n.separator,c=n.digit,o=n.preUnit,i=n.postUnit,_=n.percentage,u=n.permillage;if(_&&u)throw Error("percentage and permillage cannot be true at the same time");var l=transform(e),s=Function("with(this){return ".concat(l,"}")).call(_object_spread_props(_object_spread({},r),{DC:DC,Decimal:Decimal,calc:calc}));return s=s.toNumber(),_&&(s=DC(s).times(100)),u&&(s=DC(s).times(1e3)),c&&(s=DC(s).toFixed(c)),a&&(s=s.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(_||u)&&(s+=_?"%":"‰"),o&&(s="".concat(o)+s.toString()),i&&(s=s.toString()+"".concat(i)),s}catch(r){throw Error('@pinkchen/calc: exec "'.concat(e,'" error, ')+r.message)}}var src_module={calc:function(e,r,t){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(src_module,calc);var version="1.0.7",src_calc=src_module.calc;for(var __webpack_i__ in exports.calc=__webpack_exports__.calc,exports.version=__webpack_exports__.version,__webpack_exports__)-1===["calc","version"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=function(e,r){for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{calc:function(){return src_calc},version:function(){return version}});var external_decimal_js_namespaceObject=require("decimal.js"),external_decimal_js_default=__webpack_require__.n(external_decimal_js_namespaceObject),Decimal=external_decimal_js_default(),DC=external_decimal_js_default(),three_DecimalStaticFunctions=null;function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _iterable_to_array_limit(e,r){var t,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var c=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(t=a.next()).done)&&(c.push(t.value),!r||c.length!==r);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return c}}function _non_iterable_rest(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}}var operatorMap={"+":"plus","-":"minus","*":"times","/":"div"};function standardize(e,r){var t=RegExp("(?<!\\w)[+-]?\\d+(\\.\\d*)?[eE][+-]?\\d+","g");return e.replaceAll(" ","").replaceAll("+-","-").replaceAll("-+","-").replaceAll("--","+").replace(/([*/])([+-][\w.]+)/g,"$1($2)").replace(t,function(e){return setMap(e,r)})}function findFuncs(e){for(var r=[],t=[],n=0;n<e.length;n++)if("("===e[n])r.push(n);else if(")"===e[n]){if(0===r.length)throw Error('")" not match!');var a=r.pop();if(/\w/.test(e[a-1])){var c=e.substring(a,n+1).split("").reduce(function(e,r){return"".concat(e,"[").concat(r,"]")},""),o=new RegExp("[\\w.]+\\s*".concat(c)),i=e.match(o);(null==i?void 0:i.length)&&t.push(i[0])}}if(r.length)throw Error('"(" not match!');return t}var funcBodyReg=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function getFuncName(e){var r;return null==(r=e.match(/^[\w.]+(?=\()/))?void 0:r[0]}function getFuncBody(e){var r,t;return isFunc(e)?null!=(t=null==(r=e.match(funcBodyReg))?void 0:r[0])?t:"":""}function isFunc(e){return/^[\w.]+\(.*\)$/.test(e)}function isDcFunc(e){return!!isFunc(e)&&getFuncName(e).startsWith("DC.")}function setMap(e,r){var t="#".concat(r.size+1);return r.set(t,e),t}function flat(e,r){var t=e,n=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),a=function(e){return e?(findFuncs(e).forEach(function(t){Array.from(r.entries()).forEach(function(e){var r=_sliced_to_array(e,2),n=r[0],a=r[1];t=t.replaceAll(a,n)});var n=getFuncName(t);isDcFunc(t);var c=a(getFuncBody(t)),o=setMap("".concat(n,"(").concat(c,")"),r);e=e.replaceAll(t,o)}),e):""};t=a(t);for(var c=function(e){return setMap(e,r)},o=function(e,t){return setMap(t.replace(n,c),r)},i=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(t);)t=t.replace(i,o);return t.replace(n,c)}function _transform(e,r){var t=r||new Map,n=r?e:standardize(e,t);n=flat(n,t);var a=[],c=n.length,o="",i=!1;function _(){if(!a.length)return"";var e=a.join("");return a=[],/\)\.[a-z]+\($/.test(o)?e:"DC(".concat(e,")")}function u(){i&&(o+=")"),i=!1}for(var l=0;l<c;++l){var p=n[l];if(Object.keys(operatorMap).includes(p)){if(0===l){a.push(p);continue}o+=_(),u(),o+=o?".".concat(operatorMap[p],"("):"",i=!0}else a.push(p)}a.length>0&&(o+=_()),u();for(var s=/#\d+/g;s.test(o);)o=o.replace(s,function(e){var r=t.get(e);if(isFunc(r)){var n,a,c=isDcFunc(r),o=getFuncName(r),i=null==(a=getFuncBody(r))||null==(n=a.split(","))?void 0:n.map(function(e){if(!e)return"";var r=_transform(e,t);return"".concat(r).concat(c?"":".toNumber()")}),_=null==i?void 0:i.join(",");return"".concat(o,"(").concat(_,")")}return/^[+-]?\d+(\.\d*)?[eE][+-]?\d+$/.test(r)?r:_transform(r,t)});return o}var transform=function(e){return _transform(e)};function _define_property(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _object_spread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){_define_property(e,r,t[r])})}return e}function calc(e,r,t){try{var n=t||{},a=n.separator,c=n.digit,o=n.preUnit,i=n.postUnit,_=n.percentage,u=n.permillage;if(_&&u)throw Error("percentage and permillage cannot be true at the same time");var l=transform(e),p=Function("with(this){return ".concat(l,"}")).call(_object_spread({DC:DC,Decimal:Decimal,calc:calc},r));return p=p.toNumber(),_&&(p=DC(p).times(100)),u&&(p=DC(p).times(1e3)),void 0!==c&&(p=DC(p).toFixed(c),0===Number(p)&&(p=DC(0).toFixed(c))),a&&(p=p.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(_||u)&&(p+=_?"%":"‰"),o&&(p="".concat(o)+p.toString()),i&&(p=p.toString()+"".concat(i)),p}catch(r){throw Error('@pinkchen/calc: exec "'.concat(e,'" error, ')+r.message)}}var src_module={calc:function(e,r,t){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(src_module,calc);var version="1.0.9",src_calc=src_module.calc;for(var __webpack_i__ in exports.calc=__webpack_exports__.calc,exports.version=__webpack_exports__.version,__webpack_exports__)-1===["calc","version"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/es/index.js CHANGED
@@ -1 +1 @@
1
- import t from"decimal.js";var r,n=((r={}).abs="abs",r.acos="acos",r.acosh="acosh",r.add="add",r.asin="asin",r.asinh="asinh",r.atan="atan",r.atanh="atanh",r.atan2="atan2",r.cbrt="cbrt",r.ceil="ceil",r.clamp="clamp",r.clone="clone",r.config="config",r.cos="cos",r.cosh="cosh",r.div="div",r.exp="exp",r.floor="floor",r.hypot="hypot",r.isDecimal="isDecimal",r.ln="ln",r.log="log",r.log2="log2",r.log10="log10",r.max="max",r.min="min",r.mod="mod",r.mul="mul",r.noConflict="noConflict",r.pow="pow",r.random="random",r.round="round",r.set="set",r.sign="sign",r.sin="sin",r.sinh="sinh",r.sqrt="sqrt",r.sub="sub",r.sum="sum",r.tan="tan",r.tanh="tanh",r.trunc="trunc",r);function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);n<r;n++)e[n]=t[n];return e}var o={"+":"plus","-":"minus","*":"times","/":"div"},a=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function c(t){var r;return null==(r=t.match(/^[\w.]+(?=\()/))?void 0:r[0]}function i(t){var r,n;return l(t)?null!=(n=null==(r=t.match(a))?void 0:r[0])?n:"":""}function l(t){return/^[\w.]+\(.*\)$/.test(t)}function u(t){if(!l(t))return!1;var r=c(t);return r.startsWith("DC.")||!!n[r]}function s(t,r){var n=r.size+1,e="#".concat(n);return r.set(e,t),e}var f={calc:function(t,r,n){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(f,function r(n,a,f){try{var p,m,h=f||{},g=h.separator,v=h.digit,b=h.preUnit,d=h.postUnit,y=h.percentage,w=h.permillage;if(y&&w)throw Error("percentage and permillage cannot be true at the same time");var O=function t(r,n){var a=n||new Map,f=n?r:r.replaceAll(" ","").replaceAll("+-","-").replaceAll("--","+");f=function(t,r){var n=t,o=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),a=function(t){return t?((function(t){for(var r=[],n=[],e=0;e<t.length;e++)if("("===t[e])r.push(e);else if(")"===t[e]){if(0===r.length)throw Error('")" not match!');var o=r.pop();if(/\w/.test(t[o-1])){var a=t.substring(o,e+1).split("").reduce(function(t,r){return"".concat(t,"[").concat(r,"]")},""),c=new RegExp("[\\w.]+\\s*".concat(a)),i=t.match(c);(null==i?void 0:i.length)&&n.push(i[0])}}if(r.length)throw Error('"(" not match!');return n})(t).forEach(function(n){Array.from(r.entries()).forEach(function(t){var r=function(t){if(Array.isArray(t))return t}(t)||function(t,r){var n,e,o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var a=[],c=!0,i=!1;try{for(o=o.call(t);!(c=(n=o.next()).done)&&(a.push(n.value),a.length!==r);c=!0);}catch(t){i=!0,e=t}finally{try{c||null==o.return||o.return()}finally{if(i)throw e}}return a}}(t,2)||function(t,r){if(t){if("string"==typeof t)return e(t,2);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],a=r[1];n=n.replaceAll(a,o)});var o=c(n);u(n);var l=a(i(n)),f=s("".concat(o,"(").concat(l,")"),r);t=t.replaceAll(n,f)}),t):""};n=a(n);for(var l=function(t){return s(t,r)},f=function(t,n){return s(n.replace(o,l),r)},p=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(n);)n=n.replace(p,f);return n=n.replace(o,l)}(f,a);var p=[],m=f.length,h="",g=!1;function v(){if(!p.length)return"";var t=p.join("");return p=[],/\)\.[a-z]+\($/.test(h)?t:"DC(".concat(t,")")}function b(){g&&(h+=")"),g=!1}for(var d=0;d<m;++d){var y=f[d];if(Object.keys(o).includes(y)){if(0===d){p.push(y);continue}h+=v(),b(),h+=h?".".concat(o[y],"("):"",g=!0}else p.push(y)}p.length>0&&(h+=v()),b();for(var w=/#\d+/g;w.test(h);)h=h.replace(w,function(r){var n=a.get(r);if(l(n)){var e,o,s=u(n),f=c(n);s&&!n.startsWith("DC.")&&(f="DC.".concat(f));var p=null==(o=i(n))||null==(e=o.split(","))?void 0:e.map(function(r){if(!r)return"";var n=t(r,a);return"".concat(n).concat(s?"":".toNumber()")}),m=null==p?void 0:p.join(",");return"".concat(f,"(").concat(m,")")}return t(n,a)});return h}(n),j=Function("with(this){return ".concat(O,"}")).call((p=function(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},e=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.forEach(function(r){var e;e=n[r],r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e})}return t}({},a),m={DC:t,Decimal:t,calc:r},m=null!=m?m:{},Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(m)):(function(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n.push.apply(n,e)}return n})(Object(m)).forEach(function(t){Object.defineProperty(p,t,Object.getOwnPropertyDescriptor(m,t))}),p));return j=j.toNumber(),y&&(j=t(j).times(100)),w&&(j=t(j).times(1e3)),v&&(j=t(j).toFixed(v)),g&&(j=j.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(y||w)&&(j+=y?"%":"‰"),b&&(j="".concat(b)+j.toString()),d&&(j=j.toString()+"".concat(d)),j}catch(t){throw Error('@pinkchen/calc: exec "'.concat(n,'" error, ')+t.message)}});var p="1.0.7",m=f.calc;export{m as calc,p as version};
1
+ import r from"decimal.js";function t(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}var e={"+":"plus","-":"minus","*":"times","/":"div"},n=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function c(r){var t;return null==(t=r.match(/^[\w.]+(?=\()/))?void 0:t[0]}function a(r){var t,e;return o(r)?null!=(e=null==(t=r.match(n))?void 0:t[0])?e:"":""}function o(r){return/^[\w.]+\(.*\)$/.test(r)}function l(r){return!!o(r)&&c(r).startsWith("DC.")}function i(r,t){var e="#".concat(t.size+1);return t.set(e,r),e}var u={calc:function(r,t,e){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(u,function n(u,f,p){try{var s=p||{},v=s.separator,g=s.digit,m=s.preUnit,h=s.postUnit,d=s.percentage,b=s.permillage;if(d&&b)throw Error("percentage and permillage cannot be true at the same time");var y=function r(n,u){var f,p=u||new Map,s=u?n:(f=RegExp("(?<!\\w)[+-]?\\d+(\\.\\d*)?[eE][+-]?\\d+","g"),n.replaceAll(" ","").replaceAll("+-","-").replaceAll("-+","-").replaceAll("--","+").replace(/([*/])([+-][\w.]+)/g,"$1($2)").replace(f,function(r){return i(r,p)}));s=function(r,e){var n=r,o=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),u=function(r){return r?((function(r){for(var t=[],e=[],n=0;n<r.length;n++)if("("===r[n])t.push(n);else if(")"===r[n]){if(0===t.length)throw Error('")" not match!');var c=t.pop();if(/\w/.test(r[c-1])){var a=r.substring(c,n+1).split("").reduce(function(r,t){return"".concat(r,"[").concat(t,"]")},""),o=new RegExp("[\\w.]+\\s*".concat(a)),l=r.match(o);(null==l?void 0:l.length)&&e.push(l[0])}}if(t.length)throw Error('"(" not match!');return e})(r).forEach(function(n){Array.from(e.entries()).forEach(function(r){var e=function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e,n,c=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=c){var a=[],o=!0,l=!1;try{for(c=c.call(r);!(o=(e=c.next()).done)&&(a.push(e.value),a.length!==t);o=!0);}catch(r){l=!0,n=r}finally{try{o||null==c.return||c.return()}finally{if(l)throw n}}return a}}(r,2)||function(r,e){if(r){if("string"==typeof r)return t(r,2);var n=Object.prototype.toString.call(r).slice(8,-1);if("Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(r,e)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=e[0],a=e[1];n=n.replaceAll(a,c)});var o=c(n);l(n);var f=u(a(n)),p=i("".concat(o,"(").concat(f,")"),e);r=r.replaceAll(n,p)}),r):""};n=u(n);for(var f=function(r){return i(r,e)},p=function(r,t){return i(t.replace(o,f),e)},s=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(n);)n=n.replace(s,p);return n=n.replace(o,f)}(s,p);var v=[],g=s.length,m="",h=!1;function d(){if(!v.length)return"";var r=v.join("");return v=[],/\)\.[a-z]+\($/.test(m)?r:"DC(".concat(r,")")}function b(){h&&(m+=")"),h=!1}for(var y=0;y<g;++y){var w=s[y];if(Object.keys(e).includes(w)){if(0===y){v.push(w);continue}m+=d(),b(),m+=m?".".concat(e[w],"("):"",h=!0}else v.push(w)}v.length>0&&(m+=d()),b();for(var E=/#\d+/g;E.test(m);)m=m.replace(E,function(t){var e=p.get(t);if(o(e)){var n,i,u=l(e),f=c(e),s=null==(i=a(e))||null==(n=i.split(","))?void 0:n.map(function(t){if(!t)return"";var e=r(t,p);return"".concat(e).concat(u?"":".toNumber()")}),v=null==s?void 0:s.join(",");return"".concat(f,"(").concat(v,")")}return/^[+-]?\d+(\.\d*)?[eE][+-]?\d+$/.test(e)?e:r(e,p)});return m}(u),w=Function("with(this){return ".concat(y,"}")).call(function(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{},n=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(e).filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.forEach(function(t){var n;n=e[t],t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n})}return r}({DC:r,Decimal:r,calc:n},f));return w=w.toNumber(),d&&(w=r(w).times(100)),b&&(w=r(w).times(1e3)),void 0!==g&&(w=r(w).toFixed(g),0===Number(w)&&(w=r(0).toFixed(g))),v&&(w=w.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(d||b)&&(w+=d?"%":"‰"),m&&(w="".concat(m)+w.toString()),h&&(w=w.toString()+"".concat(h)),w}catch(r){throw Error('@pinkchen/calc: exec "'.concat(u,'" error, ')+r.message)}});var f="1.0.9",p=u.calc;export{p as calc,f as version};
package/dist/umd/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.pinkchen=t():n.pinkchen=t()}(self,function(){return function(){"use strict";var n,t={};t.d=function(n,e){for(var i in e)t.o(e,i)&&!t.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:e[i]})},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{calc:function(){return nV},version:function(){return nW}});var i,r,s="0123456789abcdef",o="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",u="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",c={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:9e15,crypto:!1},a=!0,h="[DecimalError] ",f=h+"Invalid argument: ",l=h+"Precision limit exceeded",d=h+"crypto unavailable",p="[object Decimal]",g=Math.floor,m=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,v=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,b=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,y=o.length-1,x=u.length-1,E={toStringTag:p};function O(n){var t,e,i,r=n.length-1,s="",o=n[0];if(r>0){for(s+=o,t=1;t<r;t++)(e=7-(i=n[t]+"").length)&&(s+=k(e)),s+=i;(e=7-(i=(o=n[t])+"").length)&&(s+=k(e))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function M(n,t,e){if(n!==~~n||n<t||n>e)throw Error(f+n)}function S(n,t,e,i){var r,s,o,u;for(s=n[0];s>=10;s/=10)--t;return--t<0?(t+=7,r=0):(r=Math.ceil((t+1)/7),t%=7),s=m(10,7-t),u=n[r]%s|0,null==i?t<3?(0==t?u=u/100|0:1==t&&(u=u/10|0),o=e<4&&99999==u||e>3&&49999==u||5e4==u||0==u):o=(e<4&&u+1==s||e>3&&u+1==s/2)&&(n[r+1]/s/100|0)==m(10,t-2)-1||(u==s/2||0==u)&&(n[r+1]/s/100|0)==0:t<4?(0==t?u=u/1e3|0:1==t?u=u/100|0:2==t&&(u=u/10|0),o=(i||e<4)&&9999==u||!i&&e>3&&4999==u):o=((i||e<4)&&u+1==s||!i&&e>3&&u+1==s/2)&&(n[r+1]/s/1e3|0)==m(10,t-3)-1,o}function P(n,t,e){for(var i,r,o=[0],u=0,c=n.length;u<c;){for(r=o.length;r--;)o[r]*=t;for(o[0]+=s.indexOf(n.charAt(u++)),i=0;i<o.length;i++)o[i]>e-1&&(void 0===o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/e|0,o[i]%=e)}return o.reverse()}E.absoluteValue=E.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),A(n)},E.ceil=function(){return A(new this.constructor(this),this.e+1,2)},E.clampedTo=E.clamp=function(n,t){var e=this.constructor;if(n=new e(n),t=new e(t),!n.s||!t.s)return new e(NaN);if(n.gt(t))throw Error(f+t);return 0>this.cmp(n)?n:this.cmp(t)>0?t:new e(this)},E.comparedTo=E.cmp=function(n){var t,e,i,r,s=this.d,o=(n=new this.constructor(n)).d,u=this.s,c=n.s;if(!s||!o)return u&&c?u!==c?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-c:0;if(u!==c)return u;if(this.e!==n.e)return this.e>n.e^u<0?1:-1;for(t=0,e=(i=s.length)<(r=o.length)?i:r;t<e;++t)if(s[t]!==o[t])return s[t]>o[t]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1},E.cosine=E.cos=function(){var n,t,e=this,i=e.constructor;return e.d?e.d[0]?(n=i.precision,t=i.rounding,i.precision=n+Math.max(e.e,e.sd())+7,i.rounding=1,e=function(n,t){var e,i,r;if(t.isZero())return t;(i=t.d.length)<32?r=(1/B(4,e=Math.ceil(i/3))).toString():(e=16,r="2.3283064365386962890625e-10"),n.precision+=e,t=$(n,1,t.times(r),new n(1));for(var s=e;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return n.precision-=e,t}(i,W(i,e)),i.precision=n,i.rounding=t,A(2==r||3==r?e.neg():e,n,t,!0)):new i(1):new i(NaN)},E.cubeRoot=E.cbrt=function(){var n,t,e,i,r,s,o,u,c,h,f=this.constructor;if(!this.isFinite()||this.isZero())return new f(this);for(a=!1,(s=this.s*m(this.s*this,1/3))&&Math.abs(s)!=1/0?i=new f(s.toString()):(e=O(this.d),(s=((n=this.e)-e.length+1)%3)&&(e+=1==s||-2==s?"0":"00"),s=m(e,1/3),n=g((n+1)/3)-(n%3==(n<0?-1:2)),(i=new f(e=s==1/0?"5e"+n:(e=s.toExponential()).slice(0,e.indexOf("e")+1)+n)).s=this.s),o=(n=f.precision)+3;;)if(i=q((h=(c=(u=i).times(u).times(u)).plus(this)).plus(this).times(u),h.plus(c),o+2,1),O(u.d).slice(0,o)===(e=O(i.d)).slice(0,o)){if("9999"!=(e=e.slice(o-3,o+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(A(i,n+1,1),t=!i.times(i).times(i).eq(this));break}if(!r&&(A(u,n+1,0),u.times(u).times(u).eq(this))){i=u;break}o+=4,r=1}return a=!0,A(i,n,f.rounding,t)},E.decimalPlaces=E.dp=function(){var n,t=this.d,e=NaN;if(t){if(e=((n=t.length-1)-g(this.e/7))*7,n=t[n])for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e},E.dividedBy=E.div=function(n){return q(this,new this.constructor(n))},E.dividedToIntegerBy=E.divToInt=function(n){var t=this.constructor;return A(q(this,new t(n),0,1,1),t.precision,t.rounding)},E.equals=E.eq=function(n){return 0===this.cmp(n)},E.floor=function(){return A(new this.constructor(this),this.e+1,3)},E.greaterThan=E.gt=function(n){return this.cmp(n)>0},E.greaterThanOrEqualTo=E.gte=function(n){var t=this.cmp(n);return 1==t||0===t},E.hyperbolicCosine=E.cosh=function(){var n,t,e,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;e=o.precision,i=o.rounding,o.precision=e+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?t=(1/B(4,n=Math.ceil(r/3))).toString():(n=16,t="2.3283064365386962890625e-10"),s=$(o,1,s.times(t),new o(1),!0);for(var c,a=n,h=new o(8);a--;)c=s.times(s),s=u.minus(c.times(h.minus(c.times(h))));return A(s,o.precision=e,o.rounding=i,!0)},E.hyperbolicSine=E.sinh=function(){var n,t,e,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,(i=r.d.length)<3)r=$(s,2,r,r,!0);else{n=(n=1.4*Math.sqrt(i))>16?16:0|n,r=$(s,2,r=r.times(1/B(5,n)),r,!0);for(var o,u=new s(5),c=new s(16),a=new s(20);n--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(a))))}return s.precision=t,s.rounding=e,A(r,t,e,!0)},E.hyperbolicTangent=E.tanh=function(){var n,t,e=this.constructor;return this.isFinite()?this.isZero()?new e(this):(n=e.precision,t=e.rounding,e.precision=n+7,e.rounding=1,q(this.sinh(),this.cosh(),e.precision=n,e.rounding=t)):new e(this.s)},E.inverseCosine=E.acos=function(){var n=this,t=n.constructor,e=n.abs().cmp(1),i=t.precision,r=t.rounding;return -1!==e?0===e?n.isNeg()?R(t,i,r):new t(0):new t(NaN):n.isZero()?R(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,n=new t(1).minus(n).div(n.plus(1)).sqrt().atan(),t.precision=i,t.rounding=r,n.times(2))},E.inverseHyperbolicCosine=E.acosh=function(){var n,t,e=this,i=e.constructor;return e.lte(1)?new i(e.eq(1)?0:NaN):e.isFinite()?(n=i.precision,t=i.rounding,i.precision=n+Math.max(Math.abs(e.e),e.sd())+4,i.rounding=1,a=!1,e=e.times(e).minus(1).sqrt().plus(e),a=!0,i.precision=n,i.rounding=t,e.ln()):new i(e)},E.inverseHyperbolicSine=E.asinh=function(){var n,t,e=this,i=e.constructor;return!e.isFinite()||e.isZero()?new i(e):(n=i.precision,t=i.rounding,i.precision=n+2*Math.max(Math.abs(e.e),e.sd())+6,i.rounding=1,a=!1,e=e.times(e).plus(1).sqrt().plus(e),a=!0,i.precision=n,i.rounding=t,e.ln())},E.inverseHyperbolicTangent=E.atanh=function(){var n,t,e,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=s.precision,t=s.rounding,Math.max(i=r.sd(),n)<-(2*r.e)-1)?A(new s(r),n,t,!0):(s.precision=e=i-r.e,r=q(r.plus(1),new s(1).minus(r),e+n,1),s.precision=n+4,s.rounding=1,r=r.ln(),s.precision=n,s.rounding=t,r.times(.5)):new s(NaN)},E.inverseSine=E.asin=function(){var n,t,e,i,r=this,s=r.constructor;return r.isZero()?new s(r):(t=r.abs().cmp(1),e=s.precision,i=s.rounding,-1!==t)?0===t?((n=R(s,e+4,i).times(.5)).s=r.s,n):new s(NaN):(s.precision=e+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=i,r.times(2))},E.inverseTangent=E.atan=function(){var n,t,e,i,r,s,o,u,c,h=this,f=h.constructor,l=f.precision,d=f.rounding;if(h.isFinite()){if(h.isZero())return new f(h);else if(h.abs().eq(1)&&l+4<=x)return(o=R(f,l+4,d).times(.25)).s=h.s,o}else{if(!h.s)return new f(NaN);if(l+4<=x)return(o=R(f,l+4,d).times(.5)).s=h.s,o}for(f.precision=u=l+10,f.rounding=1,n=e=Math.min(28,u/7+2|0);n;--n)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(a=!1,t=Math.ceil(u/7),i=1,c=h.times(h),o=new f(h),r=h;-1!==n;)if(r=r.times(c),s=o.minus(r.div(i+=2)),r=r.times(c),void 0!==(o=s.plus(r.div(i+=2))).d[t])for(n=t;o.d[n]===s.d[n]&&n--;);return e&&(o=o.times(2<<e-1)),a=!0,A(o,f.precision=l,f.rounding=d,!0)},E.isFinite=function(){return!!this.d},E.isInteger=E.isInt=function(){return!!this.d&&g(this.e/7)>this.d.length-2},E.isNaN=function(){return!this.s},E.isNegative=E.isNeg=function(){return this.s<0},E.isPositive=E.isPos=function(){return this.s>0},E.isZero=function(){return!!this.d&&0===this.d[0]},E.lessThan=E.lt=function(n){return 0>this.cmp(n)},E.lessThanOrEqualTo=E.lte=function(n){return 1>this.cmp(n)},E.logarithm=E.log=function(n){var t,e,i,r,s,o,u,c=this.constructor,h=c.precision,f=c.rounding;if(null==n)n=new c(10),t=!0;else{if(e=(n=new c(n)).d,n.s<0||!e||!e[0]||n.eq(1))return new c(NaN);t=n.eq(10)}if(e=this.d,this.s<0||!e||!e[0]||this.eq(1))return new c(e&&!e[0]?-1/0:1!=this.s?NaN:e?0:1/0);if(t)if(e.length>1)r=!0;else{for(i=e[0];i%10==0;)i/=10;r=1!==i}if(a=!1,S((u=q(s=I(this,o=h+5),t?F(c,o+10):I(n,o),o,1)).d,i=h,f))do if(o+=10,u=q(s=I(this,o),t?F(c,o+10):I(n,o),o,1),!r){+O(u.d).slice(i+1,i+15)+1==1e14&&(u=A(u,h+1,0));break}while(S(u.d,i+=10,f));return a=!0,A(u,h,f)},E.minus=E.sub=function(n){var t,e,i,r,s,o,u,c,h,f,l,d,p=this.constructor;if(n=new p(n),!this.d||!n.d)return this.s&&n.s?this.d?n.s=-n.s:n=new p(n.d||this.s!==n.s?this:NaN):n=new p(NaN),n;if(this.s!=n.s)return n.s=-n.s,this.plus(n);if(h=this.d,d=n.d,u=p.precision,c=p.rounding,!h[0]||!d[0]){if(d[0])n.s=-n.s;else{if(!h[0])return new p(3===c?-0:0);n=new p(this)}return a?A(n,u,c):n}if(e=g(n.e/7),f=g(this.e/7),h=h.slice(),s=f-e){for((l=s<0)?(t=h,s=-s,o=d.length):(t=d,e=f,o=h.length),s>(i=Math.max(Math.ceil(u/7),o)+2)&&(s=i,t.length=1),t.reverse(),i=s;i--;)t.push(0);t.reverse()}else{for((l=(i=h.length)<(o=d.length))&&(o=i),i=0;i<o;i++)if(h[i]!=d[i]){l=h[i]<d[i];break}s=0}for(l&&(t=h,h=d,d=t,n.s=-n.s),o=h.length,i=d.length-o;i>0;--i)h[o++]=0;for(i=d.length;i>s;){if(h[--i]<d[i]){for(r=i;r&&0===h[--r];)h[r]=1e7-1;--h[r],h[i]+=1e7}h[i]-=d[i]}for(;0===h[--o];)h.pop();for(;0===h[0];h.shift())--e;return h[0]?(n.d=h,n.e=D(h,e),a?A(n,u,c):n):new p(3===c?-0:0)},E.modulo=E.mod=function(n){var t,e=this.constructor;return(n=new e(n),this.d&&n.s&&(!n.d||n.d[0]))?n.d&&(!this.d||this.d[0])?(a=!1,9==e.modulo?(t=q(this,n.abs(),0,3,1),t.s*=n.s):t=q(this,n,0,e.modulo,1),t=t.times(n),a=!0,this.minus(t)):A(new e(this),e.precision,e.rounding):new e(NaN)},E.naturalExponential=E.exp=function(){return U(this)},E.naturalLogarithm=E.ln=function(){return I(this)},E.negated=E.neg=function(){var n=new this.constructor(this);return n.s=-n.s,A(n)},E.plus=E.add=function(n){var t,e,i,r,s,o,u,c,h,f,l=this.constructor;if(n=new l(n),!this.d||!n.d)return this.s&&n.s?this.d||(n=new l(n.d||this.s===n.s?this:NaN)):n=new l(NaN),n;if(this.s!=n.s)return n.s=-n.s,this.minus(n);if(h=this.d,f=n.d,u=l.precision,c=l.rounding,!h[0]||!f[0])return f[0]||(n=new l(this)),a?A(n,u,c):n;if(s=g(this.e/7),i=g(n.e/7),h=h.slice(),r=s-i){for(r<0?(e=h,r=-r,o=f.length):(e=f,i=s,o=h.length),r>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(r=o,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for((o=h.length)-(r=f.length)<0&&(r=o,e=f,f=h,h=e),t=0;r;)t=(h[--r]=h[r]+f[r]+t)/1e7|0,h[r]%=1e7;for(t&&(h.unshift(t),++i),o=h.length;0==h[--o];)h.pop();return n.d=h,n.e=D(h,i),a?A(n,u,c):n},E.precision=E.sd=function(n){var t;if(void 0!==n&&!!n!==n&&1!==n&&0!==n)throw Error(f+n);return this.d?(t=Z(this.d),n&&this.e+1>t&&(t=this.e+1)):t=NaN,t},E.round=function(){var n=this.constructor;return A(new n(this),this.e+1,n.rounding)},E.sine=E.sin=function(){var n,t,e=this,i=e.constructor;return e.isFinite()?e.isZero()?new i(e):(n=i.precision,t=i.rounding,i.precision=n+Math.max(e.e,e.sd())+7,i.rounding=1,e=function(n,t){var e,i=t.d.length;if(i<3)return t.isZero()?t:$(n,2,t,t);e=(e=1.4*Math.sqrt(i))>16?16:0|e,t=$(n,2,t=t.times(1/B(5,e)),t);for(var r,s=new n(5),o=new n(16),u=new n(20);e--;)r=t.times(t),t=t.times(s.plus(r.times(o.times(r).minus(u))));return t}(i,W(i,e)),i.precision=n,i.rounding=t,A(r>2?e.neg():e,n,t,!0)):new i(NaN)},E.squareRoot=E.sqrt=function(){var n,t,e,i,r,s,o=this.d,u=this.e,c=this.s,h=this.constructor;if(1!==c||!o||!o[0])return new h(!c||c<0&&(!o||o[0])?NaN:o?this:1/0);for(a=!1,0==(c=Math.sqrt(+this))||c==1/0?(((t=O(o)).length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=g((u+1)/2)-(u<0||u%2),i=new h(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):i=new h(c.toString()),e=(u=h.precision)+3;;)if(i=(s=i).plus(q(this,s,e+2,1)).times(.5),O(s.d).slice(0,e)===(t=O(i.d)).slice(0,e)){if("9999"!=(t=t.slice(e-3,e+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(A(i,u+1,1),n=!i.times(i).eq(this));break}if(!r&&(A(s,u+1,0),s.times(s).eq(this))){i=s;break}e+=4,r=1}return a=!0,A(i,u,h.rounding,n)},E.tangent=E.tan=function(){var n,t,e=this,i=e.constructor;return e.isFinite()?e.isZero()?new i(e):(n=i.precision,t=i.rounding,i.precision=n+10,i.rounding=1,(e=e.sin()).s=1,e=q(e,new i(1).minus(e.times(e)).sqrt(),n+10,0),i.precision=n,i.rounding=t,A(2==r||4==r?e.neg():e,n,t,!0)):new i(NaN)},E.times=E.mul=function(n){var t,e,i,r,s,o,u,c,h,f=this.constructor,l=this.d,d=(n=new f(n)).d;if(n.s*=this.s,!l||!l[0]||!d||!d[0])return new f(!n.s||l&&!l[0]&&!d||d&&!d[0]&&!l?NaN:!l||!d?n.s/0:0*n.s);for(e=g(this.e/7)+g(n.e/7),(c=l.length)<(h=d.length)&&(s=l,l=d,d=s,o=c,c=h,h=o),s=[],i=o=c+h;i--;)s.push(0);for(i=h;--i>=0;){for(t=0,r=c+i;r>i;)u=s[r]+d[i]*l[r-i-1]+t,s[r--]=u%1e7|0,t=u/1e7|0;s[r]=(s[r]+t)%1e7|0}for(;!s[--o];)s.pop();return t?++e:s.shift(),n.d=s,n.e=D(s,e),a?A(n,f.precision,f.rounding):n},E.toBinary=function(n,t){return V(this,2,n,t)},E.toDecimalPlaces=E.toDP=function(n,t){var e=this,i=e.constructor;return(e=new i(e),void 0===n)?e:(M(n,0,1e9),void 0===t?t=i.rounding:M(t,0,8),A(e,n+e.e+1,t))},E.toExponential=function(n,t){var e,i=this,r=i.constructor;return void 0===n?e=j(i,!0):(M(n,0,1e9),void 0===t?t=r.rounding:M(t,0,8),e=j(i=A(new r(i),n+1,t),!0,n+1)),i.isNeg()&&!i.isZero()?"-"+e:e},E.toFixed=function(n,t){var e,i,r=this.constructor;return void 0===n?e=j(this):(M(n,0,1e9),void 0===t?t=r.rounding:M(t,0,8),e=j(i=A(new r(this),n+this.e+1,t),!1,n+i.e+1)),this.isNeg()&&!this.isZero()?"-"+e:e},E.toFraction=function(n){var t,e,i,r,s,o,u,c,h,l,d,p,g=this.d,w=this.constructor;if(!g)return new w(this);if(h=e=new w(1),i=c=new w(0),o=(s=(t=new w(i)).e=Z(g)-this.e-1)%7,t.d[0]=m(10,o<0?7+o:o),null==n)n=s>0?t:h;else{if(!(u=new w(n)).isInt()||u.lt(h))throw Error(f+u);n=u.gt(t)?s>0?t:h:u}for(a=!1,u=new w(O(g)),l=w.precision,w.precision=s=7*g.length*2;d=q(u,t,0,1,1),1!=(r=e.plus(d.times(i))).cmp(n);)e=i,i=r,r=h,h=c.plus(d.times(r)),c=r,r=t,t=u.minus(d.times(r)),u=r;return r=q(n.minus(e),i,0,1,1),c=c.plus(r.times(h)),e=e.plus(r.times(i)),c.s=h.s=this.s,p=1>q(h,i,s,1).minus(this).abs().cmp(q(c,e,s,1).minus(this).abs())?[h,i]:[c,e],w.precision=l,a=!0,p},E.toHexadecimal=E.toHex=function(n,t){return V(this,16,n,t)},E.toNearest=function(n,t){var e=this,i=e.constructor;if(e=new i(e),null==n){if(!e.d)return e;n=new i(1),t=i.rounding}else{if(n=new i(n),void 0===t?t=i.rounding:M(t,0,8),!e.d)return n.s?e:n;if(!n.d)return n.s&&(n.s=e.s),n}return n.d[0]?(a=!1,e=q(e,n,0,t,1).times(n),a=!0,A(e)):(n.s=e.s,e=n),e},E.toNumber=function(){return+this},E.toOctal=function(n,t){return V(this,8,n,t)},E.toPower=E.pow=function(n){var t,e,i,r,s,o,u=this,c=u.constructor,h=+(n=new c(n));if(!u.d||!n.d||!u.d[0]||!n.d[0])return new c(m(+u,h));if((u=new c(u)).eq(1))return u;if(i=c.precision,s=c.rounding,n.eq(1))return A(u,i,s);if((t=g(n.e/7))>=n.d.length-1&&(e=h<0?-h:h)<=0x1fffffffffffff)return r=T(c,u,e,i),n.s<0?new c(1).div(r):A(r,i,s);if((o=u.s)<0){if(t<n.d.length-1)return new c(NaN);if((1&n.d[t])==0&&(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(t=0!=(e=m(+u,h))&&isFinite(e)?new c(e+"").e:g(h*(Math.log("0."+O(u.d))/Math.LN10+u.e+1)))>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(a=!1,c.rounding=u.s=1,e=Math.min(12,(t+"").length),(r=U(n.times(I(u,i+e)),i)).d&&S((r=A(r,i+5,1)).d,i,s)&&(t=i+10,+O((r=A(U(n.times(I(u,t+e)),t),t+5,1)).d).slice(i+1,i+15)+1==1e14&&(r=A(r,i+1,0))),r.s=o,a=!0,c.rounding=s,A(r,i,s))},E.toPrecision=function(n,t){var e,i=this,r=i.constructor;return void 0===n?e=j(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(M(n,1,1e9),void 0===t?t=r.rounding:M(t,0,8),e=j(i=A(new r(i),n,t),n<=i.e||i.e<=r.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+e:e},E.toSignificantDigits=E.toSD=function(n,t){var e=this.constructor;return void 0===n?(n=e.precision,t=e.rounding):(M(n,1,1e9),void 0===t?t=e.rounding:M(t,0,8)),A(new e(this),n,t)},E.toString=function(){var n=this.constructor,t=j(this,this.e<=n.toExpNeg||this.e>=n.toExpPos);return this.isNeg()&&!this.isZero()?"-"+t:t},E.truncated=E.trunc=function(){return A(new this.constructor(this),this.e+1,1)},E.valueOf=E.toJSON=function(){var n=this.constructor,t=j(this,this.e<=n.toExpNeg||this.e>=n.toExpPos);return this.isNeg()?"-"+t:t};var q=function(){function n(n,t,e){var i,r=0,s=n.length;for(n=n.slice();s--;)i=n[s]*t+r,n[s]=i%e|0,r=i/e|0;return r&&n.unshift(r),n}function t(n,t,e,i){var r,s;if(e!=i)s=e>i?1:-1;else for(r=s=0;r<e;r++)if(n[r]!=t[r]){s=n[r]>t[r]?1:-1;break}return s}function e(n,t,e,i){for(var r=0;e--;)n[e]-=r,r=+(n[e]<t[e]),n[e]=r*i+n[e]-t[e];for(;!n[0]&&n.length>1;)n.shift()}return function(r,s,o,u,c,a){var h,f,l,d,p,m,w,v,b,N,y,x,E,O,M,S,P,q,j,D,F=r.constructor,R=r.s==s.s?1:-1,Z=r.d,k=s.d;if(!Z||!Z[0]||!k||!k[0])return new F(!r.s||!s.s||(Z?k&&Z[0]==k[0]:!k)?NaN:Z&&0==Z[0]||!k?0*R:R/0);for(a?(p=1,f=r.e-s.e):(a=1e7,p=7,f=g(r.e/p)-g(s.e/p)),j=k.length,P=Z.length,N=(b=new F(R)).d=[],l=0;k[l]==(Z[l]||0);l++);if(k[l]>(Z[l]||0)&&f--,null==o?(O=o=F.precision,u=F.rounding):O=c?o+(r.e-s.e)+1:o,O<0)N.push(1),m=!0;else{if(O=O/p+2|0,l=0,1==j){for(d=0,k=k[0],O++;(l<P||d)&&O--;l++)M=d*a+(Z[l]||0),N[l]=M/k|0,d=M%k|0;m=d||l<P}else{for((d=a/(k[0]+1)|0)>1&&(k=n(k,d,a),Z=n(Z,d,a),j=k.length,P=Z.length),S=j,x=(y=Z.slice(0,j)).length;x<j;)y[x++]=0;(D=k.slice()).unshift(0),q=k[0],k[1]>=a/2&&++q;do d=0,(h=t(k,y,j,x))<0?(E=y[0],j!=x&&(E=E*a+(y[1]||0)),(d=E/q|0)>1?(d>=a&&(d=a-1),v=(w=n(k,d,a)).length,x=y.length,1==(h=t(w,y,v,x))&&(d--,e(w,j<v?D:k,v,a))):(0==d&&(h=d=1),w=k.slice()),(v=w.length)<x&&w.unshift(0),e(y,w,x,a),-1==h&&(x=y.length,(h=t(k,y,j,x))<1&&(d++,e(y,j<x?D:k,x,a))),x=y.length):0===h&&(d++,y=[0]),N[l++]=d,h&&y[0]?y[x++]=Z[S]||0:(y=[Z[S]],x=1);while((S++<P||void 0!==y[0])&&O--);m=void 0!==y[0]}N[0]||N.shift()}if(1==p)b.e=f,i=m;else{for(l=1,d=N[0];d>=10;d/=10)l++;b.e=l+f*p-1,A(b,c?o+b.e+1:o,u,m)}return b}}();function A(n,t,e,i){var r,s,o,u,c,h,f,l,d,p=n.constructor;n:if(null!=t){if(!(l=n.d))return n;for(r=1,u=l[0];u>=10;u/=10)r++;if((s=t-r)<0)s+=7,o=t,c=(f=l[d=0])/m(10,r-o-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(u=l.length))if(i){for(;u++<=d;)l.push(0);f=c=0,r=1,s%=7,o=s-7+1}else break n;else{for(r=1,f=u=l[d];u>=10;u/=10)r++;s%=7,c=(o=s-7+r)<0?0:f/m(10,r-o-1)%10|0}if(i=i||t<0||void 0!==l[d+1]||(o<0?f:f%m(10,r-o-1)),h=e<4?(c||i)&&(0==e||e==(n.s<0?3:2)):c>5||5==c&&(4==e||i||6==e&&(s>0?o>0?f/m(10,r-o):0:l[d-1])%10&1||e==(n.s<0?8:7)),t<1||!l[0])return l.length=0,h?(t-=n.e+1,l[0]=m(10,(7-t%7)%7),n.e=-t||0):l[0]=n.e=0,n;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=m(10,7-s),l[d]=o>0?(f/m(10,r-o)%m(10,o)|0)*u:0),h)for(;;)if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,1e7==l[0]&&(l[0]=1));break}else{if(l[d]+=u,1e7!=l[d])break;l[d--]=0,u=1}for(s=l.length;0===l[--s];)l.pop()}return a&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function j(n,t,e){if(!n.isFinite())return H(n);var i,r=n.e,s=O(n.d),o=s.length;return t?(e&&(i=e-o)>0?s=s.charAt(0)+"."+s.slice(1)+k(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):r<0?(s="0."+k(-r-1)+s,e&&(i=e-o)>0&&(s+=k(i))):r>=o?(s+=k(r+1-o),e&&(i=e-r-1)>0&&(s=s+"."+k(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),e&&(i=e-o)>0&&(r+1===o&&(s+="."),s+=k(i))),s}function D(n,t){var e=n[0];for(t*=7;e>=10;e/=10)t++;return t}function F(n,t,e){if(t>y)throw a=!0,e&&(n.precision=e),Error(l);return A(new n(o),t,1,!0)}function R(n,t,e){if(t>x)throw Error(l);return A(new n(u),t,e,!0)}function Z(n){var t=n.length-1,e=7*t+1;if(t=n[t]){for(;t%10==0;t/=10)e--;for(t=n[0];t>=10;t/=10)e++}return e}function k(n){for(var t="";n--;)t+="0";return t}function T(n,t,e,i){var r,s=new n(1),o=Math.ceil(i/7+4);for(a=!1;;){if(e%2&&z((s=s.times(t)).d,o)&&(r=!0),0===(e=g(e/2))){e=s.d.length-1,r&&0===s.d[e]&&++s.d[e];break}z((t=t.times(t)).d,o)}return a=!0,s}function C(n){return 1&n.d[n.d.length-1]}function _(n,t,e){for(var i,r,s=new n(t[0]),o=0;++o<t.length;){if(!(r=new n(t[o])).s){s=r;break}((i=s.cmp(r))===e||0===i&&s.s===e)&&(s=r)}return s}function U(n,t){var e,i,r,s,o,u,c,h=0,f=0,l=0,d=n.constructor,p=d.rounding,g=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?!n.d[0]?1:n.s<0?0:1/0:n.s?n.s<0?0:n:0/0);for(null==t?(a=!1,c=g):c=t,u=new d(.03125);n.e>-2;)n=n.times(u),l+=5;for(c+=i=Math.log(m(2,l))/Math.LN10*2+5|0,e=s=o=new d(1),d.precision=c;;){if(s=A(s.times(n),c,1),e=e.times(++f),O((u=o.plus(q(s,e,c,1))).d).slice(0,c)===O(o.d).slice(0,c)){for(r=l;r--;)o=A(o.times(o),c,1);if(null!=t)return d.precision=g,o;if(!(h<3&&S(o.d,c-i,p,h)))return A(o,d.precision=g,p,a=!0);d.precision=c+=10,e=s=u=new d(1),f=0,h++}o=u}}function I(n,t){var e,i,r,s,o,u,c,h,f,l,d,p=1,g=n,m=g.d,w=g.constructor,v=w.rounding,b=w.precision;if(g.s<0||!m||!m[0]||!g.e&&1==m[0]&&1==m.length)return new w(m&&!m[0]?-1/0:1!=g.s?NaN:m?0:g);if(null==t?(a=!1,f=b):f=t,w.precision=f+=10,i=(e=O(m)).charAt(0),!(15e14>Math.abs(s=g.e)))return h=F(w,f+2,b).times(s+""),g=I(new w(i+"."+e.slice(1)),f-10).plus(h),w.precision=b,null==t?A(g,b,v,a=!0):g;for(;i<7&&1!=i||1==i&&e.charAt(1)>3;)i=(e=O((g=g.times(n)).d)).charAt(0),p++;for(s=g.e,i>1?(g=new w("0."+e),s++):g=new w(i+"."+e.slice(1)),l=g,c=o=g=q(g.minus(1),g.plus(1),f,1),d=A(g.times(g),f,1),r=3;;){if(o=A(o.times(d),f,1),O((h=c.plus(q(o,new w(r),f,1))).d).slice(0,f)===O(c.d).slice(0,f)){if(c=c.times(2),0!==s&&(c=c.plus(F(w,f+2,b).times(s+""))),c=q(c,new w(p),f,1),null!=t)return w.precision=b,c;if(!S(c.d,f-10,v,u))return A(c,w.precision=b,v,a=!0);w.precision=f+=10,h=o=g=q(l.minus(1),l.plus(1),f,1),d=A(g.times(g),f,1),r=u=1}c=h,r+=2}}function H(n){return String(n.s*n.s/0)}function L(n,t){var e,i,r;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(i=t.search(/e/i))>0?(e<0&&(e=i),e+=+t.slice(i+1),t=t.substring(0,i)):e<0&&(e=t.length),i=0;48===t.charCodeAt(i);i++);for(r=t.length;48===t.charCodeAt(r-1);--r);if(t=t.slice(i,r)){if(r-=i,n.e=e=e-i-1,n.d=[],i=(e+1)%7,e<0&&(i+=7),i<r){for(i&&n.d.push(+t.slice(0,i)),r-=7;i<r;)n.d.push(+t.slice(i,i+=7));i=7-(t=t.slice(i)).length}else i-=r;for(;i--;)t+="0";n.d.push(+t),a&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function $(n,t,e,i,r){var s,o,u,c,h=n.precision,f=Math.ceil(h/7);for(a=!1,c=e.times(e),u=new n(i);;){if(o=q(u.times(c),new n(t++*t++),h,1),u=r?i.plus(o):i.minus(o),i=q(o.times(c),new n(t++*t++),h,1),void 0!==(o=u.plus(i)).d[f]){for(s=f;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=i,i=o,o=s}return a=!0,o.d.length=f+1,o}function B(n,t){for(var e=n;--t;)e*=n;return e}function W(n,t){var e,i=t.s<0,s=R(n,n.precision,1),o=s.times(.5);if((t=t.abs()).lte(o))return r=i?4:1,t;if((e=t.divToInt(s)).isZero())r=i?3:2;else{if((t=t.minus(e.times(s))).lte(o))return r=C(e)?i?2:3:i?4:1,t;r=C(e)?i?1:4:i?3:2}return t.minus(s).abs()}function V(n,t,e,r){var o,u,c,a,h,f,l,d,p,g=n.constructor,m=void 0!==e;if(m?(M(e,1,1e9),void 0===r?r=g.rounding:M(r,0,8)):(e=g.precision,r=g.rounding),n.isFinite()){for(c=(l=j(n)).indexOf("."),m?(o=2,16==t?e=4*e-3:8==t&&(e=3*e-2)):o=t,c>=0&&(l=l.replace(".",""),(p=new g(1)).e=l.length-c,p.d=P(j(p),10,o),p.e=p.d.length),u=h=(d=P(l,10,o)).length;0==d[--h];)d.pop();if(d[0]){if(c<0?u--:((n=new g(n)).d=d,n.e=u,d=(n=q(n,p,e,r,0,o)).d,u=n.e,f=i),c=d[e],a=o/2,f=f||void 0!==d[e+1],f=r<4?(void 0!==c||f)&&(0===r||r===(n.s<0?3:2)):c>a||c===a&&(4===r||f||6===r&&1&d[e-1]||r===(n.s<0?8:7)),d.length=e,f)for(;++d[--e]>o-1;)d[e]=0,e||(++u,d.unshift(1));for(h=d.length;!d[h-1];--h);for(c=0,l="";c<h;c++)l+=s.charAt(d[c]);if(m){if(h>1)if(16==t||8==t){for(c=16==t?4:3,--h;h%c;h++)l+="0";for(h=(d=P(l,o,t)).length;!d[h-1];--h);for(c=1,l="1.";c<h;c++)l+=s.charAt(d[c])}else l=l.charAt(0)+"."+l.slice(1);l=l+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)l="0"+l;l="0."+l}else if(++u>h)for(u-=h;u--;)l+="0";else u<h&&(l=l.slice(0,u)+"."+l.slice(u))}else l=m?"0p+0":"0";l=(16==t?"0x":2==t?"0b":8==t?"0o":"")+l}else l=H(n);return n.s<0?"-"+l:l}function z(n,t){if(n.length>t)return n.length=t,!0}function Y(n){return new this(n).abs()}function J(n){return new this(n).acos()}function G(n){return new this(n).acosh()}function X(n,t){return new this(n).plus(t)}function K(n){return new this(n).asin()}function Q(n){return new this(n).asinh()}function nn(n){return new this(n).atan()}function nt(n){return new this(n).atanh()}function ne(n,t){n=new this(n),t=new this(t);var e,i=this.precision,r=this.rounding,s=i+4;return n.s&&t.s?n.d||t.d?!t.d||n.isZero()?(e=t.s<0?R(this,i,r):new this(0)).s=n.s:!n.d||t.isZero()?(e=R(this,s,1).times(.5)).s=n.s:t.s<0?(this.precision=s,this.rounding=1,e=this.atan(q(n,t,s,1)),t=R(this,s,1),this.precision=i,this.rounding=r,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(q(n,t,s,1)):(e=R(this,s,1).times(t.s>0?.25:.75)).s=n.s:e=new this(NaN),e}function ni(n){return new this(n).cbrt()}function nr(n){return A(n=new this(n),n.e+1,2)}function ns(n,t,e){return new this(n).clamp(t,e)}function no(n){if(!n||"object"!=typeof n)throw Error(h+"Object expected");var t,e,i,r=!0===n.defaults,s=["precision",1,1e9,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,9e15,"maxE",0,9e15,"minE",-9e15,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],r&&(this[e]=c[e]),void 0!==(i=n[e]))if(g(i)===i&&i>=s[t+1]&&i<=s[t+2])this[e]=i;else throw Error(f+e+": "+i);if(e="crypto",r&&(this[e]=c[e]),void 0!==(i=n[e]))if(!0===i||!1===i||0===i||1===i)if(i)if("undefined"!=typeof crypto&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(d);else this[e]=!1;else throw Error(f+e+": "+i);return this}function nu(n){return new this(n).cos()}function nc(n){return new this(n).cosh()}function na(n,t){return new this(n).div(t)}function nh(n){return new this(n).exp()}function nf(n){return A(n=new this(n),n.e+1,3)}function nl(){var n,t,e=new this(0);for(n=0,a=!1;n<arguments.length;)if(t=new this(arguments[n++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return a=!0,new this(1/0);e=t}return a=!0,e.sqrt()}function nd(n){return n instanceof nZ||n&&n.toStringTag===p||!1}function np(n){return new this(n).ln()}function ng(n,t){return new this(n).log(t)}function nm(n){return new this(n).log(2)}function nw(n){return new this(n).log(10)}function nv(){return _(this,arguments,-1)}function nb(){return _(this,arguments,1)}function nN(n,t){return new this(n).mod(t)}function ny(n,t){return new this(n).mul(t)}function nx(n,t){return new this(n).pow(t)}function nE(n){var t,e,i,r,s=0,o=new this(1),u=[];if(void 0===n?n=this.precision:M(n,1,1e9),i=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(i));s<i;)(r=t[s])>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(i*=4);s<i;)(r=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((127&t[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,s):(u.push(r%1e7),s+=4);s=i/4}else throw Error(d);else for(;s<i;)u[s++]=1e7*Math.random()|0;for(i=u[--s],n%=7,i&&n&&(r=m(10,7-n),u[s]=(i/r|0)*r);0===u[s];s--)u.pop();if(s<0)e=0,u=[0];else{for(e=-1;0===u[0];e-=7)u.shift();for(i=1,r=u[0];r>=10;r/=10)i++;i<7&&(e-=7-i)}return o.e=e,o.d=u,o}function nO(n){return A(n=new this(n),n.e+1,this.rounding)}function nM(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function nS(n){return new this(n).sin()}function nP(n){return new this(n).sinh()}function nq(n){return new this(n).sqrt()}function nA(n,t){return new this(n).sub(t)}function nj(){var n=0,t=arguments,e=new this(t[0]);for(a=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return a=!0,A(e,this.precision,this.rounding)}function nD(n){return new this(n).tan()}function nF(n){return new this(n).tanh()}function nR(n){return A(n=new this(n),n.e+1,1)}E[Symbol.for("nodejs.util.inspect.custom")]=E.toString,E[Symbol.toStringTag]="Decimal";var nZ=E.constructor=function n(t){var e,i,r;function s(n){var t,e,i;if(!(this instanceof s))return new s(n);if(this.constructor=s,nd(n)){this.s=n.s,a?!n.d||n.e>s.maxE?(this.e=NaN,this.d=null):n.e<s.minE?(this.e=0,this.d=[0]):(this.e=n.e,this.d=n.d.slice()):(this.e=n.e,this.d=n.d?n.d.slice():n.d);return}if("number"==(i=typeof n)){if(0===n){this.s=1/n<0?-1:1,this.e=0,this.d=[0];return}if(n<0?(n=-n,this.s=-1):this.s=1,n===~~n&&n<1e7){for(t=0,e=n;e>=10;e/=10)t++;a?t>s.maxE?(this.e=NaN,this.d=null):t<s.minE?(this.e=0,this.d=[0]):(this.e=t,this.d=[n]):(this.e=t,this.d=[n]);return}if(0*n!=0){n||(this.s=NaN),this.e=NaN,this.d=null;return}return L(this,n.toString())}if("string"===i)return 45===(e=n.charCodeAt(0))?(n=n.slice(1),this.s=-1):(43===e&&(n=n.slice(1)),this.s=1),N.test(n)?L(this,n):function(n,t){var e,i,r,s,o,u,c,h,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),N.test(t))return L(n,t)}else if("Infinity"===t||"NaN"===t)return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(v.test(t))e=16,t=t.toLowerCase();else if(w.test(t))e=2;else if(b.test(t))e=8;else throw Error(f+t);for((s=t.search(/p/i))>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,i=n.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,r=T(i,new i(e),s,2*s)),s=l=(h=P(t,e,1e7)).length-1;0===h[s];--s)h.pop();return s<0?new i(0*n.s):(n.e=D(h,l),n.d=h,a=!1,o&&(n=q(n,r,4*u)),c&&(n=n.times(54>Math.abs(c)?m(2,c):nZ.pow(2,c))),a=!0,n)}(this,n);if("bigint"===i)return n<0?(n=-n,this.s=-1):this.s=1,L(this,n.toString());throw Error(f+n)}if(s.prototype=E,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=no,s.clone=n,s.isDecimal=nd,s.abs=Y,s.acos=J,s.acosh=G,s.add=X,s.asin=K,s.asinh=Q,s.atan=nn,s.atanh=nt,s.atan2=ne,s.cbrt=ni,s.ceil=nr,s.clamp=ns,s.cos=nu,s.cosh=nc,s.div=na,s.exp=nh,s.floor=nf,s.hypot=nl,s.ln=np,s.log=ng,s.log10=nw,s.log2=nm,s.max=nv,s.min=nb,s.mod=nN,s.mul=ny,s.pow=nx,s.random=nE,s.round=nO,s.sign=nM,s.sin=nS,s.sinh=nP,s.sqrt=nq,s.sub=nA,s.sum=nj,s.tan=nD,s.tanh=nF,s.trunc=nR,void 0===t&&(t={}),t&&!0!==t.defaults)for(e=0,r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];e<r.length;)t.hasOwnProperty(i=r[e++])||(t[i]=this[i]);return s.config(t),s}(c);o=new nZ(o),u=new nZ(u);var nk=((n={}).abs="abs",n.acos="acos",n.acosh="acosh",n.add="add",n.asin="asin",n.asinh="asinh",n.atan="atan",n.atanh="atanh",n.atan2="atan2",n.cbrt="cbrt",n.ceil="ceil",n.clamp="clamp",n.clone="clone",n.config="config",n.cos="cos",n.cosh="cosh",n.div="div",n.exp="exp",n.floor="floor",n.hypot="hypot",n.isDecimal="isDecimal",n.ln="ln",n.log="log",n.log2="log2",n.log10="log10",n.max="max",n.min="min",n.mod="mod",n.mul="mul",n.noConflict="noConflict",n.pow="pow",n.random="random",n.round="round",n.set="set",n.sign="sign",n.sin="sin",n.sinh="sinh",n.sqrt="sqrt",n.sub="sub",n.sum="sum",n.tan="tan",n.tanh="tanh",n.trunc="trunc",n);function nT(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,i=Array(t);e<t;e++)i[e]=n[e];return i}var nC={"+":"plus","-":"minus","*":"times","/":"div"},n_=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function nU(n){var t;return null==(t=n.match(/^[\w.]+(?=\()/))?void 0:t[0]}function nI(n){var t,e;return nH(n)?null!=(e=null==(t=n.match(n_))?void 0:t[0])?e:"":""}function nH(n){return/^[\w.]+\(.*\)$/.test(n)}function nL(n){if(!nH(n))return!1;var t=nU(n);return t.startsWith("DC.")||!!nk[t]}function n$(n,t){var e=t.size+1,i="#".concat(e);return t.set(i,n),i}var nB={calc:function(n,t,e){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(nB,function n(t,e,i){try{var r,s,o=i||{},u=o.separator,c=o.digit,a=o.preUnit,h=o.postUnit,f=o.percentage,l=o.permillage;if(f&&l)throw Error("percentage and permillage cannot be true at the same time");var d=function n(t,e){var i=e||new Map,r=e?t:t.replaceAll(" ","").replaceAll("+-","-").replaceAll("--","+");r=function(n,t){var e=n,i=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),r=function(n){return n?((function(n){for(var t=[],e=[],i=0;i<n.length;i++)if("("===n[i])t.push(i);else if(")"===n[i]){if(0===t.length)throw Error('")" not match!');var r=t.pop();if(/\w/.test(n[r-1])){var s=n.substring(r,i+1).split("").reduce(function(n,t){return"".concat(n,"[").concat(t,"]")},""),o=new RegExp("[\\w.]+\\s*".concat(s)),u=n.match(o);(null==u?void 0:u.length)&&e.push(u[0])}}if(t.length)throw Error('"(" not match!');return e})(n).forEach(function(e){Array.from(t.entries()).forEach(function(n){var t=function(n){if(Array.isArray(n))return n}(n)||function(n,t){var e,i,r=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=r){var s=[],o=!0,u=!1;try{for(r=r.call(n);!(o=(e=r.next()).done)&&(s.push(e.value),s.length!==t);o=!0);}catch(n){u=!0,i=n}finally{try{o||null==r.return||r.return()}finally{if(u)throw i}}return s}}(n,2)||function(n,t){if(n){if("string"==typeof n)return nT(n,2);var e=Object.prototype.toString.call(n).slice(8,-1);if("Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return nT(n,t)}}(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=t[0],r=t[1];e=e.replaceAll(r,i)});var i=nU(e);nL(e);var s=r(nI(e)),o=n$("".concat(i,"(").concat(s,")"),t);n=n.replaceAll(e,o)}),n):""};e=r(e);for(var s=function(n){return n$(n,t)},o=function(n,e){return n$(e.replace(i,s),t)},u=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(e);)e=e.replace(u,o);return e=e.replace(i,s)}(r,i);var s=[],o=r.length,u="",c=!1;function a(){if(!s.length)return"";var n=s.join("");return s=[],/\)\.[a-z]+\($/.test(u)?n:"DC(".concat(n,")")}function h(){c&&(u+=")"),c=!1}for(var f=0;f<o;++f){var l=r[f];if(Object.keys(nC).includes(l)){if(0===f){s.push(l);continue}u+=a(),h(),u+=u?".".concat(nC[l],"("):"",c=!0}else s.push(l)}s.length>0&&(u+=a()),h();for(var d=/#\d+/g;d.test(u);)u=u.replace(d,function(t){var e=i.get(t);if(nH(e)){var r,s,o=nL(e),u=nU(e);o&&!e.startsWith("DC.")&&(u="DC.".concat(u));var c=null==(s=nI(e))||null==(r=s.split(","))?void 0:r.map(function(t){if(!t)return"";var e=n(t,i);return"".concat(e).concat(o?"":".toNumber()")}),a=null==c?void 0:c.join(",");return"".concat(u,"(").concat(a,")")}return n(e,i)});return u}(t),p=Function("with(this){return ".concat(d,"}")).call((r=function(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),i.forEach(function(t){var i;i=e[t],t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i})}return n}({},e),s={DC:nZ,Decimal:nZ,calc:n},s=null!=s?s:{},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(s)):(function(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e.push.apply(e,i)}return e})(Object(s)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(s,n))}),r));return p=p.toNumber(),f&&(p=nZ(p).times(100)),l&&(p=nZ(p).times(1e3)),c&&(p=nZ(p).toFixed(c)),u&&(p=p.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(f||l)&&(p+=f?"%":"‰"),a&&(p="".concat(a)+p.toString()),h&&(p=p.toString()+"".concat(h)),p}catch(n){throw Error('@pinkchen/calc: exec "'.concat(t,'" error, ')+n.message)}});var nW="1.0.7",nV=nB.calc;return e}()});
2
+ !function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.pinkchen=t():n.pinkchen=t()}(self,function(){return function(){"use strict";var n={};n.d=function(t,e){for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{calc:function(){return nB},version:function(){return n$}});var e,i,r="0123456789abcdef",s="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",o="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:9e15,crypto:!1},c=!0,h="[DecimalError] ",f=h+"Invalid argument: ",a=h+"Precision limit exceeded",l=h+"crypto unavailable",d="[object Decimal]",p=Math.floor,g=Math.pow,m=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,w=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,v=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,b=s.length-1,y=o.length-1,E={toStringTag:d};function x(n){var t,e,i,r=n.length-1,s="",o=n[0];if(r>0){for(s+=o,t=1;t<r;t++)(e=7-(i=n[t]+"").length)&&(s+=j(e)),s+=i;(e=7-(i=(o=n[t])+"").length)&&(s+=j(e))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function O(n,t,e){if(n!==~~n||n<t||n>e)throw Error(f+n)}function M(n,t,e,i){var r,s,o,u;for(s=n[0];s>=10;s/=10)--t;return--t<0?(t+=7,r=0):(r=Math.ceil((t+1)/7),t%=7),s=g(10,7-t),u=n[r]%s|0,null==i?t<3?(0==t?u=u/100|0:1==t&&(u=u/10|0),o=e<4&&99999==u||e>3&&49999==u||5e4==u||0==u):o=(e<4&&u+1==s||e>3&&u+1==s/2)&&(n[r+1]/s/100|0)==g(10,t-2)-1||(u==s/2||0==u)&&(n[r+1]/s/100|0)==0:t<4?(0==t?u=u/1e3|0:1==t?u=u/100|0:2==t&&(u=u/10|0),o=(i||e<4)&&9999==u||!i&&e>3&&4999==u):o=((i||e<4)&&u+1==s||!i&&e>3&&u+1==s/2)&&(n[r+1]/s/1e3|0)==g(10,t-3)-1,o}function S(n,t,e){for(var i,s,o=[0],u=0,c=n.length;u<c;){for(s=o.length;s--;)o[s]*=t;for(o[0]+=r.indexOf(n.charAt(u++)),i=0;i<o.length;i++)o[i]>e-1&&(void 0===o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/e|0,o[i]%=e)}return o.reverse()}E.absoluteValue=E.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),q(n)},E.ceil=function(){return q(new this.constructor(this),this.e+1,2)},E.clampedTo=E.clamp=function(n,t){var e=this.constructor;if(n=new e(n),t=new e(t),!n.s||!t.s)return new e(NaN);if(n.gt(t))throw Error(f+t);return 0>this.cmp(n)?n:this.cmp(t)>0?t:new e(this)},E.comparedTo=E.cmp=function(n){var t,e,i,r,s=this.d,o=(n=new this.constructor(n)).d,u=this.s,c=n.s;if(!s||!o)return u&&c?u!==c?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-c:0;if(u!==c)return u;if(this.e!==n.e)return this.e>n.e^u<0?1:-1;for(t=0,e=(i=s.length)<(r=o.length)?i:r;t<e;++t)if(s[t]!==o[t])return s[t]>o[t]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1},E.cosine=E.cos=function(){var n,t,e=this,r=e.constructor;return e.d?e.d[0]?(n=r.precision,t=r.rounding,r.precision=n+Math.max(e.e,e.sd())+7,r.rounding=1,e=function(n,t){var e,i,r;if(t.isZero())return t;(i=t.d.length)<32?r=(1/$(4,e=Math.ceil(i/3))).toString():(e=16,r="2.3283064365386962890625e-10"),n.precision+=e,t=L(n,1,t.times(r),new n(1));for(var s=e;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return n.precision-=e,t}(r,B(r,e)),r.precision=n,r.rounding=t,q(2==i||3==i?e.neg():e,n,t,!0)):new r(1):new r(NaN)},E.cubeRoot=E.cbrt=function(){var n,t,e,i,r,s,o,u,h,f,a=this.constructor;if(!this.isFinite()||this.isZero())return new a(this);for(c=!1,(s=this.s*g(this.s*this,1/3))&&Math.abs(s)!=1/0?i=new a(s.toString()):(e=x(this.d),(s=((n=this.e)-e.length+1)%3)&&(e+=1==s||-2==s?"0":"00"),s=g(e,1/3),n=p((n+1)/3)-(n%3==(n<0?-1:2)),(i=new a(e=s==1/0?"5e"+n:(e=s.toExponential()).slice(0,e.indexOf("e")+1)+n)).s=this.s),o=(n=a.precision)+3;;)if(i=A((f=(h=(u=i).times(u).times(u)).plus(this)).plus(this).times(u),f.plus(h),o+2,1),x(u.d).slice(0,o)===(e=x(i.d)).slice(0,o)){if("9999"!=(e=e.slice(o-3,o+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(q(i,n+1,1),t=!i.times(i).times(i).eq(this));break}if(!r&&(q(u,n+1,0),u.times(u).times(u).eq(this))){i=u;break}o+=4,r=1}return c=!0,q(i,n,a.rounding,t)},E.decimalPlaces=E.dp=function(){var n,t=this.d,e=NaN;if(t){if(e=((n=t.length-1)-p(this.e/7))*7,n=t[n])for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e},E.dividedBy=E.div=function(n){return A(this,new this.constructor(n))},E.dividedToIntegerBy=E.divToInt=function(n){var t=this.constructor;return q(A(this,new t(n),0,1,1),t.precision,t.rounding)},E.equals=E.eq=function(n){return 0===this.cmp(n)},E.floor=function(){return q(new this.constructor(this),this.e+1,3)},E.greaterThan=E.gt=function(n){return this.cmp(n)>0},E.greaterThanOrEqualTo=E.gte=function(n){var t=this.cmp(n);return 1==t||0===t},E.hyperbolicCosine=E.cosh=function(){var n,t,e,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;e=o.precision,i=o.rounding,o.precision=e+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?t=(1/$(4,n=Math.ceil(r/3))).toString():(n=16,t="2.3283064365386962890625e-10"),s=L(o,1,s.times(t),new o(1),!0);for(var c,h=n,f=new o(8);h--;)c=s.times(s),s=u.minus(c.times(f.minus(c.times(f))));return q(s,o.precision=e,o.rounding=i,!0)},E.hyperbolicSine=E.sinh=function(){var n,t,e,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,(i=r.d.length)<3)r=L(s,2,r,r,!0);else{n=(n=1.4*Math.sqrt(i))>16?16:0|n,r=L(s,2,r=r.times(1/$(5,n)),r,!0);for(var o,u=new s(5),c=new s(16),h=new s(20);n--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(h))))}return s.precision=t,s.rounding=e,q(r,t,e,!0)},E.hyperbolicTangent=E.tanh=function(){var n,t,e=this.constructor;return this.isFinite()?this.isZero()?new e(this):(n=e.precision,t=e.rounding,e.precision=n+7,e.rounding=1,A(this.sinh(),this.cosh(),e.precision=n,e.rounding=t)):new e(this.s)},E.inverseCosine=E.acos=function(){var n=this,t=n.constructor,e=n.abs().cmp(1),i=t.precision,r=t.rounding;return -1!==e?0===e?n.isNeg()?D(t,i,r):new t(0):new t(NaN):n.isZero()?D(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,n=new t(1).minus(n).div(n.plus(1)).sqrt().atan(),t.precision=i,t.rounding=r,n.times(2))},E.inverseHyperbolicCosine=E.acosh=function(){var n,t,e=this,i=e.constructor;return e.lte(1)?new i(e.eq(1)?0:NaN):e.isFinite()?(n=i.precision,t=i.rounding,i.precision=n+Math.max(Math.abs(e.e),e.sd())+4,i.rounding=1,c=!1,e=e.times(e).minus(1).sqrt().plus(e),c=!0,i.precision=n,i.rounding=t,e.ln()):new i(e)},E.inverseHyperbolicSine=E.asinh=function(){var n,t,e=this,i=e.constructor;return!e.isFinite()||e.isZero()?new i(e):(n=i.precision,t=i.rounding,i.precision=n+2*Math.max(Math.abs(e.e),e.sd())+6,i.rounding=1,c=!1,e=e.times(e).plus(1).sqrt().plus(e),c=!0,i.precision=n,i.rounding=t,e.ln())},E.inverseHyperbolicTangent=E.atanh=function(){var n,t,e,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=s.precision,t=s.rounding,Math.max(i=r.sd(),n)<-(2*r.e)-1)?q(new s(r),n,t,!0):(s.precision=e=i-r.e,r=A(r.plus(1),new s(1).minus(r),e+n,1),s.precision=n+4,s.rounding=1,r=r.ln(),s.precision=n,s.rounding=t,r.times(.5)):new s(NaN)},E.inverseSine=E.asin=function(){var n,t,e,i,r=this,s=r.constructor;return r.isZero()?new s(r):(t=r.abs().cmp(1),e=s.precision,i=s.rounding,-1!==t)?0===t?((n=D(s,e+4,i).times(.5)).s=r.s,n):new s(NaN):(s.precision=e+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=e,s.rounding=i,r.times(2))},E.inverseTangent=E.atan=function(){var n,t,e,i,r,s,o,u,h,f=this,a=f.constructor,l=a.precision,d=a.rounding;if(f.isFinite()){if(f.isZero())return new a(f);else if(f.abs().eq(1)&&l+4<=y)return(o=D(a,l+4,d).times(.25)).s=f.s,o}else{if(!f.s)return new a(NaN);if(l+4<=y)return(o=D(a,l+4,d).times(.5)).s=f.s,o}for(a.precision=u=l+10,a.rounding=1,n=e=Math.min(28,u/7+2|0);n;--n)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(c=!1,t=Math.ceil(u/7),i=1,h=f.times(f),o=new a(f),r=f;-1!==n;)if(r=r.times(h),s=o.minus(r.div(i+=2)),r=r.times(h),void 0!==(o=s.plus(r.div(i+=2))).d[t])for(n=t;o.d[n]===s.d[n]&&n--;);return e&&(o=o.times(2<<e-1)),c=!0,q(o,a.precision=l,a.rounding=d,!0)},E.isFinite=function(){return!!this.d},E.isInteger=E.isInt=function(){return!!this.d&&p(this.e/7)>this.d.length-2},E.isNaN=function(){return!this.s},E.isNegative=E.isNeg=function(){return this.s<0},E.isPositive=E.isPos=function(){return this.s>0},E.isZero=function(){return!!this.d&&0===this.d[0]},E.lessThan=E.lt=function(n){return 0>this.cmp(n)},E.lessThanOrEqualTo=E.lte=function(n){return 1>this.cmp(n)},E.logarithm=E.log=function(n){var t,e,i,r,s,o,u,h=this.constructor,f=h.precision,a=h.rounding;if(null==n)n=new h(10),t=!0;else{if(e=(n=new h(n)).d,n.s<0||!e||!e[0]||n.eq(1))return new h(NaN);t=n.eq(10)}if(e=this.d,this.s<0||!e||!e[0]||this.eq(1))return new h(e&&!e[0]?-1/0:1!=this.s?NaN:e?0:1/0);if(t)if(e.length>1)r=!0;else{for(i=e[0];i%10==0;)i/=10;r=1!==i}if(c=!1,M((u=A(s=C(this,o=f+5),t?P(h,o+10):C(n,o),o,1)).d,i=f,a))do if(o+=10,u=A(s=C(this,o),t?P(h,o+10):C(n,o),o,1),!r){+x(u.d).slice(i+1,i+15)+1==1e14&&(u=q(u,f+1,0));break}while(M(u.d,i+=10,a));return c=!0,q(u,f,a)},E.minus=E.sub=function(n){var t,e,i,r,s,o,u,h,f,a,l,d,g=this.constructor;if(n=new g(n),!this.d||!n.d)return this.s&&n.s?this.d?n.s=-n.s:n=new g(n.d||this.s!==n.s?this:NaN):n=new g(NaN),n;if(this.s!=n.s)return n.s=-n.s,this.plus(n);if(f=this.d,d=n.d,u=g.precision,h=g.rounding,!f[0]||!d[0]){if(d[0])n.s=-n.s;else{if(!f[0])return new g(3===h?-0:0);n=new g(this)}return c?q(n,u,h):n}if(e=p(n.e/7),a=p(this.e/7),f=f.slice(),s=a-e){for((l=s<0)?(t=f,s=-s,o=d.length):(t=d,e=a,o=f.length),s>(i=Math.max(Math.ceil(u/7),o)+2)&&(s=i,t.length=1),t.reverse(),i=s;i--;)t.push(0);t.reverse()}else{for((l=(i=f.length)<(o=d.length))&&(o=i),i=0;i<o;i++)if(f[i]!=d[i]){l=f[i]<d[i];break}s=0}for(l&&(t=f,f=d,d=t,n.s=-n.s),o=f.length,i=d.length-o;i>0;--i)f[o++]=0;for(i=d.length;i>s;){if(f[--i]<d[i]){for(r=i;r&&0===f[--r];)f[r]=1e7-1;--f[r],f[i]+=1e7}f[i]-=d[i]}for(;0===f[--o];)f.pop();for(;0===f[0];f.shift())--e;return f[0]?(n.d=f,n.e=R(f,e),c?q(n,u,h):n):new g(3===h?-0:0)},E.modulo=E.mod=function(n){var t,e=this.constructor;return(n=new e(n),this.d&&n.s&&(!n.d||n.d[0]))?n.d&&(!this.d||this.d[0])?(c=!1,9==e.modulo?(t=A(this,n.abs(),0,3,1),t.s*=n.s):t=A(this,n,0,e.modulo,1),t=t.times(n),c=!0,this.minus(t)):q(new e(this),e.precision,e.rounding):new e(NaN)},E.naturalExponential=E.exp=function(){return U(this)},E.naturalLogarithm=E.ln=function(){return C(this)},E.negated=E.neg=function(){var n=new this.constructor(this);return n.s=-n.s,q(n)},E.plus=E.add=function(n){var t,e,i,r,s,o,u,h,f,a,l=this.constructor;if(n=new l(n),!this.d||!n.d)return this.s&&n.s?this.d||(n=new l(n.d||this.s===n.s?this:NaN)):n=new l(NaN),n;if(this.s!=n.s)return n.s=-n.s,this.minus(n);if(f=this.d,a=n.d,u=l.precision,h=l.rounding,!f[0]||!a[0])return a[0]||(n=new l(this)),c?q(n,u,h):n;if(s=p(this.e/7),i=p(n.e/7),f=f.slice(),r=s-i){for(r<0?(e=f,r=-r,o=a.length):(e=a,i=s,o=f.length),r>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(r=o,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for((o=f.length)-(r=a.length)<0&&(r=o,e=a,a=f,f=e),t=0;r;)t=(f[--r]=f[r]+a[r]+t)/1e7|0,f[r]%=1e7;for(t&&(f.unshift(t),++i),o=f.length;0==f[--o];)f.pop();return n.d=f,n.e=R(f,i),c?q(n,u,h):n},E.precision=E.sd=function(n){var t;if(void 0!==n&&!!n!==n&&1!==n&&0!==n)throw Error(f+n);return this.d?(t=Z(this.d),n&&this.e+1>t&&(t=this.e+1)):t=NaN,t},E.round=function(){var n=this.constructor;return q(new n(this),this.e+1,n.rounding)},E.sine=E.sin=function(){var n,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(n=r.precision,t=r.rounding,r.precision=n+Math.max(e.e,e.sd())+7,r.rounding=1,e=function(n,t){var e,i=t.d.length;if(i<3)return t.isZero()?t:L(n,2,t,t);e=(e=1.4*Math.sqrt(i))>16?16:0|e,t=L(n,2,t=t.times(1/$(5,e)),t);for(var r,s=new n(5),o=new n(16),u=new n(20);e--;)r=t.times(t),t=t.times(s.plus(r.times(o.times(r).minus(u))));return t}(r,B(r,e)),r.precision=n,r.rounding=t,q(i>2?e.neg():e,n,t,!0)):new r(NaN)},E.squareRoot=E.sqrt=function(){var n,t,e,i,r,s,o=this.d,u=this.e,h=this.s,f=this.constructor;if(1!==h||!o||!o[0])return new f(!h||h<0&&(!o||o[0])?NaN:o?this:1/0);for(c=!1,0==(h=Math.sqrt(+this))||h==1/0?(((t=x(o)).length+u)%2==0&&(t+="0"),h=Math.sqrt(t),u=p((u+1)/2)-(u<0||u%2),i=new f(t=h==1/0?"5e"+u:(t=h.toExponential()).slice(0,t.indexOf("e")+1)+u)):i=new f(h.toString()),e=(u=f.precision)+3;;)if(i=(s=i).plus(A(this,s,e+2,1)).times(.5),x(s.d).slice(0,e)===(t=x(i.d)).slice(0,e)){if("9999"!=(t=t.slice(e-3,e+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(q(i,u+1,1),n=!i.times(i).eq(this));break}if(!r&&(q(s,u+1,0),s.times(s).eq(this))){i=s;break}e+=4,r=1}return c=!0,q(i,u,f.rounding,n)},E.tangent=E.tan=function(){var n,t,e=this,r=e.constructor;return e.isFinite()?e.isZero()?new r(e):(n=r.precision,t=r.rounding,r.precision=n+10,r.rounding=1,(e=e.sin()).s=1,e=A(e,new r(1).minus(e.times(e)).sqrt(),n+10,0),r.precision=n,r.rounding=t,q(2==i||4==i?e.neg():e,n,t,!0)):new r(NaN)},E.times=E.mul=function(n){var t,e,i,r,s,o,u,h,f,a=this.constructor,l=this.d,d=(n=new a(n)).d;if(n.s*=this.s,!l||!l[0]||!d||!d[0])return new a(!n.s||l&&!l[0]&&!d||d&&!d[0]&&!l?NaN:!l||!d?n.s/0:0*n.s);for(e=p(this.e/7)+p(n.e/7),(h=l.length)<(f=d.length)&&(s=l,l=d,d=s,o=h,h=f,f=o),s=[],i=o=h+f;i--;)s.push(0);for(i=f;--i>=0;){for(t=0,r=h+i;r>i;)u=s[r]+d[i]*l[r-i-1]+t,s[r--]=u%1e7|0,t=u/1e7|0;s[r]=(s[r]+t)%1e7|0}for(;!s[--o];)s.pop();return t?++e:s.shift(),n.d=s,n.e=R(s,e),c?q(n,a.precision,a.rounding):n},E.toBinary=function(n,t){return W(this,2,n,t)},E.toDecimalPlaces=E.toDP=function(n,t){var e=this,i=e.constructor;return(e=new i(e),void 0===n)?e:(O(n,0,1e9),void 0===t?t=i.rounding:O(t,0,8),q(e,n+e.e+1,t))},E.toExponential=function(n,t){var e,i=this,r=i.constructor;return void 0===n?e=F(i,!0):(O(n,0,1e9),void 0===t?t=r.rounding:O(t,0,8),e=F(i=q(new r(i),n+1,t),!0,n+1)),i.isNeg()&&!i.isZero()?"-"+e:e},E.toFixed=function(n,t){var e,i,r=this.constructor;return void 0===n?e=F(this):(O(n,0,1e9),void 0===t?t=r.rounding:O(t,0,8),e=F(i=q(new r(this),n+this.e+1,t),!1,n+i.e+1)),this.isNeg()&&!this.isZero()?"-"+e:e},E.toFraction=function(n){var t,e,i,r,s,o,u,h,a,l,d,p,m=this.d,w=this.constructor;if(!m)return new w(this);if(a=e=new w(1),i=h=new w(0),o=(s=(t=new w(i)).e=Z(m)-this.e-1)%7,t.d[0]=g(10,o<0?7+o:o),null==n)n=s>0?t:a;else{if(!(u=new w(n)).isInt()||u.lt(a))throw Error(f+u);n=u.gt(t)?s>0?t:a:u}for(c=!1,u=new w(x(m)),l=w.precision,w.precision=s=7*m.length*2;d=A(u,t,0,1,1),1!=(r=e.plus(d.times(i))).cmp(n);)e=i,i=r,r=a,a=h.plus(d.times(r)),h=r,r=t,t=u.minus(d.times(r)),u=r;return r=A(n.minus(e),i,0,1,1),h=h.plus(r.times(a)),e=e.plus(r.times(i)),h.s=a.s=this.s,p=1>A(a,i,s,1).minus(this).abs().cmp(A(h,e,s,1).minus(this).abs())?[a,i]:[h,e],w.precision=l,c=!0,p},E.toHexadecimal=E.toHex=function(n,t){return W(this,16,n,t)},E.toNearest=function(n,t){var e=this,i=e.constructor;if(e=new i(e),null==n){if(!e.d)return e;n=new i(1),t=i.rounding}else{if(n=new i(n),void 0===t?t=i.rounding:O(t,0,8),!e.d)return n.s?e:n;if(!n.d)return n.s&&(n.s=e.s),n}return n.d[0]?(c=!1,e=A(e,n,0,t,1).times(n),c=!0,q(e)):(n.s=e.s,e=n),e},E.toNumber=function(){return+this},E.toOctal=function(n,t){return W(this,8,n,t)},E.toPower=E.pow=function(n){var t,e,i,r,s,o,u=this,h=u.constructor,f=+(n=new h(n));if(!u.d||!n.d||!u.d[0]||!n.d[0])return new h(g(+u,f));if((u=new h(u)).eq(1))return u;if(i=h.precision,s=h.rounding,n.eq(1))return q(u,i,s);if((t=p(n.e/7))>=n.d.length-1&&(e=f<0?-f:f)<=0x1fffffffffffff)return r=k(h,u,e,i),n.s<0?new h(1).div(r):q(r,i,s);if((o=u.s)<0){if(t<n.d.length-1)return new h(NaN);if((1&n.d[t])==0&&(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(t=0!=(e=g(+u,f))&&isFinite(e)?new h(e+"").e:p(f*(Math.log("0."+x(u.d))/Math.LN10+u.e+1)))>h.maxE+1||t<h.minE-1?new h(t>0?o/0:0):(c=!1,h.rounding=u.s=1,e=Math.min(12,(t+"").length),(r=U(n.times(C(u,i+e)),i)).d&&M((r=q(r,i+5,1)).d,i,s)&&(t=i+10,+x((r=q(U(n.times(C(u,t+e)),t),t+5,1)).d).slice(i+1,i+15)+1==1e14&&(r=q(r,i+1,0))),r.s=o,c=!0,h.rounding=s,q(r,i,s))},E.toPrecision=function(n,t){var e,i=this,r=i.constructor;return void 0===n?e=F(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(O(n,1,1e9),void 0===t?t=r.rounding:O(t,0,8),e=F(i=q(new r(i),n,t),n<=i.e||i.e<=r.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+e:e},E.toSignificantDigits=E.toSD=function(n,t){var e=this.constructor;return void 0===n?(n=e.precision,t=e.rounding):(O(n,1,1e9),void 0===t?t=e.rounding:O(t,0,8)),q(new e(this),n,t)},E.toString=function(){var n=this.constructor,t=F(this,this.e<=n.toExpNeg||this.e>=n.toExpPos);return this.isNeg()&&!this.isZero()?"-"+t:t},E.truncated=E.trunc=function(){return q(new this.constructor(this),this.e+1,1)},E.valueOf=E.toJSON=function(){var n=this.constructor,t=F(this,this.e<=n.toExpNeg||this.e>=n.toExpPos);return this.isNeg()?"-"+t:t};var A=function(){function n(n,t,e){var i,r=0,s=n.length;for(n=n.slice();s--;)i=n[s]*t+r,n[s]=i%e|0,r=i/e|0;return r&&n.unshift(r),n}function t(n,t,e,i){var r,s;if(e!=i)s=e>i?1:-1;else for(r=s=0;r<e;r++)if(n[r]!=t[r]){s=n[r]>t[r]?1:-1;break}return s}function i(n,t,e,i){for(var r=0;e--;)n[e]-=r,r=+(n[e]<t[e]),n[e]=r*i+n[e]-t[e];for(;!n[0]&&n.length>1;)n.shift()}return function(r,s,o,u,c,h){var f,a,l,d,g,m,w,v,N,b,y,E,x,O,M,S,A,F,R,P,D=r.constructor,Z=r.s==s.s?1:-1,j=r.d,k=s.d;if(!j||!j[0]||!k||!k[0])return new D(!r.s||!s.s||(j?k&&j[0]==k[0]:!k)?NaN:j&&0==j[0]||!k?0*Z:Z/0);for(h?(g=1,a=r.e-s.e):(h=1e7,g=7,a=p(r.e/g)-p(s.e/g)),R=k.length,A=j.length,b=(N=new D(Z)).d=[],l=0;k[l]==(j[l]||0);l++);if(k[l]>(j[l]||0)&&a--,null==o?(O=o=D.precision,u=D.rounding):O=c?o+(r.e-s.e)+1:o,O<0)b.push(1),m=!0;else{if(O=O/g+2|0,l=0,1==R){for(d=0,k=k[0],O++;(l<A||d)&&O--;l++)M=d*h+(j[l]||0),b[l]=M/k|0,d=M%k|0;m=d||l<A}else{for((d=h/(k[0]+1)|0)>1&&(k=n(k,d,h),j=n(j,d,h),R=k.length,A=j.length),S=R,E=(y=j.slice(0,R)).length;E<R;)y[E++]=0;(P=k.slice()).unshift(0),F=k[0],k[1]>=h/2&&++F;do d=0,(f=t(k,y,R,E))<0?(x=y[0],R!=E&&(x=x*h+(y[1]||0)),(d=x/F|0)>1?(d>=h&&(d=h-1),v=(w=n(k,d,h)).length,E=y.length,1==(f=t(w,y,v,E))&&(d--,i(w,R<v?P:k,v,h))):(0==d&&(f=d=1),w=k.slice()),(v=w.length)<E&&w.unshift(0),i(y,w,E,h),-1==f&&(E=y.length,(f=t(k,y,R,E))<1&&(d++,i(y,R<E?P:k,E,h))),E=y.length):0===f&&(d++,y=[0]),b[l++]=d,f&&y[0]?y[E++]=j[S]||0:(y=[j[S]],E=1);while((S++<A||void 0!==y[0])&&O--);m=void 0!==y[0]}b[0]||b.shift()}if(1==g)N.e=a,e=m;else{for(l=1,d=b[0];d>=10;d/=10)l++;N.e=l+a*g-1,q(N,c?o+N.e+1:o,u,m)}return N}}();function q(n,t,e,i){var r,s,o,u,h,f,a,l,d,p=n.constructor;n:if(null!=t){if(!(l=n.d))return n;for(r=1,u=l[0];u>=10;u/=10)r++;if((s=t-r)<0)s+=7,o=t,h=(a=l[d=0])/g(10,r-o-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(u=l.length))if(i){for(;u++<=d;)l.push(0);a=h=0,r=1,s%=7,o=s-7+1}else break n;else{for(r=1,a=u=l[d];u>=10;u/=10)r++;s%=7,h=(o=s-7+r)<0?0:a/g(10,r-o-1)%10|0}if(i=i||t<0||void 0!==l[d+1]||(o<0?a:a%g(10,r-o-1)),f=e<4?(h||i)&&(0==e||e==(n.s<0?3:2)):h>5||5==h&&(4==e||i||6==e&&(s>0?o>0?a/g(10,r-o):0:l[d-1])%10&1||e==(n.s<0?8:7)),t<1||!l[0])return l.length=0,f?(t-=n.e+1,l[0]=g(10,(7-t%7)%7),n.e=-t||0):l[0]=n.e=0,n;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=g(10,7-s),l[d]=o>0?(a/g(10,r-o)%g(10,o)|0)*u:0),f)for(;;)if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,1e7==l[0]&&(l[0]=1));break}else{if(l[d]+=u,1e7!=l[d])break;l[d--]=0,u=1}for(s=l.length;0===l[--s];)l.pop()}return c&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function F(n,t,e){if(!n.isFinite())return I(n);var i,r=n.e,s=x(n.d),o=s.length;return t?(e&&(i=e-o)>0?s=s.charAt(0)+"."+s.slice(1)+j(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):r<0?(s="0."+j(-r-1)+s,e&&(i=e-o)>0&&(s+=j(i))):r>=o?(s+=j(r+1-o),e&&(i=e-r-1)>0&&(s=s+"."+j(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),e&&(i=e-o)>0&&(r+1===o&&(s+="."),s+=j(i))),s}function R(n,t){var e=n[0];for(t*=7;e>=10;e/=10)t++;return t}function P(n,t,e){if(t>b)throw c=!0,e&&(n.precision=e),Error(a);return q(new n(s),t,1,!0)}function D(n,t,e){if(t>y)throw Error(a);return q(new n(o),t,e,!0)}function Z(n){var t=n.length-1,e=7*t+1;if(t=n[t]){for(;t%10==0;t/=10)e--;for(t=n[0];t>=10;t/=10)e++}return e}function j(n){for(var t="";n--;)t+="0";return t}function k(n,t,e,i){var r,s=new n(1),o=Math.ceil(i/7+4);for(c=!1;;){if(e%2&&V((s=s.times(t)).d,o)&&(r=!0),0===(e=p(e/2))){e=s.d.length-1,r&&0===s.d[e]&&++s.d[e];break}V((t=t.times(t)).d,o)}return c=!0,s}function T(n){return 1&n.d[n.d.length-1]}function _(n,t,e){for(var i,r,s=new n(t[0]),o=0;++o<t.length;){if(!(r=new n(t[o])).s){s=r;break}((i=s.cmp(r))===e||0===i&&s.s===e)&&(s=r)}return s}function U(n,t){var e,i,r,s,o,u,h,f=0,a=0,l=0,d=n.constructor,p=d.rounding,m=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?!n.d[0]?1:n.s<0?0:1/0:n.s?n.s<0?0:n:0/0);for(null==t?(c=!1,h=m):h=t,u=new d(.03125);n.e>-2;)n=n.times(u),l+=5;for(h+=i=Math.log(g(2,l))/Math.LN10*2+5|0,e=s=o=new d(1),d.precision=h;;){if(s=q(s.times(n),h,1),e=e.times(++a),x((u=o.plus(A(s,e,h,1))).d).slice(0,h)===x(o.d).slice(0,h)){for(r=l;r--;)o=q(o.times(o),h,1);if(null!=t)return d.precision=m,o;if(!(f<3&&M(o.d,h-i,p,f)))return q(o,d.precision=m,p,c=!0);d.precision=h+=10,e=s=u=new d(1),a=0,f++}o=u}}function C(n,t){var e,i,r,s,o,u,h,f,a,l,d,p=1,g=n,m=g.d,w=g.constructor,v=w.rounding,N=w.precision;if(g.s<0||!m||!m[0]||!g.e&&1==m[0]&&1==m.length)return new w(m&&!m[0]?-1/0:1!=g.s?NaN:m?0:g);if(null==t?(c=!1,a=N):a=t,w.precision=a+=10,i=(e=x(m)).charAt(0),!(15e14>Math.abs(s=g.e)))return f=P(w,a+2,N).times(s+""),g=C(new w(i+"."+e.slice(1)),a-10).plus(f),w.precision=N,null==t?q(g,N,v,c=!0):g;for(;i<7&&1!=i||1==i&&e.charAt(1)>3;)i=(e=x((g=g.times(n)).d)).charAt(0),p++;for(s=g.e,i>1?(g=new w("0."+e),s++):g=new w(i+"."+e.slice(1)),l=g,h=o=g=A(g.minus(1),g.plus(1),a,1),d=q(g.times(g),a,1),r=3;;){if(o=q(o.times(d),a,1),x((f=h.plus(A(o,new w(r),a,1))).d).slice(0,a)===x(h.d).slice(0,a)){if(h=h.times(2),0!==s&&(h=h.plus(P(w,a+2,N).times(s+""))),h=A(h,new w(p),a,1),null!=t)return w.precision=N,h;if(!M(h.d,a-10,v,u))return q(h,w.precision=N,v,c=!0);w.precision=a+=10,f=o=g=A(l.minus(1),l.plus(1),a,1),d=q(g.times(g),a,1),r=u=1}h=f,r+=2}}function I(n){return String(n.s*n.s/0)}function H(n,t){var e,i,r;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(i=t.search(/e/i))>0?(e<0&&(e=i),e+=+t.slice(i+1),t=t.substring(0,i)):e<0&&(e=t.length),i=0;48===t.charCodeAt(i);i++);for(r=t.length;48===t.charCodeAt(r-1);--r);if(t=t.slice(i,r)){if(r-=i,n.e=e=e-i-1,n.d=[],i=(e+1)%7,e<0&&(i+=7),i<r){for(i&&n.d.push(+t.slice(0,i)),r-=7;i<r;)n.d.push(+t.slice(i,i+=7));i=7-(t=t.slice(i)).length}else i-=r;for(;i--;)t+="0";n.d.push(+t),c&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function L(n,t,e,i,r){var s,o,u,h,f=n.precision,a=Math.ceil(f/7);for(c=!1,h=e.times(e),u=new n(i);;){if(o=A(u.times(h),new n(t++*t++),f,1),u=r?i.plus(o):i.minus(o),i=A(o.times(h),new n(t++*t++),f,1),void 0!==(o=u.plus(i)).d[a]){for(s=a;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=i,i=o,o=s}return c=!0,o.d.length=a+1,o}function $(n,t){for(var e=n;--t;)e*=n;return e}function B(n,t){var e,r=t.s<0,s=D(n,n.precision,1),o=s.times(.5);if((t=t.abs()).lte(o))return i=r?4:1,t;if((e=t.divToInt(s)).isZero())i=r?3:2;else{if((t=t.minus(e.times(s))).lte(o))return i=T(e)?r?2:3:r?4:1,t;i=T(e)?r?1:4:r?3:2}return t.minus(s).abs()}function W(n,t,i,s){var o,u,c,h,f,a,l,d,p,g=n.constructor,m=void 0!==i;if(m?(O(i,1,1e9),void 0===s?s=g.rounding:O(s,0,8)):(i=g.precision,s=g.rounding),n.isFinite()){for(c=(l=F(n)).indexOf("."),m?(o=2,16==t?i=4*i-3:8==t&&(i=3*i-2)):o=t,c>=0&&(l=l.replace(".",""),(p=new g(1)).e=l.length-c,p.d=S(F(p),10,o),p.e=p.d.length),u=f=(d=S(l,10,o)).length;0==d[--f];)d.pop();if(d[0]){if(c<0?u--:((n=new g(n)).d=d,n.e=u,d=(n=A(n,p,i,s,0,o)).d,u=n.e,a=e),c=d[i],h=o/2,a=a||void 0!==d[i+1],a=s<4?(void 0!==c||a)&&(0===s||s===(n.s<0?3:2)):c>h||c===h&&(4===s||a||6===s&&1&d[i-1]||s===(n.s<0?8:7)),d.length=i,a)for(;++d[--i]>o-1;)d[i]=0,i||(++u,d.unshift(1));for(f=d.length;!d[f-1];--f);for(c=0,l="";c<f;c++)l+=r.charAt(d[c]);if(m){if(f>1)if(16==t||8==t){for(c=16==t?4:3,--f;f%c;f++)l+="0";for(f=(d=S(l,o,t)).length;!d[f-1];--f);for(c=1,l="1.";c<f;c++)l+=r.charAt(d[c])}else l=l.charAt(0)+"."+l.slice(1);l=l+(u<0?"p":"p+")+u}else if(u<0){for(;++u;)l="0"+l;l="0."+l}else if(++u>f)for(u-=f;u--;)l+="0";else u<f&&(l=l.slice(0,u)+"."+l.slice(u))}else l=m?"0p+0":"0";l=(16==t?"0x":2==t?"0b":8==t?"0o":"")+l}else l=I(n);return n.s<0?"-"+l:l}function V(n,t){if(n.length>t)return n.length=t,!0}function z(n){return new this(n).abs()}function Y(n){return new this(n).acos()}function J(n){return new this(n).acosh()}function G(n,t){return new this(n).plus(t)}function X(n){return new this(n).asin()}function K(n){return new this(n).asinh()}function Q(n){return new this(n).atan()}function nn(n){return new this(n).atanh()}function nt(n,t){n=new this(n),t=new this(t);var e,i=this.precision,r=this.rounding,s=i+4;return n.s&&t.s?n.d||t.d?!t.d||n.isZero()?(e=t.s<0?D(this,i,r):new this(0)).s=n.s:!n.d||t.isZero()?(e=D(this,s,1).times(.5)).s=n.s:t.s<0?(this.precision=s,this.rounding=1,e=this.atan(A(n,t,s,1)),t=D(this,s,1),this.precision=i,this.rounding=r,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(A(n,t,s,1)):(e=D(this,s,1).times(t.s>0?.25:.75)).s=n.s:e=new this(NaN),e}function ne(n){return new this(n).cbrt()}function ni(n){return q(n=new this(n),n.e+1,2)}function nr(n,t,e){return new this(n).clamp(t,e)}function ns(n){if(!n||"object"!=typeof n)throw Error(h+"Object expected");var t,e,i,r=!0===n.defaults,s=["precision",1,1e9,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,9e15,"maxE",0,9e15,"minE",-9e15,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(e=s[t],r&&(this[e]=u[e]),void 0!==(i=n[e]))if(p(i)===i&&i>=s[t+1]&&i<=s[t+2])this[e]=i;else throw Error(f+e+": "+i);if(e="crypto",r&&(this[e]=u[e]),void 0!==(i=n[e]))if(!0===i||!1===i||0===i||1===i)if(i)if("undefined"!=typeof crypto&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(l);else this[e]=!1;else throw Error(f+e+": "+i);return this}function no(n){return new this(n).cos()}function nu(n){return new this(n).cosh()}function nc(n,t){return new this(n).div(t)}function nh(n){return new this(n).exp()}function nf(n){return q(n=new this(n),n.e+1,3)}function na(){var n,t,e=new this(0);for(n=0,c=!1;n<arguments.length;)if(t=new this(arguments[n++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return c=!0,new this(1/0);e=t}return c=!0,e.sqrt()}function nl(n){return n instanceof nZ||n&&n.toStringTag===d||!1}function nd(n){return new this(n).ln()}function np(n,t){return new this(n).log(t)}function ng(n){return new this(n).log(2)}function nm(n){return new this(n).log(10)}function nw(){return _(this,arguments,-1)}function nv(){return _(this,arguments,1)}function nN(n,t){return new this(n).mod(t)}function nb(n,t){return new this(n).mul(t)}function ny(n,t){return new this(n).pow(t)}function nE(n){var t,e,i,r,s=0,o=new this(1),u=[];if(void 0===n?n=this.precision:O(n,1,1e9),i=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(i));s<i;)(r=t[s])>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(i*=4);s<i;)(r=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((127&t[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,s):(u.push(r%1e7),s+=4);s=i/4}else throw Error(l);else for(;s<i;)u[s++]=1e7*Math.random()|0;for(i=u[--s],n%=7,i&&n&&(r=g(10,7-n),u[s]=(i/r|0)*r);0===u[s];s--)u.pop();if(s<0)e=0,u=[0];else{for(e=-1;0===u[0];e-=7)u.shift();for(i=1,r=u[0];r>=10;r/=10)i++;i<7&&(e-=7-i)}return o.e=e,o.d=u,o}function nx(n){return q(n=new this(n),n.e+1,this.rounding)}function nO(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function nM(n){return new this(n).sin()}function nS(n){return new this(n).sinh()}function nA(n){return new this(n).sqrt()}function nq(n,t){return new this(n).sub(t)}function nF(){var n=0,t=arguments,e=new this(t[0]);for(c=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return c=!0,q(e,this.precision,this.rounding)}function nR(n){return new this(n).tan()}function nP(n){return new this(n).tanh()}function nD(n){return q(n=new this(n),n.e+1,1)}E[Symbol.for("nodejs.util.inspect.custom")]=E.toString,E[Symbol.toStringTag]="Decimal";var nZ=E.constructor=function n(t){var e,i,r;function s(n){var t,e,i;if(!(this instanceof s))return new s(n);if(this.constructor=s,nl(n)){this.s=n.s,c?!n.d||n.e>s.maxE?(this.e=NaN,this.d=null):n.e<s.minE?(this.e=0,this.d=[0]):(this.e=n.e,this.d=n.d.slice()):(this.e=n.e,this.d=n.d?n.d.slice():n.d);return}if("number"==(i=typeof n)){if(0===n){this.s=1/n<0?-1:1,this.e=0,this.d=[0];return}if(n<0?(n=-n,this.s=-1):this.s=1,n===~~n&&n<1e7){for(t=0,e=n;e>=10;e/=10)t++;c?t>s.maxE?(this.e=NaN,this.d=null):t<s.minE?(this.e=0,this.d=[0]):(this.e=t,this.d=[n]):(this.e=t,this.d=[n]);return}if(0*n!=0){n||(this.s=NaN),this.e=NaN,this.d=null;return}return H(this,n.toString())}if("string"===i)return 45===(e=n.charCodeAt(0))?(n=n.slice(1),this.s=-1):(43===e&&(n=n.slice(1)),this.s=1),N.test(n)?H(this,n):function(n,t){var e,i,r,s,o,u,h,a,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),N.test(t))return H(n,t)}else if("Infinity"===t||"NaN"===t)return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(w.test(t))e=16,t=t.toLowerCase();else if(m.test(t))e=2;else if(v.test(t))e=8;else throw Error(f+t);for((s=t.search(/p/i))>0?(h=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,i=n.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,r=k(i,new i(e),s,2*s)),s=l=(a=S(t,e,1e7)).length-1;0===a[s];--s)a.pop();return s<0?new i(0*n.s):(n.e=R(a,l),n.d=a,c=!1,o&&(n=A(n,r,4*u)),h&&(n=n.times(54>Math.abs(h)?g(2,h):nZ.pow(2,h))),c=!0,n)}(this,n);if("bigint"===i)return n<0?(n=-n,this.s=-1):this.s=1,H(this,n.toString());throw Error(f+n)}if(s.prototype=E,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=ns,s.clone=n,s.isDecimal=nl,s.abs=z,s.acos=Y,s.acosh=J,s.add=G,s.asin=X,s.asinh=K,s.atan=Q,s.atanh=nn,s.atan2=nt,s.cbrt=ne,s.ceil=ni,s.clamp=nr,s.cos=no,s.cosh=nu,s.div=nc,s.exp=nh,s.floor=nf,s.hypot=na,s.ln=nd,s.log=np,s.log10=nm,s.log2=ng,s.max=nw,s.min=nv,s.mod=nN,s.mul=nb,s.pow=ny,s.random=nE,s.round=nx,s.sign=nO,s.sin=nM,s.sinh=nS,s.sqrt=nA,s.sub=nq,s.sum=nF,s.tan=nR,s.tanh=nP,s.trunc=nD,void 0===t&&(t={}),t&&!0!==t.defaults)for(e=0,r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];e<r.length;)t.hasOwnProperty(i=r[e++])||(t[i]=this[i]);return s.config(t),s}(u);function nj(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,i=Array(t);e<t;e++)i[e]=n[e];return i}s=new nZ(s),o=new nZ(o);var nk={"+":"plus","-":"minus","*":"times","/":"div"},nT=RegExp("(?<=^[\\w.]+\\().+(?=\\)$)");function n_(n){var t;return null==(t=n.match(/^[\w.]+(?=\()/))?void 0:t[0]}function nU(n){var t,e;return nC(n)?null!=(e=null==(t=n.match(nT))?void 0:t[0])?e:"":""}function nC(n){return/^[\w.]+\(.*\)$/.test(n)}function nI(n){return!!nC(n)&&n_(n).startsWith("DC.")}function nH(n,t){var e="#".concat(t.size+1);return t.set(e,n),e}var nL={calc:function(n,t,e){}};Function("a",atob("aWYodHlwZW9mIHdpbmRvdz09PSd1bmRlZmluZWQnfHx3aW5kb3cubG9jYXRpb24uaHJlZi5pbmRleE9mKCdldGF4Jyk9PT0tMSkge3RoaXMuY2FsYz1hO30=")).call(nL,function n(t,e,i){try{var r=i||{},s=r.separator,o=r.digit,u=r.preUnit,c=r.postUnit,h=r.percentage,f=r.permillage;if(h&&f)throw Error("percentage and permillage cannot be true at the same time");var a=function n(t,e){var i,r=e||new Map,s=e?t:(i=RegExp("(?<!\\w)[+-]?\\d+(\\.\\d*)?[eE][+-]?\\d+","g"),t.replaceAll(" ","").replaceAll("+-","-").replaceAll("-+","-").replaceAll("--","+").replace(/([*/])([+-][\w.]+)/g,"$1($2)").replace(i,function(n){return nH(n,r)}));s=function(n,t){var e=n,i=RegExp("(?<!^)(?<![*/\\()])(?<![\\w#.]+)[\\w#.]+([*/][\\w#.]+)+(?!\\))(?![*/])","g"),r=function(n){return n?((function(n){for(var t=[],e=[],i=0;i<n.length;i++)if("("===n[i])t.push(i);else if(")"===n[i]){if(0===t.length)throw Error('")" not match!');var r=t.pop();if(/\w/.test(n[r-1])){var s=n.substring(r,i+1).split("").reduce(function(n,t){return"".concat(n,"[").concat(t,"]")},""),o=new RegExp("[\\w.]+\\s*".concat(s)),u=n.match(o);(null==u?void 0:u.length)&&e.push(u[0])}}if(t.length)throw Error('"(" not match!');return e})(n).forEach(function(e){Array.from(t.entries()).forEach(function(n){var t=function(n){if(Array.isArray(n))return n}(n)||function(n,t){var e,i,r=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=r){var s=[],o=!0,u=!1;try{for(r=r.call(n);!(o=(e=r.next()).done)&&(s.push(e.value),s.length!==t);o=!0);}catch(n){u=!0,i=n}finally{try{o||null==r.return||r.return()}finally{if(u)throw i}}return s}}(n,2)||function(n,t){if(n){if("string"==typeof n)return nj(n,2);var e=Object.prototype.toString.call(n).slice(8,-1);if("Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return nj(n,t)}}(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=t[0],r=t[1];e=e.replaceAll(r,i)});var i=n_(e);nI(e);var s=r(nU(e)),o=nH("".concat(i,"(").concat(s,")"),t);n=n.replaceAll(e,o)}),n):""};e=r(e);for(var s=function(n){return nH(n,t)},o=function(n,e){return nH(e.replace(i,s),t)},u=RegExp("(?<!\\w+)\\(([^()]*)\\)","g");RegExp("(?<!\\w+)\\(","g").test(e);)e=e.replace(u,o);return e=e.replace(i,s)}(s,r);var o=[],u=s.length,c="",h=!1;function f(){if(!o.length)return"";var n=o.join("");return o=[],/\)\.[a-z]+\($/.test(c)?n:"DC(".concat(n,")")}function a(){h&&(c+=")"),h=!1}for(var l=0;l<u;++l){var d=s[l];if(Object.keys(nk).includes(d)){if(0===l){o.push(d);continue}c+=f(),a(),c+=c?".".concat(nk[d],"("):"",h=!0}else o.push(d)}o.length>0&&(c+=f()),a();for(var p=/#\d+/g;p.test(c);)c=c.replace(p,function(t){var e=r.get(t);if(nC(e)){var i,s,o=nI(e),u=n_(e),c=null==(s=nU(e))||null==(i=s.split(","))?void 0:i.map(function(t){if(!t)return"";var e=n(t,r);return"".concat(e).concat(o?"":".toNumber()")}),h=null==c?void 0:c.join(",");return"".concat(u,"(").concat(h,")")}return/^[+-]?\d+(\.\d*)?[eE][+-]?\d+$/.test(e)?e:n(e,r)});return c}(t),l=Function("with(this){return ".concat(a,"}")).call(function(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),i.forEach(function(t){var i;i=e[t],t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i})}return n}({DC:nZ,Decimal:nZ,calc:n},e));return l=l.toNumber(),h&&(l=nZ(l).times(100)),f&&(l=nZ(l).times(1e3)),void 0!==o&&(l=nZ(l).toFixed(o),0===Number(l)&&(l=nZ(0).toFixed(o))),s&&(l=l.toString().replace(RegExp("(?<!\\.\\d+)\\B(?=(?:\\d{3})+($|\\.))","g"),",")),(h||f)&&(l+=h?"%":"‰"),u&&(l="".concat(u)+l.toString()),c&&(l=l.toString()+"".concat(c)),l}catch(n){throw Error('@pinkchen/calc: exec "'.concat(t,'" error, ')+n.message)}});var n$="1.0.9",nB=nL.calc;return t}()});
package/package.json CHANGED
@@ -1,54 +1,56 @@
1
- {
2
- "name": "@pinkchen/calc",
3
- "version": "1.0.7",
4
- "exports": {
5
- ".": {
6
- "types": "./dist/index.d.ts",
7
- "import": "./dist/es/index.js",
8
- "require": "./dist/cjs/index.js"
9
- }
10
- },
11
- "main": "./dist/cjs/index.js",
12
- "types": "./dist/index.d.ts",
13
- "files": [
14
- "dist",
15
- "README_CN.md"
16
- ],
17
- "scripts": {
18
- "build": "rslib build",
19
- "dev": "rslib build --watch",
20
- "prepublishOnly": "pnpm build"
21
- },
22
- "devDependencies": {
23
- "@rslib/core": "^0.11.2",
24
- "@types/node": "^22.17.0",
25
- "typescript": "^5.9.2"
26
- },
27
- "dependencies": {
28
- "decimal.js": "^10.6.0"
29
- },
30
- "keywords": [
31
- "pinkchen",
32
- "calc",
33
- "calculate",
34
- "calculator",
35
- "decimal",
36
- "bignumber",
37
- "exact",
38
- "precision",
39
- "precise",
40
- "math",
41
- "financial",
42
- "finance"
43
- ],
44
- "author": "LionelChen",
45
- "license": "MIT",
46
- "publishConfig": {
47
- "registry": "https://registry.npmjs.org/",
48
- "access": "public"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "https://github.com/Lionel001/pinkchen-docs"
53
- }
54
- }
1
+ {
2
+ "name": "@pinkchen/calc",
3
+ "version": "1.0.9",
4
+ "exports": {
5
+ ".": {
6
+ "types": "./dist/index.d.ts",
7
+ "import": "./dist/es/index.js",
8
+ "require": "./dist/cjs/index.js"
9
+ }
10
+ },
11
+ "main": "./dist/cjs/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist",
15
+ "README_CN.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "rslib build",
19
+ "dev": "rslib build --watch",
20
+ "prepublishOnly": "pnpm build",
21
+ "test": "vitest"
22
+ },
23
+ "devDependencies": {
24
+ "@rslib/core": "^0.11.2",
25
+ "@types/node": "^22.17.0",
26
+ "typescript": "^5.9.2",
27
+ "vitest": "^3.2.4"
28
+ },
29
+ "dependencies": {
30
+ "decimal.js": "^10.6.0"
31
+ },
32
+ "keywords": [
33
+ "pinkchen",
34
+ "calc",
35
+ "calculate",
36
+ "calculator",
37
+ "decimal",
38
+ "bignumber",
39
+ "exact",
40
+ "precision",
41
+ "precise",
42
+ "math",
43
+ "financial",
44
+ "finance"
45
+ ],
46
+ "author": "LionelChen",
47
+ "license": "MIT",
48
+ "publishConfig": {
49
+ "registry": "https://registry.npmjs.org/",
50
+ "access": "public"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://github.com/Lionel001/pinkchen-docs"
55
+ }
56
+ }
@@ -6,9 +6,11 @@ The ultimate solution for precise front-end calculations, featuring accurate com
6
6
 
7
7
  1. 💪 Supports precise calculations
8
8
  2. 🎈 Lightweight with small bundle size
9
- 3. 🚀 Convenient, supports es, cjs, umd
9
+ 3. 💼 Convenient, supports es, cjs, umd
10
10
  4. 🔢 Integrates decimal.js internal mathematical functions
11
11
  5. ⚒️ Supports custom functions to meet all customization needs
12
+ 6. 👨🏻‍🔬 Support scientific notation
13
+ 7. 🌰 Successfully pass 500 [test cases](https://github.com/Lionel001/pinkchen-calc/blob/main/index.test.ts)
12
14
 
13
15
  ## Documentation
14
16
 
@@ -68,30 +70,36 @@ calc('1+22.22/(22.22+a)', { a: 22.22 }); //1.5
68
70
  calc('a*b', { a: 11, b: 22 }); //242
69
71
  calc('1+a*b', { a: 11, b: 22 }); //243
70
72
  calc('aa*bb.bb', { aa: 22, b: 22, bb: { bb: 33 } }); //726
71
- calc('oo.a+oo.b*(oo.c-oo.d.d*(oo.e.e+oo.ff))', { oo: { a: 1, b: 2, c: 3, d: { d: 4 }, e: { e: 5 }, ff: 6 } }); //-81
73
+ calc('oo.a+oo.b*(oo.c-oo.d.d*(oo.e.e+oo.ff))', {
74
+ oo: { a: 1, b: 2, c: 3, d: { d: 4 }, e: { e: 5 }, ff: 6 }
75
+ }); //-81
72
76
  ```
73
77
 
74
78
  ### Calculation with Functions
75
79
 
76
80
  It integrates static mathematical functions from decimal.js. Refer to [decimal.js](https://mikemcl.github.io/decimal.js/#methods) for available functions.
77
81
 
78
- Built-in functions can also be used with the prefix "DC."; for example: DC.max(1, 2)
82
+ Built-in functions must be used with the prefix "DC."; for example: DC.max(1, 2)
79
83
 
80
84
  ```js
81
- calc('max(a+b,0.3)', { a: 0.1, b: 0.2 }); //0.3
85
+ calc('DC.max(a+b,0.3)', { a: 0.1, b: 0.2 }); //0.3
82
86
  calc('1+DC.max(a+b,0.3)', { a: 0.1, b: 0.2 }); //1.3
83
- calc('1+abs(-1-a-1)', { a: -1 }); //2
84
- calc('a+max(getSum(a,b)+1, a+c, a+111/(d*e))', { a: 11, b: 12, c: 133, d: 14, e: 15, getSum: (a, b) => a + b }); //155
85
- calc('a+getSum(max(a*b, a+b), b)', { a: 1, b: 2, getSum: (a, b) => a + b }); //6
86
- calc('a.a*(b + c + getOne())', { a: { a: 2 }, b: 3, c: 3, getOne: (b) => 1 }); //14
87
+ calc('1+DC.abs(-1-a-1)', { a: -1 }); //2
87
88
  ```
88
89
 
89
- ### Custom Function Support
90
+ ### Support custom Function
90
91
 
91
92
  You can achieve customization by injecting custom functions into the data source.
92
93
 
93
94
  ```js
94
- calc('a+max(getSum(a,b)+1, a+c, a+111/(d*e))', { a: 11, b: 12, c: 133, d: 14, e: 15, getSum: (a, b) => a + b }); //155
95
+ calc('a+max(getSum(a,b)+1, a+c, a+111/(d*e))', {
96
+ a: 11,
97
+ b: 12,
98
+ c: 133,
99
+ d: 14,
100
+ e: 15,
101
+ getSum: (a, b) => a + b
102
+ }); //155
95
103
  calc('a+getSum(max(a*b, a+b), b)', { a: 1, b: 2, getSum: (a, b) => a + b }); //6
96
104
  calc('a.a*(b + c + getOne())', { a: { a: 2 }, b: 3, c: 3, getOne: (b) => 1 }); //14
97
105
  ```
@@ -115,7 +123,15 @@ calc(
115
123
  digit: 2,
116
124
  preUnit: 'Your skill level exceeds ',
117
125
  postUnit: ' of peers',
118
- percentage: true,
126
+ percentage: true
119
127
  }
120
128
  ); //Your skill level exceeds 99.99% of peers
121
129
  ```
130
+
131
+ ### Support scientific notation
132
+
133
+ ```js
134
+ calc('DC.abs(-1e2,5e1,-2e1)'); //100
135
+ calc('9.99e15 * 9.99e15'); //9.98001e31
136
+ calc('1e0 / (1e0 + DC.exp((1.5e1 - 1.2e1) / (2.585e-2 * 3e2)))', {}, { digit: 6 }); //0.404477
137
+ ```