cc3cc03e663ddf25ee94d05149edc05b03894223
[motion-next.git] / server / services / routing / lib / rule-engine.js
1 const a1327_0x4014=['register','priority','lodash','EventEmitter','ignoreFactChanges','findRules','map','isString','isObject','init','fromJSON','call','isArray','matchPath','rules','toString','isEqual','consequence','restart','sync','object','activeRules','prioritize','exports','result','push','ruleRef','orderBy','condition','events','prototype','nextTick','noop','next','asc','matches','isNil','filter','inherits','concat','name','parse','clone','length'];(function(_0x645295,_0xfcee5){const _0x4014ab=function(_0x46cb77){while(--_0x46cb77){_0x645295['push'](_0x645295['shift']());}};_0x4014ab(++_0xfcee5);}(a1327_0x4014,0xa3));const a1327_0x46cb=function(_0x645295,_0xfcee5){_0x645295=_0x645295-0xc9;let _0x4014ab=a1327_0x4014[_0x645295];return _0x4014ab;};const a1327_0x4bf5e6=a1327_0x46cb;'use strict';const _=require(a1327_0x4bf5e6(0xd8)),util=require('util'),EventEmitter=require(a1327_0x4bf5e6(0xf3))[a1327_0x4bf5e6(0xd9)];function RuleEngine(_0x203179,_0x3a3ae0){const _0x382d98=a1327_0x4bf5e6;return this['init'](),!_[_0x382d98(0xce)](_0x203179)&&this[_0x382d98(0xd6)](_0x203179),_0x3a3ae0&&(this[_0x382d98(0xda)]=_0x3a3ae0[_0x382d98(0xda)]),this;}util[a1327_0x4bf5e6(0xd0)](RuleEngine,EventEmitter),RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xdf)]=function(){const _0x239e8f=a1327_0x4bf5e6;this[_0x239e8f(0xe4)]=[],this[_0x239e8f(0xeb)]=[];},RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xd6)]=function(_0x375d9d){const _0x5a31bd=a1327_0x4bf5e6;if(Array[_0x5a31bd(0xe2)](_0x375d9d))this[_0x5a31bd(0xe4)]=this['rules'][_0x5a31bd(0xd1)](_0x375d9d);else _0x375d9d!==null&&_[_0x5a31bd(0xde)](_0x375d9d)&&this[_0x5a31bd(0xe4)][_0x5a31bd(0xef)](_0x375d9d);this[_0x5a31bd(0xe9)]();},RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xe9)]=function(){const _0x232c8f=a1327_0x4bf5e6;this[_0x232c8f(0xeb)]=this[_0x232c8f(0xe4)][_0x232c8f(0xcf)](function(_0x1bf66d){const _0x4aad23=_0x232c8f;_[_0x4aad23(0xce)](_0x1bf66d['on'])&&(_0x1bf66d['on']=!![]);if(_0x1bf66d['on']===!![])return _0x1bf66d;}),this[_0x232c8f(0xeb)]=_[_0x232c8f(0xf1)](this['activeRules'],['p'],[_0x232c8f(0xcc)]);},RuleEngine[a1327_0x4bf5e6(0xf4)]['execute']=function(_0x394ba0,_0x46cbd6){const _0x24c83e=a1327_0x4bf5e6;let _0x2bc0cb=![];_0x394ba0[_0x24c83e(0xee)]=!![];const _0x509a6b=_[_0x24c83e(0xd4)](_0x394ba0);let _0x100a21=_['clone'](_0x394ba0);const _0x224729=this[_0x24c83e(0xeb)],_0x3f01f3=[],_0x213b4a=this[_0x24c83e(0xda)];(function _0x424e93(_0x26d65e){const _0x3c5b0c=_0x24c83e,_0xc3b622={'rules':function(){return _0x224729;},'rule':function(){return _0x224729[_0x26d65e];},'when':function(_0x57ba94){const _0xc0a90f=a1327_0x46cb;if(_0x57ba94){const _0x4474f3=_0x224729[_0x26d65e][_0xc0a90f(0xe7)];_0x4474f3['ruleRef']=_0x224729[_0x26d65e]['id']||_0x224729[_0x26d65e][_0xc0a90f(0xd2)]||'index_'+_0x26d65e,process[_0xc0a90f(0xc9)](function(){const _0x46a605=_0xc0a90f;_0x3f01f3[_0x46a605(0xef)](_0x4474f3[_0x46a605(0xf0)]),_0x4474f3['call'](_0x509a6b,_0xc3b622);});}else process[_0xc0a90f(0xc9)](function(){const _0x509b46=_0xc0a90f;_0xc3b622[_0x509b46(0xcb)]();});},'restart':function(){return _0x424e93(0x0);},'stop':function(){return _0x2bc0cb=!![],_0x424e93(0x0);},'next':function(_0x14ea82){const _0x46662e=a1327_0x46cb;!_0x213b4a&&!_[_0x46662e(0xe6)](_0x100a21,_0x509a6b)?(_0x100a21=_[_0x46662e(0xd4)](_0x509a6b),process[_0x46662e(0xc9)](function(){const _0x46252b=_0x46662e;_0xc3b622[_0x46252b(0xe8)]();})):process['nextTick'](function(){const _0x3610ad=_0x46662e;return _[_0x3610ad(0xce)](_0x14ea82)?_0x424e93(_0x26d65e+0x1):_0x424e93(_0x14ea82);});}};if(_0x26d65e<_0x224729[_0x3c5b0c(0xd5)]&&_0x2bc0cb===![]){const _0x2518b9=_0x224729[_0x26d65e][_0x3c5b0c(0xf2)];_0x2518b9[_0x3c5b0c(0xe1)](_0x509a6b,_0xc3b622);}else process[_0x3c5b0c(0xc9)](function(){const _0x1765b8=_0x3c5b0c;return _0x509a6b[_0x1765b8(0xe3)]=_0x3f01f3,_0x46cbd6?_0x46cbd6(_0x509a6b):_[_0x1765b8(0xca)]();});}(0x0));},RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xdb)]=function(_0x25733e){const _0x26b392=a1327_0x4bf5e6;if(_[_0x26b392(0xce)](_0x25733e))return this[_0x26b392(0xe4)];else{const _0x3b78bf=_[_0x26b392(0xcd)](_0x25733e);return _[_0x26b392(0xcf)](this[_0x26b392(0xe4)],_0x3b78bf);}},RuleEngine[a1327_0x4bf5e6(0xf4)]['turn']=function(_0x3da614,_0x6390c){const _0x332921=a1327_0x4bf5e6,_0x313831=_0x3da614==='on'||_0x3da614==='ON'?!![]:![],_0x4b87be=this[_0x332921(0xdb)](_0x6390c);for(let _0x1d8156=0x0,_0x33d8ff=_0x4b87be[_0x332921(0xd5)];_0x1d8156<_0x33d8ff;_0x1d8156+=0x1){_0x4b87be[_0x1d8156]['on']=_0x313831;}this[_0x332921(0xe9)]();},RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xec)]=function(_0x47f995,_0x5705f1){const _0x5dc65b=a1327_0x4bf5e6;_0x47f995=parseInt(_0x47f995,0xa);const _0x216fc1=this[_0x5dc65b(0xdb)](_0x5705f1);for(let _0x3175f1=0x0,_0x4aa843=_0x216fc1[_0x5dc65b(0xd5)];_0x3175f1<_0x4aa843;_0x3175f1+=0x1){_0x216fc1[_0x3175f1][_0x5dc65b(0xd7)]=_0x47f995;}this[_0x5dc65b(0xe9)]();},RuleEngine[a1327_0x4bf5e6(0xf4)]['toJSON']=function(){const _0x27e3e3=a1327_0x4bf5e6;let _0x29b915=this[_0x27e3e3(0xe4)];if(_0x29b915 instanceof Array)_0x29b915=_0x29b915[_0x27e3e3(0xdc)](function(_0x521748){const _0x5cc9b1=_0x27e3e3;return _0x521748[_0x5cc9b1(0xf2)]=_0x521748['condition'][_0x5cc9b1(0xe5)](),_0x521748[_0x5cc9b1(0xe7)]=_0x521748[_0x5cc9b1(0xe7)][_0x5cc9b1(0xe5)](),_0x521748;});else!_[_0x27e3e3(0xce)](_0x29b915)&&(_0x29b915[_0x27e3e3(0xf2)]=_0x29b915['condition'][_0x27e3e3(0xe5)](),_0x29b915['consequence']=_0x29b915[_0x27e3e3(0xe7)]['toString']());return _0x29b915;},RuleEngine[a1327_0x4bf5e6(0xf4)][a1327_0x4bf5e6(0xe0)]=function(_0x204865){const _0x3c780d=a1327_0x4bf5e6;this['init']();_[_0x3c780d(0xdd)](_0x204865)&&(_0x204865=JSON[_0x3c780d(0xd3)](_0x204865));if(_0x204865 instanceof Array)_0x204865=_0x204865[_0x3c780d(0xdc)](function(_0x2eb188){const _0xb24b0e=_0x3c780d;return _0x2eb188[_0xb24b0e(0xf2)]=eval('('+_0x2eb188['condition']+')'),_0x2eb188['consequence']=eval('('+_0x2eb188['consequence']+')'),_0x2eb188;});else _0x204865!==null&&typeof _0x204865==_0x3c780d(0xea)&&(_0x204865[_0x3c780d(0xf2)]=eval('('+_0x204865['condition']+')'),_0x204865[_0x3c780d(0xe7)]=eval('('+_0x204865[_0x3c780d(0xe7)]+')'));this['register'](_0x204865);},module[a1327_0x4bf5e6(0xed)]=RuleEngine;