657fc693c9fae9e46a129c10c72b07fd6dea5d76
[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 _0x236c=['default','invalid','condition\x20not\x20found','lodash','agi','menu','getdigits','getsecretdigits','vertices','numberOfEdges','prototype','addVertex','edges','addEdge','push','size','traverseBFS','info','no\x20vertex\x20found','length','no\x20edge/s\x20available','condition','split','agicommand','vswitch','target'];(function(_0x2ea1d1,_0x1b6edf){var _0x42f315=function(_0x2f3ad0){while(--_0x2f3ad0){_0x2ea1d1['push'](_0x2ea1d1['shift']());}};_0x42f315(++_0x1b6edf);}(_0x236c,0x155));var _0xc236=function(_0x42121c,_0x249213){_0x42121c=_0x42121c-0x0;var _0x3ed706=_0x236c[_0x42121c];return _0x3ed706;};'use strict';var _=require(_0xc236('0x0'));var logger=require('../../../config/logger')(_0xc236('0x1'));var verticesWithRetry=[_0xc236('0x2'),_0xc236('0x3'),_0xc236('0x4')];var Graph=function(){this[_0xc236('0x5')]={};this['edges']={};this[_0xc236('0x6')]=0x0;};Graph[_0xc236('0x7')][_0xc236('0x8')]=function(_0xd582f6){this[_0xc236('0x5')][_0xd582f6['id']]=_0xd582f6;this[_0xc236('0x9')][_0xd582f6['id']]=[];};Graph['prototype'][_0xc236('0xa')]=function(_0x4d349b,_0x51a13b,_0x5bc6a2){this['edges'][_0x4d349b][_0xc236('0xb')]({'target':_0x51a13b,'condition':_0x5bc6a2});this['numberOfEdges']+=0x1;};Graph[_0xc236('0x7')][_0xc236('0xc')]=function(){return _[_0xc236('0xc')](this[_0xc236('0x5')]);};Graph[_0xc236('0x7')]['relations']=function(){return this[_0xc236('0x6')];};Graph[_0xc236('0x7')]['getVertex']=function(_0xcfe854){return this[_0xc236('0x5')][_0xcfe854];};Graph['prototype'][_0xc236('0xd')]=function(_0x5bce83,_0x599d36){if(!this[_0xc236('0x5')][_0x5bce83]){return logger[_0xc236('0xe')](_0xc236('0xf'));}var _0x71bce2=_0x599d36(this['vertices'][_0x5bce83]);if(!_0x71bce2){return logger[_0xc236('0xe')]('stop\x20traverse');}if(this['edges'][_0x5bce83][_0xc236('0x10')]===0x0){return logger[_0xc236('0xe')](_0xc236('0x11'));}for(var _0x1aeafc=0x0,_0x267913=[],_0x5ac3ed=![];_0x1aeafc<this['edges'][_0x5bce83]['length'];_0x1aeafc+=0x1){if(this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x12')]){_0x267913=this[_0xc236('0x9')][_0x5bce83][_0x1aeafc]['condition'][_0xc236('0x13')](',');for(var _0x506974=0x0;_0x506974<_0x267913['length'];_0x506974+=0x1){if(this[_0xc236('0x5')][_0x5bce83][_0xc236('0x14')]===_0xc236('0x15')&&_0x267913[_0x506974]==='-'){_0x5ac3ed=this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x16')];logger[_0xc236('0xe')](_0xc236('0x17'),_0x267913[_0x506974],this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x16')]);}else if(this[_0xc236('0x5')][_0x5bce83][_0xc236('0x14')]==='menu'&&_0x267913[_0x506974]==='i'){_0x5ac3ed=this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x16')];logger[_0xc236('0xe')](_0xc236('0x18'),_0x267913[_0x506974],this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x16')]);}if(_0x267913[_0x506974]===_0x71bce2){return this[_0xc236('0xd')](this[_0xc236('0x9')][_0x5bce83][_0x1aeafc][_0xc236('0x16')],_0x599d36);}}}else{return this[_0xc236('0xd')](this[_0xc236('0x9')][_0x5bce83][_0x1aeafc]['target'],_0x599d36);}}if(_0x267913[_0xc236('0x10')]){if(this[_0xc236('0x5')][_0x5bce83][_0xc236('0x14')]===_0xc236('0x15')){if(_0x5ac3ed){return this['traverseBFS'](_0x5ac3ed,_0x599d36);}return logger[_0xc236('0xe')]('default\x20on\x20switch\x20not\x20found');}else if(_['includes'](verticesWithRetry,this[_0xc236('0x5')][_0x5bce83]['agicommand'])){if(_0x71bce2==='-'){return logger[_0xc236('0xe')]('max\x20retry\x20reach');}if(_0x5ac3ed&&_0x71bce2!=='t'){return this[_0xc236('0xd')](_0x5ac3ed,_0x599d36);}return this['traverseBFS'](_0x5bce83,_0x599d36);}return logger[_0xc236('0xe')](_0xc236('0x19'));}};module['exports']=Graph;