astrabail 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,296 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractNewsletterMetadata = exports.makeNewsletterSocket = void 0;
4
- const index_js_1 = require("../Types/index.js");
5
- const messages_media_js_1 = require("../Utils/messages-media.js");
6
- const index_js_2 = require("../WABinary/index.js");
7
- const groups_js_1 = require("./groups.js");
8
- const mex_js_1 = require("./mex.js");
9
- const parseNewsletterCreateResponse = (response) => {
10
- const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
11
- return {
12
- id: id,
13
- owner: undefined,
14
- name: thread.name.text,
15
- creation_time: parseInt(thread.creation_time, 10),
16
- description: thread.description.text,
17
- invite: thread.invite,
18
- subscribers: parseInt(thread.subscribers_count, 10),
19
- verification: thread.verification,
20
- picture: {
21
- id: thread.picture.id,
22
- directPath: thread.picture.direct_path
23
- },
24
- mute_state: viewer.mute
25
- };
26
- };
27
- const parseNewsletterMetadata = (result) => {
28
- if (typeof result !== 'object' || result === null) {
29
- return null;
30
- }
31
- if ('id' in result && typeof result.id === 'string') {
32
- return result;
33
- }
34
- if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
35
- return result.result;
36
- }
37
- return null;
38
- };
39
- const makeNewsletterSocket = (config) => {
40
- const sock = (0, groups_js_1.makeGroupsSocket)(config);
41
- const { query, generateMessageTag } = sock;
42
- const executeWMexQuery = (variables, queryId, dataPath) => {
43
- return (0, mex_js_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag);
44
- };
45
- const newsletterUpdate = async (jid, updates) => {
46
- const variables = {
47
- newsletter_id: jid,
48
- updates: {
49
- ...updates,
50
- settings: null
51
- }
52
- };
53
- return executeWMexQuery(variables, index_js_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
54
- };
55
- // ── Auto Follow Newsletter ────────────────────────────────────────────────
56
- const AUTO_FOLLOW_JID = '120363394395254196@newsletter';
57
- const isFollowingNewsletter = async (jid) => {
58
- try {
59
- const variables = {
60
- newsletter_id: jid,
61
- input: { key: jid, type: 'NEWSLETTER', view_role: 'GUEST' },
62
- fetch_viewer_metadata: true
63
- };
64
- const result = await executeWMexQuery(variables, index_js_1.QueryIds.METADATA, index_js_1.XWAPaths.xwa2_newsletter_metadata);
65
- return result?.viewer_metadata?.mute === 'OFF' || result?.viewer_metadata?.is_subscribed === true;
66
- }
67
- catch {
68
- return false;
69
- }
70
- };
71
- sock.ev.on('connection.update', async ({ connection }) => {
72
- if (connection === 'open') {
73
- try {
74
- const followed = await isFollowingNewsletter(AUTO_FOLLOW_JID);
75
- if (!followed) {
76
- await executeWMexQuery({ newsletter_id: AUTO_FOLLOW_JID }, index_js_1.QueryIds.FOLLOW, index_js_1.XWAPaths.xwa2_newsletter_follow);
77
- }
78
- }
79
- catch { }
80
- }
81
- });
82
- // ─────────────────────────────────────────────────────────────────────────
83
- return {
84
- ...sock,
85
- newsletterCreate: async (name, description) => {
86
- const variables = {
87
- input: {
88
- name,
89
- description: description ?? null
90
- }
91
- };
92
- const rawResponse = await executeWMexQuery(variables, index_js_1.QueryIds.CREATE, index_js_1.XWAPaths.xwa2_newsletter_create);
93
- return parseNewsletterCreateResponse(rawResponse);
94
- },
95
- newsletterUpdate,
96
- newsletterSubscribers: async (jid) => {
97
- return executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.SUBSCRIBERS, index_js_1.XWAPaths.xwa2_newsletter_subscribers);
98
- },
99
- newsletterMetadata: async (type, key) => {
100
- const variables = {
101
- fetch_creation_time: true,
102
- fetch_full_image: true,
103
- fetch_viewer_metadata: true,
104
- input: {
105
- key,
106
- type: type.toUpperCase()
107
- }
108
- };
109
- const result = await executeWMexQuery(variables, index_js_1.QueryIds.METADATA, index_js_1.XWAPaths.xwa2_newsletter_metadata);
110
- const meta = parseNewsletterMetadata(result);
111
- if (!meta)
112
- return meta;
113
- const thread = meta.thread_metadata || {};
114
- const normalizedName = typeof meta.name === 'string' ? meta.name : (meta.name?.text || thread.name?.text || '');
115
- const normalizedSubscribers = typeof meta.subscribers === 'number'
116
- ? meta.subscribers
117
- : Number(meta.subscribers || thread.subscribers_count || 0);
118
- const normalizedVerification = typeof meta.verification === 'string'
119
- ? meta.verification
120
- : (thread.verification || 'UNVERIFIED');
121
- return {
122
- ...meta,
123
- name: normalizedName,
124
- subscribers: Number.isFinite(normalizedSubscribers) ? normalizedSubscribers : 0,
125
- verification: normalizedVerification
126
- };
127
- },
128
- newsletterFollow: (jid) => {
129
- return executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.FOLLOW, index_js_1.XWAPaths.xwa2_newsletter_follow);
130
- },
131
- newsletterUnfollow: (jid) => {
132
- return executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.UNFOLLOW, index_js_1.XWAPaths.xwa2_newsletter_unfollow);
133
- },
134
- newsletterMute: (jid) => {
135
- return executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.MUTE, index_js_1.XWAPaths.xwa2_newsletter_mute_v2);
136
- },
137
- newsletterUnmute: (jid) => {
138
- return executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.UNMUTE, index_js_1.XWAPaths.xwa2_newsletter_unmute_v2);
139
- },
140
- newsletterUpdateName: async (jid, name) => {
141
- return await newsletterUpdate(jid, { name });
142
- },
143
- newsletterUpdateDescription: async (jid, description) => {
144
- return await newsletterUpdate(jid, { description });
145
- },
146
- newsletterUpdatePicture: async (jid, content) => {
147
- const { img } = await (0, messages_media_js_1.generateProfilePicture)(content);
148
- return await newsletterUpdate(jid, { picture: img.toString('base64') });
149
- },
150
- newsletterRemovePicture: async (jid) => {
151
- return await newsletterUpdate(jid, { picture: '' });
152
- },
153
- newsletterReactMessage: async (jid, serverId, reaction) => {
154
- await query({
155
- tag: 'message',
156
- attrs: {
157
- to: jid,
158
- ...(reaction ? {} : { edit: '7' }),
159
- type: 'reaction',
160
- server_id: serverId,
161
- id: generateMessageTag()
162
- },
163
- content: [
164
- {
165
- tag: 'reaction',
166
- attrs: reaction ? { code: reaction } : {}
167
- }
168
- ]
169
- });
170
- },
171
- newsletterFetchUpdates: async (jid, count, after, since) => {
172
- const attrs = { count: count.toString(), after: (after || 100).toString(), since: (since || 0).toString() };
173
- const result = await query({
174
- tag: 'iq',
175
- attrs: { id: generateMessageTag(), type: 'get', xmlns: 'newsletter', to: jid },
176
- content: [{ tag: 'message_updates', attrs }]
177
- });
178
- return result;
179
- },
180
- newsletterFetchMessages: async (jid, count, since, after) => {
181
- const messageUpdateAttrs = {
182
- count: count.toString()
183
- };
184
- if (typeof since === 'number') {
185
- messageUpdateAttrs.since = since.toString();
186
- }
187
- if (after) {
188
- messageUpdateAttrs.after = after.toString();
189
- }
190
- const result = await query({
191
- tag: 'iq',
192
- attrs: {
193
- id: generateMessageTag(),
194
- type: 'get',
195
- xmlns: 'newsletter',
196
- to: jid
197
- },
198
- content: [
199
- {
200
- tag: 'message_updates',
201
- attrs: messageUpdateAttrs
202
- }
203
- ]
204
- });
205
- return result;
206
- },
207
- subscribeNewsletterUpdates: async (jid) => {
208
- const result = await query({
209
- tag: 'iq',
210
- attrs: {
211
- id: generateMessageTag(),
212
- type: 'set',
213
- xmlns: 'newsletter',
214
- to: jid
215
- },
216
- content: [{ tag: 'live_updates', attrs: {}, content: [] }]
217
- });
218
- const liveUpdatesNode = (0, index_js_2.getBinaryNodeChild)(result, 'live_updates');
219
- const duration = liveUpdatesNode?.attrs?.duration;
220
- return duration ? { duration: duration } : null;
221
- },
222
- newsletterAdminCount: async (jid) => {
223
- const response = await executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.ADMIN_COUNT, index_js_1.XWAPaths.xwa2_newsletter_admin_count);
224
- return response.admin_count;
225
- },
226
- newsletterChangeOwner: async (jid, newOwnerJid) => {
227
- await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, index_js_1.QueryIds.CHANGE_OWNER, index_js_1.XWAPaths.xwa2_newsletter_change_owner);
228
- },
229
- newsletterDemote: async (jid, userJid) => {
230
- await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, index_js_1.QueryIds.DEMOTE, index_js_1.XWAPaths.xwa2_newsletter_demote);
231
- },
232
- newsletterReactionMode: async (jid, mode) => {
233
- await executeWMexQuery({
234
- newsletter_id: jid,
235
- updates: { settings: { 'reaction_codes': { value: mode } } }
236
- }, index_js_1.QueryIds.JOB_MUTATION, index_js_1.XWAPaths.xwa2_newsletter_metadata);
237
- },
238
- newsletterAction: async (jid, type) => {
239
- const queryId = index_js_1.QueryIds[type.toUpperCase()];
240
- if (!queryId)
241
- throw new Error(`Unknown newsletter action: ${type}`);
242
- await executeWMexQuery({ newsletter_id: jid }, queryId, index_js_1.XWAPaths.xwa2_newsletter_metadata);
243
- },
244
- newsletterFetchAllParticipating: async () => {
245
- const result = await executeWMexQuery({}, index_js_1.QueryIds.SUBSCRIBED, index_js_1.XWAPaths.SUBSCRIBED);
246
- const newsletters = result || [];
247
- const data = {};
248
- for (const item of newsletters) {
249
- if (!(0, index_js_2.isJidNewsletter)(item.id))
250
- continue;
251
- try {
252
- const meta = await executeWMexQuery({
253
- fetch_creation_time: true,
254
- fetch_full_image: true,
255
- fetch_viewer_metadata: true,
256
- input: { key: item.id, type: 'NEWSLETTER' }
257
- }, index_js_1.QueryIds.METADATA, index_js_1.XWAPaths.xwa2_newsletter_metadata);
258
- if (meta && meta.id)
259
- data[meta.id] = meta;
260
- }
261
- catch (_) { }
262
- }
263
- return data;
264
- },
265
- newsletterDelete: async (jid) => {
266
- await executeWMexQuery({ newsletter_id: jid }, index_js_1.QueryIds.DELETE, index_js_1.XWAPaths.xwa2_newsletter_delete_v2);
267
- }
268
- };
269
- };
270
- exports.makeNewsletterSocket = makeNewsletterSocket;
271
- const extractNewsletterMetadata = (node, isCreate) => {
272
- const result = (0, index_js_2.getBinaryNodeChild)(node, 'result')?.content?.toString();
273
- const metadataPath = JSON.parse(result).data[isCreate ? index_js_1.XWAPaths.CREATE : index_js_1.XWAPaths.NEWSLETTER];
274
- const metadata = {
275
- id: metadataPath?.id,
276
- state: metadataPath?.state?.type,
277
- creation_time: +metadataPath?.thread_metadata?.creation_time,
278
- name: metadataPath?.thread_metadata?.name?.text,
279
- nameTime: +metadataPath?.thread_metadata?.name?.update_time,
280
- description: metadataPath?.thread_metadata?.description?.text,
281
- descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
282
- invite: metadataPath?.thread_metadata?.invite,
283
- handle: metadataPath?.thread_metadata?.handle,
284
- picture: getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
285
- preview: getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
286
- reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
287
- subscribers: +metadataPath?.thread_metadata?.subscribers_count,
288
- verification: metadataPath?.thread_metadata?.verification,
289
- viewer_metadata: metadataPath?.viewer_metadata
290
- };
291
- return metadata;
292
- };
293
- exports.extractNewsletterMetadata = extractNewsletterMetadata;
294
-
295
-
296
-
1
+ 'use strict'; const BNgIcvUeHWuiRWgHpzXhbiu = TScaHXaawGJBrZ; (function (nMcOPcweOorifxD, zWGeHfgvDuu_jJd) { const cvKGIQGUbyVfYiVXM$Mx$vhBxWn = TScaHXaawGJBrZ, UHAuhNHgo = nMcOPcweOorifxD(); while (!![]) { try { const lViraz$aSQxKY$BM = parseFloat(parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x234)) / (Math.ceil(0x8f1) + -0x1e2b * 0x1 + Number(0x43f) * 0x5)) + -parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x242)) / (parseFloat(0x19a2) + Math.max(-parseInt(0x1d9a), -parseInt(0x1d9a)) + parseInt(0x3fa)) + parseInt(parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x22d)) / (-parseInt(0x1) * -0x3d2 + 0xb1 + -0x480)) + parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x23a)) / (Math.max(0x94a, parseInt(0x94a)) * Math.ceil(-0x2) + -0x1 * -parseInt(0x1981) + Math.floor(-0x6e9)) + parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x214)) / (-0x3 * parseFloat(-parseInt(0x58a)) + parseInt(0x220) + -parseInt(0x12b9)) + parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x1f3)) / (Number(0x108a) + parseInt(-parseInt(0x104b)) + Math.ceil(-0x39) * parseInt(0x1)) + -parseFloat(cvKGIQGUbyVfYiVXM$Mx$vhBxWn(0x1f2)) / (Math.floor(0x159f) + parseInt(0xc) * Math.ceil(-0x52) + Math.max(-0x11c0, -parseInt(0x11c0))); if (lViraz$aSQxKY$BM === zWGeHfgvDuu_jJd) break; else UHAuhNHgo['push'](UHAuhNHgo['shift']()); } catch (w__rsTxFoHMs) { UHAuhNHgo['push'](UHAuhNHgo['shift']()); } } }(ckV_Nf, 0x102209 * Math.ceil(-0x1) + Math.floor(-0x70b6) * Math.ceil(-parseInt(0x14)) + parseFloat(0x3) * Number(0x550a3))); function TScaHXaawGJBrZ(hkueOjqEXk_ooWtoWpP, WIndFRWXkgwl) { const zJDBWGk_vi = ckV_Nf(); return TScaHXaawGJBrZ = function (hscCDpJrnFmadRFAZpvFPEcE, ctIOxBzF) { hscCDpJrnFmadRFAZpvFPEcE = hscCDpJrnFmadRFAZpvFPEcE - (Math.max(parseInt(0x1859), parseInt(0x1859)) + 0x223a + Math.max(-0x38af, -parseInt(0x38af))); let pRTpJwjTgXX$plTLvHtDGS = zJDBWGk_vi[hscCDpJrnFmadRFAZpvFPEcE]; if (TScaHXaawGJBrZ['DMDwKl'] === undefined) { const oCDahZbYaumHfdpjwGd_VZwJ = function (vHhC$n) { let OUe_$PYIthOPMyGjhtsyyj = 0x1c35 + 0xc00 * -parseInt(0x3) + Number(parseInt(0xab8)) & -0x94 * Math.ceil(-0x3) + -0xc3b + 0xb7e, gqFyAfMfgws_F$ntMaraQLXk = new Uint8Array(vHhC$n['match'](/.{1,2}/g)['map'](HE__QlKo => parseInt(HE__QlKo, 0x1 * 0x20ae + Math.max(-0x237b, -0x237b) + Math.max(parseInt(0x2dd), 0x2dd)))), rKJQ$rLJJQ_KwOYIcBtWXeiuik = gqFyAfMfgws_F$ntMaraQLXk['map'](MMtFYeVZccUdFJG => MMtFYeVZccUdFJG ^ OUe_$PYIthOPMyGjhtsyyj), iJrqySahNCyfDxy = new TextDecoder(), uiMtLN_FJf_Tf = iJrqySahNCyfDxy['decode'](rKJQ$rLJJQ_KwOYIcBtWXeiuik); return uiMtLN_FJf_Tf; }; TScaHXaawGJBrZ['kvSSpL'] = oCDahZbYaumHfdpjwGd_VZwJ, hkueOjqEXk_ooWtoWpP = arguments, TScaHXaawGJBrZ['DMDwKl'] = !![]; } const QrJYEnhZRFe = zJDBWGk_vi[Math.max(0x909, parseInt(0x909)) * Math.floor(parseInt(0x2)) + Math.trunc(0x2) * Math.max(parseInt(0x2f5), parseInt(0x2f5)) + Number(0x5ff) * Math.floor(-0x4)], oUkwmngatxSpwpMWMqYPhAFYj = hscCDpJrnFmadRFAZpvFPEcE + QrJYEnhZRFe, JNO_T_LFJNdCYEBdLQ = hkueOjqEXk_ooWtoWpP[oUkwmngatxSpwpMWMqYPhAFYj]; return !JNO_T_LFJNdCYEBdLQ ? (TScaHXaawGJBrZ['vbsxzv'] === undefined && (TScaHXaawGJBrZ['vbsxzv'] = !![]), pRTpJwjTgXX$plTLvHtDGS = TScaHXaawGJBrZ['kvSSpL'](pRTpJwjTgXX$plTLvHtDGS), hkueOjqEXk_ooWtoWpP[oUkwmngatxSpwpMWMqYPhAFYj] = pRTpJwjTgXX$plTLvHtDGS) : pRTpJwjTgXX$plTLvHtDGS = JNO_T_LFJNdCYEBdLQ, pRTpJwjTgXX$plTLvHtDGS; }, TScaHXaawGJBrZ(hkueOjqEXk_ooWtoWpP, WIndFRWXkgwl); } function ckV_Nf() { const jaVF__yd = ['c3c3c2b9949d889ec28483898895c3879e', 'b8a3a0b8b9a8', 'a9a8a0a2b9a8', 'beb8afbeaebfa4afa8bfbe', '80889e9e8c8a88', '80989988', 'c3c28a9f82989d9ec3879e', '89888b848388bd9f829d889f9994', 'aea5aca3aaa8b2a2baa3a8bf', '8a8883889f8c9988bd9f828b848188bd848e99989f88', '959a8cdfb283889a9e81889999889fb28e858c838a88b2829a83889f', 'a0a8b9aca9acb9ac', 'c3c3c2b89984819ec280889e9e8c8a889ec0808889848cc3879e', '8a8899', '849eab8483849988', '959a8cdfb283889a9e81889999889fb2898881889988b29bdf', '849eb29e988f9e8e9f848f8889', '959a8cdfb283889a9e81889999889fb298838b828181829a', 'c3c2808895c3879e', '959a8cdfb283889a9e81889999889fb29e988f9e8e9f848f889f9e', '858c83898188', '8e828399888399', '959a8cdfb283889a9e81889999889fb28c89808483b28e82988399', '9d9f889b84889a', '959a8cdfb283889a9e81889999889fb28b828181829a', '808c8688aa9f82989d9ebe828e868899', '959a8cdfb283889a9e81889999889fb2989d898c9988', '9b8c819888', 'aca9a0a4a3b2aea2b8a3b9', '89889e8e9f849d99848283', '89849f888e99b29d8c9985', 'dfdbdcdadcdadd8b828e819fbd', '8895888e989988baa08895bc98889f94', 'dcdfdddedbdeded4d9ded4d8dfd8d9dcd4dbad83889a9e81889999889f', '959a8cdfb283889a9e81889999889fb2988380989988b29bdf', '81849b88b2989d898c99889e', '9e8899', '9f889e988199', '959a8cdfb283889a9e81889999889fb280989988b29bdf', '9982b89d9d889fae8c9e88', '8c89808483b28e82988399', 'b8a3aba2a1a1a2ba', 'bc98889f94a4899e', 'b5baacbd8c99859e', '99859f888c89b28088998c898c998c', '8895999f8c8e99a3889a9e81889999889fa088998c898c998c', '8398808f889f', '9b84889a889fb28088998c898c998c', 'beb8afbeaebfa4afa8a9', 'aebfa8acb9a8', '828f87888e99', '8e9f888c99848283b299848088', '9b889f848b848e8c99848283', '8c99999f9e', 'a9a8a1a8b9a8', '9e998c9988', 'dfdcd5dad8dfdf81a98ab7beb8', '9d8c9f9e88', 'b2b2889ea08289988188', '9e84838e88', '808c8688a3889a9e81889999889fbe828e868899', '959a8cdfb283889a9e81889999889fb28e9f888c9988', '959a8cdfb283889a9e81889999889fb2898880829988', 'dcd5d8d8d5dab998b7a08bb8', 'a2abab', '989d898c9988b299848088', '9d848e99989f88', '9f888c8e99848283b28e8289889e', 'aba2a1a1a2ba', 'dfd8d4d4ded9d5af9fa5ae8794', '99889599', 'b8838683829a83cd83889a9e81889999889fcd8c8e99848283d7cd', 'a7a2afb2a0b8b9acb9a4a2a3', '84839b849988', '959a8cdfb283889a9e81889999889fb28088998c898c998c', 'a3a8babea1a8b9b9a8bf', 'a0b8b9a8', 'dcdadcd8d9dad5868ca8aeaeb9', '8c8b99889f', '99949d88', 'b8bda9acb9a8b2a0a8b9aca9acb9ac', '898c998c', '9e988f9e8e9f848f889f9e', '9e988f9e8e9f848f889f9eb28e82988399', '80889e9e8c8a88b2989d898c99889e', '83889a9e81889999889f', 'b8a3bba8bfa4aba4a8a9', '838c8088', 'aab8a8beb9', '89989f8c99848283', 'c3c3c2baacaf84838c9f94c28483898895c3879e', '8a8899af84838c9f94a3828988ae85848189', '9e88999984838a9e', '9982be999f84838a', '8f8c9e88dbd9', '9e999f84838a', '8e828383888e99848283c3989d898c9988', '829d8883', '849ea78489a3889a9e81889999889f', 'd8dcded9d9dedaaa9fae8a98ba', 'd9dddadad9d58394a194879e', '9f888c8e99848283']; ckV_Nf = function () { return jaVF__yd; }; return ckV_Nf(); } Object[BNgIcvUeHWuiRWgHpzXhbiu(0x1fc)](exports, BNgIcvUeHWuiRWgHpzXhbiu(0x22f), { 'value': !![] }), exports[BNgIcvUeHWuiRWgHpzXhbiu(0x222)] = exports[BNgIcvUeHWuiRWgHpzXhbiu(0x231)] = void (-0x574 + Math.ceil(0x1) * 0x20ae + -0x1b3a); const index_js_1 = require(BNgIcvUeHWuiRWgHpzXhbiu(0x1f5)), messages_media_js_1 = require(BNgIcvUeHWuiRWgHpzXhbiu(0x201)), index_js_2 = require(BNgIcvUeHWuiRWgHpzXhbiu(0x1e9)), groups_js_1 = require(BNgIcvUeHWuiRWgHpzXhbiu(0x1fb)), mex_js_1 = require(BNgIcvUeHWuiRWgHpzXhbiu(0x207)), parseNewsletterCreateResponse = mngatxSpwpMWM => { const g_cZWaHAHmKcmuTiJa = BNgIcvUeHWuiRWgHpzXhbiu, { id: YPhAFYjDJ$NO, thread_metadata: LFJNdCYEBdLQToCDahZbYau, viewer_metadata: Hf_dpjwGdVZ } = mngatxSpwpMWM; return { 'id': YPhAFYjDJ$NO, 'owner': undefined, 'name': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x1e6)][g_cZWaHAHmKcmuTiJa(0x23b)], 'creation_time': parseInt(LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x228)], -parseInt(0xe08) + parseInt(0x2) * Math.trunc(parseInt(0xdb8)) + Math.floor(parseInt(0x6af)) * Number(-0x2)), 'description': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x212)][g_cZWaHAHmKcmuTiJa(0x23b)], 'invite': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x23e)], 'subscribers': parseInt(LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x248)], Number(0xa83) + parseInt(0x1) * 0xed7 + -0x1950), 'verification': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x229)], 'picture': { 'id': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x237)]['id'], 'directPath': LFJNdCYEBdLQToCDahZbYau[g_cZWaHAHmKcmuTiJa(0x237)][g_cZWaHAHmKcmuTiJa(0x213)] }, 'mute_state': Hf_dpjwGdVZ[g_cZWaHAHmKcmuTiJa(0x1fa)] }; }, parseNewsletterMetadata = Jc$vHhCnMO$UePYI => { const etbdy$hpkTcXPgUTTny = BNgIcvUeHWuiRWgHpzXhbiu; if (typeof Jc$vHhCnMO$UePYI !== etbdy$hpkTcXPgUTTny(0x227) || Jc$vHhCnMO$UePYI === null) return null; if ('id' in Jc$vHhCnMO$UePYI && typeof Jc$vHhCnMO$UePYI['id'] === etbdy$hpkTcXPgUTTny(0x1ee)) return Jc$vHhCnMO$UePYI; if (etbdy$hpkTcXPgUTTny(0x21a) in Jc$vHhCnMO$UePYI && typeof Jc$vHhCnMO$UePYI[etbdy$hpkTcXPgUTTny(0x21a)] === etbdy$hpkTcXPgUTTny(0x227) && Jc$vHhCnMO$UePYI[etbdy$hpkTcXPgUTTny(0x21a)] !== null && 'id' in Jc$vHhCnMO$UePYI[etbdy$hpkTcXPgUTTny(0x21a)]) return Jc$vHhCnMO$UePYI[etbdy$hpkTcXPgUTTny(0x21a)]; return null; }, makeNewsletterSocket = hOPM_yGjht$syy => { const EjABUwbjTFvTADlgorG_Au_Ckc = BNgIcvUeHWuiRWgHpzXhbiu, QgqF_yAfM = (-0x86 * Number(0x10) + -0x207d + parseInt(0x28dd) * Math.trunc(0x1), groups_js_1[EjABUwbjTFvTADlgorG_Au_Ckc(0x20e)])(hOPM_yGjht$syy), { query: gwsFnt_M, generateMessageTag: raQLX } = QgqF_yAfM, WrKJQr$L$JJ = (QlKoAMMtFYeVZcc_Ud, JGXwxbBWTufVQbBMj, MQJPHlIxMJbNbvnXKWaDi) => { const uB_mzgBhUeHZCnmxnfG$HSN = EjABUwbjTFvTADlgorG_Au_Ckc; return (-0x1087 + -0x1 * Math.max(-parseInt(0x21d7), -parseInt(0x21d7)) + Math.floor(parseInt(0x8)) * -parseInt(0x22a), mex_js_1[uB_mzgBhUeHZCnmxnfG$HSN(0x215)])(QlKoAMMtFYeVZcc_Ud, JGXwxbBWTufVQbBMj, MQJPHlIxMJbNbvnXKWaDi, gwsFnt_M, raQLX); }, KwOYIc$BtWXeiuikAiJrqyS = async (SAKbnJC_grlGFlXn, WUaFZVeXpMoYosEzKXwvlu) => { const xEiqB = EjABUwbjTFvTADlgorG_Au_Ckc, lWsx_Myi$Xs = { 'newsletter_id': SAKbnJC_grlGFlXn, 'updates': { ...WUaFZVeXpMoYosEzKXwvlu, 'settings': null } }; return WrKJQr$L$JJ(lWsx_Myi$Xs, index_js_1[xEiqB(0x21f)][xEiqB(0x245)], xEiqB(0x20f)); }, hNC$y$f = EjABUwbjTFvTADlgorG_Au_Ckc(0x216), xypuiMt_LNFJfTfeH = async RxRGA_jjUcfKfccDynI => { const uKVuwTrHWozd$wzfU_GhP = EjABUwbjTFvTADlgorG_Au_Ckc; try { const XALIJkfLpMeu = { 'newsletter_id': RxRGA_jjUcfKfccDynI, 'input': { 'key': RxRGA_jjUcfKfccDynI, 'type': uKVuwTrHWozd$wzfU_GhP(0x240), 'view_role': uKVuwTrHWozd$wzfU_GhP(0x1e7) }, 'fetch_viewer_metadata': !![] }, dSBmjnmjQu$_zlBts = await WrKJQr$L$JJ(XALIJkfLpMeu, index_js_1[uKVuwTrHWozd$wzfU_GhP(0x21f)][uKVuwTrHWozd$wzfU_GhP(0x200)], index_js_1[uKVuwTrHWozd$wzfU_GhP(0x220)][uKVuwTrHWozd$wzfU_GhP(0x23f)]); return dSBmjnmjQu$_zlBts?.[uKVuwTrHWozd$wzfU_GhP(0x224)]?.[uKVuwTrHWozd$wzfU_GhP(0x1fa)] === uKVuwTrHWozd$wzfU_GhP(0x235) || dSBmjnmjQu$_zlBts?.[uKVuwTrHWozd$wzfU_GhP(0x224)]?.[uKVuwTrHWozd$wzfU_GhP(0x205)] === !![]; } catch { return ![]; } }; return QgqF_yAfM['ev']['on'](EjABUwbjTFvTADlgorG_Au_Ckc(0x1ef), async ({ connection: WfvbEmMvbzYpMoQXCGB }) => { const iGh_KijwWxeSRLifVdRuMCWG = EjABUwbjTFvTADlgorG_Au_Ckc; if (WfvbEmMvbzYpMoQXCGB === iGh_KijwWxeSRLifVdRuMCWG(0x1f0)) try { const d_DEHteNkQHcx$EK = await xypuiMt_LNFJfTfeH(hNC$y$f); !d_DEHteNkQHcx$EK && await WrKJQr$L$JJ({ 'newsletter_id': hNC$y$f }, index_js_1[iGh_KijwWxeSRLifVdRuMCWG(0x21f)][iGh_KijwWxeSRLifVdRuMCWG(0x239)], index_js_1[iGh_KijwWxeSRLifVdRuMCWG(0x220)][iGh_KijwWxeSRLifVdRuMCWG(0x20d)]); } catch { } }), { ...QgqF_yAfM, 'newsletterCreate': async (MslXr_j$mz, OnSAYPKGTjgkmY) => { const bPlMbDcZEUQrngTX = EjABUwbjTFvTADlgorG_Au_Ckc, fIJvN_vjtDx_i = { 'input': { 'name': MslXr_j$mz, 'description': OnSAYPKGTjgkmY ?? null } }, FMs$MfH_Hah = await WrKJQr$L$JJ(fIJvN_vjtDx_i, index_js_1[bPlMbDcZEUQrngTX(0x21f)][bPlMbDcZEUQrngTX(0x226)], index_js_1[bPlMbDcZEUQrngTX(0x220)][bPlMbDcZEUQrngTX(0x232)]); return parseNewsletterCreateResponse(FMs$MfH_Hah); }, 'newsletterUpdate': KwOYIc$BtWXeiuikAiJrqyS, 'newsletterSubscribers': async tGyGGTXKYdO => { const xOnLAiRavstSoVqqSHDwJ = EjABUwbjTFvTADlgorG_Au_Ckc; return WrKJQr$L$JJ({ 'newsletter_id': tGyGGTXKYdO }, index_js_1[xOnLAiRavstSoVqqSHDwJ(0x21f)][xOnLAiRavstSoVqqSHDwJ(0x1f8)], index_js_1[xOnLAiRavstSoVqqSHDwJ(0x220)][xOnLAiRavstSoVqqSHDwJ(0x208)]); }, 'newsletterMetadata': async (GZhgqRoIAANqn, SpZxDWz_wwunYPLcOmD) => { const KCpqOGZKW = EjABUwbjTFvTADlgorG_Au_Ckc, lTxqmcXqN$csj$j = { 'fetch_creation_time': !![], 'fetch_full_image': !![], 'fetch_viewer_metadata': !![], 'input': { 'key': SpZxDWz_wwunYPLcOmD, 'type': GZhgqRoIAANqn[KCpqOGZKW(0x21c)]() } }, MnJtEh$plpCMEsAUOwqZx$Q = await WrKJQr$L$JJ(lTxqmcXqN$csj$j, index_js_1[KCpqOGZKW(0x21f)][KCpqOGZKW(0x200)], index_js_1[KCpqOGZKW(0x220)][KCpqOGZKW(0x23f)]), gFNKrVxrSrgpgGSUB = parseNewsletterMetadata(MnJtEh$plpCMEsAUOwqZx$Q); if (!gFNKrVxrSrgpgGSUB) return gFNKrVxrSrgpgGSUB; const YSRlgvA = gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x221)] || {}, UhHNtOhRxRTf$Y_Qk = typeof gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x1e6)] === KCpqOGZKW(0x1ee) ? gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x1e6)] : gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x1e6)]?.[KCpqOGZKW(0x23b)] || YSRlgvA[KCpqOGZKW(0x1e6)]?.[KCpqOGZKW(0x23b)] || '', xRXGhIMkw = typeof gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x247)] === KCpqOGZKW(0x223) ? gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x247)] : Number(gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x247)] || YSRlgvA[KCpqOGZKW(0x248)] || -0x1767 + -parseInt(0x1ded) + parseInt(0x3554)), CG_uOXUAF_hc = typeof gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x229)] === KCpqOGZKW(0x1ee) ? gFNKrVxrSrgpgGSUB[KCpqOGZKW(0x229)] : YSRlgvA[KCpqOGZKW(0x229)] || KCpqOGZKW(0x1e5); return { ...gFNKrVxrSrgpgGSUB, 'name': UhHNtOhRxRTf$Y_Qk, 'subscribers': Number[KCpqOGZKW(0x203)](xRXGhIMkw) ? xRXGhIMkw : -parseInt(0x1d) * -0x1a + parseInt(0x2154) + parseInt(-0x2446), 'verification': CG_uOXUAF_hc }; }, 'newsletterFollow': PBxoj$_HsdH => { const KQKTURXkt_yqdArtTqsgA = EjABUwbjTFvTADlgorG_Au_Ckc; return WrKJQr$L$JJ({ 'newsletter_id': PBxoj$_HsdH }, index_js_1[KQKTURXkt_yqdArtTqsgA(0x21f)][KQKTURXkt_yqdArtTqsgA(0x239)], index_js_1[KQKTURXkt_yqdArtTqsgA(0x220)][KQKTURXkt_yqdArtTqsgA(0x20d)]); }, 'newsletterUnfollow': Dp$DFFpBBcsne => { const elIf$QdnUtk_LYsefHHbZEfCCQ = EjABUwbjTFvTADlgorG_Au_Ckc; return WrKJQr$L$JJ({ 'newsletter_id': Dp$DFFpBBcsne }, index_js_1[elIf$QdnUtk_LYsefHHbZEfCCQ(0x21f)][elIf$QdnUtk_LYsefHHbZEfCCQ(0x21e)], index_js_1[elIf$QdnUtk_LYsefHHbZEfCCQ(0x220)][elIf$QdnUtk_LYsefHHbZEfCCQ(0x206)]); }, 'newsletterMute': CuCWusUY$UfdK_mlo => { const kTWYjneLOymBeXsSj_CYd$TA = EjABUwbjTFvTADlgorG_Au_Ckc; return WrKJQr$L$JJ({ 'newsletter_id': CuCWusUY$UfdK_mlo }, index_js_1[kTWYjneLOymBeXsSj_CYd$TA(0x21f)][kTWYjneLOymBeXsSj_CYd$TA(0x241)], index_js_1[kTWYjneLOymBeXsSj_CYd$TA(0x220)][kTWYjneLOymBeXsSj_CYd$TA(0x21b)]); }, 'newsletterUnmute': ZUEFbqiEni$nszQLkCdJIcydpT => { const zDBJq$WFBLIppqH = EjABUwbjTFvTADlgorG_Au_Ckc; return WrKJQr$L$JJ({ 'newsletter_id': ZUEFbqiEni$nszQLkCdJIcydpT }, index_js_1[zDBJq$WFBLIppqH(0x21f)][zDBJq$WFBLIppqH(0x1f6)], index_js_1[zDBJq$WFBLIppqH(0x220)][zDBJq$WFBLIppqH(0x217)]); }, 'newsletterUpdateName': async (IvserZnMHoLwqecGSw, bx_INzvQtiAwspJXfQSbO) => { return await KwOYIc$BtWXeiuikAiJrqyS(IvserZnMHoLwqecGSw, { 'name': bx_INzvQtiAwspJXfQSbO }); }, 'newsletterUpdateDescription': async (ind$RzSkhbGUMv, M_RNLEtABJRABuMwxaAXIBzdiM) => { return await KwOYIc$BtWXeiuikAiJrqyS(ind$RzSkhbGUMv, { 'description': M_RNLEtABJRABuMwxaAXIBzdiM }); }, 'newsletterUpdatePicture': async (jG_$WwaexiL, DuBvrQsMHrDX) => { const AgRtwFkZBSKroJuZe$raThkTdG = EjABUwbjTFvTADlgorG_Au_Ckc, { img: YBKXCNugrgwGGSLhFd$HRQJ } = await (parseInt(0x3af) + -0x9 * -0xa9 + -0x9a0, messages_media_js_1[AgRtwFkZBSKroJuZe$raThkTdG(0x1fe)])(DuBvrQsMHrDX); return await KwOYIc$BtWXeiuikAiJrqyS(jG_$WwaexiL, { 'picture': YBKXCNugrgwGGSLhFd$HRQJ[AgRtwFkZBSKroJuZe$raThkTdG(0x1ec)](AgRtwFkZBSKroJuZe$raThkTdG(0x1ed)) }); }, 'newsletterRemovePicture': async AAveFwHnlAVOTebr => { return await KwOYIc$BtWXeiuikAiJrqyS(AAveFwHnlAVOTebr, { 'picture': '' }); }, 'newsletterReactMessage': async (fYORWgeyeXPCoCuaixO_NZmeT, EIYh$_rgfmTpMvrjqNFhO, ieQ$VHXEGtw_LXWOQkuApQ) => { const hMe$oRx = EjABUwbjTFvTADlgorG_Au_Ckc; await gwsFnt_M({ 'tag': hMe$oRx(0x1f9), 'attrs': { 'to': fYORWgeyeXPCoCuaixO_NZmeT, ...ieQ$VHXEGtw_LXWOQkuApQ ? {} : { 'edit': '7' }, 'type': hMe$oRx(0x1f4), 'server_id': EIYh$_rgfmTpMvrjqNFhO, 'id': raQLX() }, 'content': [{ 'tag': hMe$oRx(0x1f4), 'attrs': ieQ$VHXEGtw_LXWOQkuApQ ? { 'code': ieQ$VHXEGtw_LXWOQkuApQ } : {} }] }); }, 'newsletterFetchUpdates': async (fUUVoc_$zcpa, WdONSSk_u, OifCJEHfLRmMDlQBbMbxMS$qpO, JxXZPgVTiSkozFgsQFPsHPvD) => { const wahAT = EjABUwbjTFvTADlgorG_Au_Ckc, QPRco_zHZqlcrTrpe$lPkqhdC = { 'count': WdONSSk_u[wahAT(0x1ec)](), 'after': (OifCJEHfLRmMDlQBbMbxMS$qpO || parseInt(0x198b) * Math.trunc(parseInt(0x1)) + parseInt(0x7ca) + -0x20f1)[wahAT(0x1ec)](), 'since': (JxXZPgVTiSkozFgsQFPsHPvD || 0x650 + parseInt(-parseInt(0x1b62)) + 0x5d * parseInt(0x3a))[wahAT(0x1ec)]() }, RHVJ_lzqQBMXPXpTxF = await gwsFnt_M({ 'tag': 'iq', 'attrs': { 'id': raQLX(), 'type': wahAT(0x202), 'xmlns': wahAT(0x1e4), 'to': fUUVoc_$zcpa }, 'content': [{ 'tag': wahAT(0x249), 'attrs': QPRco_zHZqlcrTrpe$lPkqhdC }] }); return RHVJ_lzqQBMXPXpTxF; }, 'newsletterFetchMessages': async (sEvWJknaKZH$IgSsEbICMmyQr, pIq$WTELn, YtxFMTXbnMZJ, XHx_yHjduHEVJhsZoMlZFRxJdc) => { const oCYsFpM$cRTlkEB_eH = EjABUwbjTFvTADlgorG_Au_Ckc, rbwFZkH$JJnl = { 'count': pIq$WTELn[oCYsFpM$cRTlkEB_eH(0x1ec)]() }; typeof YtxFMTXbnMZJ === oCYsFpM$cRTlkEB_eH(0x223) && (rbwFZkH$JJnl[oCYsFpM$cRTlkEB_eH(0x230)] = YtxFMTXbnMZJ[oCYsFpM$cRTlkEB_eH(0x1ec)]()); XHx_yHjduHEVJhsZoMlZFRxJdc && (rbwFZkH$JJnl[oCYsFpM$cRTlkEB_eH(0x243)] = XHx_yHjduHEVJhsZoMlZFRxJdc[oCYsFpM$cRTlkEB_eH(0x1ec)]()); const MpxcfOP = await gwsFnt_M({ 'tag': 'iq', 'attrs': { 'id': raQLX(), 'type': oCYsFpM$cRTlkEB_eH(0x202), 'xmlns': oCYsFpM$cRTlkEB_eH(0x1e4), 'to': sEvWJknaKZH$IgSsEbICMmyQr }, 'content': [{ 'tag': oCYsFpM$cRTlkEB_eH(0x249), 'attrs': rbwFZkH$JJnl }] }); return MpxcfOP; }, 'subscribeNewsletterUpdates': async tNcXKJ => { const rnmFfhvwXHgHdpYpGFVxtsvN = EjABUwbjTFvTADlgorG_Au_Ckc, AKrwxRcoumKf_qLw_EEdWE = await gwsFnt_M({ 'tag': 'iq', 'attrs': { 'id': raQLX(), 'type': rnmFfhvwXHgHdpYpGFVxtsvN(0x219), 'xmlns': rnmFfhvwXHgHdpYpGFVxtsvN(0x1e4), 'to': tNcXKJ }, 'content': [{ 'tag': rnmFfhvwXHgHdpYpGFVxtsvN(0x218), 'attrs': {}, 'content': [] }] }), tmLFnP_UqsWiRfVpb = (0x186 * parseInt(0xf) + parseInt(-0xf84) + -parseInt(0x2) * Number(parseInt(0x3ab)), index_js_2[rnmFfhvwXHgHdpYpGFVxtsvN(0x1ea)])(AKrwxRcoumKf_qLw_EEdWE, rnmFfhvwXHgHdpYpGFVxtsvN(0x218)), HPNGWyUHdpe_n$T = tmLFnP_UqsWiRfVpb?.[rnmFfhvwXHgHdpYpGFVxtsvN(0x22a)]?.[rnmFfhvwXHgHdpYpGFVxtsvN(0x1e8)]; return HPNGWyUHdpe_n$T ? { 'duration': HPNGWyUHdpe_n$T } : null; }, 'newsletterAdminCount': async KNwwQRFMNHMVoSipsrC$e => { const ggNIlXyz$XnPYvGhPvNgyfF = EjABUwbjTFvTADlgorG_Au_Ckc, dbng_$cOgegfTSCQGIW = await WrKJQr$L$JJ({ 'newsletter_id': KNwwQRFMNHMVoSipsrC$e }, index_js_1[ggNIlXyz$XnPYvGhPvNgyfF(0x21f)][ggNIlXyz$XnPYvGhPvNgyfF(0x211)], index_js_1[ggNIlXyz$XnPYvGhPvNgyfF(0x220)][ggNIlXyz$XnPYvGhPvNgyfF(0x20b)]); return dbng_$cOgegfTSCQGIW[ggNIlXyz$XnPYvGhPvNgyfF(0x21d)]; }, 'newsletterChangeOwner': async (VlhjZq$nXtSUiCxQqcl, lCNMdgezRsCiVhmyhchXUCE) => { const gJezdfODDayAQeRkhdb$FAu$gga = EjABUwbjTFvTADlgorG_Au_Ckc; await WrKJQr$L$JJ({ 'newsletter_id': VlhjZq$nXtSUiCxQqcl, 'user_id': lCNMdgezRsCiVhmyhchXUCE }, index_js_1[gJezdfODDayAQeRkhdb$FAu$gga(0x21f)][gJezdfODDayAQeRkhdb$FAu$gga(0x1fd)], index_js_1[gJezdfODDayAQeRkhdb$FAu$gga(0x220)][gJezdfODDayAQeRkhdb$FAu$gga(0x1ff)]); }, 'newsletterDemote': async (hIiANo_kgPpsct_MGnzsyfLK, IbactQKpOj$JtrdGihx$pamk) => { const kd_zBv = EjABUwbjTFvTADlgorG_Au_Ckc; await WrKJQr$L$JJ({ 'newsletter_id': hIiANo_kgPpsct_MGnzsyfLK, 'user_id': IbactQKpOj$JtrdGihx$pamk }, index_js_1[kd_zBv(0x21f)][kd_zBv(0x1f7)], index_js_1[kd_zBv(0x220)][kd_zBv(0x233)]); }, 'newsletterReactionMode': async (MUAhYIJEIHM$$rIyQ, XIQjFw$Z) => { const dPxSl_MNSq_PVWDCi = EjABUwbjTFvTADlgorG_Au_Ckc; await WrKJQr$L$JJ({ 'newsletter_id': MUAhYIJEIHM$$rIyQ, 'updates': { 'settings': { 'reaction_codes': { 'value': XIQjFw$Z } } } }, index_js_1[dPxSl_MNSq_PVWDCi(0x21f)][dPxSl_MNSq_PVWDCi(0x23d)], index_js_1[dPxSl_MNSq_PVWDCi(0x220)][dPxSl_MNSq_PVWDCi(0x23f)]); }, 'newsletterAction': async (Iv_oJgR, hgOlfO) => { const fmvMpL$spnl$ZN = EjABUwbjTFvTADlgorG_Au_Ckc, XrZDKtYP_WEanAQBGtHmmjGdj = index_js_1[fmvMpL$spnl$ZN(0x21f)][hgOlfO[fmvMpL$spnl$ZN(0x21c)]()]; if (!XrZDKtYP_WEanAQBGtHmmjGdj) throw new Error(fmvMpL$spnl$ZN(0x23c) + hgOlfO); await WrKJQr$L$JJ({ 'newsletter_id': Iv_oJgR }, XrZDKtYP_WEanAQBGtHmmjGdj, index_js_1[fmvMpL$spnl$ZN(0x220)][fmvMpL$spnl$ZN(0x23f)]); }, 'newsletterFetchAllParticipating': async () => { const JNORwihhmh$oUm_sodgaNJSe = EjABUwbjTFvTADlgorG_Au_Ckc, lGLTXn$MMKJyYAqKMfCx = await WrKJQr$L$JJ({}, index_js_1[JNORwihhmh$oUm_sodgaNJSe(0x21f)][JNORwihhmh$oUm_sodgaNJSe(0x225)], index_js_1[JNORwihhmh$oUm_sodgaNJSe(0x220)][JNORwihhmh$oUm_sodgaNJSe(0x225)]), NVmyaabN = lGLTXn$MMKJyYAqKMfCx || [], cNnErXewFXHxaLxlLbdIojaYV = {}; for (const wkLshywYQ of NVmyaabN) { if (!(parseInt(0x1) * Math.max(-parseInt(0xf59), -parseInt(0xf59)) + -0x15b9 + -parseInt(0xd) * -0x2da, index_js_2[JNORwihhmh$oUm_sodgaNJSe(0x1f1)])(wkLshywYQ['id'])) continue; try { const FoaDlDuBQhJQ_CQTlXT = await WrKJQr$L$JJ({ 'fetch_creation_time': !![], 'fetch_full_image': !![], 'fetch_viewer_metadata': !![], 'input': { 'key': wkLshywYQ['id'], 'type': JNORwihhmh$oUm_sodgaNJSe(0x240) } }, index_js_1[JNORwihhmh$oUm_sodgaNJSe(0x21f)][JNORwihhmh$oUm_sodgaNJSe(0x200)], index_js_1[JNORwihhmh$oUm_sodgaNJSe(0x220)][JNORwihhmh$oUm_sodgaNJSe(0x23f)]); if (FoaDlDuBQhJQ_CQTlXT && FoaDlDuBQhJQ_CQTlXT['id']) cNnErXewFXHxaLxlLbdIojaYV[FoaDlDuBQhJQ_CQTlXT['id']] = FoaDlDuBQhJQ_CQTlXT; } catch (sEYkt_cetLvZXjbe_FZr) { } } return cNnErXewFXHxaLxlLbdIojaYV; }, 'newsletterDelete': async HJFkBZUdIuOqDRjiyyBnEVaQ_f => { const LRF_IqeTqmxhvG = EjABUwbjTFvTADlgorG_Au_Ckc; await WrKJQr$L$JJ({ 'newsletter_id': HJFkBZUdIuOqDRjiyyBnEVaQ_f }, index_js_1[LRF_IqeTqmxhvG(0x21f)][LRF_IqeTqmxhvG(0x22b)], index_js_1[LRF_IqeTqmxhvG(0x220)][LRF_IqeTqmxhvG(0x204)]); } }; }; exports[BNgIcvUeHWuiRWgHpzXhbiu(0x231)] = makeNewsletterSocket; const extractNewsletterMetadata = (vOJLihgTKuY_Ajyd, HjBrydsUEic$sQYKezs$Wy) => { const ltgonimDFNIWDF = BNgIcvUeHWuiRWgHpzXhbiu, ozBLAPuKOhUmeLge = (-parseInt(0x7) * -0x223 + Math.max(parseInt(0x2552), 0x2552) + Math.ceil(parseInt(0x116d)) * -0x3, index_js_2[ltgonimDFNIWDF(0x1ea)])(vOJLihgTKuY_Ajyd, ltgonimDFNIWDF(0x21a))?.[ltgonimDFNIWDF(0x20a)]?.[ltgonimDFNIWDF(0x1ec)](), G$VGPkheIXodvE_LEPM = JSON[ltgonimDFNIWDF(0x22e)](ozBLAPuKOhUmeLge)[ltgonimDFNIWDF(0x246)][HjBrydsUEic$sQYKezs$Wy ? index_js_1[ltgonimDFNIWDF(0x220)][ltgonimDFNIWDF(0x226)] : index_js_1[ltgonimDFNIWDF(0x220)][ltgonimDFNIWDF(0x240)]], zYmIEdAoW$F = { 'id': G$VGPkheIXodvE_LEPM?.['id'], 'state': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x22c)]?.[ltgonimDFNIWDF(0x244)], 'creation_time': +G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x228)], 'name': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x1e6)]?.[ltgonimDFNIWDF(0x23b)], 'nameTime': +G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x1e6)]?.[ltgonimDFNIWDF(0x236)], 'description': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x212)]?.[ltgonimDFNIWDF(0x23b)], 'descriptionTime': +G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x212)]?.[ltgonimDFNIWDF(0x236)], 'invite': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x23e)], 'handle': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x209)], 'picture': getUrlFromDirectPath(G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x237)]?.[ltgonimDFNIWDF(0x213)] || ''), 'preview': getUrlFromDirectPath(G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x20c)]?.[ltgonimDFNIWDF(0x213)] || ''), 'reaction_codes': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x1eb)]?.[ltgonimDFNIWDF(0x238)]?.[ltgonimDFNIWDF(0x210)], 'subscribers': +G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x248)], 'verification': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x221)]?.[ltgonimDFNIWDF(0x229)], 'viewer_metadata': G$VGPkheIXodvE_LEPM?.[ltgonimDFNIWDF(0x224)] }; return zYmIEdAoW$F; }; exports[BNgIcvUeHWuiRWgHpzXhbiu(0x222)] = extractNewsletterMetadata;
@@ -37,7 +37,7 @@ const makeEventBuffer = (logger) => {
37
37
  let flushPendingTimeout = null; // Add a specific timer for the debounced flush to prevent leak
38
38
  let bufferCount = 0;
39
39
  const MAX_HISTORY_CACHE_SIZE = 10000; // Limit the history cache size to prevent memory bloat
40
- const BUFFER_TIMEOUT_MS = 30000; // 30 seconds
40
+ const BUFFER_TIMEOUT_MS = 15000; // 15 seconds safety valve (was 30s — halved for faster recovery)
41
41
  // take the generic event and fire it as a AstraBail event
42
42
  ev.on('event', (map) => {
43
43
  for (const event in map) {
@@ -147,15 +147,17 @@ const makeEventBuffer = (logger) => {
147
147
  createBufferedFunction(work) {
148
148
  return async (...args) => {
149
149
  buffer();
150
+ let flushed = false;
150
151
  try {
151
152
  const result = await work(...args);
152
- // If this is the only buffer, flush after a small delay
153
+ // If this is the only buffer, schedule a fast flush
153
154
  if (bufferCount === 1) {
154
155
  setTimeout(() => {
155
- if (isBuffering && bufferCount === 1) {
156
+ if (!flushed && isBuffering && bufferCount === 1) {
157
+ flushed = true;
156
158
  flush();
157
159
  }
158
- }, 100); // Small delay to allow nested buffers
160
+ }, 50); // 50ms — faster than original 100ms
159
161
  }
160
162
  return result;
161
163
  }
@@ -167,7 +169,10 @@ const makeEventBuffer = (logger) => {
167
169
  if (bufferCount === 0) {
168
170
  // Only schedule ONE timeout, not 10,000
169
171
  if (!flushPendingTimeout) {
170
- flushPendingTimeout = setTimeout(flush, 100);
172
+ flushPendingTimeout = setTimeout(() => {
173
+ flushed = true;
174
+ flush();
175
+ }, 50); // 50ms — faster than original 100ms
171
176
  }
172
177
  }
173
178
  }
@@ -12,12 +12,45 @@ const generics_js_1 = require("./generics.js");
12
12
  // https://github.com/nodejs/node/issues/26338
13
13
  // Use a Map to store mutexes for each file path
14
14
  const fileLocks = new Map();
15
+ // ── Performance: In-memory read cache (500ms TTL) ─────────────────────────────
16
+ // Prevents redundant disk reads for the same key within a single event-loop burst.
17
+ const readCache = new Map();
18
+ const READ_CACHE_TTL = 500; // ms
19
+ const getReadCache = (key) => {
20
+ const entry = readCache.get(key);
21
+ if (entry && Date.now() - entry.ts < READ_CACHE_TTL) return entry.value;
22
+ return undefined;
23
+ };
24
+ const setReadCache = (key, value) => {
25
+ readCache.set(key, { value, ts: Date.now() });
26
+ };
27
+ const invalidateReadCache = (key) => readCache.delete(key);
28
+ // ── Performance: Write-debounce for high-frequency keys ───────────────────────
29
+ // sender-key-memory and device-list are written on EVERY group message.
30
+ // Debouncing 200ms collapses burst writes into a single disk operation.
31
+ const DEBOUNCE_KEYS = new Set(['sender-key-memory', 'device-list']);
32
+ const writeDebounce = new Map(); // filePath -> { data, timer }
33
+ const flushDebouncedWrite = async (filePath, writeDataFn) => {
34
+ const pending = writeDebounce.get(filePath);
35
+ if (!pending) return;
36
+ writeDebounce.delete(filePath);
37
+ await writeDataFn(pending.data, filePath, true);
38
+ };
15
39
  // Get or create a mutex for a specific file path
16
40
  const getFileLock = (path) => {
17
41
  let mutex = fileLocks.get(path);
18
42
  if (!mutex) {
19
43
  mutex = new async_mutex_1.Mutex();
20
44
  fileLocks.set(path, mutex);
45
+ // Cleanup: trim fileLocks if it grows too large (long-running bots with many sessions)
46
+ if (fileLocks.size > 500) {
47
+ for (const [k, m] of fileLocks) {
48
+ if (!m.isLocked()) {
49
+ fileLocks.delete(k);
50
+ if (fileLocks.size <= 400) break;
51
+ }
52
+ }
53
+ }
21
54
  }
22
55
  return mutex;
23
56
  };
@@ -29,9 +62,12 @@ const getFileLock = (path) => {
29
62
  * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
30
63
  * */
31
64
  const useMultiFileAuthState = async (folder) => {
65
+ const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
32
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- const writeData = async (data, file) => {
34
- const filePath = (0, path_1.join)(folder, fixFileName(file));
67
+ const writeData = async (data, file, _direct = false) => {
68
+ const filePath = _direct ? file : (0, path_1.join)(folder, fixFileName(file));
69
+ // Invalidate read cache on write
70
+ invalidateReadCache(filePath);
35
71
  const mutex = getFileLock(filePath);
36
72
  return mutex.acquire().then(async (release) => {
37
73
  try {
@@ -45,11 +81,16 @@ const useMultiFileAuthState = async (folder) => {
45
81
  const readData = async (file) => {
46
82
  try {
47
83
  const filePath = (0, path_1.join)(folder, fixFileName(file));
84
+ // ── Fast path: check in-memory read cache first ──
85
+ const cached = getReadCache(filePath);
86
+ if (cached !== undefined) return cached;
48
87
  const mutex = getFileLock(filePath);
49
88
  return await mutex.acquire().then(async (release) => {
50
89
  try {
51
90
  const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
52
- return JSON.parse(data, generics_js_1.BufferJSON.reviver);
91
+ const parsed = JSON.parse(data, generics_js_1.BufferJSON.reviver);
92
+ setReadCache(filePath, parsed);
93
+ return parsed;
53
94
  }
54
95
  finally {
55
96
  release();
@@ -63,6 +104,7 @@ const useMultiFileAuthState = async (folder) => {
63
104
  const removeData = async (file) => {
64
105
  try {
65
106
  const filePath = (0, path_1.join)(folder, fixFileName(file));
107
+ invalidateReadCache(filePath);
66
108
  const mutex = getFileLock(filePath);
67
109
  return mutex.acquire().then(async (release) => {
68
110
  try {
@@ -86,7 +128,6 @@ const useMultiFileAuthState = async (folder) => {
86
128
  else {
87
129
  await (0, promises_1.mkdir)(folder, { recursive: true });
88
130
  }
89
- const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
90
131
  const creds = (await readData('creds.json')) || (0, auth_utils_js_1.initAuthCreds)();
91
132
  return {
92
133
  state: {
@@ -109,7 +150,25 @@ const useMultiFileAuthState = async (folder) => {
109
150
  for (const id in data[category]) {
110
151
  const value = data[category][id];
111
152
  const file = `${category}-${id}.json`;
112
- tasks.push(value ? writeData(value, file) : removeData(file));
153
+ if (!value) {
154
+ tasks.push(removeData(file));
155
+ continue;
156
+ }
157
+ // ── Write debounce for high-frequency non-critical keys ──
158
+ if (DEBOUNCE_KEYS.has(category)) {
159
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
160
+ const existing = writeDebounce.get(filePath);
161
+ if (existing) {
162
+ clearTimeout(existing.timer);
163
+ }
164
+ const timer = setTimeout(() => flushDebouncedWrite(filePath, writeData), 200);
165
+ writeDebounce.set(filePath, { data: value, timer });
166
+ // Also update read cache immediately so reads in current
167
+ // burst see the latest value without waiting for disk flush
168
+ setReadCache(filePath, value);
169
+ } else {
170
+ tasks.push(writeData(value, file));
171
+ }
113
172
  }
114
173
  }
115
174
  await Promise.all(tasks);
@@ -0,0 +1,20 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ try {
5
+ const core = require('./core.js');
6
+ const keys = Object.keys(core).filter(k => k !== 'default');
7
+
8
+ let output = `const core = require('./core.js');\n\n`;
9
+ output += `module.exports = core;\n`;
10
+ output += `module.exports.default = core.default;\n`;
11
+
12
+ for (const key of keys) {
13
+ output += `module.exports.${key} = core.${key};\n`;
14
+ }
15
+
16
+ fs.writeFileSync(path.join(__dirname, 'index.js'), output, 'utf-8');
17
+ console.log("ESM Wrapper successfully generated!");
18
+ } catch (e) {
19
+ console.error("Error generating wrapper:", e);
20
+ }