d4a616b859fc414095dce2691af68d39dddc0a8d
[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 _0x6017=['vswitch','target','menu','invalid','includes','max\x20retry\x20reach','lodash','../../../config/logger','agi','getdigits','getsecretdigits','edges','prototype','vertices','addEdge','push','numberOfEdges','size','relations','getVertex','traverseBFS','info','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','agicommand'];(function(_0x12c076,_0x5bef17){var _0x2ddd18=function(_0x436336){while(--_0x436336){_0x12c076['push'](_0x12c076['shift']());}};_0x2ddd18(++_0x5bef17);}(_0x6017,0xae));var _0x7601=function(_0x15a916,_0x217dc7){_0x15a916=_0x15a916-0x0;var _0x5bda8b=_0x6017[_0x15a916];return _0x5bda8b;};'use strict';var _=require(_0x7601('0x0'));var logger=require(_0x7601('0x1'))(_0x7601('0x2'));var verticesWithRetry=['menu',_0x7601('0x3'),_0x7601('0x4')];var Graph=function(){this['vertices']={};this[_0x7601('0x5')]={};this['numberOfEdges']=0x0;};Graph[_0x7601('0x6')]['addVertex']=function(_0x5080a3){this[_0x7601('0x7')][_0x5080a3['id']]=_0x5080a3;this[_0x7601('0x5')][_0x5080a3['id']]=[];};Graph[_0x7601('0x6')][_0x7601('0x8')]=function(_0x2bc643,_0xe6e524,_0x4ff3e4){this[_0x7601('0x5')][_0x2bc643][_0x7601('0x9')]({'target':_0xe6e524,'condition':_0x4ff3e4});this[_0x7601('0xa')]+=0x1;};Graph['prototype'][_0x7601('0xb')]=function(){return _[_0x7601('0xb')](this[_0x7601('0x7')]);};Graph['prototype'][_0x7601('0xc')]=function(){return this[_0x7601('0xa')];};Graph[_0x7601('0x6')][_0x7601('0xd')]=function(_0x33658f){return this[_0x7601('0x7')][_0x33658f];};Graph[_0x7601('0x6')][_0x7601('0xe')]=function(_0x2f5dbf,_0x40fc89){if(!this['vertices'][_0x2f5dbf]){return logger[_0x7601('0xf')]('no\x20vertex\x20found');}var _0x4be36a=_0x40fc89(this[_0x7601('0x7')][_0x2f5dbf]);if(!_0x4be36a){return logger[_0x7601('0xf')](_0x7601('0x10'));}if(this[_0x7601('0x5')][_0x2f5dbf][_0x7601('0x11')]===0x0){return logger[_0x7601('0xf')](_0x7601('0x12'));}for(var _0xdfb58a=0x0,_0x5e99b9=[],_0xa0e556=![];_0xdfb58a<this[_0x7601('0x5')][_0x2f5dbf]['length'];_0xdfb58a+=0x1){if(this[_0x7601('0x5')][_0x2f5dbf][_0xdfb58a]['condition']){_0x5e99b9=this['edges'][_0x2f5dbf][_0xdfb58a][_0x7601('0x13')][_0x7601('0x14')](',');for(var _0x3c1b4b=0x0;_0x3c1b4b<_0x5e99b9[_0x7601('0x11')];_0x3c1b4b+=0x1){if(this[_0x7601('0x7')][_0x2f5dbf][_0x7601('0x15')]===_0x7601('0x16')&&_0x5e99b9[_0x3c1b4b]==='-'){_0xa0e556=this['edges'][_0x2f5dbf][_0xdfb58a][_0x7601('0x17')];logger[_0x7601('0xf')]('default',_0x5e99b9[_0x3c1b4b],this[_0x7601('0x5')][_0x2f5dbf][_0xdfb58a][_0x7601('0x17')]);}else if(this[_0x7601('0x7')][_0x2f5dbf][_0x7601('0x15')]===_0x7601('0x18')&&_0x5e99b9[_0x3c1b4b]==='i'){_0xa0e556=this[_0x7601('0x5')][_0x2f5dbf][_0xdfb58a]['target'];logger[_0x7601('0xf')](_0x7601('0x19'),_0x5e99b9[_0x3c1b4b],this[_0x7601('0x5')][_0x2f5dbf][_0xdfb58a][_0x7601('0x17')]);}if(_0x5e99b9[_0x3c1b4b]===_0x4be36a){return this['traverseBFS'](this[_0x7601('0x5')][_0x2f5dbf][_0xdfb58a]['target'],_0x40fc89);}}}else{return this[_0x7601('0xe')](this['edges'][_0x2f5dbf][_0xdfb58a]['target'],_0x40fc89);}}if(_0x5e99b9[_0x7601('0x11')]){if(this[_0x7601('0x7')][_0x2f5dbf]['agicommand']==='vswitch'){if(_0xa0e556){return this[_0x7601('0xe')](_0xa0e556,_0x40fc89);}return logger['info']('default\x20on\x20switch\x20not\x20found');}else if(_[_0x7601('0x1a')](verticesWithRetry,this[_0x7601('0x7')][_0x2f5dbf][_0x7601('0x15')])){if(_0x4be36a==='-'){return logger['info'](_0x7601('0x1b'));}if(_0xa0e556&&_0x4be36a!=='t'){return this['traverseBFS'](_0xa0e556,_0x40fc89);}return this[_0x7601('0xe')](_0x2f5dbf,_0x40fc89);}return logger[_0x7601('0xf')]('condition\x20not\x20found');}};module['exports']=Graph;