cdf340ce972e48eb9f5a07769247b5b5b8406f25
[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 _0x2bb0=['condition','split','agicommand','target','invalid','vswitch','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','lodash','../../../config/logger','agi','getdigits','edges','prototype','addVertex','vertices','addEdge','numberOfEdges','size','relations','getVertex','traverseBFS','info','stop\x20traverse','length','no\x20edge/s\x20available'];(function(_0x4de1b1,_0x18c64c){var _0x639f27=function(_0x635e03){while(--_0x635e03){_0x4de1b1['push'](_0x4de1b1['shift']());}};_0x639f27(++_0x18c64c);}(_0x2bb0,0xf3));var _0x02bb=function(_0x3b65d2,_0x46022d){_0x3b65d2=_0x3b65d2-0x0;var _0x3a3c0f=_0x2bb0[_0x3b65d2];return _0x3a3c0f;};'use strict';var _=require(_0x02bb('0x0'));var logger=require(_0x02bb('0x1'))(_0x02bb('0x2'));var verticesWithRetry=['menu',_0x02bb('0x3'),'getsecretdigits'];var Graph=function(){this['vertices']={};this[_0x02bb('0x4')]={};this['numberOfEdges']=0x0;};Graph[_0x02bb('0x5')][_0x02bb('0x6')]=function(_0x8e4057){this[_0x02bb('0x7')][_0x8e4057['id']]=_0x8e4057;this[_0x02bb('0x4')][_0x8e4057['id']]=[];};Graph[_0x02bb('0x5')][_0x02bb('0x8')]=function(_0x47d7ae,_0x6d064a,_0x15e425){this[_0x02bb('0x4')][_0x47d7ae]['push']({'target':_0x6d064a,'condition':_0x15e425});this[_0x02bb('0x9')]+=0x1;};Graph['prototype'][_0x02bb('0xa')]=function(){return _[_0x02bb('0xa')](this['vertices']);};Graph[_0x02bb('0x5')][_0x02bb('0xb')]=function(){return this[_0x02bb('0x9')];};Graph['prototype'][_0x02bb('0xc')]=function(_0x4e409d){return this[_0x02bb('0x7')][_0x4e409d];};Graph[_0x02bb('0x5')][_0x02bb('0xd')]=function(_0x5c8728,_0x16330c){if(!this[_0x02bb('0x7')][_0x5c8728]){return logger[_0x02bb('0xe')]('no\x20vertex\x20found');}var _0x2a03ac=_0x16330c(this['vertices'][_0x5c8728]);if(!_0x2a03ac){return logger[_0x02bb('0xe')](_0x02bb('0xf'));}if(this[_0x02bb('0x4')][_0x5c8728][_0x02bb('0x10')]===0x0){return logger[_0x02bb('0xe')](_0x02bb('0x11'));}for(var _0x5cf4cb=0x0,_0x50f402=[],_0x4711fb=![];_0x5cf4cb<this[_0x02bb('0x4')][_0x5c8728][_0x02bb('0x10')];_0x5cf4cb+=0x1){if(this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb][_0x02bb('0x12')]){_0x50f402=this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb]['condition'][_0x02bb('0x13')](',');for(var _0x4b3f78=0x0;_0x4b3f78<_0x50f402[_0x02bb('0x10')];_0x4b3f78+=0x1){if(this[_0x02bb('0x7')][_0x5c8728][_0x02bb('0x14')]==='vswitch'&&_0x50f402[_0x4b3f78]==='-'){_0x4711fb=this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb][_0x02bb('0x15')];logger[_0x02bb('0xe')]('default',_0x50f402[_0x4b3f78],this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb][_0x02bb('0x15')]);}else if(this['vertices'][_0x5c8728][_0x02bb('0x14')]==='menu'&&_0x50f402[_0x4b3f78]==='i'){_0x4711fb=this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb][_0x02bb('0x15')];logger[_0x02bb('0xe')](_0x02bb('0x16'),_0x50f402[_0x4b3f78],this[_0x02bb('0x4')][_0x5c8728][_0x5cf4cb][_0x02bb('0x15')]);}if(_0x50f402[_0x4b3f78]===_0x2a03ac){return this[_0x02bb('0xd')](this['edges'][_0x5c8728][_0x5cf4cb]['target'],_0x16330c);}}}else{return this[_0x02bb('0xd')](this['edges'][_0x5c8728][_0x5cf4cb][_0x02bb('0x15')],_0x16330c);}}if(_0x50f402[_0x02bb('0x10')]){if(this[_0x02bb('0x7')][_0x5c8728]['agicommand']===_0x02bb('0x17')){if(_0x4711fb){return this[_0x02bb('0xd')](_0x4711fb,_0x16330c);}return logger['info'](_0x02bb('0x18'));}else if(_[_0x02bb('0x19')](verticesWithRetry,this[_0x02bb('0x7')][_0x5c8728][_0x02bb('0x14')])){if(_0x2a03ac==='-'){return logger[_0x02bb('0xe')](_0x02bb('0x1a'));}if(_0x4711fb&&_0x2a03ac!=='t'){return this['traverseBFS'](_0x4711fb,_0x16330c);}return this[_0x02bb('0xd')](_0x5c8728,_0x16330c);}return logger['info'](_0x02bb('0x1b'));}};module[_0x02bb('0x1c')]=Graph;