@openclaw/line 2026.11.10 → 2026.12.1-beta.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.
- package/dist/.setup/api-B2wI3umU.mjs +3 -0
- package/dist/.setup/{api-CsvNTUeD.mjs → api-BEzEEC5x.mjs} +1 -1
- package/dist/.setup/{card-command-utjlRvb-.mjs → card-command-CxXAu1W-.mjs} +2 -2
- package/dist/.setup/{channel-DKx73los.mjs → channel-CP5-K_ID.mjs} +357 -10
- package/dist/.setup/channel.runtime-D6OWIDkw.mjs +4 -0
- package/dist/.setup/{monitor-Bo2s83rD.mjs → monitor-ClTD6chi.mjs} +6 -7
- package/dist/.setup/outbound.runtime-WmCUvxNB.mjs +3 -0
- package/dist/.setup/{send-retry-D6J7bThI.mjs → schedule-cards-D2zI0jRv.mjs} +3 -352
- package/dist/.setup/{send-H86JOXWw.mjs → send-BESSixO4.mjs} +298 -30
- package/dist/.setup/template-messages-CHhFDk8x.mjs +158 -0
- package/dist/.source-module-urls/2c97352967966b7ab9f67f528eb25c098b6fe10ea0e4616ffae3851ed839d81e.json +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/package.json +4 -4
- package/dist/.setup/api-C1rO_8GZ.mjs +0 -3
- package/dist/.setup/channel.runtime-4IuGUdfn.mjs +0 -4
- package/dist/.setup/outbound.runtime-BhQfx5xP.mjs +0 -3
- package/dist/.setup/template-messages-BZzuYlsa.mjs +0 -424
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import { C as uriAction, T as toFlexMessage, g as cardText, h as cardBox, u as createReceiptCard, w as fitsLineFlexBubble, x as postbackAction, y as messageAction } from "./send-retry-D6J7bThI.mjs";
|
|
2
|
-
import { markdownToIRWithMeta, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
|
|
3
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
4
|
-
// extensions/line/src/markdown-to-line.ts
|
|
5
|
-
const LINE_MARKDOWN_OPTIONS = {
|
|
6
|
-
assistantTranscriptRoleHeaders: true,
|
|
7
|
-
autolink: false,
|
|
8
|
-
blockquotePrefix: "",
|
|
9
|
-
headingStyle: "none",
|
|
10
|
-
horizontalRuleText: "",
|
|
11
|
-
linkify: false,
|
|
12
|
-
preserveSourceBlockSpacing: true
|
|
13
|
-
};
|
|
14
|
-
const TRANSCRIPT_ROLE_PREFIX = "[assistant-authored transcript] ";
|
|
15
|
-
const LINE_FLEX_CODE_CARD_MAX_CHARS = 2e3;
|
|
16
|
-
function parseLineMarkdown(text, tableMode = "block") {
|
|
17
|
-
return markdownToIRWithMeta(text, {
|
|
18
|
-
...LINE_MARKDOWN_OPTIONS,
|
|
19
|
-
tableMode
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function rangesOverlap(left, right) {
|
|
23
|
-
return left.start < right.end && right.start < left.end;
|
|
24
|
-
}
|
|
25
|
-
/** A link shows its href after the label unless the label already is that address. */
|
|
26
|
-
function linkAddsHref(rawLabel, href) {
|
|
27
|
-
const label = rawLabel.trim();
|
|
28
|
-
return Boolean(href && label && label !== href && `mailto:${label}` !== href);
|
|
29
|
-
}
|
|
30
|
-
function projectPlainText(ir, omitted = [], additionalInsertions = [], onSegment) {
|
|
31
|
-
const insertions = [...additionalInsertions];
|
|
32
|
-
for (const link of ir.links) {
|
|
33
|
-
if (omitted.some((range) => rangesOverlap(range, link))) continue;
|
|
34
|
-
const href = link.href.trim();
|
|
35
|
-
if (linkAddsHref(ir.text.slice(link.start, link.end), href)) insertions.push({
|
|
36
|
-
position: link.end,
|
|
37
|
-
text: ` (${href})`
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
for (const annotation of ir.annotations ?? []) if (annotation.type === "assistant_transcript_role" && !omitted.some((range) => rangesOverlap(range, annotation))) insertions.push({
|
|
41
|
-
position: annotation.start,
|
|
42
|
-
text: TRANSCRIPT_ROLE_PREFIX
|
|
43
|
-
});
|
|
44
|
-
const inlineCodeSpans = ir.styles.filter((span) => span.style === "code" && !omitted.some((range) => rangesOverlap(range, span)));
|
|
45
|
-
for (const span of inlineCodeSpans) {
|
|
46
|
-
const code = ir.text.slice(span.start, span.end);
|
|
47
|
-
if (stripMarkdown(code, { assistantTranscriptRoleHeaders: true }).startsWith(TRANSCRIPT_ROLE_PREFIX)) insertions.push({
|
|
48
|
-
position: span.start,
|
|
49
|
-
text: TRANSCRIPT_ROLE_PREFIX
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
insertions.sort((left, right) => left.position - right.position);
|
|
53
|
-
const underlineTags = [...ir.text.matchAll(/<\/?u>/gi)].map((match) => ({
|
|
54
|
-
start: match.index,
|
|
55
|
-
end: match.index + match[0].length
|
|
56
|
-
})).filter((tag) => !inlineCodeSpans.some((span) => rangesOverlap(tag, span)) && !omitted.some((span) => rangesOverlap(tag, span)));
|
|
57
|
-
const removed = [...omitted, ...underlineTags].toSorted((left, right) => left.start - right.start);
|
|
58
|
-
let output = "";
|
|
59
|
-
let segmentStart = 0;
|
|
60
|
-
let cursor = 0;
|
|
61
|
-
let insertionIndex = 0;
|
|
62
|
-
const appendRange = (end) => {
|
|
63
|
-
while (insertionIndex < insertions.length) {
|
|
64
|
-
const insertion = insertions[insertionIndex];
|
|
65
|
-
if (!insertion || insertion.position > end) break;
|
|
66
|
-
if (insertion.position >= cursor) {
|
|
67
|
-
output += ir.text.slice(cursor, insertion.position);
|
|
68
|
-
if ("text" in insertion) output += insertion.text;
|
|
69
|
-
else if (onSegment) {
|
|
70
|
-
const precedingText = output.slice(segmentStart).trim();
|
|
71
|
-
if (precedingText) onSegment({
|
|
72
|
-
type: "text",
|
|
73
|
-
text: precedingText
|
|
74
|
-
});
|
|
75
|
-
onSegment({
|
|
76
|
-
type: "flex",
|
|
77
|
-
message: insertion.message
|
|
78
|
-
});
|
|
79
|
-
segmentStart = output.length;
|
|
80
|
-
}
|
|
81
|
-
cursor = insertion.position;
|
|
82
|
-
}
|
|
83
|
-
insertionIndex += 1;
|
|
84
|
-
}
|
|
85
|
-
output += ir.text.slice(cursor, end);
|
|
86
|
-
cursor = end;
|
|
87
|
-
};
|
|
88
|
-
for (const range of removed) {
|
|
89
|
-
appendRange(range.start);
|
|
90
|
-
cursor = Math.max(cursor, range.end);
|
|
91
|
-
while (insertionIndex < insertions.length && (insertions[insertionIndex]?.position ?? cursor) < cursor) insertionIndex += 1;
|
|
92
|
-
}
|
|
93
|
-
appendRange(ir.text.length);
|
|
94
|
-
if (onSegment) {
|
|
95
|
-
const trailingText = output.slice(segmentStart).trim();
|
|
96
|
-
if (trailingText) onSegment({
|
|
97
|
-
type: "text",
|
|
98
|
-
text: trailingText
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return output.trim();
|
|
102
|
-
}
|
|
103
|
-
function renderTableCell(cell) {
|
|
104
|
-
if (!cell.text.trim()) return {
|
|
105
|
-
text: "-",
|
|
106
|
-
hasMarkup: false
|
|
107
|
-
};
|
|
108
|
-
const codeSpans = cell.styles.filter((span) => span.style === "code");
|
|
109
|
-
const tags = [...cell.text.matchAll(/<\/?u>/gi)].map((match) => ({
|
|
110
|
-
start: match.index,
|
|
111
|
-
end: match.index + match[0].length,
|
|
112
|
-
closing: match[0][1] === "/"
|
|
113
|
-
})).filter((tag) => !codeSpans.some((span) => rangesOverlap(tag, span)));
|
|
114
|
-
const boundaries = /* @__PURE__ */ new Set([0, cell.text.length]);
|
|
115
|
-
for (const style of cell.styles) {
|
|
116
|
-
boundaries.add(style.start);
|
|
117
|
-
boundaries.add(style.end);
|
|
118
|
-
}
|
|
119
|
-
for (const link of cell.links) boundaries.add(link.end);
|
|
120
|
-
for (const tag of tags) {
|
|
121
|
-
boundaries.add(tag.start);
|
|
122
|
-
boundaries.add(tag.end);
|
|
123
|
-
}
|
|
124
|
-
const sortedBoundaries = [...boundaries].toSorted((left, right) => left - right);
|
|
125
|
-
const spans = [];
|
|
126
|
-
let underlineDepth = 0;
|
|
127
|
-
let hasMarkup = false;
|
|
128
|
-
const appendSpan = (span) => {
|
|
129
|
-
const previous = spans.at(-1);
|
|
130
|
-
if (previous && previous.weight === span.weight && previous.style === span.style && previous.decoration === span.decoration) previous.text = `${previous.text ?? ""}${span.text ?? ""}`;
|
|
131
|
-
else spans.push(span);
|
|
132
|
-
};
|
|
133
|
-
for (let index = 0; index < sortedBoundaries.length - 1; index += 1) {
|
|
134
|
-
const start = sortedBoundaries[index];
|
|
135
|
-
const end = sortedBoundaries[index + 1];
|
|
136
|
-
if (start === void 0 || end === void 0) continue;
|
|
137
|
-
const tag = tags.find((candidate) => candidate.start === start);
|
|
138
|
-
if (tag) {
|
|
139
|
-
underlineDepth += tag.closing ? -1 : 1;
|
|
140
|
-
hasMarkup = true;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const text = cell.text.slice(start, end);
|
|
144
|
-
if (text) {
|
|
145
|
-
const active = new Set(cell.styles.filter((style) => style.start <= start && style.end >= end).map((style) => style.style));
|
|
146
|
-
const weight = active.has("bold") ? "bold" : void 0;
|
|
147
|
-
const style = active.has("italic") ? "italic" : void 0;
|
|
148
|
-
const decoration = active.has("strikethrough") ? "line-through" : underlineDepth > 0 ? "underline" : void 0;
|
|
149
|
-
hasMarkup ||= weight !== void 0 || style !== void 0 || decoration !== void 0;
|
|
150
|
-
appendSpan({
|
|
151
|
-
type: "span",
|
|
152
|
-
text,
|
|
153
|
-
weight,
|
|
154
|
-
style,
|
|
155
|
-
decoration
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
for (const link of cell.links.filter((candidate) => candidate.end === end)) {
|
|
159
|
-
const href = link.href.trim();
|
|
160
|
-
if (linkAddsHref(cell.text.slice(link.start, link.end), href)) {
|
|
161
|
-
appendSpan({
|
|
162
|
-
type: "span",
|
|
163
|
-
text: ` (${href})`
|
|
164
|
-
});
|
|
165
|
-
hasMarkup = true;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
text: spans.map((span) => span.text ?? "").join("").trim() || "-",
|
|
171
|
-
...hasMarkup ? { contents: spans } : {},
|
|
172
|
-
hasMarkup
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function convertTableToFlexBubble(table) {
|
|
176
|
-
const requiresPlainCells = table.rowCells.length > 10;
|
|
177
|
-
if (requiresPlainCells && (table.headers.length !== 2 || table.rowCells.length > 12)) return;
|
|
178
|
-
let hasInlineMarkup = false;
|
|
179
|
-
const renderCells = (cells) => {
|
|
180
|
-
const rendered = [];
|
|
181
|
-
for (const cell of cells) {
|
|
182
|
-
const prepared = renderTableCell(cell);
|
|
183
|
-
if (requiresPlainCells && prepared.hasMarkup) return;
|
|
184
|
-
hasInlineMarkup ||= prepared.hasMarkup;
|
|
185
|
-
rendered.push(prepared);
|
|
186
|
-
}
|
|
187
|
-
return rendered;
|
|
188
|
-
};
|
|
189
|
-
const headerCells = renderCells(table.headerCells);
|
|
190
|
-
if (!headerCells) return;
|
|
191
|
-
const rowCells = [];
|
|
192
|
-
for (const row of table.rowCells) {
|
|
193
|
-
const cells = renderCells(row);
|
|
194
|
-
if (!cells) return;
|
|
195
|
-
rowCells.push(cells);
|
|
196
|
-
}
|
|
197
|
-
if (table.headers.length === 2 && !hasInlineMarkup) return createReceiptCard({
|
|
198
|
-
title: headerCells.map((cell) => cell.text).join(" / "),
|
|
199
|
-
items: rowCells.map((row) => ({
|
|
200
|
-
name: row[0]?.text ?? "-",
|
|
201
|
-
value: row[1]?.text ?? "-"
|
|
202
|
-
}))
|
|
203
|
-
});
|
|
204
|
-
const renderRow = (cells, textStyle, rowStyle) => cardBox("horizontal", cells.map((cell) => cardText(cell.text, {
|
|
205
|
-
contents: cell.contents,
|
|
206
|
-
...textStyle,
|
|
207
|
-
size: "sm",
|
|
208
|
-
flex: 1,
|
|
209
|
-
wrap: true
|
|
210
|
-
})), rowStyle);
|
|
211
|
-
const headerRow = renderRow(headerCells, {
|
|
212
|
-
weight: "bold",
|
|
213
|
-
color: "#333333"
|
|
214
|
-
}, { paddingBottom: "sm" });
|
|
215
|
-
const dataRows = rowCells.map((row, rowIndex) => renderRow(table.headers.map((_, colIndex) => row[colIndex] ?? {
|
|
216
|
-
text: "-",
|
|
217
|
-
hasMarkup: false
|
|
218
|
-
}), { color: "#666666" }, { margin: rowIndex === 0 ? "md" : "sm" }));
|
|
219
|
-
return {
|
|
220
|
-
type: "bubble",
|
|
221
|
-
body: cardBox("vertical", [
|
|
222
|
-
headerRow,
|
|
223
|
-
{
|
|
224
|
-
type: "separator",
|
|
225
|
-
margin: "sm"
|
|
226
|
-
},
|
|
227
|
-
...dataRows
|
|
228
|
-
], { paddingAll: "lg" })
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
/** Parse once, route existing block surfaces to Flex, and project the remainder as plain text. */
|
|
232
|
-
function processLineMessage(text) {
|
|
233
|
-
const { ir, tables } = parseLineMarkdown(text);
|
|
234
|
-
const codeSpans = ir.styles.filter((span) => span.style === "code_block");
|
|
235
|
-
const plainTextInsertions = [];
|
|
236
|
-
for (const table of tables) {
|
|
237
|
-
const bubble = convertTableToFlexBubble(table);
|
|
238
|
-
if (!bubble || !fitsLineFlexBubble(bubble)) {
|
|
239
|
-
const markdownCell = (cell) => projectPlainText(cell).replace(/[\\|`*_[\]~<>&]/gu, "\\$&").replace(/\r?\n/gu, " ");
|
|
240
|
-
const markdownRow = (cells) => `| ${cells.map(markdownCell).join(" | ")} |`;
|
|
241
|
-
const markdown = [
|
|
242
|
-
markdownRow(table.headerCells),
|
|
243
|
-
`| ${table.headerCells.map(() => "---").join(" | ")} |`,
|
|
244
|
-
...table.rowCells.map(markdownRow)
|
|
245
|
-
].join("\n");
|
|
246
|
-
plainTextInsertions.push({
|
|
247
|
-
position: table.placeholderOffset,
|
|
248
|
-
text: `\n\n${projectPlainText(parseLineMarkdown(markdown, "bullets").ir)}\n\n`
|
|
249
|
-
});
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
const message = toFlexMessage("Table", bubble);
|
|
253
|
-
plainTextInsertions.push({
|
|
254
|
-
position: table.placeholderOffset,
|
|
255
|
-
message
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
for (const span of codeSpans) {
|
|
259
|
-
const block = {
|
|
260
|
-
...span.language ? { language: span.language } : {},
|
|
261
|
-
code: ir.text.slice(span.start, span.end).trimEnd()
|
|
262
|
-
};
|
|
263
|
-
if (!block.code.trim()) continue;
|
|
264
|
-
if (block.code.length > LINE_FLEX_CODE_CARD_MAX_CHARS) {
|
|
265
|
-
plainTextInsertions.push({
|
|
266
|
-
position: span.start,
|
|
267
|
-
text: `\n\n${block.code}\n\n`
|
|
268
|
-
});
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
const titleText = block.language ? `Code (${block.language})` : "Code";
|
|
272
|
-
plainTextInsertions.push({
|
|
273
|
-
position: span.start,
|
|
274
|
-
message: toFlexMessage("Code", {
|
|
275
|
-
type: "bubble",
|
|
276
|
-
body: cardBox("vertical", [cardText(titleText, {
|
|
277
|
-
weight: "bold",
|
|
278
|
-
size: "sm",
|
|
279
|
-
color: "#666666"
|
|
280
|
-
}), cardBox("vertical", [cardText(block.code, {
|
|
281
|
-
size: "xs",
|
|
282
|
-
color: "#333333",
|
|
283
|
-
wrap: true
|
|
284
|
-
})], {
|
|
285
|
-
backgroundColor: "#F5F5F5",
|
|
286
|
-
paddingAll: "md",
|
|
287
|
-
cornerRadius: "md",
|
|
288
|
-
margin: "sm"
|
|
289
|
-
})], { paddingAll: "lg" })
|
|
290
|
-
})
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
const segments = [];
|
|
294
|
-
projectPlainText(ir, codeSpans, plainTextInsertions, (segment) => segments.push(segment));
|
|
295
|
-
return segments;
|
|
296
|
-
}
|
|
297
|
-
// packages/normalization-core/src/utf16-slice.ts
|
|
298
|
-
function isHighSurrogate(codeUnit) {
|
|
299
|
-
return codeUnit >= 55296 && codeUnit <= 56319;
|
|
300
|
-
}
|
|
301
|
-
function isLowSurrogate(codeUnit) {
|
|
302
|
-
return codeUnit >= 56320 && codeUnit <= 57343;
|
|
303
|
-
}
|
|
304
|
-
/** Moves a chunk boundary away from the middle of a UTF-16 surrogate pair. */
|
|
305
|
-
function avoidTrailingHighSurrogateBreak(text, start, end) {
|
|
306
|
-
if (end <= start || end >= text.length || !isHighSurrogate(text.charCodeAt(end - 1)) || !isLowSurrogate(text.charCodeAt(end))) return end;
|
|
307
|
-
const adjusted = end - 1;
|
|
308
|
-
return adjusted > start ? adjusted : end + 1;
|
|
309
|
-
}
|
|
310
|
-
// packages/normalization-core/src/grapheme.ts
|
|
311
|
-
let graphemeSegmenter;
|
|
312
|
-
function getGraphemeSegmenter() {
|
|
313
|
-
graphemeSegmenter ??= new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
314
|
-
return graphemeSegmenter;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Chooses a whole-grapheme cut within the hard budget, honoring a usable preference.
|
|
318
|
-
* If no whole grapheme fits, allowPartial permits a surrogate-safe progress cut;
|
|
319
|
-
* a leading surrogate pair can exceed maxEnd by one code unit.
|
|
320
|
-
*/
|
|
321
|
-
function findGraphemeChunkEnd(text, start, maxEnd, preferredEnd = maxEnd, allowPartial = true) {
|
|
322
|
-
const hardEnd = Math.min(maxEnd, text.length);
|
|
323
|
-
if (hardEnd <= start) return start;
|
|
324
|
-
const preferred = Number.isInteger(preferredEnd) && preferredEnd > start && preferredEnd <= hardEnd ? preferredEnd : hardEnd;
|
|
325
|
-
if (preferred === text.length) return preferred;
|
|
326
|
-
const before = text.charCodeAt(preferred - 1);
|
|
327
|
-
const after = text.charCodeAt(preferred);
|
|
328
|
-
if (Number.isInteger(preferred) && before <= 127 && after <= 127 && !(before === 13 && after === 10)) return preferred;
|
|
329
|
-
const segments = getGraphemeSegmenter().segment(text);
|
|
330
|
-
let end = segments.containing(preferred)?.index ?? preferred;
|
|
331
|
-
if (end <= start && preferred < hardEnd) end = hardEnd === text.length ? hardEnd : segments.containing(hardEnd)?.index ?? hardEnd;
|
|
332
|
-
return end > start ? end : allowPartial ? avoidTrailingHighSurrogateBreak(text, start, hardEnd) : start;
|
|
333
|
-
}
|
|
334
|
-
// extensions/line/src/template-messages.ts
|
|
335
|
-
const COMPACT_TEMPLATE_TEXT_LIMIT = 60;
|
|
336
|
-
const TEMPLATE_ALT_TEXT_LIMIT = 1500;
|
|
337
|
-
function buildTemplatePayloadAction(action) {
|
|
338
|
-
if (action.type === "uri" && action.uri) return uriAction(action.label, action.uri);
|
|
339
|
-
if (action.type === "postback" && action.data) return postbackAction(action.label, action.data, action.label);
|
|
340
|
-
return messageAction(action.label, action.data ?? action.label);
|
|
341
|
-
}
|
|
342
|
-
function buildInferredTemplateAction(label, data) {
|
|
343
|
-
return data.startsWith("http") ? uriAction(label, data) : data.includes("=") ? postbackAction(label, data, label) : messageAction(label, data);
|
|
344
|
-
}
|
|
345
|
-
function resolveTemplateTextLimit(title, thumbnailImageUrl, textOnlyLimit) {
|
|
346
|
-
return title !== void 0 || thumbnailImageUrl !== void 0 ? COMPACT_TEMPLATE_TEXT_LIMIT : textOnlyLimit;
|
|
347
|
-
}
|
|
348
|
-
function truncateTemplateText(text, limit) {
|
|
349
|
-
const end = findGraphemeChunkEnd(text, 0, limit, limit, false);
|
|
350
|
-
return end > 0 ? text.slice(0, end) : truncateUtf16Safe(text, limit);
|
|
351
|
-
}
|
|
352
|
-
function resolveTemplateAltText(value, fallback) {
|
|
353
|
-
return truncateTemplateText(value ?? fallback, TEMPLATE_ALT_TEXT_LIMIT);
|
|
354
|
-
}
|
|
355
|
-
function buildTemplateMessageFromPayload(payload) {
|
|
356
|
-
switch (payload.type) {
|
|
357
|
-
case "confirm": return {
|
|
358
|
-
type: "template",
|
|
359
|
-
altText: resolveTemplateAltText(payload.altText, payload.text),
|
|
360
|
-
template: {
|
|
361
|
-
type: "confirm",
|
|
362
|
-
text: truncateTemplateText(payload.text, 240),
|
|
363
|
-
actions: [buildInferredTemplateAction(payload.confirmLabel, payload.confirmData), buildInferredTemplateAction(payload.cancelLabel, payload.cancelData)]
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
case "buttons": {
|
|
367
|
-
const title = payload.title || void 0;
|
|
368
|
-
const textLimit = resolveTemplateTextLimit(title, payload.thumbnailImageUrl, 160);
|
|
369
|
-
return {
|
|
370
|
-
type: "template",
|
|
371
|
-
altText: resolveTemplateAltText(payload.altText, title ? `${title}: ${payload.text}` : payload.text),
|
|
372
|
-
template: {
|
|
373
|
-
type: "buttons",
|
|
374
|
-
...title ? { title: truncateTemplateText(title, 40) } : {},
|
|
375
|
-
text: truncateTemplateText(payload.text, textLimit),
|
|
376
|
-
actions: payload.actions.slice(0, 4).map(buildTemplatePayloadAction),
|
|
377
|
-
thumbnailImageUrl: payload.thumbnailImageUrl,
|
|
378
|
-
imageAspectRatio: "rectangle",
|
|
379
|
-
imageSize: "cover",
|
|
380
|
-
imageBackgroundColor: void 0,
|
|
381
|
-
defaultAction: void 0
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
case "carousel": {
|
|
386
|
-
const visibleColumns = payload.columns.map((column) => {
|
|
387
|
-
const title = column.title || void 0;
|
|
388
|
-
const textLimit = resolveTemplateTextLimit(title, column.thumbnailImageUrl, 120);
|
|
389
|
-
return {
|
|
390
|
-
title: title === void 0 ? void 0 : truncateTemplateText(title, 40),
|
|
391
|
-
text: truncateTemplateText(column.text, textLimit),
|
|
392
|
-
actions: column.actions.map(buildTemplatePayloadAction).filter((action) => action.label !== void 0 && action.label !== "").slice(0, 3),
|
|
393
|
-
thumbnailImageUrl: column.thumbnailImageUrl,
|
|
394
|
-
imageBackgroundColor: void 0,
|
|
395
|
-
defaultAction: void 0
|
|
396
|
-
};
|
|
397
|
-
}).slice(0, 10);
|
|
398
|
-
const first = visibleColumns[0];
|
|
399
|
-
if (!first || visibleColumns.some((column) => column.text === "" || column.actions.length === 0 || column.title === void 0 !== (first.title === void 0) || column.actions.length !== first.actions.length)) {
|
|
400
|
-
const text = [...payload.altText ? [truncateTemplateText(payload.altText, TEMPLATE_ALT_TEXT_LIMIT)] : [], ...visibleColumns.map((column) => {
|
|
401
|
-
const body = column.title ? `${column.title}: ${column.text}` : column.text;
|
|
402
|
-
const labels = column.actions.map((action) => action.label).filter((label) => label !== void 0 && label !== "");
|
|
403
|
-
return labels.length > 0 ? `${body} (${labels.join(" / ")})` : body;
|
|
404
|
-
}).filter((line) => line !== "")].join("\n");
|
|
405
|
-
return text ? {
|
|
406
|
-
type: "text",
|
|
407
|
-
text
|
|
408
|
-
} : null;
|
|
409
|
-
}
|
|
410
|
-
return {
|
|
411
|
-
type: "template",
|
|
412
|
-
altText: resolveTemplateAltText(payload.altText, "View carousel"),
|
|
413
|
-
template: {
|
|
414
|
-
type: "carousel",
|
|
415
|
-
columns: visibleColumns,
|
|
416
|
-
imageAspectRatio: "rectangle",
|
|
417
|
-
imageSize: "cover"
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
default: return null;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
export { processLineMessage as n, buildTemplateMessageFromPayload as t };
|