5291090d00b970d8c4b2291c6a3e5815d07a90ec
[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 _0xa374=['menu','getdigits','prototype','edges','numberOfEdges','size','vertices','relations','traverseBFS','info','no\x20vertex\x20found','stop\x20traverse','length','no\x20edge/s\x20available','condition','agicommand','vswitch','target','invalid','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','../../../config/logger'];(function(_0x292f93,_0x2c6e8e){var _0x5a94b1=function(_0x25735e){while(--_0x25735e){_0x292f93['push'](_0x292f93['shift']());}};_0x5a94b1(++_0x2c6e8e);}(_0xa374,0xe0));var _0x4a37=function(_0x20da38,_0xbeb760){_0x20da38=_0x20da38-0x0;var _0x2b50c3=_0xa374[_0x20da38];return _0x2b50c3;};'use strict';var _=require('lodash');var logger=require(_0x4a37('0x0'))('agi');var verticesWithRetry=[_0x4a37('0x1'),_0x4a37('0x2'),'getsecretdigits'];var Graph=function(){this['vertices']={};this['edges']={};this['numberOfEdges']=0x0;};Graph[_0x4a37('0x3')]['addVertex']=function(_0x136bea){this['vertices'][_0x136bea['id']]=_0x136bea;this[_0x4a37('0x4')][_0x136bea['id']]=[];};Graph['prototype']['addEdge']=function(_0x106475,_0x5cd357,_0x1dc828){this[_0x4a37('0x4')][_0x106475]['push']({'target':_0x5cd357,'condition':_0x1dc828});this[_0x4a37('0x5')]+=0x1;};Graph['prototype']['size']=function(){return _[_0x4a37('0x6')](this[_0x4a37('0x7')]);};Graph['prototype'][_0x4a37('0x8')]=function(){return this[_0x4a37('0x5')];};Graph['prototype']['getVertex']=function(_0xe4cbdf){return this[_0x4a37('0x7')][_0xe4cbdf];};Graph[_0x4a37('0x3')][_0x4a37('0x9')]=function(_0x3ff88d,_0x240b53){if(!this[_0x4a37('0x7')][_0x3ff88d]){return logger[_0x4a37('0xa')](_0x4a37('0xb'));}var _0x405e48=_0x240b53(this[_0x4a37('0x7')][_0x3ff88d]);if(!_0x405e48){return logger[_0x4a37('0xa')](_0x4a37('0xc'));}if(this[_0x4a37('0x4')][_0x3ff88d][_0x4a37('0xd')]===0x0){return logger[_0x4a37('0xa')](_0x4a37('0xe'));}for(var _0x234685=0x0,_0x5c7608=[],_0x91d0a4=![];_0x234685<this[_0x4a37('0x4')][_0x3ff88d][_0x4a37('0xd')];_0x234685+=0x1){if(this['edges'][_0x3ff88d][_0x234685]['condition']){_0x5c7608=this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0xf')]['split'](',');for(var _0x5a08f3=0x0;_0x5a08f3<_0x5c7608[_0x4a37('0xd')];_0x5a08f3+=0x1){if(this[_0x4a37('0x7')][_0x3ff88d][_0x4a37('0x10')]===_0x4a37('0x11')&&_0x5c7608[_0x5a08f3]==='-'){_0x91d0a4=this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0x12')];logger[_0x4a37('0xa')]('default',_0x5c7608[_0x5a08f3],this['edges'][_0x3ff88d][_0x234685][_0x4a37('0x12')]);}else if(this[_0x4a37('0x7')][_0x3ff88d]['agicommand']===_0x4a37('0x1')&&_0x5c7608[_0x5a08f3]==='i'){_0x91d0a4=this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0x12')];logger[_0x4a37('0xa')](_0x4a37('0x13'),_0x5c7608[_0x5a08f3],this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0x12')]);}if(_0x5c7608[_0x5a08f3]===_0x405e48){return this[_0x4a37('0x9')](this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0x12')],_0x240b53);}}}else{return this['traverseBFS'](this[_0x4a37('0x4')][_0x3ff88d][_0x234685][_0x4a37('0x12')],_0x240b53);}}if(_0x5c7608[_0x4a37('0xd')]){if(this['vertices'][_0x3ff88d][_0x4a37('0x10')]==='vswitch'){if(_0x91d0a4){return this[_0x4a37('0x9')](_0x91d0a4,_0x240b53);}return logger[_0x4a37('0xa')](_0x4a37('0x14'));}else if(_[_0x4a37('0x15')](verticesWithRetry,this[_0x4a37('0x7')][_0x3ff88d][_0x4a37('0x10')])){if(_0x405e48==='-'){return logger[_0x4a37('0xa')](_0x4a37('0x16'));}if(_0x91d0a4&&_0x405e48!=='t'){return this['traverseBFS'](_0x91d0a4,_0x240b53);}return this[_0x4a37('0x9')](_0x3ff88d,_0x240b53);}return logger['info'](_0x4a37('0x17'));}};module[_0x4a37('0x18')]=Graph;