@wirecat/bitrix24-cli 0.0.0-stage → 0.2.0
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.
- package/CHANGELOG.md +41 -0
- package/LICENSE +204 -0
- package/README.md +17 -2
- package/dist/api-keys.d.ts +21 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +58 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/bin/b24.d.ts +3 -0
- package/dist/bin/b24.d.ts.map +1 -0
- package/dist/bin/b24.js +40 -0
- package/dist/bin/b24.js.map +1 -0
- package/dist/bitrix/errors.d.ts +22 -0
- package/dist/bitrix/errors.d.ts.map +1 -0
- package/dist/bitrix/errors.js +76 -0
- package/dist/bitrix/errors.js.map +1 -0
- package/dist/bitrix/methods.d.ts +13 -0
- package/dist/bitrix/methods.d.ts.map +1 -0
- package/dist/bitrix/methods.js +33 -0
- package/dist/bitrix/methods.js.map +1 -0
- package/dist/bitrix/transport.d.ts +50 -0
- package/dist/bitrix/transport.d.ts.map +1 -0
- package/dist/bitrix/transport.js +189 -0
- package/dist/bitrix/transport.js.map +1 -0
- package/dist/bitrix/webhook.d.ts +14 -0
- package/dist/bitrix/webhook.d.ts.map +1 -0
- package/dist/bitrix/webhook.js +29 -0
- package/dist/bitrix/webhook.js.map +1 -0
- package/dist/bundle/all-profiles-QJ444GSX.js +24 -0
- package/dist/bundle/anthropic-RHRAVHC2.js +70 -0
- package/dist/bundle/app-server-QIT6S7AZ.js +224 -0
- package/dist/bundle/b24.js +32 -0
- package/dist/bundle/bun-H6RSODZ3.js +169 -0
- package/dist/bundle/bun-sqlite-BO4LTQHX.js +69 -0
- package/dist/bundle/chunk-2KCZ7BKW.js +215 -0
- package/dist/bundle/chunk-2SNUMZ7S.js +1028 -0
- package/dist/bundle/chunk-45AKJVKV.js +24 -0
- package/dist/bundle/chunk-4PDYYS5K.js +2 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-6WY72XVQ.js +216 -0
- package/dist/bundle/chunk-7GRZAKBB.js +639 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-BCF7P4FZ.js +558 -0
- package/dist/bundle/chunk-CNNEA2M4.js +54 -0
- package/dist/bundle/chunk-CXL33BFL.js +570 -0
- package/dist/bundle/chunk-D5S6QV6R.js +95 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DTXERR44.js +35 -0
- package/dist/bundle/chunk-EVYSBZ3I.js +153 -0
- package/dist/bundle/chunk-EXOOKUEA.js +82 -0
- package/dist/bundle/chunk-FLUEXJ4X.js +53 -0
- package/dist/bundle/chunk-FOTREPNS.js +366 -0
- package/dist/bundle/chunk-FZL7F5NR.js +2022 -0
- package/dist/bundle/chunk-GDFNH33E.js +1691 -0
- package/dist/bundle/chunk-H2ADPPSH.js +50910 -0
- package/dist/bundle/chunk-HAXNUIGQ.js +1245 -0
- package/dist/bundle/chunk-HGL63O5V.js +288 -0
- package/dist/bundle/chunk-INFYLWUA.js +929 -0
- package/dist/bundle/chunk-IRV2PCQ2.js +5213 -0
- package/dist/bundle/chunk-K3UIB6ZF.js +45 -0
- package/dist/bundle/chunk-LRGYKOCP.js +91 -0
- package/dist/bundle/chunk-LSPIOT6Z.js +459 -0
- package/dist/bundle/chunk-MBDK4YXG.js +34 -0
- package/dist/bundle/chunk-N6FLBXZS.js +73 -0
- package/dist/bundle/chunk-OTD2ZRXD.js +161 -0
- package/dist/bundle/chunk-P33NDCDI.js +78 -0
- package/dist/bundle/chunk-P364PLIK.js +257 -0
- package/dist/bundle/chunk-PH5FZX6E.js +193 -0
- package/dist/bundle/chunk-POC3V3AO.js +36616 -0
- package/dist/bundle/chunk-QC53QBNC.js +143 -0
- package/dist/bundle/chunk-QGMDQ2PM.js +122 -0
- package/dist/bundle/chunk-QIPTIUMJ.js +281 -0
- package/dist/bundle/chunk-QMPN6WKD.js +3512 -0
- package/dist/bundle/chunk-QQXH2OPB.js +594 -0
- package/dist/bundle/chunk-QSNROIJL.js +413 -0
- package/dist/bundle/chunk-RRJNNPR4.js +76 -0
- package/dist/bundle/chunk-SFRNX2TI.js +6848 -0
- package/dist/bundle/chunk-SGRYYE4X.js +266 -0
- package/dist/bundle/chunk-TE3FR6MI.js +884 -0
- package/dist/bundle/chunk-U5ACMCAQ.js +12049 -0
- package/dist/bundle/chunk-VEWWAGTD.js +2315 -0
- package/dist/bundle/chunk-VL6SPMZV.js +194 -0
- package/dist/bundle/chunk-WII44RXN.js +58 -0
- package/dist/bundle/chunk-WKRQ44EH.js +528 -0
- package/dist/bundle/chunk-WTPMJYMD.js +8308 -0
- package/dist/bundle/chunk-XD4FRDSL.js +565 -0
- package/dist/bundle/chunk-XJXONOB5.js +63 -0
- package/dist/bundle/chunk-XNHSPHUN.js +48 -0
- package/dist/bundle/chunk-XRFJWHY5.js +131 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YYO7D2MO.js +783 -0
- package/dist/bundle/chunk-YZ5LHE5Q.js +31 -0
- package/dist/bundle/chunk-ZDQQCXFG.js +392 -0
- package/dist/bundle/chunk-ZEW4P6AH.js +158 -0
- package/dist/bundle/chunk-ZGZT5S6B.js +3480 -0
- package/dist/bundle/chunk-ZIAQPTUS.js +82 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-OKQOE6G4.js +30 -0
- package/dist/bundle/decode-5ZPLTYV6.js +160 -0
- package/dist/bundle/dist-6Y64DTOE.js +7577 -0
- package/dist/bundle/echarts-J6LAPIX7.js +42501 -0
- package/dist/bundle/embed-YG5LDHME.js +35 -0
- package/dist/bundle/embedder-7FNUA5OZ.js +108 -0
- package/dist/bundle/first-run-JPZNWIJN.js +23 -0
- package/dist/bundle/first-screen-VQM4MTS7.js +28 -0
- package/dist/bundle/instructions-AXWTQHMR.js +11 -0
- package/dist/bundle/mcp-7F46P6AM.js +165 -0
- package/dist/bundle/mcp-HUD6UH5X.js +160 -0
- package/dist/bundle/mcp-J5R5A65I.js +87 -0
- package/dist/bundle/node-CWKAIOEM.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LSEKVRDA.js +67 -0
- package/dist/bundle/oauth-THYNLRLD.js +17 -0
- package/dist/bundle/open-E47QYKFC.js +20 -0
- package/dist/bundle/openai-EWSGC3BC.js +227 -0
- package/dist/bundle/process-WKTEA3WE.js +91 -0
- package/dist/bundle/program-UYX5362I.js +20851 -0
- package/dist/bundle/prompt-CAQ7QR3U.js +12 -0
- package/dist/bundle/recognize-6KGHNZC3.js +23 -0
- package/dist/bundle/remote-3UO2WDC3.js +26 -0
- package/dist/bundle/rerank-2JVDPZBX.js +49 -0
- package/dist/bundle/serve-ES7AG5IK.js +19 -0
- package/dist/bundle/server-5LE5LNUQ.js +45 -0
- package/dist/bundle/server-BU4VBM6S.js +58 -0
- package/dist/bundle/state-7NH5G4XJ.js +33 -0
- package/dist/bundle/store-7O4JQD2Z.js +127 -0
- package/dist/bundle/store-maintenance-command-UDVGEY2D.js +47 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +131 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/crm-writes.d.ts +4 -0
- package/dist/commands/crm-writes.d.ts.map +1 -0
- package/dist/commands/crm-writes.js +182 -0
- package/dist/commands/crm-writes.js.map +1 -0
- package/dist/commands/crm.d.ts +3 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +144 -0
- package/dist/commands/crm.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +74 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +97 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +101 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/write.d.ts +21 -0
- package/dist/commands/write.d.ts.map +1 -0
- package/dist/commands/write.js +47 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/crm/conditions.d.ts +25 -0
- package/dist/crm/conditions.d.ts.map +1 -0
- package/dist/crm/conditions.js +78 -0
- package/dist/crm/conditions.js.map +1 -0
- package/dist/crm/deal.d.ts +27 -0
- package/dist/crm/deal.d.ts.map +1 -0
- package/dist/crm/deal.js +74 -0
- package/dist/crm/deal.js.map +1 -0
- package/dist/crm/items.d.ts +30 -0
- package/dist/crm/items.d.ts.map +1 -0
- package/dist/crm/items.js +76 -0
- package/dist/crm/items.js.map +1 -0
- package/dist/crm/lead.d.ts +36 -0
- package/dist/crm/lead.d.ts.map +1 -0
- package/dist/crm/lead.js +85 -0
- package/dist/crm/lead.js.map +1 -0
- package/dist/crm/organization.d.ts +32 -0
- package/dist/crm/organization.d.ts.map +1 -0
- package/dist/crm/organization.js +67 -0
- package/dist/crm/organization.js.map +1 -0
- package/dist/crm/person.d.ts +31 -0
- package/dist/crm/person.d.ts.map +1 -0
- package/dist/crm/person.js +67 -0
- package/dist/crm/person.js.map +1 -0
- package/dist/crm/pipeline.d.ts +17 -0
- package/dist/crm/pipeline.d.ts.map +1 -0
- package/dist/crm/pipeline.js +42 -0
- package/dist/crm/pipeline.js.map +1 -0
- package/dist/crm/product.d.ts +43 -0
- package/dist/crm/product.d.ts.map +1 -0
- package/dist/crm/product.js +42 -0
- package/dist/crm/product.js.map +1 -0
- package/dist/crm/stage.d.ts +20 -0
- package/dist/crm/stage.d.ts.map +1 -0
- package/dist/crm/stage.js +65 -0
- package/dist/crm/stage.js.map +1 -0
- package/dist/crm/user.d.ts +39 -0
- package/dist/crm/user.d.ts.map +1 -0
- package/dist/crm/user.js +54 -0
- package/dist/crm/user.js.map +1 -0
- package/dist/crm/values.d.ts +33 -0
- package/dist/crm/values.d.ts.map +1 -0
- package/dist/crm/values.js +54 -0
- package/dist/crm/values.js.map +1 -0
- package/dist/crm/walk.d.ts +19 -0
- package/dist/crm/walk.d.ts.map +1 -0
- package/dist/crm/walk.js +22 -0
- package/dist/crm/walk.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +18 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +99 -0
- package/dist/mcp.js.map +1 -0
- package/dist/portal.d.ts +47 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +52 -0
- package/dist/portal.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +45 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +28 -0
- package/dist/reasons.js.map +1 -0
- package/dist/token.d.ts +12 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +41 -0
- package/dist/token.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/whoami.d.ts +8 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +9 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +83 -4
- package/skills/bitrix24-cli/SKILL.md +41 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
stringWidth,
|
|
5
|
+
wrapAnsi
|
|
6
|
+
} from "./chunk-INFYLWUA.js";
|
|
7
|
+
import {
|
|
8
|
+
singleLine,
|
|
9
|
+
visibleControls
|
|
10
|
+
} from "./chunk-IRV2PCQ2.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
16
|
+
import { styleText } from "node:util";
|
|
17
|
+
var TIME_WIDTH = 8;
|
|
18
|
+
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
19
|
+
var MIN_WIDTH = 40;
|
|
20
|
+
var SENDER_COLOURS = ["green", "yellow", "magenta", "blue", "red"];
|
|
21
|
+
var renderMessages = /* @__PURE__ */ __name((messages, options = {}) => {
|
|
22
|
+
if (messages.length === 0)
|
|
23
|
+
return "(nothing)";
|
|
24
|
+
const day = dayFormatter(options);
|
|
25
|
+
const paint = painter(options);
|
|
26
|
+
let previous;
|
|
27
|
+
const blocks = [];
|
|
28
|
+
for (const message of messages) {
|
|
29
|
+
const date = day(message.timestamp);
|
|
30
|
+
if (date !== previous)
|
|
31
|
+
blocks.push(paint("dim", `\u2500\u2500 ${date} \u2500\u2500`));
|
|
32
|
+
previous = date;
|
|
33
|
+
blocks.push(renderMessage(message, options));
|
|
34
|
+
}
|
|
35
|
+
return blocks.join("\n\n");
|
|
36
|
+
}, "renderMessages");
|
|
37
|
+
var renderMessage = /* @__PURE__ */ __name((message, options = {}) => {
|
|
38
|
+
const paint = painter(options);
|
|
39
|
+
const width = Math.max(MIN_WIDTH, options.width ?? 80);
|
|
40
|
+
const room = width - INDENT.length;
|
|
41
|
+
const time = timeFormatter(options);
|
|
42
|
+
const verbosity = options.verbosity ?? 0;
|
|
43
|
+
const chat = "chatTitle" in message ? paint("dim", ` \xB7 ${singleLine(message.chatTitle ?? message.chatId)}`) : "";
|
|
44
|
+
const mark = "anchor" in message && message.anchor ? paint("bold", " \u25C0") : "";
|
|
45
|
+
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message, options)}${chat}${mark}`];
|
|
46
|
+
const body = /* @__PURE__ */ __name((text) => wrapAnsi(visibleControls(text), room, { hard: true }).split("\n"), "body");
|
|
47
|
+
const email = message.email;
|
|
48
|
+
if (email)
|
|
49
|
+
lines.push(paint("dim", mailLine(email)));
|
|
50
|
+
if (message.replyTo)
|
|
51
|
+
lines.push(paint("dim", preview("\u21B3", message.replyTo, room, options)));
|
|
52
|
+
if (message.forwardedFrom) {
|
|
53
|
+
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom, options)}`));
|
|
54
|
+
if (message.forwardedFrom.text)
|
|
55
|
+
for (const line of body(message.forwardedFrom.text))
|
|
56
|
+
lines.push(line);
|
|
57
|
+
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint, options));
|
|
58
|
+
}
|
|
59
|
+
if (message.text)
|
|
60
|
+
for (const line of body(message.text))
|
|
61
|
+
lines.push(line);
|
|
62
|
+
lines.push(...attachmentLines(message.attachments, paint, options));
|
|
63
|
+
if (message.reactions && message.reactions.total > 0)
|
|
64
|
+
lines.push(paint("dim", reactionLine(message.reactions)));
|
|
65
|
+
if (message.editedAt)
|
|
66
|
+
lines.push(paint("dim", `edited ${editedAt(message, options)}`));
|
|
67
|
+
if (verbosity >= 1) {
|
|
68
|
+
const fields = [
|
|
69
|
+
["message", message.id],
|
|
70
|
+
["sender", message.senderId],
|
|
71
|
+
["chat", message.chatId],
|
|
72
|
+
["reply to", message.replyTo?.id ?? message.replyToId],
|
|
73
|
+
["thread", message.threadId],
|
|
74
|
+
["forward of", message.forwardedFrom?.id],
|
|
75
|
+
...message.attachments.map((a) => ["link", a.url])
|
|
76
|
+
];
|
|
77
|
+
if (verbosity >= 2) {
|
|
78
|
+
fields.push(["provider", options.provider], ["profile", options.profile], ["sent", message.timestamp], ["edited", message.editedAt], ["outgoing", message.outgoing === null ? "unknown" : String(message.outgoing)], ...message.attachments.map((a) => ["attachment", JSON.stringify(a)]), ["metadata", message.providerMetadata && JSON.stringify(message.providerMetadata)]);
|
|
79
|
+
}
|
|
80
|
+
const shown = fields.filter((field) => typeof field[1] === "string");
|
|
81
|
+
const label = Math.max(...shown.map(([key]) => key.length));
|
|
82
|
+
lines.push("", ...shown.map(([key, value]) => paint("dim", `${key.padEnd(label)} ${singleLine(value)}`)));
|
|
83
|
+
}
|
|
84
|
+
return lines.map((line, index) => index === 0 || line === "" ? line : `${INDENT}${line}`).join("\n");
|
|
85
|
+
}, "renderMessage");
|
|
86
|
+
var mailLine = /* @__PURE__ */ __name(({ to, cc, labels }) => {
|
|
87
|
+
const names = /* @__PURE__ */ __name((people) => people.map(({ name, address }) => singleLine(name ?? address)).join(", "), "names");
|
|
88
|
+
return [to.length ? `to ${names(to)}` : "", cc.length ? `cc ${names(cc)}` : "", labels.join(", ")].filter(Boolean).join(" \xB7 ");
|
|
89
|
+
}, "mailLine");
|
|
90
|
+
var painter = /* @__PURE__ */ __name(({ color = false }) => (style, text) => color ? styleText(style, text, { validateStream: false }) : text, "painter");
|
|
91
|
+
var senderOf = /* @__PURE__ */ __name((message, options) => {
|
|
92
|
+
const paint = painter(options);
|
|
93
|
+
if (message.outgoing === true)
|
|
94
|
+
return paint(["bold", "cyan"], you(options));
|
|
95
|
+
const name = nameOf(message, options);
|
|
96
|
+
if (!options.senderColors)
|
|
97
|
+
return paint("bold", name);
|
|
98
|
+
const colour = SENDER_COLOURS[hash(message.senderId ?? name) % SENDER_COLOURS.length] ?? "green";
|
|
99
|
+
return paint(["bold", colour], name);
|
|
100
|
+
}, "senderOf");
|
|
101
|
+
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing }, options) => outgoing === true ? you(options) : singleLine(senderName ?? senderId ?? "unknown"), "nameOf");
|
|
102
|
+
var DEFAULT_LOCALE = "ru-RU";
|
|
103
|
+
var you = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE }) => locale.startsWith("ru") ? "\u0432\u044B" : "you", "you");
|
|
104
|
+
var hash = /* @__PURE__ */ __name((value) => [...value].reduce((sum, char) => sum * 31 + char.charCodeAt(0) >>> 0, 7), "hash");
|
|
105
|
+
var preview = /* @__PURE__ */ __name((mark, quoted, room, options) => {
|
|
106
|
+
const text = singleLine(quoted.text.split("\n")[0] ?? "") || (quoted.attachments[0] ? `\u{1F4CE} ${quoted.attachments[0].kind}` : "");
|
|
107
|
+
const line = text ? `${mark} ${nameOf(quoted, options)}: ${text}` : `${mark} message ${quoted.id}`;
|
|
108
|
+
if (stringWidth(line) <= room)
|
|
109
|
+
return line;
|
|
110
|
+
return `${wrapAnsi(line, room - 1, { hard: true }).split("\n")[0]}\u2026`;
|
|
111
|
+
}, "preview");
|
|
112
|
+
var attachmentLines = /* @__PURE__ */ __name((attachments, paint, options) => {
|
|
113
|
+
const link = /* @__PURE__ */ __name((label, raw) => {
|
|
114
|
+
if (raw === void 0)
|
|
115
|
+
return label;
|
|
116
|
+
const url = singleLine(raw);
|
|
117
|
+
return options.color ? `\x1B]8;;${url}\x07${label}\x1B]8;;\x07` : `${label} ${url}`;
|
|
118
|
+
}, "link");
|
|
119
|
+
let number = 0;
|
|
120
|
+
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++number} ${singleLine(button.text)}]`, button.url)).join(" ")));
|
|
121
|
+
const polls = attachments.flatMap((attachment) => attachment.poll ? pollLines(attachment.poll) : []);
|
|
122
|
+
const cards = attachments.flatMap(({ contact }) => contact ? [
|
|
123
|
+
paint("dim", `\u{1F464} ${[contact.name, contact.phone].flatMap((part) => part ? [singleLine(part)] : []).join(" \xB7 ")}`)
|
|
124
|
+
] : []);
|
|
125
|
+
const groups = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const attachment of attachments) {
|
|
127
|
+
if (attachment.buttons || attachment.poll || attachment.contact)
|
|
128
|
+
continue;
|
|
129
|
+
const key = singleLine(attachment.name ?? attachment.title ?? attachment.kind);
|
|
130
|
+
groups.set(key, [...groups.get(key) ?? [], attachment]);
|
|
131
|
+
}
|
|
132
|
+
const files = [...groups].map(([label, same]) => {
|
|
133
|
+
const first = same[0];
|
|
134
|
+
const size = first?.size === void 0 ? "" : ` \xB7 ${megabytes(first.size)}`;
|
|
135
|
+
if (same.length === 1)
|
|
136
|
+
return paint("dim", `\u{1F4CE} ${link(`${label}${size}`, first?.url)}`);
|
|
137
|
+
const each = same.map((attachment, index) => link(String(index + 1), attachment.url)).join(" ");
|
|
138
|
+
return paint("dim", `\u{1F4CE} ${label} \xD7${same.length} ${each}`);
|
|
139
|
+
});
|
|
140
|
+
return [...polls, ...cards, ...files, ...keyboard];
|
|
141
|
+
}, "attachmentLines");
|
|
142
|
+
var pollLines = /* @__PURE__ */ __name((poll) => {
|
|
143
|
+
const kind = [
|
|
144
|
+
poll.closed ? "closed" : "",
|
|
145
|
+
poll.multiple ? "several answers" : "",
|
|
146
|
+
poll.anonymous ? "anonymous" : "",
|
|
147
|
+
poll.quiz ? "quiz" : ""
|
|
148
|
+
].filter(Boolean);
|
|
149
|
+
const count = /* @__PURE__ */ __name((voters) => voters === null ? "?" : String(voters), "count");
|
|
150
|
+
return [
|
|
151
|
+
`\u{1F4CA} ${visibleControls(poll.question)}`,
|
|
152
|
+
...poll.answers.map((answer) => ` [${answer.id}] ${visibleControls(answer.text)} \u2014 ${count(answer.voters)}${answer.chosen ? " \u2713" : ""}`),
|
|
153
|
+
` ${[`${count(poll.voters)} voted`, ...kind].join(" \xB7 ")}`
|
|
154
|
+
];
|
|
155
|
+
}, "pollLines");
|
|
156
|
+
var megabytes = /* @__PURE__ */ __name((bytes) => bytes >= 1e6 ? `${Math.round(bytes / 1e6)} MB` : `${Math.max(1, Math.round(bytes / 1e3))} KB`, "megabytes");
|
|
157
|
+
var parts = /* @__PURE__ */ __name((format, iso) => Object.fromEntries(format.formatToParts(new Date(iso)).map(({ type, value }) => [type, value])), "parts");
|
|
158
|
+
var timeFormatter = /* @__PURE__ */ __name(({ timeZone }) => {
|
|
159
|
+
const format = new Intl.DateTimeFormat("en-GB", {
|
|
160
|
+
hour: "2-digit",
|
|
161
|
+
minute: "2-digit",
|
|
162
|
+
second: "2-digit",
|
|
163
|
+
hourCycle: "h23",
|
|
164
|
+
...timeZone ? { timeZone } : {}
|
|
165
|
+
});
|
|
166
|
+
return (iso) => {
|
|
167
|
+
const { hour, minute, second } = parts(format, iso);
|
|
168
|
+
return `${hour}:${minute}:${second}`;
|
|
169
|
+
};
|
|
170
|
+
}, "timeFormatter");
|
|
171
|
+
var dayFormatter = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE, timeZone }) => {
|
|
172
|
+
const format = new Intl.DateTimeFormat(locale, {
|
|
173
|
+
day: "numeric",
|
|
174
|
+
month: "long",
|
|
175
|
+
year: "numeric",
|
|
176
|
+
...timeZone ? { timeZone } : {}
|
|
177
|
+
});
|
|
178
|
+
return (iso) => format.format(new Date(iso)).replace(/\s*г\.$/, "");
|
|
179
|
+
}, "dayFormatter");
|
|
180
|
+
var reactionLine = /* @__PURE__ */ __name(({ counts, mine }) => {
|
|
181
|
+
const shown = counts.map(({ reaction, count }) => `${singleLine(reaction)} ${count}`).join(" ");
|
|
182
|
+
return mine ? `${shown} (you: ${singleLine(mine)})` : shown;
|
|
183
|
+
}, "reactionLine");
|
|
184
|
+
var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
185
|
+
const edited = message.editedAt ?? message.timestamp;
|
|
186
|
+
const time = timeFormatter(options)(edited);
|
|
187
|
+
const day = dayFormatter(options);
|
|
188
|
+
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
189
|
+
}, "editedAt");
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
renderMessages
|
|
193
|
+
};
|