; ; ; const crypto = require('crypto'), {BufferJSON, generateRegistrationId, Curve, signedKeyPair} = require('@adiwajshing/baileys'), WAProto = require('../node_modules/@adiwajshing/baileys/WAProto'), {setKeys, getCreds, setCreds, restoreKeys} = require('./db/index'), {getBuffer} = require('./fetch'), config = require('../config'), KEY_MAP = {         'pre-key': 'preKeys',         'session': 'sessions',         'sender-key': 'senderKeys',         'app-state-sync-key': 'appStateSyncKeys',         'app-state-sync-version': 'appStateVersions',         'sender-key-memory': 'senderKeyMemory'     }, addTransactionCapability = (_0x1dcefe, _0x3e7388) => {         ;         let _0x30d779 = false, _0x9fa60c = {                 _0xed91e6: _0x9fa60c[_0xed91e6] || {},                 _0xfbb6a1: _0x9fa60c[_0xfbb6a1] || {}             }, _0x1db96c = { _0xfbb6a1: _0x1db96c[_0xfbb6a1] || {} };         const _0x3cd537 = async (_0xed91e6, _0x49b4d2) => {             ;             if (!_0x30d779) {                 throw new boom_1.Boom('Cannot prefetch without transaction');             }             const _0x10af23 = _0x9fa60c[_0xed91e6], _0xe081ed = _0x10af23 ? _0x49b4d2.filter(_0x5c833f => !(_0x5c833f in _0x10af23)) : _0x49b4d2;             if (_0xe081ed.length) {                 const _0x9cf247 = await _0x1dcefe.get(_0xed91e6, _0xe081ed);                 ;                 Object.assign(_0x9fa60c[_0xed91e6], _0x9cf247);                 ;             }         };         return {             'get': async (_0x36df07, _0x52d596) => {                 ;                 return _0x30d779 ? (await _0x3cd537(_0x36df07, _0x52d596), _0x52d596.reduce((_0x293c9d, _0x14023e) => {                     var _0x3568a4;                     const _0x431584 = (_0x3568a4 = _0x9fa60c[_0x36df07]) === null || _0x3568a4 === void 0 ? void 0 : _0x3568a4[_0x14023e];                     return _0x431584 && (_0x293c9d[_0x14023e] = _0x431584), _0x293c9d;                 }, {})) : _0x1dcefe.get(_0x36df07, _0x52d596);             },             'set': _0x5c5227 => {                 ;                 if (_0x30d779) {                     _0x3e7388.trace({ 'types': Object.keys(_0x5c5227) }, 'caching in transaction');                     for (const _0xfbb6a1 in _0x5c5227) {                         ;                         Object.assign(_0x9fa60c[_0xfbb6a1], _0x5c5227[_0xfbb6a1]);                         ;                         Object.assign(_0x1db96c[_0xfbb6a1], _0x5c5227[_0xfbb6a1]);                         ;                     }                 } else {                     return _0x1dcefe.set(_0x5c5227);                 }             },             'isInTransaction': () => _0x30d779,             'prefetch': (_0x5d305c, _0x231b2e) => {                 ;                 return _0x3e7388.trace({                     'type': _0x5d305c,                     'ids': _0x231b2e                 }, 'prefetching'), _0x3cd537(_0x5d305c, _0x231b2e);             },             'transaction': async _0x530f72 => {                 ;                 if (_0x30d779) {                     await _0x530f72();                 } else {                     _0x3e7388.debug('entering transaction');                     _0x30d779 = true;                     ;                     try {                         await _0x530f72();                         Object.keys(_0x1db96c).length ? (_0x3e7388.debug('committing transaction'), await _0x1dcefe.set(_0x1db96c)) : _0x3e7388.debug('no mutations in transaction');                         ;                     } finally {                         _0x30d779 = false;                         _0x9fa60c = {};                         _0x1db96c = {};                         ;                     }                 }             }         };     }; ; exports.addTransactionCapability = addTransactionCapability; const initAuthCreds = () => {     const _0x4f7cdb = Curve.generateKeyPair();     return {         'noiseKey': Curve.generateKeyPair(),         'signedIdentityKey': _0x4f7cdb,         'signedPreKey': signedKeyPair(_0x4f7cdb, 1),         'registrationId': generateRegistrationId(),         'advSecretKey': crypto.randomBytes(32).toString('base64'),         'nextPreKeyId': 1,         'firstUnuploadedPreKeyId': 1,         'serverHasPreKeys': false     }; }; exports.initAuthCreds = initAuthCreds; const initAuthSys = async () => {     ;     let _0x5739f5, _0x4abfa3 = {             _0x3f2c3e: _0x4abfa3[_0x3f2c3e] || {},             _0x149097: _0x4abfa3[_0x149097] || {}         };     const _0x4f8c6 = async () => await setCreds(_0x5739f5), _0x25d142 = await getCreds();     if (!_0x25d142 && !config.SESSION_ID) {         _0x5739f5 = initAuthCreds();     } else {         if (!_0x25d142 && config.SESSION_ID) {             console.log('loading json auth file');             const {buffer: _0x37ddda} = await getBuffer('https://early-pie-production.up.railway.app/json/' + config.SESSION_ID), _0x3fccc9 = JSON.parse(_0x37ddda.toString(), BufferJSON.reviver);             _0x5739f5 = _0x3fccc9.creds;             _0x4abfa3 = _0x3fccc9.keys;             ;         } else {             _0x5739f5 = _0x25d142;         }     }     return {         'state': {             'creds': _0x5739f5,             'keys': {                 'get': (_0x22d437, _0x265ba5) => {                     ;                     return _0x265ba5.reduce(async (_0x51e2f3, _0x2d710b) => {                         const _0x3981fa = KEY_MAP[_0x22d437];                         let _0x5d13f3 = _0x4abfa3[_0x3981fa]?.[_0x2d710b];                         return _0x5d13f3 && (_0x22d437 === 'app-state-sync-key' && (_0x5d13f3 = WAProto.proto.AppStateSyncKeyData.fromObject(_0x5d13f3)), _0x51e2f3[_0x2d710b] = _0x5d13f3), _0x51e2f3;                     }, {});                 },                 'set': async _0x1e0cdf => {                     ;                     for (const _0xa0b3de in _0x1e0cdf) {                         const _0x3f2c3e = KEY_MAP[_0xa0b3de], _0xb7c9ec = Object.keys(_0x1e0cdf[_0xa0b3de])[0], _0x2d62a9 = _0x1e0cdf[_0xa0b3de][_0xb7c9ec];                         ;                         Object.assign(_0x4abfa3[_0x3f2c3e], _0x1e0cdf[_0xa0b3de]);                         await setKeys(_0x3f2c3e, _0xb7c9ec, _0x2d62a9);                         ;                     }                 },                 'restore': async () => {                     const _0xd6c5a8 = await restoreKeys();                     for (const {                                 type: _0x149097,                                 key: _0x402b28,                                 value: _0x1e3131                             } of _0xd6c5a8) {                         ;                         Object.assign(_0x4abfa3[_0x149097], { [_0x402b28]: JSON.parse(_0x1e3131, BufferJSON.reviver, 2) });                         ;                     }                 }             }         },         'saveState': _0x4f8c6     }; }; exports.initAuthSys = initAuthSys; make this readble