Built motion from commit d5e4af8c.|2.6.23
[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 _0x923c=['push','size','relations','traverseBFS','info','no\x20vertex\x20found','length','no\x20edge/s\x20available','condition','split','vswitch','target','default','agicommand','menu','invalid','includes','max\x20retry\x20reach','condition\x20not\x20found','lodash','../../../config/logger','getsecretdigits','vertices','numberOfEdges','addVertex','edges','prototype'];(function(_0x9c8b4a,_0x2387ff){var _0x198bef=function(_0x2eb4e8){while(--_0x2eb4e8){_0x9c8b4a['push'](_0x9c8b4a['shift']());}};_0x198bef(++_0x2387ff);}(_0x923c,0x157));var _0xc923=function(_0x3fdef2,_0x5a0001){_0x3fdef2=_0x3fdef2-0x0;var _0x2e6a66=_0x923c[_0x3fdef2];return _0x2e6a66;};'use strict';var _=require(_0xc923('0x0'));var logger=require(_0xc923('0x1'))('agi');var verticesWithRetry=['menu','getdigits',_0xc923('0x2')];var Graph=function(){this[_0xc923('0x3')]={};this['edges']={};this[_0xc923('0x4')]=0x0;};Graph['prototype'][_0xc923('0x5')]=function(_0x579b7f){this[_0xc923('0x3')][_0x579b7f['id']]=_0x579b7f;this[_0xc923('0x6')][_0x579b7f['id']]=[];};Graph[_0xc923('0x7')]['addEdge']=function(_0x798775,_0x5ce7bc,_0x15965f){this[_0xc923('0x6')][_0x798775][_0xc923('0x8')]({'target':_0x5ce7bc,'condition':_0x15965f});this['numberOfEdges']+=0x1;};Graph['prototype'][_0xc923('0x9')]=function(){return _[_0xc923('0x9')](this[_0xc923('0x3')]);};Graph['prototype'][_0xc923('0xa')]=function(){return this[_0xc923('0x4')];};Graph[_0xc923('0x7')]['getVertex']=function(_0x191c32){return this[_0xc923('0x3')][_0x191c32];};Graph[_0xc923('0x7')][_0xc923('0xb')]=function(_0x36e49d,_0x174e7e){if(!this[_0xc923('0x3')][_0x36e49d]){return logger[_0xc923('0xc')](_0xc923('0xd'));}var _0x669b29=_0x174e7e(this[_0xc923('0x3')][_0x36e49d]);if(!_0x669b29){return logger[_0xc923('0xc')]('stop\x20traverse');}if(this['edges'][_0x36e49d][_0xc923('0xe')]===0x0){return logger[_0xc923('0xc')](_0xc923('0xf'));}for(var _0x4e88af=0x0,_0x366316=[],_0x4eb5ed=![];_0x4e88af<this[_0xc923('0x6')][_0x36e49d][_0xc923('0xe')];_0x4e88af+=0x1){if(this[_0xc923('0x6')][_0x36e49d][_0x4e88af][_0xc923('0x10')]){_0x366316=this['edges'][_0x36e49d][_0x4e88af][_0xc923('0x10')][_0xc923('0x11')](',');for(var _0x203860=0x0;_0x203860<_0x366316[_0xc923('0xe')];_0x203860+=0x1){if(this[_0xc923('0x3')][_0x36e49d]['agicommand']===_0xc923('0x12')&&_0x366316[_0x203860]==='-'){_0x4eb5ed=this['edges'][_0x36e49d][_0x4e88af][_0xc923('0x13')];logger[_0xc923('0xc')](_0xc923('0x14'),_0x366316[_0x203860],this[_0xc923('0x6')][_0x36e49d][_0x4e88af][_0xc923('0x13')]);}else if(this[_0xc923('0x3')][_0x36e49d][_0xc923('0x15')]===_0xc923('0x16')&&_0x366316[_0x203860]==='i'){_0x4eb5ed=this[_0xc923('0x6')][_0x36e49d][_0x4e88af][_0xc923('0x13')];logger[_0xc923('0xc')](_0xc923('0x17'),_0x366316[_0x203860],this[_0xc923('0x6')][_0x36e49d][_0x4e88af][_0xc923('0x13')]);}if(_0x366316[_0x203860]===_0x669b29){return this['traverseBFS'](this['edges'][_0x36e49d][_0x4e88af]['target'],_0x174e7e);}}}else{return this[_0xc923('0xb')](this['edges'][_0x36e49d][_0x4e88af][_0xc923('0x13')],_0x174e7e);}}if(_0x366316['length']){if(this[_0xc923('0x3')][_0x36e49d][_0xc923('0x15')]===_0xc923('0x12')){if(_0x4eb5ed){return this['traverseBFS'](_0x4eb5ed,_0x174e7e);}return logger['info']('default\x20on\x20switch\x20not\x20found');}else if(_[_0xc923('0x18')](verticesWithRetry,this[_0xc923('0x3')][_0x36e49d][_0xc923('0x15')])){if(_0x669b29==='-'){return logger[_0xc923('0xc')](_0xc923('0x19'));}if(_0x4eb5ed&&_0x669b29!=='t'){return this[_0xc923('0xb')](_0x4eb5ed,_0x174e7e);}return this[_0xc923('0xb')](_0x36e49d,_0x174e7e);}return logger[_0xc923('0xc')](_0xc923('0x1a'));}};module['exports']=Graph;