UNPKG

ultra-db.js

Version:

UltraDB - AdvancedBSON Database Managment System, High-Speed, Ultra Security, Multi Functionalty, and EasyToUse!

1 lines 45.2 kB
const a0_0x31d3de=a0_0x574e;(function(_0x25a4df,_0x16b64b){const _0x37323e=a0_0x574e,_0x44e99e=_0x25a4df();while(!![]){try{const _0x4aace1=-parseInt(_0x37323e(0x23f))/0x1*(-parseInt(_0x37323e(0x1dc))/0x2)+-parseInt(_0x37323e(0x1a8))/0x3*(parseInt(_0x37323e(0x233))/0x4)+-parseInt(_0x37323e(0x28f))/0x5+parseInt(_0x37323e(0x23a))/0x6+-parseInt(_0x37323e(0x224))/0x7*(parseInt(_0x37323e(0x281))/0x8)+parseInt(_0x37323e(0x1b3))/0x9+-parseInt(_0x37323e(0x23b))/0xa;if(_0x4aace1===_0x16b64b)break;else _0x44e99e['push'](_0x44e99e['shift']());}catch(_0x3778fa){_0x44e99e['push'](_0x44e99e['shift']());}}}(a0_0x487d,0x27cd5));const fs=require('fs'),path=require(a0_0x31d3de(0x1ba)),crypto=require('crypto'),zlib=require(a0_0x31d3de(0x287)),{Worker}=require(a0_0x31d3de(0x203)),EventEmitter=require(a0_0x31d3de(0x217)),v8=require('v8'),DEFAULT_CHUNK_SIZE=0x40*0x400,MAX_CHUNK_SIZE=0x4*0x400*0x400,WRITE_BUFFER_KEY_LIMIT=0x1f4,BATCH_FLUSH_INTERVAL=0x14,CLEAN_INTERVAL=0x1388,CLEAN_IDLE_TIME=0x7530,IDLE_FLUSH_THRESHOLD=0x1e,maxHeap=v8[a0_0x31d3de(0x22c)]()[a0_0x31d3de(0x22a)],Color={'reset':'\x1b[0m','big':a0_0x31d3de(0x1e3),'shadow':a0_0x31d3de(0x1cc),'underscore':a0_0x31d3de(0x1cf),'blink':'\x1b[5m','reverse':a0_0x31d3de(0x1f3),'hidden':a0_0x31d3de(0x26b),'fg':{'black':'\x1b[30m','red':'\x1b[31m','green':a0_0x31d3de(0x1c5),'yellow':a0_0x31d3de(0x266),'blue':'\x1b[34m','magenta':a0_0x31d3de(0x1d0),'cyan':a0_0x31d3de(0x1c8),'white':a0_0x31d3de(0x211),'gray':a0_0x31d3de(0x1f2),'crimson':'\x1b[38m','lime':a0_0x31d3de(0x1ee),'orange':'\x1b[38;5;208m'},'bg':{'black':'\x1b[40m','red':'\x1b[41m','green':a0_0x31d3de(0x228),'yellow':a0_0x31d3de(0x272),'blue':a0_0x31d3de(0x25e),'magenta':a0_0x31d3de(0x247),'cyan':'\x1b[46m','white':a0_0x31d3de(0x25c),'gray':a0_0x31d3de(0x210),'crimson':'\x1b[48m','lime':a0_0x31d3de(0x241),'orange':a0_0x31d3de(0x245)}};function getDynamicChunkSize(_0x53b8b7){const _0x5b18ed=a0_0x31d3de;try{const _0x979d29=fs[_0x5b18ed(0x290)](_0x53b8b7);let _0xc45ab6=_0x979d29[_0x5b18ed(0x219)]/0x2;if(_0xc45ab6%0x2===0x1)_0xc45ab6++;let _0x50cf88=Math[_0x5b18ed(0x261)](Math[_0x5b18ed(0x277)](_0xc45ab6,DEFAULT_CHUNK_SIZE),MAX_CHUNK_SIZE);return _0x50cf88=Math[_0x5b18ed(0x291)](_0x50cf88/0x40)*0x40,_0x50cf88;}catch(_0x271a54){return DEFAULT_CHUNK_SIZE;}}function a0_0x487d(){const _0x57b4a1=['\x1b[37m','open','delete','reject','58ffd80695bd5c8c47b62dfb29e8cb0a3ae3b1d19725bc92b8db2fb083514d8b','digest','events','ead','size','encryptData','\x20bytes)','scanForKey','decompress','recordData','stat','writeFile','pushToWriteBuffer\x20error:\x20','Failed\x20to\x20clean\x20garbage:\x20','dirname','86884xiHThF','has','getWriteBufferTotalLength','3054104fCCPHB','\x1b[42m','Failed\x20to\x20decompress\x20or\x20parse\x20data.','heap_size_limit','dbPath','getHeapStatistics','renameSync','length','buffer','customKey','Failed\x20to\x20rebuild\x20index:\x20','_db.udb','16712zItnGf','210746hUTFiM','Invalid\x20key.\x20Must\x20be\x20a\x20string\x20type.','[UltraDB\x20Error]:\x20','dbReadFd','[UltraDB]\x20Database\x20renamed\x20due\x20existing\x20NonDB\x20file,\x20new\x20name:\x20','filter','1057866NvpsYQ','2936780DsybbY','Warning:\x20No\x20DB\x20key\x20provided;\x20using\x20default\x20unsecure\x20key','2b34366c303514086c366a33171169713237370f0c0a201b1315201c16032d1b1b1b1b','sleep','1398tmWSAo','7873356hQsNRW','\x1b[102m','value','slice','writeUInt16BE','\x1b[48;5;208m','toString','\x1b[45m','writeDatabase','compressObject','history','cwd','endsWith','[UltraDB]\x20License\x20Verified\x20✅','hex','Warning:\x20DB\x20History\x20is\x20disabled\x20by\x20default,\x20which\x20means\x20cleanGarbage\x20is\x20running.\x20In\x20order\x20to\x20enable\x20it,\x20pass:\x20arg[3]\x20of\x20constructor\x20`doEnableHistory\x20=\x20true`','parse','Failed\x20to\x20rebuild\x20function\x20for\x20property\x20','[ERROR]\x20License\x20file\x20missing!\x20UltraDB\x20is\x20not\x20licensed.','join','Initialization\x20failed:\x20','base64','\x22:\x20','[ERROR]\x20Failed\x20to\x20open\x20database\x20file:\x20','currentOffset','pheriv','gunzipSync','createDeci','\x1b[47m','Failed\x20to\x20write\x20database:\x20','\x1b[44m','write','historyCleared','min','6e1f036f6b712e3863086832093112082930','rebuildIndex','shift','flush','\x1b[33m','from','resolve','writeFileSync','worker_temp.js','\x1b[8m','warn','pending','readUInt16BE','.udb','flushWriteBuffer','trim','\x1b[43m','utf8','get','taskId','createHash','max','Compression\x20failed:\x20','aes-256-cb','readRecords','writeBuffer','exit','terminate','recordOffset','Failed\x20to\x20retrieve\x20values:\x20','cache','40vwhwfD','[UltraDB]:\x20Initialization\x20started\x20for\x20database\x20\x22','GiElw','writeUInt32BE','\x22\x20not\x20found.','emit','zlib','[UltraDB]:\x20Successfully\x20PreLoaded\x20Database\x20\x22','workers','object','sort','log','Key\x20\x22','inited','146865DAKjsp','statSync','ceil','getAuthTag','lastFlushTime','catch','promises','Failed\x20to\x20read\x20record\x20at\x20offset\x20','Encryption\x20failed:\x20','entries','57ujvzmA','byteLength','sha256','concat','string','query','readUInt32BE','decryptData','readRecordAtOffset','keys','worker_thr','2412657JfNWcL','message','historyDisabled','Failed\x20to\x20scan\x20for\x20key\x20\x22','batchFlushTimer','historyLimit','[UltraDB]:\x20Database\x20already\x20loaded,\x20no\x20need\x20to\x20reload.','path','Invalid\x20key.\x20Must\x20be\x20a\x20non-empty\x20string.','isFlushing','Idle\x20flush\x20failed:\x20','Failed\x20to\x20delete\x20key\x20\x22','decompressObject','load','disableHistory','logError','rnFdu','bytesRead','\x1b[32m','postMessage','getPercentOfMaxHeapInUse','\x1b[36m','[UltraDB]\x20Removed\x20largest\x20cache\x20item:\x20','\x0a\x20\x20\x20\x20\x20\x20const\x20{\x20parentPort,\x20workerData\x20}\x20=\x20require(\x27worker_threads\x27);\x0a\x20\x20\x20\x20\x20\x20const\x20crypto\x20=\x20require(\x27crypto\x27);\x0a\x20\x20\x20\x20\x20\x20const\x20zlib\x20=\x20require(\x27zlib\x27);\x0a\x20\x20\x20\x20\x20\x20const\x20key\x20=\x20Buffer.from(workerData.key,\x20\x27hex\x27);\x0a\x20\x20\x20\x20\x20\x20parentPort.on(\x27message\x27,\x20(msg)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20{\x20task,\x20payload,\x20id\x20}\x20=\x20msg;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20try\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if(task\x20===\x20\x27compress\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20buf\x20=\x20Buffer.from(payload,\x20\x27utf8\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20compressed\x20=\x20zlib.deflateSync(buf);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20parentPort.postMessage({\x20id,\x20result:\x20compressed\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20if(task\x20===\x20\x27decompress\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20decompressed\x20=\x20zlib.inflateSync(Buffer.from(payload));\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20parentPort.postMessage({\x20id,\x20result:\x20decompressed.toString(\x27utf8\x27)\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20if(task\x20===\x20\x27encrypt\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20nonce\x20=\x20crypto.randomBytes(12);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20cipher\x20=\x20crypto.createCipheriv(\x27chacha20-poly1305\x27,\x20key,\x20nonce,\x20{\x20authTagLength:\x2016\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20ciphertext\x20=\x20Buffer.concat([cipher.update(Buffer.from(payload)),\x20cipher.final()]);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20authTag\x20=\x20cipher.getAuthTag();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20result\x20=\x20Buffer.concat([nonce,\x20authTag,\x20ciphertext]);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20parentPort.postMessage({\x20id,\x20result\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20if(task\x20===\x20\x27decrypt\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20inputBuffer\x20=\x20Buffer.from(payload);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20nonce\x20=\x20inputBuffer.slice(0,\x2012);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20authTag\x20=\x20inputBuffer.slice(12,\x2028);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20ciphertext\x20=\x20inputBuffer.slice(28);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20decipher\x20=\x20crypto.createDecipheriv(\x27chacha20-poly1305\x27,\x20key,\x20nonce,\x20{\x20authTagLength:\x2016\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20decipher.setAuthTag(authTag);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20decrypted\x20=\x20Buffer.concat([decipher.update(ciphertext),\x20decipher.final()]);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20parentPort.postMessage({\x20id,\x20result:\x20decrypted\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20throw\x20new\x20Error(\x27Unknown\x20task\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20catch\x20(e)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20parentPort.postMessage({\x20id,\x20error:\x20e.message\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20','Invalid\x20key.\x20Expected\x20a\x20string\x20key,\x20received\x20NULL.','\x1b[2m','deflateSync','callWorker','\x1b[4m','\x1b[35m','decrypt','tSkMe','copy','1268958XMacdn','read','Compression\x20failed','alloc','now','createReadStream','[UltraDB]:\x20Database\x20loaded\x20successfully\x20and\x20ready\x20for\x20work!','stringify','262vIwGvR','clearHistory','queryResult','Invalid\x20key.\x20Expected\x20a\x20string\x20key,\x20received\x20','update','existsSync','HCpQK','\x1b[1m','init','indexMap','126e29131b1b1b1b1b1b1b1b193d02183d081f1b170b3d19291036','close','cleanTimer','OldencryptData','final','key','values','ready','\x1b[92m','workerPool','5deNNQK','19390965YZYxcX','\x1b[90m','\x1b[7m','initPromise','function','ensureInitialized','keyBuffer','chacha20-poly1305','dbWriteFd','push','map','gUWzB','error','cacheLimit','historyEnabled','require','1085wiAFJX','readFile','worker_threads','tFYyL','15900waVCul','enableHistory','basename','set','OldcompressObject','lastActivity','randomBytes','currentWorker','pLfUu','7mcTKVR','[UltraDB]\x20Halted\x20Preloading\x20Cache\x20due\x20loaded\x20data\x20amount\x20passed\x20memory\x20limit\x20(80%)','\x1b[100m'];a0_0x487d=function(){return _0x57b4a1;};return a0_0x487d();}function _0x1969(){const _0x280d28=a0_0x31d3de,_0x4a4381=[_0x280d28(0x1f1),'610kfuLwg',_0x280d28(0x273),_0x280d28(0x234),_0x280d28(0x20d),_0x280d28(0x22e),_0x280d28(0x1f0),_0x280d28(0x25a),_0x280d28(0x267),_0x280d28(0x276),_0x280d28(0x204),'CMXfT',_0x280d28(0x227),_0x280d28(0x1ea),_0x280d28(0x24e),'IyhZb',_0x280d28(0x1ab),_0x280d28(0x205),_0x280d28(0x240),_0x280d28(0x1d4),'sha256',_0x280d28(0x216),_0x280d28(0x255),_0x280d28(0x259),_0x280d28(0x1e2),_0x280d28(0x25b),_0x280d28(0x20e),_0x280d28(0x246),_0x280d28(0x1d2),_0x280d28(0x1b2),_0x280d28(0x1d7),_0x280d28(0x1fc),_0x280d28(0x279),'230247LmUeND',_0x280d28(0x1c3),_0x280d28(0x201),_0x280d28(0x218),_0x280d28(0x283),'update'];return _0x1969=function(){return _0x4a4381;},_0x1969();}(function(_0x610a95,_0x58fd18){const _0x55267f=a0_0x31d3de,_0x5d8295=_0x3421,_0x1f12c2=_0x610a95();while(!![]){try{const _0xc270dd=parseInt(_0x5d8295(0x110))/(-0x1*0x1549+-0x5*-0x1fd+0xb59)*(parseInt(_0x5d8295(0x134))/(-0x1eb0+-0xa9c+0x294e))+parseInt(_0x5d8295(0x11d))/(-0x494*0x1+0xd*-0x1e1+0x9ac*0x3)+-parseInt(_0x5d8295(0x11b))/(-0x44e*0x2+0x1*0x99e+-0xfe)*(parseInt(_0x5d8295(0x12d))/(0x257*0x10+-0x25ca+0x5f))+parseInt(_0x5d8295(0x11c))/(-0x1*-0x9f7+-0x285+-0x76c)*(parseInt(_0x5d8295(0x124))/(-0xd8a+-0x1*-0x1a6b+-0xcda))+-parseInt(_0x5d8295(0x116))/(0x1*-0xb0b+-0x21f5+0x2c*0x106)+parseInt(_0x5d8295(0x12b))/(-0x80e*0x2+0x695+0x990)*(parseInt(_0x5d8295(0x132))/(0xb3d+-0x1e81+0x1*0x134e))+-parseInt(_0x5d8295(0x131))/(0x25f*-0x8+-0x16f+-0xa39*-0x2);if(_0xc270dd===_0x58fd18)break;else _0x1f12c2['push'](_0x1f12c2[_0x55267f(0x264)]());}catch(_0x1a9b4c){_0x1f12c2[_0x55267f(0x1fa)](_0x1f12c2[_0x55267f(0x264)]());}}}(_0x1969,0x1484f1+-0x12*-0x129b9+-0x1d0274));function _0x3421(_0x338a49,_0x44c073){const _0x3f35ba=_0x1969();return _0x3421=function(_0xae397c,_0x2f353c){_0xae397c=_0xae397c-(0x2489+-0xd*0x135+-0x279*0x8);let _0x3c9031=_0x3f35ba[_0xae397c];return _0x3c9031;},_0x3421(_0x338a49,_0x44c073);}function GC(_0x22c67b){const _0x591a1f=_0x3421,_0x8ca681={'rnFdu':_0x591a1f(0x118),'CMXfT':function(_0x208fee,_0x2ca0d7){return _0x208fee<_0x2ca0d7;},'gUWzB':_0x591a1f(0x120),'pLfUu':_0x591a1f(0x133),'tSkMe':function(_0x29a668,_0x547be6){return _0x29a668+_0x547be6;},'IyhZb':function(_0xcd6162,_0x3ecf05){return _0xcd6162*_0x3ecf05;},'GiElw':_0x591a1f(0x11e),'tFYyL':_0x591a1f(0x127)+_0x591a1f(0x12e),'HCpQK':_0x591a1f(0x12a)+'c'};let _0x478bd1=Buffer[_0x591a1f(0x112)](_0x22c67b,_0x8ca681[_0x591a1f(0x12c)]);for(let _0x422c4a=0x2024+-0x175*0x16+-0x16;_0x8ca681[_0x591a1f(0x115)](_0x422c4a,_0x478bd1[_0x591a1f(0x136)]);_0x422c4a++){_0x478bd1[_0x422c4a]^=-0x1*0x11a9+0x1*0x196b+0x13c*-0x6;}let _0x16f4c9=zlib[_0x591a1f(0x111)](Buffer[_0x591a1f(0x112)](_0x478bd1[_0x591a1f(0x125)](),_0x8ca681[_0x591a1f(0x129)]))[_0x591a1f(0x125)]();_0x478bd1=null,_0x16f4c9=Buffer[_0x591a1f(0x112)](_0x16f4c9,_0x8ca681[_0x591a1f(0x12c)])[_0x591a1f(0x125)](_0x8ca681[_0x591a1f(0x135)]);let _0x4ac291=_0x8ca681[_0x591a1f(0x126)](-0x10c6+-0x44f+0x1517,_0x8ca681[_0x591a1f(0x119)](0x319*-0xb+0x76*-0x1d+0x2*0x17bc,-0x11bf+-0x25bd+0x377e)),_0x10c3da=Buffer[_0x591a1f(0x128)](_0x4ac291,0x1e7*-0xb+-0xfb*0x1d+-0x12*-0x2be),_0xd15f27=crypto[_0x591a1f(0x113)](_0x8ca681[_0x591a1f(0x12f)])[_0x591a1f(0x130)](_0x8ca681[_0x591a1f(0x114)])[_0x591a1f(0x11f)](),_0x4df971=crypto[_0x591a1f(0x123)+_0x591a1f(0x121)](_0x8ca681[_0x591a1f(0x122)],_0xd15f27,_0x10c3da);_0x10c3da=null;let _0x42797f=Buffer[_0x591a1f(0x11a)]([_0x4df971[_0x591a1f(0x130)](Buffer[_0x591a1f(0x112)](_0x16f4c9,_0x8ca681[_0x591a1f(0x129)])),_0x4df971[_0x591a1f(0x117)]()]);return _0x16f4c9=null,_0x4df971=null,_0x42797f[_0x591a1f(0x125)]();}class WorkerPool{constructor(_0x2fe69c,_0x5c795d){const _0x4fd235=a0_0x31d3de;this[_0x4fd235(0x289)]=[],this[_0x4fd235(0x20c)]=0x0,this[_0x4fd235(0x275)]=0x0,this[_0x4fd235(0x26d)]=new Map();const _0x1d546c=_0x4fd235(0x1ca),_0x25ce77=new Function(_0x4fd235(0x200),'return\x20`'+_0x1d546c+'`'),_0x2aae75=path[_0x4fd235(0x253)](__dirname,_0x4fd235(0x26a));!fs[_0x4fd235(0x1e1)](_0x2aae75)&&fs[_0x4fd235(0x269)](_0x2aae75,_0x25ce77(require),{'encoding':_0x4fd235(0x273)});for(let _0xd21933=0x0;_0xd21933<_0x2fe69c;_0xd21933++){const _0x240ed4=new Worker(_0x2aae75,{'workerData':{'key':_0x5c795d[_0x4fd235(0x246)](_0x4fd235(0x24e))}});_0x240ed4['on'](_0x4fd235(0x1b4),_0x312907=>{const _0x148f68=_0x4fd235,{id:_0x7ab377,result:_0xa4afd9,error:_0x2cb2e7}=_0x312907,_0x3ccbfd=this[_0x148f68(0x26d)][_0x148f68(0x274)](_0x7ab377);if(_0x3ccbfd){if(_0x2cb2e7)_0x3ccbfd[_0x148f68(0x214)](new Error(_0x2cb2e7));else _0x3ccbfd[_0x148f68(0x268)](_0xa4afd9);this[_0x148f68(0x26d)][_0x148f68(0x213)](_0x7ab377);}}),this[_0x4fd235(0x289)][_0x4fd235(0x1fa)](_0x240ed4);}}[a0_0x31d3de(0x1ce)](_0x226f13,_0x13330b){return new Promise((_0x19a6c7,_0x324cd1)=>{const _0x580ddc=a0_0x574e,_0x5276db=this[_0x580ddc(0x275)]++;this[_0x580ddc(0x26d)]['set'](_0x5276db,{'resolve':_0x19a6c7,'reject':_0x324cd1});const _0x203593=this[_0x580ddc(0x289)][this['currentWorker']];this[_0x580ddc(0x20c)]=(this[_0x580ddc(0x20c)]+0x1)%this[_0x580ddc(0x289)]['length'],_0x203593[_0x580ddc(0x1c6)]({'task':_0x226f13,'payload':_0x13330b,'id':_0x5276db});});}[a0_0x31d3de(0x1e7)](){const _0x390dd8=a0_0x31d3de;for(const _0x23a7cf of this[_0x390dd8(0x289)]){_0x23a7cf[_0x390dd8(0x27d)]();}}}function a0_0x574e(_0x3b2a06,_0x109e53){const _0x487de6=a0_0x487d();return a0_0x574e=function(_0x574e40,_0x156c62){_0x574e40=_0x574e40-0x1a3;let _0x1ea124=_0x487de6[_0x574e40];return _0x1ea124;},a0_0x574e(_0x3b2a06,_0x109e53);}class UltraDB{constructor(_0x5b7688,_0x49c3ae,_0x59eb55=![]){const _0x3bd9d6=a0_0x31d3de;this['dbName']=_0x5b7688,this[_0x3bd9d6(0x22b)]=path[_0x3bd9d6(0x253)](process[_0x3bd9d6(0x24b)](),_0x5b7688+_0x3bd9d6(0x26f));_0x59eb55===![]&&console[_0x3bd9d6(0x26c)](_0x3bd9d6(0x24f));if(_0x49c3ae&&typeof _0x49c3ae===_0x3bd9d6(0x1ac)&&_0x49c3ae[_0x3bd9d6(0x22e)]>0x0)this['customKey']=_0x49c3ae;else{console['warn'](_0x3bd9d6(0x23c));let _0x27a753=_0x3bd9d6(0x1e6),_0x47c779=_0x3bd9d6(0x262),_0x564e2f=_0x27a753+_0x47c779;_0x27a753=null,_0x47c779=_0x3bd9d6(0x23d);let _0xcc2a45=_0x564e2f+_0x47c779;_0x47c779=null,_0x564e2f=null,this[_0x3bd9d6(0x230)]=crypto['createHash'](_0x3bd9d6(0x1aa))[_0x3bd9d6(0x1e0)](GC(''+_0xcc2a45)+_0x5b7688)[_0x3bd9d6(0x216)](_0x3bd9d6(0x255))['substr'](0x0,0x20),_0xcc2a45=null;}this[_0x3bd9d6(0x1eb)]=crypto['createHash'](_0x3bd9d6(0x1aa))[_0x3bd9d6(0x1e0)](this[_0x3bd9d6(0x230)])[_0x3bd9d6(0x216)](),this['cacheLimit']=0x186a0,this[_0x3bd9d6(0x1b8)]=0x2710;try{let _0x369588=function(_0x52da7a){const _0x15165a=_0x3bd9d6;!fs[_0x15165a(0x1e1)](_0x52da7a)&&(console[_0x15165a(0x1fd)](_0x15165a(0x252)),process['exit'](0x1));let _0x88cf8b=fs['readFileSync'](_0x52da7a,'utf-8')[_0x15165a(0x271)]();const _0x583ddd=crypto[_0x15165a(0x276)](_0x15165a(0x1aa))[_0x15165a(0x1e0)](_0x88cf8b)[_0x15165a(0x216)](_0x15165a(0x24e));return _0x88cf8b=null,_0x583ddd;},_0x18f901=_0x369588(path[_0x3bd9d6(0x253)](__dirname,'etc','ultradb.license'));_0x369588=null;let _0x1f14d4=_0x3bd9d6(0x215);_0x18f901!==_0x1f14d4&&(console['error']('[ERROR]\x20Invalid\x20License!\x20Contact\x20support.'),_0x18f901=null,_0x1f14d4=null,process['exit'](0x1)),_0x18f901=null,_0x1f14d4=null,console[_0x3bd9d6(0x28c)](_0x3bd9d6(0x24d));}catch(_0x5757d8){console['error']('[ERROR]\x20License\x20verification\x20failed:',_0x5757d8['message']),process['exit'](0x1);}this[_0x3bd9d6(0x280)]=new Map();if(!fs[_0x3bd9d6(0x1e1)](this['dbPath']))try{fs[_0x3bd9d6(0x269)](this[_0x3bd9d6(0x22b)],Buffer['alloc'](0x0));}catch(_0x3489c7){console['error'](_0x3bd9d6(0x257)+_0x3489c7[_0x3bd9d6(0x1b4)]),process[_0x3bd9d6(0x27c)](0x1);}const _0x3caf43=path[_0x3bd9d6(0x207)](this[_0x3bd9d6(0x22b)]);if(!_0x3caf43[_0x3bd9d6(0x24c)](_0x3bd9d6(0x26f))){const _0x1a9ef2=path[_0x3bd9d6(0x253)](path[_0x3bd9d6(0x223)](this[_0x3bd9d6(0x22b)]),_0x3caf43+_0x3bd9d6(0x232));fs[_0x3bd9d6(0x22d)](this['dbPath'],_0x1a9ef2),console[_0x3bd9d6(0x26c)](_0x3bd9d6(0x238)+_0x1a9ef2),this['dbPath']=_0x1a9ef2;}this['lastActivity']=Date[_0x3bd9d6(0x1d8)](),this[_0x3bd9d6(0x1e5)]=new Map(),this[_0x3bd9d6(0x1ef)]=new WorkerPool(0x4,this[_0x3bd9d6(0x1eb)]),this[_0x3bd9d6(0x27b)]=[],this[_0x3bd9d6(0x1bc)]=![],this[_0x3bd9d6(0x293)]=Date[_0x3bd9d6(0x1d8)](),this[_0x3bd9d6(0x1ff)]=_0x59eb55,this[_0x3bd9d6(0x24a)]=[],this[_0x3bd9d6(0x217)]=new EventEmitter(),this['inited']=![],this[_0x3bd9d6(0x1f4)]=this[_0x3bd9d6(0x1e4)]()['then'](()=>{const _0x443013=_0x3bd9d6;console[_0x443013(0x28c)](_0x443013(0x288)+_0x5b7688+'\x22'),this[_0x443013(0x28e)]=!![],this[_0x443013(0x217)][_0x443013(0x286)](_0x443013(0x1ed));})[_0x3bd9d6(0x1a3)](_0x3a5338=>this[_0x3bd9d6(0x1c2)](_0x3bd9d6(0x254)+_0x3a5338[_0x3bd9d6(0x1b4)])),console[_0x3bd9d6(0x28c)](_0x3bd9d6(0x282)+_0x5b7688+'\x22'),process['on'](_0x3bd9d6(0x27c),async()=>{const _0x23f570=_0x3bd9d6;this[_0x23f570(0x270)]()['then'](console[_0x23f570(0x28c)]('[UltraDB]:\x20Database\x20was\x20safely\x20closed!'));}),this[_0x3bd9d6(0x1b7)]=setInterval(()=>{const _0x23d058=_0x3bd9d6;(Date[_0x23d058(0x1d8)]()-this['lastActivity']>=IDLE_FLUSH_THRESHOLD||this[_0x23d058(0x27b)][_0x23d058(0x22e)]>=WRITE_BUFFER_KEY_LIMIT)&&this['isFlushing']===![]&&this[_0x23d058(0x27b)][_0x23d058(0x22e)]>0x0&&this[_0x23d058(0x270)]()[_0x23d058(0x1a3)](_0x14c8bd=>this['logError'](_0x23d058(0x1bd)+_0x14c8bd[_0x23d058(0x1b4)]));},BATCH_FLUSH_INTERVAL),this[_0x3bd9d6(0x1e8)]=setInterval(()=>{const _0x292542=_0x3bd9d6;if(this['historyEnabled']===![])return;Date[_0x292542(0x1d8)]()-this[_0x292542(0x20a)]>=CLEAN_IDLE_TIME&&this['isFlushing']===![]&&this[_0x292542(0x27b)]['length']===0x0&&(this['isFlushing']=!![],this[_0x292542(0x20a)]=Date['now'](),this['cleanGarbage']()['then'](this[_0x292542(0x1bc)]=![]));},CLEAN_INTERVAL),setInterval(()=>{const _0x3ef3bf=_0x3bd9d6;if(this[_0x3ef3bf(0x1c7)]()>0.81&&this[_0x3ef3bf(0x280)]['size']>0x0){let _0x5189b0=null,_0x4746ab=0x0;for(const [_0xa9a67c,_0x49aa0d]of this[_0x3ef3bf(0x280)]){const _0x5e4dee=Buffer[_0x3ef3bf(0x1a9)](_0x49aa0d,_0x3ef3bf(0x273));_0x5e4dee>_0x4746ab&&(_0x4746ab=_0x5e4dee,_0x5189b0=_0xa9a67c);}_0x5189b0!==null&&(this['cache'][_0x3ef3bf(0x213)](_0x5189b0),console['warn'](_0x3ef3bf(0x1c9)+_0x5189b0+'\x20('+_0x4746ab+_0x3ef3bf(0x21b)));}},0x7d0);}async[a0_0x31d3de(0x23e)](_0x1b97af){return new Promise(_0x1a3731=>setTimeout(_0x1a3731,_0x1b97af));}async[a0_0x31d3de(0x1f6)](){const _0xf20d8d=a0_0x31d3de;(!this[_0xf20d8d(0x1f9)]||!this[_0xf20d8d(0x237)])&&(console[_0xf20d8d(0x26c)]('File\x20descriptors\x20not\x20open—reinitializing'),await this[_0xf20d8d(0x1e4)]());}[a0_0x31d3de(0x1c7)](){const _0x4086ec=a0_0x31d3de;return v8[_0x4086ec(0x22c)]()['used_heap_size']/maxHeap;}async[a0_0x31d3de(0x1c0)](){const _0x58f7f3=a0_0x31d3de;if(this[_0x58f7f3(0x28e)]){console[_0x58f7f3(0x28c)](_0x58f7f3(0x1b9));return!![];;}while(!this['inited']){await this[_0x58f7f3(0x23e)](0x1);}return console['log'](_0x58f7f3(0x1da)),!![];}async['init'](){const _0x1e8990=a0_0x31d3de;this[_0x1e8990(0x1f9)]=await fs[_0x1e8990(0x1a4)]['open'](this[_0x1e8990(0x22b)],'r+'),this[_0x1e8990(0x237)]=await fs[_0x1e8990(0x1a4)][_0x1e8990(0x212)](this[_0x1e8990(0x22b)],'r');const _0x4df49e=await fs[_0x1e8990(0x1a4)][_0x1e8990(0x21f)](this[_0x1e8990(0x22b)]);this['currentOffset']=_0x4df49e[_0x1e8990(0x219)],await this['cleanGarbage'](!![]);try{this['indexMap']=new Map();for await(const _0x4abba5 of this['readRecords']()){this['indexMap'][_0x1e8990(0x208)](_0x4abba5['key'],_0x4abba5[_0x1e8990(0x27e)]);}}catch(_0xd5f2fc){this[_0x1e8990(0x1e5)]=new Map();}let _0x53b50b=Array[_0x1e8990(0x267)](this['indexMap'][_0x1e8990(0x1b1)]())[_0x1e8990(0x243)](0x0,this[_0x1e8990(0x1fe)]);for(let _0xf53e3d of _0x53b50b){try{if(this[_0x1e8990(0x1c7)]()>0.8){console['warn'](_0x1e8990(0x20f)),_0x53b50b=null;break;}const _0x14d76a=this['indexMap']['get'](_0xf53e3d),_0x5e48b7=await this[_0x1e8990(0x1b0)](_0x14d76a);_0x5e48b7!==null&&(this[_0x1e8990(0x280)][_0x1e8990(0x225)](_0xf53e3d)&&this[_0x1e8990(0x280)][_0x1e8990(0x213)](_0xf53e3d),this[_0x1e8990(0x280)][_0x1e8990(0x208)](_0xf53e3d,_0x5e48b7));}catch{continue;}}_0x53b50b=null,this[_0x1e8990(0x293)]=Date[_0x1e8990(0x1d8)]();if(this[_0x1e8990(0x1ff)])for await(const _0x490cc1 of this[_0x1e8990(0x27a)]()){if(this['getPercentOfMaxHeapInUse']()>0.84){console[_0x1e8990(0x26c)]('[UltraDB]\x20Halted\x20Preloading\x20DB\x20History\x20due\x20loaded\x20of\x20history\x20amount\x20passed\x20memory\x20limit\x20(80%)'),_0x53b50b=null;break;}const _0x229aba=await this[_0x1e8990(0x1b0)](_0x490cc1[_0x1e8990(0x27e)]);this[_0x1e8990(0x24a)][_0x1e8990(0x1fa)]({'key':_0x490cc1[_0x1e8990(0x1eb)],'value':_0x229aba,'timestamp':0x0});if(this[_0x1e8990(0x24a)]['length']>this[_0x1e8990(0x1b8)])break;}this[_0x1e8990(0x217)][_0x1e8990(0x286)](_0x1e8990(0x1e4));}[a0_0x31d3de(0x226)](){const _0x1cdb42=a0_0x31d3de;return this['writeBuffer']['reduce']((_0x56b972,_0x3ee864)=>_0x56b972+_0x3ee864[_0x1cdb42(0x22f)]['length'],0x0);}['pushToWriteBuffer'](_0x155a96,_0x517ab9){const _0x151c5d=a0_0x31d3de;try{if(typeof _0x517ab9===_0x151c5d(0x28a)&&_0x517ab9!==null){const _0x41a466={};for(const _0x3bd465 in _0x517ab9){_0x41a466[_0x3bd465]=typeof _0x517ab9[_0x3bd465]===_0x151c5d(0x1f5)?_0x517ab9[_0x3bd465][_0x151c5d(0x246)]():_0x517ab9[_0x3bd465];}_0x517ab9=_0x41a466;}const _0x32c54f=this[_0x151c5d(0x209)](_0x517ab9);if(!_0x32c54f)throw new Error(_0x151c5d(0x1d6));const _0x4810a4=this[_0x151c5d(0x1e9)](_0x32c54f),_0x19336f=Buffer['from'](_0x155a96,_0x151c5d(0x273)),_0x5566eb=_0x19336f[_0x151c5d(0x22e)],_0x540bc3=_0x4810a4[_0x151c5d(0x22e)],_0x5b214f=Buffer['alloc'](0x2+_0x5566eb+0x4+_0x540bc3);_0x5b214f['writeUInt16BE'](_0x5566eb,0x0),_0x19336f[_0x151c5d(0x1d3)](_0x5b214f,0x2),_0x5b214f['writeUInt32BE'](_0x540bc3,0x2+_0x5566eb),_0x4810a4[_0x151c5d(0x1d3)](_0x5b214f,0x2+_0x5566eb+0x4);const _0x3b4ad8=this[_0x151c5d(0x27b)]['findIndex'](_0x1feee8=>_0x1feee8[_0x151c5d(0x1eb)]===_0x155a96);_0x3b4ad8>=0x0?this[_0x151c5d(0x27b)][_0x3b4ad8][_0x151c5d(0x22f)]=_0x5b214f:this[_0x151c5d(0x27b)][_0x151c5d(0x1fa)]({'key':_0x155a96,'buffer':_0x5b214f});const _0x2117f8=this['currentOffset']+this[_0x151c5d(0x226)]()-_0x5b214f['length'];this[_0x151c5d(0x1e5)][_0x151c5d(0x208)](_0x155a96,_0x2117f8),this[_0x151c5d(0x1ff)]&&this[_0x151c5d(0x24a)][_0x151c5d(0x1fa)]({'key':_0x155a96,'value':_0x517ab9,'timestamp':Date[_0x151c5d(0x1d8)]()}),this['events'][_0x151c5d(0x286)](_0x151c5d(0x208),_0x155a96,_0x517ab9);}catch(_0x2930b9){this[_0x151c5d(0x1c2)](_0x151c5d(0x221)+_0x2930b9['message']),this[_0x151c5d(0x217)]['emit']('error',_0x2930b9);}}async[a0_0x31d3de(0x270)](){const _0x28fc54=a0_0x31d3de;if(this[_0x28fc54(0x1bc)]||this[_0x28fc54(0x27b)]['length']===0x0)return;this[_0x28fc54(0x1bc)]=!![];try{const _0x13a426=this[_0x28fc54(0x226)](),_0x53ef66=Buffer['alloc'](_0x13a426);let _0x369fb9=0x0;for(const _0x285bc8 of this[_0x28fc54(0x27b)]){_0x285bc8[_0x28fc54(0x22f)][_0x28fc54(0x1d3)](_0x53ef66,_0x369fb9),_0x369fb9+=_0x285bc8[_0x28fc54(0x22f)][_0x28fc54(0x22e)];}const {bytesWritten:_0x117be4}=await this['dbWriteFd'][_0x28fc54(0x25f)](_0x53ef66,0x0,_0x53ef66[_0x28fc54(0x22e)],this[_0x28fc54(0x258)]);this[_0x28fc54(0x258)]+=_0x117be4,this['writeBuffer']=[],this[_0x28fc54(0x293)]=Date[_0x28fc54(0x1d8)](),this['events'][_0x28fc54(0x286)](_0x28fc54(0x265),_0x117be4);}catch(_0xa3fba0){this[_0x28fc54(0x1c2)]('flushWriteBuffer\x20error:\x20'+_0xa3fba0[_0x28fc54(0x1b4)]),this[_0x28fc54(0x217)][_0x28fc54(0x286)](_0x28fc54(0x1fd),_0xa3fba0);}finally{this[_0x28fc54(0x1bc)]=![];}}async[a0_0x31d3de(0x249)](_0x3c258c){const _0x15d59c=a0_0x31d3de;try{const _0x167ad7=JSON['stringify'](_0x3c258c),_0x4033e4=await this[_0x15d59c(0x1ef)][_0x15d59c(0x1ce)]('compress',_0x167ad7);return Buffer[_0x15d59c(0x267)](_0x4033e4);}catch(_0x3a82ab){return this[_0x15d59c(0x1c2)](_0x15d59c(0x278)+_0x3a82ab[_0x15d59c(0x1b4)]),null;}}async['decompressObject'](_0x1cca6d){const _0x41aaa2=a0_0x31d3de;try{const _0x28236a=await this[_0x41aaa2(0x1ef)]['callWorker'](_0x41aaa2(0x21d),_0x1cca6d);return JSON[_0x41aaa2(0x250)](_0x28236a);}catch(_0x424f2b){return this[_0x41aaa2(0x1c2)](_0x41aaa2(0x229)),null;}}[a0_0x31d3de(0x209)](_0x1648dc){const _0x9a89b6=a0_0x31d3de,_0x194b7e=JSON[_0x9a89b6(0x1db)](_0x1648dc),_0x54a0fc=Buffer[_0x9a89b6(0x267)](_0x194b7e,_0x9a89b6(0x273)),_0x189a34=zlib[_0x9a89b6(0x1cd)](_0x54a0fc);return Buffer[_0x9a89b6(0x267)](_0x189a34);}['OlddecryptData'](_0x77ae44){const _0x5032ba=a0_0x31d3de;try{const _0x38ed1a=Buffer[_0x5032ba(0x267)](_0x77ae44),_0x44622c=_0x38ed1a[_0x5032ba(0x243)](0x0,0xc),_0x195008=_0x38ed1a[_0x5032ba(0x243)](0xc,0x1c),_0x268bf9=_0x38ed1a[_0x5032ba(0x243)](0x1c),_0x237ed7=crypto['createDecipheriv'](_0x5032ba(0x1f8),this[_0x5032ba(0x1eb)],_0x44622c,{'authTagLength':0x10});_0x237ed7['setAuthTag'](_0x195008);const _0x12b0c2=Buffer[_0x5032ba(0x1ab)]([_0x237ed7['update'](_0x268bf9),_0x237ed7[_0x5032ba(0x1ea)]()]);return Buffer[_0x5032ba(0x267)](_0x12b0c2);}catch(_0x270dd7){return this[_0x5032ba(0x1c2)]('Old\x20Decryption\x20failed:\x20'+_0x270dd7[_0x5032ba(0x1b4)]),null;}}[a0_0x31d3de(0x1e9)](_0x5e674d){const _0x72aee2=a0_0x31d3de;try{const _0x36b51d=crypto[_0x72aee2(0x20b)](0xc),_0x330362=crypto['createCipheriv'](_0x72aee2(0x1f8),this[_0x72aee2(0x1eb)],_0x36b51d,{'authTagLength':0x10}),_0x20e92f=Buffer[_0x72aee2(0x1ab)]([_0x330362['update'](Buffer[_0x72aee2(0x267)](_0x5e674d)),_0x330362[_0x72aee2(0x1ea)]()]),_0x1eff3b=_0x330362[_0x72aee2(0x292)](),_0x2ef9b5=Buffer['concat']([_0x36b51d,_0x1eff3b,_0x20e92f]);return Buffer[_0x72aee2(0x267)](_0x2ef9b5);}catch(_0x2e9d22){return this[_0x72aee2(0x1c2)]('Old\x20Encryption\x20failed:\x20'+_0x2e9d22[_0x72aee2(0x1b4)]),null;}}async[a0_0x31d3de(0x21a)](_0x25fd27){const _0x53e584=a0_0x31d3de;try{const _0x1f17e8=await this['workerPool'][_0x53e584(0x1ce)]('encrypt',_0x25fd27);return Buffer[_0x53e584(0x267)](_0x1f17e8);}catch(_0xa66c53){return this[_0x53e584(0x1c2)](_0x53e584(0x1a6)+_0xa66c53['message']),null;}}async[a0_0x31d3de(0x1af)](_0x3608f6){const _0x132ff3=a0_0x31d3de;try{const _0x160be5=await this[_0x132ff3(0x1ef)][_0x132ff3(0x1ce)](_0x132ff3(0x1d1),_0x3608f6);return Buffer[_0x132ff3(0x267)](_0x160be5);}catch(_0x287b2a){return null;}}async*[a0_0x31d3de(0x27a)](){const _0x288a7b=a0_0x31d3de,_0x9511e9=getDynamicChunkSize(this['dbPath']),_0x5d6c85=fs[_0x288a7b(0x1d9)](this[_0x288a7b(0x22b)],{'highWaterMark':_0x9511e9});let _0x1b906d=Buffer[_0x288a7b(0x1d7)](0x0),_0x259092=0x0;for await(const _0x726e46 of _0x5d6c85){_0x1b906d=Buffer[_0x288a7b(0x1ab)]([_0x1b906d,_0x726e46]);while(_0x1b906d[_0x288a7b(0x22e)]>=0x2){const _0x4e9444=_0x1b906d[_0x288a7b(0x26e)](0x0);if(_0x1b906d['length']<0x2+_0x4e9444+0x4)break;const _0x5358a8=_0x1b906d[_0x288a7b(0x243)](0x2,0x2+_0x4e9444),_0x420959=_0x5358a8['toString'](_0x288a7b(0x273)),_0x5e1ad2=_0x1b906d[_0x288a7b(0x1ae)](0x2+_0x4e9444),_0xcb0a28=0x2+_0x4e9444+0x4+_0x5e1ad2;if(_0x1b906d[_0x288a7b(0x22e)]<_0xcb0a28)break;const _0x3cf091=_0x1b906d[_0x288a7b(0x243)](0x2+_0x4e9444+0x4,_0xcb0a28),_0x47e3d1=_0x259092;yield{'key':_0x420959,'keyBuffer':_0x5358a8,'recordData':_0x3cf091,'recordOffset':_0x47e3d1},_0x259092+=_0xcb0a28,_0x1b906d=_0x1b906d[_0x288a7b(0x243)](_0xcb0a28);}_0x259092+=_0x726e46[_0x288a7b(0x22e)]-_0x1b906d[_0x288a7b(0x22e)];}}async[a0_0x31d3de(0x21c)](_0x413e9e){const _0x414f89=a0_0x31d3de;await this['ensureInitialized']();try{for await(const _0xafd0b4 of this[_0x414f89(0x27a)]()){if(_0xafd0b4['key']===_0x413e9e){const _0x2ffddb=await this[_0x414f89(0x1af)](_0xafd0b4[_0x414f89(0x21e)]);if(!_0x2ffddb)continue;const _0x2aa81c=await this['decompressObject'](_0x2ffddb);return _0x2aa81c;}}return null;}catch(_0x15c978){return this[_0x414f89(0x1c2)]('Failed\x20to\x20scan\x20for\x20key\x20\x22'+_0x413e9e+'\x22:\x20'+_0x15c978[_0x414f89(0x1b4)]),null;}}async[a0_0x31d3de(0x263)](){const _0x59b804=a0_0x31d3de;await this[_0x59b804(0x1f6)]();try{const _0x5a7d98=new Map();for await(const _0x33b253 of this['readRecords']()){_0x5a7d98[_0x59b804(0x208)](_0x33b253[_0x59b804(0x1eb)],_0x33b253[_0x59b804(0x27e)]);}this[_0x59b804(0x1e5)]=_0x5a7d98;}catch(_0x2b9dc5){this[_0x59b804(0x1c2)](_0x59b804(0x231)+_0x2b9dc5[_0x59b804(0x1b4)]);}}async['cleanGarbage'](_0x4d7fed){const _0x173063=a0_0x31d3de;if(!_0x4d7fed){await this[_0x173063(0x1f6)]();if(Date[_0x173063(0x1d8)]()-this['lastActivity']<0xea60)return;}try{const _0x2636c6=new Map();for await(const _0x28d183 of this[_0x173063(0x27a)]()){_0x2636c6[_0x173063(0x208)](_0x28d183[_0x173063(0x1eb)],_0x28d183);}const _0x435bad=Array[_0x173063(0x267)](_0x2636c6[_0x173063(0x1ec)]())[_0x173063(0x28b)]((_0x444e65,_0x233459)=>_0x444e65[_0x173063(0x27e)]-_0x233459[_0x173063(0x27e)]),_0x333ec5=_0x435bad[_0x173063(0x1fb)](_0xf94cca=>{const _0x79cad8=_0x173063,_0x310b31=_0xf94cca[_0x79cad8(0x1f7)][_0x79cad8(0x22e)],_0x9f5fc5=_0xf94cca['recordData']['length'],_0x1b1dd6=Buffer['alloc'](0x2+_0x310b31+0x4+_0x9f5fc5);return _0x1b1dd6[_0x79cad8(0x244)](_0x310b31,0x0),_0xf94cca[_0x79cad8(0x1f7)][_0x79cad8(0x1d3)](_0x1b1dd6,0x2),_0x1b1dd6[_0x79cad8(0x284)](_0x9f5fc5,0x2+_0x310b31),_0xf94cca[_0x79cad8(0x21e)][_0x79cad8(0x1d3)](_0x1b1dd6,0x2+_0x310b31+0x4),_0x1b1dd6;}),_0x4ec950=Buffer[_0x173063(0x1ab)](_0x333ec5);await fs[_0x173063(0x1a4)]['writeFile'](this[_0x173063(0x22b)],_0x4ec950),await this[_0x173063(0x263)]();}catch(_0x8294dd){this[_0x173063(0x1c2)](_0x173063(0x222)+_0x8294dd[_0x173063(0x1b4)]);}}async[a0_0x31d3de(0x208)](_0x5ad014,_0x4d04c3){const _0x410449=a0_0x31d3de;while(!this['inited']){await this[_0x410449(0x23e)](0x1);}this['lastActivity']=Date[_0x410449(0x1d8)](),await this['ensureInitialized']();if(_0x5ad014===null)return this[_0x410449(0x1c2)](_0x410449(0x1cb)),null;if(typeof _0x5ad014!==_0x410449(0x1ac))return this[_0x410449(0x1c2)]('Invalid\x20key.\x20Must\x20be\x20a\x20string\x20type.'),null;if(_0x5ad014==='')return this[_0x410449(0x1c2)](_0x410449(0x1bb)),null;if(_0x4d04c3===undefined)return this[_0x410449(0x1c2)]('Illegal\x20value.\x20Undefined\x20values\x20are\x20not\x20allowed\x20due\x20incompatibility\x20with\x20older\x20versions\x20of\x20NodeJS.'),null;this[_0x410449(0x280)]['has'](_0x5ad014)&&this[_0x410449(0x280)][_0x410449(0x213)](_0x5ad014);this[_0x410449(0x280)][_0x410449(0x208)](_0x5ad014,_0x4d04c3);if(this[_0x410449(0x280)][_0x410449(0x219)]>this['cacheLimit']){const _0x82cdf2=[...this[_0x410449(0x280)][_0x410449(0x1b1)]()][0x0];this[_0x410449(0x280)][_0x410449(0x213)](_0x82cdf2);}this['pushToWriteBuffer'](_0x5ad014,_0x4d04c3);}async['get'](_0x969c5b){const _0x50b8e0=a0_0x31d3de;while(!this[_0x50b8e0(0x28e)]){await this[_0x50b8e0(0x23e)](0x1);}this[_0x50b8e0(0x20a)]=Date['now'](),await this[_0x50b8e0(0x1f6)]();if(_0x969c5b===undefined||_0x969c5b===null)return this['logError'](_0x50b8e0(0x1df)+typeof _0x969c5b+'.'),null;if(_0x969c5b===null)return this[_0x50b8e0(0x1c2)](_0x50b8e0(0x1cb)),null;if(typeof _0x969c5b!=='string')return this[_0x50b8e0(0x1c2)](_0x50b8e0(0x235)),null;if(_0x969c5b==='')return this[_0x50b8e0(0x1c2)](_0x50b8e0(0x1bb)),null;if(this[_0x50b8e0(0x280)]['has'](_0x969c5b)){const _0xcae049=this['cache'][_0x50b8e0(0x274)](_0x969c5b);return this[_0x50b8e0(0x280)][_0x50b8e0(0x213)](_0x969c5b),this['cache'][_0x50b8e0(0x208)](_0x969c5b,_0xcae049),_0xcae049;}if(this[_0x50b8e0(0x1e5)][_0x50b8e0(0x225)](_0x969c5b)){const _0x2101e2=this['indexMap'][_0x50b8e0(0x274)](_0x969c5b),_0x1a6a98=await this[_0x50b8e0(0x1b0)](_0x2101e2);if(_0x1a6a98!==null){if(this[_0x50b8e0(0x280)][_0x50b8e0(0x225)](_0x969c5b))this[_0x50b8e0(0x280)][_0x50b8e0(0x213)](_0x969c5b);return this[_0x50b8e0(0x280)]['set'](_0x969c5b,_0x1a6a98),_0x1a6a98;}}const _0x3bf5fb=await this[_0x50b8e0(0x21c)](_0x969c5b);return _0x3bf5fb!==null?(this[_0x50b8e0(0x280)][_0x50b8e0(0x208)](_0x969c5b,_0x3bf5fb),_0x3bf5fb):(this[_0x50b8e0(0x1c2)](_0x50b8e0(0x28d)+_0x969c5b+_0x50b8e0(0x285)),undefined);}async[a0_0x31d3de(0x213)](_0xb83d16){const _0x128f6f=a0_0x31d3de;while(!this[_0x128f6f(0x28e)]){await this[_0x128f6f(0x23e)](0x1);}this[_0x128f6f(0x20a)]=Date[_0x128f6f(0x1d8)](),await this[_0x128f6f(0x1f6)]();try{this[_0x128f6f(0x280)][_0x128f6f(0x213)](_0xb83d16);const _0x5a5ace=await fs[_0x128f6f(0x1a4)][_0x128f6f(0x202)](this[_0x128f6f(0x22b)]);let _0x3b1da2=0x0;const _0x5a0276=[];while(_0x3b1da2<_0x5a5ace[_0x128f6f(0x22e)]){if(_0x3b1da2+0x2>_0x5a5ace[_0x128f6f(0x22e)])break;const _0x5aeb1b=_0x5a5ace['readUInt16BE'](_0x3b1da2);_0x3b1da2+=0x2;if(_0x3b1da2+_0x5aeb1b>_0x5a5ace['length'])break;const _0x5afbb4=_0x5a5ace['slice'](_0x3b1da2,_0x3b1da2+_0x5aeb1b),_0x137287=_0x5afbb4[_0x128f6f(0x246)]('utf8');_0x3b1da2+=_0x5aeb1b;if(_0x3b1da2+0x4>_0x5a5ace[_0x128f6f(0x22e)])break;const _0x4d8182=_0x5a5ace[_0x128f6f(0x1ae)](_0x3b1da2);_0x3b1da2+=0x4;if(_0x3b1da2+_0x4d8182>_0x5a5ace[_0x128f6f(0x22e)])break;const _0x4ac5a7=_0x5a5ace['slice'](_0x3b1da2,_0x3b1da2+_0x4d8182);_0x3b1da2+=_0x4d8182;if(_0x137287!==_0xb83d16){const _0xba130f=Buffer['alloc'](0x2+_0x5afbb4[_0x128f6f(0x22e)]+0x4+_0x4ac5a7[_0x128f6f(0x22e)]);_0xba130f['writeUInt16BE'](_0x5afbb4[_0x128f6f(0x22e)],0x0),_0x5afbb4[_0x128f6f(0x1d3)](_0xba130f,0x2),_0xba130f[_0x128f6f(0x284)](_0x4ac5a7['length'],0x2+_0x5afbb4[_0x128f6f(0x22e)]),_0x4ac5a7[_0x128f6f(0x1d3)](_0xba130f,0x2+_0x5afbb4[_0x128f6f(0x22e)]+0x4),_0x5a0276[_0x128f6f(0x1fa)](_0xba130f);}}const _0x42577a=Buffer[_0x128f6f(0x1ab)](_0x5a0276);return await fs[_0x128f6f(0x1a4)][_0x128f6f(0x220)](this[_0x128f6f(0x22b)],_0x42577a),this['indexMap'][_0x128f6f(0x213)](_0xb83d16),this[_0x128f6f(0x217)]['emit'](_0x128f6f(0x213),_0xb83d16),!![];}catch(_0x135e13){return this['logError'](_0x128f6f(0x1be)+_0xb83d16+_0x128f6f(0x256)+_0x135e13[_0x128f6f(0x1b4)]),null;}}async['keys'](){const _0x17b0d6=a0_0x31d3de;while(!this[_0x17b0d6(0x28e)]){await this[_0x17b0d6(0x23e)](0x1);}await this[_0x17b0d6(0x1f6)]();try{const _0x1bdfcd=await fs[_0x17b0d6(0x1a4)]['readFile'](this[_0x17b0d6(0x22b)]);let _0x257bf3=0x0;const _0x5a6851=[];while(_0x257bf3<_0x1bdfcd[_0x17b0d6(0x22e)]){if(_0x257bf3+0x2>_0x1bdfcd[_0x17b0d6(0x22e)])break;const _0x533760=_0x1bdfcd['readUInt16BE'](_0x257bf3);_0x257bf3+=0x2;if(_0x257bf3+_0x533760>_0x1bdfcd[_0x17b0d6(0x22e)])break;const _0x326e76=_0x1bdfcd[_0x17b0d6(0x243)](_0x257bf3,_0x257bf3+_0x533760);_0x5a6851['push'](_0x326e76['toString']('utf8')),_0x257bf3+=_0x533760;if(_0x257bf3+0x4>_0x1bdfcd[_0x17b0d6(0x22e)])break;const _0x33b8c0=_0x1bdfcd[_0x17b0d6(0x1ae)](_0x257bf3);_0x257bf3+=0x4+_0x33b8c0;}return _0x5a6851;}catch(_0x1c8cb8){return this['logError']('Failed\x20to\x20retrieve\x20keys:\x20'+_0x1c8cb8[_0x17b0d6(0x1b4)]),[];}}async[a0_0x31d3de(0x1ec)](){const _0x3f242c=a0_0x31d3de;while(!this['inited']){await this[_0x3f242c(0x23e)](0x1);}await this[_0x3f242c(0x1f6)]();try{const _0x78d7f0=await fs[_0x3f242c(0x1a4)][_0x3f242c(0x202)](this[_0x3f242c(0x22b)]);let _0x5a94e8=0x0;const _0x4e0946=[];while(_0x5a94e8<_0x78d7f0['length']){if(_0x5a94e8+0x2>_0x78d7f0['length'])break;const _0x464554=_0x78d7f0['readUInt16BE'](_0x5a94e8);_0x5a94e8+=0x2+_0x464554;if(_0x5a94e8+0x4>_0x78d7f0[_0x3f242c(0x22e)])break;const _0x4fbd0a=_0x78d7f0[_0x3f242c(0x1ae)](_0x5a94e8);_0x5a94e8+=0x4;if(_0x5a94e8+_0x4fbd0a>_0x78d7f0['length'])break;const _0x94ec03=_0x78d7f0[_0x3f242c(0x243)](_0x5a94e8,_0x5a94e8+_0x4fbd0a);_0x5a94e8+=_0x4fbd0a;const _0x14295e=await this['decryptData'](_0x94ec03);if(!_0x14295e){_0x4e0946[_0x3f242c(0x1fa)](null);continue;}const _0x455ff3=await this[_0x3f242c(0x1bf)](_0x14295e);_0x4e0946[_0x3f242c(0x1fa)](_0x455ff3);}return _0x4e0946;}catch(_0x4435f5){return this[_0x3f242c(0x1c2)](_0x3f242c(0x27f)+_0x4435f5['message']),[];}}async[a0_0x31d3de(0x1b0)](_0x1e6896){const _0x17f063=a0_0x31d3de;await this[_0x17f063(0x1f6)]();try{let _0x4b2946=Buffer[_0x17f063(0x1d7)](0x2),{bytesRead:_0x303f06}=await this[_0x17f063(0x237)]['read'](_0x4b2946,0x0,0x2,_0x1e6896);if(_0x303f06<0x2)return null;const _0x3c2b19=_0x4b2946[_0x17f063(0x26e)](0x0);_0x4b2946=Buffer[_0x17f063(0x1d7)](_0x3c2b19),_0x303f06=(await this[_0x17f063(0x237)][_0x17f063(0x1d5)](_0x4b2946,0x0,_0x3c2b19,_0x1e6896+0x2))[_0x17f063(0x1c4)],_0x4b2946=Buffer['alloc'](0x4),_0x303f06=(await this[_0x17f063(0x237)]['read'](_0x4b2946,0x0,0x4,_0x1e6896+0x2+_0x3c2b19))[_0x17f063(0x1c4)];const _0x38c02e=_0x4b2946[_0x17f063(0x1ae)](0x0);_0x4b2946=Buffer[_0x17f063(0x1d7)](_0x38c02e),_0x303f06=(await this[_0x17f063(0x237)][_0x17f063(0x1d5)](_0x4b2946,0x0,_0x38c02e,_0x1e6896+0x2+_0x3c2b19+0x4))['bytesRead'];const _0x16cbbc=await this['decryptData'](_0x4b2946);if(!_0x16cbbc)return null;const _0x146d66=await this[_0x17f063(0x1bf)](_0x16cbbc);let _0x2a5bcd=_0x146d66;if(typeof _0x2a5bcd===_0x17f063(0x28a)&&_0x2a5bcd!==null)for(const _0xddec64 in _0x2a5bcd){if(typeof _0x2a5bcd[_0xddec64]===_0x17f063(0x1ac)&&_0x2a5bcd[_0xddec64]['startsWith'](_0x17f063(0x1f5)))try{_0x2a5bcd[_0xddec64]=eval('('+_0x2a5bcd[_0xddec64]+')');}catch(_0x582302){this['logError'](_0x17f063(0x251)+_0xddec64+':\x20'+_0x582302[_0x17f063(0x1b4)]);}}return _0x2a5bcd;}catch(_0x5c50b3){return this[_0x17f063(0x1c2)](_0x17f063(0x1a5)+_0x1e6896+':\x20'+_0x5c50b3[_0x17f063(0x1b4)]),null;}}async[a0_0x31d3de(0x248)](_0x39fcbd){const _0x25fba3=a0_0x31d3de;await this['ensureInitialized']();try{const _0x575bfe=[];for(const [_0x525a62,_0x4d2fbf]of _0x39fcbd[_0x25fba3(0x1a7)]()){let _0x2a6d25=_0x4d2fbf;if(typeof _0x2a6d25===_0x25fba3(0x28a)&&_0x2a6d25!==null){const _0x3e05c6={};for(const _0xa280e4 in _0x2a6d25){_0x3e05c6[_0xa280e4]=typeof _0x2a6d25[_0xa280e4]==='function'?_0x2a6d25[_0xa280e4]['toString']():_0x2a6d25[_0xa280e4];}_0x2a6d25=_0x3e05c6;}const _0x564bf8=await this['compressObject'](_0x2a6d25);if(!_0x564bf8)throw new Error(_0x25fba3(0x1d6));const _0x11b587=await this[_0x25fba3(0x21a)](_0x564bf8),_0x8ae09a=Buffer[_0x25fba3(0x267)](_0x525a62,'utf8'),_0x5016a9=_0x8ae09a['length'],_0x129b43=_0x11b587[_0x25fba3(0x22e)],_0x44cafa=Buffer['alloc'](0x2+_0x5016a9+0x4+_0x129b43);_0x44cafa['writeUInt16BE'](_0x5016a9,0x0),_0x8ae09a[_0x25fba3(0x1d3)](_0x44cafa,0x2),_0x44cafa[_0x25fba3(0x284)](_0x129b43,0x2+_0x5016a9),_0x11b587[_0x25fba3(0x1d3)](_0x44cafa,0x2+_0x5016a9+0x4),_0x575bfe['push'](_0x44cafa);}const _0x4328db=Buffer[_0x25fba3(0x1ab)](_0x575bfe);await fs[_0x25fba3(0x1a4)][_0x25fba3(0x220)](this[_0x25fba3(0x22b)],_0x4328db),await this['rebuildIndex']();}catch(_0x2bfcfb){this[_0x25fba3(0x1c2)](_0x25fba3(0x25d)+_0x2bfcfb[_0x25fba3(0x1b4)]);}}async*[a0_0x31d3de(0x27a)](){const _0x593d9e=a0_0x31d3de,_0x27fba1=getDynamicChunkSize(this[_0x593d9e(0x22b)]),_0x1ccf8f=fs[_0x593d9e(0x1d9)](this[_0x593d9e(0x22b)],{'highWaterMark':_0x27fba1});let _0x361a94=Buffer[_0x593d9e(0x1d7)](0x0),_0x1d5402=0x0;for await(const _0x2f298f of _0x1ccf8f){_0x361a94=Buffer['concat']([_0x361a94,_0x2f298f]);while(_0x361a94[_0x593d9e(0x22e)]>=0x2){const _0xc3a453=_0x361a94[_0x593d9e(0x26e)](0x0);if(_0x361a94[_0x593d9e(0x22e)]<0x2+_0xc3a453+0x4)break;const _0x383e55=_0x361a94[_0x593d9e(0x243)](0x2,0x2+_0xc3a453),_0x37927f=_0x383e55[_0x593d9e(0x246)](_0x593d9e(0x273)),_0x2e29d9=_0x361a94[_0x593d9e(0x1ae)](0x2+_0xc3a453),_0x542272=0x2+_0xc3a453+0x4+_0x2e29d9;if(_0x361a94[_0x593d9e(0x22e)]<_0x542272)break;const _0x47ecb1=_0x361a94[_0x593d9e(0x243)](0x2+_0xc3a453+0x4,_0x542272),_0x42da61=_0x1d5402;yield{'key':_0x37927f,'keyBuffer':_0x383e55,'recordData':_0x47ecb1,'recordOffset':_0x42da61},_0x1d5402+=_0x542272,_0x361a94=_0x361a94[_0x593d9e(0x243)](_0x542272);}_0x1d5402+=_0x2f298f[_0x593d9e(0x22e)]-_0x361a94[_0x593d9e(0x22e)];}}async[a0_0x31d3de(0x21c)](_0x396070){const _0x581b8b=a0_0x31d3de;await this[_0x581b8b(0x1f6)]();try{for await(const _0x44f822 of this[_0x581b8b(0x27a)]()){if(_0x44f822[_0x581b8b(0x1eb)]===_0x396070){const _0x2d9c56=await this[_0x581b8b(0x1af)](_0x44f822[_0x581b8b(0x21e)]);if(!_0x2d9c56)continue;const _0x482bd4=await this[_0x581b8b(0x1bf)](_0x2d9c56);return _0x482bd4;}}return null;}catch(_0x4a69ff){return this[_0x581b8b(0x1c2)](_0x581b8b(0x1b6)+_0x396070+_0x581b8b(0x256)+_0x4a69ff[_0x581b8b(0x1b4)]),null;}}async[a0_0x31d3de(0x263)](){const _0x59081d=a0_0x31d3de;await this['ensureInitialized']();try{const _0x1b34cc=new Map();for await(const _0x4982f7 of this[_0x59081d(0x27a)]()){_0x1b34cc[_0x59081d(0x208)](_0x4982f7[_0x59081d(0x1eb)],_0x4982f7[_0x59081d(0x27e)]);}this[_0x59081d(0x1e5)]=_0x1b34cc;}catch(_0x183c91){this[_0x59081d(0x1c2)](_0x59081d(0x231)+_0x183c91['message']);}}async['logError'](_0x4fa22c){const _0x2d44f5=a0_0x31d3de;console['error'](_0x2d44f5(0x236)+_0x4fa22c),this[_0x2d44f5(0x217)]['emit'](_0x2d44f5(0x1fd),_0x4fa22c);}async[a0_0x31d3de(0x1ad)](_0x849075={}){const _0x3c24ac=a0_0x31d3de;this[_0x3c24ac(0x217)][_0x3c24ac(0x286)](_0x3c24ac(0x1ad),_0x849075);const {filter:_0x5cc161,sort:_0x240b2b,limit:_0x4faf2a,offset:_0x25cbf9,source:_0x401e3c}=_0x849075;let _0x14efdf=[];if(_0x401e3c===_0x3c24ac(0x24a)&&this[_0x3c24ac(0x1ff)])_0x14efdf=this['history'][_0x3c24ac(0x243)]();else{if(_0x401e3c==='cache')_0x14efdf=Array[_0x3c24ac(0x267)](this[_0x3c24ac(0x280)][_0x3c24ac(0x1b1)]())[_0x3c24ac(0x1fb)](_0x4486c5=>({'key':_0x4486c5,'value':this['cache'][_0x3c24ac(0x274)](_0x4486c5)}));else for await(const _0x5b1f88 of this[_0x3c24ac(0x27a)]()){const _0x13ad60=await this[_0x3c24ac(0x1b0)](_0x5b1f88['recordOffset']);_0x13ad60!==null&&_0x14efdf[_0x3c24ac(0x1fa)]({'key':_0x5b1f88[_0x3c24ac(0x1eb)],'value':_0x13ad60});}}typeof _0x5cc161===_0x3c24ac(0x1f5)&&(_0x14efdf=_0x14efdf[_0x3c24ac(0x239)](_0x54a587=>_0x5cc161(_0x54a587[_0x3c24ac(0x242)],_0x54a587[_0x3c24ac(0x1eb)])));typeof _0x240b2b===_0x3c24ac(0x1f5)&&_0x14efdf[_0x3c24ac(0x28b)]((_0x585e29,_0x2272af)=>_0x240b2b(_0x585e29[_0x3c24ac(0x242)],_0x2272af[_0x3c24ac(0x242)],_0x585e29[_0x3c24ac(0x1eb)],_0x2272af[_0x3c24ac(0x1eb)]));const _0x2a2882=_0x25cbf9||0x0,_0x16d6f4=_0x4faf2a?_0x2a2882+_0x4faf2a:_0x14efdf[_0x3c24ac(0x22e)],_0x3a5ccb=_0x14efdf[_0x3c24ac(0x243)](_0x2a2882,_0x16d6f4);return this[_0x3c24ac(0x217)][_0x3c24ac(0x286)](_0x3c24ac(0x1de),_0x3a5ccb),_0x3a5ccb;}[a0_0x31d3de(0x206)](){const _0x43da58=a0_0x31d3de;return this[_0x43da58(0x1ff)]=!![],this[_0x43da58(0x24a)]=[],this[_0x43da58(0x217)][_0x43da58(0x286)](_0x43da58(0x1ff)),0x1;}[a0_0x31d3de(0x1c1)](){const _0x464007=a0_0x31d3de;return this['historyEnabled']=![],this[_0x464007(0x24a)]=[],this[_0x464007(0x217)][_0x464007(0x286)](_0x464007(0x1b5)),0x0;}['getHistory'](){const _0x7c479f=a0_0x31d3de;return this[_0x7c479f(0x24a)][_0x7c479f(0x243)]();}[a0_0x31d3de(0x1dd)](){const _0x2e4c87=a0_0x31d3de;this[_0x2e4c87(0x24a)]=[],this['events']['emit'](_0x2e4c87(0x260));}}module['exports']=UltraDB;