6527c6e3af8c64818468dff8723ed795c11f56b6
[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 _0xe9a9=['size','relations','getVertex','traverseBFS','info','no\x20vertex\x20found','stop\x20traverse','length','condition','split','agicommand','vswitch','target','menu','invalid','includes','condition\x20not\x20found','lodash','../../../config/logger','agi','getsecretdigits','edges','numberOfEdges','prototype','addVertex','vertices','addEdge'];(function(_0x43d0dd,_0x1bd3d2){var _0x233879=function(_0x4461ef){while(--_0x4461ef){_0x43d0dd['push'](_0x43d0dd['shift']());}};_0x233879(++_0x1bd3d2);}(_0xe9a9,0xce));var _0x9e9a=function(_0x368677,_0x598fb7){_0x368677=_0x368677-0x0;var _0x195bf7=_0xe9a9[_0x368677];return _0x195bf7;};'use strict';var _=require(_0x9e9a('0x0'));var logger=require(_0x9e9a('0x1'))(_0x9e9a('0x2'));var verticesWithRetry=['menu','getdigits',_0x9e9a('0x3')];var Graph=function(){this['vertices']={};this[_0x9e9a('0x4')]={};this[_0x9e9a('0x5')]=0x0;};Graph[_0x9e9a('0x6')][_0x9e9a('0x7')]=function(_0x23c58b){this[_0x9e9a('0x8')][_0x23c58b['id']]=_0x23c58b;this[_0x9e9a('0x4')][_0x23c58b['id']]=[];};Graph['prototype'][_0x9e9a('0x9')]=function(_0x224f3e,_0x4af396,_0x188d28){this[_0x9e9a('0x4')][_0x224f3e]['push']({'target':_0x4af396,'condition':_0x188d28});this[_0x9e9a('0x5')]+=0x1;};Graph[_0x9e9a('0x6')][_0x9e9a('0xa')]=function(){return _[_0x9e9a('0xa')](this[_0x9e9a('0x8')]);};Graph[_0x9e9a('0x6')][_0x9e9a('0xb')]=function(){return this[_0x9e9a('0x5')];};Graph[_0x9e9a('0x6')][_0x9e9a('0xc')]=function(_0x2d8680){return this['vertices'][_0x2d8680];};Graph[_0x9e9a('0x6')][_0x9e9a('0xd')]=function(_0x514295,_0xee9897){if(!this[_0x9e9a('0x8')][_0x514295]){return logger[_0x9e9a('0xe')](_0x9e9a('0xf'));}var _0x163d91=_0xee9897(this[_0x9e9a('0x8')][_0x514295]);if(!_0x163d91){return logger['info'](_0x9e9a('0x10'));}if(this[_0x9e9a('0x4')][_0x514295][_0x9e9a('0x11')]===0x0){return logger[_0x9e9a('0xe')]('no\x20edge/s\x20available');}for(var _0x41c667=0x0,_0x10b44b=[],_0x45190a=![];_0x41c667<this[_0x9e9a('0x4')][_0x514295][_0x9e9a('0x11')];_0x41c667+=0x1){if(this[_0x9e9a('0x4')][_0x514295][_0x41c667]['condition']){_0x10b44b=this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x12')][_0x9e9a('0x13')](',');for(var _0x27ab91=0x0;_0x27ab91<_0x10b44b[_0x9e9a('0x11')];_0x27ab91+=0x1){if(this[_0x9e9a('0x8')][_0x514295][_0x9e9a('0x14')]===_0x9e9a('0x15')&&_0x10b44b[_0x27ab91]==='-'){_0x45190a=this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x16')];logger[_0x9e9a('0xe')]('default',_0x10b44b[_0x27ab91],this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x16')]);}else if(this[_0x9e9a('0x8')][_0x514295][_0x9e9a('0x14')]===_0x9e9a('0x17')&&_0x10b44b[_0x27ab91]==='i'){_0x45190a=this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x16')];logger[_0x9e9a('0xe')](_0x9e9a('0x18'),_0x10b44b[_0x27ab91],this[_0x9e9a('0x4')][_0x514295][_0x41c667]['target']);}if(_0x10b44b[_0x27ab91]===_0x163d91){return this[_0x9e9a('0xd')](this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x16')],_0xee9897);}}}else{return this[_0x9e9a('0xd')](this[_0x9e9a('0x4')][_0x514295][_0x41c667][_0x9e9a('0x16')],_0xee9897);}}if(_0x10b44b[_0x9e9a('0x11')]){if(this[_0x9e9a('0x8')][_0x514295][_0x9e9a('0x14')]===_0x9e9a('0x15')){if(_0x45190a){return this[_0x9e9a('0xd')](_0x45190a,_0xee9897);}return logger[_0x9e9a('0xe')]('default\x20on\x20switch\x20not\x20found');}else if(_[_0x9e9a('0x19')](verticesWithRetry,this[_0x9e9a('0x8')][_0x514295][_0x9e9a('0x14')])){if(_0x163d91==='-'){return logger['info']('max\x20retry\x20reach');}if(_0x45190a&&_0x163d91!=='t'){return this[_0x9e9a('0xd')](_0x45190a,_0xee9897);}return this['traverseBFS'](_0x514295,_0xee9897);}return logger[_0x9e9a('0xe')](_0x9e9a('0x1a'));}};module['exports']=Graph;