Built motion from commit (unavailable).|2.5.31
[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 _0xccde=['exports','lodash','agi','getdigits','getsecretdigits','numberOfEdges','prototype','addVertex','vertices','addEdge','edges','push','relations','getVertex','traverseBFS','info','stop\x20traverse','no\x20edge/s\x20available','length','condition','split','agicommand','vswitch','target','menu','invalid','default\x20on\x20switch\x20not\x20found','includes','max\x20retry\x20reach','condition\x20not\x20found'];(function(_0x3a698f,_0x4a82fc){var _0x1b7cf3=function(_0xc8c70){while(--_0xc8c70){_0x3a698f['push'](_0x3a698f['shift']());}};_0x1b7cf3(++_0x4a82fc);}(_0xccde,0x1e1));var _0xeccd=function(_0x4ed32d,_0x327695){_0x4ed32d=_0x4ed32d-0x0;var _0xf624df=_0xccde[_0x4ed32d];return _0xf624df;};'use strict';var _=require(_0xeccd('0x0'));var logger=require('../../../config/logger')(_0xeccd('0x1'));var verticesWithRetry=['menu',_0xeccd('0x2'),_0xeccd('0x3')];var Graph=function(){this['vertices']={};this['edges']={};this[_0xeccd('0x4')]=0x0;};Graph[_0xeccd('0x5')][_0xeccd('0x6')]=function(_0x397cd0){this[_0xeccd('0x7')][_0x397cd0['id']]=_0x397cd0;this['edges'][_0x397cd0['id']]=[];};Graph[_0xeccd('0x5')][_0xeccd('0x8')]=function(_0x1b622f,_0x1eebfb,_0x4b068e){this[_0xeccd('0x9')][_0x1b622f][_0xeccd('0xa')]({'target':_0x1eebfb,'condition':_0x4b068e});this[_0xeccd('0x4')]+=0x1;};Graph[_0xeccd('0x5')]['size']=function(){return _['size'](this['vertices']);};Graph['prototype'][_0xeccd('0xb')]=function(){return this[_0xeccd('0x4')];};Graph[_0xeccd('0x5')][_0xeccd('0xc')]=function(_0x307e37){return this['vertices'][_0x307e37];};Graph[_0xeccd('0x5')][_0xeccd('0xd')]=function(_0x377cd7,_0x3bd19c){if(!this[_0xeccd('0x7')][_0x377cd7]){return logger[_0xeccd('0xe')]('no\x20vertex\x20found');}var _0x57516f=_0x3bd19c(this[_0xeccd('0x7')][_0x377cd7]);if(!_0x57516f){return logger[_0xeccd('0xe')](_0xeccd('0xf'));}if(this[_0xeccd('0x9')][_0x377cd7]['length']===0x0){return logger[_0xeccd('0xe')](_0xeccd('0x10'));}for(var _0x496061=0x0,_0x53f4d8=[],_0x42e47e=![];_0x496061<this[_0xeccd('0x9')][_0x377cd7][_0xeccd('0x11')];_0x496061+=0x1){if(this[_0xeccd('0x9')][_0x377cd7][_0x496061][_0xeccd('0x12')]){_0x53f4d8=this[_0xeccd('0x9')][_0x377cd7][_0x496061][_0xeccd('0x12')][_0xeccd('0x13')](',');for(var _0x5ba676=0x0;_0x5ba676<_0x53f4d8[_0xeccd('0x11')];_0x5ba676+=0x1){if(this[_0xeccd('0x7')][_0x377cd7][_0xeccd('0x14')]===_0xeccd('0x15')&&_0x53f4d8[_0x5ba676]==='-'){_0x42e47e=this[_0xeccd('0x9')][_0x377cd7][_0x496061][_0xeccd('0x16')];logger['info']('default',_0x53f4d8[_0x5ba676],this['edges'][_0x377cd7][_0x496061][_0xeccd('0x16')]);}else if(this['vertices'][_0x377cd7][_0xeccd('0x14')]===_0xeccd('0x17')&&_0x53f4d8[_0x5ba676]==='i'){_0x42e47e=this['edges'][_0x377cd7][_0x496061][_0xeccd('0x16')];logger['info'](_0xeccd('0x18'),_0x53f4d8[_0x5ba676],this[_0xeccd('0x9')][_0x377cd7][_0x496061][_0xeccd('0x16')]);}if(_0x53f4d8[_0x5ba676]===_0x57516f){return this[_0xeccd('0xd')](this[_0xeccd('0x9')][_0x377cd7][_0x496061]['target'],_0x3bd19c);}}}else{return this[_0xeccd('0xd')](this['edges'][_0x377cd7][_0x496061][_0xeccd('0x16')],_0x3bd19c);}}if(_0x53f4d8[_0xeccd('0x11')]){if(this[_0xeccd('0x7')][_0x377cd7][_0xeccd('0x14')]==='vswitch'){if(_0x42e47e){return this[_0xeccd('0xd')](_0x42e47e,_0x3bd19c);}return logger[_0xeccd('0xe')](_0xeccd('0x19'));}else if(_[_0xeccd('0x1a')](verticesWithRetry,this['vertices'][_0x377cd7][_0xeccd('0x14')])){if(_0x57516f==='-'){return logger[_0xeccd('0xe')](_0xeccd('0x1b'));}if(_0x42e47e&&_0x57516f!=='t'){return this[_0xeccd('0xd')](_0x42e47e,_0x3bd19c);}return this[_0xeccd('0xd')](_0x377cd7,_0x3bd19c);}return logger[_0xeccd('0xe')](_0xeccd('0x1c'));}};module[_0xeccd('0x1d')]=Graph;