simplex-chat 0.0.1 → 0.1.1

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,537 +1,11 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.simplex = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- class Sem {
8
- constructor(permits) {
9
- this.permits = permits;
10
- this.promises = [];
11
- }
12
- signal() {
13
- this.permits += 1;
14
- if (this.promises.length > 0)
15
- this.promises.pop()();
16
- }
17
- async wait() {
18
- if (this.permits === 0 || this.promises.length > 0) {
19
- await new Promise((r) => this.promises.unshift(r));
20
- }
21
- this.permits -= 1;
22
- }
23
- }
24
- const queueClosed = Symbol();
25
- class ABQueueError extends Error {
26
- }
27
- class ABQueue {
28
- constructor(maxSize) {
29
- this.maxSize = maxSize;
30
- this.queue = [];
31
- this.enqClosed = false;
32
- this.deqClosed = false;
33
- this.enq = new Sem(0);
34
- this.deq = new Sem(maxSize);
35
- }
36
- [Symbol.asyncIterator]() {
37
- return this;
38
- }
39
- enqueue(x) {
40
- return this._enqueue(x);
41
- }
42
- async _enqueue(x) {
43
- if (this.enqClosed)
44
- throw new ABQueueError("enqueue: queue closed");
45
- await this.deq.wait();
46
- this.queue.push(x);
47
- this.enq.signal();
48
- }
49
- async dequeue() {
50
- if (this.deqClosed)
51
- throw new ABQueueError("dequeue: queue closed");
52
- this.deq.signal();
53
- await this.enq.wait();
54
- const x = this.queue.shift();
55
- if (x === queueClosed) {
56
- this.deqClosed = true;
57
- throw new ABQueueError("dequeue: queue closed");
58
- }
59
- return x;
60
- }
61
- async close() {
62
- await this._enqueue(queueClosed);
63
- this.enqClosed = true;
64
- }
65
- async next() {
66
- if (this.deqClosed)
67
- return { done: true };
68
- try {
69
- return { value: await this.dequeue() };
70
- }
71
- catch (e) {
72
- if (e instanceof ABQueueError)
73
- return { done: true };
74
- throw e;
75
- }
76
- }
77
- }
78
-
79
- class TransportError extends Error {
80
- }
81
- class Transport {
82
- constructor(qSize) {
83
- this.queue = new ABQueue(qSize);
84
- }
85
- [Symbol.asyncIterator]() {
86
- return this;
87
- }
88
- async read() {
89
- return this.queue.dequeue();
90
- }
91
- async next() {
92
- return this.queue.next();
93
- }
94
- }
95
- class WSTransport extends Transport {
96
- constructor(sock, timeout, qSize) {
97
- super(qSize);
98
- this.sock = sock;
99
- this.timeout = timeout;
100
- }
101
- static connect(url, timeout, qSize) {
102
- const sock = new WebSocket(url);
103
- const t = new WSTransport(sock, timeout, qSize);
104
- sock.onmessage = async ({ data }) => await t.queue.enqueue(data);
105
- sock.onclose = async () => await t.queue.close();
106
- sock.onerror = () => sock.close();
107
- return withTimeout(timeout, () => new Promise((r) => (sock.onopen = () => r(t))));
108
- }
109
- close() {
110
- this.sock.close();
111
- return Promise.resolve();
112
- }
113
- write(data) {
114
- const buffered = this.sock.bufferedAmount;
115
- this.sock.send(data);
116
- return withTimeout(this.timeout, async () => {
117
- while (this.sock.bufferedAmount > buffered)
118
- await delay();
119
- });
120
- }
121
- async readBinary(size) {
122
- const data = await this.read();
123
- if (typeof data == "string")
124
- throw new TransportError("invalid text block: expected binary");
125
- if (data.byteLength !== size)
126
- throw new TransportError("invalid block size");
127
- return data;
128
- }
129
- }
130
- function withTimeout(ms, action) {
131
- return Promise.race([
132
- action(),
133
- (async () => {
134
- await delay(ms);
135
- throw new Error("timeout");
136
- })(),
137
- ]);
138
- }
139
- const localServer = {
140
- host: "localhost",
141
- port: "5225",
142
- };
143
- class ChatResponseError extends Error {
144
- constructor(message, data) {
145
- super(message);
146
- this.message = message;
147
- this.data = data;
148
- }
149
- }
150
- class ChatTransport extends Transport {
151
- constructor(ws, timeout, qSize) {
152
- super(qSize);
153
- this.ws = ws;
154
- this.timeout = timeout;
155
- }
156
- static async connect(srv, timeout, qSize) {
157
- const uri = typeof srv == "string" ? srv : `ws://${srv.host}:${srv.port || "5225"}`;
158
- const ws = await WSTransport.connect(uri, timeout, qSize);
159
- const c = new ChatTransport(ws, timeout, qSize);
160
- processWSQueue(c, ws).then(noop, noop);
161
- return c;
162
- }
163
- async close() {
164
- await this.ws.close();
165
- }
166
- async write(cmd) {
167
- return this.ws.write(JSON.stringify(cmd));
168
- }
169
- }
170
- function noop() { }
171
- async function processWSQueue(c, ws) {
172
- var _a;
173
- for await (const data of ws) {
174
- const str = (data instanceof Promise ? await data : data);
175
- if (typeof str != "string") {
176
- await c.queue.enqueue(new ChatResponseError("websocket data is not a string"));
177
- continue;
178
- }
179
- let resp;
180
- try {
181
- const json = JSON.parse(str);
182
- if (typeof ((_a = json === null || json === void 0 ? void 0 : json.resp) === null || _a === void 0 ? void 0 : _a.type) == "string") {
183
- resp = json;
184
- }
185
- else {
186
- resp = new ChatResponseError("invalid response format", str);
187
- }
188
- }
189
- catch (err) {
190
- resp = new ChatResponseError(err.message, str);
191
- }
192
- await c.queue.enqueue(resp);
193
- }
194
- await c.queue.close();
195
- }
196
- function delay(ms) {
197
- return new Promise((r) => setTimeout(r, ms));
198
- }
199
-
200
- var ChatType;
201
- (function (ChatType) {
202
- ChatType["CTDirect"] = "@";
203
- ChatType["CTGroup"] = "#";
204
- ChatType["CTContactRequest"] = "<@";
205
- })(ChatType || (ChatType = {}));
206
- var DeleteMode;
207
- (function (DeleteMode) {
208
- DeleteMode["Broadcast"] = "broadcast";
209
- DeleteMode["Internal"] = "internal";
210
- })(DeleteMode || (DeleteMode = {}));
211
- function cmdString(cmd) {
212
- switch (cmd.type) {
213
- case "showActiveUser":
214
- return "/u";
215
- case "createActiveUser":
216
- return `/u ${JSON.stringify(cmd.profile)}`;
217
- case "startChat":
218
- return "/_start";
219
- case "setFilesFolder":
220
- return `/_files_folder ${cmd.filePath}`;
221
- case "apiGetChats":
222
- return "/_get chats";
223
- case "apiGetChat":
224
- return `/_get chat ${cmd.chatType}${cmd.chatId}${paginationStr(cmd.pagination)}`;
225
- case "apiSendMessage":
226
- return `/_send ${cmd.chatType}${cmd.chatId} json ${JSON.stringify(cmd.message)}`;
227
- case "apiUpdateChatItem":
228
- return `/_update item ${cmd.chatType}${cmd.chatId} ${cmd.chatItemId} json ${JSON.stringify(cmd.msgContent)}`;
229
- case "apiDeleteChatItem":
230
- return `/_delete item ${cmd.chatType}${cmd.chatId} ${cmd.chatItemId} ${cmd.deleteMode}`;
231
- case "apiChatRead":
232
- return `/_read chat ${cmd.chatType}${cmd.chatId} from=${cmd.fromItem} to=${cmd.toItem}`;
233
- case "apiDeleteChat":
234
- return `/_delete ${cmd.chatType}${cmd.chatId}`;
235
- case "apiAcceptContact":
236
- return `/_accept ${cmd.contactReqId}`;
237
- case "apiRejectContact":
238
- return `/_reject ${cmd.contactReqId}`;
239
- case "apiUpdateProfile":
240
- return `/_profile ${JSON.stringify(cmd.profile)}`;
241
- case "apiParseMarkdown":
242
- return `/_parse ${cmd.text}`;
243
- case "getUserSMPServers":
244
- return "/smp_servers";
245
- case "setUserSMPServers":
246
- return `/smp_servers ${cmd.servers.join(",") || "default"}`;
247
- case "addContact":
248
- return "/connect";
249
- case "connect":
250
- return `/connect ${cmd.connReq}`;
251
- case "connectSimplex":
252
- return "/simplex";
253
- case "createMyAddress":
254
- return "/address";
255
- case "deleteMyAddress":
256
- return "/delete_address";
257
- case "showMyAddress":
258
- return "/show_address";
259
- case "addressAutoAccept":
260
- return `/auto_accept ${cmd.enable ? "on" : "off"}`;
261
- }
262
- }
263
- function paginationStr(cp) {
264
- const base = "after" in cp ? ` after=${cp.after}` : "before" in cp ? ` before=${cp.before}` : "";
265
- return base + ` count=${cp.count}`;
266
- }
267
-
268
- class ChatCommandError extends Error {
269
- constructor(message, response) {
270
- super(message);
271
- this.message = message;
272
- this.response = response;
273
- }
274
- }
275
- var ConnReqType;
276
- (function (ConnReqType) {
277
- ConnReqType["Invitation"] = "invitation";
278
- ConnReqType["Contact"] = "contact";
279
- })(ConnReqType || (ConnReqType = {}));
280
- class ChatClient {
281
- constructor(server, config, msgQ, client, transport) {
282
- this.server = server;
283
- this.config = config;
284
- this.msgQ = msgQ;
285
- this.client = client;
286
- this.transport = transport;
287
- this._connected = true;
288
- this.clientCorrId = 0;
289
- this.sentCommands = new Map();
290
- }
291
- static async create(server = localServer, cfg = ChatClient.defaultConfig) {
292
- const transport = await ChatTransport.connect(server, cfg.tcpTimeout, cfg.qSize);
293
- const msgQ = new ABQueue(cfg.qSize);
294
- const client = runClient().then(noop, noop);
295
- const c = new ChatClient(server, cfg, msgQ, client, transport);
296
- return c;
297
- async function runClient() {
298
- for await (const t of transport) {
299
- const apiResp = (t instanceof Promise ? await t : t);
300
- if (apiResp instanceof ChatResponseError) {
301
- console.log("chat response error: ", apiResp);
302
- }
303
- else {
304
- const { corrId, resp } = apiResp;
305
- if (corrId) {
306
- const req = c.sentCommands.get(corrId);
307
- if (req) {
308
- c.sentCommands.delete(corrId);
309
- if (resp.type === "chatCmdError") {
310
- req.reject(resp);
311
- }
312
- else {
313
- req.resolve(resp);
314
- }
315
- }
316
- else {
317
- // TODO send error to errQ?
318
- console.log("no command sent for chat response: ", apiResp);
319
- }
320
- }
321
- else {
322
- await msgQ.enqueue(resp);
323
- }
324
- }
325
- }
326
- c._connected = false;
327
- }
328
- }
329
- sendChatCmdStr(cmd) {
330
- const corrId = `${++this.clientCorrId}`;
331
- const t = { corrId, cmd };
332
- this.transport.write(t).then(noop, noop);
333
- return new Promise((resolve, reject) => this.sentCommands.set(corrId, { resolve, reject }));
334
- }
335
- sendChatCommand(command) {
336
- return this.sendChatCmdStr(cmdString(command));
337
- }
338
- async disconnect() {
339
- await this.transport.close();
340
- await this.client;
341
- }
342
- async apiGetActiveUser() {
343
- const r = await this.sendChatCommand({ type: "showActiveUser" });
344
- switch (r.type) {
345
- case "activeUser":
346
- return r.user;
347
- case "chatCmdError":
348
- if (r.chatError.type === "error" && r.chatError.errorType.type === "noActiveUser")
349
- return undefined;
350
- throw new ChatCommandError("unexpected response error", r);
351
- default:
352
- throw new ChatCommandError("unexpected response", r);
353
- }
354
- }
355
- async apiCreateActiveUser(profile) {
356
- const r = await this.sendChatCommand({ type: "createActiveUser", profile });
357
- if (r.type === "activeUser")
358
- return r.user;
359
- throw new ChatCommandError("unexpected response", r);
360
- }
361
- async apiStartChat() {
362
- const r = await this.sendChatCommand({ type: "startChat" });
363
- if (r.type !== "chatStarted" && r.type !== "chatRunning") {
364
- throw new ChatCommandError("error starting chat", r);
365
- }
366
- }
367
- async apiGetChats() {
368
- const r = await this.sendChatCommand({ type: "apiGetChats" });
369
- if (r.type === "apiChats")
370
- return r.chats;
371
- throw new ChatCommandError("error loading chats", r);
372
- }
373
- async apiGetChat(chatType, chatId, pagination = { count: 100 }) {
374
- const r = await this.sendChatCommand({ type: "apiGetChat", chatType, chatId, pagination });
375
- if (r.type === "apiChat")
376
- return r.chat;
377
- throw new ChatCommandError("error loading chat", r);
378
- }
379
- async apiSendMessage(chatType, chatId, message) {
380
- const r = await this.sendChatCommand({ type: "apiSendMessage", chatType, chatId, message });
381
- if (r.type === "newChatItem")
382
- return r.chatItem;
383
- throw new ChatCommandError("unexpected response", r);
384
- }
385
- apiSendTextMessage(chatType, chatId, text) {
386
- return this.apiSendMessage(chatType, chatId, { msgContent: { type: "text", text } });
387
- }
388
- async apiUpdateChatItem(chatType, chatId, chatItemId, msgContent) {
389
- const r = await this.sendChatCommand({ type: "apiUpdateChatItem", chatType, chatId, chatItemId, msgContent });
390
- if (r.type === "chatItemUpdated")
391
- return r.chatItem.chatItem;
392
- throw new ChatCommandError("error updating chat item", r);
393
- }
394
- async apiDeleteChatItem(chatType, chatId, chatItemId, deleteMode) {
395
- const r = await this.sendChatCommand({ type: "apiDeleteChatItem", chatType, chatId, chatItemId, deleteMode });
396
- if (r.type === "chatItemDeleted")
397
- return r.toChatItem.chatItem;
398
- throw new ChatCommandError("error deleting chat item", r);
399
- }
400
- // func getUserSMPServers() throws -> [String] {
401
- // let r = chatSendCmdSync(.getUserSMPServers)
402
- // if case let .userSMPServers(smpServers) = r { return smpServers }
403
- // throw r
404
- // }
405
- // func setUserSMPServers(smpServers: [String]) async throws {
406
- // let r = await chatSendCmd(.setUserSMPServers(smpServers: smpServers))
407
- // if case .cmdOk = r { return }
408
- // throw r
409
- // }
410
- async apiCreateLink() {
411
- const r = await this.sendChatCommand({ type: "addContact" });
412
- if (r.type === "invitation")
413
- return r.connReqInvitation;
414
- throw new ChatCommandError("error creating link", r);
415
- }
416
- async apiConnect(connReq) {
417
- const r = await this.sendChatCommand({ type: "connect", connReq });
418
- switch (r.type) {
419
- case "sentConfirmation":
420
- return ConnReqType.Invitation;
421
- case "sentInvitation":
422
- return ConnReqType.Contact;
423
- default:
424
- throw new ChatCommandError("connection error", r);
425
- }
426
- }
427
- async apiDeleteChat(chatType, chatId) {
428
- const r = await this.sendChatCommand({ type: "apiDeleteChat", chatType, chatId });
429
- if (r.type !== "contactDeleted")
430
- throw new ChatCommandError("error deleting chat", r);
431
- }
432
- async apiUpdateProfile(profile) {
433
- const r = await this.sendChatCommand({ type: "apiUpdateProfile", profile });
434
- switch (r.type) {
435
- case "userProfileNoChange":
436
- return undefined;
437
- case "userProfileUpdated":
438
- return r.toProfile;
439
- default:
440
- throw new ChatCommandError("error updating profile", r);
441
- }
442
- }
443
- // func apiParseMarkdown(text: String) throws -> [FormattedText]? {
444
- // let r = chatSendCmdSync(.apiParseMarkdown(text: text))
445
- // if case let .apiParsedMarkdown(formattedText) = r { return formattedText }
446
- // throw r
447
- // }
448
- // func apiCreateUserAddress() async throws -> String {
449
- // let r = await chatSendCmd(.createMyAddress)
450
- // if case let .userContactLinkCreated(connReq) = r { return connReq }
451
- // throw r
452
- // }
453
- // func apiDeleteUserAddress() async throws {
454
- // let r = await chatSendCmd(.deleteMyAddress)
455
- // if case .userContactLinkDeleted = r { return }
456
- // throw r
457
- // }
458
- // func apiGetUserAddress() async throws -> String? {
459
- // let r = await chatSendCmd(.showMyAddress)
460
- // switch r {
461
- // case let .userContactLink(connReq):
462
- // return connReq
463
- // case .chatCmdError(chatError: .errorStore(storeError: .userContactLinkNotFound)):
464
- // return nil
465
- // default: throw r
466
- // }
467
- // }
468
- // func apiAcceptContactRequest(contactReqId: Int64) async throws -> Contact {
469
- // let r = await chatSendCmd(.apiAcceptContact(contactReqId: contactReqId))
470
- // if case let .acceptingContactRequest(contact) = r { return contact }
471
- // throw r
472
- // }
473
- // func apiRejectContactRequest(contactReqId: Int64) async throws {
474
- // let r = await chatSendCmd(.apiRejectContact(contactReqId: contactReqId))
475
- // if case .contactRequestRejected = r { return }
476
- // throw r
477
- // }
478
- // func apiChatRead(type: ChatType, id: Int64, itemRange: (Int64, Int64)) async throws {
479
- // let r = await chatSendCmd(.apiChatRead(type: type, id: id, itemRange: itemRange))
480
- // if case .cmdOk = r { return }
481
- // throw r
482
- // }
483
- // func acceptContactRequest(_ contactRequest: UserContactRequest) async {
484
- // do {
485
- // let contact = try await apiAcceptContactRequest(contactReqId: contactRequest.apiId)
486
- // let chat = Chat(chatInfo: ChatInfo.direct(contact: contact), chatItems: [])
487
- // DispatchQueue.main.async { ChatModel.shared.replaceChat(contactRequest.id, chat) }
488
- // } catch let error {
489
- // logger.error("acceptContactRequest error: \(error.localizedDescription)")
490
- // }
491
- // }
492
- // func rejectContactRequest(_ contactRequest: UserContactRequest) async {
493
- // do {
494
- // try await apiRejectContactRequest(contactReqId: contactRequest.apiId)
495
- // DispatchQueue.main.async { ChatModel.shared.removeChat(contactRequest.id) }
496
- // } catch let error {
497
- // logger.error("rejectContactRequest: \(error.localizedDescription)")
498
- // }
499
- // }
500
- // func markChatRead(_ chat: Chat) async {
501
- // do {
502
- // let minItemId = chat.chatStats.minUnreadItemId
503
- // let itemRange = (minItemId, chat.chatItems.last?.id ?? minItemId)
504
- // let cInfo = chat.chatInfo
505
- // try await apiChatRead(type: cInfo.chatType, id: cInfo.apiId, itemRange: itemRange)
506
- // DispatchQueue.main.async { ChatModel.shared.markChatItemsRead(cInfo) }
507
- // } catch {
508
- // logger.error("markChatRead apiChatRead error: \(error.localizedDescription)")
509
- // }
510
- // }
511
- // func markChatItemRead(_ cInfo: ChatInfo, _ cItem: ChatItem) async {
512
- // do {
513
- // try await apiChatRead(type: cInfo.chatType, id: cInfo.apiId, itemRange: (cItem.id, cItem.id))
514
- // DispatchQueue.main.async { ChatModel.shared.markChatItemRead(cInfo, cItem) }
515
- // } catch {
516
- // logger.error("markChatItemRead apiChatRead error: \(error.localizedDescription)")
517
- // }
518
- // }
519
- // private async okChatCommand(command: ChatCommand): Promise<void> {
520
- // const resp = await this.sendChatCommand(command)
521
- // if (resp.type !== "cmdOk") throw new ChatCommandError("unexpected response", resp)
522
- // }
523
- get connected() {
524
- return this._connected;
525
- }
526
- }
527
- ChatClient.defaultConfig = {
528
- qSize: 16,
529
- tcpTimeout: 4000,
530
- };
531
-
532
- exports.ABQueue = ABQueue;
533
- exports.ChatClient = ChatClient;
534
-
535
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ (function (factory) {
2
+ typeof define === 'function' && define.amd ? define(factory) :
3
+ factory();
4
+ })((function () { 'use strict';
5
+
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ChatClient = void 0;
8
+ var client_1 = require("./client");
9
+ Object.defineProperty(exports, "ChatClient", { enumerable: true, get: function () { return client_1.ChatClient; } });
536
10
 
537
11
  }));
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
- import "./websocket";
2
- export { ChatClient } from "./client";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatClient = void 0;
4
+ require("./websocket");
5
+ var client_1 = require("./client");
6
+ Object.defineProperty(exports, "ChatClient", { enumerable: true, get: function () { return client_1.ChatClient; } });
3
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uBAAoB;AACpB,mCAAmC;AAA3B,oGAAA,UAAU,OAAA"}
package/dist/queue.js CHANGED
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ABQueue = exports.ABQueueError = void 0;
1
4
  class Sem {
2
5
  constructor(permits) {
3
6
  this.permits = permits;
@@ -16,9 +19,10 @@ class Sem {
16
19
  }
17
20
  }
18
21
  const queueClosed = Symbol();
19
- export class ABQueueError extends Error {
22
+ class ABQueueError extends Error {
20
23
  }
21
- export class ABQueue {
24
+ exports.ABQueueError = ABQueueError;
25
+ class ABQueue {
22
26
  constructor(maxSize) {
23
27
  this.maxSize = maxSize;
24
28
  this.queue = [];
@@ -69,4 +73,5 @@ export class ABQueue {
69
73
  }
70
74
  }
71
75
  }
76
+ exports.ABQueue = ABQueue;
72
77
  //# sourceMappingURL=queue.js.map
package/dist/queue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG;IAGP,YAAoB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAFlB,aAAQ,GAA6B,EAAE,CAAA;IAElB,CAAC;IAEvC,MAAM;QACJ,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;QACjB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAiB,EAAE,CAAA;IACrE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAClD,MAAM,IAAI,OAAO,CAAC,CAAC,C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