Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@evergis/condition

Package Overview
Dependencies
Maintainers
5
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/condition - npm Package Compare versions

Comparing version 1.2.19 to 1.2.20

35

dist/condition.cjs.development.js

@@ -243,4 +243,2 @@ 'use strict';

TokenType[TokenType["Outside"] = 30] = "Outside";
TokenType[TokenType["Intersect"] = 31] = "Intersect";
TokenType[TokenType["NotIntersect"] = 32] = "NotIntersect";
})(exports.TokenType || (exports.TokenType = {}));

@@ -355,3 +353,3 @@

}(ExpressionNode);
OperationNode.TOKENS = [exports.TokenType.ArEq, exports.TokenType.ArNotEq, exports.TokenType.ArGr, exports.TokenType.ArGre, exports.TokenType.ArLs, exports.TokenType.ArLse, exports.TokenType.ArPlus, exports.TokenType.ArMinus, exports.TokenType.ArDiv, exports.TokenType.ArMul, exports.TokenType.Between, exports.TokenType.Outside, exports.TokenType.Intersect, exports.TokenType.NotIntersect];
OperationNode.TOKENS = [exports.TokenType.ArEq, exports.TokenType.ArNotEq, exports.TokenType.ArGr, exports.TokenType.ArGre, exports.TokenType.ArLs, exports.TokenType.ArLse, exports.TokenType.ArPlus, exports.TokenType.ArMinus, exports.TokenType.ArDiv, exports.TokenType.ArMul, exports.TokenType.Between, exports.TokenType.Outside];
let BoolOperationNode = /*#__PURE__*/function (_ExpressionNode4) {

@@ -430,4 +428,2 @@ _inherits(BoolOperationNode, _ExpressionNode4);

OperationPrecedence.set(exports.TokenType.Outside, 5);
OperationPrecedence.set(exports.TokenType.Intersect, 5);
OperationPrecedence.set(exports.TokenType.NotIntersect, 5);

@@ -507,3 +503,3 @@ let TokenError = /*#__PURE__*/function (_Error) {

if (isOperation(token)) {
if (![exports.TokenType.Between, exports.TokenType.Outside, exports.TokenType.Intersect, exports.TokenType.NotIntersect].includes(token.type)) {
if (![exports.TokenType.Between, exports.TokenType.Outside].includes(token.type)) {
while (last(operators) && isHigherPrecedence(last(operators), token) && last(operators).type !== exports.TokenType.ExprOpen) {

@@ -1438,4 +1434,2 @@ output.push(operators.pop());

Char.OUTSIDE = '!between';
Char.INTERSECT = 'intersect';
Char.NOT_INTERSECT = '!intersect';
Char.SINGLE_QUOTE = "'";

@@ -1472,3 +1466,3 @@ Char.DOUBLE_QUOTE = '"';

const AcceptTree = /*#__PURE__*/new OperationAccept('', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept(Char.BETWEEN, exports.TokenType.Between), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, exports.TokenType.Outside), /*#__PURE__*/new OperationAccept(Char.BETWEEN, exports.TokenType.Intersect), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, exports.TokenType.NotIntersect), /*#__PURE__*/new OperationAccept('>', exports.TokenType.ArGr, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArGre)]), /*#__PURE__*/new OperationAccept('<', exports.TokenType.ArLs, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArLse)]), /*#__PURE__*/new OperationAccept('!', exports.TokenType.BoolNot, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArNotEq)]), /*#__PURE__*/new OperationAccept('&', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept('&', exports.TokenType.BoolAnd)]), /*#__PURE__*/new OperationAccept('=', exports.TokenType.ArEq, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArEq)]), /*#__PURE__*/new OperationAccept('|', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept('|', exports.TokenType.BoolOr)]), /*#__PURE__*/new OperationAccept('+', exports.TokenType.ArPlus), /*#__PURE__*/new OperationAccept('-', exports.TokenType.ArMinus), /*#__PURE__*/new OperationAccept('*', exports.TokenType.ArMul), /*#__PURE__*/new OperationAccept('/', exports.TokenType.ArDiv), /*#__PURE__*/new OperationAccept('(', exports.TokenType.ExprOpen), /*#__PURE__*/new OperationAccept(')', exports.TokenType.ExprClose), /*#__PURE__*/new OperationAccept('[', exports.TokenType.ArrayOpen), /*#__PURE__*/new OperationAccept(']', exports.TokenType.ArrayClose), /*#__PURE__*/new OperationAccept(',', exports.TokenType.Separator)]);
const AcceptTree = /*#__PURE__*/new OperationAccept('', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept(Char.BETWEEN, exports.TokenType.Between), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, exports.TokenType.Outside), /*#__PURE__*/new OperationAccept('>', exports.TokenType.ArGr, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArGre)]), /*#__PURE__*/new OperationAccept('<', exports.TokenType.ArLs, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArLse)]), /*#__PURE__*/new OperationAccept('!', exports.TokenType.BoolNot, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArNotEq)]), /*#__PURE__*/new OperationAccept('&', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept('&', exports.TokenType.BoolAnd)]), /*#__PURE__*/new OperationAccept('=', exports.TokenType.ArEq, [/*#__PURE__*/new OperationAccept('=', exports.TokenType.ArEq)]), /*#__PURE__*/new OperationAccept('|', exports.TokenType.Null, [/*#__PURE__*/new OperationAccept('|', exports.TokenType.BoolOr)]), /*#__PURE__*/new OperationAccept('+', exports.TokenType.ArPlus), /*#__PURE__*/new OperationAccept('-', exports.TokenType.ArMinus), /*#__PURE__*/new OperationAccept('*', exports.TokenType.ArMul), /*#__PURE__*/new OperationAccept('/', exports.TokenType.ArDiv), /*#__PURE__*/new OperationAccept('(', exports.TokenType.ExprOpen), /*#__PURE__*/new OperationAccept(')', exports.TokenType.ExprClose), /*#__PURE__*/new OperationAccept('[', exports.TokenType.ArrayOpen), /*#__PURE__*/new OperationAccept(']', exports.TokenType.ArrayClose), /*#__PURE__*/new OperationAccept(',', exports.TokenType.Separator)]);

@@ -1533,12 +1527,2 @@ const TOKENIZER_MAX_SIZE = 1000;

if (this.input.slice(this.currentPosition).startsWith(Char.INTERSECT)) {
this.currentPosition += Char.INTERSECT.length;
return this.createToken(exports.TokenType.Intersect, Char.INTERSECT);
}
if (this.input.slice(this.currentPosition).startsWith(Char.NOT_INTERSECT)) {
this.currentPosition += Char.NOT_INTERSECT.length;
return this.createToken(exports.TokenType.NotIntersect, Char.NOT_INTERSECT);
}
const acceptOp = AcceptTree.accept(this.current);

@@ -1684,14 +1668,3 @@

const isOutside = this.tokens.some(token => token.type === exports.TokenType.Outside);
const isIntersect = this.tokens.some(token => token.type === exports.TokenType.Intersect);
const isNotIntersect = this.tokens.some(token => token.type === exports.TokenType.NotIntersect);
if (isBetween || isOutside) {
return this.createToken(isOutside ? exports.TokenType.Outside : exports.TokenType.Between, result);
}
if (isIntersect || isNotIntersect) {
return this.createToken(isIntersect ? exports.TokenType.Intersect : exports.TokenType.NotIntersect, result);
}
return this.createToken(exports.TokenType.Function, result);
return this.createToken(isOutside ? exports.TokenType.Outside : isBetween ? exports.TokenType.Between : exports.TokenType.Function, result);
}

@@ -1698,0 +1671,0 @@

2

dist/condition.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns");function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,n){return(a=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function T(e){var t=p();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return h(this,n)}}function f(e,t,n){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}(e=exports.TokenType||(exports.TokenType={}))[e.Number=0]="Number",e[e.Identifier=1]="Identifier",e[e.DynamicIdentifier=2]="DynamicIdentifier",e[e.String=3]="String",e[e.Date=4]="Date",e[e.TimeSpan=5]="TimeSpan",e[e.Terminal=6]="Terminal",e[e.EndOfString=7]="EndOfString",e[e.Null=8]="Null",e[e.ArIn=9]="ArIn",e[e.ArEq=10]="ArEq",e[e.ArNotEq=11]="ArNotEq",e[e.ArGr=12]="ArGr",e[e.ArGre=13]="ArGre",e[e.ArLs=14]="ArLs",e[e.ArLse=15]="ArLse",e[e.BoolNot=16]="BoolNot",e[e.BoolAnd=17]="BoolAnd",e[e.BoolOr=18]="BoolOr",e[e.ArPlus=19]="ArPlus",e[e.ArMinus=20]="ArMinus",e[e.ArMul=21]="ArMul",e[e.ArDiv=22]="ArDiv",e[e.ExprOpen=23]="ExprOpen",e[e.ExprClose=24]="ExprClose",e[e.ArrayOpen=25]="ArrayOpen",e[e.ArrayClose=26]="ArrayClose",e[e.Separator=27]="Separator",e[e.Function=28]="Function",e[e.Between=29]="Between",e[e.Outside=30]="Outside",e[e.Intersect=31]="Intersect",e[e.NotIntersect=32]="NotIntersect";const y={start:0,end:0};let k=o((function e(t,r,o){void 0===o&&(o=y),n(this,e),this.type=t,this.value=r,this.position=o})),v=function(){function e(t,r,o){void 0===r&&(r=null),void 0===o&&(o=null),n(this,e),this.token=t,this.left=r,this.right=o}return o(e,[{key:"accept",value:function(e){return e.visit(this)}}]),e}(),x=function(e){s(r,v);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();x.TOKENS=[exports.TokenType.String,exports.TokenType.Number,exports.TokenType.DynamicIdentifier,exports.TokenType.Date];let E=function(e){s(r,v);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();E.TOKENS=[exports.TokenType.Identifier];let d=function(e){s(r,v);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();d.TOKENS=[exports.TokenType.ArEq,exports.TokenType.ArNotEq,exports.TokenType.ArGr,exports.TokenType.ArGre,exports.TokenType.ArLs,exports.TokenType.ArLse,exports.TokenType.ArPlus,exports.TokenType.ArMinus,exports.TokenType.ArDiv,exports.TokenType.ArMul,exports.TokenType.Between,exports.TokenType.Outside,exports.TokenType.Intersect,exports.TokenType.NotIntersect];let N=function(e){s(r,v);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();N.TOKENS=[exports.TokenType.BoolAnd,exports.TokenType.BoolOr];let O=function(e){s(r,v);var t=T(r);function r(e,o,i,s){var u;return void 0===i&&(i=null),void 0===s&&(s=null),n(this,r),(u=t.call(this,e,i,s)).func=o,u}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();O.TOKENS=[exports.TokenType.Function];const g=new Map;g.set(exports.TokenType.ExprOpen,0),g.set(exports.TokenType.ExprClose,0),g.set(exports.TokenType.BoolAnd,1),g.set(exports.TokenType.BoolOr,1),g.set(exports.TokenType.ArEq,2),g.set(exports.TokenType.ArNotEq,2),g.set(exports.TokenType.ArGr,2),g.set(exports.TokenType.ArGre,2),g.set(exports.TokenType.ArLs,2),g.set(exports.TokenType.ArLse,2),g.set(exports.TokenType.ArPlus,3),g.set(exports.TokenType.ArMinus,3),g.set(exports.TokenType.ArMul,4),g.set(exports.TokenType.ArDiv,4),g.set(exports.TokenType.Function,5),g.set(exports.TokenType.Between,5),g.set(exports.TokenType.Outside,5),g.set(exports.TokenType.Intersect,5),g.set(exports.TokenType.NotIntersect,5);let A=function(e){s(r,l(Error));var t=T(r);function r(e,o){var i;void 0===o&&(o=y),n(this,r),(i=t.call(this)).position=o;const{start:s,end:u}=o;return i.message=i.name+"(cимвол: "+(s+1)+", "+(u+1)+"):"+e+".",i}return o(r)}(),b=function(e){s(r,A);var t=T(r);function r(e,o){var i;return void 0===o&&(o=y),n(this,r),(i=t.call(this,e,o)).position=o,i.name="LintError",i}return o(r)}();const S=e=>e[e.length-1],m=e=>x.is(e)||E.is(e),w=e=>d.is(e)||N.is(e)||O.is(e);let C=function(e){s(r,A);var t=T(r);function r(e,o){var i;return void 0===o&&(o=y),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionAst",i}return o(r)}(),B=function(){function e(){n(this,e)}return o(e,[{key:"visit",value:function(e){return e instanceof N?this.visitBoolOpNode(e):e instanceof d?this.visitOpNode(e):e instanceof x?this.visitValueNode(e):e instanceof E?this.visitAttributeNode(e):e instanceof O?this.visitFunctionNode(e):void 0}},{key:"visitBoolOpNode",value:function(e){}},{key:"visitOpNode",value:function(e){}},{key:"visitValueNode",value:function(e){}},{key:"visitAttributeNode",value:function(e){}},{key:"visitFunctionNode",value:function(e){}}]),e}(),I=function(e){s(r,B);var t=T(r);function r(e){var o;return n(this,r),(o=t.call(this)).attributes=e,o}return o(r,[{key:"visitBoolOpNode",value:function(e){f(u(r.prototype),"visitBoolOpNode",this).call(this,e),this.checkBoolOpNode(e),this.acceptLeafs(e)}},{key:"visitOpNode",value:function(e){f(u(r.prototype),"visitOpNode",this).call(this,e),this.checkOpNode(e),this.acceptLeafs(e)}},{key:"visitValueNode",value:function(e){f(u(r.prototype),"visitValueNode",this).call(this,e),this.checkLeafNode(e)}},{key:"visitAttributeNode",value:function(e){f(u(r.prototype),"visitAttributeNode",this).call(this,e),this.checkLeafNode(e),this.checkAttributeNode(e)}},{key:"visitFunctionNode",value:function(e){f(u(r.prototype),"visitFunctionNode",this).call(this,e),this.checkLeafNode(e),this.checkFunctionNode(e)}},{key:"checkBoolOpNode",value:function(e){const t="Ожидается выражение вида 'a == 2 "+e.token.value+" b == 3'";this.isOperationNode(e.left)||this.Error(t,e.token),this.isOperationNode(e.right)||this.Error(t,e.token)}},{key:"checkOpNode",value:function(e){e.left&&e.right||this.Error("'"+e.token.value+"' ожидает выражение",e.token)}},{key:"checkLeafNode",value:function(e){if(e.left){const{token:t}=e.left;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}if(e.right){const{token:t}=e.right;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}}},{key:"checkAttributeNode",value:function(e){e.token.value&&void 0!==this.attributes[e.token.value]||this.Error("Атрибут '"+e.token.value+"' не найден в атрибутах слоя",e.token)}},{key:"checkFunctionNode",value:function(e){const t=e.func.check(this.attributes);t instanceof Error&&this.Error(t.message,e.token)}},{key:"Error",value:function(e,t){const{position:n}=t;throw new b(e,n)}},{key:"acceptLeafs",value:function(e){return{x:e.left&&e.left.accept(this),y:e.right&&e.right.accept(this)}}},{key:"isOperationNode",value:function(e){return e instanceof N||e instanceof d}}]),r}(),L=function(e){s(r,I);var t=T(r);function r(e,o){var i;return n(this,r),(i=t.call(this,e)).attributes=e,i.silent=!(!o||!o.silent),i}return o(r,[{key:"visitBoolOpNode",value:function(e){this.silent||f(u(r.prototype),"visitBoolOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);return e.token.type===exports.TokenType.BoolAnd?t&&n:t||n}},{key:"visitOpNode",value:function(e){this.silent||f(u(r.prototype),"visitOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);switch(e.token.type){case exports.TokenType.ArEq:return t===n;case exports.TokenType.ArNotEq:return t!==n;case exports.TokenType.ArGre:return t>=n;case exports.TokenType.ArLse:return t<=n;case exports.TokenType.ArGr:return t>n;case exports.TokenType.ArLs:return t<n;case exports.TokenType.ArPlus:return t+n;case exports.TokenType.ArMinus:return t-n;case exports.TokenType.ArMul:return t*n;case exports.TokenType.ArDiv:return t/n;default:return!1}}},{key:"visitValueNode",value:function(e){return this.silent||f(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return this.silent||f(u(r.prototype),"visitAttributeNode",this).call(this,e),this.attributes[e.token.value]}},{key:"visitFunctionNode",value:function(e){return this.silent||f(u(r.prototype),"visitFunctionNode",this).call(this,e),e.func.calc(this.attributes)}}]),r}(),P=function(){function e(t){n(this,e),this.args=t}return o(e,[{key:"calc",value:function(e){return 0}},{key:"evaluateArguments",value:function(e){return this.args.map(t=>{if(t instanceof d)return t.accept(new L(e));if("string"==typeof t.value){if("number"!=typeof e[t.value]){const{position:e}=t;throw new b("Аргумент функции должен быть числовым типом",e)}return e[t.value]}return t.value})}},{key:"check",value:function(e,t){return this.evaluateArguments(e).length!==t?new Error("Передано неверное количество аргументов"):null}}]),e}(),M=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sin(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();M.ArgsCount=1,M.Name="sin";let D=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.asin(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();D.ArgsCount=1,D.Name="arcsin";let F=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.cos(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();F.ArgsCount=1,F.Name="cos";let _=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.acos(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();_.ArgsCount=1,_.Name="arccos";let R=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t,n]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan2(t,n).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();R.ArgsCount=2,R.Name="arctan2";let U=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.tan(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();U.ArgsCount=1,U.Name="tan";let K=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();K.ArgsCount=1,K.Name="arctan";let q=function(e){s(r,P);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=f(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sqrt(t).toFixed(3)}},{key:"check",value:function(e){return f(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();q.ArgsCount=1,q.Name="sqrt";const G={[M.Name]:M,[D.Name]:D,[F.Name]:F,[_.Name]:_,[U.Name]:U,[K.Name]:K,[R.Name]:R,[q.Name]:q},j=e=>t.isValid(e)?e:"#'"+e+"'";let W=function(){function e(t){n(this,e),this.tokens=t,this.tree=null,this.currentPosition=0}return o(e,[{key:"value",get:function(){if(this.tree)return this.tree;this.tokens=function(e){let t=[];const n=[];for(const i of e){if(m(i)&&t.push(i),w(i)){if(![exports.TokenType.Between,exports.TokenType.Outside,exports.TokenType.Intersect,exports.TokenType.NotIntersect].includes(i.type))for(;S(n)&&(r=S(n),o=i,g.get(r.type)>g.get(o.type))&&S(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());n.push(i)}if(i.type===exports.TokenType.ExprOpen&&n.push(i),i.type===exports.TokenType.ExprClose){const e=i;for(;S(n)&&S(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());if(0===n.length)throw new b("Пропущена открывающая скобка",e.position);S(n).type===exports.TokenType.ExprOpen&&n.pop()}}var r,o;if(n.length){const e=S(n);if(e.type===exports.TokenType.ExprOpen)throw new b("Пропущена закрывающая скобка",e.position);t=[...t,...n.reverse()]}return t}(this.tokens);const e=[];for(;this.currentPosition<this.tokens.length;this.nextToken()){if(x.is(this.currentToken)&&e.push(new x(this.currentToken)),E.is(this.currentToken)&&e.push(new E(this.currentToken)),O.is(this.currentToken)){const t=G[this.currentToken.value];t||this.Error("Функция '"+this.currentToken.value+"' не определена",this.currentToken);const n=[];for(let r=0;r<t.ArgsCount;r++){const t=e.pop()||null;t instanceof d?n.push(t):t&&t.token&&n.push(t.token)}const r=new t(n);e.push(new O(this.currentToken,r))}if(d.is(this.currentToken)){const r=new d(this.currentToken);if([exports.TokenType.Between,exports.TokenType.Outside].includes(this.currentToken.type)){var t,n;const o=e.pop()||null,s=e.pop()||null;r.left=e.pop()||null,r.right=new x(i({},this.currentToken,{value:j(null==s?void 0:s.token.value)+" - "+j(null==o?void 0:o.token.value),position:{start:(null==s||null==(t=s.token.position)?void 0:t.start)||0,end:(null==o||null==(n=o.token.position)?void 0:n.end)||0}}))}else e.length>1&&(r.right=e.pop()||null),r.left=e.pop()||null;e.push(r)}if(N.is(this.currentToken)){const t=new N(this.currentToken);e.length>1&&(t.right=e.pop()||null),t.left=e.pop()||null,e.push(t)}}return this.tree=e.pop()||null,this.flashStack(e),this.checkRoot(),this.tree}},{key:"nextToken",value:function(){this.currentPosition+=1}},{key:"currentToken",get:function(){return this.tokens[this.currentPosition]}},{key:"checkRoot",value:function(){}},{key:"flashStack",value:function(e){if(this.tree&&e.length)for(;e.length;){const t=e.pop();t&&this.insert(this.tree,t)}}},{key:"insert",value:function(e,t){null!==e.right?this.insert(e.right,t):e.right=t}},{key:"Error",value:function(e,t){const{position:n}=t,{start:r,end:o}=n;throw new C(e,{start:r,end:o})}}]),e}(),V=function(e){s(r,A);var t=T(r);function r(e,o){var i;return void 0===o&&(o=y),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionTokenizer",i}return o(r)}(),H=function(){function e(t,r,o){void 0===o&&(o=[]),n(this,e),this.acceptMap=new Map,this.value=t,this.tokenType=r,o.map(e=>this.acceptMap.set(e.value,e))}return o(e,[{key:"accept",value:function(e){return this.acceptMap.get(e)||null}}]),e}(),z=function(){function e(){n(this,e)}return o(e,null,[{key:"isChar",value:function(e){return"string"==typeof e&&1===e.length}},{key:"isDigit",value:function(e){return this.isChar(e)&&/\d/.test(e)}},{key:"isLetter",value:function(e){return this.isChar(e)&&/\w/.test(e)}},{key:"isWhiteSpace",value:function(t){return this.isChar(t)&&t===e.WHITE_SPACE}},{key:"isLetterOrDigit",value:function(t){return e.isLetter(t)||e.isDigit(t)}},{key:"isUnderscore",value:function(t){return e.isChar(t)&&t===e.UNDERSCORE}},{key:"isFloating",value:function(t){return e.isChar(t)&&("f"===t||"F"===t)}},{key:"escapeSpecChars",value:function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\t/g,"\\\\t").replace(/\v/g,"\\\\v").replace(/\0/g,"\\\\0").replace(/\f/g,"\\\\f").replace(/\n/g,"\\\\n").replace(/\r/g,"\\\\r")}},{key:"unEscapeSpecChars",value:function(e){return e.replace(/\\'/g,"'").replace(/\\"/g,'"').replace(/\\\\/g,"\\").replace(/\\\\t/g,"\t").replace(/\\\\v/g,"\v").replace(/\\\\0/g,"\0").replace(/\\\\f/g,"\f").replace(/\\\\n/g,"\n").replace(/\\\\r/g,"\r")}}]),e}();function Q(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}z.LEFT_BRACKET="{",z.OPEN_BRACKET="(",z.BETWEEN="between",z.OUTSIDE="!between",z.INTERSECT="intersect",z.NOT_INTERSECT="!intersect",z.SINGLE_QUOTE="'",z.DOUBLE_QUOTE='"',z.HASH_SYMBOL="#",z.RIGHT_BRACKET="}",z.CLOSE_BRACKET=")",z.BACK_SLASH="\\",z.WHITE_SPACE=" ",z.UNDERSCORE="_",z.PERCENTAGE="%",z.POINT=".";let Y=o((function e(){n(this,e)}));Y.sToMs=e=>1e3*e,Y.mToMs=e=>60*Y.sToMs(e),Y.hToMs=e=>60*Y.mToMs(e),Y.dToMs=e=>24*Y.hToMs(e),Y.mthToMs=e=>30*Y.dToMs(e),Y.yToMs=e=>365*Y.mthToMs(e);const J=new H("",exports.TokenType.Null,[new H(z.BETWEEN,exports.TokenType.Between),new H(z.OUTSIDE,exports.TokenType.Outside),new H(z.BETWEEN,exports.TokenType.Intersect),new H(z.OUTSIDE,exports.TokenType.NotIntersect),new H(">",exports.TokenType.ArGr,[new H("=",exports.TokenType.ArGre)]),new H("<",exports.TokenType.ArLs,[new H("=",exports.TokenType.ArLse)]),new H("!",exports.TokenType.BoolNot,[new H("=",exports.TokenType.ArNotEq)]),new H("&",exports.TokenType.Null,[new H("&",exports.TokenType.BoolAnd)]),new H("=",exports.TokenType.ArEq,[new H("=",exports.TokenType.ArEq)]),new H("|",exports.TokenType.Null,[new H("|",exports.TokenType.BoolOr)]),new H("+",exports.TokenType.ArPlus),new H("-",exports.TokenType.ArMinus),new H("*",exports.TokenType.ArMul),new H("/",exports.TokenType.ArDiv),new H("(",exports.TokenType.ExprOpen),new H(")",exports.TokenType.ExprClose),new H("[",exports.TokenType.ArrayOpen),new H("]",exports.TokenType.ArrayClose),new H(",",exports.TokenType.Separator)]);let X=function(){function e(t){n(this,e),this.start=0,this.currentPosition=0,this.tokens=[],this.input=t||""}return o(e,[{key:"tokenize",value:function(){if(this.isEndOfString())return this.tokens;for(;;){const e=this.nextToken();if(!e)break;if(this.tokens.push(e),this.tokens.length>1e3&&this.Error("Привышен лимит запроса: 1000"),e.type===exports.TokenType.EndOfString)break}return this.tokens}},{key:"nextToken",value:function(){for(;this.currentPosition<this.input.length;this.nextSymbol()){if(z.isWhiteSpace(this.current))continue;if(this.resetStart(),this.input.slice(this.currentPosition).startsWith(z.OUTSIDE))return this.currentPosition+=z.OUTSIDE.length,this.createToken(exports.TokenType.Outside,z.OUTSIDE);if(this.input.slice(this.currentPosition).startsWith(z.BETWEEN))return this.currentPosition+=z.BETWEEN.length,this.createToken(exports.TokenType.Between,z.BETWEEN);if(this.input.slice(this.currentPosition).startsWith(z.INTERSECT))return this.currentPosition+=z.INTERSECT.length,this.createToken(exports.TokenType.Intersect,z.INTERSECT);if(this.input.slice(this.currentPosition).startsWith(z.NOT_INTERSECT))return this.currentPosition+=z.NOT_INTERSECT.length,this.createToken(exports.TokenType.NotIntersect,z.NOT_INTERSECT);const e=J.accept(this.current);if(null!==e)return this.captureSpecial(e);if(z.isDigit(this.current)||this.current===z.POINT)return this.captureNumber();if(z.isLetter(this.current)||z.isUnderscore(this.current))return this.captureIdentifier();if(this.current===z.LEFT_BRACKET)return this.captureDynamicIdentifier();if(this.current===z.DOUBLE_QUOTE||this.current===z.SINGLE_QUOTE)return this.captureString();if(this.current===z.HASH_SYMBOL)return this.captureDate()}return this.resetStart(),this.createToken(exports.TokenType.EndOfString)}},{key:"resetStart",value:function(){this.start=this.currentPosition}},{key:"createToken",value:function(e,t){void 0===t&&(t=null);const n=this.currentPosition-(e===exports.TokenType.EndOfString?0:1);return new k(e,t,{start:this.start,end:n})}},{key:"nextSymbol",value:function(){this.currentPosition+=1}},{key:"current",get:function(){return this.input[this.currentPosition]}},{key:"captureSpecial",value:function(e){let t=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol()){const n=e.accept(this.current);if(null===n||n.tokenType===exports.TokenType.Null)break;t+=this.current,e=n}return this.current&&z.isDigit(this.current)&&e.tokenType===exports.TokenType.ArMinus?this.createToken(exports.TokenType.Number,-(this.captureNumber().value||0)):(e.tokenType===exports.TokenType.Null&&this.Error("Неизвеcтная операция '"+e.value+"'"),this.createToken(e.tokenType,t))}},{key:"captureNumber",value:function(){let e="",t=!1;for(;this.currentPosition<this.input.length&&!z.isWhiteSpace(this.current)&&(z.isDigit(this.current)||z.isFloating(this.current)||this.current===z.POINT);this.nextSymbol())this.current===z.POINT&&(t=!0),e+=this.current;t&&z.isFloating(e[e.length-1])&&(e=e.slice(0,-1));const n=parseFloat(e);return Number.isNaN(n)&&this.Error("Неверный числовой формат: "+e),this.createToken(exports.TokenType.Number,n)}},{key:"captureIdentifier",value:function(){let e="";for(;this.currentPosition<this.input.length&&(z.isLetterOrDigit(this.current)||z.isUnderscore(this.current));this.nextSymbol())e+=this.current;if(this.current===z.OPEN_BRACKET){const t=this.tokens.some(e=>e.type===exports.TokenType.Between),n=this.tokens.some(e=>e.type===exports.TokenType.Outside),r=this.tokens.some(e=>e.type===exports.TokenType.Intersect),o=this.tokens.some(e=>e.type===exports.TokenType.NotIntersect);return this.createToken(t||n?n?exports.TokenType.Outside:exports.TokenType.Between:r||o?r?exports.TokenType.Intersect:exports.TokenType.NotIntersect:exports.TokenType.Function,e)}return"true"===e||"True"===e||"TRUE"===e?this.createToken(exports.TokenType.Terminal,!0):"false"===e||"False"===e||"FALSE"===e?this.createToken(exports.TokenType.Terminal,!1):"in"===e||"IN"===e?this.createToken(exports.TokenType.ArIn):this.createToken(exports.TokenType.Identifier,e)}},{key:"captureDynamicIdentifier",value:function(){this.nextSymbol();let e="";for(;this.currentPosition<this.input.length;this.nextSymbol()){if(this.current===z.RIGHT_BRACKET){this.nextSymbol();break}e+=this.current}return this.createToken(exports.TokenType.DynamicIdentifier,"null"===e||"Null"===e||"NULL"===e?null:e)}},{key:"captureString",value:function(){let e="",t=!1;const n=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol())if(t||this.current!==z.BACK_SLASH){if(!t&&this.current===n)return this.nextSymbol(),this.createToken(exports.TokenType.String,e);e+=this.current,t=!1}else t=!0;this.Error("Открытая строка")}},{key:"captureDate",value:function(){if(this.nextSymbol(),![z.SINGLE_QUOTE,z.DOUBLE_QUOTE,z.BACK_SLASH].includes(this.current))return this.captureTimeSpan();const e=this.captureString();return this.createToken(exports.TokenType.Date,e.value)}},{key:"captureTimeSpan",value:function(){let e="";for(;this.currentPosition<this.input.length&&z.isDigit(this.current);this.nextSymbol())e+=this.current;const t=parseFloat(e);Number.isNaN(t)&&this.Error("Неверный формат числа для значения timespan: "+e+". Должно быть положительным целочисленным значением."),z.isLetter(this.current)||this.Error("Для значения задана неверная единица измерения "+this.current);let n="";for(;z.isLetter(this.current);)n+=this.current,this.nextSymbol();let r=0;switch(n){case"ms":r=t;break;case"s":r=Y.sToMs(t);break;case"m":r=Y.mToMs(t);break;case"h":r=Y.hToMs(t);break;case"d":r=Y.dToMs(t);break;case"mth":r=Y.mthToMs(t);break;case"y":r=Y.yToMs(t);break;default:this.Error("Неверная единица измерения для timespan: "+n)}return this.createToken(exports.TokenType.TimeSpan,r)}},{key:"isEndOfString",value:function(){return this.tokens.length>0&&this.tokens[this.tokens.length-1].type===exports.TokenType.EndOfString}},{key:"Error",value:function(e){throw new V(e,{start:this.start,end:this.start})}}]),e}(),Z=function(e){s(r,B);var t=T(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"visitBoolOpNode",value:function(e){f(u(r.prototype),"visitBoolOpNode",this).call(this,e);const t=e.left&&e.left.accept(this),n=e.right&&e.right.accept(this);return e.left instanceof N&&e.right instanceof N?(this.checkBoolOperations(e.token.type,[...t.boolOperations,...n.boolOperations]),{boolOperations:[...t.boolOperations,e.token.type,...n.boolOperations],expressions:[...t.expressions,...n.expressions]}):e.right instanceof N?(this.checkBoolOperations(e.token.type,n.boolOperations),{boolOperations:[e.token.type,...n.boolOperations],expressions:[t,...n.expressions]}):e.left instanceof N?(this.checkBoolOperations(e.token.type,t.boolOperations),{boolOperations:[...t.boolOperations,e.token.type],expressions:[...t.expressions,n]}):{boolOperations:[e.token.type],expressions:[t,n]}}},{key:"visitOpNode",value:function(e){var t;f(u(r.prototype),"visitOpNode",this).call(this,e),this.checkExpressionSimple(e);const n=e.left&&e.left.accept(this),o=e.right&&(null==(t=e.right)?void 0:t.accept(this));return{attribute:n,operation:e.token.type,value:o}}},{key:"visitValueNode",value:function(e){return f(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return f(u(r.prototype),"visitAttributeNode",this).call(this,e),e.token.value}},{key:"checkBoolOperations",value:function(e,t){if(t.some(t=>t!==e))throw new b("Выражение должно использовать одинаковые булевы операторы")}},{key:"checkExpressionSimple",value:function(e){if(!(e.left instanceof E&&e.right instanceof x||e.right instanceof x))throw new b("Выражение должно быть простым")}}]),r}();const $=e=>Q(e)&&"boolOperations"in e,ee=e=>Q(e)&&"attribute"in e;let te=function(){function e(t){n(this,e),this.result=null,this.tokenizer=new X(t)}return o(e,[{key:"value",get:function(){if(this.result)return this.result;try{const e=this.tokenizer.tokenize(),t=new W(e).value,n=t&&t.accept(new Z);return this.result=$(n)?n:ee(n)?{boolOperations:[],expressions:[n]}:{boolOperations:[],expressions:[]},this.result}catch(e){return e}}}]),e}(),ne=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"evaluate",value:function(e,t){try{const n=new X(e).tokenize(),r=new W(n).value;return r&&r.accept(new L(this.attributes,t))}catch(e){return e}}}]),e}(),re=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"lint",value:function(e){try{const t=new X(e).tokenize(),n=new W(t).value;return n&&n.accept(new I(this.attributes)),null}catch(e){return e}}}]),e}();exports.ArcCos=_,exports.ArcSin=D,exports.ArcTan=K,exports.ArcTan2=R,exports.AttributeNode=E,exports.BoolOperationNode=N,exports.Char=z,exports.ConditionEvaluator=ne,exports.ConditionInterpreter=te,exports.ConditionLinter=re,exports.ConditionVisitor=Z,exports.Cos=F,exports.DEFAULT_TOKEN_POSITION=y,exports.EqlFunction=P,exports.EqlFunctions=G,exports.EvaluateVisitor=L,exports.ExpressionAst=W,exports.ExpressionAstError=C,exports.ExpressionNode=v,exports.ExpressionTokenizer=X,exports.ExpressionTokenizerError=V,exports.ExpressionVisitor=B,exports.FunctionNode=O,exports.LintError=b,exports.LintVisitor=I,exports.OperationNode=d,exports.Sin=M,exports.Sqrt=q,exports.Tan=U,exports.Time=Y,exports.Token=k,exports.TokenError=A,exports.ValueNode=x,exports.isBoolResult=$,exports.isExpression=ee,exports.isObject=Q;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns");function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,n){return(a=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){var t=p();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return h(this,n)}}function y(e,t,n){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}(e=exports.TokenType||(exports.TokenType={}))[e.Number=0]="Number",e[e.Identifier=1]="Identifier",e[e.DynamicIdentifier=2]="DynamicIdentifier",e[e.String=3]="String",e[e.Date=4]="Date",e[e.TimeSpan=5]="TimeSpan",e[e.Terminal=6]="Terminal",e[e.EndOfString=7]="EndOfString",e[e.Null=8]="Null",e[e.ArIn=9]="ArIn",e[e.ArEq=10]="ArEq",e[e.ArNotEq=11]="ArNotEq",e[e.ArGr=12]="ArGr",e[e.ArGre=13]="ArGre",e[e.ArLs=14]="ArLs",e[e.ArLse=15]="ArLse",e[e.BoolNot=16]="BoolNot",e[e.BoolAnd=17]="BoolAnd",e[e.BoolOr=18]="BoolOr",e[e.ArPlus=19]="ArPlus",e[e.ArMinus=20]="ArMinus",e[e.ArMul=21]="ArMul",e[e.ArDiv=22]="ArDiv",e[e.ExprOpen=23]="ExprOpen",e[e.ExprClose=24]="ExprClose",e[e.ArrayOpen=25]="ArrayOpen",e[e.ArrayClose=26]="ArrayClose",e[e.Separator=27]="Separator",e[e.Function=28]="Function",e[e.Between=29]="Between",e[e.Outside=30]="Outside";const k={start:0,end:0};let T=o((function e(t,r,o){void 0===o&&(o=k),n(this,e),this.type=t,this.value=r,this.position=o})),v=function(){function e(t,r,o){void 0===r&&(r=null),void 0===o&&(o=null),n(this,e),this.token=t,this.left=r,this.right=o}return o(e,[{key:"accept",value:function(e){return e.visit(this)}}]),e}(),x=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();x.TOKENS=[exports.TokenType.String,exports.TokenType.Number,exports.TokenType.DynamicIdentifier,exports.TokenType.Date];let d=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();d.TOKENS=[exports.TokenType.Identifier];let E=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();E.TOKENS=[exports.TokenType.ArEq,exports.TokenType.ArNotEq,exports.TokenType.ArGr,exports.TokenType.ArGre,exports.TokenType.ArLs,exports.TokenType.ArLse,exports.TokenType.ArPlus,exports.TokenType.ArMinus,exports.TokenType.ArDiv,exports.TokenType.ArMul,exports.TokenType.Between,exports.TokenType.Outside];let A=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();A.TOKENS=[exports.TokenType.BoolAnd,exports.TokenType.BoolOr];let g=function(e){s(r,v);var t=f(r);function r(e,o,i,s){var u;return void 0===i&&(i=null),void 0===s&&(s=null),n(this,r),(u=t.call(this,e,i,s)).func=o,u}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();g.TOKENS=[exports.TokenType.Function];const O=new Map;O.set(exports.TokenType.ExprOpen,0),O.set(exports.TokenType.ExprClose,0),O.set(exports.TokenType.BoolAnd,1),O.set(exports.TokenType.BoolOr,1),O.set(exports.TokenType.ArEq,2),O.set(exports.TokenType.ArNotEq,2),O.set(exports.TokenType.ArGr,2),O.set(exports.TokenType.ArGre,2),O.set(exports.TokenType.ArLs,2),O.set(exports.TokenType.ArLse,2),O.set(exports.TokenType.ArPlus,3),O.set(exports.TokenType.ArMinus,3),O.set(exports.TokenType.ArMul,4),O.set(exports.TokenType.ArDiv,4),O.set(exports.TokenType.Function,5),O.set(exports.TokenType.Between,5),O.set(exports.TokenType.Outside,5);let N=function(e){s(r,l(Error));var t=f(r);function r(e,o){var i;void 0===o&&(o=k),n(this,r),(i=t.call(this)).position=o;const{start:s,end:u}=o;return i.message=i.name+"(cимвол: "+(s+1)+", "+(u+1)+"):"+e+".",i}return o(r)}(),b=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="LintError",i}return o(r)}();const m=e=>e[e.length-1],S=e=>x.is(e)||d.is(e),w=e=>E.is(e)||A.is(e)||g.is(e);let B=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionAst",i}return o(r)}(),C=function(){function e(){n(this,e)}return o(e,[{key:"visit",value:function(e){return e instanceof A?this.visitBoolOpNode(e):e instanceof E?this.visitOpNode(e):e instanceof x?this.visitValueNode(e):e instanceof d?this.visitAttributeNode(e):e instanceof g?this.visitFunctionNode(e):void 0}},{key:"visitBoolOpNode",value:function(e){}},{key:"visitOpNode",value:function(e){}},{key:"visitValueNode",value:function(e){}},{key:"visitAttributeNode",value:function(e){}},{key:"visitFunctionNode",value:function(e){}}]),e}(),L=function(e){s(r,C);var t=f(r);function r(e){var o;return n(this,r),(o=t.call(this)).attributes=e,o}return o(r,[{key:"visitBoolOpNode",value:function(e){y(u(r.prototype),"visitBoolOpNode",this).call(this,e),this.checkBoolOpNode(e),this.acceptLeafs(e)}},{key:"visitOpNode",value:function(e){y(u(r.prototype),"visitOpNode",this).call(this,e),this.checkOpNode(e),this.acceptLeafs(e)}},{key:"visitValueNode",value:function(e){y(u(r.prototype),"visitValueNode",this).call(this,e),this.checkLeafNode(e)}},{key:"visitAttributeNode",value:function(e){y(u(r.prototype),"visitAttributeNode",this).call(this,e),this.checkLeafNode(e),this.checkAttributeNode(e)}},{key:"visitFunctionNode",value:function(e){y(u(r.prototype),"visitFunctionNode",this).call(this,e),this.checkLeafNode(e),this.checkFunctionNode(e)}},{key:"checkBoolOpNode",value:function(e){const t="Ожидается выражение вида 'a == 2 "+e.token.value+" b == 3'";this.isOperationNode(e.left)||this.Error(t,e.token),this.isOperationNode(e.right)||this.Error(t,e.token)}},{key:"checkOpNode",value:function(e){e.left&&e.right||this.Error("'"+e.token.value+"' ожидает выражение",e.token)}},{key:"checkLeafNode",value:function(e){if(e.left){const{token:t}=e.left;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}if(e.right){const{token:t}=e.right;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}}},{key:"checkAttributeNode",value:function(e){e.token.value&&void 0!==this.attributes[e.token.value]||this.Error("Атрибут '"+e.token.value+"' не найден в атрибутах слоя",e.token)}},{key:"checkFunctionNode",value:function(e){const t=e.func.check(this.attributes);t instanceof Error&&this.Error(t.message,e.token)}},{key:"Error",value:function(e,t){const{position:n}=t;throw new b(e,n)}},{key:"acceptLeafs",value:function(e){return{x:e.left&&e.left.accept(this),y:e.right&&e.right.accept(this)}}},{key:"isOperationNode",value:function(e){return e instanceof A||e instanceof E}}]),r}(),M=function(e){s(r,L);var t=f(r);function r(e,o){var i;return n(this,r),(i=t.call(this,e)).attributes=e,i.silent=!(!o||!o.silent),i}return o(r,[{key:"visitBoolOpNode",value:function(e){this.silent||y(u(r.prototype),"visitBoolOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);return e.token.type===exports.TokenType.BoolAnd?t&&n:t||n}},{key:"visitOpNode",value:function(e){this.silent||y(u(r.prototype),"visitOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);switch(e.token.type){case exports.TokenType.ArEq:return t===n;case exports.TokenType.ArNotEq:return t!==n;case exports.TokenType.ArGre:return t>=n;case exports.TokenType.ArLse:return t<=n;case exports.TokenType.ArGr:return t>n;case exports.TokenType.ArLs:return t<n;case exports.TokenType.ArPlus:return t+n;case exports.TokenType.ArMinus:return t-n;case exports.TokenType.ArMul:return t*n;case exports.TokenType.ArDiv:return t/n;default:return!1}}},{key:"visitValueNode",value:function(e){return this.silent||y(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return this.silent||y(u(r.prototype),"visitAttributeNode",this).call(this,e),this.attributes[e.token.value]}},{key:"visitFunctionNode",value:function(e){return this.silent||y(u(r.prototype),"visitFunctionNode",this).call(this,e),e.func.calc(this.attributes)}}]),r}(),P=function(){function e(t){n(this,e),this.args=t}return o(e,[{key:"calc",value:function(e){return 0}},{key:"evaluateArguments",value:function(e){return this.args.map(t=>{if(t instanceof E)return t.accept(new M(e));if("string"==typeof t.value){if("number"!=typeof e[t.value]){const{position:e}=t;throw new b("Аргумент функции должен быть числовым типом",e)}return e[t.value]}return t.value})}},{key:"check",value:function(e,t){return this.evaluateArguments(e).length!==t?new Error("Передано неверное количество аргументов"):null}}]),e}(),D=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sin(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();D.ArgsCount=1,D.Name="sin";let F=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.asin(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();F.ArgsCount=1,F.Name="arcsin";let I=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.cos(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();I.ArgsCount=1,I.Name="cos";let _=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.acos(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();_.ArgsCount=1,_.Name="arccos";let R=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t,n]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan2(t,n).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();R.ArgsCount=2,R.Name="arctan2";let U=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.tan(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();U.ArgsCount=1,U.Name="tan";let K=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();K.ArgsCount=1,K.Name="arctan";let q=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sqrt(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();q.ArgsCount=1,q.Name="sqrt";const G={[D.Name]:D,[F.Name]:F,[I.Name]:I,[_.Name]:_,[U.Name]:U,[K.Name]:K,[R.Name]:R,[q.Name]:q},j=e=>t.isValid(e)?e:"#'"+e+"'";let V=function(){function e(t){n(this,e),this.tokens=t,this.tree=null,this.currentPosition=0}return o(e,[{key:"value",get:function(){if(this.tree)return this.tree;this.tokens=function(e){let t=[];const n=[];for(const i of e){if(S(i)&&t.push(i),w(i)){if(![exports.TokenType.Between,exports.TokenType.Outside].includes(i.type))for(;m(n)&&(r=m(n),o=i,O.get(r.type)>O.get(o.type))&&m(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());n.push(i)}if(i.type===exports.TokenType.ExprOpen&&n.push(i),i.type===exports.TokenType.ExprClose){const e=i;for(;m(n)&&m(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());if(0===n.length)throw new b("Пропущена открывающая скобка",e.position);m(n).type===exports.TokenType.ExprOpen&&n.pop()}}var r,o;if(n.length){const e=m(n);if(e.type===exports.TokenType.ExprOpen)throw new b("Пропущена закрывающая скобка",e.position);t=[...t,...n.reverse()]}return t}(this.tokens);const e=[];for(;this.currentPosition<this.tokens.length;this.nextToken()){if(x.is(this.currentToken)&&e.push(new x(this.currentToken)),d.is(this.currentToken)&&e.push(new d(this.currentToken)),g.is(this.currentToken)){const t=G[this.currentToken.value];t||this.Error("Функция '"+this.currentToken.value+"' не определена",this.currentToken);const n=[];for(let r=0;r<t.ArgsCount;r++){const t=e.pop()||null;t instanceof E?n.push(t):t&&t.token&&n.push(t.token)}const r=new t(n);e.push(new g(this.currentToken,r))}if(E.is(this.currentToken)){const r=new E(this.currentToken);if([exports.TokenType.Between,exports.TokenType.Outside].includes(this.currentToken.type)){var t,n;const o=e.pop()||null,s=e.pop()||null;r.left=e.pop()||null,r.right=new x(i({},this.currentToken,{value:j(null==s?void 0:s.token.value)+" - "+j(null==o?void 0:o.token.value),position:{start:(null==s||null==(t=s.token.position)?void 0:t.start)||0,end:(null==o||null==(n=o.token.position)?void 0:n.end)||0}}))}else e.length>1&&(r.right=e.pop()||null),r.left=e.pop()||null;e.push(r)}if(A.is(this.currentToken)){const t=new A(this.currentToken);e.length>1&&(t.right=e.pop()||null),t.left=e.pop()||null,e.push(t)}}return this.tree=e.pop()||null,this.flashStack(e),this.checkRoot(),this.tree}},{key:"nextToken",value:function(){this.currentPosition+=1}},{key:"currentToken",get:function(){return this.tokens[this.currentPosition]}},{key:"checkRoot",value:function(){}},{key:"flashStack",value:function(e){if(this.tree&&e.length)for(;e.length;){const t=e.pop();t&&this.insert(this.tree,t)}}},{key:"insert",value:function(e,t){null!==e.right?this.insert(e.right,t):e.right=t}},{key:"Error",value:function(e,t){const{position:n}=t,{start:r,end:o}=n;throw new B(e,{start:r,end:o})}}]),e}(),W=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionTokenizer",i}return o(r)}(),H=function(){function e(t,r,o){void 0===o&&(o=[]),n(this,e),this.acceptMap=new Map,this.value=t,this.tokenType=r,o.map(e=>this.acceptMap.set(e.value,e))}return o(e,[{key:"accept",value:function(e){return this.acceptMap.get(e)||null}}]),e}(),z=function(){function e(){n(this,e)}return o(e,null,[{key:"isChar",value:function(e){return"string"==typeof e&&1===e.length}},{key:"isDigit",value:function(e){return this.isChar(e)&&/\d/.test(e)}},{key:"isLetter",value:function(e){return this.isChar(e)&&/\w/.test(e)}},{key:"isWhiteSpace",value:function(t){return this.isChar(t)&&t===e.WHITE_SPACE}},{key:"isLetterOrDigit",value:function(t){return e.isLetter(t)||e.isDigit(t)}},{key:"isUnderscore",value:function(t){return e.isChar(t)&&t===e.UNDERSCORE}},{key:"isFloating",value:function(t){return e.isChar(t)&&("f"===t||"F"===t)}},{key:"escapeSpecChars",value:function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\t/g,"\\\\t").replace(/\v/g,"\\\\v").replace(/\0/g,"\\\\0").replace(/\f/g,"\\\\f").replace(/\n/g,"\\\\n").replace(/\r/g,"\\\\r")}},{key:"unEscapeSpecChars",value:function(e){return e.replace(/\\'/g,"'").replace(/\\"/g,'"').replace(/\\\\/g,"\\").replace(/\\\\t/g,"\t").replace(/\\\\v/g,"\v").replace(/\\\\0/g,"\0").replace(/\\\\f/g,"\f").replace(/\\\\n/g,"\n").replace(/\\\\r/g,"\r")}}]),e}();function Q(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}z.LEFT_BRACKET="{",z.OPEN_BRACKET="(",z.BETWEEN="between",z.OUTSIDE="!between",z.SINGLE_QUOTE="'",z.DOUBLE_QUOTE='"',z.HASH_SYMBOL="#",z.RIGHT_BRACKET="}",z.CLOSE_BRACKET=")",z.BACK_SLASH="\\",z.WHITE_SPACE=" ",z.UNDERSCORE="_",z.PERCENTAGE="%",z.POINT=".";let Y=o((function e(){n(this,e)}));Y.sToMs=e=>1e3*e,Y.mToMs=e=>60*Y.sToMs(e),Y.hToMs=e=>60*Y.mToMs(e),Y.dToMs=e=>24*Y.hToMs(e),Y.mthToMs=e=>30*Y.dToMs(e),Y.yToMs=e=>365*Y.mthToMs(e);const J=new H("",exports.TokenType.Null,[new H(z.BETWEEN,exports.TokenType.Between),new H(z.OUTSIDE,exports.TokenType.Outside),new H(">",exports.TokenType.ArGr,[new H("=",exports.TokenType.ArGre)]),new H("<",exports.TokenType.ArLs,[new H("=",exports.TokenType.ArLse)]),new H("!",exports.TokenType.BoolNot,[new H("=",exports.TokenType.ArNotEq)]),new H("&",exports.TokenType.Null,[new H("&",exports.TokenType.BoolAnd)]),new H("=",exports.TokenType.ArEq,[new H("=",exports.TokenType.ArEq)]),new H("|",exports.TokenType.Null,[new H("|",exports.TokenType.BoolOr)]),new H("+",exports.TokenType.ArPlus),new H("-",exports.TokenType.ArMinus),new H("*",exports.TokenType.ArMul),new H("/",exports.TokenType.ArDiv),new H("(",exports.TokenType.ExprOpen),new H(")",exports.TokenType.ExprClose),new H("[",exports.TokenType.ArrayOpen),new H("]",exports.TokenType.ArrayClose),new H(",",exports.TokenType.Separator)]);let X=function(){function e(t){n(this,e),this.start=0,this.currentPosition=0,this.tokens=[],this.input=t||""}return o(e,[{key:"tokenize",value:function(){if(this.isEndOfString())return this.tokens;for(;;){const e=this.nextToken();if(!e)break;if(this.tokens.push(e),this.tokens.length>1e3&&this.Error("Привышен лимит запроса: 1000"),e.type===exports.TokenType.EndOfString)break}return this.tokens}},{key:"nextToken",value:function(){for(;this.currentPosition<this.input.length;this.nextSymbol()){if(z.isWhiteSpace(this.current))continue;if(this.resetStart(),this.input.slice(this.currentPosition).startsWith(z.OUTSIDE))return this.currentPosition+=z.OUTSIDE.length,this.createToken(exports.TokenType.Outside,z.OUTSIDE);if(this.input.slice(this.currentPosition).startsWith(z.BETWEEN))return this.currentPosition+=z.BETWEEN.length,this.createToken(exports.TokenType.Between,z.BETWEEN);const e=J.accept(this.current);if(null!==e)return this.captureSpecial(e);if(z.isDigit(this.current)||this.current===z.POINT)return this.captureNumber();if(z.isLetter(this.current)||z.isUnderscore(this.current))return this.captureIdentifier();if(this.current===z.LEFT_BRACKET)return this.captureDynamicIdentifier();if(this.current===z.DOUBLE_QUOTE||this.current===z.SINGLE_QUOTE)return this.captureString();if(this.current===z.HASH_SYMBOL)return this.captureDate()}return this.resetStart(),this.createToken(exports.TokenType.EndOfString)}},{key:"resetStart",value:function(){this.start=this.currentPosition}},{key:"createToken",value:function(e,t){void 0===t&&(t=null);const n=this.currentPosition-(e===exports.TokenType.EndOfString?0:1);return new T(e,t,{start:this.start,end:n})}},{key:"nextSymbol",value:function(){this.currentPosition+=1}},{key:"current",get:function(){return this.input[this.currentPosition]}},{key:"captureSpecial",value:function(e){let t=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol()){const n=e.accept(this.current);if(null===n||n.tokenType===exports.TokenType.Null)break;t+=this.current,e=n}return this.current&&z.isDigit(this.current)&&e.tokenType===exports.TokenType.ArMinus?this.createToken(exports.TokenType.Number,-(this.captureNumber().value||0)):(e.tokenType===exports.TokenType.Null&&this.Error("Неизвеcтная операция '"+e.value+"'"),this.createToken(e.tokenType,t))}},{key:"captureNumber",value:function(){let e="",t=!1;for(;this.currentPosition<this.input.length&&!z.isWhiteSpace(this.current)&&(z.isDigit(this.current)||z.isFloating(this.current)||this.current===z.POINT);this.nextSymbol())this.current===z.POINT&&(t=!0),e+=this.current;t&&z.isFloating(e[e.length-1])&&(e=e.slice(0,-1));const n=parseFloat(e);return Number.isNaN(n)&&this.Error("Неверный числовой формат: "+e),this.createToken(exports.TokenType.Number,n)}},{key:"captureIdentifier",value:function(){let e="";for(;this.currentPosition<this.input.length&&(z.isLetterOrDigit(this.current)||z.isUnderscore(this.current));this.nextSymbol())e+=this.current;if(this.current===z.OPEN_BRACKET){const t=this.tokens.some(e=>e.type===exports.TokenType.Between),n=this.tokens.some(e=>e.type===exports.TokenType.Outside);return this.createToken(n?exports.TokenType.Outside:t?exports.TokenType.Between:exports.TokenType.Function,e)}return"true"===e||"True"===e||"TRUE"===e?this.createToken(exports.TokenType.Terminal,!0):"false"===e||"False"===e||"FALSE"===e?this.createToken(exports.TokenType.Terminal,!1):"in"===e||"IN"===e?this.createToken(exports.TokenType.ArIn):this.createToken(exports.TokenType.Identifier,e)}},{key:"captureDynamicIdentifier",value:function(){this.nextSymbol();let e="";for(;this.currentPosition<this.input.length;this.nextSymbol()){if(this.current===z.RIGHT_BRACKET){this.nextSymbol();break}e+=this.current}return this.createToken(exports.TokenType.DynamicIdentifier,"null"===e||"Null"===e||"NULL"===e?null:e)}},{key:"captureString",value:function(){let e="",t=!1;const n=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol())if(t||this.current!==z.BACK_SLASH){if(!t&&this.current===n)return this.nextSymbol(),this.createToken(exports.TokenType.String,e);e+=this.current,t=!1}else t=!0;this.Error("Открытая строка")}},{key:"captureDate",value:function(){if(this.nextSymbol(),![z.SINGLE_QUOTE,z.DOUBLE_QUOTE,z.BACK_SLASH].includes(this.current))return this.captureTimeSpan();const e=this.captureString();return this.createToken(exports.TokenType.Date,e.value)}},{key:"captureTimeSpan",value:function(){let e="";for(;this.currentPosition<this.input.length&&z.isDigit(this.current);this.nextSymbol())e+=this.current;const t=parseFloat(e);Number.isNaN(t)&&this.Error("Неверный формат числа для значения timespan: "+e+". Должно быть положительным целочисленным значением."),z.isLetter(this.current)||this.Error("Для значения задана неверная единица измерения "+this.current);let n="";for(;z.isLetter(this.current);)n+=this.current,this.nextSymbol();let r=0;switch(n){case"ms":r=t;break;case"s":r=Y.sToMs(t);break;case"m":r=Y.mToMs(t);break;case"h":r=Y.hToMs(t);break;case"d":r=Y.dToMs(t);break;case"mth":r=Y.mthToMs(t);break;case"y":r=Y.yToMs(t);break;default:this.Error("Неверная единица измерения для timespan: "+n)}return this.createToken(exports.TokenType.TimeSpan,r)}},{key:"isEndOfString",value:function(){return this.tokens.length>0&&this.tokens[this.tokens.length-1].type===exports.TokenType.EndOfString}},{key:"Error",value:function(e){throw new W(e,{start:this.start,end:this.start})}}]),e}(),Z=function(e){s(r,C);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"visitBoolOpNode",value:function(e){y(u(r.prototype),"visitBoolOpNode",this).call(this,e);const t=e.left&&e.left.accept(this),n=e.right&&e.right.accept(this);return e.left instanceof A&&e.right instanceof A?(this.checkBoolOperations(e.token.type,[...t.boolOperations,...n.boolOperations]),{boolOperations:[...t.boolOperations,e.token.type,...n.boolOperations],expressions:[...t.expressions,...n.expressions]}):e.right instanceof A?(this.checkBoolOperations(e.token.type,n.boolOperations),{boolOperations:[e.token.type,...n.boolOperations],expressions:[t,...n.expressions]}):e.left instanceof A?(this.checkBoolOperations(e.token.type,t.boolOperations),{boolOperations:[...t.boolOperations,e.token.type],expressions:[...t.expressions,n]}):{boolOperations:[e.token.type],expressions:[t,n]}}},{key:"visitOpNode",value:function(e){var t;y(u(r.prototype),"visitOpNode",this).call(this,e),this.checkExpressionSimple(e);const n=e.left&&e.left.accept(this),o=e.right&&(null==(t=e.right)?void 0:t.accept(this));return{attribute:n,operation:e.token.type,value:o}}},{key:"visitValueNode",value:function(e){return y(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return y(u(r.prototype),"visitAttributeNode",this).call(this,e),e.token.value}},{key:"checkBoolOperations",value:function(e,t){if(t.some(t=>t!==e))throw new b("Выражение должно использовать одинаковые булевы операторы")}},{key:"checkExpressionSimple",value:function(e){if(!(e.left instanceof d&&e.right instanceof x||e.right instanceof x))throw new b("Выражение должно быть простым")}}]),r}();const $=e=>Q(e)&&"boolOperations"in e,ee=e=>Q(e)&&"attribute"in e;let te=function(){function e(t){n(this,e),this.result=null,this.tokenizer=new X(t)}return o(e,[{key:"value",get:function(){if(this.result)return this.result;try{const e=this.tokenizer.tokenize(),t=new V(e).value,n=t&&t.accept(new Z);return this.result=$(n)?n:ee(n)?{boolOperations:[],expressions:[n]}:{boolOperations:[],expressions:[]},this.result}catch(e){return e}}}]),e}(),ne=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"evaluate",value:function(e,t){try{const n=new X(e).tokenize(),r=new V(n).value;return r&&r.accept(new M(this.attributes,t))}catch(e){return e}}}]),e}(),re=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"lint",value:function(e){try{const t=new X(e).tokenize(),n=new V(t).value;return n&&n.accept(new L(this.attributes)),null}catch(e){return e}}}]),e}();exports.ArcCos=_,exports.ArcSin=F,exports.ArcTan=K,exports.ArcTan2=R,exports.AttributeNode=d,exports.BoolOperationNode=A,exports.Char=z,exports.ConditionEvaluator=ne,exports.ConditionInterpreter=te,exports.ConditionLinter=re,exports.ConditionVisitor=Z,exports.Cos=I,exports.DEFAULT_TOKEN_POSITION=k,exports.EqlFunction=P,exports.EqlFunctions=G,exports.EvaluateVisitor=M,exports.ExpressionAst=V,exports.ExpressionAstError=B,exports.ExpressionNode=v,exports.ExpressionTokenizer=X,exports.ExpressionTokenizerError=W,exports.ExpressionVisitor=C,exports.FunctionNode=g,exports.LintError=b,exports.LintVisitor=L,exports.OperationNode=E,exports.Sin=D,exports.Sqrt=q,exports.Tan=U,exports.Time=Y,exports.Token=T,exports.TokenError=N,exports.ValueNode=x,exports.isBoolResult=$,exports.isExpression=ee,exports.isObject=Q;
//# sourceMappingURL=condition.cjs.production.min.js.map

@@ -241,4 +241,2 @@ import { isValid } from 'date-fns';

TokenType[TokenType["Outside"] = 30] = "Outside";
TokenType[TokenType["Intersect"] = 31] = "Intersect";
TokenType[TokenType["NotIntersect"] = 32] = "NotIntersect";
})(TokenType || (TokenType = {}));

@@ -353,3 +351,3 @@

}(ExpressionNode);
OperationNode.TOKENS = [TokenType.ArEq, TokenType.ArNotEq, TokenType.ArGr, TokenType.ArGre, TokenType.ArLs, TokenType.ArLse, TokenType.ArPlus, TokenType.ArMinus, TokenType.ArDiv, TokenType.ArMul, TokenType.Between, TokenType.Outside, TokenType.Intersect, TokenType.NotIntersect];
OperationNode.TOKENS = [TokenType.ArEq, TokenType.ArNotEq, TokenType.ArGr, TokenType.ArGre, TokenType.ArLs, TokenType.ArLse, TokenType.ArPlus, TokenType.ArMinus, TokenType.ArDiv, TokenType.ArMul, TokenType.Between, TokenType.Outside];
let BoolOperationNode = /*#__PURE__*/function (_ExpressionNode4) {

@@ -428,4 +426,2 @@ _inherits(BoolOperationNode, _ExpressionNode4);

OperationPrecedence.set(TokenType.Outside, 5);
OperationPrecedence.set(TokenType.Intersect, 5);
OperationPrecedence.set(TokenType.NotIntersect, 5);

@@ -505,3 +501,3 @@ let TokenError = /*#__PURE__*/function (_Error) {

if (isOperation(token)) {
if (![TokenType.Between, TokenType.Outside, TokenType.Intersect, TokenType.NotIntersect].includes(token.type)) {
if (![TokenType.Between, TokenType.Outside].includes(token.type)) {
while (last(operators) && isHigherPrecedence(last(operators), token) && last(operators).type !== TokenType.ExprOpen) {

@@ -1436,4 +1432,2 @@ output.push(operators.pop());

Char.OUTSIDE = '!between';
Char.INTERSECT = 'intersect';
Char.NOT_INTERSECT = '!intersect';
Char.SINGLE_QUOTE = "'";

@@ -1470,3 +1464,3 @@ Char.DOUBLE_QUOTE = '"';

const AcceptTree = /*#__PURE__*/new OperationAccept('', TokenType.Null, [/*#__PURE__*/new OperationAccept(Char.BETWEEN, TokenType.Between), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, TokenType.Outside), /*#__PURE__*/new OperationAccept(Char.BETWEEN, TokenType.Intersect), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, TokenType.NotIntersect), /*#__PURE__*/new OperationAccept('>', TokenType.ArGr, [/*#__PURE__*/new OperationAccept('=', TokenType.ArGre)]), /*#__PURE__*/new OperationAccept('<', TokenType.ArLs, [/*#__PURE__*/new OperationAccept('=', TokenType.ArLse)]), /*#__PURE__*/new OperationAccept('!', TokenType.BoolNot, [/*#__PURE__*/new OperationAccept('=', TokenType.ArNotEq)]), /*#__PURE__*/new OperationAccept('&', TokenType.Null, [/*#__PURE__*/new OperationAccept('&', TokenType.BoolAnd)]), /*#__PURE__*/new OperationAccept('=', TokenType.ArEq, [/*#__PURE__*/new OperationAccept('=', TokenType.ArEq)]), /*#__PURE__*/new OperationAccept('|', TokenType.Null, [/*#__PURE__*/new OperationAccept('|', TokenType.BoolOr)]), /*#__PURE__*/new OperationAccept('+', TokenType.ArPlus), /*#__PURE__*/new OperationAccept('-', TokenType.ArMinus), /*#__PURE__*/new OperationAccept('*', TokenType.ArMul), /*#__PURE__*/new OperationAccept('/', TokenType.ArDiv), /*#__PURE__*/new OperationAccept('(', TokenType.ExprOpen), /*#__PURE__*/new OperationAccept(')', TokenType.ExprClose), /*#__PURE__*/new OperationAccept('[', TokenType.ArrayOpen), /*#__PURE__*/new OperationAccept(']', TokenType.ArrayClose), /*#__PURE__*/new OperationAccept(',', TokenType.Separator)]);
const AcceptTree = /*#__PURE__*/new OperationAccept('', TokenType.Null, [/*#__PURE__*/new OperationAccept(Char.BETWEEN, TokenType.Between), /*#__PURE__*/new OperationAccept(Char.OUTSIDE, TokenType.Outside), /*#__PURE__*/new OperationAccept('>', TokenType.ArGr, [/*#__PURE__*/new OperationAccept('=', TokenType.ArGre)]), /*#__PURE__*/new OperationAccept('<', TokenType.ArLs, [/*#__PURE__*/new OperationAccept('=', TokenType.ArLse)]), /*#__PURE__*/new OperationAccept('!', TokenType.BoolNot, [/*#__PURE__*/new OperationAccept('=', TokenType.ArNotEq)]), /*#__PURE__*/new OperationAccept('&', TokenType.Null, [/*#__PURE__*/new OperationAccept('&', TokenType.BoolAnd)]), /*#__PURE__*/new OperationAccept('=', TokenType.ArEq, [/*#__PURE__*/new OperationAccept('=', TokenType.ArEq)]), /*#__PURE__*/new OperationAccept('|', TokenType.Null, [/*#__PURE__*/new OperationAccept('|', TokenType.BoolOr)]), /*#__PURE__*/new OperationAccept('+', TokenType.ArPlus), /*#__PURE__*/new OperationAccept('-', TokenType.ArMinus), /*#__PURE__*/new OperationAccept('*', TokenType.ArMul), /*#__PURE__*/new OperationAccept('/', TokenType.ArDiv), /*#__PURE__*/new OperationAccept('(', TokenType.ExprOpen), /*#__PURE__*/new OperationAccept(')', TokenType.ExprClose), /*#__PURE__*/new OperationAccept('[', TokenType.ArrayOpen), /*#__PURE__*/new OperationAccept(']', TokenType.ArrayClose), /*#__PURE__*/new OperationAccept(',', TokenType.Separator)]);

@@ -1531,12 +1525,2 @@ const TOKENIZER_MAX_SIZE = 1000;

if (this.input.slice(this.currentPosition).startsWith(Char.INTERSECT)) {
this.currentPosition += Char.INTERSECT.length;
return this.createToken(TokenType.Intersect, Char.INTERSECT);
}
if (this.input.slice(this.currentPosition).startsWith(Char.NOT_INTERSECT)) {
this.currentPosition += Char.NOT_INTERSECT.length;
return this.createToken(TokenType.NotIntersect, Char.NOT_INTERSECT);
}
const acceptOp = AcceptTree.accept(this.current);

@@ -1682,14 +1666,3 @@

const isOutside = this.tokens.some(token => token.type === TokenType.Outside);
const isIntersect = this.tokens.some(token => token.type === TokenType.Intersect);
const isNotIntersect = this.tokens.some(token => token.type === TokenType.NotIntersect);
if (isBetween || isOutside) {
return this.createToken(isOutside ? TokenType.Outside : TokenType.Between, result);
}
if (isIntersect || isNotIntersect) {
return this.createToken(isIntersect ? TokenType.Intersect : TokenType.NotIntersect, result);
}
return this.createToken(TokenType.Function, result);
return this.createToken(isOutside ? TokenType.Outside : isBetween ? TokenType.Between : TokenType.Function, result);
}

@@ -1696,0 +1669,0 @@

@@ -32,5 +32,3 @@ export declare enum TokenType {

Between = 29,
Outside = 30,
Intersect = 31,
NotIntersect = 32
Outside = 30
}

@@ -37,0 +35,0 @@ export declare type TokenValue = string | number | boolean | null;

@@ -6,4 +6,2 @@ export declare class Char {

static readonly OUTSIDE = "!between";
static readonly INTERSECT = "intersect";
static readonly NOT_INTERSECT = "!intersect";
static readonly SINGLE_QUOTE = "'";

@@ -10,0 +8,0 @@ static readonly DOUBLE_QUOTE = "\"";

{
"version": "1.2.19",
"version": "1.2.20",
"license": "MIT",

@@ -36,3 +36,3 @@ "main": "dist/index.js",

"module": "dist/condition.esm.js",
"gitHead": "6d41f1d12415b85b028406303b3cf2ed842b3b8e"
"gitHead": "0937b11bb6edbc4dbd49bfe0394fb16ae36e49b5"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc