atagen

malice

public
Star0
Watch0
c1e86c4a3a6cebca0b28f413ffb9a591ae74b469
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git

Blame: web/src/lib/MessageRow.svelte

973f8fbdaf80atagen2026-09-28 09:10 UTC1
<script lang="ts">
973f8fbdaf80atagen2026-09-28 09:10 UTC2
  import MediaAttachmentView from './MediaAttachmentView.svelte';
973f8fbdaf80atagen2026-09-28 09:10 UTC3
  import MxcAvatar from './MxcAvatar.svelte';
544a170ead2catagen2026-10-20 11:47 UTC4
  import Emoji from './Emoji.svelte';
544a170ead2catagen2026-10-20 11:47 UTC5
  import EmojiText from './EmojiText.svelte';
df3c0f2b3da4atagen2026-10-22 13:07 UTC6
  import MessageText from './MessageText.svelte';
544a170ead2catagen2026-10-20 11:47 UTC7
  import ReactionPicker from './ReactionPicker.svelte';
b8ab00377c20atagen2026-10-22 05:13 UTC8
  import LinkCard from './LinkCard.svelte';
ecb8598b38afatagen2026-10-22 09:19 UTC9
  import { mediaUrl, messageMediaUrl } from './api';
a4555a7eae2datagen2026-10-25 09:18 UTC10
  import { keywordMatcher } from './keywords';
df3c0f2b3da4atagen2026-10-22 13:07 UTC11
  import type { ImagePack, LinkPreview, Person, QuickReaction, ReplyReference, SendState, TimelineContent, TimelineEvent } from './types';
973f8fbdaf80atagen2026-09-28 09:10 UTC12
  import { senderLabel } from './types';
973f8fbdaf80atagen2026-09-28 09:10 UTC13
  import { formatClock, formatDay, initialsOf, senderHue } from './format';
973f8fbdaf80atagen2026-09-28 09:10 UTC14
  import { findUrls } from './urls';
787cdbbf0721atagen2026-10-24 06:50 UTC15
  import { mentionsFromHtml, resolveMentions, stripMarkdownPills } from './mentions';
973f8fbdaf80atagen2026-09-28 09:10 UTC16
973f8fbdaf80atagen2026-09-28 09:10 UTC17
  export let itemId: string;
973f8fbdaf80atagen2026-09-28 09:10 UTC18
  export let event: TimelineEvent;
973f8fbdaf80atagen2026-09-28 09:10 UTC19
  export let showSender: boolean;
973f8fbdaf80atagen2026-09-28 09:10 UTC20
  export let reacting: boolean;
ecb8598b38afatagen2026-10-22 09:19 UTC21
  export let onReact: (eventId: string, key: string, shortcode?: string) => void;
973f8fbdaf80atagen2026-09-28 09:10 UTC22
  export let senderAvatar: string | null = null;
544a170ead2catagen2026-10-20 11:47 UTC23
  export let quickReactions: QuickReaction[] = [];
544a170ead2catagen2026-10-20 11:47 UTC24
  export let packs: ImagePack[] = [];
544a170ead2catagen2026-10-20 11:47 UTC25
  export let onQuickChange: (list: QuickReaction[]) => void = () => {};
ecb8598b38afatagen2026-10-22 09:19 UTC26
  export let linkPreviews: Record<string, LinkPreview | null> = {};
ecb8598b38afatagen2026-10-22 09:19 UTC27
  export let loadPreview: ((url: string) => void) | null = null;
df3c0f2b3da4atagen2026-10-22 13:07 UTC28
  export let people: Record<string, Person> = {};
df3c0f2b3da4atagen2026-10-22 13:07 UTC29
  export let onReply: ((target: ReplyReference) => void) | null = null;
df3c0f2b3da4atagen2026-10-22 13:07 UTC30
  export let onJump: ((eventId: string) => void) | null = null;
cf23dbf4e77catagen2026-10-23 06:36 UTC31
  export let onEdit: ((eventId: string, body: string) => void) | null = null;
cf23dbf4e77catagen2026-10-23 06:36 UTC32
  export let editing = false;
df3c0f2b3da4atagen2026-10-22 13:07 UTC33
  export let showSent = true;
668ab5c30531atagen2026-10-25 03:13 UTC34
  export let readOnly = false;
705b1e1062c2atagen2026-10-23 09:05 UTC35
  export let self: string | null = null;
d8624c214c04atagen2026-10-24 08:24 UTC36
  export let onUser: ((userId: string, x: number, y: number, menu: boolean) => void) | null = null;
d095131eec0eatagen2026-10-24 08:39 UTC37
  export let onCloneSticker: ((eventId: string, body: string, x: number, y: number) => void) | null = null;
0380cd8c765catagen2026-10-24 09:08 UTC38
  export let onMore: ((event: TimelineEvent, x: number, y: number) => void) | null = null;
7ebc2472a9e3atagen2026-10-25 09:53 UTC39
  export let onOpenThread: ((rootEventId: string) => void) | null = null;
d8624c214c04atagen2026-10-24 08:24 UTC40
d2a34d0f4861atagen2026-10-25 07:29 UTC41
  $: lag = lagLabel(event);
7ebc2472a9e3atagen2026-10-25 09:53 UTC42
  $: threadRoot = onOpenThread && interactive && event.event_id && !event.thread_root ? event.event_id : null;
7ebc2472a9e3atagen2026-10-25 09:53 UTC43
  $: threadReplies = event.thread_summary?.reply_count ?? 0;
d2a34d0f4861atagen2026-10-25 07:29 UTC44
d2a34d0f4861atagen2026-10-25 07:29 UTC45
  function lagLabel(event: TimelineEvent): string | null {
d2a34d0f4861atagen2026-10-25 07:29 UTC46
    const lag = event.delivery_lag_ms;
d2a34d0f4861atagen2026-10-25 07:29 UTC47
    if (!lag) return null;
d2a34d0f4861atagen2026-10-25 07:29 UTC48
    if (lag < 60 * 60 * 1000) return `${Math.max(1, Math.floor(lag / 60000))}m`;
d2a34d0f4861atagen2026-10-25 07:29 UTC49
    if (lag < 24 * 60 * 60 * 1000) return `${Math.floor(lag / 3600000)}h`;
d2a34d0f4861atagen2026-10-25 07:29 UTC50
    return `${Math.floor(lag / 86400000)}d`;
d2a34d0f4861atagen2026-10-25 07:29 UTC51
  }
d2a34d0f4861atagen2026-10-25 07:29 UTC52
d8624c214c04atagen2026-10-24 08:24 UTC53
  function openUser(ev: MouseEvent, menu: boolean): void {
d8624c214c04atagen2026-10-24 08:24 UTC54
    if (!onUser) return;
d8624c214c04atagen2026-10-24 08:24 UTC55
    const rect = (ev.currentTarget as HTMLElement).getBoundingClientRect();
d8624c214c04atagen2026-10-24 08:24 UTC56
    onUser(event.sender.user_id, menu ? ev.clientX : rect.left, menu ? ev.clientY : rect.bottom + 4, menu);
d8624c214c04atagen2026-10-24 08:24 UTC57
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC58
544a170ead2catagen2026-10-20 11:47 UTC59
  const PICKER_WIDTH = 320;
544a170ead2catagen2026-10-20 11:47 UTC60
  const PICKER_HEIGHT = 380;
544a170ead2catagen2026-10-20 11:47 UTC61
  const PICKER_MARGIN = 8;
df3c0f2b3da4atagen2026-10-22 13:07 UTC62
  const MAX_READERS = 3;
05a48e9e7942atagen2026-10-24 09:32 UTC63
  const STATE_LABELS: Record<string, string> = {
05a48e9e7942atagen2026-10-24 09:32 UTC64
    'm.room.pinned_events': 'changed the pinned messages',
05a48e9e7942atagen2026-10-24 09:32 UTC65
    'm.room.power_levels': 'changed the room permissions',
05a48e9e7942atagen2026-10-24 09:32 UTC66
    'm.room.join_rules': 'changed who can join',
05a48e9e7942atagen2026-10-24 09:32 UTC67
    'm.room.history_visibility': 'changed who can read history',
05a48e9e7942atagen2026-10-24 09:32 UTC68
    'm.room.guest_access': 'changed guest access',
05a48e9e7942atagen2026-10-24 09:32 UTC69
    'm.room.canonical_alias': 'changed the room address',
05a48e9e7942atagen2026-10-24 09:32 UTC70
    'm.room.server_acl': 'changed the server access list',
05a48e9e7942atagen2026-10-24 09:32 UTC71
    'm.space.child': 'changed the rooms in this space',
05a48e9e7942atagen2026-10-24 09:32 UTC72
    'm.space.parent': 'changed the parent space',
05a48e9e7942atagen2026-10-24 09:32 UTC73
    'im.ponies.room_emotes': 'updated a sticker pack'
05a48e9e7942atagen2026-10-24 09:32 UTC74
  };
544a170ead2catagen2026-10-20 11:47 UTC75
544a170ead2catagen2026-10-20 11:47 UTC76
  let row: HTMLDivElement;
544a170ead2catagen2026-10-20 11:47 UTC77
  let pickerPop: HTMLDivElement | undefined;
544a170ead2catagen2026-10-20 11:47 UTC78
  let selected = false;
544a170ead2catagen2026-10-20 11:47 UTC79
  let pickerOpen = false;
544a170ead2catagen2026-10-20 11:47 UTC80
  let pickerStyle = '';
973f8fbdaf80atagen2026-09-28 09:10 UTC81
973f8fbdaf80atagen2026-09-28 09:10 UTC82
  const MEMBERSHIP_LABELS: Record<string, string> = {
973f8fbdaf80atagen2026-09-28 09:10 UTC83
    Joined: 'joined the room',
973f8fbdaf80atagen2026-09-28 09:10 UTC84
    Left: 'left the room',
973f8fbdaf80atagen2026-09-28 09:10 UTC85
    Banned: 'was banned',
973f8fbdaf80atagen2026-09-28 09:10 UTC86
    Unbanned: 'was unbanned',
973f8fbdaf80atagen2026-09-28 09:10 UTC87
    Kicked: 'was kicked',
973f8fbdaf80atagen2026-09-28 09:10 UTC88
    KickedAndBanned: 'was kicked and banned',
973f8fbdaf80atagen2026-09-28 09:10 UTC89
    Invited: 'was invited',
973f8fbdaf80atagen2026-09-28 09:10 UTC90
    InvitationAccepted: 'accepted the invite',
973f8fbdaf80atagen2026-09-28 09:10 UTC91
    InvitationRejected: 'rejected the invite',
973f8fbdaf80atagen2026-09-28 09:10 UTC92
    InvitationRevoked: 'had the invite revoked',
973f8fbdaf80atagen2026-09-28 09:10 UTC93
    Knocked: 'requested to join',
973f8fbdaf80atagen2026-09-28 09:10 UTC94
    KnockAccepted: 'was let in',
973f8fbdaf80atagen2026-09-28 09:10 UTC95
    KnockRetracted: 'withdrew the request to join',
973f8fbdaf80atagen2026-09-28 09:10 UTC96
    KnockDenied: 'had the request to join denied'
973f8fbdaf80atagen2026-09-28 09:10 UTC97
  };
973f8fbdaf80atagen2026-09-28 09:10 UTC98
f604ef6df0c4atagen2026-10-24 10:08 UTC99
  $: name = event.sender.display_name ?? people[event.sender.user_id]?.name ?? event.sender.user_id;
973f8fbdaf80atagen2026-09-28 09:10 UTC100
  $: displayName = event.sender.name_ambiguous ? `${name} (${event.sender.user_id})` : name;
df3c0f2b3da4atagen2026-10-22 13:07 UTC101
  $: readers = event.read_by.map((id) => people[id] ?? { user_id: id, name: id, avatar: null });
973f8fbdaf80atagen2026-09-28 09:10 UTC102
  $: interactive = event.content.kind === 'Message' || event.content.kind === 'Sticker' || event.content.kind === 'Poll';
705b1e1062c2atagen2026-10-23 09:05 UTC103
  $: message = event.content.kind === 'Message' ? event.content.message : null;
705b1e1062c2atagen2026-10-23 09:05 UTC104
  $: stripped = stripMarkdownPills(message ? (message.media ? message.media.caption : message.body) ?? '' : '');
787cdbbf0721atagen2026-10-24 06:50 UTC105
  $: linked = message ? [...mentionsFromHtml(message.formatted_body), ...stripped.mentions] : [];
787cdbbf0721atagen2026-10-24 06:50 UTC106
  $: mentions = resolveMentions(stripped.text, linked);
787cdbbf0721atagen2026-10-24 06:50 UTC107
  $: mentionsMe = self !== null && [...linked, ...mentions].some((m) => m.user_id === self);
a4555a7eae2datagen2026-10-25 09:18 UTC108
  $: keywordHit = !event.own && (event.highlight === true || (message !== null && ($keywordMatcher?.test(stripped.text) ?? false)));
705b1e1062c2atagen2026-10-23 09:05 UTC109
  $: previews = findUrls(stripped.text);
705b1e1062c2atagen2026-10-23 09:05 UTC110
  $: bundled = message ? message.link_previews : [];
705b1e1062c2atagen2026-10-23 09:05 UTC111
  $: cards = previews
705b1e1062c2atagen2026-10-23 09:05 UTC112
    .map((link) => ({ link, preview: bundled.find((b) => b.url === link.href) ?? linkPreviews[link.href] ?? null }))
705b1e1062c2atagen2026-10-23 09:05 UTC113
    .filter((c) => c.preview && (c.preview.title || c.preview.description || c.preview.image));
ecb8598b38afatagen2026-10-22 09:19 UTC114
  $: if (loadPreview) {
ecb8598b38afatagen2026-10-22 09:19 UTC115
    for (const link of previews) {
ecb8598b38afatagen2026-10-22 09:19 UTC116
      if (!bundled.some((b) => b.url === link.href) && !(link.href in linkPreviews)) loadPreview(link.href);
ecb8598b38afatagen2026-10-22 09:19 UTC117
    }
ecb8598b38afatagen2026-10-22 09:19 UTC118
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC119
f604ef6df0c4atagen2026-10-24 10:08 UTC120
  $: sent = interactive && showSent && event.own && event.send_state.kind === 'Sent' && event.event_id !== null;
f604ef6df0c4atagen2026-10-24 10:08 UTC121
973f8fbdaf80atagen2026-09-28 09:10 UTC122
  function sendLabel(state: SendState): string {
973f8fbdaf80atagen2026-09-28 09:10 UTC123
    if (state.kind === 'Failed') return state.will_retry ? 'failed — will retry' : 'failed — not delivered';
973f8fbdaf80atagen2026-09-28 09:10 UTC124
    if (state.kind === 'Sending') return 'sending…';
973f8fbdaf80atagen2026-09-28 09:10 UTC125
    return '';
973f8fbdaf80atagen2026-09-28 09:10 UTC126
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC127
544a170ead2catagen2026-10-20 11:47 UTC128
  function toggleSelected(e: MouseEvent) {
668ab5c30531atagen2026-10-25 03:13 UTC129
    if (readOnly || !interactive || (e.target as Element).closest('a, button, input, video, audio, .picker-pop')) return;
544a170ead2catagen2026-10-20 11:47 UTC130
    selected = !selected;
544a170ead2catagen2026-10-20 11:47 UTC131
  }
544a170ead2catagen2026-10-20 11:47 UTC132
544a170ead2catagen2026-10-20 11:47 UTC133
  function deselectOutside(e: PointerEvent) {
544a170ead2catagen2026-10-20 11:47 UTC134
    if (selected && !pickerOpen && !row.contains(e.target as Node)) selected = false;
544a170ead2catagen2026-10-20 11:47 UTC135
  }
544a170ead2catagen2026-10-20 11:47 UTC136
544a170ead2catagen2026-10-20 11:47 UTC137
  function openPicker(e: MouseEvent) {
544a170ead2catagen2026-10-20 11:47 UTC138
    if (pickerOpen) {
544a170ead2catagen2026-10-20 11:47 UTC139
      pickerOpen = false;
544a170ead2catagen2026-10-20 11:47 UTC140
      return;
544a170ead2catagen2026-10-20 11:47 UTC141
    }
544a170ead2catagen2026-10-20 11:47 UTC142
    const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
544a170ead2catagen2026-10-20 11:47 UTC143
    const height = Math.min(PICKER_HEIGHT, window.innerHeight - 2 * PICKER_MARGIN);
544a170ead2catagen2026-10-20 11:47 UTC144
    const below = window.innerHeight - rect.bottom - PICKER_MARGIN >= height;
544a170ead2catagen2026-10-20 11:47 UTC145
    const top = below ? rect.bottom + 4 : Math.max(PICKER_MARGIN, rect.top - height - 4);
544a170ead2catagen2026-10-20 11:47 UTC146
    const maxLeft = window.innerWidth - PICKER_WIDTH - PICKER_MARGIN;
544a170ead2catagen2026-10-20 11:47 UTC147
    const left = Math.max(PICKER_MARGIN, Math.min(rect.right - PICKER_WIDTH, maxLeft));
544a170ead2catagen2026-10-20 11:47 UTC148
    pickerStyle = `top:${top}px;left:${left}px;height:${height}px`;
544a170ead2catagen2026-10-20 11:47 UTC149
    selected = true;
544a170ead2catagen2026-10-20 11:47 UTC150
    pickerOpen = true;
544a170ead2catagen2026-10-20 11:47 UTC151
  }
544a170ead2catagen2026-10-20 11:47 UTC152
544a170ead2catagen2026-10-20 11:47 UTC153
  function closePicker() {
544a170ead2catagen2026-10-20 11:47 UTC154
    pickerOpen = false;
544a170ead2catagen2026-10-20 11:47 UTC155
  }
544a170ead2catagen2026-10-20 11:47 UTC156
ecb8598b38afatagen2026-10-22 09:19 UTC157
  function isImageKey(key: string): boolean {
ecb8598b38afatagen2026-10-22 09:19 UTC158
    return key.startsWith('mxc://') || packs.some((p) => p.images.some((i) => i.reaction_key === key));
ecb8598b38afatagen2026-10-22 09:19 UTC159
  }
ecb8598b38afatagen2026-10-22 09:19 UTC160
ecb8598b38afatagen2026-10-22 09:19 UTC161
  function react(key: string, shortcode: string | null) {
ecb8598b38afatagen2026-10-22 09:19 UTC162
    if (shortcode && isImageKey(key)) onReact(event.event_id ?? '', key, shortcode);
ecb8598b38afatagen2026-10-22 09:19 UTC163
    else onReact(event.event_id ?? '', key);
ecb8598b38afatagen2026-10-22 09:19 UTC164
  }
ecb8598b38afatagen2026-10-22 09:19 UTC165
df3c0f2b3da4atagen2026-10-22 13:07 UTC166
  function reply() {
df3c0f2b3da4atagen2026-10-22 13:07 UTC167
    if (!event.event_id || !onReply) return;
df3c0f2b3da4atagen2026-10-22 13:07 UTC168
    onReply({
df3c0f2b3da4atagen2026-10-22 13:07 UTC169
      event_id: event.event_id,
df3c0f2b3da4atagen2026-10-22 13:07 UTC170
      details: { kind: 'Ready', sender: event.sender, content: event.content, timestamp_ms: event.timestamp_ms }
df3c0f2b3da4atagen2026-10-22 13:07 UTC171
    });
df3c0f2b3da4atagen2026-10-22 13:07 UTC172
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC173
cf23dbf4e77catagen2026-10-23 06:36 UTC174
  $: editableBody =
cf23dbf4e77catagen2026-10-23 06:36 UTC175
    event.own && event.editable && event.event_id && event.content.kind === 'Message' && event.content.message.kind === 'Text'
cf23dbf4e77catagen2026-10-23 06:36 UTC176
      ? event.content.message.body
cf23dbf4e77catagen2026-10-23 06:36 UTC177
      : null;
cf23dbf4e77catagen2026-10-23 06:36 UTC178
cf23dbf4e77catagen2026-10-23 06:36 UTC179
  function edit() {
cf23dbf4e77catagen2026-10-23 06:36 UTC180
    if (!event.event_id || editableBody === null || !onEdit) return;
cf23dbf4e77catagen2026-10-23 06:36 UTC181
    onEdit(event.event_id, editableBody);
cf23dbf4e77catagen2026-10-23 06:36 UTC182
  }
cf23dbf4e77catagen2026-10-23 06:36 UTC183
cf23dbf4e77catagen2026-10-23 06:36 UTC184
  function reactorNames(senders: string[]): string {
cf23dbf4e77catagen2026-10-23 06:36 UTC185
    const names = senders.map((id) => people[id]?.name ?? id);
cf23dbf4e77catagen2026-10-23 06:36 UTC186
    if (names.length <= 12) return names.join(', ');
cf23dbf4e77catagen2026-10-23 06:36 UTC187
    return `${names.slice(0, 12).join(', ')} and ${names.length - 12} more`;
cf23dbf4e77catagen2026-10-23 06:36 UTC188
  }
cf23dbf4e77catagen2026-10-23 06:36 UTC189
ecb8598b38afatagen2026-10-22 09:19 UTC190
  function pick(key: string, shortcode: string | null) {
544a170ead2catagen2026-10-20 11:47 UTC191
    pickerOpen = false;
ecb8598b38afatagen2026-10-22 09:19 UTC192
    react(key, shortcode);
544a170ead2catagen2026-10-20 11:47 UTC193
  }
544a170ead2catagen2026-10-20 11:47 UTC194
544a170ead2catagen2026-10-20 11:47 UTC195
  function closeOnScroll(e: Event) {
544a170ead2catagen2026-10-20 11:47 UTC196
    if (pickerOpen && !pickerPop?.contains(e.target as Node)) pickerOpen = false;
544a170ead2catagen2026-10-20 11:47 UTC197
  }
544a170ead2catagen2026-10-20 11:47 UTC198
973f8fbdaf80atagen2026-09-28 09:10 UTC199
  function actorLabel(userId: string, name: string | null): string {
f604ef6df0c4atagen2026-10-24 10:08 UTC200
    return name ?? people[userId]?.name ?? userId;
973f8fbdaf80atagen2026-09-28 09:10 UTC201
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC202
973f8fbdaf80atagen2026-09-28 09:10 UTC203
  function replyPreview(content: TimelineContent): string {
705b1e1062c2atagen2026-10-23 09:05 UTC204
    if (content.kind === 'Message') return stripMarkdownPills(content.message.body).text;
973f8fbdaf80atagen2026-09-28 09:10 UTC205
    if (content.kind === 'Sticker') return content.body || 'Sticker';
973f8fbdaf80atagen2026-09-28 09:10 UTC206
    if (content.kind === 'Poll') return `Poll: ${content.question}`;
973f8fbdaf80atagen2026-09-28 09:10 UTC207
    if (content.kind === 'Redacted') return 'Message deleted';
973f8fbdaf80atagen2026-09-28 09:10 UTC208
    if (content.kind === 'UnableToDecrypt') return 'Unable to decrypt';
973f8fbdaf80atagen2026-09-28 09:10 UTC209
    return systemLine(content);
973f8fbdaf80atagen2026-09-28 09:10 UTC210
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC211
f604ef6df0c4atagen2026-10-24 10:08 UTC212
  function systemLine(content: TimelineContent, actor = displayName): string {
973f8fbdaf80atagen2026-09-28 09:10 UTC213
    switch (content.kind) {
973f8fbdaf80atagen2026-09-28 09:10 UTC214
      case 'Redacted':
973f8fbdaf80atagen2026-09-28 09:10 UTC215
        return 'Message deleted';
973f8fbdaf80atagen2026-09-28 09:10 UTC216
      case 'UnableToDecrypt':
f604ef6df0c4atagen2026-10-24 10:08 UTC217
        return `Message from ${actor} could not be decrypted`;
973f8fbdaf80atagen2026-09-28 09:10 UTC218
      case 'Membership': {
973f8fbdaf80atagen2026-09-28 09:10 UTC219
        const who = actorLabel(content.user_id, content.display_name);
973f8fbdaf80atagen2026-09-28 09:10 UTC220
        return `${who} ${MEMBERSHIP_LABELS[content.change] ?? 'updated their membership'}`;
973f8fbdaf80atagen2026-09-28 09:10 UTC221
      }
973f8fbdaf80atagen2026-09-28 09:10 UTC222
      case 'Profile': {
973f8fbdaf80atagen2026-09-28 09:10 UTC223
        const who = actorLabel(content.user_id, null);
973f8fbdaf80atagen2026-09-28 09:10 UTC224
        const parts: string[] = [];
973f8fbdaf80atagen2026-09-28 09:10 UTC225
        if (content.display_name) {
973f8fbdaf80atagen2026-09-28 09:10 UTC226
          parts.push(
973f8fbdaf80atagen2026-09-28 09:10 UTC227
            content.display_name.new
973f8fbdaf80atagen2026-09-28 09:10 UTC228
              ? `changed their display name to "${content.display_name.new}"`
973f8fbdaf80atagen2026-09-28 09:10 UTC229
              : 'removed their display name'
973f8fbdaf80atagen2026-09-28 09:10 UTC230
          );
973f8fbdaf80atagen2026-09-28 09:10 UTC231
        }
973f8fbdaf80atagen2026-09-28 09:10 UTC232
        if (content.avatar) parts.push('changed their avatar');
973f8fbdaf80atagen2026-09-28 09:10 UTC233
        return `${who} ${parts.length > 0 ? parts.join(' and ') : 'updated their profile'}`;
973f8fbdaf80atagen2026-09-28 09:10 UTC234
      }
973f8fbdaf80atagen2026-09-28 09:10 UTC235
      case 'RoomName':
973f8fbdaf80atagen2026-09-28 09:10 UTC236
        return content.name
f604ef6df0c4atagen2026-10-24 10:08 UTC237
          ? `${actor} changed the room name to "${content.name}"`
f604ef6df0c4atagen2026-10-24 10:08 UTC238
          : `${actor} removed the room name`;
973f8fbdaf80atagen2026-09-28 09:10 UTC239
      case 'RoomTopic':
973f8fbdaf80atagen2026-09-28 09:10 UTC240
        return content.topic
f604ef6df0c4atagen2026-10-24 10:08 UTC241
          ? `${actor} changed the topic to "${content.topic}"`
f604ef6df0c4atagen2026-10-24 10:08 UTC242
          : `${actor} removed the topic`;
973f8fbdaf80atagen2026-09-28 09:10 UTC243
      case 'RoomAvatar':
f604ef6df0c4atagen2026-10-24 10:08 UTC244
        return content.avatar ? `${actor} changed the room avatar` : `${actor} removed the room avatar`;
973f8fbdaf80atagen2026-09-28 09:10 UTC245
      case 'EncryptionEnabled':
f604ef6df0c4atagen2026-10-24 10:08 UTC246
        return `${actor} enabled encryption in this room`;
973f8fbdaf80atagen2026-09-28 09:10 UTC247
      case 'RoomCreated':
f604ef6df0c4atagen2026-10-24 10:08 UTC248
        return `${actor} created the room`;
973f8fbdaf80atagen2026-09-28 09:10 UTC249
      case 'RoomUpgraded':
f604ef6df0c4atagen2026-10-24 10:08 UTC250
        return `${actor} upgraded the room to a new version`;
973f8fbdaf80atagen2026-09-28 09:10 UTC251
      case 'OtherState':
f604ef6df0c4atagen2026-10-24 10:08 UTC252
        return `${actor} ${STATE_LABELS[content.event_type] ?? `sent a state event (${content.event_type})`}`;
973f8fbdaf80atagen2026-09-28 09:10 UTC253
      case 'Other':
f604ef6df0c4atagen2026-10-24 10:08 UTC254
        return `${actor} sent an event (${content.event_type})`;
973f8fbdaf80atagen2026-09-28 09:10 UTC255
      default:
f604ef6df0c4atagen2026-10-24 10:08 UTC256
        return actor;
973f8fbdaf80atagen2026-09-28 09:10 UTC257
    }
973f8fbdaf80atagen2026-09-28 09:10 UTC258
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC259
</script>
973f8fbdaf80atagen2026-09-28 09:10 UTC260
544a170ead2catagen2026-10-20 11:47 UTC261
<svelte:window
544a170ead2catagen2026-10-20 11:47 UTC262
  on:pointerdown={deselectOutside}
544a170ead2catagen2026-10-20 11:47 UTC263
  on:keydown={(e) => e.key === 'Escape' && (selected = false)}
544a170ead2catagen2026-10-20 11:47 UTC264
  on:scroll|capture={closeOnScroll}
544a170ead2catagen2026-10-20 11:47 UTC265
  on:resize={closePicker}
544a170ead2catagen2026-10-20 11:47 UTC266
/>
544a170ead2catagen2026-10-20 11:47 UTC267
544a170ead2catagen2026-10-20 11:47 UTC268
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
544a170ead2catagen2026-10-20 11:47 UTC269
<div
544a170ead2catagen2026-10-20 11:47 UTC270
  class="msg"
544a170ead2catagen2026-10-20 11:47 UTC271
  class:own={event.own}
cf23dbf4e77catagen2026-10-23 06:36 UTC272
  class:editing
a4555a7eae2datagen2026-10-25 09:18 UTC273
  class:mentioned={mentionsMe || keywordHit}
544a170ead2catagen2026-10-20 11:47 UTC274
  class:system={!interactive}
df3c0f2b3da4atagen2026-10-22 13:07 UTC275
  class:has-readers={interactive && readers.length > 0}
544a170ead2catagen2026-10-20 11:47 UTC276
  class:selected
544a170ead2catagen2026-10-20 11:47 UTC277
  data-item={itemId}
df3c0f2b3da4atagen2026-10-22 13:07 UTC278
  data-event={event.event_id}
544a170ead2catagen2026-10-20 11:47 UTC279
  bind:this={row}
544a170ead2catagen2026-10-20 11:47 UTC280
  on:click={toggleSelected}
544a170ead2catagen2026-10-20 11:47 UTC281
>
668ab5c30531atagen2026-10-25 03:13 UTC282
  {#if !readOnly && interactive && event.event_id}
544a170ead2catagen2026-10-20 11:47 UTC283
    <div class="actions" role="toolbar" aria-label={`Actions for message from ${displayName}`}>
544a170ead2catagen2026-10-20 11:47 UTC284
      {#each quickReactions as r (r.key)}
544a170ead2catagen2026-10-20 11:47 UTC285
        {@const label = r.shortcode ? `:${r.shortcode}:` : r.key}
544a170ead2catagen2026-10-20 11:47 UTC286
        <button
544a170ead2catagen2026-10-20 11:47 UTC287
          type="button"
544a170ead2catagen2026-10-20 11:47 UTC288
          title={`React ${label}`}
544a170ead2catagen2026-10-20 11:47 UTC289
          aria-label={`React ${label} to message from ${displayName}`}
544a170ead2catagen2026-10-20 11:47 UTC290
          disabled={reacting}
ecb8598b38afatagen2026-10-22 09:19 UTC291
          on:click={() => react(r.key, r.shortcode)}
544a170ead2catagen2026-10-20 11:47 UTC292
        >
544a170ead2catagen2026-10-20 11:47 UTC293
          {#if r.key.startsWith('mxc://')}
7643577c76bbatagen2026-10-25 07:37 UTC294
            <img class="emote" src={mediaUrl(r.key, 64) ?? ''} alt="" />
544a170ead2catagen2026-10-20 11:47 UTC295
          {:else}
544a170ead2catagen2026-10-20 11:47 UTC296
            <Emoji emoji={r.key} size={18} />
544a170ead2catagen2026-10-20 11:47 UTC297
          {/if}
544a170ead2catagen2026-10-20 11:47 UTC298
        </button>
544a170ead2catagen2026-10-20 11:47 UTC299
      {/each}
544a170ead2catagen2026-10-20 11:47 UTC300
      <button
544a170ead2catagen2026-10-20 11:47 UTC301
        type="button"
544a170ead2catagen2026-10-20 11:47 UTC302
        title="Add reaction"
544a170ead2catagen2026-10-20 11:47 UTC303
        aria-label={`Add reaction to message from ${displayName}`}
544a170ead2catagen2026-10-20 11:47 UTC304
        aria-haspopup="dialog"
544a170ead2catagen2026-10-20 11:47 UTC305
        aria-expanded={pickerOpen}
544a170ead2catagen2026-10-20 11:47 UTC306
        on:pointerdown|stopPropagation
544a170ead2catagen2026-10-20 11:47 UTC307
        on:click={openPicker}
544a170ead2catagen2026-10-20 11:47 UTC308
      >
544a170ead2catagen2026-10-20 11:47 UTC309
        ☺+
544a170ead2catagen2026-10-20 11:47 UTC310
      </button>
d095131eec0eatagen2026-10-24 08:39 UTC311
      {#if onCloneSticker && event.content.kind === 'Sticker'}
d095131eec0eatagen2026-10-24 08:39 UTC312
        {@const stickerBody = event.content.body}
d095131eec0eatagen2026-10-24 08:39 UTC313
        {@const stickerId = event.event_id}
d095131eec0eatagen2026-10-24 08:39 UTC314
        <button
d095131eec0eatagen2026-10-24 08:39 UTC315
          type="button"
d095131eec0eatagen2026-10-24 08:39 UTC316
          title="Clone sticker"
d095131eec0eatagen2026-10-24 08:39 UTC317
          aria-label="Clone sticker to one of your packs"
d095131eec0eatagen2026-10-24 08:39 UTC318
          on:click|stopPropagation={(ev) => onCloneSticker?.(stickerId, stickerBody, ev.clientX, ev.clientY)}
d095131eec0eatagen2026-10-24 08:39 UTC319
        >
d095131eec0eatagen2026-10-24 08:39 UTC320
          ⧉
d095131eec0eatagen2026-10-24 08:39 UTC321
        </button>
d095131eec0eatagen2026-10-24 08:39 UTC322
      {/if}
df3c0f2b3da4atagen2026-10-22 13:07 UTC323
      {#if onReply}
df3c0f2b3da4atagen2026-10-22 13:07 UTC324
        <button
df3c0f2b3da4atagen2026-10-22 13:07 UTC325
          type="button"
df3c0f2b3da4atagen2026-10-22 13:07 UTC326
          title="Reply"
df3c0f2b3da4atagen2026-10-22 13:07 UTC327
          aria-label={`Reply to message from ${displayName}`}
df3c0f2b3da4atagen2026-10-22 13:07 UTC328
          on:click|stopPropagation={reply}
df3c0f2b3da4atagen2026-10-22 13:07 UTC329
        >
df3c0f2b3da4atagen2026-10-22 13:07 UTC330
          ↩
df3c0f2b3da4atagen2026-10-22 13:07 UTC331
        </button>
df3c0f2b3da4atagen2026-10-22 13:07 UTC332
      {/if}
7ebc2472a9e3atagen2026-10-25 09:53 UTC333
      {#if threadRoot}
7ebc2472a9e3atagen2026-10-25 09:53 UTC334
        {@const root = threadRoot}
7ebc2472a9e3atagen2026-10-25 09:53 UTC335
        <button
7ebc2472a9e3atagen2026-10-25 09:53 UTC336
          type="button"
7ebc2472a9e3atagen2026-10-25 09:53 UTC337
          title="Reply in thread"
7ebc2472a9e3atagen2026-10-25 09:53 UTC338
          aria-label={`Reply in thread to message from ${displayName}`}
7ebc2472a9e3atagen2026-10-25 09:53 UTC339
          on:click|stopPropagation={() => onOpenThread?.(root)}
7ebc2472a9e3atagen2026-10-25 09:53 UTC340
        >
7ebc2472a9e3atagen2026-10-25 09:53 UTC341
          <svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 3h11v7h-6l-3 3v-3h-2z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M5 6h6M5 8h4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>
7ebc2472a9e3atagen2026-10-25 09:53 UTC342
        </button>
7ebc2472a9e3atagen2026-10-25 09:53 UTC343
      {/if}
cf23dbf4e77catagen2026-10-23 06:36 UTC344
      {#if onEdit && editableBody !== null}
cf23dbf4e77catagen2026-10-23 06:36 UTC345
        <button type="button" title="Edit" aria-label="Edit your message" on:click|stopPropagation={edit}>
cf23dbf4e77catagen2026-10-23 06:36 UTC346
          ✎
cf23dbf4e77catagen2026-10-23 06:36 UTC347
        </button>
cf23dbf4e77catagen2026-10-23 06:36 UTC348
      {/if}
0380cd8c765catagen2026-10-24 09:08 UTC349
      {#if onMore}
0380cd8c765catagen2026-10-24 09:08 UTC350
        <button
0380cd8c765catagen2026-10-24 09:08 UTC351
          type="button"
0380cd8c765catagen2026-10-24 09:08 UTC352
          title="More"
0380cd8c765catagen2026-10-24 09:08 UTC353
          aria-label={`More actions for message from ${displayName}`}
0380cd8c765catagen2026-10-24 09:08 UTC354
          aria-haspopup="menu"
0380cd8c765catagen2026-10-24 09:08 UTC355
          on:click|stopPropagation={(ev) => onMore?.(event, ev.clientX, ev.clientY)}
0380cd8c765catagen2026-10-24 09:08 UTC356
        >
0380cd8c765catagen2026-10-24 09:08 UTC357
          ⋯
0380cd8c765catagen2026-10-24 09:08 UTC358
        </button>
0380cd8c765catagen2026-10-24 09:08 UTC359
      {/if}
544a170ead2catagen2026-10-20 11:47 UTC360
    </div>
544a170ead2catagen2026-10-20 11:47 UTC361
    {#if pickerOpen}
544a170ead2catagen2026-10-20 11:47 UTC362
      <div class="picker-pop" style={pickerStyle} bind:this={pickerPop}>
ecb8598b38afatagen2026-10-22 09:19 UTC363
        <ReactionPicker {packs} quick={quickReactions} onPick={pick} {onQuickChange} onClose={closePicker} />
544a170ead2catagen2026-10-20 11:47 UTC364
      </div>
544a170ead2catagen2026-10-20 11:47 UTC365
    {/if}
544a170ead2catagen2026-10-20 11:47 UTC366
  {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC367
  {#if showSender}
d8624c214c04atagen2026-10-24 08:24 UTC368
    <button
d8624c214c04atagen2026-10-24 08:24 UTC369
      type="button"
d8624c214c04atagen2026-10-24 08:24 UTC370
      class="user-hit"
668ab5c30531atagen2026-10-25 03:13 UTC371
      disabled={!onUser}
d8624c214c04atagen2026-10-24 08:24 UTC372
      tabindex="-1"
d8624c214c04atagen2026-10-24 08:24 UTC373
      aria-hidden="true"
d8624c214c04atagen2026-10-24 08:24 UTC374
      on:click|stopPropagation={(ev) => openUser(ev, false)}
d8624c214c04atagen2026-10-24 08:24 UTC375
      on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)}
d8624c214c04atagen2026-10-24 08:24 UTC376
    >
d8624c214c04atagen2026-10-24 08:24 UTC377
      {#if senderAvatar}
d8624c214c04atagen2026-10-24 08:24 UTC378
        <MxcAvatar mxc={senderAvatar} label={name} size={34} />
d8624c214c04atagen2026-10-24 08:24 UTC379
      {:else}
d8624c214c04atagen2026-10-24 08:24 UTC380
        <span class="avatar" style={`background:hsl(${senderHue(event.sender.user_id)} 35% 32%)`}>
445bf199a9cfatagen2026-10-25 02:56 UTC381
          <span><EmojiText text={initialsOf(name)} /></span>
d8624c214c04atagen2026-10-24 08:24 UTC382
        </span>
d8624c214c04atagen2026-10-24 08:24 UTC383
      {/if}
d8624c214c04atagen2026-10-24 08:24 UTC384
    </button>
973f8fbdaf80atagen2026-09-28 09:10 UTC385
  {:else}
973f8fbdaf80atagen2026-09-28 09:10 UTC386
    <div class="avatar-spacer" aria-hidden="true">
973f8fbdaf80atagen2026-09-28 09:10 UTC387
      <span class="hover-time">{formatClock(event.timestamp_ms)}</span>
973f8fbdaf80atagen2026-09-28 09:10 UTC388
    </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC389
  {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC390
  <div class="msg-body">
973f8fbdaf80atagen2026-09-28 09:10 UTC391
    {#if showSender}
973f8fbdaf80atagen2026-09-28 09:10 UTC392
      <div class="msg-head">
d8624c214c04atagen2026-10-24 08:24 UTC393
        <button
d8624c214c04atagen2026-10-24 08:24 UTC394
          type="button"
d8624c214c04atagen2026-10-24 08:24 UTC395
          class="sender"
668ab5c30531atagen2026-10-25 03:13 UTC396
          disabled={!onUser}
d8624c214c04atagen2026-10-24 08:24 UTC397
          style={`color:hsl(${senderHue(event.sender.user_id)} 70% var(--name-lightness))`}
d8624c214c04atagen2026-10-24 08:24 UTC398
          on:click|stopPropagation={(ev) => openUser(ev, false)}
d8624c214c04atagen2026-10-24 08:24 UTC399
          on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)}
d8624c214c04atagen2026-10-24 08:24 UTC400
        >
445bf199a9cfatagen2026-10-25 02:56 UTC401
          <EmojiText text={displayName} />
d8624c214c04atagen2026-10-24 08:24 UTC402
        </button>
d2a34d0f4861atagen2026-10-25 07:29 UTC403
        {#if lag}
d2a34d0f4861atagen2026-10-25 07:29 UTC404
          <span class="federation-lag" title="Possibly delayed by federation" aria-label={`Arrived ${lag} late, possibly delayed by federation`}>
d2a34d0f4861atagen2026-10-25 07:29 UTC405
            <span aria-hidden="true">◷</span><span>{lag}</span>
d2a34d0f4861atagen2026-10-25 07:29 UTC406
          </span>
d2a34d0f4861atagen2026-10-25 07:29 UTC407
        {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC408
        <time class="time" datetime={new Date(event.timestamp_ms).toISOString()}>
973f8fbdaf80atagen2026-09-28 09:10 UTC409
          {formatDay(event.timestamp_ms)} {formatClock(event.timestamp_ms)}
973f8fbdaf80atagen2026-09-28 09:10 UTC410
        </time>
973f8fbdaf80atagen2026-09-28 09:10 UTC411
        {#if event.content.kind === 'Message' && event.content.message.edited}
973f8fbdaf80atagen2026-09-28 09:10 UTC412
          <span class="edited" title="Edited">(edited)</span>
973f8fbdaf80atagen2026-09-28 09:10 UTC413
        {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC414
      </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC415
    {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC416
    {#if event.reply_to}
df3c0f2b3da4atagen2026-10-22 13:07 UTC417
      {@const target = event.reply_to.event_id}
df3c0f2b3da4atagen2026-10-22 13:07 UTC418
      <button
df3c0f2b3da4atagen2026-10-22 13:07 UTC419
        type="button"
df3c0f2b3da4atagen2026-10-22 13:07 UTC420
        class="reply-quote"
df3c0f2b3da4atagen2026-10-22 13:07 UTC421
        disabled={!onJump}
df3c0f2b3da4atagen2026-10-22 13:07 UTC422
        title="Jump to the original message"
df3c0f2b3da4atagen2026-10-22 13:07 UTC423
        on:click|stopPropagation={() => onJump?.(target)}
df3c0f2b3da4atagen2026-10-22 13:07 UTC424
      >
973f8fbdaf80atagen2026-09-28 09:10 UTC425
        {#if event.reply_to.details.kind === 'Ready'}
445bf199a9cfatagen2026-10-25 02:56 UTC426
          <span class="reply-sender"><EmojiText text={event.reply_to.details.sender.display_name ?? people[event.reply_to.details.sender.user_id]?.name ?? senderLabel(event.reply_to.details.sender)} /></span>
df3c0f2b3da4atagen2026-10-22 13:07 UTC427
          <span class="reply-text"><EmojiText text={replyPreview(event.reply_to.details.content)} /></span>
973f8fbdaf80atagen2026-09-28 09:10 UTC428
        {:else if event.reply_to.details.kind === 'Pending'}
973f8fbdaf80atagen2026-09-28 09:10 UTC429
          Loading reply…
973f8fbdaf80atagen2026-09-28 09:10 UTC430
        {:else}
973f8fbdaf80atagen2026-09-28 09:10 UTC431
          Reply unavailable
973f8fbdaf80atagen2026-09-28 09:10 UTC432
        {/if}
df3c0f2b3da4atagen2026-10-22 13:07 UTC433
      </button>
973f8fbdaf80atagen2026-09-28 09:10 UTC434
    {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC435
973f8fbdaf80atagen2026-09-28 09:10 UTC436
    {#if event.content.kind === 'Message'}
973f8fbdaf80atagen2026-09-28 09:10 UTC437
      {@const m = event.content.message}
705b1e1062c2atagen2026-10-23 09:05 UTC438
      {#if stripped.text}
445bf199a9cfatagen2026-10-25 02:56 UTC439
        <div class="text" class:emote={m.kind === 'Emote'} class:notice={m.kind === 'Notice' || m.kind === 'ServerNotice'}>{#if m.kind === 'Emote'}* <EmojiText text={displayName} /> {/if}<MessageText text={stripped.text} html={m.formatted_body} jumbo={m.kind === 'Text'} {mentions} {self} nameOf={(id) => people[id]?.name ?? null} />{#if m.edited && !showSender}<span class="edited" title="Edited">(edited)</span>{/if}</div>
df3c0f2b3da4atagen2026-10-22 13:07 UTC440
      {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC441
      {#if m.media}
973f8fbdaf80atagen2026-09-28 09:10 UTC442
        <MediaAttachmentView attachment={m.media} />
973f8fbdaf80atagen2026-09-28 09:10 UTC443
      {/if}
705b1e1062c2atagen2026-10-23 09:05 UTC444
      {#if cards.length > 0}
973f8fbdaf80atagen2026-09-28 09:10 UTC445
        <div class="link-previews">
705b1e1062c2atagen2026-10-23 09:05 UTC446
          {#each cards as card (card.link.href)}
705b1e1062c2atagen2026-10-23 09:05 UTC447
            <LinkCard link={card.link} preview={card.preview} />
973f8fbdaf80atagen2026-09-28 09:10 UTC448
          {/each}
973f8fbdaf80atagen2026-09-28 09:10 UTC449
        </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC450
      {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC451
    {:else if event.content.kind === 'Sticker'}
973f8fbdaf80atagen2026-09-28 09:10 UTC452
      {#if event.content.media}
973f8fbdaf80atagen2026-09-28 09:10 UTC453
        <MediaAttachmentView attachment={event.content.media} />
dfd1feaae855atagen2026-10-24 10:54 UTC454
      {:else if event.content.body}<p class="text"><EmojiText text={event.content.body} /></p>{/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC455
    {:else if event.content.kind === 'Poll'}
445bf199a9cfatagen2026-10-25 02:56 UTC456
      <p class="text"><EmojiText text={`📊 ${event.content.question}`} /></p>
973f8fbdaf80atagen2026-09-28 09:10 UTC457
    {:else}
445bf199a9cfatagen2026-10-25 02:56 UTC458
      <p class="system-line"><EmojiText text={systemLine(event.content, displayName)} /></p>
973f8fbdaf80atagen2026-09-28 09:10 UTC459
    {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC460
973f8fbdaf80atagen2026-09-28 09:10 UTC461
    {#if interactive && event.reactions.length > 0}
973f8fbdaf80atagen2026-09-28 09:10 UTC462
      <div class="reactions" aria-label="Reactions">
973f8fbdaf80atagen2026-09-28 09:10 UTC463
        {#each event.reactions as r (r.key)}
973f8fbdaf80atagen2026-09-28 09:10 UTC464
          <button
973f8fbdaf80atagen2026-09-28 09:10 UTC465
            type="button"
973f8fbdaf80atagen2026-09-28 09:10 UTC466
            class="reaction"
973f8fbdaf80atagen2026-09-28 09:10 UTC467
            class:mine={r.own}
d4c0d65f690aatagen2026-10-24 12:50 UTC468
            aria-label={`${r.shortcode ? `:${r.shortcode}:` : r.key.startsWith('mxc://') ? 'custom emote' : r.key}, ${r.count} reaction${r.count === 1 ? '' : 's'}`}
668ab5c30531atagen2026-10-25 03:13 UTC469
            disabled={readOnly || !event.event_id || reacting}
973f8fbdaf80atagen2026-09-28 09:10 UTC470
            on:click={() => event.event_id && onReact(event.event_id, r.key)}
973f8fbdaf80atagen2026-09-28 09:10 UTC471
          >
ecb8598b38afatagen2026-10-22 09:19 UTC472
            {#if r.image}
ecb8598b38afatagen2026-10-22 09:19 UTC473
              <img class="emote" src={messageMediaUrl(r.image, 'Thumbnail')} alt={r.shortcode ?? ''} title={r.shortcode ?? ''} />
ecb8598b38afatagen2026-10-22 09:19 UTC474
            {:else if r.key.startsWith('mxc://')}
7643577c76bbatagen2026-10-25 07:37 UTC475
              <img class="emote" src={mediaUrl(r.key, 64) ?? ''} alt="" />
544a170ead2catagen2026-10-20 11:47 UTC476
            {:else}
544a170ead2catagen2026-10-20 11:47 UTC477
              <Emoji emoji={r.key} size={16} />
544a170ead2catagen2026-10-20 11:47 UTC478
            {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC479
            <span class="count">{r.count}</span>
cf23dbf4e77catagen2026-10-23 06:36 UTC480
            <span class="reactors" role="tooltip" id={`${itemId}-reactors-${r.key}`}>
2021154f9e16atagen2026-10-25 02:37 UTC481
              <span class="reactors-key"><EmojiText text={r.shortcode ? `:${r.shortcode}:` : r.key.startsWith('mxc://') ? 'custom emote' : r.key} /></span>
2021154f9e16atagen2026-10-25 02:37 UTC482
              <EmojiText text={reactorNames(r.senders)} />
cf23dbf4e77catagen2026-10-23 06:36 UTC483
            </span>
973f8fbdaf80atagen2026-09-28 09:10 UTC484
          </button>
973f8fbdaf80atagen2026-09-28 09:10 UTC485
        {/each}
973f8fbdaf80atagen2026-09-28 09:10 UTC486
      </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC487
    {/if}
7ebc2472a9e3atagen2026-10-25 09:53 UTC488
    {#if threadRoot && threadReplies > 0}
7ebc2472a9e3atagen2026-10-25 09:53 UTC489
      {@const root = threadRoot}
7ebc2472a9e3atagen2026-10-25 09:53 UTC490
      {@const latest = event.thread_summary?.latest_event_timestamp_ms ?? null}
7ebc2472a9e3atagen2026-10-25 09:53 UTC491
      <button type="button" class="thread-chip" on:click|stopPropagation={() => onOpenThread?.(root)}>
7ebc2472a9e3atagen2026-10-25 09:53 UTC492
        <span class="thread-count">{threadReplies} {threadReplies === 1 ? 'reply' : 'replies'}</span>
7ebc2472a9e3atagen2026-10-25 09:53 UTC493
        {#if latest}<time datetime={new Date(latest).toISOString()}>{formatDay(latest)} {formatClock(latest)}</time>{/if}
7ebc2472a9e3atagen2026-10-25 09:53 UTC494
      </button>
7ebc2472a9e3atagen2026-10-25 09:53 UTC495
    {/if}
f604ef6df0c4atagen2026-10-24 10:08 UTC496
    {#if sent}<span class="sent-tick" title="Sent" aria-label="Sent">✓</span>{/if}
df3c0f2b3da4atagen2026-10-22 13:07 UTC497
    {#if interactive && sendLabel(event.send_state)}
973f8fbdaf80atagen2026-09-28 09:10 UTC498
      <div class="msg-foot">
df3c0f2b3da4atagen2026-10-22 13:07 UTC499
        <span class="sendstate" class:failed={event.send_state.kind === 'Failed'}>{sendLabel(event.send_state)}</span>
df3c0f2b3da4atagen2026-10-22 13:07 UTC500
      </div>
df3c0f2b3da4atagen2026-10-22 13:07 UTC501
    {/if}
df3c0f2b3da4atagen2026-10-22 13:07 UTC502
    {#if interactive && readers.length > 0}
df3c0f2b3da4atagen2026-10-22 13:07 UTC503
      {@const seenBy = `Seen by ${readers.map((r) => r.name).join(', ')}`}
df3c0f2b3da4atagen2026-10-22 13:07 UTC504
      <div class="readby" title={seenBy} aria-label={seenBy} role="img">
df3c0f2b3da4atagen2026-10-22 13:07 UTC505
        {#each readers.slice(0, MAX_READERS) as r (r.user_id)}
df3c0f2b3da4atagen2026-10-22 13:07 UTC506
          <MxcAvatar mxc={r.avatar} label={r.name} size={16} />
df3c0f2b3da4atagen2026-10-22 13:07 UTC507
        {/each}
df3c0f2b3da4atagen2026-10-22 13:07 UTC508
        {#if readers.length > MAX_READERS}<span class="more">+{readers.length - MAX_READERS}</span>{/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC509
      </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC510
    {/if}
973f8fbdaf80atagen2026-09-28 09:10 UTC511
  </div>
973f8fbdaf80atagen2026-09-28 09:10 UTC512
</div>
973f8fbdaf80atagen2026-09-28 09:10 UTC513
973f8fbdaf80atagen2026-09-28 09:10 UTC514
<style>
df3c0f2b3da4atagen2026-10-22 13:07 UTC515
  .msg { position: relative; display: flex; gap: 10px; padding: var(--msg-gap, 3px) 0; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC516
  .msg:hover, .msg.selected { background: var(--hover-faint); }
544a170ead2catagen2026-10-20 11:47 UTC517
  .msg:hover .hover-time, .msg.selected .hover-time { opacity: 1; }
544a170ead2catagen2026-10-20 11:47 UTC518
  .msg-foot { display: flex; align-items: center; gap: 8px; }
7ebc2472a9e3atagen2026-10-25 09:53 UTC519
  .thread-chip { display: inline-flex; align-items: baseline; gap: 8px; margin-top: 4px; padding: 3px 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-soft); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; transition: border-color var(--pop), background var(--pop); }
7ebc2472a9e3atagen2026-10-25 09:53 UTC520
  .thread-chip:hover { border-color: var(--accent); background: var(--hover-faint); }
7ebc2472a9e3atagen2026-10-25 09:53 UTC521
  .thread-count { color: var(--accent); font-weight: 650; }
7ebc2472a9e3atagen2026-10-25 09:53 UTC522
  .thread-chip time { color: var(--muted); font-size: 11px; }
973f8fbdaf80atagen2026-09-28 09:10 UTC523
  .sendstate { font-size: 11px; color: var(--muted); }
f604ef6df0c4atagen2026-10-24 10:08 UTC524
  .sent-tick { position: absolute; right: 12px; bottom: 4px; font-size: 11px; color: var(--muted); }
973f8fbdaf80atagen2026-09-28 09:10 UTC525
  .sendstate.failed { color: var(--danger); }
973f8fbdaf80atagen2026-09-28 09:10 UTC526
  .link-previews { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; }
973f8fbdaf80atagen2026-09-28 09:10 UTC527
  .avatar {
973f8fbdaf80atagen2026-09-28 09:10 UTC528
    flex: none;
973f8fbdaf80atagen2026-09-28 09:10 UTC529
    width: 34px; height: 34px;
973f8fbdaf80atagen2026-09-28 09:10 UTC530
    border-radius: 50%;
973f8fbdaf80atagen2026-09-28 09:10 UTC531
    display: grid; place-items: center;
973f8fbdaf80atagen2026-09-28 09:10 UTC532
    font-size: 12px; font-weight: 700; color: #fff;
973f8fbdaf80atagen2026-09-28 09:10 UTC533
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC534
  .avatar-spacer { flex: none; width: 34px; padding-top: 2px; text-align: center; }
973f8fbdaf80atagen2026-09-28 09:10 UTC535
  .hover-time { opacity: 0; font-size: 10.5px; color: var(--muted); }
973f8fbdaf80atagen2026-09-28 09:10 UTC536
  .msg-body { min-width: 0; flex: 1; }
973f8fbdaf80atagen2026-09-28 09:10 UTC537
  .msg-head { display: flex; align-items: baseline; gap: 8px; }
d2a34d0f4861atagen2026-10-25 07:29 UTC538
  .federation-lag { display: inline-flex; align-items: center; gap: 3px; color: var(--danger); font-size: 11px; font-weight: 650; }
d2a34d0f4861atagen2026-10-25 07:29 UTC539
  .federation-lag > span:last-child { display: inline-grid; place-items: center; min-width: 24px; height: 18px; padding: 0 4px; border: 1px solid currentColor; border-radius: 999px; }
d8624c214c04atagen2026-10-24 08:24 UTC540
  .sender { font-weight: 650; font-size: 13.5px; padding: 0; border: none; background: none; font-family: inherit; cursor: pointer; }
d8624c214c04atagen2026-10-24 08:24 UTC541
  .sender:hover { text-decoration: underline; }
d8624c214c04atagen2026-10-24 08:24 UTC542
  .user-hit { flex: none; align-self: flex-start; padding: 0; border: none; background: none; border-radius: 50%; cursor: pointer; }
973f8fbdaf80atagen2026-09-28 09:10 UTC543
  .time, .edited { color: var(--muted); font-size: 11.5px; }
cf23dbf4e77catagen2026-10-23 06:36 UTC544
  .text .edited { margin-left: 6px; }
cf23dbf4e77catagen2026-10-23 06:36 UTC545
  .msg.editing { background: color-mix(in srgb, var(--accent) 10%, transparent); }
705b1e1062c2atagen2026-10-23 09:05 UTC546
  .msg.mentioned { background: color-mix(in srgb, var(--warn) 8%, transparent); box-shadow: inset 2px 0 0 var(--warn); }
973f8fbdaf80atagen2026-09-28 09:10 UTC547
  .reply-quote {
df3c0f2b3da4atagen2026-10-22 13:07 UTC548
    display: flex; gap: 6px; align-items: baseline;
df3c0f2b3da4atagen2026-10-22 13:07 UTC549
    max-width: min(100%, 520px);
df3c0f2b3da4atagen2026-10-22 13:07 UTC550
    border: none;
973f8fbdaf80atagen2026-09-28 09:10 UTC551
    border-left: 2px solid var(--accent);
973f8fbdaf80atagen2026-09-28 09:10 UTC552
    padding: 2px 8px;
973f8fbdaf80atagen2026-09-28 09:10 UTC553
    margin: 2px 0 4px;
973f8fbdaf80atagen2026-09-28 09:10 UTC554
    color: var(--muted);
973f8fbdaf80atagen2026-09-28 09:10 UTC555
    font-size: 12.5px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC556
    text-align: left;
973f8fbdaf80atagen2026-09-28 09:10 UTC557
    background: var(--bg-soft);
05a48e9e7942atagen2026-10-24 09:32 UTC558
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
df3c0f2b3da4atagen2026-10-22 13:07 UTC559
    cursor: pointer;
973f8fbdaf80atagen2026-09-28 09:10 UTC560
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC561
  .reply-quote:disabled { cursor: default; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC562
  .reply-quote:hover:not(:disabled) { color: var(--text); }
df3c0f2b3da4atagen2026-10-22 13:07 UTC563
  .reply-sender { flex: none; font-weight: 650; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC564
  .reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC565
  :global(.msg.flash) { animation: reply-flash 1.2s ease-out; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC566
  @keyframes -global-reply-flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } }
973f8fbdaf80atagen2026-09-28 09:10 UTC567
  .text {
973f8fbdaf80atagen2026-09-28 09:10 UTC568
    margin: 1px 0 2px;
973f8fbdaf80atagen2026-09-28 09:10 UTC569
    font-size: 14px;
df3c0f2b3da4atagen2026-10-22 13:07 UTC570
    line-height: var(--msg-line-height, 1.5);
973f8fbdaf80atagen2026-09-28 09:10 UTC571
    white-space: pre-wrap;
973f8fbdaf80atagen2026-09-28 09:10 UTC572
    overflow-wrap: anywhere;
973f8fbdaf80atagen2026-09-28 09:10 UTC573
  }
973f8fbdaf80atagen2026-09-28 09:10 UTC574
  .text.emote { font-style: italic; color: var(--muted); }
973f8fbdaf80atagen2026-09-28 09:10 UTC575
  .text.notice { color: var(--muted); }
973f8fbdaf80atagen2026-09-28 09:10 UTC576
  .system-line { color: var(--muted); font-size: 12.5px; font-style: italic; margin: 1px 0; }
f604ef6df0c4atagen2026-10-24 10:08 UTC577
  .msg.system { opacity: 0.85; --msg-gap: 1.5px; }
f604ef6df0c4atagen2026-10-24 10:08 UTC578
  .msg.system .avatar-spacer { height: 0; padding-top: 0; }
dfd1feaae855atagen2026-10-24 10:54 UTC579
  .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: max(4px, var(--msg-gap, 3px)); }
973f8fbdaf80atagen2026-09-28 09:10 UTC580
  .reaction {
973f8fbdaf80atagen2026-09-28 09:10 UTC581
    display: inline-flex; align-items: center; gap: 4px;
973f8fbdaf80atagen2026-09-28 09:10 UTC582
    background: var(--bg-soft);
973f8fbdaf80atagen2026-09-28 09:10 UTC583
    border: 1px solid var(--border);
05a48e9e7942atagen2026-10-24 09:32 UTC584
    border-radius: var(--r-sm);
973f8fbdaf80atagen2026-09-28 09:10 UTC585
    padding: 1px 8px;
973f8fbdaf80atagen2026-09-28 09:10 UTC586
    font-size: 13px;
973f8fbdaf80atagen2026-09-28 09:10 UTC587
    color: var(--text);
973f8fbdaf80atagen2026-09-28 09:10 UTC588
    cursor: pointer;
973f8fbdaf80atagen2026-09-28 09:10 UTC589
  }
cf23dbf4e77catagen2026-10-23 06:36 UTC590
  .reaction { position: relative; }
cf23dbf4e77catagen2026-10-23 06:36 UTC591
  .reactors {
cf23dbf4e77catagen2026-10-23 06:36 UTC592
    position: absolute;
cf23dbf4e77catagen2026-10-23 06:36 UTC593
    left: 0;
cf23dbf4e77catagen2026-10-23 06:36 UTC594
    bottom: calc(100% + 6px);
cf23dbf4e77catagen2026-10-23 06:36 UTC595
    z-index: 15;
cf23dbf4e77catagen2026-10-23 06:36 UTC596
    display: none;
cf23dbf4e77catagen2026-10-23 06:36 UTC597
    width: max-content;
cf23dbf4e77catagen2026-10-23 06:36 UTC598
    max-width: 260px;
cf23dbf4e77catagen2026-10-23 06:36 UTC599
    padding: 6px 9px;
cf23dbf4e77catagen2026-10-23 06:36 UTC600
    border: 1px solid var(--border);
05a48e9e7942atagen2026-10-24 09:32 UTC601
    border-radius: var(--r-md);
cf23dbf4e77catagen2026-10-23 06:36 UTC602
    background: var(--panel-2);
cf23dbf4e77catagen2026-10-23 06:36 UTC603
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
cf23dbf4e77catagen2026-10-23 06:36 UTC604
    color: var(--text);
cf23dbf4e77catagen2026-10-23 06:36 UTC605
    font-size: 12px;
cf23dbf4e77catagen2026-10-23 06:36 UTC606
    line-height: 1.35;
cf23dbf4e77catagen2026-10-23 06:36 UTC607
    text-align: left;
cf23dbf4e77catagen2026-10-23 06:36 UTC608
    white-space: normal;
cf23dbf4e77catagen2026-10-23 06:36 UTC609
    pointer-events: none;
cf23dbf4e77catagen2026-10-23 06:36 UTC610
  }
cf23dbf4e77catagen2026-10-23 06:36 UTC611
  .reactors-key { display: block; color: var(--muted); font-size: 11px; }
cf23dbf4e77catagen2026-10-23 06:36 UTC612
  .reaction:hover .reactors, .reaction:focus-visible .reactors { display: block; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC613
  .reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
973f8fbdaf80atagen2026-09-28 09:10 UTC614
  .reaction:disabled { cursor: default; opacity: 0.85; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC615
  .msg.has-readers .msg-body { padding-right: 72px; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC616
  .readby { position: absolute; right: 12px; bottom: 4px; display: flex; align-items: center; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC617
  .readby > :global(* + *) { margin-left: -4px; }
df3c0f2b3da4atagen2026-10-22 13:07 UTC618
  .readby :global(.mxc-avatar), .readby :global(.mxc-fallback) { box-shadow: 0 0 0 1.5px var(--bg); }
df3c0f2b3da4atagen2026-10-22 13:07 UTC619
  .readby .more { margin-left: 3px; font-size: 10.5px; color: var(--muted); }
544a170ead2catagen2026-10-20 11:47 UTC620
  .actions {
05a48e9e7942atagen2026-10-24 09:32 UTC621
    position: absolute; top: -12px; right: 10px; z-index: 2;
544a170ead2catagen2026-10-20 11:47 UTC622
    display: flex; gap: 2px;
544a170ead2catagen2026-10-20 11:47 UTC623
    padding: 2px;
544a170ead2catagen2026-10-20 11:47 UTC624
    background: var(--bg-soft);
544a170ead2catagen2026-10-20 11:47 UTC625
    border: 1px solid var(--border);
05a48e9e7942atagen2026-10-24 09:32 UTC626
    border-radius: var(--r-md);
544a170ead2catagen2026-10-20 11:47 UTC627
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
544a170ead2catagen2026-10-20 11:47 UTC628
    opacity: 0;
d4c0d65f690aatagen2026-10-24 12:50 UTC629
    visibility: hidden;
544a170ead2catagen2026-10-20 11:47 UTC630
    pointer-events: none;
544a170ead2catagen2026-10-20 11:47 UTC631
  }
d4c0d65f690aatagen2026-10-24 12:50 UTC632
  .msg:hover .actions, .msg:focus-within .actions, .msg.selected .actions { opacity: 1; visibility: visible; pointer-events: auto; }
d4c0d65f690aatagen2026-10-24 12:50 UTC633
  :global(.timeline-inner:has(.msg.selected)) .msg:not(.selected) .actions { opacity: 0; visibility: hidden; pointer-events: none; }
544a170ead2catagen2026-10-20 11:47 UTC634
  .actions button {
973f8fbdaf80atagen2026-09-28 09:10 UTC635
    background: transparent;
973f8fbdaf80atagen2026-09-28 09:10 UTC636
    border: 1px solid transparent;
05a48e9e7942atagen2026-10-24 09:32 UTC637
    border-radius: var(--r-sm);
973f8fbdaf80atagen2026-09-28 09:10 UTC638
    cursor: pointer;
544a170ead2catagen2026-10-20 11:47 UTC639
    font-size: 14px;
544a170ead2catagen2026-10-20 11:47 UTC640
    padding: 1px 5px;
973f8fbdaf80atagen2026-09-28 09:10 UTC641
  }
df3c0f2b3da4atagen2026-10-22 13:07 UTC642
  .actions button:hover:not(:disabled) { border-color: var(--border); background: var(--hover); }
544a170ead2catagen2026-10-20 11:47 UTC643
  .actions button:disabled { opacity: 0.4; cursor: default; }
544a170ead2catagen2026-10-20 11:47 UTC644
  .emote { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: middle; }
05a48e9e7942atagen2026-10-24 09:32 UTC645
  .picker-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); animation: pop-in var(--pop); }
973f8fbdaf80atagen2026-09-28 09:10 UTC646
</style>