Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / services / agi / graph / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x23ee=['exports','../../../config/logger','agi','menu','getdigits','getsecretdigits','vertices','edges','numberOfEdges','prototype','addVertex','addEdge','push','size','relations','getVertex','traverseBFS','info','no\x20vertex\x20found','length','no\x20edge/s\x20available','condition','split','agicommand','vswitch','target','default','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach'];(function(_0xeb5a88,_0x37d8b7){var _0x591ce4=function(_0x30614a){while(--_0x30614a){_0xeb5a88['push'](_0xeb5a88['shift']());}};_0x591ce4(++_0x37d8b7);}(_0x23ee,0xf1));var _0xe23e=function(_0x467cb0,_0x303070){_0x467cb0=_0x467cb0-0x0;var _0x2153f7=_0x23ee[_0x467cb0];return _0x2153f7;};'use strict';var _=require('lodash');var logger=require(_0xe23e('0x0'))(_0xe23e('0x1'));var verticesWithRetry=[_0xe23e('0x2'),_0xe23e('0x3'),_0xe23e('0x4')];var Graph=function(){this[_0xe23e('0x5')]={};this[_0xe23e('0x6')]={};this[_0xe23e('0x7')]=0x0;};Graph[_0xe23e('0x8')][_0xe23e('0x9')]=function(_0x268d40){this[_0xe23e('0x5')][_0x268d40['id']]=_0x268d40;this[_0xe23e('0x6')][_0x268d40['id']]=[];};Graph[_0xe23e('0x8')][_0xe23e('0xa')]=function(_0x318a1d,_0xaaed01,_0x8b23d0){this[_0xe23e('0x6')][_0x318a1d][_0xe23e('0xb')]({'target':_0xaaed01,'condition':_0x8b23d0});this[_0xe23e('0x7')]+=0x1;};Graph['prototype']['size']=function(){return _[_0xe23e('0xc')](this[_0xe23e('0x5')]);};Graph[_0xe23e('0x8')][_0xe23e('0xd')]=function(){return this['numberOfEdges'];};Graph[_0xe23e('0x8')][_0xe23e('0xe')]=function(_0x4498d6){return this['vertices'][_0x4498d6];};Graph['prototype'][_0xe23e('0xf')]=function(_0x2945a4,_0xba3b60){if(!this[_0xe23e('0x5')][_0x2945a4]){return logger[_0xe23e('0x10')](_0xe23e('0x11'));}var _0x19225a=_0xba3b60(this[_0xe23e('0x5')][_0x2945a4]);if(!_0x19225a){return logger[_0xe23e('0x10')]('stop\x20traverse');}if(this[_0xe23e('0x6')][_0x2945a4][_0xe23e('0x12')]===0x0){return logger[_0xe23e('0x10')](_0xe23e('0x13'));}for(var _0xf4d85c=0x0,_0x4a11cc=[],_0x2b44c1=![];_0xf4d85c<this['edges'][_0x2945a4][_0xe23e('0x12')];_0xf4d85c+=0x1){if(this[_0xe23e('0x6')][_0x2945a4][_0xf4d85c][_0xe23e('0x14')]){_0x4a11cc=this['edges'][_0x2945a4][_0xf4d85c][_0xe23e('0x14')][_0xe23e('0x15')](',');for(var _0x52e0ed=0x0;_0x52e0ed<_0x4a11cc[_0xe23e('0x12')];_0x52e0ed+=0x1){if(this[_0xe23e('0x5')][_0x2945a4][_0xe23e('0x16')]===_0xe23e('0x17')&&_0x4a11cc[_0x52e0ed]==='-'){_0x2b44c1=this['edges'][_0x2945a4][_0xf4d85c][_0xe23e('0x18')];logger[_0xe23e('0x10')](_0xe23e('0x19'),_0x4a11cc[_0x52e0ed],this['edges'][_0x2945a4][_0xf4d85c][_0xe23e('0x18')]);}else if(this[_0xe23e('0x5')][_0x2945a4][_0xe23e('0x16')]===_0xe23e('0x2')&&_0x4a11cc[_0x52e0ed]==='i'){_0x2b44c1=this[_0xe23e('0x6')][_0x2945a4][_0xf4d85c][_0xe23e('0x18')];logger['info']('invalid',_0x4a11cc[_0x52e0ed],this[_0xe23e('0x6')][_0x2945a4][_0xf4d85c][_0xe23e('0x18')]);}if(_0x4a11cc[_0x52e0ed]===_0x19225a){return this[_0xe23e('0xf')](this[_0xe23e('0x6')][_0x2945a4][_0xf4d85c][_0xe23e('0x18')],_0xba3b60);}}}else{return this[_0xe23e('0xf')](this[_0xe23e('0x6')][_0x2945a4][_0xf4d85c]['target'],_0xba3b60);}}if(_0x4a11cc[_0xe23e('0x12')]){if(this[_0xe23e('0x5')][_0x2945a4][_0xe23e('0x16')]===_0xe23e('0x17')){if(_0x2b44c1){return this[_0xe23e('0xf')](_0x2b44c1,_0xba3b60);}return logger[_0xe23e('0x10')](_0xe23e('0x1a'));}else if(_[_0xe23e('0x1b')](verticesWithRetry,this[_0xe23e('0x5')][_0x2945a4]['agicommand'])){if(_0x19225a==='-'){return logger[_0xe23e('0x10')](_0xe23e('0x1c'));}if(_0x2b44c1&&_0x19225a!=='t'){return this[_0xe23e('0xf')](_0x2b44c1,_0xba3b60);}return this[_0xe23e('0xf')](_0x2945a4,_0xba3b60);}return logger['info']('condition\x20not\x20found');}};module[_0xe23e('0x1d')]=Graph;