Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / services / routing / lib / rule-engine.js
index 03a0daf..8da12bd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2f39=['clone','consequence','name','index_','nextTick','push','call','next','matchPath','noop','findRules','matches','turn','length','prioritize','priority','toJSON','map','condition','toString','fromJSON','isString','lodash','util','EventEmitter','register','ignoreFactChanges','inherits','prototype','init','rules','isArray','concat','isObject','sync','activeRules','filter','isNil','orderBy','asc','execute','result'];(function(_0x5af2a7,_0x1955b4){var _0x24f340=function(_0x536e24){while(--_0x536e24){_0x5af2a7['push'](_0x5af2a7['shift']());}};_0x24f340(++_0x1955b4);}(_0x2f39,0xbe));var _0x92f3=function(_0x47623f,_0x148f3a){_0x47623f=_0x47623f-0x0;var _0x282ce8=_0x2f39[_0x47623f];return _0x282ce8;};'use strict';var _=require(_0x92f3('0x0'));var util=require(_0x92f3('0x1'));var EventEmitter=require('events')[_0x92f3('0x2')];function RuleEngine(_0xaf7fe5,_0xfe973a){this['init']();if(!_['isNil'](_0xaf7fe5)){this[_0x92f3('0x3')](_0xaf7fe5);}if(_0xfe973a){this[_0x92f3('0x4')]=_0xfe973a[_0x92f3('0x4')];}return this;}util[_0x92f3('0x5')](RuleEngine,EventEmitter);RuleEngine[_0x92f3('0x6')][_0x92f3('0x7')]=function(_0xdd9d50){this[_0x92f3('0x8')]=[];this['activeRules']=[];};RuleEngine[_0x92f3('0x6')]['register']=function(_0x263549){if(Array[_0x92f3('0x9')](_0x263549)){this[_0x92f3('0x8')]=this[_0x92f3('0x8')][_0x92f3('0xa')](_0x263549);}else if(_0x263549!==null&&_[_0x92f3('0xb')](_0x263549)){this['rules']['push'](_0x263549);}this['sync']();};RuleEngine['prototype'][_0x92f3('0xc')]=function(){this[_0x92f3('0xd')]=this[_0x92f3('0x8')][_0x92f3('0xe')](function(_0x319eb5){if(_[_0x92f3('0xf')](_0x319eb5['on'])){_0x319eb5['on']=!![];}if(_0x319eb5['on']===!![]){return _0x319eb5;}});this[_0x92f3('0xd')]=_[_0x92f3('0x10')](this[_0x92f3('0xd')],['p'],[_0x92f3('0x11')]);};RuleEngine[_0x92f3('0x6')][_0x92f3('0x12')]=function(_0x1a0350,_0x2fdb3d){var _0x11d293=![];_0x1a0350[_0x92f3('0x13')]=!![];var _0x2c927e=_[_0x92f3('0x14')](_0x1a0350);var _0x3b23a2=_[_0x92f3('0x14')](_0x1a0350);var _0x306f5b=this['activeRules'];var _0x5152cf=[];var _0x574dbb=this[_0x92f3('0x4')];(function FnRuleLoop(_0x2053a9){var _0x3dd070={'rules':function(){return _0x306f5b;},'rule':function(){return _0x306f5b[_0x2053a9];},'when':function(_0x268bb9){if(_0x268bb9){var _0x32ae42=_0x306f5b[_0x2053a9][_0x92f3('0x15')];_0x32ae42['ruleRef']=_0x306f5b[_0x2053a9]['id']||_0x306f5b[_0x2053a9][_0x92f3('0x16')]||_0x92f3('0x17')+_0x2053a9;process[_0x92f3('0x18')](function(){_0x5152cf[_0x92f3('0x19')](_0x32ae42['ruleRef']);_0x32ae42[_0x92f3('0x1a')](_0x2c927e,_0x3dd070);});}else{process['nextTick'](function(){_0x3dd070[_0x92f3('0x1b')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x11d293=!![];return FnRuleLoop(0x0);},'next':function(_0x3eb557){if(!_0x574dbb&&!_['isEqual'](_0x3b23a2,_0x2c927e)){_0x3b23a2=_[_0x92f3('0x14')](_0x2c927e);process[_0x92f3('0x18')](function(){_0x3dd070['restart']();});}else{process[_0x92f3('0x18')](function(){if(_[_0x92f3('0xf')](_0x3eb557)){return FnRuleLoop(_0x2053a9+0x1);}else{return FnRuleLoop(_0x3eb557);}});}}};if(_0x2053a9<_0x306f5b['length']&&_0x11d293===![]){var _0x1bc7d9=_0x306f5b[_0x2053a9]['condition'];_0x1bc7d9[_0x92f3('0x1a')](_0x2c927e,_0x3dd070);}else{process[_0x92f3('0x18')](function(){_0x2c927e[_0x92f3('0x1c')]=_0x5152cf;return _0x2fdb3d?_0x2fdb3d(_0x2c927e):_[_0x92f3('0x1d')]();});}}(0x0));};RuleEngine[_0x92f3('0x6')][_0x92f3('0x1e')]=function(_0x579601){if(_[_0x92f3('0xf')](_0x579601)){return this[_0x92f3('0x8')];}else{var _0x12eb06=_[_0x92f3('0x1f')](_0x579601);return _[_0x92f3('0xe')](this[_0x92f3('0x8')],_0x12eb06);}};RuleEngine[_0x92f3('0x6')][_0x92f3('0x20')]=function(_0x39094,_0x5c8b1b){var _0x39094=_0x39094==='on'||_0x39094==='ON'?!![]:![];var _0xba5146=this[_0x92f3('0x1e')](_0x5c8b1b);for(var _0x5df6d9=0x0,_0x1b1735=_0xba5146[_0x92f3('0x21')];_0x5df6d9<_0x1b1735;_0x5df6d9+=0x1){_0xba5146[_0x5df6d9]['on']=_0x39094;}this[_0x92f3('0xc')]();};RuleEngine[_0x92f3('0x6')][_0x92f3('0x22')]=function(_0x1e2abd,_0x39b883){_0x1e2abd=parseInt(_0x1e2abd,0xa);var _0xc4ceae=this['findRules'](_0x39b883);for(var _0x39c0b6=0x0,_0x583aa3=_0xc4ceae[_0x92f3('0x21')];_0x39c0b6<_0x583aa3;_0x39c0b6+=0x1){_0xc4ceae[_0x39c0b6][_0x92f3('0x23')]=_0x1e2abd;}this[_0x92f3('0xc')]();};RuleEngine['prototype'][_0x92f3('0x24')]=function(){var _0x287966=this[_0x92f3('0x8')];if(_0x287966 instanceof Array){_0x287966=_0x287966[_0x92f3('0x25')](function(_0x25054f){_0x25054f[_0x92f3('0x26')]=_0x25054f[_0x92f3('0x26')][_0x92f3('0x27')]();_0x25054f[_0x92f3('0x15')]=_0x25054f[_0x92f3('0x15')][_0x92f3('0x27')]();return _0x25054f;});}else if(!_['isNil'](_0x287966)){_0x287966[_0x92f3('0x26')]=_0x287966[_0x92f3('0x26')][_0x92f3('0x27')]();_0x287966[_0x92f3('0x15')]=_0x287966[_0x92f3('0x15')][_0x92f3('0x27')]();}return _0x287966;};RuleEngine[_0x92f3('0x6')][_0x92f3('0x28')]=function(_0x495789){this[_0x92f3('0x7')]();if(_[_0x92f3('0x29')](_0x495789)){_0x495789=JSON['parse'](_0x495789);}if(_0x495789 instanceof Array){_0x495789=_0x495789[_0x92f3('0x25')](function(_0x4783c1){_0x4783c1[_0x92f3('0x26')]=eval('('+_0x4783c1[_0x92f3('0x26')]+')');_0x4783c1[_0x92f3('0x15')]=eval('('+_0x4783c1[_0x92f3('0x15')]+')');return _0x4783c1;});}else if(_0x495789!==null&&typeof _0x495789=='object'){_0x495789[_0x92f3('0x26')]=eval('('+_0x495789[_0x92f3('0x26')]+')');_0x495789[_0x92f3('0x15')]=eval('('+_0x495789['consequence']+')');}this[_0x92f3('0x3')](_0x495789);};module['exports']=RuleEngine;
\ No newline at end of file
+var _0x7793=['prototype','rules','isArray','concat','isObject','push','sync','activeRules','orderBy','asc','execute','result','clone','consequence','ruleRef','name','index_','nextTick','next','isEqual','restart','condition','call','noop','findRules','matches','filter','turn','length','prioritize','priority','toJSON','map','toString','fromJSON','isString','parse','exports','util','EventEmitter','init','isNil','register','ignoreFactChanges','inherits'];(function(_0x325501,_0x5242f6){var _0x2c1626=function(_0x4270b2){while(--_0x4270b2){_0x325501['push'](_0x325501['shift']());}};_0x2c1626(++_0x5242f6);}(_0x7793,0xad));var _0x3779=function(_0x26cdca,_0x3ee4a4){_0x26cdca=_0x26cdca-0x0;var _0x2e633f=_0x7793[_0x26cdca];return _0x2e633f;};'use strict';var _=require('lodash');var util=require(_0x3779('0x0'));var EventEmitter=require('events')[_0x3779('0x1')];function RuleEngine(_0x5ced5f,_0x172c44){this[_0x3779('0x2')]();if(!_[_0x3779('0x3')](_0x5ced5f)){this[_0x3779('0x4')](_0x5ced5f);}if(_0x172c44){this[_0x3779('0x5')]=_0x172c44[_0x3779('0x5')];}return this;}util[_0x3779('0x6')](RuleEngine,EventEmitter);RuleEngine[_0x3779('0x7')][_0x3779('0x2')]=function(_0x50e3bb){this[_0x3779('0x8')]=[];this['activeRules']=[];};RuleEngine[_0x3779('0x7')][_0x3779('0x4')]=function(_0x8661b1){if(Array[_0x3779('0x9')](_0x8661b1)){this[_0x3779('0x8')]=this[_0x3779('0x8')][_0x3779('0xa')](_0x8661b1);}else if(_0x8661b1!==null&&_[_0x3779('0xb')](_0x8661b1)){this[_0x3779('0x8')][_0x3779('0xc')](_0x8661b1);}this[_0x3779('0xd')]();};RuleEngine[_0x3779('0x7')][_0x3779('0xd')]=function(){this[_0x3779('0xe')]=this['rules']['filter'](function(_0xf63e8){if(_[_0x3779('0x3')](_0xf63e8['on'])){_0xf63e8['on']=!![];}if(_0xf63e8['on']===!![]){return _0xf63e8;}});this[_0x3779('0xe')]=_[_0x3779('0xf')](this[_0x3779('0xe')],['p'],[_0x3779('0x10')]);};RuleEngine['prototype'][_0x3779('0x11')]=function(_0x10459c,_0x19b130){var _0x28fa34=![];_0x10459c[_0x3779('0x12')]=!![];var _0xf19e62=_[_0x3779('0x13')](_0x10459c);var _0x36bfc3=_[_0x3779('0x13')](_0x10459c);var _0x11ac14=this[_0x3779('0xe')];var _0x35f2e6=[];var _0x957cb1=this['ignoreFactChanges'];(function FnRuleLoop(_0x5a3e83){var _0x38094c={'rules':function(){return _0x11ac14;},'rule':function(){return _0x11ac14[_0x5a3e83];},'when':function(_0x503264){if(_0x503264){var _0xa7aeff=_0x11ac14[_0x5a3e83][_0x3779('0x14')];_0xa7aeff[_0x3779('0x15')]=_0x11ac14[_0x5a3e83]['id']||_0x11ac14[_0x5a3e83][_0x3779('0x16')]||_0x3779('0x17')+_0x5a3e83;process['nextTick'](function(){_0x35f2e6[_0x3779('0xc')](_0xa7aeff[_0x3779('0x15')]);_0xa7aeff['call'](_0xf19e62,_0x38094c);});}else{process[_0x3779('0x18')](function(){_0x38094c[_0x3779('0x19')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x28fa34=!![];return FnRuleLoop(0x0);},'next':function(_0x5c64bb){if(!_0x957cb1&&!_[_0x3779('0x1a')](_0x36bfc3,_0xf19e62)){_0x36bfc3=_['clone'](_0xf19e62);process[_0x3779('0x18')](function(){_0x38094c[_0x3779('0x1b')]();});}else{process[_0x3779('0x18')](function(){if(_['isNil'](_0x5c64bb)){return FnRuleLoop(_0x5a3e83+0x1);}else{return FnRuleLoop(_0x5c64bb);}});}}};if(_0x5a3e83<_0x11ac14['length']&&_0x28fa34===![]){var _0x359725=_0x11ac14[_0x5a3e83][_0x3779('0x1c')];_0x359725[_0x3779('0x1d')](_0xf19e62,_0x38094c);}else{process['nextTick'](function(){_0xf19e62['matchPath']=_0x35f2e6;return _0x19b130?_0x19b130(_0xf19e62):_[_0x3779('0x1e')]();});}}(0x0));};RuleEngine[_0x3779('0x7')][_0x3779('0x1f')]=function(_0x5b51ab){if(_[_0x3779('0x3')](_0x5b51ab)){return this[_0x3779('0x8')];}else{var _0x364153=_[_0x3779('0x20')](_0x5b51ab);return _[_0x3779('0x21')](this[_0x3779('0x8')],_0x364153);}};RuleEngine[_0x3779('0x7')][_0x3779('0x22')]=function(_0x14fe5c,_0x289da8){var _0x14fe5c=_0x14fe5c==='on'||_0x14fe5c==='ON'?!![]:![];var _0x543ea9=this['findRules'](_0x289da8);for(var _0x17c2b7=0x0,_0xa8df54=_0x543ea9[_0x3779('0x23')];_0x17c2b7<_0xa8df54;_0x17c2b7+=0x1){_0x543ea9[_0x17c2b7]['on']=_0x14fe5c;}this[_0x3779('0xd')]();};RuleEngine[_0x3779('0x7')][_0x3779('0x24')]=function(_0x784023,_0x1c05a4){_0x784023=parseInt(_0x784023,0xa);var _0x4d090f=this['findRules'](_0x1c05a4);for(var _0xe58723=0x0,_0xd610a5=_0x4d090f[_0x3779('0x23')];_0xe58723<_0xd610a5;_0xe58723+=0x1){_0x4d090f[_0xe58723][_0x3779('0x25')]=_0x784023;}this['sync']();};RuleEngine[_0x3779('0x7')][_0x3779('0x26')]=function(){var _0x5de783=this[_0x3779('0x8')];if(_0x5de783 instanceof Array){_0x5de783=_0x5de783[_0x3779('0x27')](function(_0x17bf5d){_0x17bf5d[_0x3779('0x1c')]=_0x17bf5d['condition']['toString']();_0x17bf5d['consequence']=_0x17bf5d['consequence'][_0x3779('0x28')]();return _0x17bf5d;});}else if(!_[_0x3779('0x3')](_0x5de783)){_0x5de783['condition']=_0x5de783['condition'][_0x3779('0x28')]();_0x5de783['consequence']=_0x5de783[_0x3779('0x14')]['toString']();}return _0x5de783;};RuleEngine[_0x3779('0x7')][_0x3779('0x29')]=function(_0x729dc4){this[_0x3779('0x2')]();if(_[_0x3779('0x2a')](_0x729dc4)){_0x729dc4=JSON[_0x3779('0x2b')](_0x729dc4);}if(_0x729dc4 instanceof Array){_0x729dc4=_0x729dc4[_0x3779('0x27')](function(_0x484f31){_0x484f31[_0x3779('0x1c')]=eval('('+_0x484f31[_0x3779('0x1c')]+')');_0x484f31[_0x3779('0x14')]=eval('('+_0x484f31[_0x3779('0x14')]+')');return _0x484f31;});}else if(_0x729dc4!==null&&typeof _0x729dc4=='object'){_0x729dc4[_0x3779('0x1c')]=eval('('+_0x729dc4[_0x3779('0x1c')]+')');_0x729dc4[_0x3779('0x14')]=eval('('+_0x729dc4[_0x3779('0x14')]+')');}this[_0x3779('0x4')](_0x729dc4);};module[_0x3779('0x2c')]=RuleEngine;
\ No newline at end of file