PromoCursed/node_modules/.cache/babel-loader/f7fdd2806b7ba0dd3924d468d540862004135c8cf27e66d6133cb3269e8fdec8.json

1 line
14 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport AbstractCalculator from \"./calculator\";\nvar CALC_UNIT = 'CALC_UNIT';\nvar regexp = new RegExp(CALC_UNIT, 'g');\nfunction unit(value) {\n if (typeof value === 'number') {\n return \"\".concat(value).concat(CALC_UNIT);\n }\n return value;\n}\nvar CSSCalculator = /*#__PURE__*/function (_AbstractCalculator) {\n _inherits(CSSCalculator, _AbstractCalculator);\n var _super = _createSuper(CSSCalculator);\n function CSSCalculator(num, unitlessCssVar) {\n var _this;\n _classCallCheck(this, CSSCalculator);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"result\", '');\n _defineProperty(_assertThisInitialized(_this), \"unitlessCssVar\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"lowPriority\", void 0);\n var numType = _typeof(num);\n _this.unitlessCssVar = unitlessCssVar;\n if (num instanceof CSSCalculator) {\n _this.result = \"(\".concat(num.result, \")\");\n } else if (numType === 'number') {\n _this.result = unit(num);\n } else if (numType === 'string') {\n _this.result = num;\n }\n return _this;\n }\n _createClass(CSSCalculator, [{\n key: \"add\",\n value: function add(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" + \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" + \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"sub\",\n value: function sub(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" - \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" - \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"mul\",\n value: function mul(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" * \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" * \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"div\",\n value: function div(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" / \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" / \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"getResult\",\n value: function getResult(force) {\n return this.lowPriority || force ? \"(\".concat(this.result, \")\") : this.result;\n }\n }, {\n key: \"equal\",\n value: function equal(options) {\n var _this2 = this;\n var _ref = options || {},\n cssUnit = _ref.unit;\n var mergedUnit = true;\n if (typeof cssUnit === 'boolean') {\n mergedUnit = cssUnit;\n } else if (Array.from(this.unitlessCssVar).some(function (cssVar) {\n return _this2.result.includes(cssVar);\n })) {\n mergedUnit = false;\n }\n this.resul