f58a5ab795a9f33b23d4c2a55a7ae12835ec6e17
[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 _0x578c=['getsecretdigits','edges','numberOfEdges','prototype','addVertex','vertices','addEdge','push','size','relations','info','no\x20vertex\x20found','stop\x20traverse','length','condition','agicommand','target','traverseBFS','vswitch','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','lodash','../../../config/logger','agi','menu','getdigits'];(function(_0x2d8434,_0x43d781){var _0x26b9e4=function(_0x54f5b8){while(--_0x54f5b8){_0x2d8434['push'](_0x2d8434['shift']());}};_0x26b9e4(++_0x43d781);}(_0x578c,0x1e8));var _0xc578=function(_0x815034,_0x79e13b){_0x815034=_0x815034-0x0;var _0x1b8035=_0x578c[_0x815034];return _0x1b8035;};'use strict';var _=require(_0xc578('0x0'));var logger=require(_0xc578('0x1'))(_0xc578('0x2'));var verticesWithRetry=[_0xc578('0x3'),_0xc578('0x4'),_0xc578('0x5')];var Graph=function(){this['vertices']={};this[_0xc578('0x6')]={};this[_0xc578('0x7')]=0x0;};Graph[_0xc578('0x8')][_0xc578('0x9')]=function(_0x22f522){this[_0xc578('0xa')][_0x22f522['id']]=_0x22f522;this['edges'][_0x22f522['id']]=[];};Graph[_0xc578('0x8')][_0xc578('0xb')]=function(_0x308eb2,_0xe8792a,_0x5b667c){this[_0xc578('0x6')][_0x308eb2][_0xc578('0xc')]({'target':_0xe8792a,'condition':_0x5b667c});this[_0xc578('0x7')]+=0x1;};Graph[_0xc578('0x8')][_0xc578('0xd')]=function(){return _[_0xc578('0xd')](this[_0xc578('0xa')]);};Graph['prototype'][_0xc578('0xe')]=function(){return this[_0xc578('0x7')];};Graph['prototype']['getVertex']=function(_0x456151){return this['vertices'][_0x456151];};Graph[_0xc578('0x8')]['traverseBFS']=function(_0x5d3caf,_0x272d81){if(!this[_0xc578('0xa')][_0x5d3caf]){return logger[_0xc578('0xf')](_0xc578('0x10'));}var _0x35c556=_0x272d81(this[_0xc578('0xa')][_0x5d3caf]);if(!_0x35c556){return logger['info'](_0xc578('0x11'));}if(this[_0xc578('0x6')][_0x5d3caf][_0xc578('0x12')]===0x0){return logger[_0xc578('0xf')]('no\x20edge/s\x20available');}for(var _0x55d58d=0x0,_0x50fc84=[],_0x688791=![];_0x55d58d<this[_0xc578('0x6')][_0x5d3caf][_0xc578('0x12')];_0x55d58d+=0x1){if(this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x13')]){_0x50fc84=this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x13')]['split'](',');for(var _0x32c234=0x0;_0x32c234<_0x50fc84[_0xc578('0x12')];_0x32c234+=0x1){if(this[_0xc578('0xa')][_0x5d3caf][_0xc578('0x14')]==='vswitch'&&_0x50fc84[_0x32c234]==='-'){_0x688791=this[_0xc578('0x6')][_0x5d3caf][_0x55d58d]['target'];logger[_0xc578('0xf')]('default',_0x50fc84[_0x32c234],this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x15')]);}else if(this[_0xc578('0xa')][_0x5d3caf][_0xc578('0x14')]==='menu'&&_0x50fc84[_0x32c234]==='i'){_0x688791=this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x15')];logger[_0xc578('0xf')]('invalid',_0x50fc84[_0x32c234],this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x15')]);}if(_0x50fc84[_0x32c234]===_0x35c556){return this['traverseBFS'](this[_0xc578('0x6')][_0x5d3caf][_0x55d58d][_0xc578('0x15')],_0x272d81);}}}else{return this[_0xc578('0x16')](this[_0xc578('0x6')][_0x5d3caf][_0x55d58d]['target'],_0x272d81);}}if(_0x50fc84[_0xc578('0x12')]){if(this[_0xc578('0xa')][_0x5d3caf][_0xc578('0x14')]===_0xc578('0x17')){if(_0x688791){return this[_0xc578('0x16')](_0x688791,_0x272d81);}return logger[_0xc578('0xf')](_0xc578('0x18'));}else if(_[_0xc578('0x19')](verticesWithRetry,this['vertices'][_0x5d3caf][_0xc578('0x14')])){if(_0x35c556==='-'){return logger[_0xc578('0xf')](_0xc578('0x1a'));}if(_0x688791&&_0x35c556!=='t'){return this[_0xc578('0x16')](_0x688791,_0x272d81);}return this[_0xc578('0x16')](_0x5d3caf,_0x272d81);}return logger['info'](_0xc578('0x1b'));}};module[_0xc578('0x1c')]=Graph;