Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / services / routing / lib / rule-engine.js
index 83c7c6c..0d922b2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8c91=['call','matchPath','noop','findRules','matches','priority','map','condition','toString','object','lodash','util','EventEmitter','init','isNil','ignoreFactChanges','inherits','prototype','rules','activeRules','register','concat','isObject','push','sync','filter','orderBy','asc','execute','clone','consequence','ruleRef','name','index_','nextTick','next','restart','length'];(function(_0x32f1cb,_0x4ecb17){var _0x4cde17=function(_0x56c003){while(--_0x56c003){_0x32f1cb['push'](_0x32f1cb['shift']());}};_0x4cde17(++_0x4ecb17);}(_0x8c91,0x1ac));var _0x18c9=function(_0x1a5a1d,_0x5ed242){_0x1a5a1d=_0x1a5a1d-0x0;var _0x46b983=_0x8c91[_0x1a5a1d];return _0x46b983;};'use strict';var _=require(_0x18c9('0x0'));var util=require(_0x18c9('0x1'));var EventEmitter=require('events')[_0x18c9('0x2')];function RuleEngine(_0x9afb,_0x29d301){this[_0x18c9('0x3')]();if(!_[_0x18c9('0x4')](_0x9afb)){this['register'](_0x9afb);}if(_0x29d301){this[_0x18c9('0x5')]=_0x29d301[_0x18c9('0x5')];}return this;}util[_0x18c9('0x6')](RuleEngine,EventEmitter);RuleEngine[_0x18c9('0x7')]['init']=function(_0x316df8){this[_0x18c9('0x8')]=[];this[_0x18c9('0x9')]=[];};RuleEngine[_0x18c9('0x7')][_0x18c9('0xa')]=function(_0x3b131f){if(Array['isArray'](_0x3b131f)){this[_0x18c9('0x8')]=this[_0x18c9('0x8')][_0x18c9('0xb')](_0x3b131f);}else if(_0x3b131f!==null&&_[_0x18c9('0xc')](_0x3b131f)){this[_0x18c9('0x8')][_0x18c9('0xd')](_0x3b131f);}this[_0x18c9('0xe')]();};RuleEngine[_0x18c9('0x7')]['sync']=function(){this[_0x18c9('0x9')]=this[_0x18c9('0x8')][_0x18c9('0xf')](function(_0x20c070){if(_[_0x18c9('0x4')](_0x20c070['on'])){_0x20c070['on']=!![];}if(_0x20c070['on']===!![]){return _0x20c070;}});this['activeRules']=_[_0x18c9('0x10')](this['activeRules'],['p'],[_0x18c9('0x11')]);};RuleEngine[_0x18c9('0x7')][_0x18c9('0x12')]=function(_0x1e0d7b,_0x2b97e3){var _0x5db46e=![];_0x1e0d7b['result']=!![];var _0x1b791e=_['clone'](_0x1e0d7b);var _0xa839b8=_[_0x18c9('0x13')](_0x1e0d7b);var _0x5af69f=this[_0x18c9('0x9')];var _0x34666e=[];var _0x2b78eb=this[_0x18c9('0x5')];(function FnRuleLoop(_0x1d14c9){var _0x1ba2ee={'rules':function(){return _0x5af69f;},'rule':function(){return _0x5af69f[_0x1d14c9];},'when':function(_0x42e2d9){if(_0x42e2d9){var _0x2fb6b9=_0x5af69f[_0x1d14c9][_0x18c9('0x14')];_0x2fb6b9[_0x18c9('0x15')]=_0x5af69f[_0x1d14c9]['id']||_0x5af69f[_0x1d14c9][_0x18c9('0x16')]||_0x18c9('0x17')+_0x1d14c9;process[_0x18c9('0x18')](function(){_0x34666e['push'](_0x2fb6b9[_0x18c9('0x15')]);_0x2fb6b9['call'](_0x1b791e,_0x1ba2ee);});}else{process['nextTick'](function(){_0x1ba2ee[_0x18c9('0x19')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x5db46e=!![];return FnRuleLoop(0x0);},'next':function(_0x2dc063){if(!_0x2b78eb&&!_['isEqual'](_0xa839b8,_0x1b791e)){_0xa839b8=_[_0x18c9('0x13')](_0x1b791e);process[_0x18c9('0x18')](function(){_0x1ba2ee[_0x18c9('0x1a')]();});}else{process[_0x18c9('0x18')](function(){if(_[_0x18c9('0x4')](_0x2dc063)){return FnRuleLoop(_0x1d14c9+0x1);}else{return FnRuleLoop(_0x2dc063);}});}}};if(_0x1d14c9<_0x5af69f[_0x18c9('0x1b')]&&_0x5db46e===![]){var _0x356e20=_0x5af69f[_0x1d14c9]['condition'];_0x356e20[_0x18c9('0x1c')](_0x1b791e,_0x1ba2ee);}else{process[_0x18c9('0x18')](function(){_0x1b791e[_0x18c9('0x1d')]=_0x34666e;return _0x2b97e3?_0x2b97e3(_0x1b791e):_[_0x18c9('0x1e')]();});}}(0x0));};RuleEngine['prototype'][_0x18c9('0x1f')]=function(_0x5f1aa7){if(_[_0x18c9('0x4')](_0x5f1aa7)){return this[_0x18c9('0x8')];}else{var _0x522140=_[_0x18c9('0x20')](_0x5f1aa7);return _[_0x18c9('0xf')](this[_0x18c9('0x8')],_0x522140);}};RuleEngine[_0x18c9('0x7')]['turn']=function(_0x5c3dee,_0x3beeb7){var _0x58dfbc=_0x5c3dee==='on'||_0x5c3dee==='ON'?!![]:![];var _0x32596d=this[_0x18c9('0x1f')](_0x3beeb7);for(var _0x42c687=0x0,_0x181f0c=_0x32596d[_0x18c9('0x1b')];_0x42c687<_0x181f0c;_0x42c687+=0x1){_0x32596d[_0x42c687]['on']=_0x58dfbc;}this['sync']();};RuleEngine['prototype']['prioritize']=function(_0x1696f0,_0x8f9566){_0x1696f0=parseInt(_0x1696f0,0xa);var _0x5e5111=this[_0x18c9('0x1f')](_0x8f9566);for(var _0x2c24ef=0x0,_0x74e6de=_0x5e5111[_0x18c9('0x1b')];_0x2c24ef<_0x74e6de;_0x2c24ef+=0x1){_0x5e5111[_0x2c24ef][_0x18c9('0x21')]=_0x1696f0;}this[_0x18c9('0xe')]();};RuleEngine[_0x18c9('0x7')]['toJSON']=function(){var _0x4957ee=this['rules'];if(_0x4957ee instanceof Array){_0x4957ee=_0x4957ee[_0x18c9('0x22')](function(_0x583985){_0x583985[_0x18c9('0x23')]=_0x583985[_0x18c9('0x23')][_0x18c9('0x24')]();_0x583985['consequence']=_0x583985[_0x18c9('0x14')][_0x18c9('0x24')]();return _0x583985;});}else if(!_[_0x18c9('0x4')](_0x4957ee)){_0x4957ee[_0x18c9('0x23')]=_0x4957ee[_0x18c9('0x23')][_0x18c9('0x24')]();_0x4957ee[_0x18c9('0x14')]=_0x4957ee['consequence']['toString']();}return _0x4957ee;};RuleEngine[_0x18c9('0x7')]['fromJSON']=function(_0x14a43c){this[_0x18c9('0x3')]();if(_['isString'](_0x14a43c)){_0x14a43c=JSON['parse'](_0x14a43c);}if(_0x14a43c instanceof Array){_0x14a43c=_0x14a43c[_0x18c9('0x22')](function(_0x1fafae){_0x1fafae[_0x18c9('0x23')]=eval('('+_0x1fafae[_0x18c9('0x23')]+')');_0x1fafae[_0x18c9('0x14')]=eval('('+_0x1fafae[_0x18c9('0x14')]+')');return _0x1fafae;});}else if(_0x14a43c!==null&&typeof _0x14a43c==_0x18c9('0x25')){_0x14a43c[_0x18c9('0x23')]=eval('('+_0x14a43c[_0x18c9('0x23')]+')');_0x14a43c['consequence']=eval('('+_0x14a43c[_0x18c9('0x14')]+')');}this['register'](_0x14a43c);};module['exports']=RuleEngine;
\ No newline at end of file
+var _0xaf21=['isNil','orderBy','asc','result','clone','name','index_','nextTick','ruleRef','call','next','length','condition','matchPath','noop','findRules','matches','turn','prioritize','priority','toJSON','map','consequence','toString','fromJSON','isString','object','exports','util','events','init','register','ignoreFactChanges','inherits','rules','prototype','isArray','concat','isObject','push','sync','activeRules','filter'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xaf21,0x19f));var _0x1af2=function(_0x32df39,_0x277df7){_0x32df39=_0x32df39-0x0;var _0x1aa36f=_0xaf21[_0x32df39];return _0x1aa36f;};'use strict';var _=require('lodash');var util=require(_0x1af2('0x0'));var EventEmitter=require(_0x1af2('0x1'))['EventEmitter'];function RuleEngine(_0x4a8eea,_0x57ad5c){this[_0x1af2('0x2')]();if(!_['isNil'](_0x4a8eea)){this[_0x1af2('0x3')](_0x4a8eea);}if(_0x57ad5c){this[_0x1af2('0x4')]=_0x57ad5c['ignoreFactChanges'];}return this;}util[_0x1af2('0x5')](RuleEngine,EventEmitter);RuleEngine['prototype'][_0x1af2('0x2')]=function(_0x151a7c){this[_0x1af2('0x6')]=[];this['activeRules']=[];};RuleEngine[_0x1af2('0x7')][_0x1af2('0x3')]=function(_0xbac158){if(Array[_0x1af2('0x8')](_0xbac158)){this[_0x1af2('0x6')]=this[_0x1af2('0x6')][_0x1af2('0x9')](_0xbac158);}else if(_0xbac158!==null&&_[_0x1af2('0xa')](_0xbac158)){this[_0x1af2('0x6')][_0x1af2('0xb')](_0xbac158);}this[_0x1af2('0xc')]();};RuleEngine[_0x1af2('0x7')][_0x1af2('0xc')]=function(){this[_0x1af2('0xd')]=this[_0x1af2('0x6')][_0x1af2('0xe')](function(_0x1a0de2){if(_[_0x1af2('0xf')](_0x1a0de2['on'])){_0x1a0de2['on']=!![];}if(_0x1a0de2['on']===!![]){return _0x1a0de2;}});this[_0x1af2('0xd')]=_[_0x1af2('0x10')](this[_0x1af2('0xd')],['p'],[_0x1af2('0x11')]);};RuleEngine['prototype']['execute']=function(_0xba69de,_0x5207eb){var _0x46e84f=![];_0xba69de[_0x1af2('0x12')]=!![];var _0xd2e204=_['clone'](_0xba69de);var _0x23a25f=_[_0x1af2('0x13')](_0xba69de);var _0x2623d5=this[_0x1af2('0xd')];var _0x12ce62=[];var _0x5b5071=this[_0x1af2('0x4')];(function FnRuleLoop(_0x10f9ea){var _0x166366={'rules':function(){return _0x2623d5;},'rule':function(){return _0x2623d5[_0x10f9ea];},'when':function(_0x59059f){if(_0x59059f){var _0x2a890c=_0x2623d5[_0x10f9ea]['consequence'];_0x2a890c['ruleRef']=_0x2623d5[_0x10f9ea]['id']||_0x2623d5[_0x10f9ea][_0x1af2('0x14')]||_0x1af2('0x15')+_0x10f9ea;process[_0x1af2('0x16')](function(){_0x12ce62[_0x1af2('0xb')](_0x2a890c[_0x1af2('0x17')]);_0x2a890c[_0x1af2('0x18')](_0xd2e204,_0x166366);});}else{process['nextTick'](function(){_0x166366[_0x1af2('0x19')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x46e84f=!![];return FnRuleLoop(0x0);},'next':function(_0x502fd2){if(!_0x5b5071&&!_['isEqual'](_0x23a25f,_0xd2e204)){_0x23a25f=_['clone'](_0xd2e204);process[_0x1af2('0x16')](function(){_0x166366['restart']();});}else{process[_0x1af2('0x16')](function(){if(_[_0x1af2('0xf')](_0x502fd2)){return FnRuleLoop(_0x10f9ea+0x1);}else{return FnRuleLoop(_0x502fd2);}});}}};if(_0x10f9ea<_0x2623d5[_0x1af2('0x1a')]&&_0x46e84f===![]){var _0x497581=_0x2623d5[_0x10f9ea][_0x1af2('0x1b')];_0x497581[_0x1af2('0x18')](_0xd2e204,_0x166366);}else{process[_0x1af2('0x16')](function(){_0xd2e204[_0x1af2('0x1c')]=_0x12ce62;return _0x5207eb?_0x5207eb(_0xd2e204):_[_0x1af2('0x1d')]();});}}(0x0));};RuleEngine[_0x1af2('0x7')][_0x1af2('0x1e')]=function(_0x1569dc){if(_[_0x1af2('0xf')](_0x1569dc)){return this[_0x1af2('0x6')];}else{var _0x357eec=_[_0x1af2('0x1f')](_0x1569dc);return _[_0x1af2('0xe')](this[_0x1af2('0x6')],_0x357eec);}};RuleEngine['prototype'][_0x1af2('0x20')]=function(_0x381ae2,_0x430eae){var _0x4cb585=_0x381ae2==='on'||_0x381ae2==='ON'?!![]:![];var _0x29e7df=this[_0x1af2('0x1e')](_0x430eae);for(var _0x212607=0x0,_0x46ab1e=_0x29e7df[_0x1af2('0x1a')];_0x212607<_0x46ab1e;_0x212607+=0x1){_0x29e7df[_0x212607]['on']=_0x4cb585;}this[_0x1af2('0xc')]();};RuleEngine['prototype'][_0x1af2('0x21')]=function(_0x211500,_0x505c4d){_0x211500=parseInt(_0x211500,0xa);var _0x2a81c5=this[_0x1af2('0x1e')](_0x505c4d);for(var _0x1309f1=0x0,_0x461215=_0x2a81c5['length'];_0x1309f1<_0x461215;_0x1309f1+=0x1){_0x2a81c5[_0x1309f1][_0x1af2('0x22')]=_0x211500;}this[_0x1af2('0xc')]();};RuleEngine[_0x1af2('0x7')][_0x1af2('0x23')]=function(){var _0xc155a9=this[_0x1af2('0x6')];if(_0xc155a9 instanceof Array){_0xc155a9=_0xc155a9[_0x1af2('0x24')](function(_0x10ced6){_0x10ced6[_0x1af2('0x1b')]=_0x10ced6['condition']['toString']();_0x10ced6[_0x1af2('0x25')]=_0x10ced6[_0x1af2('0x25')][_0x1af2('0x26')]();return _0x10ced6;});}else if(!_[_0x1af2('0xf')](_0xc155a9)){_0xc155a9['condition']=_0xc155a9[_0x1af2('0x1b')][_0x1af2('0x26')]();_0xc155a9[_0x1af2('0x25')]=_0xc155a9['consequence'][_0x1af2('0x26')]();}return _0xc155a9;};RuleEngine[_0x1af2('0x7')][_0x1af2('0x27')]=function(_0x3a2d63){this['init']();if(_[_0x1af2('0x28')](_0x3a2d63)){_0x3a2d63=JSON['parse'](_0x3a2d63);}if(_0x3a2d63 instanceof Array){_0x3a2d63=_0x3a2d63['map'](function(_0x3cbc07){_0x3cbc07[_0x1af2('0x1b')]=eval('('+_0x3cbc07[_0x1af2('0x1b')]+')');_0x3cbc07[_0x1af2('0x25')]=eval('('+_0x3cbc07[_0x1af2('0x25')]+')');return _0x3cbc07;});}else if(_0x3a2d63!==null&&typeof _0x3a2d63==_0x1af2('0x29')){_0x3a2d63[_0x1af2('0x1b')]=eval('('+_0x3a2d63[_0x1af2('0x1b')]+')');_0x3a2d63[_0x1af2('0x25')]=eval('('+_0x3a2d63[_0x1af2('0x25')]+')');}this[_0x1af2('0x3')](_0x3a2d63);};module[_0x1af2('0x2a')]=RuleEngine;
\ No newline at end of file