6a9f986c59f2f8fa0e58da3af4af2bc06502f762
[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 _0x24cf=['target','invalid','default\x20on\x20switch\x20not\x20found','max\x20retry\x20reach','exports','agi','menu','getdigits','getsecretdigits','vertices','numberOfEdges','prototype','addVertex','addEdge','edges','push','size','relations','getVertex','traverseBFS','no\x20vertex\x20found','info','stop\x20traverse','length','condition','split','agicommand','vswitch','default'];(function(_0x149033,_0x4fbd54){var _0x1fb5c7=function(_0x7dc3f5){while(--_0x7dc3f5){_0x149033['push'](_0x149033['shift']());}};_0x1fb5c7(++_0x4fbd54);}(_0x24cf,0x1d5));var _0xf24c=function(_0x114e29,_0x16b323){_0x114e29=_0x114e29-0x0;var _0x12d649=_0x24cf[_0x114e29];return _0x12d649;};'use strict';var _=require('lodash');var logger=require('../../../config/logger')(_0xf24c('0x0'));var verticesWithRetry=[_0xf24c('0x1'),_0xf24c('0x2'),_0xf24c('0x3')];var Graph=function(){this[_0xf24c('0x4')]={};this['edges']={};this[_0xf24c('0x5')]=0x0;};Graph[_0xf24c('0x6')][_0xf24c('0x7')]=function(_0x10c351){this['vertices'][_0x10c351['id']]=_0x10c351;this['edges'][_0x10c351['id']]=[];};Graph['prototype'][_0xf24c('0x8')]=function(_0x596e81,_0x3b7cf1,_0x13163e){this[_0xf24c('0x9')][_0x596e81][_0xf24c('0xa')]({'target':_0x3b7cf1,'condition':_0x13163e});this['numberOfEdges']+=0x1;};Graph[_0xf24c('0x6')][_0xf24c('0xb')]=function(){return _[_0xf24c('0xb')](this[_0xf24c('0x4')]);};Graph[_0xf24c('0x6')][_0xf24c('0xc')]=function(){return this['numberOfEdges'];};Graph[_0xf24c('0x6')][_0xf24c('0xd')]=function(_0x233ee8){return this['vertices'][_0x233ee8];};Graph[_0xf24c('0x6')][_0xf24c('0xe')]=function(_0x57edfa,_0x5a0bbf){if(!this[_0xf24c('0x4')][_0x57edfa]){return logger['info'](_0xf24c('0xf'));}var _0x2fd9a8=_0x5a0bbf(this['vertices'][_0x57edfa]);if(!_0x2fd9a8){return logger[_0xf24c('0x10')](_0xf24c('0x11'));}if(this[_0xf24c('0x9')][_0x57edfa][_0xf24c('0x12')]===0x0){return logger[_0xf24c('0x10')]('no\x20edge/s\x20available');}for(var _0x5c46a5=0x0,_0x32787d=[],_0x462801=![];_0x5c46a5<this['edges'][_0x57edfa][_0xf24c('0x12')];_0x5c46a5+=0x1){if(this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5][_0xf24c('0x13')]){_0x32787d=this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5][_0xf24c('0x13')][_0xf24c('0x14')](',');for(var _0x36ceba=0x0;_0x36ceba<_0x32787d[_0xf24c('0x12')];_0x36ceba+=0x1){if(this[_0xf24c('0x4')][_0x57edfa][_0xf24c('0x15')]===_0xf24c('0x16')&&_0x32787d[_0x36ceba]==='-'){_0x462801=this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5]['target'];logger[_0xf24c('0x10')](_0xf24c('0x17'),_0x32787d[_0x36ceba],this['edges'][_0x57edfa][_0x5c46a5][_0xf24c('0x18')]);}else if(this[_0xf24c('0x4')][_0x57edfa][_0xf24c('0x15')]==='menu'&&_0x32787d[_0x36ceba]==='i'){_0x462801=this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5]['target'];logger[_0xf24c('0x10')](_0xf24c('0x19'),_0x32787d[_0x36ceba],this['edges'][_0x57edfa][_0x5c46a5][_0xf24c('0x18')]);}if(_0x32787d[_0x36ceba]===_0x2fd9a8){return this[_0xf24c('0xe')](this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5][_0xf24c('0x18')],_0x5a0bbf);}}}else{return this[_0xf24c('0xe')](this[_0xf24c('0x9')][_0x57edfa][_0x5c46a5][_0xf24c('0x18')],_0x5a0bbf);}}if(_0x32787d[_0xf24c('0x12')]){if(this[_0xf24c('0x4')][_0x57edfa][_0xf24c('0x15')]===_0xf24c('0x16')){if(_0x462801){return this['traverseBFS'](_0x462801,_0x5a0bbf);}return logger['info'](_0xf24c('0x1a'));}else if(_['includes'](verticesWithRetry,this['vertices'][_0x57edfa][_0xf24c('0x15')])){if(_0x2fd9a8==='-'){return logger['info'](_0xf24c('0x1b'));}if(_0x462801&&_0x2fd9a8!=='t'){return this[_0xf24c('0xe')](_0x462801,_0x5a0bbf);}return this['traverseBFS'](_0x57edfa,_0x5a0bbf);}return logger['info']('condition\x20not\x20found');}};module[_0xf24c('0x1c')]=Graph;