@openclaw/line 2026.7.2-beta.4 → 2026.7.2-beta.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.
@@ -0,0 +1,1341 @@
1
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
2
+ //#region extensions/line/src/actions.ts
3
+ const LINE_ACTION_LABEL_LIMIT = 20;
4
+ const LINE_ACTION_DATA_LIMIT = 300;
5
+ const LINE_ACTION_URI_LIMIT = 1e3;
6
+ const LINE_CLIPBOARD_TEXT_LIMIT = 1e3;
7
+ const LINE_RICH_MENU_ALIAS_LIMIT = 32;
8
+ const LINE_IMAGEMAP_ACTION_LABEL_LIMIT = 100;
9
+ const LINE_IMAGEMAP_MESSAGE_TEXT_LIMIT = 400;
10
+ const LINE_IMAGEMAP_EXTERNAL_LINK_LABEL_LIMIT = 30;
11
+ const LINE_IMAGEMAP_ACTION_LIMIT = 50;
12
+ const graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
13
+ function truncateLineActionText(text, limit) {
14
+ let result = "";
15
+ let count = 0;
16
+ for (const { segment } of graphemeSegmenter.segment(text)) {
17
+ const codePointCount = Array.from(segment).length;
18
+ if (count + codePointCount > limit) break;
19
+ result += segment;
20
+ count += codePointCount;
21
+ }
22
+ return result;
23
+ }
24
+ function truncateLineActionLabel(label, limit = LINE_ACTION_LABEL_LIMIT) {
25
+ return truncateLineActionText(label, limit) || (label ? "…" : "");
26
+ }
27
+ function truncateLineActionData(data) {
28
+ return truncateUtf16Safe(data, LINE_ACTION_DATA_LIMIT);
29
+ }
30
+ const unavailableActionMarker = Symbol("lineUnavailableAction");
31
+ function unavailableAction(kind, reason) {
32
+ const action = {
33
+ type: "message",
34
+ label: "Unavailable",
35
+ text: `${kind} unavailable: ${reason}`
36
+ };
37
+ Object.defineProperty(action, unavailableActionMarker, { value: true });
38
+ return action;
39
+ }
40
+ const actionTypes = /* @__PURE__ */ new Set([
41
+ "camera",
42
+ "cameraRoll",
43
+ "clipboard",
44
+ "datetimepicker",
45
+ "location",
46
+ "message",
47
+ "postback",
48
+ "richmenuswitch",
49
+ "uri"
50
+ ]);
51
+ function isRecord(value) {
52
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53
+ }
54
+ function isLineAction(value) {
55
+ return isRecord(value) && typeof value.type === "string" && actionTypes.has(value.type);
56
+ }
57
+ function isUnavailableAction(action) {
58
+ return action[unavailableActionMarker] === true;
59
+ }
60
+ function normalizeNestedActions(value, labelLimit, warnings) {
61
+ if (Array.isArray(value)) {
62
+ const normalized = [];
63
+ for (const item of value) normalized.push(normalizeNestedActions(item, labelLimit, warnings));
64
+ return normalized;
65
+ }
66
+ if (!isRecord(value)) return value;
67
+ const normalized = { ...value };
68
+ for (const [key, nested] of Object.entries(value)) if ((key === "action" || key === "defaultAction") && isLineAction(nested)) {
69
+ const action = normalizeLineAction(nested, labelLimit);
70
+ if (warnings && key === "action" && (value.type === "video" && action.type !== "uri" || value.type !== "button" && isUnavailableAction(action))) {
71
+ delete normalized[key];
72
+ warnings.push(isUnavailableAction(action) ? action.text ?? "Action unavailable." : "Action unavailable in this video.");
73
+ } else normalized[key] = action;
74
+ } else if (key === "actions" && Array.isArray(nested)) normalized[key] = nested.map((action) => isLineAction(action) ? normalizeLineAction(action, labelLimit) : action);
75
+ else normalized[key] = normalizeNestedActions(nested, labelLimit, warnings);
76
+ return normalized;
77
+ }
78
+ function normalizeFlexBubbleActions(value) {
79
+ if (!isRecord(value) || value.type !== "bubble") return normalizeNestedActions(value, 40);
80
+ const warnings = [];
81
+ const normalized = normalizeNestedActions(value, 40, warnings);
82
+ if (!isRecord(normalized) || warnings.length === 0) return normalized;
83
+ const warning = {
84
+ type: "text",
85
+ text: [...new Set(warnings)].join("\n"),
86
+ wrap: true,
87
+ size: "sm",
88
+ color: "#B45309",
89
+ margin: "md"
90
+ };
91
+ const body = normalized.body;
92
+ if (isRecord(body) && Array.isArray(body.contents)) normalized.body = {
93
+ ...body,
94
+ contents: [...body.contents, warning]
95
+ };
96
+ else normalized.body = {
97
+ type: "box",
98
+ layout: "vertical",
99
+ contents: [warning]
100
+ };
101
+ return normalized;
102
+ }
103
+ function normalizeFlexContainerActions(value) {
104
+ if (!isRecord(value)) return value;
105
+ if (value.type === "bubble") return normalizeFlexBubbleActions(value);
106
+ if (value.type === "carousel" && Array.isArray(value.contents)) return {
107
+ ...value,
108
+ contents: value.contents.map((bubble) => normalizeFlexBubbleActions(bubble))
109
+ };
110
+ return normalizeNestedActions(value, 40);
111
+ }
112
+ function unavailableImagemapAction(kind, reason, area) {
113
+ return {
114
+ type: "message",
115
+ label: "Unavailable",
116
+ text: `${kind} unavailable: ${reason}`,
117
+ area
118
+ };
119
+ }
120
+ function normalizeImagemapAction(action) {
121
+ const label = action.label === void 0 ? void 0 : truncateLineActionText(action.label, LINE_IMAGEMAP_ACTION_LABEL_LIMIT);
122
+ if (action.type === "uri") {
123
+ if (truncateUtf16Safe(action.linkUri, LINE_ACTION_URI_LIMIT) !== action.linkUri) return unavailableImagemapAction("Link", "URL exceeds LINE's limit.", action.area);
124
+ return {
125
+ ...action,
126
+ label
127
+ };
128
+ }
129
+ if (action.type === "message") {
130
+ const text = truncateUtf16Safe(action.text, LINE_IMAGEMAP_MESSAGE_TEXT_LIMIT);
131
+ if (text !== action.text) return unavailableImagemapAction("Action", "message text exceeds LINE's limit.", action.area);
132
+ return {
133
+ ...action,
134
+ label,
135
+ text
136
+ };
137
+ }
138
+ if (truncateUtf16Safe(action.clipboardText, LINE_CLIPBOARD_TEXT_LIMIT) !== action.clipboardText) return unavailableImagemapAction("Action", "clipboard text exceeds LINE's limit.", action.area);
139
+ return {
140
+ ...action,
141
+ label
142
+ };
143
+ }
144
+ function normalizeImagemapVideo(video) {
145
+ const externalLink = video.externalLink;
146
+ if (!externalLink) return { video };
147
+ const label = externalLink.label === void 0 ? void 0 : truncateUtf16Safe(externalLink.label, LINE_IMAGEMAP_EXTERNAL_LINK_LABEL_LIMIT) || (externalLink.label ? "…" : "");
148
+ if (externalLink.linkUri !== void 0 && truncateUtf16Safe(externalLink.linkUri, LINE_ACTION_URI_LIMIT) !== externalLink.linkUri) {
149
+ const normalizedVideo = { ...video };
150
+ delete normalizedVideo.externalLink;
151
+ return {
152
+ video: normalizedVideo,
153
+ fallbackAction: video.area === void 0 ? void 0 : unavailableImagemapAction("Link", "URL exceeds LINE's limit.", video.area)
154
+ };
155
+ }
156
+ return { video: {
157
+ ...video,
158
+ externalLink: {
159
+ ...externalLink,
160
+ label
161
+ }
162
+ } };
163
+ }
164
+ function normalizeLineMessageActions(message) {
165
+ let normalized;
166
+ if (message.type === "flex") normalized = {
167
+ ...message,
168
+ contents: normalizeFlexContainerActions(message.contents)
169
+ };
170
+ else if (message.type === "template") {
171
+ const labelLimit = message.template.type === "image_carousel" ? 12 : 20;
172
+ normalized = {
173
+ ...message,
174
+ template: normalizeNestedActions(message.template, labelLimit)
175
+ };
176
+ } else if (message.type === "imagemap") {
177
+ const actions = message.actions.map(normalizeImagemapAction);
178
+ const videoResult = message.video ? normalizeImagemapVideo(message.video) : void 0;
179
+ if (videoResult?.fallbackAction) {
180
+ if (actions.length < LINE_IMAGEMAP_ACTION_LIMIT) actions.push(videoResult.fallbackAction);
181
+ }
182
+ normalized = {
183
+ ...message,
184
+ actions,
185
+ video: videoResult?.video
186
+ };
187
+ } else normalized = { ...message };
188
+ if (message.quickReply) normalized = {
189
+ ...normalized,
190
+ quickReply: normalizeNestedActions(message.quickReply, 20)
191
+ };
192
+ return normalized;
193
+ }
194
+ function normalizeLineAction(action, labelLimit = LINE_ACTION_LABEL_LIMIT) {
195
+ if (isUnavailableAction(action)) return action;
196
+ const label = action.label === void 0 ? void 0 : truncateLineActionLabel(action.label, labelLimit);
197
+ if (action.type === "uri") {
198
+ const uriTooLong = action.uri !== void 0 && truncateUtf16Safe(action.uri, LINE_ACTION_URI_LIMIT) !== action.uri;
199
+ const desktopUri = action.altUri?.desktop;
200
+ const desktopUriTooLong = desktopUri !== void 0 && truncateUtf16Safe(desktopUri, LINE_ACTION_URI_LIMIT) !== desktopUri;
201
+ if (uriTooLong || desktopUriTooLong) return unavailableAction("Link", "URL exceeds LINE's limit.");
202
+ return {
203
+ ...action,
204
+ label
205
+ };
206
+ }
207
+ if (action.type === "postback") {
208
+ const data = action.data === void 0 ? void 0 : truncateLineActionData(action.data);
209
+ if (data !== action.data) return unavailableAction("Action", "callback data exceeds LINE's limit.");
210
+ const text = action.text === void 0 ? void 0 : truncateLineActionText(action.text, LINE_ACTION_DATA_LIMIT);
211
+ const fillInText = action.fillInText === void 0 ? void 0 : truncateLineActionText(action.fillInText, LINE_ACTION_DATA_LIMIT);
212
+ if (text !== action.text || fillInText !== action.fillInText) return unavailableAction("Action", "message text exceeds LINE's limit.");
213
+ return {
214
+ ...action,
215
+ label,
216
+ data,
217
+ displayText: action.displayText === void 0 ? void 0 : truncateLineActionText(action.displayText, LINE_ACTION_DATA_LIMIT),
218
+ text,
219
+ fillInText
220
+ };
221
+ }
222
+ if (action.type === "datetimepicker") {
223
+ const data = action.data === void 0 ? void 0 : truncateLineActionData(action.data);
224
+ if (data !== action.data) return unavailableAction("Action", "callback data exceeds LINE's limit.");
225
+ return {
226
+ ...action,
227
+ label,
228
+ data
229
+ };
230
+ }
231
+ if (action.type === "message") {
232
+ const text = action.text === void 0 ? void 0 : truncateLineActionText(action.text, LINE_ACTION_DATA_LIMIT);
233
+ if (text !== action.text) return unavailableAction("Action", "message text exceeds LINE's limit.");
234
+ return {
235
+ ...action,
236
+ label,
237
+ text
238
+ };
239
+ }
240
+ if (action.type === "clipboard") {
241
+ if (truncateUtf16Safe(action.clipboardText, LINE_CLIPBOARD_TEXT_LIMIT) !== action.clipboardText) return unavailableAction("Action", "clipboard text exceeds LINE's limit.");
242
+ return {
243
+ ...action,
244
+ label
245
+ };
246
+ }
247
+ if (action.type === "richmenuswitch") {
248
+ const data = action.data === void 0 ? void 0 : truncateLineActionData(action.data);
249
+ const aliasTooLong = action.richMenuAliasId !== void 0 && truncateUtf16Safe(action.richMenuAliasId, LINE_RICH_MENU_ALIAS_LIMIT) !== action.richMenuAliasId;
250
+ if (data !== action.data || aliasTooLong) return unavailableAction("Action", "rich menu data exceeds LINE's limit.");
251
+ return {
252
+ ...action,
253
+ label,
254
+ data
255
+ };
256
+ }
257
+ return action.label === label ? action : {
258
+ ...action,
259
+ label
260
+ };
261
+ }
262
+ /**
263
+ * Create a message action (sends text when tapped)
264
+ */
265
+ function messageAction(label, text) {
266
+ return normalizeLineAction({
267
+ type: "message",
268
+ label,
269
+ text: text ?? label
270
+ });
271
+ }
272
+ /**
273
+ * Create a URI action (opens a URL when tapped)
274
+ */
275
+ function uriAction(label, uri) {
276
+ return normalizeLineAction({
277
+ type: "uri",
278
+ label,
279
+ uri
280
+ });
281
+ }
282
+ /**
283
+ * Create a postback action (sends data to webhook when tapped)
284
+ */
285
+ function postbackAction(label, data, displayText) {
286
+ return normalizeLineAction({
287
+ type: "postback",
288
+ label,
289
+ data,
290
+ displayText
291
+ });
292
+ }
293
+ /**
294
+ * Create a datetime picker action
295
+ */
296
+ function datetimePickerAction(label, data, mode, options) {
297
+ return normalizeLineAction({
298
+ type: "datetimepicker",
299
+ label,
300
+ data,
301
+ mode,
302
+ initial: options?.initial,
303
+ max: options?.max,
304
+ min: options?.min
305
+ });
306
+ }
307
+ //#endregion
308
+ //#region extensions/line/src/flex-templates/common.ts
309
+ function attachFooterText(bubble, footer) {
310
+ bubble.footer = {
311
+ type: "box",
312
+ layout: "vertical",
313
+ contents: [{
314
+ type: "text",
315
+ text: footer,
316
+ size: "xs",
317
+ color: "#AAAAAA",
318
+ wrap: true,
319
+ align: "center"
320
+ }],
321
+ paddingAll: "lg",
322
+ backgroundColor: "#FAFAFA"
323
+ };
324
+ }
325
+ //#endregion
326
+ //#region extensions/line/src/flex-templates/basic-cards.ts
327
+ /**
328
+ * Create an info card with title, body, and optional footer
329
+ *
330
+ * Editorial design: Clean hierarchy with accent bar, generous spacing,
331
+ * and subtle background zones for visual separation.
332
+ */
333
+ function createInfoCard(title, body, footer) {
334
+ const bubble = {
335
+ type: "bubble",
336
+ size: "mega",
337
+ body: {
338
+ type: "box",
339
+ layout: "vertical",
340
+ contents: [{
341
+ type: "box",
342
+ layout: "horizontal",
343
+ contents: [{
344
+ type: "box",
345
+ layout: "vertical",
346
+ contents: [],
347
+ width: "4px",
348
+ backgroundColor: "#06C755",
349
+ cornerRadius: "2px"
350
+ }, {
351
+ type: "text",
352
+ text: title,
353
+ weight: "bold",
354
+ size: "xl",
355
+ color: "#111111",
356
+ wrap: true,
357
+ flex: 1,
358
+ margin: "lg"
359
+ }]
360
+ }, {
361
+ type: "box",
362
+ layout: "vertical",
363
+ contents: [{
364
+ type: "text",
365
+ text: body,
366
+ size: "md",
367
+ color: "#444444",
368
+ wrap: true,
369
+ lineSpacing: "6px"
370
+ }],
371
+ margin: "xl",
372
+ paddingAll: "lg",
373
+ backgroundColor: "#F8F9FA",
374
+ cornerRadius: "lg"
375
+ }],
376
+ paddingAll: "xl",
377
+ backgroundColor: "#FFFFFF"
378
+ }
379
+ };
380
+ if (footer) attachFooterText(bubble, footer);
381
+ return bubble;
382
+ }
383
+ /**
384
+ * Create a list card with title and multiple items
385
+ *
386
+ * Editorial design: Numbered/bulleted list with clear visual hierarchy,
387
+ * accent dots for each item, and generous spacing.
388
+ */
389
+ function createListCard(title, items) {
390
+ const itemContents = items.slice(0, 8).map((item, index) => {
391
+ const itemContentsLocal = [{
392
+ type: "text",
393
+ text: item.title,
394
+ size: "md",
395
+ weight: "bold",
396
+ color: "#1a1a1a",
397
+ wrap: true
398
+ }];
399
+ if (item.subtitle) itemContentsLocal.push({
400
+ type: "text",
401
+ text: item.subtitle,
402
+ size: "sm",
403
+ color: "#888888",
404
+ wrap: true,
405
+ margin: "xs"
406
+ });
407
+ const itemBox = {
408
+ type: "box",
409
+ layout: "horizontal",
410
+ contents: [{
411
+ type: "box",
412
+ layout: "vertical",
413
+ contents: [{
414
+ type: "box",
415
+ layout: "vertical",
416
+ contents: [],
417
+ width: "8px",
418
+ height: "8px",
419
+ backgroundColor: index === 0 ? "#06C755" : "#DDDDDD",
420
+ cornerRadius: "4px"
421
+ }],
422
+ width: "20px",
423
+ alignItems: "center",
424
+ paddingTop: "sm"
425
+ }, {
426
+ type: "box",
427
+ layout: "vertical",
428
+ contents: itemContentsLocal,
429
+ flex: 1
430
+ }],
431
+ margin: index > 0 ? "lg" : void 0
432
+ };
433
+ if (item.action) itemBox.action = normalizeLineAction(item.action, 40);
434
+ return itemBox;
435
+ });
436
+ return {
437
+ type: "bubble",
438
+ size: "mega",
439
+ body: {
440
+ type: "box",
441
+ layout: "vertical",
442
+ contents: [
443
+ {
444
+ type: "text",
445
+ text: title,
446
+ weight: "bold",
447
+ size: "xl",
448
+ color: "#111111",
449
+ wrap: true
450
+ },
451
+ {
452
+ type: "separator",
453
+ margin: "lg",
454
+ color: "#EEEEEE"
455
+ },
456
+ {
457
+ type: "box",
458
+ layout: "vertical",
459
+ contents: itemContents,
460
+ margin: "lg"
461
+ }
462
+ ],
463
+ paddingAll: "xl",
464
+ backgroundColor: "#FFFFFF"
465
+ }
466
+ };
467
+ }
468
+ /**
469
+ * Create an image card with image, title, and optional body text
470
+ */
471
+ function createImageCard(imageUrl, title, body, options) {
472
+ const bubble = {
473
+ type: "bubble",
474
+ hero: {
475
+ type: "image",
476
+ url: imageUrl,
477
+ size: "full",
478
+ aspectRatio: options?.aspectRatio ?? "20:13",
479
+ aspectMode: options?.aspectMode ?? "cover",
480
+ action: options?.action === void 0 ? void 0 : normalizeLineAction(options.action, 40)
481
+ },
482
+ body: {
483
+ type: "box",
484
+ layout: "vertical",
485
+ contents: [{
486
+ type: "text",
487
+ text: title,
488
+ weight: "bold",
489
+ size: "xl",
490
+ wrap: true
491
+ }],
492
+ paddingAll: "lg"
493
+ }
494
+ };
495
+ if (body && bubble.body) bubble.body.contents.push({
496
+ type: "text",
497
+ text: body,
498
+ size: "md",
499
+ wrap: true,
500
+ margin: "md",
501
+ color: "#666666"
502
+ });
503
+ return bubble;
504
+ }
505
+ /**
506
+ * Create an action card with title, body, and action buttons
507
+ */
508
+ function createActionCard(title, body, actions, options) {
509
+ const bubble = {
510
+ type: "bubble",
511
+ body: {
512
+ type: "box",
513
+ layout: "vertical",
514
+ contents: [{
515
+ type: "text",
516
+ text: title,
517
+ weight: "bold",
518
+ size: "xl",
519
+ wrap: true
520
+ }, {
521
+ type: "text",
522
+ text: body,
523
+ size: "md",
524
+ wrap: true,
525
+ margin: "md",
526
+ color: "#666666"
527
+ }],
528
+ paddingAll: "lg"
529
+ },
530
+ footer: {
531
+ type: "box",
532
+ layout: "vertical",
533
+ contents: actions.slice(0, 4).map((action, index) => ({
534
+ type: "button",
535
+ action: normalizeLineAction(action.action, 40),
536
+ style: index === 0 ? "primary" : "secondary",
537
+ margin: index > 0 ? "sm" : void 0
538
+ })),
539
+ paddingAll: "md"
540
+ }
541
+ };
542
+ if (options?.imageUrl) bubble.hero = {
543
+ type: "image",
544
+ url: options.imageUrl,
545
+ size: "full",
546
+ aspectRatio: options.aspectRatio ?? "20:13",
547
+ aspectMode: "cover"
548
+ };
549
+ return bubble;
550
+ }
551
+ /**
552
+ * Create a carousel container from multiple bubbles
553
+ * LINE allows max 12 bubbles in a carousel
554
+ */
555
+ function createCarousel(bubbles) {
556
+ return {
557
+ type: "carousel",
558
+ contents: bubbles.slice(0, 12)
559
+ };
560
+ }
561
+ /**
562
+ * Create a notification bubble (for alerts, status updates)
563
+ *
564
+ * Editorial design: Bold status indicator with accent color,
565
+ * clear typography, optional icon for context.
566
+ */
567
+ function createNotificationBubble(text, options) {
568
+ const typeColors = {
569
+ info: {
570
+ accent: "#3B82F6",
571
+ bg: "#EFF6FF"
572
+ },
573
+ success: {
574
+ accent: "#06C755",
575
+ bg: "#F0FDF4"
576
+ },
577
+ warning: {
578
+ accent: "#F59E0B",
579
+ bg: "#FFFBEB"
580
+ },
581
+ error: {
582
+ accent: "#EF4444",
583
+ bg: "#FEF2F2"
584
+ }
585
+ }[options?.type ?? "info"];
586
+ const contents = [];
587
+ contents.push({
588
+ type: "box",
589
+ layout: "vertical",
590
+ contents: [],
591
+ width: "4px",
592
+ backgroundColor: typeColors.accent,
593
+ cornerRadius: "2px"
594
+ });
595
+ const textContents = [];
596
+ if (options?.title) textContents.push({
597
+ type: "text",
598
+ text: options.title,
599
+ size: "md",
600
+ weight: "bold",
601
+ color: "#111111",
602
+ wrap: true
603
+ });
604
+ textContents.push({
605
+ type: "text",
606
+ text,
607
+ size: options?.title ? "sm" : "md",
608
+ color: options?.title ? "#666666" : "#333333",
609
+ wrap: true,
610
+ margin: options?.title ? "sm" : void 0
611
+ });
612
+ contents.push({
613
+ type: "box",
614
+ layout: "vertical",
615
+ contents: textContents,
616
+ flex: 1,
617
+ paddingStart: "lg"
618
+ });
619
+ return {
620
+ type: "bubble",
621
+ body: {
622
+ type: "box",
623
+ layout: "horizontal",
624
+ contents,
625
+ paddingAll: "xl",
626
+ backgroundColor: typeColors.bg
627
+ }
628
+ };
629
+ }
630
+ //#endregion
631
+ //#region extensions/line/src/flex-templates/schedule-cards.ts
632
+ function buildTitleSubtitleHeader(params) {
633
+ const { title, subtitle } = params;
634
+ const headerContents = [{
635
+ type: "text",
636
+ text: title,
637
+ weight: "bold",
638
+ size: "xl",
639
+ color: "#111111",
640
+ wrap: true
641
+ }];
642
+ if (subtitle) headerContents.push({
643
+ type: "text",
644
+ text: subtitle,
645
+ size: "sm",
646
+ color: "#888888",
647
+ margin: "sm",
648
+ wrap: true
649
+ });
650
+ return headerContents;
651
+ }
652
+ function buildCardHeaderSections(headerContents) {
653
+ return [{
654
+ type: "box",
655
+ layout: "vertical",
656
+ contents: headerContents,
657
+ paddingBottom: "lg"
658
+ }, {
659
+ type: "separator",
660
+ color: "#EEEEEE"
661
+ }];
662
+ }
663
+ function createMegaBubbleWithFooter(params) {
664
+ const bubble = {
665
+ type: "bubble",
666
+ size: "mega",
667
+ body: {
668
+ type: "box",
669
+ layout: "vertical",
670
+ contents: params.bodyContents,
671
+ paddingAll: "xl",
672
+ backgroundColor: "#FFFFFF"
673
+ }
674
+ };
675
+ if (params.footer) attachFooterText(bubble, params.footer);
676
+ return bubble;
677
+ }
678
+ /**
679
+ * Create a receipt/summary card (for orders, transactions, data tables)
680
+ *
681
+ * Editorial design: Clean table layout with alternating row backgrounds,
682
+ * prominent total section, and clear visual hierarchy.
683
+ */
684
+ function createReceiptCard(params) {
685
+ const { title, subtitle, items, total, footer } = params;
686
+ const itemRows = items.slice(0, 12).map((item, index) => ({
687
+ type: "box",
688
+ layout: "horizontal",
689
+ contents: [{
690
+ type: "text",
691
+ text: item.name,
692
+ size: "sm",
693
+ color: item.highlight ? "#111111" : "#666666",
694
+ weight: item.highlight ? "bold" : "regular",
695
+ flex: 3,
696
+ wrap: true
697
+ }, {
698
+ type: "text",
699
+ text: item.value,
700
+ size: "sm",
701
+ color: item.highlight ? "#06C755" : "#333333",
702
+ weight: item.highlight ? "bold" : "regular",
703
+ flex: 2,
704
+ align: "end",
705
+ wrap: true
706
+ }],
707
+ paddingAll: "md",
708
+ backgroundColor: index % 2 === 0 ? "#FFFFFF" : "#FAFAFA"
709
+ }));
710
+ const bodyContents = [...buildCardHeaderSections(buildTitleSubtitleHeader({
711
+ title,
712
+ subtitle
713
+ })), {
714
+ type: "box",
715
+ layout: "vertical",
716
+ contents: itemRows,
717
+ margin: "md",
718
+ cornerRadius: "md",
719
+ borderWidth: "light",
720
+ borderColor: "#EEEEEE"
721
+ }];
722
+ if (total) bodyContents.push({
723
+ type: "box",
724
+ layout: "horizontal",
725
+ contents: [{
726
+ type: "text",
727
+ text: total.label,
728
+ size: "lg",
729
+ weight: "bold",
730
+ color: "#111111",
731
+ flex: 2
732
+ }, {
733
+ type: "text",
734
+ text: total.value,
735
+ size: "xl",
736
+ weight: "bold",
737
+ color: "#06C755",
738
+ flex: 2,
739
+ align: "end"
740
+ }],
741
+ margin: "xl",
742
+ paddingAll: "lg",
743
+ backgroundColor: "#F0FDF4",
744
+ cornerRadius: "lg"
745
+ });
746
+ return createMegaBubbleWithFooter({
747
+ bodyContents,
748
+ footer
749
+ });
750
+ }
751
+ /**
752
+ * Create a calendar event card (for meetings, appointments, reminders)
753
+ *
754
+ * Editorial design: Date as hero, strong typographic hierarchy,
755
+ * color-blocked zones, full text wrapping for readability.
756
+ */
757
+ function createEventCard(params) {
758
+ const { title, date, time, location, description, calendar, isAllDay, action } = params;
759
+ const dateBlock = {
760
+ type: "box",
761
+ layout: "vertical",
762
+ contents: [{
763
+ type: "text",
764
+ text: date.toUpperCase(),
765
+ size: "sm",
766
+ weight: "bold",
767
+ color: "#06C755",
768
+ wrap: true
769
+ }, {
770
+ type: "text",
771
+ text: isAllDay ? "ALL DAY" : time ?? "",
772
+ size: "xxl",
773
+ weight: "bold",
774
+ color: "#111111",
775
+ wrap: true,
776
+ margin: "xs"
777
+ }],
778
+ paddingBottom: "lg",
779
+ borderWidth: "none"
780
+ };
781
+ if (!time && !isAllDay) dateBlock.contents = [{
782
+ type: "text",
783
+ text: date,
784
+ size: "xl",
785
+ weight: "bold",
786
+ color: "#111111",
787
+ wrap: true
788
+ }];
789
+ const bodyContents = [dateBlock, {
790
+ type: "box",
791
+ layout: "horizontal",
792
+ contents: [{
793
+ type: "box",
794
+ layout: "vertical",
795
+ contents: [],
796
+ width: "4px",
797
+ backgroundColor: "#06C755",
798
+ cornerRadius: "2px"
799
+ }, {
800
+ type: "box",
801
+ layout: "vertical",
802
+ contents: [{
803
+ type: "text",
804
+ text: title,
805
+ size: "lg",
806
+ weight: "bold",
807
+ color: "#1a1a1a",
808
+ wrap: true
809
+ }, ...calendar ? [{
810
+ type: "text",
811
+ text: calendar,
812
+ size: "xs",
813
+ color: "#888888",
814
+ margin: "sm",
815
+ wrap: true
816
+ }] : []],
817
+ flex: 1,
818
+ paddingStart: "lg"
819
+ }],
820
+ paddingTop: "lg",
821
+ paddingBottom: "lg",
822
+ borderWidth: "light",
823
+ borderColor: "#EEEEEE"
824
+ }];
825
+ if (location || description) {
826
+ const detailItems = [];
827
+ if (location) detailItems.push({
828
+ type: "box",
829
+ layout: "horizontal",
830
+ contents: [{
831
+ type: "text",
832
+ text: "📍",
833
+ size: "sm",
834
+ flex: 0
835
+ }, {
836
+ type: "text",
837
+ text: location,
838
+ size: "sm",
839
+ color: "#444444",
840
+ margin: "md",
841
+ flex: 1,
842
+ wrap: true
843
+ }],
844
+ alignItems: "flex-start"
845
+ });
846
+ if (description) detailItems.push({
847
+ type: "text",
848
+ text: description,
849
+ size: "sm",
850
+ color: "#666666",
851
+ wrap: true,
852
+ margin: location ? "lg" : "none"
853
+ });
854
+ bodyContents.push({
855
+ type: "box",
856
+ layout: "vertical",
857
+ contents: detailItems,
858
+ margin: "lg",
859
+ paddingAll: "lg",
860
+ backgroundColor: "#F8F9FA",
861
+ cornerRadius: "lg"
862
+ });
863
+ }
864
+ return {
865
+ type: "bubble",
866
+ size: "mega",
867
+ body: {
868
+ type: "box",
869
+ layout: "vertical",
870
+ contents: bodyContents,
871
+ paddingAll: "xl",
872
+ backgroundColor: "#FFFFFF",
873
+ action: action === void 0 ? void 0 : normalizeLineAction(action, 40)
874
+ }
875
+ };
876
+ }
877
+ /**
878
+ * Create a calendar agenda card showing multiple events
879
+ *
880
+ * Editorial timeline design: Time-focused left column with event details
881
+ * on the right. Visual accent bars indicate event priority/recency.
882
+ */
883
+ function createAgendaCard(params) {
884
+ const { title, subtitle, events, footer } = params;
885
+ const headerContents = buildTitleSubtitleHeader({
886
+ title,
887
+ subtitle
888
+ });
889
+ const eventItems = events.slice(0, 6).map((event, index) => {
890
+ const isActive = event.isNow || index === 0;
891
+ const accentColor = isActive ? "#06C755" : "#E5E5E5";
892
+ const timeColumn = {
893
+ type: "box",
894
+ layout: "vertical",
895
+ contents: [{
896
+ type: "text",
897
+ text: event.time ?? "—",
898
+ size: "sm",
899
+ weight: isActive ? "bold" : "regular",
900
+ color: isActive ? "#06C755" : "#666666",
901
+ align: "end",
902
+ wrap: true
903
+ }],
904
+ width: "65px",
905
+ justifyContent: "flex-start"
906
+ };
907
+ const dotColumn = {
908
+ type: "box",
909
+ layout: "vertical",
910
+ contents: [{
911
+ type: "box",
912
+ layout: "vertical",
913
+ contents: [],
914
+ width: "10px",
915
+ height: "10px",
916
+ backgroundColor: accentColor,
917
+ cornerRadius: "5px"
918
+ }],
919
+ width: "24px",
920
+ alignItems: "center",
921
+ justifyContent: "flex-start",
922
+ paddingTop: "xs"
923
+ };
924
+ const detailContents = [{
925
+ type: "text",
926
+ text: event.title,
927
+ size: "md",
928
+ weight: "bold",
929
+ color: "#1a1a1a",
930
+ wrap: true
931
+ }];
932
+ const secondaryParts = [];
933
+ if (event.location) secondaryParts.push(event.location);
934
+ if (event.calendar) secondaryParts.push(event.calendar);
935
+ if (secondaryParts.length > 0) detailContents.push({
936
+ type: "text",
937
+ text: secondaryParts.join(" · "),
938
+ size: "xs",
939
+ color: "#888888",
940
+ wrap: true,
941
+ margin: "xs"
942
+ });
943
+ return {
944
+ type: "box",
945
+ layout: "horizontal",
946
+ contents: [
947
+ timeColumn,
948
+ dotColumn,
949
+ {
950
+ type: "box",
951
+ layout: "vertical",
952
+ contents: detailContents,
953
+ flex: 1
954
+ }
955
+ ],
956
+ margin: index > 0 ? "xl" : void 0,
957
+ alignItems: "flex-start"
958
+ };
959
+ });
960
+ return createMegaBubbleWithFooter({
961
+ bodyContents: [...buildCardHeaderSections(headerContents), {
962
+ type: "box",
963
+ layout: "vertical",
964
+ contents: eventItems,
965
+ paddingTop: "xl"
966
+ }],
967
+ footer
968
+ });
969
+ }
970
+ //#endregion
971
+ //#region extensions/line/src/flex-templates/media-control-cards.ts
972
+ /**
973
+ * Create a media player card for Sonos, Spotify, Apple Music, etc.
974
+ *
975
+ * Editorial design: Album art hero with gradient overlay for text,
976
+ * prominent now-playing indicator, refined playback controls.
977
+ */
978
+ function createMediaPlayerCard(params) {
979
+ const { title, subtitle, source, imageUrl, isPlaying, progress, controls, extraActions } = params;
980
+ const trackInfo = [{
981
+ type: "text",
982
+ text: title,
983
+ weight: "bold",
984
+ size: "xl",
985
+ color: "#111111",
986
+ wrap: true
987
+ }];
988
+ if (subtitle) trackInfo.push({
989
+ type: "text",
990
+ text: subtitle,
991
+ size: "md",
992
+ color: "#666666",
993
+ wrap: true,
994
+ margin: "sm"
995
+ });
996
+ const statusItems = [];
997
+ if (isPlaying !== void 0) statusItems.push({
998
+ type: "box",
999
+ layout: "horizontal",
1000
+ contents: [{
1001
+ type: "box",
1002
+ layout: "vertical",
1003
+ contents: [],
1004
+ width: "8px",
1005
+ height: "8px",
1006
+ backgroundColor: isPlaying ? "#06C755" : "#CCCCCC",
1007
+ cornerRadius: "4px"
1008
+ }, {
1009
+ type: "text",
1010
+ text: isPlaying ? "Now Playing" : "Paused",
1011
+ size: "xs",
1012
+ color: isPlaying ? "#06C755" : "#888888",
1013
+ weight: "bold",
1014
+ margin: "sm"
1015
+ }],
1016
+ alignItems: "center"
1017
+ });
1018
+ if (source) statusItems.push({
1019
+ type: "text",
1020
+ text: source,
1021
+ size: "xs",
1022
+ color: "#AAAAAA",
1023
+ margin: statusItems.length > 0 ? "lg" : void 0
1024
+ });
1025
+ if (progress) statusItems.push({
1026
+ type: "text",
1027
+ text: progress,
1028
+ size: "xs",
1029
+ color: "#888888",
1030
+ align: "end",
1031
+ flex: 1
1032
+ });
1033
+ const bodyContents = [{
1034
+ type: "box",
1035
+ layout: "vertical",
1036
+ contents: trackInfo
1037
+ }];
1038
+ if (statusItems.length > 0) bodyContents.push({
1039
+ type: "box",
1040
+ layout: "horizontal",
1041
+ contents: statusItems,
1042
+ margin: "lg",
1043
+ alignItems: "center"
1044
+ });
1045
+ const bubble = {
1046
+ type: "bubble",
1047
+ size: "mega",
1048
+ body: {
1049
+ type: "box",
1050
+ layout: "vertical",
1051
+ contents: bodyContents,
1052
+ paddingAll: "xl",
1053
+ backgroundColor: "#FFFFFF"
1054
+ }
1055
+ };
1056
+ if (imageUrl) bubble.hero = {
1057
+ type: "image",
1058
+ url: imageUrl,
1059
+ size: "full",
1060
+ aspectRatio: "1:1",
1061
+ aspectMode: "cover"
1062
+ };
1063
+ if (controls || extraActions?.length) {
1064
+ const footerContents = [];
1065
+ if (controls) {
1066
+ const controlButtons = [];
1067
+ if (controls.previous) controlButtons.push({
1068
+ type: "button",
1069
+ action: postbackAction("⏮", controls.previous.data),
1070
+ style: "secondary",
1071
+ flex: 1,
1072
+ height: "sm"
1073
+ });
1074
+ if (controls.play) controlButtons.push({
1075
+ type: "button",
1076
+ action: postbackAction("▶", controls.play.data),
1077
+ style: isPlaying ? "secondary" : "primary",
1078
+ flex: 1,
1079
+ height: "sm",
1080
+ margin: controls.previous ? "md" : void 0
1081
+ });
1082
+ if (controls.pause) controlButtons.push({
1083
+ type: "button",
1084
+ action: postbackAction("⏸", controls.pause.data),
1085
+ style: isPlaying ? "primary" : "secondary",
1086
+ flex: 1,
1087
+ height: "sm",
1088
+ margin: controlButtons.length > 0 ? "md" : void 0
1089
+ });
1090
+ if (controls.next) controlButtons.push({
1091
+ type: "button",
1092
+ action: postbackAction("⏭", controls.next.data),
1093
+ style: "secondary",
1094
+ flex: 1,
1095
+ height: "sm",
1096
+ margin: controlButtons.length > 0 ? "md" : void 0
1097
+ });
1098
+ if (controlButtons.length > 0) footerContents.push({
1099
+ type: "box",
1100
+ layout: "horizontal",
1101
+ contents: controlButtons
1102
+ });
1103
+ }
1104
+ if (extraActions?.length) footerContents.push({
1105
+ type: "box",
1106
+ layout: "horizontal",
1107
+ contents: extraActions.slice(0, 2).map((action, index) => ({
1108
+ type: "button",
1109
+ action: postbackAction(truncateLineActionLabel(action.label, 15), action.data),
1110
+ style: "secondary",
1111
+ flex: 1,
1112
+ height: "sm",
1113
+ margin: index > 0 ? "md" : void 0
1114
+ })),
1115
+ margin: "md"
1116
+ });
1117
+ if (footerContents.length > 0) bubble.footer = {
1118
+ type: "box",
1119
+ layout: "vertical",
1120
+ contents: footerContents,
1121
+ paddingAll: "lg",
1122
+ backgroundColor: "#FAFAFA"
1123
+ };
1124
+ }
1125
+ return bubble;
1126
+ }
1127
+ /**
1128
+ * Create an Apple TV remote card with a D-pad and control rows.
1129
+ */
1130
+ function createAppleTvRemoteCard(params) {
1131
+ const { deviceName, status, actionData } = params;
1132
+ const headerContents = [{
1133
+ type: "text",
1134
+ text: deviceName,
1135
+ weight: "bold",
1136
+ size: "xl",
1137
+ color: "#111111",
1138
+ wrap: true
1139
+ }];
1140
+ if (status) headerContents.push({
1141
+ type: "text",
1142
+ text: status,
1143
+ size: "sm",
1144
+ color: "#666666",
1145
+ wrap: true,
1146
+ margin: "sm"
1147
+ });
1148
+ const makeButton = (label, data, style = "secondary") => ({
1149
+ type: "button",
1150
+ action: postbackAction(label, data),
1151
+ style,
1152
+ height: "sm",
1153
+ flex: 1
1154
+ });
1155
+ const dpadRows = [
1156
+ {
1157
+ type: "box",
1158
+ layout: "horizontal",
1159
+ contents: [
1160
+ { type: "filler" },
1161
+ makeButton("↑", actionData.up),
1162
+ { type: "filler" }
1163
+ ]
1164
+ },
1165
+ {
1166
+ type: "box",
1167
+ layout: "horizontal",
1168
+ contents: [
1169
+ makeButton("←", actionData.left),
1170
+ makeButton("OK", actionData.select, "primary"),
1171
+ makeButton("→", actionData.right)
1172
+ ],
1173
+ margin: "md"
1174
+ },
1175
+ {
1176
+ type: "box",
1177
+ layout: "horizontal",
1178
+ contents: [
1179
+ { type: "filler" },
1180
+ makeButton("↓", actionData.down),
1181
+ { type: "filler" }
1182
+ ],
1183
+ margin: "md"
1184
+ }
1185
+ ];
1186
+ const menuRow = {
1187
+ type: "box",
1188
+ layout: "horizontal",
1189
+ contents: [makeButton("Menu", actionData.menu), makeButton("Home", actionData.home)],
1190
+ margin: "lg"
1191
+ };
1192
+ const playbackRow = {
1193
+ type: "box",
1194
+ layout: "horizontal",
1195
+ contents: [makeButton("Play", actionData.play), makeButton("Pause", actionData.pause)],
1196
+ margin: "md"
1197
+ };
1198
+ const volumeRow = {
1199
+ type: "box",
1200
+ layout: "horizontal",
1201
+ contents: [
1202
+ makeButton("Vol +", actionData.volumeUp),
1203
+ makeButton("Mute", actionData.mute),
1204
+ makeButton("Vol -", actionData.volumeDown)
1205
+ ],
1206
+ margin: "md"
1207
+ };
1208
+ return {
1209
+ type: "bubble",
1210
+ size: "mega",
1211
+ body: {
1212
+ type: "box",
1213
+ layout: "vertical",
1214
+ contents: [
1215
+ {
1216
+ type: "box",
1217
+ layout: "vertical",
1218
+ contents: headerContents
1219
+ },
1220
+ {
1221
+ type: "separator",
1222
+ margin: "lg",
1223
+ color: "#EEEEEE"
1224
+ },
1225
+ ...dpadRows,
1226
+ menuRow,
1227
+ playbackRow,
1228
+ volumeRow
1229
+ ],
1230
+ paddingAll: "xl",
1231
+ backgroundColor: "#FFFFFF"
1232
+ }
1233
+ };
1234
+ }
1235
+ /**
1236
+ * Create a device control card for Apple TV, smart home devices, etc.
1237
+ *
1238
+ * Editorial design: Device-focused header with status indicator,
1239
+ * clean control grid with clear visual hierarchy.
1240
+ */
1241
+ function createDeviceControlCard(params) {
1242
+ const { deviceName, deviceType, status, isOnline, imageUrl, controls } = params;
1243
+ const headerContents = [{
1244
+ type: "box",
1245
+ layout: "horizontal",
1246
+ contents: [{
1247
+ type: "box",
1248
+ layout: "vertical",
1249
+ contents: [],
1250
+ width: "10px",
1251
+ height: "10px",
1252
+ backgroundColor: isOnline !== false ? "#06C755" : "#FF5555",
1253
+ cornerRadius: "5px"
1254
+ }, {
1255
+ type: "text",
1256
+ text: deviceName,
1257
+ weight: "bold",
1258
+ size: "xl",
1259
+ color: "#111111",
1260
+ wrap: true,
1261
+ flex: 1,
1262
+ margin: "md"
1263
+ }],
1264
+ alignItems: "center"
1265
+ }];
1266
+ if (deviceType) headerContents.push({
1267
+ type: "text",
1268
+ text: deviceType,
1269
+ size: "sm",
1270
+ color: "#888888",
1271
+ margin: "sm"
1272
+ });
1273
+ if (status) headerContents.push({
1274
+ type: "box",
1275
+ layout: "vertical",
1276
+ contents: [{
1277
+ type: "text",
1278
+ text: status,
1279
+ size: "sm",
1280
+ color: "#444444",
1281
+ wrap: true
1282
+ }],
1283
+ margin: "lg",
1284
+ paddingAll: "md",
1285
+ backgroundColor: "#F8F9FA",
1286
+ cornerRadius: "md"
1287
+ });
1288
+ const bubble = {
1289
+ type: "bubble",
1290
+ size: "mega",
1291
+ body: {
1292
+ type: "box",
1293
+ layout: "vertical",
1294
+ contents: headerContents,
1295
+ paddingAll: "xl",
1296
+ backgroundColor: "#FFFFFF"
1297
+ }
1298
+ };
1299
+ if (imageUrl) bubble.hero = {
1300
+ type: "image",
1301
+ url: imageUrl,
1302
+ size: "full",
1303
+ aspectRatio: "16:9",
1304
+ aspectMode: "cover"
1305
+ };
1306
+ if (controls.length > 0) {
1307
+ const rows = [];
1308
+ const limitedControls = controls.slice(0, 6);
1309
+ for (let i = 0; i < limitedControls.length; i += 2) {
1310
+ const rowButtons = [];
1311
+ for (const [offset, ctrl] of limitedControls.slice(i, i + 2).entries()) {
1312
+ const buttonLabel = ctrl.icon ? `${ctrl.icon} ${ctrl.label}` : ctrl.label;
1313
+ rowButtons.push({
1314
+ type: "button",
1315
+ action: postbackAction(truncateLineActionLabel(buttonLabel, 18), ctrl.data),
1316
+ style: ctrl.style ?? "secondary",
1317
+ flex: 1,
1318
+ height: "sm",
1319
+ margin: offset > 0 ? "md" : void 0
1320
+ });
1321
+ }
1322
+ if (rowButtons.length === 1) rowButtons.push({ type: "filler" });
1323
+ rows.push({
1324
+ type: "box",
1325
+ layout: "horizontal",
1326
+ contents: rowButtons,
1327
+ margin: i > 0 ? "md" : void 0
1328
+ });
1329
+ }
1330
+ bubble.footer = {
1331
+ type: "box",
1332
+ layout: "vertical",
1333
+ contents: rows,
1334
+ paddingAll: "lg",
1335
+ backgroundColor: "#FAFAFA"
1336
+ };
1337
+ }
1338
+ return bubble;
1339
+ }
1340
+ //#endregion
1341
+ export { postbackAction as _, createEventCard as a, createCarousel as c, createListCard as d, createNotificationBubble as f, normalizeLineMessageActions as g, normalizeLineAction as h, createAgendaCard as i, createImageCard as l, messageAction as m, createDeviceControlCard as n, createReceiptCard as o, datetimePickerAction as p, createMediaPlayerCard as r, createActionCard as s, createAppleTvRemoteCard as t, createInfoCard as u, uriAction as v };