586367f87be76604fb44f77a6da7b19e1943ac78
[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 _0x705f=['no\x20vertex\x20found','info','length','no\x20edge/s\x20available','condition','agicommand','target','menu','invalid','vswitch','includes','max\x20retry\x20reach','condition\x20not\x20found','agi','getdigits','getsecretdigits','vertices','edges','numberOfEdges','prototype','addVertex','push','size','relations','getVertex','traverseBFS'];(function(_0x215723,_0xf52617){var _0x5878ca=function(_0x242cd1){while(--_0x242cd1){_0x215723['push'](_0x215723['shift']());}};_0x5878ca(++_0xf52617);}(_0x705f,0x75));var _0xf705=function(_0x3a8b7c,_0x3e5db2){_0x3a8b7c=_0x3a8b7c-0x0;var _0x40eb80=_0x705f[_0x3a8b7c];return _0x40eb80;};'use strict';var _=require('lodash');var logger=require('../../../config/logger')(_0xf705('0x0'));var verticesWithRetry=['menu',_0xf705('0x1'),_0xf705('0x2')];var Graph=function(){this[_0xf705('0x3')]={};this[_0xf705('0x4')]={};this[_0xf705('0x5')]=0x0;};Graph[_0xf705('0x6')][_0xf705('0x7')]=function(_0x240742){this[_0xf705('0x3')][_0x240742['id']]=_0x240742;this[_0xf705('0x4')][_0x240742['id']]=[];};Graph[_0xf705('0x6')]['addEdge']=function(_0x51fda8,_0xc244e3,_0x58cae9){this[_0xf705('0x4')][_0x51fda8][_0xf705('0x8')]({'target':_0xc244e3,'condition':_0x58cae9});this['numberOfEdges']+=0x1;};Graph['prototype'][_0xf705('0x9')]=function(){return _[_0xf705('0x9')](this[_0xf705('0x3')]);};Graph[_0xf705('0x6')][_0xf705('0xa')]=function(){return this[_0xf705('0x5')];};Graph[_0xf705('0x6')][_0xf705('0xb')]=function(_0x4a92bb){return this[_0xf705('0x3')][_0x4a92bb];};Graph[_0xf705('0x6')][_0xf705('0xc')]=function(_0xf625da,_0x31e6f5){if(!this['vertices'][_0xf625da]){return logger['info'](_0xf705('0xd'));}var _0x10763f=_0x31e6f5(this[_0xf705('0x3')][_0xf625da]);if(!_0x10763f){return logger[_0xf705('0xe')]('stop\x20traverse');}if(this[_0xf705('0x4')][_0xf625da][_0xf705('0xf')]===0x0){return logger[_0xf705('0xe')](_0xf705('0x10'));}for(var _0x572efc=0x0,_0x11dcbc=[],_0x479b31=![];_0x572efc<this[_0xf705('0x4')][_0xf625da][_0xf705('0xf')];_0x572efc+=0x1){if(this['edges'][_0xf625da][_0x572efc][_0xf705('0x11')]){_0x11dcbc=this['edges'][_0xf625da][_0x572efc][_0xf705('0x11')]['split'](',');for(var _0x57d537=0x0;_0x57d537<_0x11dcbc[_0xf705('0xf')];_0x57d537+=0x1){if(this[_0xf705('0x3')][_0xf625da][_0xf705('0x12')]==='vswitch'&&_0x11dcbc[_0x57d537]==='-'){_0x479b31=this[_0xf705('0x4')][_0xf625da][_0x572efc][_0xf705('0x13')];logger[_0xf705('0xe')]('default',_0x11dcbc[_0x57d537],this[_0xf705('0x4')][_0xf625da][_0x572efc]['target']);}else if(this['vertices'][_0xf625da][_0xf705('0x12')]===_0xf705('0x14')&&_0x11dcbc[_0x57d537]==='i'){_0x479b31=this[_0xf705('0x4')][_0xf625da][_0x572efc][_0xf705('0x13')];logger[_0xf705('0xe')](_0xf705('0x15'),_0x11dcbc[_0x57d537],this[_0xf705('0x4')][_0xf625da][_0x572efc][_0xf705('0x13')]);}if(_0x11dcbc[_0x57d537]===_0x10763f){return this[_0xf705('0xc')](this[_0xf705('0x4')][_0xf625da][_0x572efc][_0xf705('0x13')],_0x31e6f5);}}}else{return this['traverseBFS'](this[_0xf705('0x4')][_0xf625da][_0x572efc]['target'],_0x31e6f5);}}if(_0x11dcbc[_0xf705('0xf')]){if(this['vertices'][_0xf625da]['agicommand']===_0xf705('0x16')){if(_0x479b31){return this[_0xf705('0xc')](_0x479b31,_0x31e6f5);}return logger['info']('default\x20on\x20switch\x20not\x20found');}else if(_[_0xf705('0x17')](verticesWithRetry,this[_0xf705('0x3')][_0xf625da][_0xf705('0x12')])){if(_0x10763f==='-'){return logger[_0xf705('0xe')](_0xf705('0x18'));}if(_0x479b31&&_0x10763f!=='t'){return this['traverseBFS'](_0x479b31,_0x31e6f5);}return this[_0xf705('0xc')](_0xf625da,_0x31e6f5);}return logger[_0xf705('0xe')](_0xf705('0x19'));}};module['exports']=Graph;