d31e7f42ef3958ba770aa2d5983a37c25595ce31
[motion-next.git] / server / components / parsers / advancedSearch.js
1 const a835_0x46fe=['=\x20?','[$and]','conditions','shift','filter','replace','add','\x20IS\x20NULL)','$endsWith','buildExpression','$in','BETWEEN\x20?\x20AND\x20?','castTo','CAST(','match','utcOffset','$lt','<=\x20?','LIKE\x20?','split','$substring','$gte','[$or]','>=\x20?','$ne','YYYY-MM-DD','\x20OR\x20','start','forEach','seconds','text','$gt','parseSearch','operator','<\x20?','NOT\x20IN\x20?','$startsWith','sqlOperator','lodash','startsWith','$notIn','$eq','field','length','days','value','map','\x20AS\x20','moment','$between','format','$lte','includes'];(function(_0x45a53c,_0x46fe2a){const _0x50d84d=function(_0x14503f){while(--_0x14503f){_0x45a53c['push'](_0x45a53c['shift']());}};_0x50d84d(++_0x46fe2a);}(a835_0x46fe,0x1b5));const a835_0x50d8=function(_0x45a53c,_0x46fe2a){_0x45a53c=_0x45a53c-0x0;let _0x50d84d=a835_0x46fe[_0x45a53c];return _0x50d84d;};const _0x42a714=a835_0x50d8;'use strict';const _=require(_0x42a714('0x19')),moment=require(_0x42a714('0x23'));exports[_0x42a714('0x13')]=function(_0x14503f){const _0x24ae77=_0x42a714,_0x16166a={'conditions':[]};_0x16166a[_0x24ae77('0x18')]=_[_0x24ae77('0x1a')](_0x14503f,_0x24ae77('0x9'))?'or':'and';const _0x1e218d=_0x14503f[_0x24ae77('0x2d')](_0x24ae77('0x29'),'')[_0x24ae77('0x2d')](_0x24ae77('0x9'),'')['split']('||');for(let _0x2fb69e=0x0;_0x2fb69e<_0x1e218d[_0x24ae77('0x1e')];_0x2fb69e++){const _0xc63e16=_0x1e218d[_0x2fb69e][_0x24ae77('0x6')](':='),_0x1f58bb=_0xc63e16[0x0],_0x1f1471=_0xc63e16['slice'](0x1);_0x1f1471[_0x24ae77('0xf')](function(_0x2f8e86){const _0x254b14=_0x24ae77,_0x3b90a9=_0x2f8e86[_0x254b14('0x6')]('[')[_0x254b14('0x2b')](),_0x590740=_0x2f8e86[_0x254b14('0x1')](/\[(.*?)\]/g);_0x590740[_0x254b14('0xf')](function(_0x43f628){const _0x12db70=_0x254b14,_0x333f1a=_0x43f628['split']('[')[_0x12db70('0x2c')](function(_0x49e2a4){return _0x49e2a4['indexOf'](']')>-0x1;})[_0x12db70('0x21')](function(_0x265b9e){const _0x2ac2b2=_0x12db70;return _0x265b9e[_0x2ac2b2('0x6')](']')[0x0];})[0x0];_0x16166a[_0x12db70('0x2a')]['push']({'field':_0x1f58bb,'operator':_0x3b90a9,'value':_0x333f1a});});});}return _0x16166a;},exports[_0x42a714('0x31')]=function(_0x5171db,_0x354abf,_0x361f53){const _0x200718=_0x42a714,_0x483bf0={};if(_0x354abf==='DATE'){if(_0x361f53[_0x200718('0x14')]==='$eq')_0x361f53[_0x200718('0x14')]=_0x200718('0x24'),_0x361f53['value']+=','+_0x361f53[_0x200718('0x20')];else _[_0x200718('0x27')]([_0x200718('0x12'),_0x200718('0x26')],_0x361f53[_0x200718('0x14')])&&(_0x361f53[_0x200718('0x20')]=moment(_0x361f53[_0x200718('0x20')])[_0x200718('0x2e')](0x1,_0x200718('0x1f'))[_0x200718('0x25')](_0x200718('0xc')));}_0x361f53[_0x200718('0x34')]?(_0x354abf=_0x361f53['castTo'],_0x483bf0[_0x200718('0x11')]=_0x200718('0x0')+_0x5171db+'.'+_0x361f53['field']+_0x200718('0x22')+_0x361f53[_0x200718('0x34')]+')\x20'+parseOperator(_0x361f53['operator'])):_0x483bf0[_0x200718('0x11')]=_0x5171db+'.'+_0x361f53[_0x200718('0x1d')]+'\x20'+parseOperator(_0x361f53['operator']);if(_[_0x200718('0x27')]([_0x200718('0xb'),'$notIn'],_0x361f53[_0x200718('0x14')]))_0x483bf0[_0x200718('0x11')]='('+_0x483bf0['text']+_0x200718('0xd')+_0x5171db+'.'+_0x361f53[_0x200718('0x1d')]+_0x200718('0x2f');return _0x483bf0[_0x200718('0x20')]=parseValue(_0x354abf,_0x361f53[_0x200718('0x14')],_0x361f53[_0x200718('0x20')]),_0x483bf0;};function parseOperator(_0x819bfa){const _0xd7a7f2=_0x42a714;let _0x5a2a4a;switch(_0x819bfa){case _0xd7a7f2('0x32'):_0x5a2a4a='IN\x20?';break;case _0xd7a7f2('0x1b'):_0x5a2a4a=_0xd7a7f2('0x16');break;case _0xd7a7f2('0x1c'):_0x5a2a4a=_0xd7a7f2('0x28');break;case _0xd7a7f2('0xb'):_0x5a2a4a='<>\x20?';break;case _0xd7a7f2('0x7'):case _0xd7a7f2('0x17'):case _0xd7a7f2('0x30'):_0x5a2a4a=_0xd7a7f2('0x5');break;case _0xd7a7f2('0x3'):_0x5a2a4a=_0xd7a7f2('0x15');break;case'$gt':_0x5a2a4a='>\x20?';break;case _0xd7a7f2('0x26'):_0x5a2a4a=_0xd7a7f2('0x4');break;case _0xd7a7f2('0x8'):_0x5a2a4a=_0xd7a7f2('0xa');break;case'$between':_0x5a2a4a=_0xd7a7f2('0x33');break;}return _0x5a2a4a;}function parseValue(_0x22b466,_0xcf68bc,_0x5c214f){const _0x47c7db=_0x42a714;let _0x3bf516={'start':undefined,'end':undefined};switch(_0xcf68bc){case _0x47c7db('0x32'):case _0x47c7db('0x1b'):_0x3bf516['start']=_0x5c214f[_0x47c7db('0x6')](',');break;case'$substring':_0x3bf516[_0x47c7db('0xe')]='%'+_0x5c214f+'%';break;case _0x47c7db('0x17'):_0x3bf516[_0x47c7db('0xe')]=_0x5c214f+'%';break;case _0x47c7db('0x30'):_0x3bf516[_0x47c7db('0xe')]='%'+_0x5c214f;break;case _0x47c7db('0x24'):{const _0x28d919=_0x3d4417['split'](',');let _0x3d4417=_0x28d919[_0x47c7db('0x2b')](),_0x5227a2=_0x28d919['pop']();_0x22b466==='DATE'&&(_0x3d4417=moment(_0x3d4417)['utcOffset'](0x0,!![])['format'](),_0x5227a2=moment(_0x5227a2)[_0x47c7db('0x2')](0x0,!![])['add'](0x17,'hours')[_0x47c7db('0x2e')](0x3b,'minutes')[_0x47c7db('0x2e')](0x3b,_0x47c7db('0x10'))[_0x47c7db('0x25')]()),_0x3bf516={'start':_0x3d4417,'end':_0x5227a2};}break;default:_0x3bf516['start']=_0x5c214f;break;}return _0x3bf516;}