@crvouga/mockingbird-notifications 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3HF2NSFV.js → chunk-4BPQC52H.js} +68 -1
- package/dist/chunk-4BPQC52H.js.map +7 -0
- package/dist/{chunk-FBJ2DRHH.js → chunk-OR6VYHWA.js} +3 -1
- package/dist/chunk-OR6VYHWA.js.map +7 -0
- package/dist/{chunk-SNOESDNW.js → chunk-TN2LRJAM.js} +2 -2
- package/dist/chunk-ZRI5NLWC.js +1177 -0
- package/dist/chunk-ZRI5NLWC.js.map +7 -0
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/server.js +3 -3
- package/dist/{types-C4yF6DQp.d.ts → types-B--Ql-Jg.d.ts} +4 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +25 -10
- package/dist/ui.js.map +2 -2
- package/package.json +1 -1
- package/dist/chunk-3HF2NSFV.js.map +0 -7
- package/dist/chunk-FBJ2DRHH.js.map +0 -7
- package/dist/chunk-GHIEYY5B.js +0 -1177
- package/dist/chunk-GHIEYY5B.js.map +0 -7
- /package/dist/{chunk-SNOESDNW.js.map → chunk-TN2LRJAM.js.map} +0 -0
package/dist/chunk-GHIEYY5B.js
DELETED
|
@@ -1,1177 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DASHBOARD_PAGE_STYLES,
|
|
3
|
-
DASHBOARD_STYLES,
|
|
4
|
-
PAGE_STYLES,
|
|
5
|
-
SERVICE_KINDS,
|
|
6
|
-
STYLES,
|
|
7
|
-
filterFromSearch,
|
|
8
|
-
matches
|
|
9
|
-
} from "./chunk-3HF2NSFV.js";
|
|
10
|
-
|
|
11
|
-
// src/mime.ts
|
|
12
|
-
var utf8 = new TextDecoder();
|
|
13
|
-
var base64Bytes = (value) => {
|
|
14
|
-
const binary = atob(value.replace(/[^A-Za-z0-9+/=]/g, ""));
|
|
15
|
-
const bytes = new Uint8Array(binary.length);
|
|
16
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
17
|
-
return bytes;
|
|
18
|
-
};
|
|
19
|
-
var quotedPrintableBytes = (value, underscoreSpace = false) => {
|
|
20
|
-
const source = value.replace(/=\r?\n/g, "");
|
|
21
|
-
const out = [];
|
|
22
|
-
for (let i = 0; i < source.length; i++) {
|
|
23
|
-
const ch = source[i] ?? "";
|
|
24
|
-
const hex = source.slice(i + 1, i + 3);
|
|
25
|
-
if (ch === "=" && /^[0-9A-Fa-f]{2}$/.test(hex)) {
|
|
26
|
-
out.push(Number.parseInt(hex, 16));
|
|
27
|
-
i += 2;
|
|
28
|
-
} else if (underscoreSpace && ch === "_") out.push(32);
|
|
29
|
-
else for (const byte of new TextEncoder().encode(ch)) out.push(byte);
|
|
30
|
-
}
|
|
31
|
-
return new Uint8Array(out);
|
|
32
|
-
};
|
|
33
|
-
var decodeWords = (value) => value.replace(/\?=\s+=\?/g, "?==?").replace(
|
|
34
|
-
/=\?([^?]+)\?([BbQq])\?([^?]*)\?=/g,
|
|
35
|
-
(_, _charset, kind, text) => utf8.decode(
|
|
36
|
-
kind.toUpperCase() === "B" ? base64Bytes(text) : quotedPrintableBytes(text, true)
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
var splitHead = (raw) => {
|
|
40
|
-
const normalized = raw.replace(/\r\n/g, "\n");
|
|
41
|
-
const end = normalized.indexOf("\n\n");
|
|
42
|
-
const head = end < 0 ? normalized : normalized.slice(0, end);
|
|
43
|
-
const body = end < 0 ? "" : normalized.slice(end + 2);
|
|
44
|
-
const headers = {};
|
|
45
|
-
for (const line of head.replace(/\n[ \t]+/g, " ").split("\n")) {
|
|
46
|
-
const colon = line.indexOf(":");
|
|
47
|
-
if (colon <= 0) continue;
|
|
48
|
-
const name = line.slice(0, colon).trim().toLowerCase();
|
|
49
|
-
const value = decodeWords(line.slice(colon + 1).trim());
|
|
50
|
-
headers[name] = headers[name] ? `${headers[name]}, ${value}` : value;
|
|
51
|
-
}
|
|
52
|
-
return { headers, body };
|
|
53
|
-
};
|
|
54
|
-
var param = (header, name) => {
|
|
55
|
-
if (!header) return null;
|
|
56
|
-
const match = new RegExp(`${name}\\*?=(?:"([^"]*)"|([^;\\s]+))`, "i").exec(header);
|
|
57
|
-
return match ? match[1] ?? match[2] ?? null : null;
|
|
58
|
-
};
|
|
59
|
-
var decodeBody = (part) => {
|
|
60
|
-
const encoding = (part.headers["content-transfer-encoding"] ?? "").toLowerCase();
|
|
61
|
-
if (encoding === "base64") return base64Bytes(part.body);
|
|
62
|
-
if (encoding === "quoted-printable") return quotedPrintableBytes(part.body);
|
|
63
|
-
return new TextEncoder().encode(part.body);
|
|
64
|
-
};
|
|
65
|
-
var walk = (part, out) => {
|
|
66
|
-
const type = (part.headers["content-type"] ?? "text/plain").toLowerCase();
|
|
67
|
-
const boundary = param(part.headers["content-type"], "boundary");
|
|
68
|
-
if (type.startsWith("multipart/") && boundary) {
|
|
69
|
-
const sections = part.body.split(`--${boundary}`);
|
|
70
|
-
for (const section of sections.slice(1)) {
|
|
71
|
-
if (section.startsWith("--")) break;
|
|
72
|
-
walk(splitHead(section.replace(/^\n/, "")), out);
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const disposition = part.headers["content-disposition"] ?? "";
|
|
77
|
-
const filename = param(disposition, "filename") ?? param(part.headers["content-type"], "name");
|
|
78
|
-
if (/^attachment/i.test(disposition) || filename && !type.startsWith("text/")) {
|
|
79
|
-
out.attachments.push({
|
|
80
|
-
filename: filename ?? "attachment",
|
|
81
|
-
contentType: type.split(";")[0]?.trim() ?? null,
|
|
82
|
-
size: decodeBody(part).byteLength
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const text = utf8.decode(decodeBody(part)).replace(/\n$/, "");
|
|
87
|
-
if (type.startsWith("text/html") && out.html === null) out.html = text;
|
|
88
|
-
else if (type.startsWith("text/plain") && out.text === null) out.text = text;
|
|
89
|
-
};
|
|
90
|
-
var addressList = (value) => (value ?? "").split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).map((item) => item.trim()).filter(Boolean);
|
|
91
|
-
var parseMime = (raw) => {
|
|
92
|
-
const root = splitHead(raw);
|
|
93
|
-
const out = {
|
|
94
|
-
headers: root.headers,
|
|
95
|
-
subject: root.headers.subject ?? "",
|
|
96
|
-
from: root.headers.from ?? null,
|
|
97
|
-
to: addressList(root.headers.to),
|
|
98
|
-
cc: addressList(root.headers.cc),
|
|
99
|
-
html: null,
|
|
100
|
-
text: null,
|
|
101
|
-
attachments: []
|
|
102
|
-
};
|
|
103
|
-
walk(root, out);
|
|
104
|
-
return out;
|
|
105
|
-
};
|
|
106
|
-
var decodeRawMessage = (data) => {
|
|
107
|
-
const compact = data.replace(/\s+/g, "");
|
|
108
|
-
if (/^[A-Za-z0-9+/]+=*$/.test(compact) && compact.length % 4 === 0) {
|
|
109
|
-
const decoded = utf8.decode(base64Bytes(compact));
|
|
110
|
-
if (/^[\x20-\x7e]+:/m.test(decoded)) return decoded;
|
|
111
|
-
}
|
|
112
|
-
return data;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// src/discovery.ts
|
|
116
|
-
var asServiceKind = (value) => typeof value === "string" && SERVICE_KINDS.includes(value) ? value : null;
|
|
117
|
-
var trimSlash = (url) => url.replace(/\/+$/, "");
|
|
118
|
-
var endpointsFromServices = (services, fetchImpl) => Object.entries(services).map(([name, input]) => {
|
|
119
|
-
if (typeof input === "string")
|
|
120
|
-
return {
|
|
121
|
-
name,
|
|
122
|
-
service: asServiceKind(name),
|
|
123
|
-
adminUrl: `${trimSlash(input)}/__admin`,
|
|
124
|
-
fetch: fetchImpl
|
|
125
|
-
};
|
|
126
|
-
if ("fetch" in input)
|
|
127
|
-
return {
|
|
128
|
-
name,
|
|
129
|
-
service: input.service ?? asServiceKind(name),
|
|
130
|
-
adminUrl: `http://${name}.mockingbird.local${input.adminPrefix ?? "/__admin"}`,
|
|
131
|
-
fetch: input.fetch
|
|
132
|
-
};
|
|
133
|
-
return {
|
|
134
|
-
name,
|
|
135
|
-
service: input.service ?? asServiceKind(name),
|
|
136
|
-
adminUrl: input.adminUrl ? trimSlash(input.adminUrl) : `${trimSlash(input.url)}/__admin`,
|
|
137
|
-
fetch: fetchImpl
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
var endpointsFromManifest = (manifest, fetchImpl, targets = {}) => Object.entries(manifest.services ?? {}).flatMap(([name, entry]) => {
|
|
141
|
-
if (!entry || entry.protocol && entry.protocol !== "http" || !entry.url) return [];
|
|
142
|
-
const service = asServiceKind(targets[name] ?? entry.target ?? name);
|
|
143
|
-
if (!service && (targets[name] ?? entry.target)) return [];
|
|
144
|
-
return [
|
|
145
|
-
{
|
|
146
|
-
name,
|
|
147
|
-
service,
|
|
148
|
-
adminUrl: entry.adminUrl ? trimSlash(entry.adminUrl) : `${trimSlash(entry.url)}/__admin`,
|
|
149
|
-
fetch: fetchImpl
|
|
150
|
-
}
|
|
151
|
-
];
|
|
152
|
-
});
|
|
153
|
-
var adminTargetsFromServices = (services, fetchImpl) => endpointsFromServices(services, fetchImpl).map((endpoint) => ({
|
|
154
|
-
name: endpoint.name,
|
|
155
|
-
target: endpoint.service ?? endpoint.name,
|
|
156
|
-
adminUrl: endpoint.adminUrl,
|
|
157
|
-
fetch: endpoint.fetch
|
|
158
|
-
}));
|
|
159
|
-
var adminTargetsFromManifest = (manifest, fetchImpl, targets = {}) => Object.entries(manifest.services ?? {}).flatMap(([name, entry]) => {
|
|
160
|
-
if (!entry || entry.protocol && entry.protocol !== "http" || !entry.url) return [];
|
|
161
|
-
return [
|
|
162
|
-
{
|
|
163
|
-
name,
|
|
164
|
-
target: targets[name] ?? entry.target ?? name,
|
|
165
|
-
adminUrl: entry.adminUrl ? trimSlash(entry.adminUrl) : `${trimSlash(entry.url)}/__admin`,
|
|
166
|
-
fetch: fetchImpl
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
});
|
|
170
|
-
var discoverFleet = async (adminBase, fetchImpl, headers) => {
|
|
171
|
-
const base2 = trimSlash(adminBase);
|
|
172
|
-
const get = async (path) => {
|
|
173
|
-
const response = await fetchImpl(new Request(`${base2}${path}`, { headers }));
|
|
174
|
-
if (!response.ok) throw new Error(`fleet ${base2}${path}: HTTP ${response.status}`);
|
|
175
|
-
return await response.json();
|
|
176
|
-
};
|
|
177
|
-
const [root, namespaces] = await Promise.all([
|
|
178
|
-
get(""),
|
|
179
|
-
get("/namespaces").catch(() => ({}))
|
|
180
|
-
]);
|
|
181
|
-
const manifest = root.manifest;
|
|
182
|
-
if (!manifest?.services) throw new Error(`fleet ${base2}: discovery has no manifest`);
|
|
183
|
-
const described = root.services ?? {};
|
|
184
|
-
const targets = Object.fromEntries(
|
|
185
|
-
Object.entries(described).map(([name, entry]) => [name, entry?.target])
|
|
186
|
-
);
|
|
187
|
-
const names = Array.isArray(namespaces.namespaces) ? namespaces.namespaces.map((n) => n.namespace).filter((n) => typeof n === "string") : [];
|
|
188
|
-
return {
|
|
189
|
-
endpoints: endpointsFromManifest(manifest, fetchImpl, targets),
|
|
190
|
-
admins: adminTargetsFromManifest(manifest, fetchImpl, targets),
|
|
191
|
-
namespaces: names
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// src/generated/browser.ts
|
|
196
|
-
var BROWSER_JS = 'var le=["sms","push","email","chat"];var l={app:"notifications-app",topbar:"topbar",namespace:"namespace",search:"search",viewDevices:"view-devices",viewTimeline:"view-timeline",follow:"follow",sound:"sound-toggle",connection:"connection",source:"source",notice:"notice",toast:"toast",toastUndo:"toast-undo",channelTabs:"channel-tabs",channelTab:"channel-tab",channelTabUnread:"channel-tab-unread",smsDevice:"sms-device",smsRecipient:"sms-recipient",smsUnreadCount:"sms-unread-count",smsThread:"sms-thread",smsThreadName:"sms-thread-name",smsThreadPreview:"sms-thread-preview",smsThreadTime:"sms-thread-time",smsThreadUnread:"sms-thread-unread",smsThreadVia:"sms-thread-via",smsThreadDelete:"sms-thread-delete",smsThreadMute:"sms-thread-mute",smsThreadPin:"sms-thread-pin",smsThreadToggleUnread:"sms-thread-toggle-unread",smsEmpty:"sms-empty",smsConversation:"sms-conversation",smsConversationTitle:"sms-conversation-title",smsBack:"sms-back",smsBubble:"sms-bubble",smsBubbleMedia:"sms-bubble-media",smsBubbleTime:"sms-bubble-time",smsTapback:"sms-tapback",smsTimestamp:"sms-timestamp",smsCode:"sms-code",smsMenu:"sms-menu",smsMenuCopy:"sms-menu-copy",smsMenuTapback:"sms-menu-tapback",pushDevice:"push-device",pushRecipient:"push-recipient",pushSkin:"push-skin",pushUnreadCount:"push-unread-count",pushNotification:"push-notification",pushNotificationApp:"push-notification-app",pushNotificationTitle:"push-notification-title",pushNotificationBody:"push-notification-body",pushNotificationTime:"push-notification-time",pushNotificationImage:"push-notification-image",pushNotificationData:"push-notification-data",pushNotificationMeta:"push-notification-meta",pushGroup:"push-group",pushGroupMore:"push-group-more",pushGroupCollapse:"push-group-collapse",pushClear:"push-clear",pushOptions:"push-options",pushPreview:"push-preview",pushSettings:"push-settings",pushClearAll:"push-clear-all",pushEmpty:"push-empty",emailDevice:"email-device",emailRecipient:"email-recipient",emailUnreadCount:"email-unread-count",emailRow:"email-row",emailRowFrom:"email-row-from",emailRowSubject:"email-row-subject",emailRowSnippet:"email-row-snippet",emailRowDate:"email-row-date",emailRowService:"email-row-service",emailRowAttachment:"email-row-attachment",emailRowStar:"email-row-star",emailRowArchive:"email-row-archive",emailRowDelete:"email-row-delete",emailRowToggleRead:"email-row-toggle-read",emailRefresh:"email-refresh",emailEmpty:"email-empty",emailOpen:"email-open",emailBack:"email-back",emailArchive:"email-archive",emailDelete:"email-delete",emailMarkUnread:"email-mark-unread",emailSubject:"email-subject",emailFromName:"email-from-name",emailFromAddress:"email-from-address",emailTo:"email-to",emailDate:"email-date",emailDetails:"email-details",emailDetail:"email-detail",emailBody:"email-body",emailText:"email-text",emailAttachments:"email-attachments",emailAttachment:"email-attachment",chatDevice:"chat-device",chatRecipient:"chat-recipient",chatUnreadCount:"chat-unread-count",chatWorkspace:"chat-workspace",chatChannel:"chat-channel",chatTitle:"chat-title",chatMessage:"chat-message",chatMessageAuthor:"chat-message-author",chatMessageTime:"chat-message-time",chatMessageText:"chat-message-text",chatMessageBlocks:"chat-message-blocks",chatMessageAttachments:"chat-message-attachments",chatMessageReaction:"chat-message-reaction",chatEmpty:"chat-empty",timeline:"timeline",timelineRow:"timeline-row",timelineEmpty:"timeline-empty",inspector:"inspector",inspectorTitle:"inspector-title",inspectorClose:"inspector-close",inspectorShowOnDevice:"inspector-show-on-device",inspectorField:"inspector-field",inspectorJson:"inspector-json",dashboard:"dashboard",dashboardTab:"dashboard-tab",dashboardPanel:"dashboard-panel",dashboardBadge:"dashboard-badge"};var Mt=a=>typeof a=="object"&&a!==null&&!Array.isArray(a),va=a=>Mt(a)?a:{},de=a=>Array.isArray(a)?a.filter(Mt):[],R=a=>typeof a=="string"?a:"",P=a=>String(a??"").replace(/[&<>"\']/g,o=>`&#${o.charCodeAt(0)};`),tt=a=>/^(https?:\\/\\/|mailto:)/i.test(a.trim())?a.trim():null,dn={"+1":"\\u{1F44D}",thumbsup:"\\u{1F44D}","-1":"\\u{1F44E}",thumbsdown:"\\u{1F44E}",tada:"\\u{1F389}",rocket:"\\u{1F680}",white_check_mark:"\\u2705",heavy_check_mark:"\\u2714\\uFE0F",x:"\\u274C",warning:"\\u26A0\\uFE0F",rotating_light:"\\u{1F6A8}",fire:"\\u{1F525}",eyes:"\\u{1F440}",heart:"\\u2764\\uFE0F",wave:"\\u{1F44B}",bell:"\\u{1F514}",calendar:"\\u{1F4C5}",package:"\\u{1F4E6}",bug:"\\u{1F41B}",hourglass:"\\u231B",moneybag:"\\u{1F4B0}",email:"\\u2709\\uFE0F",red_circle:"\\u{1F534}",large_green_circle:"\\u{1F7E2}",large_yellow_circle:"\\u{1F7E1}",sparkles:"\\u2728",memo:"\\u{1F4DD}",lock:"\\u{1F512}",information_source:"\\u2139\\uFE0F",pray:"\\u{1F64F}"},Ie=a=>dn[a.toLowerCase()]??`:${a}:`,ke=(a,o={})=>{let d=[],h=y=>`\\0${d.push(y)-1}\\0`,g=y=>y.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),v=y=>y.replace(/&#(\\d+);/g,(E,D)=>String.fromCharCode(Number(D))),$=P(a).replace(/```\\n?([\\s\\S]*?)```/g,(y,E)=>h(`<pre class="chat-pre">${g(E)}</pre>`)).replace(/`([^`\\n]+)`/g,(y,E)=>h(`<code class="chat-code">${g(E)}</code>`)).replace(/<(.+?)>/g,(y,E)=>{let[D="",W]=E.split("|");if(D.startsWith("@")||D.startsWith("#")){let O=D.slice(1),V=W||o.name?.(v(O))||O;return h(`<span class="chat-mention">${D[0]}${P(v(V))}</span>`)}if(D.startsWith("!")){let O=D.slice(1).split("^")[0]??"";return h(`<span class="chat-mention">${W||`@${O}`}</span>`)}let F=tt(v(D));return F?h(`<a href="${P(F)}" target="_blank" rel="noreferrer">${W||D}</a>`):y});$=g($).replace(/(^|[\\s(])\\*([^*\\n]+)\\*(?=$|[\\s.,;:!?)])/gm,"$1<b>$2</b>").replace(/(^|[\\s(])_([^_\\n]+)_(?=$|[\\s.,;:!?)])/gm,"$1<i>$2</i>").replace(/(^|[\\s(])~([^~\\n]+)~(?=$|[\\s.,;:!?)])/gm,"$1<s>$2</s>").replace(/:([a-z0-9_+-]+):/gi,(y,E)=>Ie(E)).replace(/(?:^> ?.*(?:\\n|$))+/gm,y=>`<blockquote class="chat-quote">${y.replace(/\\n$/,"").replace(/^> ?/gm,"")}</blockquote>`);let H=/\\u0000(\\d+)\\u0000/g;for(let y=0;y<3&&$.includes("\\0");y++)$=$.replace(H,(E,D)=>d[Number(D)]??"");return $},ze=(a,o)=>{if(typeof a=="string")return ke(a,o);let d=va(a),h=R(d.text);return h?d.type==="plain_text"?P(h).replace(/:([a-z0-9_+-]+):/gi,(g,v)=>Ie(v)):ke(h,o):""},At=(a,o,d)=>{let h=tt(a);return h?`<img class="${d}" src="${P(h)}" alt="${P(o)}" loading="lazy">`:""},wa=(a,o)=>`<span class="chat-btn ${a.style==="primary"||a.style==="danger"?a.style:""}" data-block-element="${P(R(a.type))}">${ze(a.text??a.placeholder,o)||P(R(a.type))}</span>`,ga=(a,o)=>a.type==="image"?At(R(a.image_url),R(a.alt_text),"chat-thumb"):a.type==="mrkdwn"||a.type==="plain_text"?`<span>${ze(a,o)}</span>`:wa(a,o),xa=(a,o)=>{let d=va(a.style),h;if(a.type==="link"){let g=tt(R(a.url)),v=P(R(a.text)||R(a.url));h=g?`<a href="${P(g)}" target="_blank" rel="noreferrer">${v}</a>`:v}else a.type==="emoji"?h=P(Ie(R(a.name))):a.type==="user"||a.type==="usergroup"?h=`<span class="chat-mention">@${P(o.name?.(R(a.user_id))??R(a.user_id??a.usergroup_id))}</span>`:a.type==="channel"?h=`<span class="chat-mention">#${P(o.name?.(R(a.channel_id))??R(a.channel_id))}</span>`:a.type==="broadcast"?h=`<span class="chat-mention">@${P(R(a.range))}</span>`:h=P(R(a.text));return d.code&&(h=`<code class="chat-code">${h}</code>`),d.bold&&(h=`<b>${h}</b>`),d.italic&&(h=`<i>${h}</i>`),d.strike&&(h=`<s>${h}</s>`),h},cn=(a,o)=>de(a.elements).map(d=>{let h=de(d.elements);if(d.type==="rich_text_list")return`<${d.style==="ordered"?"ol":"ul"} class="chat-list-block">${h.map(v=>`<li>${de(v.elements).map($=>xa($,o)).join("")}</li>`).join("")}</${d.style==="ordered"?"ol":"ul"}>`;let g=h.map(v=>xa(v,o)).join("");return d.type==="rich_text_preformatted"?`<pre class="chat-pre">${g}</pre>`:d.type==="rich_text_quote"?`<blockquote class="chat-quote">${g}</blockquote>`:`<div class="chat-text">${g}</div>`}).join(""),pn=(a,o)=>{let d=R(a.type),h=(g,v="")=>`<div class="chat-block chat-block-${P(d)} ${v}" data-block="${P(d)}">${g}</div>`;switch(d){case"section":{let g=de(a.fields),v=Mt(a.accessory)?ga(a.accessory,o):"";return h(`<div class="chat-section-body">${a.text?`<div class="chat-text">${ze(a.text,o)}</div>`:""}${g.length?`<div class="chat-fields">${g.map($=>`<div class="chat-text">${ze($,o)}</div>`).join("")}</div>`:""}</div>${v?`<div class="chat-accessory">${v}</div>`:""}`,v?"with-accessory":"")}case"header":return h(ze(a.text,o));case"divider":return h("<hr>");case"context":return h(de(a.elements).map(g=>ga(g,o)).join(""));case"actions":return h(de(a.elements).map(g=>wa(g,o)).join(""));case"image":return h(`${a.title?`<div class="chat-caption">${ze(a.title,o)}</div>`:""}${At(R(a.image_url),R(a.alt_text),"chat-image")}`);case"rich_text":return h(cn(a,o));default:return h(`<span class="chat-unknown">${P(d||"block")}</span>`,"unknown")}},Lt=(a,o={})=>de(a).map(d=>pn(d,o)).join(""),mn={good:"#2eb67d",warning:"#ecb22e",danger:"#e01e5a"},$a=(a,o={})=>de(a).map(d=>{let h=R(d.color),g=mn[h]??(/^#?[0-9a-f]{3,8}$/i.test(h)?`#${h.replace(/^#/,"")}`:"#dddddd"),v=tt(R(d.title_link)),$=P(R(d.title)),H=de(d.fields);return`<div class="chat-attachment" data-color="${P(g)}" style="border-left-color:${P(g)}">${d.pretext?`<div class="chat-text">${ke(R(d.pretext),o)}</div>`:""}${d.author_name?`<div class="chat-att-author">${P(R(d.author_name))}</div>`:""}${$?`<div class="chat-att-title">${v?`<a href="${P(v)}" target="_blank" rel="noreferrer">${$}</a>`:$}</div>`:""}${d.text?`<div class="chat-text">${ke(R(d.text),o)}</div>`:""}${H.length?`<div class="chat-fields">${H.map(y=>`<div class="chat-field ${y.short?"short":""}"><b>${P(R(y.title))}</b><div class="chat-text">${ke(R(y.value),o)}</div></div>`).join("")}</div>`:""}${Lt(d.blocks,o)}${At(R(d.image_url),R(d.fallback),"chat-image")}${d.footer?`<div class="chat-att-footer">${P(R(d.footer))}</div>`:""}</div>`}).join("");var X=(a,o,d,h="")=>`<svg width="${a}" height="${o}" viewBox="0 0 ${a} ${o}" fill="none" aria-hidden="true" ${h}>${d}</svg>`,A=(a,o=20)=>`<svg width="${o}" height="${o}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="${a}"/></svg>`,u={signal:(a="currentColor")=>X(18,12,`<rect x="0" y="8" width="3" height="4" rx="1" fill="${a}"/><rect x="5" y="5.5" width="3" height="6.5" rx="1" fill="${a}"/><rect x="10" y="3" width="3" height="9" rx="1" fill="${a}"/><rect x="15" y="0" width="3" height="12" rx="1" fill="${a}"/>`),wifi:(a="currentColor")=>X(16,12,`<path d="M8 2.6c2.3 0 4.4.9 6 2.4l1.1-1.1A10 10 0 0 0 8 1 10 10 0 0 0 .9 3.9L2 5c1.6-1.5 3.7-2.4 6-2.4Z" fill="${a}"/><path d="M8 5.9c1.4 0 2.6.5 3.6 1.4l1.1-1.1A6.7 6.7 0 0 0 8 4.3c-1.8 0-3.5.7-4.7 1.9l1.1 1.1c1-.9 2.2-1.4 3.6-1.4Z" fill="${a}"/><path d="M10.3 8.6 8 11 5.7 8.6A3.3 3.3 0 0 1 8 7.6c.9 0 1.7.4 2.3 1Z" fill="${a}"/>`),battery:(a="currentColor")=>X(27,13,`<rect x=".5" y=".5" width="23" height="12" rx="3.8" stroke="${a}" stroke-opacity=".4"/><rect x="2" y="2" width="20" height="9" rx="2.5" fill="${a}"/><path d="M25 4.5v4c.8-.3 1.3-1.1 1.3-2s-.5-1.7-1.3-2Z" fill="${a}" fill-opacity=".45"/>`),compose:()=>X(24,24,\'<path d="M19 13v6.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 3 19.5v-13A1.5 1.5 0 0 1 4.5 5H11" stroke="#007aff" stroke-width="1.8" stroke-linecap="round"/><path d="m9.5 14.5.6-3.1 8.8-8.8a1.5 1.5 0 0 1 2.1 0l.9.9a1.5 1.5 0 0 1 0 2.1l-8.8 8.8-3.6.1Z" stroke="#007aff" stroke-width="1.8" stroke-linejoin="round"/>\'),search:(a="currentColor",o=16)=>X(o,o,`<circle cx="${o*.43}" cy="${o*.43}" r="${o*.3}" stroke="${a}" stroke-width="${o/9}"/><path d="m${o*.65} ${o*.65} ${o*.27} ${o*.27}" stroke="${a}" stroke-width="${o/9}" stroke-linecap="round"/>`),mic:(a="#8e8e93")=>X(14,20,`<rect x="4" y="1" width="6" height="11" rx="3" fill="${a}"/><path d="M1.5 9a5.5 5.5 0 0 0 11 0M7 14.5V18" stroke="${a}" stroke-width="1.6" stroke-linecap="round"/>`),chevronRight:(a="#c4c4c6")=>X(8,13,`<path d="m1.5 1.5 5 5-5 5" stroke="${a}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`),chevronBack:()=>X(13,21,\'<path d="M11 2 2.5 10.5 11 19" stroke="#007aff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\'),plus:()=>X(16,16,\'<path d="M8 2v12M2 8h12" stroke="#8e8e93" stroke-width="2.2" stroke-linecap="round"/>\'),person:()=>X(26,26,\'<circle cx="13" cy="9" r="5" fill="#fff"/><path d="M3 24c0-5.5 4.5-9 10-9s10 3.5 10 9" fill="#fff"/>\'),padlock:()=>X(16,21,\'<rect x="1" y="9" width="14" height="11" rx="2.5" fill="#fff"/><path d="M4 9V6a4 4 0 0 1 8 0v3" stroke="#fff" stroke-width="2"/>\'),flashlight:()=>X(14,22,\'<path d="M2 1h10v4L9.5 9v11a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V9L2 5V1Z" fill="#fff"/>\'),camera:()=>X(22,18,\'<path d="M2 5.5A1.5 1.5 0 0 1 3.5 4h3l1.6-2.2h5.8L15.5 4h3A1.5 1.5 0 0 1 20 5.5v10a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 2 15.5v-10Z" fill="#fff"/><circle cx="11" cy="10.3" r="3.6" fill="#555"/>\'),bell:()=>A("M12 22a2 2 0 0 0 2-2h-4a2 2 0 0 0 2 2Zm6-6V11a6 6 0 0 0-5-5.9V4a1 1 0 0 0-2 0v1.1A6 6 0 0 0 6 11v5l-2 2v1h16v-1l-2-2Z",18),expand:()=>A("M7.4 8.6 12 13.2l4.6-4.6L18 10l-6 6-6-6z",16),collapse:()=>A("M7.4 15.4 12 10.8l4.6 4.6L18 14l-6-6-6 6z",16),androidWifi:()=>A("M12 21 23.6 6.5A17.6 17.6 0 0 0 12 2.5 17.6 17.6 0 0 0 .4 6.5Z",15),androidSignal:()=>A("M2 22h20V2Z",14),androidBattery:()=>A("M16 4h-2V2h-4v2H8a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1Z",15),menu:()=>A("M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z",24),tune:()=>A("M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z",24),help:()=>A("M11 18h2v-2h-2v2zm1-16a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm0-14a4 4 0 0 0-4 4h2a2 2 0 1 1 4 0c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5a4 4 0 0 0-4-4z",24),gear:()=>A("M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.49.49 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.48.48 0 0 0-.48-.41h-3.84a.48.48 0 0 0-.48.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96a.48.48 0 0 0-.59.22L2.74 8.87a.47.47 0 0 0 .12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32a.47.47 0 0 0-.12-.61l-2.01-1.58zM12 15.6A3.6 3.6 0 1 1 12 8.4a3.6 3.6 0 0 1 0 7.2z",24),apps:()=>A("M6 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm-6 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0-6a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm4-8a2 2 0 1 0 4 0 2 2 0 0 0-4 0zm-4 2a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6 6a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 6a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",24),pencil:()=>A("M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",24),inbox:()=>A("M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm0 12h-4a3 3 0 0 1-6 0H5V5h14v10z",20),star:()=>A("M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z",20),clock:()=>A("M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67V7z",20),send:()=>A("M3.4 20.4l17.45-7.48a1 1 0 0 0 0-1.84L3.4 3.6a.99.99 0 0 0-1.39.91L2 9.12c0 .5.37.93.87.99L17 12 2.87 13.88c-.5.07-.87.5-.87 1l.01 4.61c0 .71.73 1.2 1.39.91z",20),draft:()=>A("M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zM6 20V4h7v5h5v11H6z",20),more:()=>A("M12 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 2a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm0 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z",20),refresh:()=>A("M17.65 6.35A7.96 7.96 0 0 0 12 4a8 8 0 1 0 7.73 10h-2.08A6 6 0 1 1 12 6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z",20),checkbox:()=>A("M19 5v14H5V5h14m0-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z",18),back:()=>A("M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z",20),archive:()=>A("M20.54 5.23l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z",20),report:()=>A("M15.73 3H8.27L3 8.27v7.46L8.27 21h7.46L21 15.73V8.27L15.73 3zM19 14.9 14.9 19H9.1L5 14.9V9.1L9.1 5h5.8L19 9.1v5.8zM11 7h2v6h-2zm0 8h2v2h-2z",20),trash:()=>A("M15 4V3H9v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5zm2 15H7V6h10v13zM9 8h2v9H9zm4 0h2v9h-2z",20),reply:()=>A("M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z",20),forward:()=>A("M14 9V5l7 7-7 7v-4.1c-5 0-8.5 1.6-11 5.1 1-5 4-10 11-11z",20),clip:()=>A("M16.5 6v11.5a4 4 0 0 1-8 0V5a2.5 2.5 0 0 1 5 0v10.5a1 1 0 0 1-2 0V6H10v9.5a2.5 2.5 0 0 0 5 0V5a4 4 0 0 0-8 0v12.5a5.5 5.5 0 0 0 11 0V6h-1.5z",16),file:()=>A("M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm4 18H6V4h7v5h5v11z",28),dropdown:()=>A("M7 10l5 5 5-5z",18),lock:()=>A("M18 8h-1V6A5 5 0 0 0 7 6v2H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2zM9 6a3 3 0 0 1 6 0v2H9V6z",14),envelope:()=>X(30,24,\'<path d="M3 4h24v16a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4Z" fill="#e8eaed"/><path d="M3 4l12 9 12-9" stroke="#5f6368" stroke-width="2.2" stroke-linejoin="round"/><path d="M3 4h24" stroke="#5f6368" stroke-width="2.2"/>\'),pin:(a=16)=>A("M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z",a),bellSlash:(a=16)=>A("M20 18.69 7.84 6.14 5.27 3.49 4 4.76l2.8 2.8v.01c-.52.99-.8 2.16-.8 3.42v5l-2 2v1h13.73l2 2L21 19.72l-1-1.03zM12 22c1.11 0 2-.89 2-2h-4c0 1.11.89 2 2 2zm6-7.32V11c0-3.08-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.15.03-.29.08-.42.12-.1.03-.2.07-.3.11-.23.09-.46.2-.68.31L18 14.68z",a),volumeOn:(a=16)=>A("M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z",a),volumeOff:(a=16)=>A("M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z",a),markUnread:(a=20)=>A("M22 8.98V18c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h10.1c-.06.32-.1.66-.1 1 0 1.48.65 2.79 1.67 3.71L12 11 4 6v2l8 5 5.3-3.32c.54.2 1.1.32 1.7.32 1.13 0 2.16-.39 3-1.02zM16 5c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z",a),markRead:(a=20)=>A("M21.99 8c0-.72-.37-1.35-.94-1.7L12 1 2.95 6.3C2.38 6.65 2 7.28 2 8v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2l-.01-10zM12 13 3.74 7.84 12 3l8.26 4.84L12 13z",a),close:(a=16)=>A("M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",a),starFilled:(a=20)=>A("M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z",a)};var Te=(a,o,d,h,g,v=1)=>{for(let[$,H]of[[1,1],[2.76,.18],[5.4,.06]]){let y=a.createOscillator(),E=a.createGain();y.type="sine",y.frequency.value=h*$,E.gain.setValueAtTime(0,d),E.gain.linearRampToValueAtTime(.32*H*v,d+.006),E.gain.exponentialRampToValueAtTime(1e-4,d+g/$**.35),y.connect(E).connect(o),y.start(d),y.stop(d+g+.05)}},_e=(a,o,d,h,g)=>{let v=a.createOscillator(),$=a.createBiquadFilter(),H=a.createGain();v.type="triangle",v.frequency.value=h,$.type="lowpass",$.frequency.setValueAtTime(h*6,d),$.frequency.exponentialRampToValueAtTime(h*1.5,d+g),H.gain.setValueAtTime(0,d),H.gain.linearRampToValueAtTime(.42,d+.004),H.gain.exponentialRampToValueAtTime(1e-4,d+g),v.connect($).connect(H).connect(o),v.start(d),v.stop(d+g+.05)},hn={sms:(a,o,d)=>{Te(a,o,d,1318.5,.5),Te(a,o,d+.12,1661.2,.5),Te(a,o,d+.24,1975.5,.8)},"push-ios":(a,o,d)=>{Te(a,o,d,1760,.35,.8),Te(a,o,d+.09,2349.3,.9,.9)},"push-android":(a,o,d)=>{_e(a,o,d,1046.5,.22),_e(a,o,d+.1,1568,.22),_e(a,o,d+.2,2093,.45)},email:(a,o,d)=>{Te(a,o,d,987.8,.45,.7),Te(a,o,d+.16,1318.5,.9,.7)},chat:(a,o,d)=>{_e(a,o,d,587.3,.12),_e(a,o,d+.11,880,.2)}},un={sms:[180,90,180],"push-ios":[120],"push-android":[60,80,60]},ya=(a=!1)=>{let o=null,d=null,h=new Map,g=()=>{if(o)return o;let $=globalThis.AudioContext??globalThis.webkitAudioContext;if(!$)return null;try{o=new $,d=o.createGain(),d.gain.value=.6,d.connect(o.destination)}catch{o=null}return o},v={enabled:a,unlock(){if(!v.enabled)return;let $=g();$?.state==="suspended"&&$.resume().catch(()=>{})},play($){if(!v.enabled)return;let H=Date.now();if(H-(h.get($)??0)<600)return;h.set($,H);let y=un[$];if(y)try{navigator.vibrate?.(y)}catch{}let E=g();!E||!d||(E.state==="suspended"&&E.resume().catch(()=>{}),hn[$](E,d,E.currentTime+.02))},close(){o?.close().catch(()=>{}),o=null}};return v};var Ue=(a,o)=>{let d=a.replace(/\\/\\*[\\s\\S]*?\\*\\//g,""),h="",g=0;for(;g<d.length;){let v=d.indexOf("{",g);if(v<0)break;let $=d.slice(g,v).trim(),H=1,y=v+1;for(;y<d.length&&H>0;)d[y]==="{"?H++:d[y]==="}"&&H--,y++;let E=d.slice(v+1,y-1);/^@(media|container|supports|layer)\\b/.test($)?h+=`${$} {\n${Ue(E,o)}}\n`:$.startsWith("@")?h+=`${$} {${E}}\n`:h+=`${fn($,o)} {${E}}\n`,g=y}return h},fn=(a,o)=>bn(a).map(d=>{let h=d.trim();return h===":root"||h==="html"||h==="body"?o:h.startsWith(":root")?`${o}${h.slice(5)}`:h.startsWith("&")?`${o}${h.slice(1)}`:`${o} ${h}`}).join(", "),bn=a=>{let o=[],d=0,h=0;for(let g=0;g<a.length;g++){let v=a[g];v==="("?d++:v===")"?d--:v===","&&d===0&&(o.push(a.slice(h,g)),h=g+1)}return o.push(a.slice(h)),o};var at="mb-notifications",gn=`\n:root {\n --bg: #0e1015; --panel: #161920; --panel-2: #1d212a; --line: #2a2f3a; --text: #e8eaf0;\n --muted: #9aa1b1; --accent: #0a84ff; --ok: #30d158; --bad: #ff453a; --warn: #ffd60a;\n --ios: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;\n --android: "Google Sans Text", "Google Sans", Roboto, "Segoe UI", system-ui, sans-serif;\n --mail: "Google Sans", Roboto, RobotoDraft, Helvetica, Arial, sans-serif;\n --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n}\n:root { display: block; position: relative; box-sizing: border-box; min-height: 100%; background: var(--bg); color: var(--text);\n font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }\n*, *::before, *::after { box-sizing: border-box; }\nbutton, input, select { font: inherit; color: inherit; }\nbutton { cursor: pointer; }\n[hidden] { display: none !important; }\n&[data-motion="reduce"] *, &[data-motion="reduce"] *::before, &[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }\n&.embedded { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }\n&.embedded .mbn-scroll { flex: 1; min-height: 0; overflow: auto; }\n&.embedded .inspector { position: absolute; }\n[data-gesture]:focus-visible, [role="button"]:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }\n.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n/* \\u2500\\u2500 Harness chrome \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;\n padding: 10px 18px; background: rgba(14,16,21,.86); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }\n.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; margin-right: 6px; }\n.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg,#0a84ff,#5e5ce6); display: grid; place-items: center; }\n.brand small { color: var(--muted); font-weight: 500; }\n.field { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; height: 32px; }\n.field label { color: var(--muted); font-size: 12px; }\n.field select, .field input { background: transparent; border: 0; outline: 0; height: 30px; min-width: 0; }\n.field select option { background: var(--panel-2); }\n.field.search { flex: 1 1 220px; max-width: 360px; }\n.field.search input { width: 100%; }\n.tabs { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }\n.tabs button { background: none; border: 0; padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 550; }\n.tabs button[aria-pressed="true"] { background: #2c3240; color: var(--text); }\n.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; user-select: none; }\n.toggle input { accent-color: var(--accent); }\n.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }\n.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--muted); white-space: nowrap; }\n.pill b { color: var(--text); font-weight: 600; }\n.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }\n.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(48,209,88,.15); }\n.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(255,69,58,.15); }\n.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }\n.notice { margin: 14px 18px 0; padding: 10px 14px; border: 1px solid #5a2b2b; background: #2a1517; color: #ffb4ab; border-radius: 10px; font-size: 13px; }\n\n.devices { display: flex; flex-wrap: wrap; gap: 28px; padding: 22px 18px 40px; align-items: flex-start; justify-content: center; zoom: var(--mbn-scale, 1); }\n.devices.solo .device-col.wide { max-width: 1280px; }\n.device-col { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 362px; flex: none; }\n.device-col.wide { flex: 3 1 480px; width: auto; min-width: 0; max-width: 1180px; align-items: stretch; }\n.device-col.wide.chat-col { flex: 2 1 340px; max-width: 760px; }\n.devices.solo .device-col.wide.chat-col { max-width: 980px; }\n/* Two fixed rows on every device, so the frames underneath all start at the same height. */\n.device-head { display: grid; grid-template-rows: 28px 30px; row-gap: 6px; height: 64px; flex: none; width: 100%; justify-items: start; }\n.device-head .head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; height: 28px; overflow: hidden; }\n.device-head h2 { white-space: nowrap; }\n.device-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 8px; }\n.device-head h2 .count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; letter-spacing: 0; line-height: 18px; }\n.device-head .field { height: 30px; max-width: 100%; min-width: 0; }\n.device-head .field select { max-width: 190px; text-overflow: ellipsis; }\n.channel-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; flex: none; scrollbar-width: none; }\n.channel-tabs [role="tab"] { position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none; background: none; border: 0; padding: 10px 14px 9px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }\n.channel-tabs [role="tab"]:hover { color: var(--text); }\n.channel-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }\n.channel-tabs [role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 6px; }\n.channel-tabs .tab-unread { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; min-width: 18px; font-size: 11px; line-height: 18px; text-align: center; }\n.channel-tabs[data-layout="tabs"] { padding: 0 6px; }\n.channel-tabs[data-layout="tabs"] [role="tab"] { flex: 1 1 0; justify-content: center; padding-left: 8px; padding-right: 8px; }\n/* One device at a time: the host is too narrow for two. Phones shrink to fit rather than clip. */\n&[data-layout="tabs"] .devices { padding: 14px 8px 32px; gap: 0; }\n&[data-layout="tabs"] .device-col.wide { flex-basis: 100%; }\n&[data-layout="tabs"] .iphone, &[data-layout="tabs"] .pixel { zoom: var(--mbn-fit, 1); }\n&[data-layout="tabs"] .device-col:not(.wide) { width: auto; max-width: 100%; }\n&[data-layout="tabs"] .device-col:not(.wide) .device-head { width: calc(362px * var(--mbn-fit, 1)); }\n.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }\n.seg button { border: 0; background: none; color: var(--muted); padding: 2px 9px; border-radius: 5px; font-size: 12px; }\n.seg button[aria-pressed="true"] { background: #2c3240; color: var(--text); }\n\n/* \\u2500\\u2500 Phone hardware \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.iphone { position: relative; width: 362px; height: 760px; border-radius: 58px; padding: 12px; background: #0b0b0c;\n box-shadow: 0 0 0 2px #3a3a3c, 0 0 0 6px #1c1c1e, 0 0 0 7px #4a4a4e, 0 40px 80px rgba(0,0,0,.55); }\n.iphone::before, .iphone::after { content: ""; position: absolute; left: -9px; width: 4px; border-radius: 2px; background: #2c2c2e; }\n.iphone::before { top: 150px; height: 60px; }\n.iphone::after { top: 225px; height: 60px; }\n/* clip-path as well as overflow: under zoom, Chromium lets a blurred bar (backdrop-filter) square off the rounded corners. */\n.iphone .screen { position: relative; width: 100%; height: 100%; border-radius: 47px; overflow: hidden; clip-path: inset(0 round 47px); background: #fff; font-family: var(--ios); color: #000; -webkit-font-smoothing: antialiased; }\n.island { position: absolute; z-index: 30; top: 11px; left: 50%; transform: translateX(-50%); width: 112px; height: 33px; border-radius: 20px; background: #000; }\n.statusbar { position: absolute; z-index: 25; top: 0; left: 0; right: 0; height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 6px 32px 0 40px; font: 600 16px/1 var(--ios); letter-spacing: -.01em; }\n.statusbar .icons { display: flex; gap: 6px; align-items: center; }\n.statusbar.light { color: #fff; }\n.home-indicator { position: absolute; z-index: 30; bottom: 8px; left: 50%; transform: translateX(-50%); width: 134px; height: 5px; border-radius: 3px; background: #000; }\n.home-indicator.light { background: rgba(255,255,255,.9); }\n\n.pixel { position: relative; width: 352px; height: 760px; border-radius: 44px; padding: 10px; background: #111;\n box-shadow: 0 0 0 2px #2b2b2f, 0 0 0 5px #3c3c41, 0 40px 80px rgba(0,0,0,.55); }\n.pixel::after { content: ""; position: absolute; right: -7px; top: 170px; width: 4px; height: 90px; border-radius: 2px; background: #2c2c2e; }\n.pixel .screen { position: relative; width: 100%; height: 100%; border-radius: 35px; overflow: hidden; clip-path: inset(0 round 35px); font-family: var(--android); }\n.punch { position: absolute; z-index: 30; top: 12px; left: 50%; width: 13px; height: 13px; margin-left: -6px; border-radius: 50%; background: #050505; box-shadow: inset 0 0 0 2px #1a1a1a; }\n\n/* \\u2500\\u2500 Messages (iOS) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.msgs { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; }\n.msgs-nav { padding: 54px 16px 0; }\n.msgs-nav .row { display: flex; justify-content: space-between; align-items: center; height: 44px; color: #007aff; font-size: 17px; }\n.msgs-nav h1 { margin: 2px 0 8px; font: 700 34px/41px var(--ios); letter-spacing: .01em; }\n.ios-search { display: flex; align-items: center; gap: 6px; height: 36px; border-radius: 10px; background: rgba(118,118,128,.12); color: rgba(60,60,67,.6); padding: 0 8px; font-size: 17px; margin-bottom: 8px; }\n.ios-search span { flex: 1; }\n.threads { flex: 1; overflow-y: auto; }\n.thread { position: relative; display: flex; gap: 12px; padding: 10px 16px 0 26px; cursor: pointer; }\n.thread:active { background: #e5e5ea; }\n.thread .unread { position: absolute; left: 8px; top: 30px; width: 10px; height: 10px; border-radius: 50%; background: #007aff; }\n.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 18px var(--ios); background: linear-gradient(180deg,#a5abb8,#858994); }\n.thread .text { flex: 1; min-width: 0; border-bottom: .5px solid #c6c6c8; padding-bottom: 10px; }\n.thread .top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }\n.thread .name { font: 600 17px/22px var(--ios); letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.thread .when { flex: none; color: rgba(60,60,67,.6); font-size: 15px; display: flex; align-items: center; gap: 6px; }\n.thread .preview { color: rgba(60,60,67,.6); font-size: 15px; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; letter-spacing: -.01em; }\n.empty-ios { flex: 1; display: grid; place-items: center; color: rgba(60,60,67,.6); font-size: 17px; text-align: center; padding: 40px; }\n\n.convo { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; }\n.convo-nav { position: relative; z-index: 5; padding-top: 50px; background: rgba(249,249,249,.94); backdrop-filter: blur(20px); border-bottom: .5px solid rgba(0,0,0,.18); }\n.convo-nav .bar { position: relative; height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }\n.convo-nav .back { position: absolute; left: 8px; top: 8px; display: flex; align-items: center; color: #007aff; font-size: 17px; background: none; border: 0; padding: 4px; }\n.convo-nav .back .badge { background: #007aff; color: #fff; border-radius: 10px; font-size: 13px; min-width: 20px; padding: 0 6px; line-height: 20px; margin-left: 2px; }\n.convo-nav .avatar { width: 54px; height: 54px; font-size: 22px; }\n.convo-nav .who { font-size: 12px; display: flex; align-items: center; gap: 2px; }\n.convo-body { flex: 1; overflow-y: auto; padding: 8px 0 12px; }\n.stamp { text-align: center; color: rgba(60,60,67,.6); font-size: 12px; margin: 14px 0 6px; }\n.stamp b { font-weight: 600; }\n.bubble-row { display: flex; padding: 0 14px; margin-top: 2px; }\n.bubble-row.gap { margin-top: 10px; }\n.bubble { position: relative; max-width: 74%; padding: 7px 12px 8px; border-radius: 18px; background: #e9e9eb; color: #000; font-size: 17px; line-height: 22px; letter-spacing: -.02em; white-space: pre-wrap; overflow-wrap: anywhere; }\n.bubble.tail::before { content: ""; position: absolute; bottom: 0; left: -7px; width: 20px; height: 20px; background: #e9e9eb; border-bottom-right-radius: 15px; }\n.bubble.tail::after { content: ""; position: absolute; bottom: 0; left: -10px; width: 10px; height: 20px; background: #fff; border-bottom-right-radius: 10px; }\n.bubble a, .bubble .code { color: inherit; text-decoration: underline; text-underline-offset: 2px; }\n.bubble .media { display: block; max-width: 100%; border-radius: 12px; margin: 2px 0 4px; }\n.bubble.arrive { animation: mbn-pop .35s cubic-bezier(.2,.9,.3,1.3); }\n.delivered-note { padding: 2px 16px 0 26px; color: rgba(60,60,67,.6); font-size: 11px; }\n.convo-input { display: flex; align-items: flex-end; gap: 8px; padding: 6px 10px 32px; background: #fff; }\n.convo-input .plus { width: 34px; height: 34px; border-radius: 50%; background: #e9e9eb; display: grid; place-items: center; flex: none; }\n.convo-input .field-ios { flex: 1; height: 36px; border: 1px solid #c6c6c8; border-radius: 18px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 14px; color: #c4c4c6; font-size: 17px; }\n.qt { margin: 0 10px 6px; padding: 8px 12px; border-radius: 10px; background: #d1d3d9; text-align: center; font-size: 15px; color: #000; }\n.qt small { display: block; font-size: 12px; color: #3c3c43; }\n\n/* \\u2500\\u2500 Lock screen (iOS) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.lock { position: absolute; inset: 0; color: #fff; overflow: hidden;\n background: radial-gradient(120% 70% at 20% 10%, #6f86ff 0%, transparent 55%), radial-gradient(90% 60% at 90% 30%, #ff7eb3 0%, transparent 60%), radial-gradient(120% 80% at 50% 100%, #1d1b4a 0%, transparent 70%), linear-gradient(180deg,#3a3f9f,#141433); }\n.lock .padlock { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); opacity: .95; }\n.lock .date { position: absolute; top: 84px; width: 100%; text-align: center; font: 600 19px var(--ios); letter-spacing: .01em; opacity: .92; }\n.lock .clock { position: absolute; top: 102px; width: 100%; text-align: center; font: 700 92px/1 "SF Pro Rounded", var(--ios); letter-spacing: -.02em; color: rgba(255,255,255,.93); }\n.lock-stack { position: absolute; left: 10px; right: 10px; top: 236px; bottom: 112px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; scrollbar-width: none; }\n.lock-stack::-webkit-scrollbar { display: none; }\n.lock-stack .center-label { text-align: center; font: 600 15px var(--ios); opacity: .85; padding: 4px 0; }\n.ios-note { position: relative; display: flex; gap: 10px; padding: 11px 12px 12px 11px; border-radius: 22px; color: #000; background: rgba(246,246,246,.66); backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%); cursor: pointer; box-shadow: 0 1px 0 rgba(255,255,255,.25) inset; }\n.ios-note.arrive { animation: mbn-drop .45s cubic-bezier(.2,.9,.3,1.15); }\n.ios-note .app-icon { flex: none; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; color: #fff; font: 700 18px var(--ios); box-shadow: 0 0 0 .5px rgba(0,0,0,.08); }\n.ios-note .content { flex: 1; min-width: 0; }\n.ios-note .line1 { display: flex; justify-content: space-between; gap: 8px; }\n.ios-note .title { font: 600 15px/20px var(--ios); letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ios-note .time { flex: none; font-size: 13px; color: rgba(60,60,67,.62); }\n.ios-note .body { font: 400 15px/20px var(--ios); letter-spacing: -.02em; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }\n.ios-note .thumb { flex: none; width: 38px; height: 38px; border-radius: 7px; object-fit: cover; align-self: center; }\n.ios-note.expanded .body { -webkit-line-clamp: unset; }\n.ios-note .hero { width: 100%; border-radius: 12px; margin-top: 8px; display: block; }\n.note-data { margin-top: 8px; font: 12px/1.45 var(--mono); background: rgba(255,255,255,.55); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: #1c1c1e; }\n.note-meta { margin-top: 6px; font-size: 12px; color: rgba(60,60,67,.7); }\n.ios-stack-more { position: relative; height: 18px; margin: -14px 14px 0; border-radius: 0 0 18px 18px; background: rgba(246,246,246,.42); backdrop-filter: blur(20px); }\n.ios-stack-more + .ios-stack-more { margin: -10px 26px 0; background: rgba(246,246,246,.28); }\n.lock-buttons { position: absolute; bottom: 46px; left: 46px; right: 46px; display: flex; justify-content: space-between; }\n.lock-buttons span { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.28); backdrop-filter: blur(20px); }\n.lock-empty { text-align: center; font: 500 15px var(--ios); opacity: .7; margin-top: 30px; }\n\n/* \\u2500\\u2500 Notification shade (Android) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.shade { position: absolute; inset: 0; color: #e6e1e5; background: linear-gradient(180deg, rgba(20,18,24,.94), rgba(20,18,24,.98)), radial-gradient(100% 60% at 30% 0%, #4b3f72, #141218); overflow: hidden; }\n.shade .sb { position: absolute; top: 0; left: 0; right: 0; height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 6px 24px 0; font: 500 14px var(--android); color: #e6e1e5; }\n.shade .sb .icons { display: flex; gap: 5px; align-items: center; }\n.shade .qs-head { position: absolute; top: 46px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: center; font: 400 15px var(--android); color: #cac4d0; }\n.qs { position: absolute; top: 80px; left: 14px; right: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }\n.qs .tile { height: 60px; border-radius: 20px; background: #36343b; display: flex; align-items: center; gap: 10px; padding: 0 14px; font: 500 14px var(--android); color: #e6e1e5; min-width: 0; }\n.qs .tile > div { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.qs .tile svg { flex: none; }\n.qs .tile.on { background: #d0bcff; color: #381e72; }\n.qs .tile small { display: block; font-weight: 400; font-size: 12px; opacity: .8; }\n.qs-bright { position: absolute; top: 216px; left: 14px; right: 14px; height: 44px; border-radius: 22px; background: #36343b; overflow: hidden; }\n.qs-bright::before { content: ""; position: absolute; inset: 0 44% 0 0; background: #d0bcff; border-radius: 22px; }\n.shade-list { position: absolute; top: 276px; left: 10px; right: 10px; bottom: 92px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }\n.shade-list::-webkit-scrollbar { display: none; }\n.a-note { background: #2b2930; border-radius: 6px; padding: 14px 16px 14px 14px; cursor: pointer; display: flex; gap: 12px; }\n.a-note:first-child { border-top-left-radius: 26px; border-top-right-radius: 26px; }\n.a-note:last-child { border-bottom-left-radius: 26px; border-bottom-right-radius: 26px; }\n.a-note.arrive { animation: mbn-headsup .5s cubic-bezier(.2,.9,.3,1.12); }\n.a-note .a-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 15px var(--android); }\n.a-note .a-main { flex: 1; min-width: 0; }\n.a-note .a-head { display: flex; align-items: center; gap: 6px; font: 400 12px var(--android); color: #cac4d0; }\n.a-note .a-head .chev { margin-left: auto; width: 26px; height: 20px; border-radius: 10px; background: #49454f; display: grid; place-items: center; }\n.a-note .a-title { font: 500 15px/20px var(--android); color: #e6e1e5; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.a-note .a-body { font: 400 14px/20px var(--android); color: #cac4d0; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }\n.a-note.expanded .a-body { -webkit-line-clamp: unset; }\n.a-note .large-icon { flex: none; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; align-self: center; }\n.a-note .big-picture { display: block; width: 100%; border-radius: 14px; margin-top: 10px; }\n.a-note .note-data { background: #1d1b20; color: #e6e1e5; }\n.a-note .note-meta { color: #938f99; }\n.shade-actions { position: absolute; bottom: 44px; left: 14px; right: 14px; display: flex; justify-content: space-between; }\n.shade-actions span { padding: 8px 16px; border-radius: 18px; background: #36343b; font: 500 14px var(--android); color: #e6e1e5; }\n.shade-empty { text-align: center; color: #938f99; font: 400 14px var(--android); margin-top: 26px; }\n.gesture { position: absolute; bottom: 12px; left: 50%; width: 110px; height: 4px; margin-left: -55px; border-radius: 2px; background: rgba(255,255,255,.75); }\n\n/* \\u2500\\u2500 Mail (web client) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.window { position: relative; container-type: inline-size; border-radius: 12px; overflow: hidden; background: #f8fafd; box-shadow: 0 0 0 1px #2c313c, 0 30px 70px rgba(0,0,0,.5); height: 760px; display: flex; flex-direction: column; font-family: var(--mail); color: #1f1f1f; }\n.chrome { flex: none; height: 38px; background: #dfe3e9; display: flex; align-items: center; gap: 12px; padding: 0 12px; }\n.lights { display: flex; gap: 7px; }\n.lights i { width: 12px; height: 12px; border-radius: 50%; display: block; }\n.lights i:nth-child(1) { background: #ff5f57; } .lights i:nth-child(2) { background: #febc2e; } .lights i:nth-child(3) { background: #28c840; }\n.omnibox { flex: 1; max-width: 560px; margin: 0 auto; height: 26px; border-radius: 13px; background: #fff; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #5f6368; font: 13px system-ui; }\n.mail-top { flex: none; height: 64px; display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 12px; }\n.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #444746; border: 0; background: none; flex: none; }\n.icon-btn:hover { background: rgba(68,71,70,.08); }\n.mail-logo { display: flex; align-items: center; gap: 6px; width: 194px; font: 400 22px var(--mail); color: #444746; letter-spacing: -.01em; }\n.mail-search { flex: 1; min-width: 0; max-width: 720px; height: 48px; border-radius: 24px; background: #e9eef6; display: flex; align-items: center; gap: 4px; padding: 0 4px; color: #444746; font-size: 16px; }\n.mail-search .placeholder { flex: 1; padding-left: 4px; }\n.mail-top .right { margin-left: auto; display: flex; align-items: center; gap: 2px; }\n.mail-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 500 15px var(--mail); margin-left: 8px; }\n.mail-body { flex: 1; min-height: 0; display: flex; }\n.mail-nav { flex: none; width: 236px; padding: 8px 8px 0 0; overflow: hidden; }\n.compose { display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 22px 0 16px; margin: 0 0 16px 8px; border-radius: 16px; background: #c2e7ff; color: #001d35; font: 500 14px var(--mail); border: 0; box-shadow: none; }\n.nav-item { display: flex; align-items: center; gap: 18px; height: 32px; padding: 0 12px 0 26px; border-radius: 0 16px 16px 0; color: #202124; font: 400 14px var(--mail); }\n.nav-item.active { background: #d3e3fd; font-weight: 700; color: #001d35; }\n.nav-item .n { margin-left: auto; font-size: 12px; }\n.mail-main { flex: 1; min-width: 0; margin: 0 16px 16px 0; background: #fff; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }\n.mail-toolbar { flex: none; height: 48px; display: flex; align-items: center; gap: 4px; padding: 0 12px 0 14px; color: #444746; }\n.mail-toolbar .range { margin-left: auto; font-size: 12px; color: #444746; }\n.cat-tabs { flex: none; display: flex; border-bottom: 1px solid #f1f3f4; }\n.cat-tabs div { flex: 0 1 250px; min-width: 0; height: 54px; display: flex; align-items: center; gap: 16px; padding: 0 16px; color: #444746; font: 500 14px var(--mail); position: relative; }\n.cat-tabs div.on { color: #0b57d0; }\n.cat-tabs div.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: #0b57d0; }\n.mail-list { flex: 1; overflow-y: auto; }\n.mrow { display: flex; align-items: center; height: 40px; padding: 0 16px 0 12px; border-bottom: 1px solid #f1f3f4; cursor: pointer; font-size: 14px; color: #202124; background: #f2f6fc; }\n.mrow.unread { background: #fff; font-weight: 700; }\n.mrow:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); position: relative; z-index: 1; }\n.mrow.arrive { animation: mbn-rowflash 1.6s ease-out; }\n.mrow .chk, .mrow .star { flex: none; width: 20px; height: 20px; margin-right: 10px; color: #c4c7c5; display: grid; place-items: center; }\n.mrow .from { flex: none; width: 168px; padding-right: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.mrow .subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.mrow .snippet { color: #5f6368; font-weight: 400; }\n.mrow .clip { color: #5f6368; margin-left: 8px; flex: none; }\n.mrow .date { flex: none; width: 78px; text-align: right; font-size: 12px; }\n.mrow .svc { flex: none; font: 500 10px var(--mail); color: #5f6368; border: 1px solid #dadce0; border-radius: 4px; padding: 0 4px; margin-left: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }\n.mail-empty { padding: 60px 20px; text-align: center; color: #5f6368; font: 400 14px var(--mail); }\n.mail-empty b { display: block; font: 400 22px var(--mail); color: #1f1f1f; margin: 12px 0 4px; }\n.reader { flex: 1; overflow-y: auto; padding: 0 0 24px; }\n.reader .subject-row { display: flex; align-items: center; gap: 10px; padding: 18px 16px 8px 72px; }\n.reader h1 { margin: 0; font: 400 22px/28px var(--mail); color: #1f1f1f; }\n.label-chip { font: 400 12px var(--mail); background: #ddd; border-radius: 4px; padding: 0 6px; color: #444746; display: inline-flex; gap: 4px; align-items: center; }\n.sender-row { display: flex; gap: 14px; padding: 12px 16px 0 16px; }\n.sender-row .mail-avatar { width: 40px; height: 40px; font-size: 18px; margin: 0; }\n.sender-row .who { flex: 1; min-width: 0; }\n.sender-row .who b { font: 700 14px var(--mail); color: #1f1f1f; }\n.sender-row .who .addr { font: 400 12px var(--mail); color: #5e5e5e; }\n.sender-row .who .to { font: 400 12px var(--mail); color: #5e5e5e; display: flex; align-items: center; gap: 2px; margin-top: 2px; }\n.sender-row .meta { display: flex; align-items: center; gap: 4px; color: #5e5e5e; font: 400 12px var(--mail); white-space: nowrap; }\n.details { margin: 8px 16px 0 70px; padding: 10px 14px; border: 1px solid #dadce0; border-radius: 8px; font: 12px/1.6 var(--mail); color: #5e5e5e; display: grid; grid-template-columns: max-content 1fr; gap: 0 12px; }\n.details span:nth-child(odd) { text-align: right; }\n.details span:nth-child(even) { color: #1f1f1f; overflow-wrap: anywhere; }\n.mail-frame { display: block; width: calc(100% - 86px); margin: 16px 16px 0 70px; border: 0; min-height: 120px; background: #fff; }\n.mail-text { margin: 16px 16px 0 70px; white-space: pre-wrap; font: 400 14px/1.55 Arial, sans-serif; color: #222; overflow-wrap: anywhere; }\n.mail-text a { color: #1155cc; }\n.attachments { margin: 18px 16px 0 70px; border-top: 1px solid #e0e0e0; padding-top: 14px; }\n.attachments h3 { margin: 0 0 10px; font: 500 14px var(--mail); color: #1f1f1f; }\n.att-grid { display: flex; flex-wrap: wrap; gap: 12px; }\n.att { width: 180px; height: 104px; border: 1px solid #dadce0; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }\n.att .att-top { flex: 1; background: #f1f3f4; display: grid; place-items: center; color: #d93025; }\n.att .att-name { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; font: 500 12px var(--mail); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.reply-row { display: flex; gap: 10px; margin: 24px 16px 0 70px; }\n.reply-row span { display: inline-flex; align-items: center; gap: 8px; padding: 0 22px 0 16px; height: 36px; border: 1px solid #747775; border-radius: 18px; font: 500 14px var(--mail); color: #444746; }\n\n/* \\u2500\\u2500 Timeline + inspector \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.timeline { padding: 18px; overflow-x: auto; }\n.tl td.mono:first-child { white-space: nowrap; }\n.tl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }\n.tl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); }\n.tl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }\n.tl tr:last-child td { border-bottom: 0; }\n.tl tbody tr { cursor: pointer; }\n.tl tbody tr:hover { background: #1b1f28; }\n.tl .content { max-width: 520px; color: var(--muted); }\n.tl .content b { color: var(--text); font-weight: 600; }\n.tl .mono { font-family: var(--mono); font-size: 12px; }\n.chan { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }\n.chan.sms { background: rgba(48,209,88,.14); color: #6ee38a; }\n.chan.email { background: rgba(10,132,255,.16); color: #69b0ff; }\n.chan.push { background: rgba(255,159,10,.15); color: #ffc15e; }\n.chan.chat { background: rgba(191,90,242,.16); color: #d79bff; }\n.chan.sms.wa { background: rgba(37,211,102,.2); color: #4be08a; }\n.svc-tag { font-size: 12px; color: var(--muted); }\n.empty-tl { padding: 60px; text-align: center; color: var(--muted); }\n.inspector { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0,0,0,.4); display: flex; flex-direction: column; }\n.inspector header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }\n.inspector header h3 { margin: 0; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.inspector .btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; font-size: 13px; }\n.inspector pre { margin: 0; flex: 1; overflow: auto; padding: 14px 16px; font: 12px/1.55 var(--mono); color: #cdd3df; white-space: pre-wrap; overflow-wrap: anywhere; }\n.inspector .kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }\n.inspector .kv span:nth-child(odd) { color: var(--muted); }\n.inspector .kv span:nth-child(even) { overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }\n\n\n/* \\u2500\\u2500 Sound toggle \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.icon-toggle { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 13px; }\n.icon-toggle[aria-pressed="true"] { color: var(--text); border-color: #3d4a66; }\n\n/* \\u2500\\u2500 Swipe gestures \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.swipe { position: relative; touch-action: pan-y; }\n.swipe > .swipe-card { position: relative; z-index: 1; will-change: transform; }\n.swipe.settling > .swipe-card, .settling.a-note { transition: transform .32s cubic-bezier(.2,.9,.25,1), opacity .32s ease; }\n.swipe-actions { position: absolute; inset: 0; display: flex; justify-content: flex-end; align-items: stretch; visibility: hidden; }\n.swipe.swiping > .swipe-actions, .swipe.open > .swipe-actions { visibility: visible; }\n.collapsing { overflow: hidden; transition: height .26s ease, margin .26s ease, padding .26s ease, opacity .2s ease !important; }\n\n/* iOS lock screen: Options / Clear behind a card */\n.ios-swipe .swipe-actions { gap: 8px; }\n.ios-swipe .swipe-actions button { width: 72px; border: 0; border-radius: 20px; background: rgba(246,246,246,.6); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: #000; font: 500 14px var(--ios); }\n.push-group { display: flex; flex-direction: column; gap: 8px; }\n.group-head { display: flex; align-items: center; gap: 8px; padding: 0 2px; animation: mbn-fadein .25s ease; }\n.group-head h3 { flex: 1; margin: 0; font: 700 20px/1.2 var(--ios); color: #fff; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.group-head button { border: 0; border-radius: 15px; background: rgba(246,246,246,.6); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: #000; font: 500 13px var(--ios); padding: 6px 12px; }\n.group-head button.x { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%; }\n.push-group[data-open="true"] .ios-swipe { animation: mbn-unstack .38s cubic-bezier(.2,.9,.3,1.1) backwards; }\n.push-group[data-open="true"] .ios-swipe:nth-child(3) { animation-delay: .03s; } .push-group[data-open="true"] .ios-swipe:nth-child(4) { animation-delay: .06s; }\n.stack-layers { cursor: pointer; border: 0; padding: 0; background: none; display: block; width: 100%; }\n.stack-layers .ios-stack-more:first-child { margin-top: -14px; }\n.lock.wake { animation: mbn-wake 1.1s ease-out; }\n.ios-overlay { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 0 14px; background: rgba(255,255,255,.28); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); animation: mbn-fadein .2s ease; }\n.ios-overlay.dark { background: rgba(0,0,0,.28); }\n.ios-overlay .ios-note { animation: mbn-lift .3s cubic-bezier(.2,.9,.3,1.2); box-shadow: 0 20px 40px rgba(0,0,0,.25); }\n.ios-menu { align-self: flex-start; width: 250px; border-radius: 14px; overflow: hidden; background: rgba(237,237,237,.86); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); box-shadow: 0 10px 40px rgba(0,0,0,.2); animation: mbn-lift .28s cubic-bezier(.2,.9,.3,1.2); }\n.ios-menu button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 11px 16px; border: 0; border-bottom: .5px solid rgba(60,60,67,.29); background: none; color: #000; font: 400 17px var(--ios); letter-spacing: -.02em; text-align: left; }\n.ios-menu button:last-child { border-bottom: 0; }\n.ios-menu button:active { background: rgba(0,0,0,.08); }\n.ios-overlay.dark .ios-menu { align-self: stretch; width: auto; }\n\n/* Android shade */\n.a-note { touch-action: pan-y; position: relative; }\n.a-settings { margin-top: 8px; display: grid; gap: 8px; animation: mbn-fadein .2s ease; }\n.a-settings .opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; border: 1px solid #49454f; font: 500 14px var(--android); color: #e6e1e5; background: none; text-align: left; }\n.a-settings .opt[aria-pressed="true"] { background: #4a4458; border-color: #d0bcff; }\n.a-settings .opt small { display: block; font-weight: 400; color: #cac4d0; font-size: 12px; }\n.a-settings .row { display: flex; justify-content: space-between; }\n.a-settings .row button { border: 0; background: none; color: #d0bcff; font: 500 14px var(--android); padding: 6px 4px; }\n.shade-actions button { padding: 8px 16px; border: 0; border-radius: 18px; background: #36343b; font: 500 14px var(--android); color: #e6e1e5; }\n\n/* Messages: thread swipe actions, page transitions, bubble times, tapbacks */\n.thread-swipe .swipe-actions { justify-content: space-between; }\n.thread-swipe .swipe-actions .side { display: flex; }\n.thread-swipe .swipe-actions button { width: 74px; border: 0; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: 400 13px var(--ios); }\n.act-unread { background: #007aff; } .act-pin { background: #ffcc00; } .act-mute { background: #5856d6; } .act-delete { background: #ff3b30; }\n.thread-swipe .thread { background: #fff; }\n.thread .name-line { display: flex; align-items: center; gap: 4px; min-width: 0; }\n.thread .flag { flex: none; color: rgba(60,60,67,.6); display: inline-flex; }\n.msgs.enter { animation: mbn-back .38s cubic-bezier(.2,.9,.25,1); }\n.convo.enter { animation: mbn-push .4s cubic-bezier(.2,.9,.25,1); box-shadow: -10px 0 30px rgba(0,0,0,.12); }\n.convo-body { --reveal: 0px; overflow-x: hidden; touch-action: pan-y; }\n.convo-body .bubble-row, .convo-body .stamp { transform: translateX(calc(-1 * var(--reveal))); }\n.convo-body.settling .bubble-row, .convo-body.settling .stamp { transition: transform .3s cubic-bezier(.2,.9,.25,1); }\n.bubble-row { position: relative; }\n.bubble-time { position: absolute; right: -66px; top: 50%; transform: translateY(-50%); width: 58px; color: rgba(60,60,67,.6); font-size: 12px; white-space: nowrap; }\n.bubble { touch-action: pan-y; -webkit-user-select: text; user-select: text; }\n.tapback { position: absolute; z-index: 2; top: -16px; right: -12px; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 15px; background: #007aff; color: #fff; display: grid; place-items: center; font: 700 13px/1 var(--ios); box-shadow: 0 0 0 2.5px #fff; animation: mbn-pop .35s cubic-bezier(.2,.9,.3,1.4); }\n.tapback-bar { align-self: flex-start; display: flex; gap: 4px; padding: 6px 8px; border-radius: 26px; background: rgba(233,233,235,.96); box-shadow: 0 8px 30px rgba(0,0,0,.18); animation: mbn-lift .28s cubic-bezier(.2,.9,.3,1.3); }\n.tapback-bar button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; color: #8e8e93; font: 700 16px/1 var(--ios); display: grid; place-items: center; }\n.tapback-bar button[aria-pressed="true"] { background: #007aff; color: #fff; }\n.ios-overlay .bubble { align-self: flex-start; max-width: 80%; animation: mbn-lift .28s cubic-bezier(.2,.9,.3,1.2); }\n\n/* Mail: hover actions, row swipe, toast */\n.mrow .hover-actions { display: none; flex: none; align-items: center; gap: 2px; margin-left: 8px; }\n.mrow .hover-actions .icon-btn { width: 32px; height: 32px; }\n.mrow:hover .hover-actions, .mrow:focus-within .hover-actions { display: flex; }\n.mrow:hover .date, .mrow:focus-within .date { display: none; }\n.mrow .star { cursor: pointer; }\n.mrow .star[aria-pressed="true"] { color: #f4b400; }\n.mrow-swipe { background: #188038; }\n.mrow-swipe .swipe-actions { justify-content: space-between; align-items: center; padding: 0 22px; color: #fff; }\n.toast { position: absolute; z-index: 20; left: 24px; bottom: 24px; display: flex; align-items: center; gap: 24px; min-width: 288px; max-width: calc(100% - 48px); padding: 14px 16px 14px 24px; border-radius: 4px; background: #303030; color: #f2f2f2; font: 400 14px var(--mail); box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px rgba(0,0,0,.14); animation: mbn-toast .25s cubic-bezier(0,0,.2,1); }\n.toast button { margin-left: auto; border: 0; background: none; color: #a8c7fa; font: 500 14px var(--mail); padding: 4px 8px; }\n.reader.enter, .mail-list.enter { animation: mbn-fadein .18s ease; }\n\n@keyframes mbn-fadein { from { opacity: 0; } to { opacity: 1; } }\n@keyframes mbn-headsup { from { opacity: 0; transform: translateY(-70px) scale(.98); } to { opacity: 1; transform: none; } }\n@keyframes mbn-unstack { from { opacity: 0; transform: translateY(-40px) scale(.94); } to { opacity: 1; transform: none; } }\n@keyframes mbn-wake { from { filter: brightness(.25); } to { filter: none; } }\n@keyframes mbn-lift { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }\n@keyframes mbn-push { from { transform: translateX(100%); } to { transform: none; } }\n@keyframes mbn-back { from { transform: translateX(-28%); filter: brightness(.92); } to { transform: none; filter: none; } }\n@keyframes mbn-toast { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }\n@keyframes mbn-pop { from { transform: scale(.6) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }\n@keyframes mbn-drop { from { transform: translateY(-30px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }\n@keyframes mbn-fade { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }\n@keyframes mbn-rowflash { from { background: #fef7e0; } to { background: #fff; } }\n@container (max-width: 980px) { .mail-nav { width: 72px; } .mail-nav .lbl, .mail-nav .n, .compose .lbl { display: none; } .mail-logo { width: auto; } .compose { padding: 0 16px; } .mrow .svc { display: none; } }\n@container (max-width: 640px) { .mail-nav, .mail-search, .cat-tabs, .mail-logo .lbl, .mail-toolbar .range { display: none; } .mail-main { margin-left: 8px; } .mrow .from { width: 110px; } .reader .subject-row, .sender-row { padding-left: 16px; } .mail-frame, .mail-text, .attachments, .reply-row, .details { margin-left: 16px; } .mail-frame { width: calc(100% - 32px); } .sender-row { flex-wrap: wrap; } .sender-row .who { flex-basis: calc(100% - 54px); } .sender-row .meta { flex-basis: 100%; padding-left: 54px; white-space: normal; } .reader h1 { font-size: 19px; line-height: 24px; } }\n\n/* \\u2500\\u2500 WhatsApp: the same phone, a different app \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.avatar.wa { background: linear-gradient(180deg,#5fe08b,#1daa61); }\n.thread .via-wa { flex: none; font: 600 10px/16px var(--ios); letter-spacing: .02em; color: #0a7a43; background: #d9fdd3; border-radius: 4px; padding: 0 5px; }\n.convo.wa { background: #efeae2; }\n.convo.wa .convo-nav { background: rgba(246,246,246,.96); }\n.convo.wa .convo-nav .back { color: #1daa61; }\n.convo.wa .convo-nav .back svg [stroke] { stroke: #1daa61; }\n.convo.wa .convo-nav .back svg [fill]:not([fill="none"]) { fill: #1daa61; }\n.convo.wa .convo-nav .avatar { background: linear-gradient(180deg,#5fe08b,#1daa61); }\n.convo.wa .convo-nav .back .badge { background: #1daa61; }\n.convo.wa .convo-nav .who { flex-direction: column; gap: 0; }\n.convo.wa .wa-sub { font: 400 11px/14px var(--ios); color: #1daa61; }\n.convo.wa .convo-body { background: #efeae2; }\n.convo.wa .stamp { width: max-content; max-width: 90%; margin: 12px auto 8px; padding: 3px 10px; border-radius: 8px; background: rgba(255,255,255,.92); color: #54656f; box-shadow: 0 1px .5px rgba(11,20,26,.13); }\n.convo.wa .bubble { background: #fff; border-radius: 8px; border-top-left-radius: 8px; font-size: 16px; line-height: 21px; padding: 6px 9px 7px; box-shadow: 0 1px .5px rgba(11,20,26,.13); }\n.convo.wa .bubble.tail { border-bottom-left-radius: 0; }\n.convo.wa .bubble.tail::before { left: -7px; width: 8px; height: 12px; background: #fff; border-radius: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); }\n.convo.wa .bubble.tail::after { display: none; }\n.convo.wa .wa-time { float: right; margin: 9px 0 -3px 10px; font: 400 11px/14px var(--ios); letter-spacing: 0; color: #667781; }\n.convo.wa .convo-input { background: #f6f6f6; }\n.convo.wa .convo-input .plus { background: none; }\n.convo.wa .convo-input .field-ios { background: #fff; border-color: #e2e2e2; }\n.convo.wa .otp-bar small { color: #1daa61; }\n\n/* \\u2500\\u2500 Chat: a team chat window \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.window.chat { background: #fff; color: #1d1c1d; font-family: "Lato", "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif; }\n.window.chat .chrome { flex: none; }\n.chat-body { flex: 1; min-height: 0; display: flex; }\n.chat-side { flex: none; width: 200px; background: #2f1d3a; color: #cfc3d4; padding: 0 8px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }\n.chat-team { display: flex; align-items: center; gap: 4px; padding: 14px 8px 12px; margin: 0 -8px 8px; border-bottom: 1px solid rgba(255,255,255,.1); color: #fff; font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.chat-side-label { padding: 6px 8px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }\n.chat-chan { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; color: inherit; text-align: left; padding: 4px 8px; border-radius: 6px; font-size: 14px; min-width: 0; }\n.chat-chan:hover { background: rgba(255,255,255,.08); }\n.chat-chan .hash { opacity: .7; width: 12px; text-align: center; flex: none; }\n.chat-chan .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.chat-chan .n { flex: none; background: #e01e5a; color: #fff; border-radius: 999px; font-size: 11px; line-height: 16px; padding: 0 6px; font-weight: 700; }\n.chat-chan.unread { color: #fff; font-weight: 700; }\n.chat-chan.on { background: #5b3a70; color: #fff; }\n.chat-chan:focus-visible { outline: 2px solid #9ec5ff; outline-offset: -2px; }\n.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }\n.chat-head { flex: none; display: flex; align-items: baseline; gap: 10px; padding: 12px 18px; border-bottom: 1px solid #e3e3e3; }\n.chat-head b { font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.chat-head span { color: #616061; font-size: 12px; white-space: nowrap; }\n.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 12px; display: flex; flex-direction: column; }\n.chat-list > :first-child { margin-top: auto; }\n.chat-day { display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: #616061; font-size: 12px; font-weight: 700; }\n.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: #e3e3e3; }\n.chat-day span { border: 1px solid #e3e3e3; border-radius: 999px; padding: 2px 12px; }\n.chat-msg { display: flex; gap: 10px; padding: 7px 18px; outline: 0; }\n.chat-msg:hover, .chat-msg:focus-visible { background: #f8f8f8; }\n.chat-msg[data-unread="true"] { background: #fffbea; }\n.chat-msg[data-ephemeral="true"] { background: #f6f6f6; }\n.chat-msg.arrive { animation: mbn-chat-in .3s ease-out; }\n@keyframes mbn-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }\n.chat-avatar { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }\n.chat-msg-main { flex: 1; min-width: 0; font-size: 15px; line-height: 22px; }\n.chat-meta { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }\n.chat-meta b { font-weight: 800; }\n.chat-app { background: #e8e8e8; color: #555; font-size: 10px; font-weight: 700; border-radius: 3px; padding: 0 4px; line-height: 14px; align-self: center; }\n.chat-time, .chat-edited { color: #616061; font-size: 12px; }\n.chat-note { color: #616061; font-size: 12px; line-height: 16px; }\n.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }\n.chat-text a, .chat-att-title a { color: #1264a3; text-decoration: none; }\n.chat-text a:hover { text-decoration: underline; }\n.chat-code { font: 12px/18px var(--mono); background: #f4f4f4; border: 1px solid #dcdcdc; border-radius: 3px; padding: 1px 3px; color: #c0143c; }\n.chat-pre { font: 12px/18px var(--mono); background: #f7f7f7; border: 1px solid #dcdcdc; border-radius: 4px; padding: 8px; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }\n.chat-mention { background: #e8f1fa; color: #1264a3; border-radius: 3px; padding: 0 2px; }\n.chat-quote { display: block; border-left: 4px solid #ddd; padding-left: 10px; margin: 2px 0; }\n.chat-blocks, .chat-attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }\n.chat-block-header { font-size: 18px; font-weight: 800; line-height: 24px; }\n.chat-block-divider hr { border: 0; border-top: 1px solid #e3e3e3; margin: 4px 0; }\n.chat-block-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #616061; font-size: 13px; }\n.chat-block-actions { display: flex; flex-wrap: wrap; gap: 8px; }\n.chat-block.with-accessory { display: flex; gap: 12px; align-items: flex-start; }\n.chat-section-body { flex: 1; min-width: 0; }\n.chat-accessory { flex: none; }\n.chat-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 4px; }\n.chat-btn { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border: 1px solid #bbb; border-radius: 4px; background: #fff; font-size: 13px; font-weight: 700; color: #1d1c1d; }\n.chat-btn.primary { background: #007a5a; border-color: #007a5a; color: #fff; }\n.chat-btn.danger { color: #e01e5a; }\n.chat-thumb { width: 72px; height: 72px; border-radius: 6px; object-fit: cover; display: block; }\n.chat-block-context .chat-thumb { width: 20px; height: 20px; border-radius: 3px; }\n.chat-image { max-width: min(360px, 100%); max-height: 260px; border-radius: 6px; display: block; }\n.chat-caption { color: #616061; font-size: 13px; }\n.chat-list-block { margin: 2px 0; padding-left: 22px; }\n.chat-unknown { color: #616061; font: 12px var(--mono); border: 1px dashed #ccc; border-radius: 4px; padding: 2px 6px; }\n.chat-attachment { border-left: 4px solid #ddd; padding-left: 12px; display: flex; flex-direction: column; gap: 2px; }\n.chat-att-author { font-size: 13px; font-weight: 700; }\n.chat-att-title { font-weight: 700; }\n.chat-field { margin-top: 4px; }\n.chat-field:not(.short) { grid-column: 1 / -1; }\n.chat-att-footer { color: #616061; font-size: 12px; }\n.chat-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }\n.chat-reaction { background: #f0f0f0; border: 1px solid #e0e0e0; border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 22px; }\n.chat-compose { flex: none; display: flex; align-items: center; justify-content: space-between; margin: 0 18px 16px; padding: 0 12px; height: 42px; border: 1px solid #bbb; border-radius: 8px; color: #8a8a8a; font-size: 14px; }\n.chat-compose span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.chat-compose .send { display: grid; place-items: center; opacity: .5; }\n.chat-empty { margin: auto; padding: 40px 28px; text-align: center; color: #616061; display: flex; flex-direction: column; gap: 6px; max-width: 380px; }\n.chat-empty b { color: #1d1c1d; font-size: 16px; }\n@container (max-width: 560px) { .chat-side { display: none; } .chat-msg, .chat-head, .chat-day { padding-left: 12px; padding-right: 12px; } .chat-compose { margin: 0 12px 12px; } .chat-fields { grid-template-columns: 1fr; } }\n@media (max-width: 760px) { .devices { padding: 16px 8px; } .device-col.wide { flex-basis: 100%; } }\n`,ka=Ue(gn,`.${at}`);var Ta={all:"All",sms:"Text",push:"Push",email:"Email",chat:"Chat"},xn=.5,nt=a=>typeof a=="number"&&Number.isFinite(a)?Math.max(xn,Math.min(1,a)):1,Sa=(a,o,d=1)=>a==="tabs"||a==="auto"&&o>0&&o/d<800,Ma=(a,o=1)=>Math.max(.5,Math.min(1,(a/o-16)/362)),Ct=(a,o)=>a.length<2?[]:o?[...a]:["all",...a],Aa=(a,o,d,h)=>d&&a.includes(d)?d:a.length===1&&a[0]?a[0]:o?(h&&a.includes(h)?h:a[0])??"all":"all",La=(a,o,d)=>{if(!a.length)return null;let h=Math.max(0,a.indexOf(o)),g=d==="ArrowRight"||d==="ArrowDown"?(h+1)%a.length:d==="ArrowLeft"||d==="ArrowUp"?(h-1+a.length)%a.length:d==="Home"?0:d==="End"?a.length-1:-1;return g<0?null:a[g]??null};var Ca=[{id:"heart",glyph:"\\u2665",label:"Heart"},{id:"like",glyph:"\\u{1F44D}",label:"Like"},{id:"dislike",glyph:"\\u{1F44E}",label:"Dislike"},{id:"laugh",glyph:"HA<br>HA",label:"Laugh"},{id:"emphasize",glyph:"\\u203C",label:"Emphasize"},{id:"question",glyph:"?",label:"Question"}];function it(a,o={}){let d=o.live??!0,h=o.syncUrl??(d&&!o.fetch&&!o.baseUrl),g=o.storage??d,v=o.now,$=()=>v??Date.now(),H=o.baseUrl??(o.fetch||typeof location>"u"?"http://harness.local/":location.href),y=(e,t)=>{let s=new Request(new URL(e,H),t);return o.fetch?o.fetch(s):fetch(s)},E=new AbortController,D=(e,t,s=!1)=>a.addEventListener(e,t,{signal:E.signal,capture:s}),W=new Set,F=(e,t)=>{let s=setTimeout(()=>{W.delete(s),t()},e);W.add(s)},O=!1,V=new URLSearchParams(o.search??(h&&typeof location<"u"?location.search:"")),ne=V.get("view"),_=o.initial??{},i={namespace:V.get("namespace")??o.namespace??"default",namespaces:[],items:[],sources:[],discoveryError:null,version:0,view:ne==="timeline"?"timeline":"devices",only:le.includes(ne??"")?ne:null,search:"",follow:V.get("follow")!=="0",connected:!1,sms:{to:null,thread:null,menu:null,transition:null},push:{to:null,skin:"auto",expanded:null,preview:null,settings:null,wake:!1},email:{to:null,open:null,transition:!1},chat:{to:null},inspect:null,toast:null,arrived:new Set(o.arrived??[])};Object.assign(i,{..._,sms:{...i.sms,..._.sms},push:{...i.push,..._.push},email:{...i.email,..._.email},chat:{...i.chat,..._.chat},toast:_.toast?{text:_.toast}:null}),ne==="timeline"&&(i.view="timeline"),delete i.local,delete i.push.openGroups;let M={dismissed:new Set(_.local?.dismissed??[]),pinned:new Set(_.local?.pinned??[]),muted:new Set(_.local?.muted??[]),starred:new Set(_.local?.starred??[]),silent:new Set(_.local?.silent??[]),checked:new Set,tapbacks:new Map(Object.entries(_.local?.tapbacks??{})),openGroups:new Set(_.push?.openGroups??[])},he=_.mailDetailsOpen??!1,Be=V.get("to"),rt=V.get("from"),ue=V.get("id"),q=Be&&i.only?{channel:i.only,to:Be}:null;V.get("follow")===null&&q&&(i.follow=!1);let fe=le.filter(e=>o.channels===void 0||o.channels.includes(e)),Ee=o.layout??"auto",b=nt(o.scale),z=Ee==="tabs",C=i.only,L=()=>Aa(fe,z,i.only,C),U=()=>{let e=a.clientWidth;a.style.setProperty("--mbn-scale",String(b)),e>0&&a.style.setProperty("--mbn-fit",String(Ma(e,b)));let t=Sa(o.tabs===!1&&Ee==="auto"?"grid":Ee,e,b);return t===z?!1:(z=t,!0)},De=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Et=()=>(o.motion??"auto")==="auto"?De()?"reduce":"full":o.motion,ce=()=>Et()==="full",Dt="mockingbird-notifications:sound",Na=()=>{if(!g)return null;try{let e=localStorage.getItem(Dt);return e===null?null:e==="1"}catch{return null}},ie=ya(V.get("sound")!==null?V.get("sound")==="1":Na()??o.sound??!1),Nt=()=>`mockingbird-notifications:seen:${i.namespace}`,B=new Set(o.seen??[]),Ht=()=>{if(g)try{B=new Set(JSON.parse(localStorage.getItem(Nt())??"[]"))}catch{B=new Set}},Rt=()=>{if(g)try{localStorage.setItem(Nt(),JSON.stringify([...B].slice(-5e3)))}catch{}},Se=e=>{let t=!1;for(let s of e)B.has(s)||(B.add(s),t=!0);t&&Rt()},lt=e=>{for(let t of e)B.delete(t);Rt()},r=e=>String(e??"").replace(/[&<>"\']/g,t=>`&#${t.charCodeAt(0)};`),p=e=>`data-testid="${e}"`,be=e=>`data-notification-id="${r(e.id)}" data-channel="${e.channel}" data-service="${r(e.service)}" data-source="${r(e.source)}" data-to="${r(e.to)}" data-from="${r(e.from.address)}" data-status="${r(e.status??"")}" data-created-at="${r(e.createdAt)}" data-unread="${!B.has(e.id)}"${ge(e)?\' data-via="whatsapp"\':""}`,ge=e=>e?.sms?.via==="whatsapp",jt=e=>e.replace(/\\bhttps?:\\/\\/[^\\s<]+[^\\s<.,;:!?)\'"]/g,t=>`<a href="${t}" target="_blank" rel="noreferrer">${t}</a>`),dt=e=>{let t=/^\\+1(\\d{3})(\\d{3})(\\d{4})$/.exec(e);return t?`+1 (${t[1]}) ${t[2]}-${t[3]}`:e},Ot=e=>/^\\+?\\d[\\d\\s()-]{5,}$/.test(e),Pt=e=>e.replace(/^whatsapp:/i,""),Fe=e=>{let t=Pt(e.from.address);return e.from.name??(Ot(t)?dt(t):t)},Ne=e=>{let t=e.replace(/[^\\p{L}\\p{N}\\s]/gu," ").trim().split(/\\s+/).filter(Boolean);return t.length?((t[0]?.[0]??"")+(t[1]?.[0]??"")).toUpperCase():"?"},Ha=["#1a73e8","#e8710a","#188038","#d93025","#9334e6","#12b5cb","#e52592","#f9ab00","#5f6368","#a142f4"],ct=["#ff9500","#34c759","#5856d6","#ff2d55","#007aff","#af52de","#ff3b30","#30b0c7"],Ra=e=>[...e].reduce((t,s)=>t*31+s.charCodeAt(0)>>>0,7),He=(e,t=Ha)=>t[Ra(e)%t.length]??"#5f6368",xe=(e,t)=>e.toDateString()===t.toDateString(),se=e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),ja=e=>{let t=new Date(e),s=new Date($());if(xe(t,s))return se(t);let c=new Date(s);return c.setDate(s.getDate()-1),xe(t,c)?"Yesterday":s.getTime()-t.getTime()<6*864e5?t.toLocaleDateString([],{weekday:"long"}):t.toLocaleDateString([],{year:"2-digit",month:"numeric",day:"numeric"})},Oa=e=>{let t=new Date(e),s=new Date($());return xe(t,s)?`<b>Today</b> ${se(t)}`:`<b>${r(t.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}))}</b> at ${se(t)}`},pt=e=>{let t=Math.max(0,($()-Date.parse(e))/1e3);return t<60?"now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`},Pa=e=>{let t=Math.max(0,($()-Date.parse(e))/1e3);return t<60?"now":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`},Ia=e=>{let t=new Date(e);return xe(t,new Date($()))?t.toLocaleTimeString():t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...t.getFullYear()===new Date($()).getFullYear()?{}:{year:"numeric"}})},_a=e=>{let t=new Date(e),s=new Date($());return xe(t,s)?se(t):t.getFullYear()===s.getFullYear()?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleDateString([],{year:"2-digit",month:"numeric",day:"numeric"})},Ua=e=>`${new Date(e).toLocaleString([],{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})} (${pt(e)==="now"?"0 minutes ago":pt(e)})`,Me={twilio:"Twilio",resend:"Resend",fcm:"FCM",ses:"SES",sns:"SNS",customerio:"Customer.io",mailosaur:"Mailosaur",slack:"Slack"},Ba={sms:"SMS",push:"Push",email:"Email",chat:"Chat"},Fa=e=>{let t=i.search.trim().toLowerCase();return t?[e.to,e.from.address,e.from.name??"",e.preview,e.email?.subject??"",e.push?.title??"",e.source,e.service].join(`\n`).toLowerCase().includes(t):!0},It=()=>i.items.filter(Fa),ee=e=>It().filter(t=>t.channel===e&&!M.dismissed.has(t.id)),Ve=e=>{let t=new Map;for(let s of ee(e)){let c=t.get(s.to)??{to:s.to,count:0,unread:0,latest:s.createdAt};c.count++,B.has(s.id)||c.unread++,s.createdAt>c.latest&&(c.latest=s.createdAt),s.push&&(c.platform=s.push.platform),t.set(s.to,c)}return[...t.values()].sort((s,c)=>s.latest<c.latest?1:-1)},mt=()=>{for(let e of le){let t=Ve(e),s=i[e];if(q?.channel===e){s.to=q.to;continue}(!s.to||!t.some(c=>c.to===s.to))&&(s.to=t[0]?.to??null)}},ht=async e=>{let t=await y(e);if(!t.ok)throw new Error(`${e}: HTTP ${t.status}`);return await t.json()},qe=async()=>{let e=new URLSearchParams({namespace:i.namespace,order:"newest"}),t=await ht(`./api/notifications?${e}`);O||(i.items=t.notifications,i.version=t.version??i.version,mt(),J())},_t=async()=>{try{let e=await ht("./api/sources");i.sources=e.sources,i.discoveryError=e.discoveryError;let t=await ht("./api/namespaces");i.namespaces=t.namespaces,O||ve()}catch{}},Ae=(e,t)=>`${e}|${t}`,We=null,ut=(e,t)=>`${e}|${t}`,Va=e=>{if(e.channel==="sms")return M.muted.has(Ae(e.to,e.from.address))?null:"sms";if(e.channel==="email")return"email";if(e.channel==="chat")return"chat";let t=i.push.skin==="auto"?e.push?.platform==="android"?"android":"ios":i.push.skin;return t==="android"&&M.silent.has(e.push?.app??"App")?null:t==="android"?"push-android":"push-ios"},qa=e=>{for(let n of e)i.arrived.add(n.id);let t=[...e].sort((n,f)=>n.createdAt<f.createdAt?1:-1);for(let n of le){let f=t.filter(x=>x.channel===n),w=q?.channel===n?f.find(x=>x.to===q.to):f[0];w&&(q?.channel===n?n==="sms"&&!i.sms.thread&&(i.sms.thread=w.from.address):i.follow&&(i[n].to=w.to,n==="sms"&&i.sms.thread!==null&&(i.sms.thread=w.from.address)),n==="push"&&i.push.to===w.to&&(i.push.wake=!0))}let s=We&&t.find(n=>n.channel==="sms"&&n.to===We);s&&(i.sms.to=s.to,i.sms.thread=s.from.address,We=null);let c=new Set(e.map(Va).filter(n=>n!==null));for(let n of c)ie.play(n);o.onArrive?.(e),F(1800,()=>{for(let n of e)i.arrived.delete(n.id)})},ft=null,Ut=()=>{ft?.abort();let e=new AbortController;ft=e;let t=i.namespace,s=(n,f)=>{if(!e.signal.aborted){if(n==="sources")i.sources=JSON.parse(f),ve();else if(n==="change"){let{added:w,version:x}=JSON.parse(f);i.version=x,qa(w),qe().catch(()=>{})}}};(async()=>{for(;!e.signal.aborted;){try{let n=await y(`./api/events?namespace=${encodeURIComponent(t)}`,{signal:e.signal,headers:{accept:"text/event-stream"}});if(!n.ok||!n.body)throw new Error(`events: HTTP ${n.status}`);i.connected=!0,ve();let f=n.body.pipeThrough(new TextDecoderStream).getReader(),w="";for(;;){let{value:x,done:S}=await f.read();if(S)break;w+=x.replace(/\\r\\n/g,`\n`);let k=w.indexOf(`\n\n`);for(;k>=0;){let m=w.slice(0,k);w=w.slice(k+2);let T="message",I=[];for(let j of m.split(`\n`))j.startsWith("event:")?T=j.slice(6).trim():j.startsWith("data:")&&I.push(j.slice(5).trimStart());I.length&&s(T,I.join(`\n`)),k=w.indexOf(`\n\n`)}}}catch{}if(e.signal.aborted)return;i.connected=!1,ve(),await new Promise(n=>F(1e3,()=>n(null)))}})()},pe=`mbn-${Math.random().toString(36).slice(2,8)}`;a.classList.add(at),o.embedded&&a.classList.add("embedded"),a.dataset.testid=l.app,a.dataset.ready="false",a.innerHTML=`\n<header class="topbar" data-region="topbar" ${p(l.topbar)}></header>\n<div data-region="notice"></div>\n<div class="channel-tabs" data-region="tabs" role="tablist" aria-label="Notification channels" ${p(l.channelTabs)} hidden></div>\n<div class="mbn-scroll" data-region="scroll">\n<section class="devices" data-region="devices">\n <div class="device-col" data-region="col-sms" id="${pe}-panel-sms"></div>\n <div class="device-col" data-region="col-push" id="${pe}-panel-push"></div>\n <div class="device-col wide" data-region="col-email" id="${pe}-panel-email"></div>\n <div class="device-col wide chat-col" data-region="col-chat" id="${pe}-panel-chat"></div>\n</section>\n<section class="timeline" data-region="timeline" hidden></section>\n</div>\n<aside class="inspector" data-region="inspector" ${p(l.inspector)} hidden></aside>`;let Z=e=>a.querySelector(`[data-region="${e}"]`),Bt=e=>a.querySelector(`[data-testid="${e}"]`),Ft=()=>o.title??a.dataset.title??"Notifications",Wa=()=>{Object.assign(a.dataset,{view:i.view,namespace:i.namespace,count:String(i.items.length),version:String(i.version),connected:String(i.connected),sound:String(ie.enabled),motion:Et(),layout:z?"tabs":"grid",tab:L()})},ve=()=>{Wa();let e=Z("topbar");if(e.hidden=o.chrome===!1,o.chrome===!1)return;let t=[...new Set([...i.namespaces,i.namespace])].sort(),s=document.activeElement===Bt(l.search);if(e.innerHTML=`\n <div class="brand"><span class="brand-mark">${u.bell()}</span><span>${r(Ft())} <small>Mockingbird</small></span></div>\n <label class="field">Namespace <select data-action="namespace" ${p(l.namespace)} aria-label="Namespace">${t.map(n=>`<option ${n===i.namespace?"selected":""}>${r(n)}</option>`).join("")}</select></label>\n <div class="field search">${u.search("#9aa1b1",14)}<input type="search" data-action="search" ${p(l.search)} aria-label="Filter notifications" placeholder="Filter by recipient, sender, text\\u2026" value="${r(i.search)}"></div>\n <div class="tabs" role="group" aria-label="View">\n <button data-action="view" data-value="devices" ${p(l.viewDevices)} aria-pressed="${i.view==="devices"}">Devices</button>\n <button data-action="view" data-value="timeline" ${p(l.viewTimeline)} aria-pressed="${i.view==="timeline"}">Timeline <span style="opacity:.6">${i.items.length}</span></button>\n </div>\n <label class="toggle" title="Jump each device to the newest arrival"><input type="checkbox" data-action="follow" ${p(l.follow)} ${i.follow?"checked":""}> Follow new</label>\n <button class="icon-toggle" data-action="sound" ${p(l.sound)} aria-pressed="${ie.enabled}" title="Play alert sounds on arrivals">${ie.enabled?u.volumeOn():u.volumeOff()}<span>Sound</span></button>\n <span class="live" ${p(l.connection)} data-state="${i.connected?"live":"reconnecting"}" role="status"><span class="dot ${i.connected?"ok":"bad"}"></span>${i.connected?"Live":"Reconnecting"}</span>\n <div class="sources">${i.sources.map(n=>`<span class="pill" title="${r(n.error??n.url)}" ${p(l.source)} data-name="${r(n.name)}" data-service="${r(n.service??"")}" data-ok="${n.ok}" data-count="${n.count}"><span class="dot ${n.ok?"ok":n.error?"bad":""}"></span>${r(n.service&&n.name!==n.service?`${n.name} \\xB7 ${Me[n.service]??n.service}`:Me[n.name]??n.name)} <b>${n.count}</b></span>`).join("")}</div>`,s){let n=Bt(l.search);n?.focus(),n?.setSelectionRange(n.value.length,n.value.length)}let c=i.sources.filter(n=>n.error);Z("notice").innerHTML=i.discoveryError||c.length?`<div class="notice" ${p(l.notice)} data-kind="error" role="alert">${i.discoveryError?`Fleet discovery failed: ${r(i.discoveryError)}. `:""}${c.map(n=>`<b>${r(n.name)}</b>: ${r(n.error)}`).join(" \\xB7 ")}</div>`:i.sources.length?"":`<div class="notice" ${p(l.notice)} data-kind="empty" style="border-color:#3a3f4b;background:#171a21;color:#9aa1b1">No messaging emulators found yet. Start the fleet with twilio, resend, fcm, ses, sns, customerio, mailosaur or slack.</div>`},Ge=(e,t,s,c)=>{let n=Ve(e),f=i[e].to;return`<label class="field">${t}<select data-action="recipient" data-channel="${e}" ${p(s)} aria-label="${t}" ${n.length?"":"disabled"}>${n.length?n.map(w=>`<option value="${r(w.to)}" ${w.to===f?"selected":""}>${w.unread?"\\u25CF ":""}${r(c(w.to))} \\xB7 ${w.count}</option>`).join(""):"<option>No recipients yet</option>"}</select></label>`},Ke=(e,t)=>e?`<span class="count" ${p(t)} data-count="${e}">${e}</span>`:"",Ye=(e,t,s,c="")=>`<div class="device-head"><div class="head-row"><h2>${e} ${t}</h2>${c}</div>${s}</div>`,Vt=(e=!1)=>`\n <div class="statusbar ${e?"light":""}"><span>${se(new Date($())).replace(/\\s?[AP]M$/i,"")}</span>\n <span class="icons">${u.signal()}${u.wifi()}${u.battery()}</span></div>`,qt=e=>e.currentCSSZoom||1,bt=(e,t)=>{if(!ce()||typeof e.animate!="function")return t();let s=new Map;for(let c of e.querySelectorAll("[data-flip]"))s.set(c.dataset.flip??"",c.getBoundingClientRect().top);t();for(let c of e.querySelectorAll("[data-flip]")){let n=s.get(c.dataset.flip??"");if(n===void 0)continue;let f=(n-c.getBoundingClientRect().top)/qt(c);Math.abs(f)<1||c.animate([{transform:`translateY(${f}px)`},{transform:"none"}],{duration:380,easing:"cubic-bezier(.2,.9,.25,1)"})}},gt=e=>{let t=new Map;for(let s of ee("sms").filter(c=>c.to===e)){let c=s.from.address;t.set(c,[...t.get(c)??[],s])}return[...t.entries()].map(([s,c])=>({from:s,items:c.sort((n,f)=>n.createdAt<f.createdAt?-1:1),pinned:M.pinned.has(Ae(e,s))})).sort((s,c)=>s.pinned!==c.pinned?s.pinned?-1:1:(s.items.at(-1)?.createdAt??"")<(c.items.at(-1)?.createdAt??"")?1:-1)},Wt=e=>{let t=e?Fe(e):"";return Ot(Pt(e?.from.address??""))&&!e?.from.name?u.person():r(Ne(t))},xt=e=>e.sms?.code??(/\\b(code|otp|passcode|pin|verif)/i.test(e.sms?.body??"")?/\\b(\\d{4,8})\\b/.exec(e.sms?.body??"")?.[1]??null:null),Ga=(e,t)=>t?e.replace(new RegExp(`\\\\b${t}\\\\b`),`<span class="code">${t}</span>`):e,Ka=e=>{let t=M.tapbacks.get(e),s=Ca.find(c=>c.id===t);return s?`<span class="tapback" ${p(l.smsTapback)} data-tapback="${s.id}" aria-label="${s.label}">${s.glyph}</span>`:""},Gt=e=>{let t=Ga(jt(r(e.sms?.body??"")),xt(e));return(e.sms?.media??[]).map(c=>`<img class="media" src="${r(c)}" alt="" ${p(l.smsBubbleMedia)}>`).join("")+t},ae=()=>{let e=i.sms.to,t=e?gt(e):[],s=ee("sms").filter(k=>!B.has(k.id)).length,c,n=t.find(k=>k.from===i.sms.thread),f=i.sms.transition;if(i.sms.transition=null,n&&e){Se(n.items.map(Y=>Y.id));let k=n.items[0],m=ge(k),T=t.filter(Y=>Y!==n).reduce((Y,Ce)=>Y+Ce.items.filter(ye=>!B.has(ye.id)).length,0),I=0,j=!0,K=n.items.map((Y,Ce)=>{let ye=Date.parse(Y.createdAt),ha=Ce===0||ye-I>15*6e4?`<div class="stamp" ${p(l.smsTimestamp)}>${Ce===0?m?"WhatsApp<br>":"Text Message<br>":""}${Oa(Y.createdAt)}</div>`:"",ua=n.items[Ce+1],fa=!ua||Date.parse(ua.createdAt)-ye>6e4,ln=!ha&&j&&Ce>0;I=ye,j=fa;let ba=xt(Y);return`${ha}<div class="bubble-row ${ln?"gap":""}"><div class="bubble ${fa?"tail":""} ${i.arrived.has(Y.id)?"arrive":""}" ${be(Y)} ${p(l.smsBubble)} ${ba?`data-code="${r(ba)}"`:""} data-longpress="sms-bubble" tabindex="0" aria-haspopup="menu">${Gt(Y)}${m?`<span class="wa-time">${r(se(new Date(ye)))}</span>`:""}${Ka(Y.id)}</div><span class="bubble-time" ${p(l.smsBubbleTime)} aria-hidden="true">${r(se(new Date(ye)))}</span></div>`}).join(""),oe=n.items.at(-1),$e=oe?xt(oe):null,ma=i.sms.menu?n.items.find(Y=>Y.id===i.sms.menu):null,rn=M.muted.has(Ae(e,n.from));c=`<div class="convo ${m?"wa":""} ${f==="push"&&ce()?"enter":""}" ${p(l.smsConversation)} data-from="${r(n.from)}" data-via="${m?"whatsapp":"sms"}">\n <div class="convo-nav"><div class="bar">\n <button class="back" data-action="sms-back" ${p(l.smsBack)} aria-label="Back to Messages">${u.chevronBack()}${T?`<span class="badge">${T}</span>`:""}</button>\n <div class="avatar">${Wt(k)}</div>\n <div class="who"><span ${p(l.smsConversationTitle)}>${r(k?Fe(k):n.from)}</span>${rn?` <span class="flag">${u.bellSlash(12)}</span>`:""} ${m?\'<small class="wa-sub">WhatsApp</small>\':u.chevronRight("#8e8e93")}</div>\n </div></div>\n <div class="convo-body" data-swipe="sms-convo">${K}</div>\n ${$e&&oe&&$()-Date.parse(oe.createdAt)<10*6e4?`<button class="qt" data-action="sms-copy-code" data-code="${r($e)}" ${p(l.smsCode)}><small>From ${m?"WhatsApp":"Messages"}</small>${r($e)}</button>`:""}\n <div class="convo-input"><span class="plus">${u.plus()}</span><span class="field-ios">${m?"Message":"Text Message"}<span>${u.mic()}</span></span></div>\n ${ma?Ya(ma):""}\n </div>`}else i.sms.thread=null,i.sms.menu=null,c=`<div class="msgs ${f==="back"&&ce()?"enter":""}">\n <div class="msgs-nav"><div class="row"><span>Edit</span>${u.compose()}</div><h1>Messages</h1>\n <div class="ios-search">${u.search("rgba(60,60,67,.6)",15)}<span>Search</span>${u.mic("rgba(60,60,67,.6)")}</div></div>\n ${t.length&&e?`<div class="threads" role="list">${t.map(k=>{let m=k.items.at(-1),T=k.items.some($e=>!B.has($e.id)),I=Ae(e,k.from),j=M.muted.has(I),K=m?Fe(m):k.from,oe=ge(m);return`<div class="swipe thread-swipe" data-swipe="sms-thread" data-from="${r(k.from)}" data-flip="thread:${r(k.from)}" role="listitem">\n <div class="swipe-actions">\n <div class="side"><button class="act-unread" data-action="thread-unread" data-from="${r(k.from)}" ${p(l.smsThreadToggleUnread)}>${T?u.markRead(22):u.markUnread(22)}${T?"Read":"Unread"}</button><button class="act-pin" data-action="thread-pin" data-from="${r(k.from)}" ${p(l.smsThreadPin)}>${u.pin(22)}${k.pinned?"Unpin":"Pin"}</button></div>\n <div class="side"><button class="act-mute" data-action="thread-mute" data-from="${r(k.from)}" ${p(l.smsThreadMute)}>${u.bellSlash(22)}${j?"Show Alerts":"Hide Alerts"}</button><button class="act-delete" data-action="thread-delete" data-from="${r(k.from)}" ${p(l.smsThreadDelete)}>${u.trash()}Delete</button></div>\n </div>\n <div class="thread swipe-card" data-action="sms-open" data-from="${r(k.from)}" ${p(l.smsThread)} ${m?be(m):""} data-unread="${T}" data-pinned="${k.pinned}" data-muted="${j}" role="button" tabindex="0" aria-label="${r(K)}${oe?", WhatsApp":""}${T?", unread":""}">\n ${T?`<span class="unread" ${p(l.smsThreadUnread)}></span>`:""}<div class="avatar ${oe?"wa":""}">${Wt(m)}</div>\n <div class="text"><div class="top"><span class="name-line"><span class="name" ${p(l.smsThreadName)}>${r(K)}</span>${oe?`<span class="via-wa" ${p(l.smsThreadVia)}>WhatsApp</span>`:""}${k.pinned?`<span class="flag">${u.pin(13)}</span>`:""}${j?`<span class="flag">${u.bellSlash(13)}</span>`:""}</span><span class="when" ${p(l.smsThreadTime)}>${r(ja(m?.createdAt??""))} ${u.chevronRight()}</span></div>\n <div class="preview" ${p(l.smsThreadPreview)}>${r(m?.sms?.body??"")}</div></div></div></div>`}).join("")}</div>`:`<div class="empty-ios" ${p(l.smsEmpty)}>${e?"No Messages":"No text messages yet.<br><br>SMS sent through Twilio, SNS, Customer.io or Mailosaur, and WhatsApp sent through Twilio, show up here."}</div>`}\n </div>`;let w=Z("col-sms");bt(w,()=>{w.innerHTML=`\n ${Ye("Text messages",Ke(s,l.smsUnreadCount),Ge("sms","Phone",l.smsRecipient,dt))}\n <div class="iphone" ${p(l.smsDevice)} data-screen="${n?"conversation":"threads"}" data-recipient="${r(e??"")}" data-thread="${r(n?.from??"")}"${n&&ge(n.items[0])?\' data-via="whatsapp"\':""}><div class="screen"><div class="island"></div>${Vt()}${c}<div class="home-indicator"></div></div></div>`});let x=w.querySelector(".convo-body"),S=()=>{x&&(x.scrollTop=x.scrollHeight)};S(),requestAnimationFrame(S),je()},Ya=e=>{let t=M.tapbacks.get(e.id);return`<div class="ios-overlay" data-action="close-overlay" ${p(l.smsMenu)} data-notification-id="${r(e.id)}" role="dialog" aria-label="Message actions">\n <div class="tapback-bar" role="toolbar" aria-label="Tapback">${Ca.map(s=>`<button data-action="tapback" data-id="${r(e.id)}" data-value="${s.id}" ${p(l.smsMenuTapback)} data-tapback="${s.id}" aria-label="${s.label}" aria-pressed="${t===s.id}">${s.glyph}</button>`).join("")}</div>\n <div class="bubble tail">${Gt(e)}</div>\n <div class="ios-menu" role="menu">\n <button role="menuitem" data-action="close-overlay">Reply</button>\n <button role="menuitem" data-action="sms-copy" data-id="${r(e.id)}" ${p(l.smsMenuCopy)}>Copy</button>\n <button role="menuitem" data-action="close-overlay">Translate</button>\n <button role="menuitem" data-action="close-overlay">More\\u2026</button>\n </div></div>`},Kt=e=>{let t=e.push?.data??{};return Object.keys(t).length?`<div class="note-data" ${p(l.pushNotificationData)}>${r(JSON.stringify(t,null,2))}</div>`:""},Yt=e=>`<div class="note-meta" ${p(l.pushNotificationMeta)}>${r(Me[e.service]??e.service)} \\xB7 ${r(e.status??"accepted")}${e.push?.badge!==null&&e.push?.badge!==void 0?` \\xB7 badge ${e.push.badge}`:""}${e.push?.sound?` \\xB7 sound ${r(e.push.sound)}`:""}</div>`,Zt=(e,t={})=>`${be(e)} ${p(l.pushNotification)} data-platform="${r(e.push?.platform??"unknown")}" data-app="${r(e.push?.app??"App")}" ${Object.entries(t).map(([s,c])=>`data-${s}="${r(c)}"`).join(" ")}`,Jt=(e,t)=>{let s=e.push,c=s?.app??"App",n=t.expanded;return`<div class="ios-note swipe-card ${n?"expanded":""} ${i.arrived.has(e.id)?"arrive":""}" data-action="push-toggle" data-id="${r(e.id)}" ${Zt(e,{expanded:n,stacked:t.stacked??!1})} ${t.extra??""} role="button" tabindex="0" aria-expanded="${n}" data-longpress="ios-note">\n <span class="app-icon" style="background:${He(c,ct)}" ${p(l.pushNotificationApp)} aria-label="${r(c)}">${r(Ne(c).slice(0,1))}</span>\n <div class="content">\n <div class="line1"><span class="title" ${p(l.pushNotificationTitle)}>${r(s?.title??c)}</span><span class="time" ${p(l.pushNotificationTime)}>${r(pt(e.createdAt))}</span></div>\n <div class="body" ${p(l.pushNotificationBody)}>${r(s?.body??"")}</div>\n ${n&&s?.imageUrl?`<img class="hero" src="${r(s.imageUrl)}" alt="" ${p(l.pushNotificationImage)}>`:""}\n ${n?Kt(e)+Yt(e):""}\n </div>\n ${!n&&s?.imageUrl?`<img class="thumb" src="${r(s.imageUrl)}" alt="" ${p(l.pushNotificationImage)}>`:""}\n </div>`},Ze=(e,t={})=>`<div class="swipe ios-swipe" data-swipe="ios-note" data-id="${r(e.id)}" data-flip="note:${r(e.id)}" ${t.hidden?"hidden":""}>\n <div class="swipe-actions"><button data-action="push-options" data-id="${r(e.id)}" ${p(l.pushOptions)}>Options</button><button data-action="push-clear" data-id="${r(e.id)}" ${p(l.pushClear)}>Clear</button></div>\n ${Jt(e,{expanded:i.push.expanded===e.id,stacked:t.stacked??!1,extra:t.top?\'data-group-top="true"\':""})}\n </div>`,Za=e=>{let t=e.push,s=i.push.expanded===e.id,c=t?.app??"App",n=i.push.settings===e.id,f=M.silent.has(c);return`<div class="a-note ${s?"expanded":""} ${i.arrived.has(e.id)?"arrive":""}" data-action="push-toggle" data-id="${r(e.id)}" ${Zt(e,{expanded:s})} data-swipe="a-note" data-longpress="a-note" data-flip="note:${r(e.id)}" role="button" tabindex="0" aria-expanded="${s}">\n <span class="a-icon" style="background:${He(c,ct)}" aria-hidden="true">${r(Ne(c).slice(0,1))}</span>\n <div class="a-main">\n <div class="a-head"><span ${p(l.pushNotificationApp)}>${r(c)}</span><span>\\u2022</span><span ${p(l.pushNotificationTime)}>${r(Pa(e.createdAt))}</span>${f?`<span>${u.bellSlash(12)}</span>`:""}<span class="chev">${s?u.collapse():u.expand()}</span></div>\n ${t?.title?`<div class="a-title" ${p(l.pushNotificationTitle)}>${r(t.title)}</div>`:""}\n <div class="a-body" ${p(l.pushNotificationBody)}>${r(t?.body??"")}</div>\n ${s&&t?.imageUrl?`<img class="big-picture" src="${r(t.imageUrl)}" alt="" ${p(l.pushNotificationImage)}>`:""}\n ${s?Kt(e)+Yt(e):""}\n ${n?`<div class="a-settings" ${p(l.pushSettings)} data-app="${r(c)}">\n <button class="opt" data-action="push-alerting" data-app="${r(c)}" data-value="alerting" aria-pressed="${!f}">${u.bell()}<span>Default<small>May ring or vibrate based on device settings</small></span></button>\n <button class="opt" data-action="push-alerting" data-app="${r(c)}" data-value="silent" aria-pressed="${f}">${u.bellSlash(18)}<span>Silent<small>No sound or vibration</small></span></button>\n <div class="row"><button data-action="close-overlay">Turn off notifications</button><button data-action="close-overlay">Done</button></div></div>`:""}\n </div>\n ${!s&&t?.imageUrl?`<img class="large-icon" src="${r(t.imageUrl)}" alt="" ${p(l.pushNotificationImage)}>`:""}\n </div>`},Ja=(e,t)=>{let s=[],c=new Map;for(let n of t){let f=n.push?.app??"App";c.has(f)||s.push(f),c.set(f,[...c.get(f)??[],n])}return s.map(n=>{let f=c.get(n)??[],w=f[0];if(!w)return"";if(f.length===1)return Ze(w);let x=ut(e,n),S=M.openGroups.has(x),k=f.length-1;return S?`<div class="push-group" ${p(l.pushGroup)} data-app="${r(n)}" data-count="${f.length}" data-open="true" data-flip="group:${r(n)}">\n <div class="group-head"><h3>${r(n)}</h3><button data-action="group-collapse" data-key="${r(x)}" ${p(l.pushGroupCollapse)}>Show less</button><button class="x" data-action="group-clear" data-key="${r(x)}" data-app="${r(n)}" aria-label="Clear ${r(n)} notifications">${u.close(14)}</button></div>\n ${f.map(m=>Ze(m)).join("")}</div>`:`<div class="push-group" ${p(l.pushGroup)} data-app="${r(n)}" data-count="${f.length}" data-open="false" data-flip="group:${r(n)}">\n ${Ze(w,{top:!0})}\n <button class="stack-layers" data-action="group-open" data-key="${r(x)}" ${p(l.pushGroupMore)} data-count="${k}" aria-label="Show ${k} more notification${k===1?"":"s"}"><div class="ios-stack-more"></div>${k>1?\'<div class="ios-stack-more"></div>\':""}<div class="center-label" style="font-size:13px;margin-top:6px">${k} more notification${k===1?"":"s"}</div></button>\n ${f.slice(1).map(m=>Ze(m,{stacked:!0,hidden:!0})).join("")}</div>`}).join("")},G=()=>{let e=i.push.to,t=e?ee("push").filter(T=>T.to===e):[];Se(t.map(T=>T.id));let s=t[0]?.push?.platform??"unknown",c=i.push.skin==="auto"?s==="android"?"android":"ios":i.push.skin,n=new Date($()),f=ee("push").filter(T=>!B.has(T.id)).length,w=i.push.wake&&ce();i.push.wake=!1;let x,S=`${p(l.pushDevice)} data-skin="${c}" data-recipient="${r(e??"")}" data-platform="${r(s)}"`;if(c==="android")x=`<div class="pixel" ${S}><div class="screen"><div class="punch"></div><div class="shade">\n <div class="sb"><span>${se(n).replace(/\\s?[AP]M$/i,"")}</span><span class="icons">${u.androidWifi()}${u.androidSignal()}${u.androidBattery()}</span></div>\n <div class="qs-head"><span>${r(n.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}))}</span>${u.gear()}</div>\n <div class="qs"><div class="tile on">${u.androidWifi()}<div>Internet<small>Mockingbird</small></div></div><div class="tile">${u.bell()}<div>Do Not Disturb<small>Off</small></div></div>\n <div class="tile">${u.androidBattery()}<div>Battery Saver<small>Off</small></div></div><div class="tile">${u.lock()}<div>Screen lock<small>On</small></div></div></div>\n <div class="qs-bright"></div>\n <div class="shade-list" role="list">${t.length?t.map(Za).join(""):`<div class="shade-empty" ${p(l.pushEmpty)}>No notifications</div>`}</div>\n ${t.length?`<div class="shade-actions"><button data-action="close-overlay">Manage</button><button data-action="push-clear-all" ${p(l.pushClearAll)}>Clear all</button></div>`:""}\n <div class="gesture"></div></div></div></div>`;else{let T=i.push.preview?t.find(I=>I.id===i.push.preview):null;x=`<div class="iphone" ${S}><div class="screen"><div class="island"></div>${Vt(!0)}<div class="lock ${w?"wake":""}">\n <div class="padlock">${u.padlock()}</div>\n <div class="date">${r(n.toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"}))}</div>\n <div class="clock">${r(se(n).replace(/\\s?[AP]M$/i,""))}</div>\n <div class="lock-stack" role="list">${t.length&&e?`<div class="center-label">Notification Center</div>${Ja(e,t)}`:`<div class="lock-empty" ${p(l.pushEmpty)}>${e?"No Older Notifications":"No push notifications yet"}</div>`}</div>\n <div class="lock-buttons"><span>${u.flashlight()}</span><span>${u.camera()}</span></div>\n ${T?`<div class="ios-overlay dark" data-action="close-overlay" ${p(l.pushPreview)} data-notification-id="${r(T.id)}" role="dialog" aria-label="Notification preview">${Jt(T,{expanded:!0})}\n <div class="ios-menu" role="menu"><button role="menuitem" data-action="push-clear" data-id="${r(T.id)}">Clear</button><button role="menuitem" data-action="close-overlay">Options</button></div></div>`:""}\n </div><div class="home-indicator light"></div></div></div>`}let k=T=>{let I=Ve("push").find(K=>K.to===T);return`${T.length>22?`${T.slice(0,10)}\\u2026${T.slice(-8)}`:T}${I?.platform&&I.platform!=="unknown"?` \\xB7 ${I.platform}`:""}`},m=Z("col-push");bt(m,()=>{m.innerHTML=`\n ${Ye("Push",Ke(f,l.pushUnreadCount),Ge("push","Device",l.pushRecipient,k),`<div class="seg" role="group" aria-label="Phone">${["auto","ios","android"].map(T=>`<button data-action="skin" data-value="${T}" ${p(l.pushSkin)} aria-pressed="${i.push.skin===T}">${T==="auto"?"Auto":T==="ios"?"iOS":"Android"}</button>`).join("")}</div>`)}${x}`}),je()},Xa=e=>`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;font:14px/1.5 Arial,Helvetica,sans-serif;color:#222;overflow-wrap:anywhere}img{max-width:100%;height:auto}</style></head><body>${e.email?.html??""}</body></html>`,Qa=(e,t)=>{i.toast=t?{text:e,undo:t}:{text:e},te();let s=i.toast;F(6e3,()=>{i.toast===s&&(i.toast=null,te())})},Xt=(e,t)=>{M.dismissed.add(e),i.email.open===e&&(i.email.open=null,i.email.transition=!0),Qa(t==="archived"?"Conversation archived.":"Conversation moved to Trash.",()=>{M.dismissed.delete(e),i.toast=null,te()})},te=()=>{let e=i.email.to,t=e?ee("email").filter(m=>m.to===e):[],s=t.filter(m=>!B.has(m.id)).length,c=ee("email").filter(m=>!B.has(m.id)).length,n=t.find(m=>m.id===i.email.open);n||(i.email.open=null);let f=i.email.transition&&ce();i.email.transition=!1;let w=e??"you@example.test",x;if(n){Se([n.id]);let m=n.email,T=n.from.name??n.from.address,I=n.to.toLowerCase()===w.toLowerCase()?"me":n.to,j=(K,oe,$e)=>`<span>${oe}:</span><span ${p(l.emailDetail)} data-field="${K}">${r($e)}</span>`;x=`<div class="mail-toolbar">\n <button class="icon-btn" data-action="mail-back" ${p(l.emailBack)} title="Back to Inbox" aria-label="Back to Inbox">${u.back()}</button>\n <button class="icon-btn" data-action="mail-archive" data-id="${r(n.id)}" ${p(l.emailArchive)} title="Archive" aria-label="Archive">${u.archive()}</button><span class="icon-btn">${u.report()}</span><button class="icon-btn" data-action="mail-delete" data-id="${r(n.id)}" ${p(l.emailDelete)} title="Delete" aria-label="Delete">${u.trash()}</button>\n <button class="icon-btn" data-action="mail-unread" data-id="${r(n.id)}" ${p(l.emailMarkUnread)} title="Mark as unread" aria-label="Mark as unread">${u.markUnread()}</button><span class="icon-btn">${u.clock()}</span><span class="icon-btn">${u.more()}</span>\n <span class="range">${t.indexOf(n)+1} of ${t.length}</span></div>\n <div class="reader ${f?"enter":""}" ${be(n)} ${p(l.emailOpen)}>\n <div class="subject-row"><h1 ${p(l.emailSubject)}>${r(m?.subject||"(no subject)")}</h1><span class="label-chip">Inbox</span></div>\n <div class="sender-row">\n <span class="mail-avatar" style="background:${He(n.from.address)}">${r(Ne(T).slice(0,1))}</span>\n <div class="who"><b ${p(l.emailFromName)}>${r(T)}</b> <span class="addr"><<span ${p(l.emailFromAddress)}>${r(n.from.address)}</span>></span>\n <div class="to" data-action="mail-details" ${p(l.emailTo)} role="button" tabindex="0" aria-expanded="${he}">to ${r(I)}${m?.cc.length?`, ${r(m.cc.join(", "))}`:""} ${u.dropdown()}</div></div>\n <div class="meta"><span ${p(l.emailDate)}>${r(Ua(n.createdAt))}</span> <span class="icon-btn">${u.star()}</span><span class="icon-btn">${u.reply()}</span><span class="icon-btn">${u.more()}</span></div>\n </div>\n ${he?`<div class="details" ${p(l.emailDetails)}>\n ${j("from","from",n.from.name?`${n.from.name} <${n.from.address}>`:n.from.address)}\n ${j("to","to",n.to)}\n ${m?.cc.length?j("cc","cc",m.cc.join(", ")):""}\n ${m?.bcc.length?j("bcc","bcc",m.bcc.join(", ")):""}\n ${m?.replyTo.length?j("reply-to","reply-to",m.replyTo.join(", ")):""}\n ${j("date","date",new Date(n.createdAt).toLocaleString())}\n ${j("subject","subject",m?.subject??"")}\n ${j("mailed-by","mailed-by",`${Me[n.service]??n.service} (${n.source})`)}\n ${j("message-id","message id",n.providerId)}\n </div>`:""}\n ${m?.html?`<iframe class="mail-frame" name="email-body" ${p(l.emailBody)} data-format="html" sandbox="allow-same-origin allow-popups allow-popups-to-escape-sandbox" title="Email body"></iframe>`:`<div class="mail-text" ${p(l.emailText)} data-format="text">${jt(r(m?.text??""))}</div>`}\n ${m?.attachments.length?`<div class="attachments" ${p(l.emailAttachments)} data-count="${m.attachments.length}"><h3>${m.attachments.length} attachment${m.attachments.length===1?"":"s"}</h3><div class="att-grid">${m.attachments.map(K=>`<div class="att" ${p(l.emailAttachment)} data-filename="${r(K.filename)}" data-content-type="${r(K.contentType??"")}" data-size="${K.size??""}"><div class="att-top">${u.file()}</div><div class="att-name">${u.clip()} ${r(K.filename)}${K.size?` <span style="color:#5f6368;font-weight:400">${Math.max(1,Math.round(K.size/1024))} KB</span>`:""}</div></div>`).join("")}</div></div>`:""}\n <div class="reply-row"><span>${u.reply()} Reply</span><span>${u.forward()} Forward</span></div>\n </div>`}else x=`<div class="mail-toolbar"><span class="icon-btn">${u.checkbox()}</span><button class="icon-btn" data-action="refresh" ${p(l.emailRefresh)} title="Refresh" aria-label="Refresh">${u.refresh()}</button><span class="icon-btn">${u.more()}</span>\n <span class="range">${t.length?`1\\u2013${t.length} of ${t.length}`:""}</span></div>\n <div class="cat-tabs"><div class="on">${u.inbox()} Primary</div><div>${u.star()} Promotions</div><div>${u.send()} Updates</div></div>\n <div class="mail-list ${f?"enter":""}" role="list">${t.length?t.map(m=>{let T=!B.has(m.id),I=m.from.name??m.from.address,j=M.starred.has(m.id);return`<div class="swipe mrow-swipe" data-swipe="mrow" data-id="${r(m.id)}" data-flip="row:${r(m.id)}" role="listitem">\n <div class="swipe-actions">${u.archive()}${u.archive()}</div>\n <div class="mrow swipe-card ${T?"unread":""} ${i.arrived.has(m.id)?"arrive":""}" data-action="mail-open" data-id="${r(m.id)}" ${be(m)} ${p(l.emailRow)} data-starred="${j}" role="button" tabindex="0">\n <span class="chk" data-action="mail-check" data-id="${r(m.id)}" role="checkbox" aria-checked="${M.checked.has(m.id)}" aria-label="Select">${u.checkbox()}</span><span class="star" data-action="mail-star" data-id="${r(m.id)}" ${p(l.emailRowStar)} role="button" aria-pressed="${j}" aria-label="${j?"Starred":"Not starred"}">${j?u.starFilled():u.star()}</span>\n <span class="from" ${p(l.emailRowFrom)}>${r(I)}</span>\n <span class="subj"><span ${p(l.emailRowSubject)}>${r(m.email?.subject||"(no subject)")}</span> <span class="snippet">- <span ${p(l.emailRowSnippet)}>${r(m.preview)}</span></span></span>\n ${m.email?.attachments.length?`<span class="clip" ${p(l.emailRowAttachment)}>${u.clip()}</span>`:""}<span class="svc" ${p(l.emailRowService)}>${r(Me[m.service]??m.service)}</span>\n <span class="date" ${p(l.emailRowDate)}>${r(_a(m.createdAt))}</span>\n <span class="hover-actions"><button class="icon-btn" data-action="mail-archive" data-id="${r(m.id)}" ${p(l.emailRowArchive)} title="Archive" aria-label="Archive">${u.archive()}</button><button class="icon-btn" data-action="mail-delete" data-id="${r(m.id)}" ${p(l.emailRowDelete)} title="Delete" aria-label="Delete">${u.trash()}</button><button class="icon-btn" data-action="mail-toggle-read" data-id="${r(m.id)}" ${p(l.emailRowToggleRead)} title="${T?"Mark as read":"Mark as unread"}" aria-label="${T?"Mark as read":"Mark as unread"}">${T?u.markRead():u.markUnread()}</button><span class="icon-btn">${u.clock()}</span></span></div></div>`}).join(""):`<div class="mail-empty" ${p(l.emailEmpty)}>${u.envelope()}<b>${e?"Your Primary tab is empty.":"No email yet"}</b>${e?"":"Email sent through Resend, SES, SNS, Customer.io or Mailosaur lands here."}</div>`}</div>`;let S=Z("col-email");bt(S,()=>{S.innerHTML=`\n ${Ye("Email",Ke(c,l.emailUnreadCount),Ge("email","Mailbox",l.emailRecipient,m=>m))}\n <div class="window" ${p(l.emailDevice)} data-screen="${n?"message":"inbox"}" data-recipient="${r(e??"")}">\n <div class="chrome"><span class="lights"><i></i><i></i><i></i></span><span class="omnibox">${u.lock()} mail.example.test/#inbox${n?`/${r(n.providerId)}`:""}</span></div>\n <div class="mail-top"><span class="icon-btn">${u.menu()}</span><span class="mail-logo">${u.envelope()}<span class="lbl">Mail</span></span>\n <div class="mail-search"><span class="icon-btn">${u.search("#444746",20)}</span><span class="placeholder">Search mail</span><span class="icon-btn">${u.tune()}</span></div>\n <div class="right"><span class="icon-btn">${u.help()}</span><span class="icon-btn">${u.gear()}</span><span class="icon-btn">${u.apps()}</span>\n <span class="mail-avatar" title="${r(w)}" style="background:${He(w)}">${r(w.slice(0,1).toUpperCase())}</span></div></div>\n <div class="mail-body">\n <nav class="mail-nav"><button class="compose">${u.pencil()}<span class="lbl">Compose</span></button>\n <div class="nav-item active">${u.inbox()}<span class="lbl">Inbox</span><span class="n">${s||""}</span></div>\n <div class="nav-item">${u.star()}<span class="lbl">Starred</span></div>\n <div class="nav-item">${u.clock()}<span class="lbl">Snoozed</span></div>\n <div class="nav-item">${u.send()}<span class="lbl">Sent</span></div>\n <div class="nav-item">${u.draft()}<span class="lbl">Drafts</span></div>\n <div class="nav-item">${u.expand()}<span class="lbl">More</span></div></nav>\n <main class="mail-main">${x}</main>\n </div>\n ${i.toast?`<div class="toast" ${p(l.toast)} role="status"><span>${r(i.toast.text)}</span>${i.toast.undo?`<button data-action="toast-undo" ${p(l.toastUndo)}>Undo</button>`:""}<button data-action="toast-close" aria-label="Dismiss">${u.close(16)}</button></div>`:""}\n </div>`});let k=S.querySelector(".mail-frame");k&&n&&(k.addEventListener("load",()=>{let m=k.contentDocument;m&&(k.style.height=`${Math.max(120,m.documentElement.scrollHeight+8)}px`)}),k.srcdoc=Xa(n)),Qt(),je()},vt=e=>ee(e).filter(t=>!B.has(t.id)).length,Qt=()=>{if(!h||!d)return;let e=le.reduce((t,s)=>t+vt(s),0);document.title=`${e?`(${e}) `:""}${Ft()} \\xB7 Mockingbird`},Le=e=>e.startsWith("/services/")?`Webhook \\u2026${e.slice(-6)}`:e,en=e=>{let t=new Date(e),s=new Date($());if(xe(t,s))return"Today";let c=new Date(s);return c.setDate(s.getDate()-1),xe(t,c)?"Yesterday":t.toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"})},tn=e=>{let t=e.chat,s=e.from.name??e.from.address,c={name:S=>t?.names?.[S]},n=t?.text&&!t.blocks.length?`<div class="chat-text" ${p(l.chatMessageText)}>${ke(t.text,c)}</div>`:"",f=t?.blocks.length?`<div class="chat-blocks" ${p(l.chatMessageBlocks)}>${Lt(t.blocks,c)}</div>`:"",w=t?.attachments.length?`<div class="chat-attachments" ${p(l.chatMessageAttachments)}>${$a(t.attachments,c)}</div>`:"",x=t?.reactions.length?`<div class="chat-reactions">${t.reactions.map(S=>`<span class="chat-reaction" ${p(l.chatMessageReaction)} data-name="${r(S.name)}" data-count="${S.count}">${r(Ie(S.name))} ${S.count}</span>`).join("")}</div>`:"";return`<div class="chat-msg ${i.arrived.has(e.id)?"arrive":""}" ${be(e)} ${p(l.chatMessage)} data-method="${r(t?.method??"")}" data-ephemeral="${t?.ephemeral??!1}" data-thread="${r(t?.threadTs??"")}" role="listitem" tabindex="0">\n <span class="chat-avatar" style="background:${He(e.from.address,ct)}" aria-hidden="true">${r(Ne(s))}</span>\n <div class="chat-msg-main">\n <div class="chat-meta"><b ${p(l.chatMessageAuthor)}>${r(s)}</b><span class="chat-app">APP</span><span class="chat-time" ${p(l.chatMessageTime)}>${r(se(new Date(e.createdAt)))}</span>${t?.edited?\'<span class="chat-edited">(edited)</span>\':""}</div>\n ${t?.ephemeral?\'<div class="chat-note">Only visible to you</div>\':""}${t?.threadTs?\'<div class="chat-note">replied to a thread</div>\':""}\n ${n}${f}${w}${x}\n </div></div>`},ea=()=>{let e=i.chat.to,t=ee("chat"),s=e?t.filter(m=>m.to===e).sort((m,T)=>m.createdAt<T.createdAt?-1:1):[];Se(s.map(m=>m.id));let c=Ve("chat"),n=t[0]?.chat?.workspace??"Workspace",f="",w=s.map(m=>{let T=en(m.createdAt),I=T===f?"":`<div class="chat-day"><span>${r(T)}</span></div>`;return f=T,I+tn(m)}).join(""),x=Z("col-chat");x.innerHTML=`\n ${Ye("Chat",Ke(vt("chat"),l.chatUnreadCount),Ge("chat","Channel",l.chatRecipient,Le))}\n <div class="window chat" ${p(l.chatDevice)} data-recipient="${r(e??"")}" data-workspace="${r(n)}">\n <div class="chrome"><span class="lights"><i></i><i></i><i></i></span><span class="omnibox">${u.lock()} chat.example.test/${r(e?Le(e).replace(/^#/,""):"")}</span></div>\n <div class="chat-body">\n <nav class="chat-side" aria-label="Channels">\n <div class="chat-team" ${p(l.chatWorkspace)}>${r(n)} ${u.dropdown()}</div>\n <div class="chat-side-label">Channels</div>\n ${c.map(m=>`<button class="chat-chan ${m.to===e?"on":""} ${m.unread?"unread":""}" data-action="chat-channel" data-value="${r(m.to)}" ${p(l.chatChannel)} data-to="${r(m.to)}" data-unread="${m.unread}" aria-current="${m.to===e}"><span class="hash">${m.to.startsWith("#")?"#":"~"}</span><span class="lbl">${r(Le(m.to).replace(/^#/,""))}</span>${m.unread?`<span class="n">${m.unread}</span>`:""}</button>`).join("")}\n </nav>\n <main class="chat-main">\n <header class="chat-head"><b ${p(l.chatTitle)}>${r(e?Le(e):"Chat")}</b><span>${s.length?`${s.length} message${s.length===1?"":"s"}`:""}</span></header>\n <div class="chat-list" role="list">${w||`<div class="chat-empty" ${p(l.chatEmpty)}><b>${e?"No messages in this channel":"No chat messages yet"}</b>${e?"":"Messages posted to the Slack emulator, with chat.postMessage or an incoming webhook, land here."}</div>`}</div>\n <div class="chat-compose"><span>Message ${r(e?Le(e):"channel")}</span><span class="send">${u.send()}</span></div>\n </main>\n </div>\n </div>`;let S=x.querySelector(".chat-list"),k=()=>{S&&(S.scrollTop=S.scrollHeight)};k(),requestAnimationFrame(k),je()},an=()=>{let e=It();Z("timeline").innerHTML=e.length?`<table class="tl" ${p(l.timeline)}><thead><tr><th>Time</th><th>Channel</th><th>Source</th><th>To</th><th>From</th><th>Content</th><th>Status</th></tr></thead><tbody>${e.map(t=>`<tr data-action="inspect" data-id="${r(t.id)}" ${be(t)} ${p(l.timelineRow)} tabindex="0">\n <td class="mono" data-col="time">${r(Ia(t.createdAt))}</td>\n <td data-col="channel"><span class="chan ${t.channel} ${ge(t)?"wa":""}">${ge(t)?"WhatsApp":Ba[t.channel]}</span></td>\n <td data-col="source"><span class="svc-tag">${r(Me[t.service]??t.service)}${t.source!==t.service?` \\xB7 ${r(t.source)}`:""}</span></td>\n <td class="mono" data-col="to">${r(t.channel==="sms"?dt(t.to):t.channel==="chat"?Le(t.to):t.to.length>28?`${t.to.slice(0,26)}\\u2026`:t.to)}</td>\n <td data-col="from">${r(Fe(t))}</td>\n <td class="content" data-col="content">${t.email?`<b>${r(t.email.subject)}</b> \\u2014 `:t.push?.title?`<b>${r(t.push.title)}</b> \\u2014 `:""}${r(t.channel==="email"||t.channel==="chat"?t.preview.slice(0,120):t.sms?.body??t.push?.body??t.preview)}</td>\n <td class="svc-tag" data-col="status">${r(t.status??"")}</td></tr>`).join("")}</tbody></table>`:`<div class="empty-tl" ${p(l.timelineEmpty)}>Nothing sent in namespace <b>${r(i.namespace)}</b> yet.</div>`},Re=()=>{let e=i.items.find(f=>f.id===i.inspect),t=Z("inspector");if(!e){t.hidden=!0,t.innerHTML="";for(let f of Object.keys(t.dataset))f!=="region"&&f!=="testid"&&delete t.dataset[f];return}t.hidden=!1,Object.assign(t.dataset,{notificationId:e.id,channel:e.channel,service:e.service,source:e.source,to:e.to,from:e.from.address,status:e.status??"",createdAt:e.createdAt});let{raw:s,...c}=e,n=(f,w,x)=>`<span>${w}</span><span ${p(l.inspectorField)} data-field="${f}">${r(x)}</span>`;t.innerHTML=`<header><h3 ${p(l.inspectorTitle)}>${r(ge(e)?"WHATSAPP":e.channel.toUpperCase())} \\xB7 ${r(e.email?.subject??e.push?.title??e.preview.slice(0,60))}</h3>\n <button class="btn" data-action="show-on-device" data-id="${r(e.id)}" ${p(l.inspectorShowOnDevice)}>Show on device</button><button class="btn" data-action="close-inspector" ${p(l.inspectorClose)}>Close</button></header>\n <div class="kv">${n("id","Id",e.id)}${n("providerId","Provider id",e.providerId)}${n("service","Service",`${e.service} (${e.source})`)}\n ${n("namespace","Namespace",e.namespace)}${n("to","To",e.to)}${n("from","From",e.from.name?`${e.from.name} <${e.from.address}>`:e.from.address)}\n ${n("createdAt","Created",e.createdAt)}${n("status","Status",e.status??"\\u2014")}</div>\n <pre ${p(l.inspectorJson)}>${r(JSON.stringify({...c,raw:s},null,2))}</pre>`},we=e=>{let t=L();return fe.includes(e)&&(t==="all"||t===e)},ta=e=>{if(i.only=e==="all"?null:e,e!=="all"&&(C=e),h){let t=new URL(location.href);e==="all"?t.searchParams.delete("view"):t.searchParams.set("view",e);for(let s of["to","from","id"])t.searchParams.delete(s);q?.channel===e&&t.searchParams.set("to",q.to),history.replaceState(null,"",t)}J()},aa=e=>a.querySelector(`[data-action="tab"][data-value="${e}"]`),je=()=>{let e=Z("tabs"),t=o.tabs===!1?[]:Ct(fe,z);e.hidden=!t.length||i.view!=="devices";for(let n of le){let f=Z(`col-${n}`);t.length?(f.setAttribute("role","tabpanel"),f.setAttribute("aria-labelledby",`${pe}-tab-${n}`)):(f.removeAttribute("role"),f.removeAttribute("aria-labelledby"))}if(e.hidden){e.innerHTML="";return}let s=L(),c=e.contains(document.activeElement)?document.activeElement.dataset.value:void 0;e.dataset.layout=z?"tabs":"grid",e.innerHTML=t.map(n=>{let f=n===s,w=n==="all"?0:vt(n),x=n==="all"?fe.map(S=>`${pe}-panel-${S}`).join(" "):`${pe}-panel-${n}`;return`<button role="tab" id="${pe}-tab-${n}" aria-selected="${f}" aria-controls="${x}" tabindex="${f?0:-1}" data-action="tab" data-value="${n}" ${p(l.channelTab)} data-unread="${w}">${Ta[n]}${w&&!f?`<span class="tab-unread" ${p(l.channelTabUnread)} aria-label="${w} unread">${w}</span>`:""}</button>`}).join(""),c&&aa(c)?.focus()},J=()=>{if(!O){ve(),Z("devices").hidden=i.view!=="devices",Z("timeline").hidden=i.view!=="timeline";for(let e of le)Z(`col-${e}`).hidden=!we(e);Z("devices").classList.toggle("solo",le.filter(we).length===1),i.view==="devices"?(we("sms")&&ae(),we("push")&&G(),we("email")&&te(),we("chat")&&ea()):an(),je(),Re(),Qt()}},na=e=>{fe.includes(e)&&(C=e,!we(e)&&(i.only=e))},wt=e=>{i.view="devices",na(e.channel),i[e.channel].to=e.to,e.channel==="sms"&&(i.sms.thread=e.from.address),e.channel==="email"&&(i.email.open=e.id),e.channel==="push"&&(i.push.expanded=e.id,M.openGroups.add(ut(e.to,e.push?.app??"App"))),M.dismissed.delete(e.id),i.inspect=null,J(),a.querySelector(`.devices [data-notification-id="${CSS.escape(e.id)}"]`)?.scrollIntoView({block:"nearest"})},nn=(e,t)=>{if(!ce())return t();e.style.height=`${e.offsetHeight}px`,e.classList.add("collapsing"),e.offsetHeight,Object.assign(e.style,{height:"0px",marginTop:"0px",marginBottom:"0px",paddingTop:"0px",paddingBottom:"0px",opacity:"0"}),F(270,t)},$t=(e,t,s,c)=>{if(!ce())return c();e.classList.add("settling"),t.classList.add("settling"),t.style.transform=`translateX(${s*(e.offsetWidth+40)}px)`,t.style.opacity="0",F(230,()=>nn(e,c))},Je=e=>a.querySelector(e),Oe=e=>e.querySelector(".swipe-card")??e,Xe=(e,t=-1)=>{let s=Je(`.ios-swipe[data-id="${CSS.escape(e)}"]`)??Je(`.a-note[data-id="${CSS.escape(e)}"]`),c=()=>{M.dismissed.add(e),i.push.preview===e&&(i.push.preview=null),G()};if(!s)return c();$t(s,Oe(s),t,c)},yt=e=>{let t=i.sms.to;if(!t)return;let s=ee("sms").filter(f=>f.to===t&&f.from.address===e).map(f=>f.id),c=Je(`.thread-swipe[data-from="${CSS.escape(e)}"]`),n=()=>{for(let f of s)M.dismissed.add(f);ae()};if(!c)return n();$t(c,Oe(c),-1,n)},Qe=(e,t,s=-1)=>{let c=Je(`.mrow-swipe[data-id="${CSS.escape(e)}"]`);if(!c)return Xt(e,t);$t(c,Oe(c),s,()=>Xt(e,t))},N=null,Pe=!1,sn=160,ia=148,sa=(e,t)=>{let s=Oe(e);s.style.transform=t?`translateX(${t}px)`:"",e.dataset.swipe==="a-note"&&(s.style.opacity=String(1-Math.min(.9,Math.abs(t)/e.offsetWidth)))},re=(e,t,s)=>{e.classList.add("settling"),e.classList.toggle("open",s),e.dataset.swipe==="a-note"&&e.classList.add("settling"),sa(e,t),F(340,()=>{e.classList.remove("settling","swiping"),e.dataset.offset=String(t)})},kt=e=>{let t=e.dataset.longpress,s=e.dataset.notificationId??e.dataset.id??"";if(t==="sms-bubble"){i.sms.menu=s,ae();try{navigator.vibrate?.(10)}catch{}}else t==="ios-note"?(i.push.preview=s,G()):t==="a-note"&&(i.push.settings=i.push.settings===s?null:s,G())};D("pointerdown",e=>{if(ie.unlock(),Pe=!1,e.button!==0||!e.isPrimary)return;let t=e.target;if(t.closest("select, input, .swipe-actions button, .ios-overlay"))return;let s=t.closest("[data-swipe]"),c=t.closest("[data-longpress]");if(!(!s&&!c)&&(N={pointerId:e.pointerId,x0:e.clientX,y0:e.clientY,t0:performance.now(),dx:0,axis:null,swipe:s,press:c,base:Number(s?.dataset.offset??0),timer:null},c)){let n=N;n.timer=setTimeout(()=>{N!==n||n.axis||(Pe=!0,N=null,kt(c))},480)}}),D("pointermove",e=>{if(!N||e.pointerId!==N.pointerId)return;let t=qt(N.swipe??a),s=(e.clientX-N.x0)/t,c=(e.clientY-N.y0)/t;if(!N.axis){if(Math.hypot(s,c)<8)return;if(N.axis=Math.abs(s)>Math.abs(c)?"x":"y",N.timer&&clearTimeout(N.timer),N.axis==="x"&&N.swipe){N.swipe.classList.add("swiping"),N.swipe.classList.remove("settling"),Oe(N.swipe).classList.remove("settling");try{N.swipe.setPointerCapture(e.pointerId)}catch{}}}if(N.axis!=="x"||!N.swipe)return;e.preventDefault(),N.dx=s;let n=N.swipe.dataset.swipe,f=N.base+s;if(n==="sms-convo"){let w=Math.max(0,Math.min(72,-s));N.swipe.style.setProperty("--reveal",`${w}px`);return}n==="ios-note"&&f>0&&(f=f*.35),(n==="mrow"||n==="a-note")&&(f=s),sa(N.swipe,f)});let oa=e=>{if(!N||e.pointerId!==N.pointerId)return;let t=N;if(N=null,t.timer&&clearTimeout(t.timer),t.axis!=="x"||!t.swipe)return;Pe=!0;let s=t.swipe,c=s.dataset.swipe,n=s.offsetWidth||1,f=t.dx/Math.max(1,performance.now()-t.t0),w=t.base+t.dx;if(c==="sms-convo")s.classList.add("settling"),s.style.setProperty("--reveal","0px"),F(320,()=>s.classList.remove("settling"));else if(c==="ios-note"){let x=s.dataset.id??"";w<-n*.7||f<-1.1&&w<-60?Xe(x):w<-60?re(s,-sn,!0):w>70?(re(s,0,!1),i.push.expanded=x,G()):re(s,0,!1)}else if(c==="a-note")Math.abs(w)>n*.4||Math.abs(f)>.7?Xe(s.dataset.id??"",Math.sign(w)||1):re(s,0,!1);else if(c==="sms-thread"){let x=s.dataset.from??"";w<-n*.6?yt(x):w<-50?re(s,-ia,!0):w>50?re(s,ia,!0):re(s,0,!1)}else c==="mrow"&&(Math.abs(w)>n*.35||Math.abs(f)>.8?Qe(s.dataset.id??"","archived",Math.sign(w)||1):re(s,0,!1))};D("pointerup",oa),D("pointercancel",oa),D("contextmenu",e=>{let t=e.target.closest("[data-longpress]");t&&(e.preventDefault(),kt(t))}),D("click",e=>{Pe&&(Pe=!1,e.stopPropagation(),e.preventDefault())},!0);let ra=()=>{let e=i.sms.menu||i.push.preview||i.push.settings;return i.sms.menu=null,i.push.preview=null,i.push.settings=null,e&&(ae(),G()),!!e},la=e=>{try{navigator.clipboard?.writeText(e).catch(()=>{})}catch{}};D("click",e=>{let t=e.target.closest("[data-action]");if(!t)return;let s=t.closest(".swipe.open");if(s&&t.classList.contains("swipe-card")){re(s,0,!1);return}let c=t.dataset.action,n=t.dataset.id??"",f=t.dataset.from??"",w=i.sms.to??"";switch(c){case"view":i.view=t.dataset.value==="timeline"?"timeline":"devices",J();break;case"tab":ta(t.dataset.value??"all");break;case"chat-channel":i.chat.to=t.dataset.value??null,ea();break;case"sound":et.setSound(!ie.enabled);break;case"sms-open":i.sms.thread=f||null,i.sms.transition="push",ae();break;case"sms-back":i.sms.thread=null,i.sms.transition="back",ae();break;case"thread-delete":yt(f);break;case"thread-pin":{let x=Ae(w,f);M.pinned.delete(x)||M.pinned.add(x),ae();break}case"thread-mute":{let x=Ae(w,f);M.muted.delete(x)||M.muted.add(x),ae();break}case"thread-unread":{let x=ee("sms").filter(S=>S.to===w&&S.from.address===f);if(x.some(S=>!B.has(S.id)))Se(x.map(S=>S.id));else{let S=x.at(-1);S&<([S.id])}ae();break}case"tapback":{let x=t.dataset.value;M.tapbacks.get(n)===x?M.tapbacks.delete(n):M.tapbacks.set(n,x),i.sms.menu=null,ae();break}case"sms-copy":{let x=i.items.find(S=>S.id===n);x&&la(x.sms?.body??""),i.sms.menu=null,ae();break}case"sms-copy-code":la(t.dataset.code??"");break;case"close-overlay":ra();break;case"push-toggle":{if(t.dataset.groupTop==="true"){let x=i.items.find(S=>S.id===n);x&&(M.openGroups.add(ut(x.to,x.push?.app??"App")),G());break}i.push.expanded=i.push.expanded===n?null:n,G();break}case"push-clear":i.push.preview=null,Xe(n);break;case"push-options":i.push.preview=n,G();break;case"push-alerting":{let x=t.dataset.app??"App";t.dataset.value==="silent"?M.silent.add(x):M.silent.delete(x),G();break}case"push-clear-all":{let x=[...a.querySelectorAll(".shade-list .a-note")],S=x.map(m=>m.dataset.id??""),k=()=>{for(let m of S)M.dismissed.add(m);G()};if(!ce())return k();x.forEach((m,T)=>{F(T*60,()=>{m.classList.add("settling"),m.style.transform=`translateX(${m.offsetWidth+40}px)`,m.style.opacity="0"})}),F(x.length*60+300,k);break}case"group-open":M.openGroups.add(t.dataset.key??""),G();break;case"group-collapse":M.openGroups.delete(t.dataset.key??""),G();break;case"group-clear":{let x=t.dataset.app??"App";for(let S of ee("push"))S.to===i.push.to&&(S.push?.app??"App")===x&&M.dismissed.add(S.id);M.openGroups.delete(t.dataset.key??""),G();break}case"skin":i.push.skin=t.dataset.value??"auto",G();break;case"mail-open":i.email.open=n,i.email.transition=!0,he=!1,te();break;case"mail-back":i.email.open=null,i.email.transition=!0,te();break;case"mail-details":he=!he,te();break;case"mail-archive":Qe(n,"archived");break;case"mail-delete":Qe(n,"deleted");break;case"mail-unread":lt([n]),i.email.open=null,i.email.transition=!0,te();break;case"mail-toggle-read":B.has(n)?lt([n]):Se([n]),te();break;case"mail-star":M.starred.delete(n)||M.starred.add(n),te();break;case"mail-check":M.checked.delete(n)||M.checked.add(n),te();break;case"toast-undo":i.toast?.undo?.();break;case"toast-close":i.toast=null,te();break;case"refresh":qe().catch(()=>{});break;case"inspect":i.inspect=n,Re();break;case"close-inspector":i.inspect=null,Re();break;case"show-on-device":{let x=i.items.find(S=>S.id===n);x&&wt(x);break}}}),D("dblclick",e=>{let t=e.target.closest("[data-notification-id]");!t||t.closest("[data-region=inspector]")||(i.inspect=t.dataset.notificationId??null,Re())}),D("change",e=>{let t=e.target,s=t.dataset.action;if(s==="namespace")et.setNamespace(t.value);else if(s==="follow")i.follow=t.checked;else if(s==="recipient"){let c=t.dataset.channel;i[c].to=t.value,c==="sms"&&(i.sms.thread=null),c==="email"&&(i.email.open=null),J()}}),D("input",e=>{let t=e.target;t.dataset.action==="search"&&(i.search=t.value,mt(),J())}),D("keydown",e=>{ie.unlock();let t=e.target;if(e.key==="Escape"){if(ra())return;i.inspect&&(i.inspect=null,Re());return}if(!t.matches("input, select, textarea")){if(t.matches(\'[role="tab"]\')){let s=La(Ct(fe,z),L(),e.key);s&&(e.preventDefault(),ta(s),aa(s)?.focus());return}if(e.key==="ContextMenu"||e.shiftKey&&e.key==="F10"){let s=t.closest("[data-longpress]");s&&(e.preventDefault(),kt(s));return}if(e.key==="Delete"||e.key==="Backspace"||e.key==="#"||e.key==="e"){let s=t.dataset.id??"";t.matches("[data-testid=push-notification]")&&e.key!=="e"?(e.preventDefault(),Xe(s)):t.matches("[data-testid=sms-thread]")&&e.key!=="e"?(e.preventDefault(),yt(t.dataset.from??"")):t.matches("[data-testid=email-row]")&&(e.preventDefault(),Qe(s,e.key==="e"?"archived":"deleted"));return}(e.key==="Enter"||e.key===" ")&&t.matches("[role=button]:not(button)")&&(e.preventDefault(),t.click())}});let da=()=>{if(q&&(i[q.channel].to=q.to,q.channel==="sms"&&(i.sms.thread=rt??gt(q.to)[0]?.from??null)),ue){let e=i.items.find(t=>t.id===ue);if(e)return wt(e)}J()},Tt=()=>{},on=new Promise(e=>{Tt=()=>{a.dataset.ready="true",e()}}),et={render:J,state:i,ready:on,show(e){let t=e.id?i.items.find(s=>s.id===e.id):void 0;if(t)return wt(t);e.channel&&(i.view="devices",na(e.channel),e.to&&(i[e.channel].to=e.to),e.channel==="sms"&&e.to&&(i.sms.thread=gt(e.to)[0]?.from??null,We=i.sms.thread===null?e.to:null),e.channel==="email"&&(i.email.open=null),J())},setNamespace(e){if(e!==i.namespace){if(i.namespace=e,i.items=[],i.sms={...i.sms,to:null,thread:null,menu:null},i.email={...i.email,to:null,open:null},i.push.to=null,i.chat.to=null,Ht(),h){let t=new URL(location.href);t.searchParams.set("namespace",e),history.replaceState(null,"",t)}d?(Ut(),qe().catch(()=>{})):J()}},setSound(e){if(ie.enabled=e,e&&ie.unlock(),g)try{localStorage.setItem(Dt,e?"1":"0")}catch{}ve()},setScale(e){nt(e)!==b&&(b=nt(e),U(),J())},destroy(){O=!0,E.abort(),ft?.abort();for(let e of W)clearTimeout(e);W.clear();for(let e of ca)clearInterval(e);St?.disconnect(),ie.close(),a.innerHTML="",a.classList.remove(at,"embedded"),a.style.removeProperty("--mbn-fit"),a.style.removeProperty("--mbn-scale")}},ca=[];U();let pa=()=>{U()&&J()},St=typeof ResizeObserver=="function"?new ResizeObserver(pa):null;return St?St.observe(a):typeof window<"u"&&window.addEventListener("resize",pa,{signal:E.signal}),d?(ca.push(setInterval(()=>{N||i.sms.menu||i.push.preview||i.push.settings||(i.view==="devices"&&!a.querySelector(".mail-frame")?J():ve())},3e4),setInterval(()=>{_t()},5e3)),Ht(),J(),Ut(),_t(),(async()=>{for(let e=0;!O;e++)try{await qe(),da(),Tt();return}catch{await new Promise(t=>F(Math.min(5e3,500*2**e),()=>t(null)))}})(),et):(i.items=[...o.items??[]].sort((e,t)=>e.createdAt<t.createdAt?1:-1),i.sources=o.sources??[],i.namespaces=o.namespaces??[],i.discoveryError=o.discoveryError??null,i.connected=o.connected??!0,mt(),da(),Tt(),et)}var st="mb-dashboard",vn=`\n:root {\n --mbd-bar: #12151b; --mbd-line: #2a2f3a; --mbd-text: #e8eaf0; --mbd-muted: #9aa1b1;\n --mbd-accent: #0a84ff; --mbd-hover: rgba(255,255,255,.07); --mbd-panel: #0e1015; --mbd-ok: #30d158;\n}\n&[data-theme="light"] {\n --mbd-bar: #ffffff; --mbd-line: #e4e8ee; --mbd-text: #172033; --mbd-muted: #667085;\n --mbd-accent: #2563d8; --mbd-hover: rgba(16,24,40,.06); --mbd-panel: #f5f7fa; --mbd-ok: #1f9d55;\n}\n@media (prefers-color-scheme: light) {\n &[data-theme="auto"] {\n --mbd-bar: #ffffff; --mbd-line: #e4e8ee; --mbd-text: #172033; --mbd-muted: #667085;\n --mbd-accent: #2563d8; --mbd-hover: rgba(16,24,40,.06); --mbd-panel: #f5f7fa; --mbd-ok: #1f9d55;\n }\n}\n:root { display: flex; flex-direction: column; box-sizing: border-box; height: 100%; min-height: 0; overflow: hidden;\n background: var(--mbd-panel); color: var(--mbd-text);\n font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }\n.mbd-bar, .mbd-bar *, .mbd-panels, .mbd-panel { box-sizing: border-box; }\n.mbd-bar { flex: none; display: flex; align-items: stretch; gap: 18px; height: 46px; padding: 0 16px;\n background: var(--mbd-bar); border-bottom: 1px solid var(--mbd-line); }\n.mbd-brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }\n.mbd-mark { width: 24px; height: 24px; border-radius: 7px; background: linear-gradient(135deg,#0a84ff,#5e5ce6); flex: none;\n display: grid; place-items: center; color: #fff; font-size: 13px; line-height: 1; }\n.mbd-tabs { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }\n.mbd-tabs::-webkit-scrollbar { display: none; }\n.mbd-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; margin: 0; border: 0;\n background: none; color: var(--mbd-muted); font: inherit; font-weight: 560; white-space: nowrap; cursor: pointer; border-radius: 0; }\n.mbd-tab::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: transparent; }\n.mbd-tab:hover { color: var(--mbd-text); background: var(--mbd-hover); }\n.mbd-tab[aria-selected="true"] { color: var(--mbd-text); }\n.mbd-tab[aria-selected="true"]::after { background: var(--mbd-accent); }\n.mbd-tab:focus-visible { outline: 2px solid var(--mbd-accent); outline-offset: -3px; border-radius: 7px; }\n.mbd-badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--mbd-accent); color: #fff;\n font-size: 11px; font-weight: 650; line-height: 18px; text-align: center; }\n.mbd-badge[hidden] { display: none; }\n.mbd-aside { display: flex; align-items: center; gap: 12px; margin-left: auto; min-width: 0; color: var(--mbd-muted); font-size: 12.5px; white-space: nowrap; }\n.mbd-aside:empty { display: none; }\n.mbd-aside a { color: var(--mbd-accent); text-decoration: none; font-weight: 560; }\n.mbd-aside a:hover { text-decoration: underline; }\n.mbd-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--mbd-line); border-radius: 999px; }\n.mbd-pill b { color: var(--mbd-text); font-weight: 600; }\n.mbd-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mbd-ok); }\n.mbd-panels { flex: 1; min-height: 0; position: relative; }\n.mbd-panel { height: 100%; overflow: auto; }\n.mbd-panel[hidden] { display: none; }\n.mbd-fill { height: 100%; }\n.mbd-status { padding: 48px; color: var(--mbd-muted); }\n.mbd-status[data-kind="error"] { color: #ff6b61; }\n@media (max-width: 640px) {\n .mbd-bar { gap: 8px; height: 42px; padding: 0 8px; }\n .mbd-brand span { display: none; }\n .mbd-tabs { flex: 1; }\n .mbd-tab { flex: 1 0 auto; justify-content: center; padding: 0 10px; font-size: 13px; }\n .mbd-aside .mbd-pill { display: none; }\n}\n`,za=Ue(vn,`.${st}`);var zt=(a,o,d)=>{let h=a.getRootNode(),g=h instanceof ShadowRoot?h:document.head;if(g.querySelector(`#${o}`))return;let v=document.createElement("style");v.id=o,v.textContent=d,g.append(v)},Ea=(a,o={})=>{let{harness:d,injectStyles:h=!0,...g}=o;return h&&zt(a,"mockingbird-notifications-styles",ka),d&&(g.fetch=v=>d.fetch(v)),it(a,{embedded:!0,syncUrl:!1,...g})};var wn="emulators",me="notifications",Q=(a,o,d={})=>{let h=document.createElement(a);h.className=o;for(let[g,v]of Object.entries(d))h.setAttribute(g,v);return h},$n=0,yn=(a,o,d)=>{let h=`mbd-${++$n}`,g=[...o.tabs??[],...o.emulators?[{id:wn,label:o.emulators.label??"Emulators",mount:o.emulators.mount}]:[],...o.notifications?[{id:me,label:o.notifications.label??"Notifications",mount:null}]:[]];if(g.length===0)throw new Error("mountDashboard: pass tabs, emulators or notifications");let v=new Set;for(let b of g){if(v.has(b.id))throw new Error(`mountDashboard: duplicate tab id ${b.id}`);v.add(b.id)}(o.injectStyles??!0)&&zt(a,"mockingbird-dashboard-styles",za),a.classList.add(st),a.setAttribute("data-testid",l.dashboard),a.setAttribute("data-theme",o.theme??"dark"),a.replaceChildren();let $=Q("header","mbd-bar");if(o.title){let b=Q("div","mbd-brand"),z=Q("i","mbd-mark",{"aria-hidden":"true"});z.textContent="\\u25C6";let C=Q("span","");C.textContent=o.title,b.append(z,C),$.append(b)}let H=Q("div","mbd-tabs",{role:"tablist","aria-label":o.title??"Dashboard"}),y=Q("div","mbd-aside"),E=Q("div","mbd-panels");$.append(H,y),a.append($,E);let D=Q("span","mbd-badge",{"data-testid":l.dashboardBadge});D.hidden=!0;let W=0,F=()=>{D.hidden=W===0,D.textContent=W>99?"99+":String(W),D.setAttribute("data-count",String(W)),D.setAttribute("aria-label",`${W} new`)};F();let O=g.map(b=>{let z=Q("button","mbd-tab",{type:"button",role:"tab",id:`${h}-tab-${b.id}`,"aria-controls":`${h}-panel-${b.id}`,"aria-selected":"false",tabindex:"-1","data-testid":l.dashboardTab,"data-tab":b.id}),C=Q("span","");C.textContent=b.label,z.append(C),b.id===me&&z.append(D);let L=Q("section","mbd-panel",{role:"tabpanel",id:`${h}-panel-${b.id}`,"aria-labelledby":`${h}-tab-${b.id}`,"data-testid":l.dashboardPanel,"data-tab":b.id});return L.hidden=!0,H.append(z),E.append(L),{id:b.id,button:z,panel:L,mount:b.mount,mounted:!1,dispose:null}}),V=!1,ne="",_=(b,z,C)=>{let L=Q("div","mbd-status",{"data-kind":z});return L.textContent=C,b.panel.append(L),L},i=b=>{if(b.mounted||!b.mount)return;b.mounted=!0;let z=C=>{if(typeof C!="function")return;let L=C;V?L():b.dispose=L};try{let C=b.mount(b.panel);if(!(C instanceof Promise))return z(C);b.panel.setAttribute("aria-busy","true");let L=_(b,"loading","Loading\\u2026");C.then(U=>{L.remove(),b.panel.removeAttribute("aria-busy"),z(U)},U=>{L.remove(),b.panel.removeAttribute("aria-busy"),V||_(b,"error",U instanceof Error?U.message:String(U))})}catch(C){_(b,"error",C instanceof Error?C.message:String(C))}},M=b=>{let z=O.find(L=>L.id===b);if(!z||V||b===ne)return;let C=ne==="";ne=b,a.setAttribute("data-tab",b);for(let L of O){let U=L===z;L.button.setAttribute("aria-selected",String(U)),L.button.setAttribute("tabindex",U?"0":"-1"),L.panel.hidden=!U}if(b===me&&(W=0,F()),i(z),o.syncUrl&&typeof location<"u"&&typeof history<"u"){let L=new URL(location.href);L.searchParams.get("tab")!==b&&!(C&&!L.searchParams.has("tab"))&&(L.searchParams.set("tab",b),history.replaceState(history.state,"",L))}C||o.onTabChange?.(b)},he=b=>()=>M(b.id),Be=b=>z=>{let C=z.key,L=O.indexOf(b),U=C==="ArrowRight"?(L+1)%O.length:C==="ArrowLeft"?(L-1+O.length)%O.length:C==="Home"?0:C==="End"?O.length-1:-1,De=O[U];De&&(z.preventDefault(),M(De.id),De.button.focus())},rt=O.map(b=>{let z=he(b),C=Be(b);return b.button.addEventListener("click",z),b.button.addEventListener("keydown",C),()=>{b.button.removeEventListener("click",z),b.button.removeEventListener("keydown",C)}}),ue,q=O.find(b=>b.id===me);if(o.notifications&&q){let{label:b,onArrive:z,...C}=o.notifications;q.mounted=!0;let L=Q("div","mbd-fill");q.panel.append(L),ue=d(L,{...C,onArrive(U){ne!==me&&(W+=U.length,F()),z?.(U)}})}let Ee=[o.syncUrl&&typeof location<"u"?new URL(location.href).searchParams.get("tab"):null,o.initialTab].find(b=>b!=null&&O.some(z=>z.id===b));return M(Ee??O[0].id),{show:M,active:()=>ne,tabs:()=>O.map(b=>b.id),aside:y,...ue?{notifications:ue}:{},destroy(){if(!V){V=!0;for(let b of rt)b();ue?.destroy();for(let b of O){try{b.dispose?.()}catch{}b.dispose=null}a.replaceChildren(),a.classList.remove(st);for(let b of["data-testid","data-theme","data-tab"])a.removeAttribute(b)}}}},Da=(a,o)=>yn(a,o,Ea);var ot=document.getElementById("app"),kn=async()=>{try{let a=await fetch(new URL("api/admin",location.href));return a.ok?await a.json():null}catch{return null}},Tn=(a,o)=>new Promise((d,h)=>{let g=document.createElement("div");g.style.cssText="height:100%;color-scheme:light dark";let v=document.createElement("main");v.id="admin-root",v.setAttribute("data-mockingbird-admin",""),v.style.cssText="display:block;height:100%;overflow:auto",g.attachShadow({mode:"open"}).append(v),a.append(g);let $=document.createElement("script");$.src=new URL("admin/ui.js",location.href).href,$.onload=()=>{let H=globalThis.MockingbirdAdmin;if(!H)return h(new Error("The admin UI did not load."));let y=H.mount(v,o);d(()=>{typeof y=="function"?y():document.dispatchEvent(new Event("mockingbird:unmount")),g.remove()})},$.onerror=()=>h(new Error("The admin UI could not be loaded.")),document.head.append($)}),Sn=async()=>{let a=await kn();if(!a?.admin){it(ot,{live:!0});return}let o=new URLSearchParams(location.search),d=["view","to","from","id"].some(y=>o.has(y));document.documentElement.classList.add("mbd-page");let h=a.admin,g=Da(ot,{title:ot.dataset.title??"Mockingbird",syncUrl:!0,injectStyles:!1,initialTab:d?me:ot.dataset.defaultTab??me,emulators:{mount:y=>Tn(y,h)},notifications:{syncUrl:!0,baseUrl:location.href,injectStyles:!1}}),v=document.createElement("span");v.className="mbd-pill";let $=document.createElement("i");$.className="mbd-dot";let H=document.createElement("b");if(H.textContent=String(a.emulators.length),v.append($,H,` emulator${a.emulators.length===1?"":"s"}`),g.aside.append(v),a.fleet){let y=document.createElement("a");y.href=a.fleet.consoleUrl,y.target="_blank",y.rel="noopener noreferrer",y.textContent="Fleet console \\u2197",g.aside.append(y)}};Sn();\n';
|
|
197
|
-
|
|
198
|
-
// src/sources.ts
|
|
199
|
-
var isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
200
|
-
var row = (value) => isRow(value) ? value : {};
|
|
201
|
-
var str = (value) => typeof value === "string" ? value : typeof value === "number" ? String(value) : null;
|
|
202
|
-
var strings = (value) => Array.isArray(value) ? value.map(str).filter((v) => v !== null && v !== "") : typeof value === "string" && value !== "" ? [value] : [];
|
|
203
|
-
var list = (value, key) => {
|
|
204
|
-
const items = isRow(value) ? value[key] : value;
|
|
205
|
-
return Array.isArray(items) ? items.filter(isRow) : [];
|
|
206
|
-
};
|
|
207
|
-
var iso = (value) => {
|
|
208
|
-
if (typeof value === "number") return new Date(value < 1e11 ? value * 1e3 : value).toISOString();
|
|
209
|
-
if (typeof value === "string" && !Number.isNaN(Date.parse(value)))
|
|
210
|
-
return new Date(value).toISOString();
|
|
211
|
-
return (/* @__PURE__ */ new Date(0)).toISOString();
|
|
212
|
-
};
|
|
213
|
-
var parseAddress = (value) => {
|
|
214
|
-
const match = /^\s*"?([^"<]*?)"?\s*<([^>]+)>\s*$/.exec(value);
|
|
215
|
-
if (match) return { name: match[1]?.trim() || null, address: (match[2] ?? "").trim() };
|
|
216
|
-
return { name: null, address: value.trim() };
|
|
217
|
-
};
|
|
218
|
-
var bare = (value) => parseAddress(value).address.toLowerCase();
|
|
219
|
-
var stripHtml = (html) => html.replace(/<(style|script|head)[^>]*>[\s\S]*?<\/\1>/gi, " ").replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/[ \t]+/g, " ").replace(/\s*\n\s*/g, "\n").trim();
|
|
220
|
-
var preview = (text) => text.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
221
|
-
var base = (input, channel) => ({
|
|
222
|
-
id: `${input.context.source}:${input.context.namespace}:${input.providerId}${channel === "email" ? `#${input.to.toLowerCase()}` : ""}`,
|
|
223
|
-
providerId: input.providerId,
|
|
224
|
-
channel,
|
|
225
|
-
source: input.context.source,
|
|
226
|
-
service: input.service,
|
|
227
|
-
namespace: input.context.namespace,
|
|
228
|
-
to: input.to,
|
|
229
|
-
from: input.from,
|
|
230
|
-
createdAt: input.createdAt,
|
|
231
|
-
status: input.status ?? null,
|
|
232
|
-
raw: input.raw
|
|
233
|
-
});
|
|
234
|
-
var smsNotification = (input, sms) => ({
|
|
235
|
-
...base(input, "sms"),
|
|
236
|
-
preview: preview(sms.body),
|
|
237
|
-
sms: {
|
|
238
|
-
body: sms.body,
|
|
239
|
-
code: sms.code ?? null,
|
|
240
|
-
media: sms.media ?? [],
|
|
241
|
-
...sms.via === "whatsapp" ? { via: sms.via } : {}
|
|
242
|
-
},
|
|
243
|
-
email: null,
|
|
244
|
-
push: null,
|
|
245
|
-
chat: null
|
|
246
|
-
});
|
|
247
|
-
var emailNotifications = (input, recipients, email) => {
|
|
248
|
-
const content = {
|
|
249
|
-
subject: email.subject,
|
|
250
|
-
html: email.html ?? null,
|
|
251
|
-
text: email.text ?? null,
|
|
252
|
-
cc: email.cc ?? [],
|
|
253
|
-
bcc: email.bcc ?? [],
|
|
254
|
-
replyTo: email.replyTo ?? [],
|
|
255
|
-
attachments: email.attachments ?? [],
|
|
256
|
-
headers: email.headers ?? {}
|
|
257
|
-
};
|
|
258
|
-
const body = content.text ?? (content.html ? stripHtml(content.html) : "");
|
|
259
|
-
const seen = /* @__PURE__ */ new Set();
|
|
260
|
-
return recipients.flatMap((recipient) => {
|
|
261
|
-
const to = bare(recipient);
|
|
262
|
-
if (!to || seen.has(to)) return [];
|
|
263
|
-
seen.add(to);
|
|
264
|
-
return [
|
|
265
|
-
{
|
|
266
|
-
...base({ ...input, to }, "email"),
|
|
267
|
-
preview: preview(body),
|
|
268
|
-
sms: null,
|
|
269
|
-
email: content,
|
|
270
|
-
push: null,
|
|
271
|
-
chat: null
|
|
272
|
-
}
|
|
273
|
-
];
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
var pushNotification = (input, push) => ({
|
|
277
|
-
...base(input, "push"),
|
|
278
|
-
preview: preview([push.title, push.body].filter(Boolean).join(" \u2014 ")),
|
|
279
|
-
sms: null,
|
|
280
|
-
email: null,
|
|
281
|
-
push,
|
|
282
|
-
chat: null
|
|
283
|
-
});
|
|
284
|
-
var chatNotification = (input, chat, summary) => ({
|
|
285
|
-
...base(input, "chat"),
|
|
286
|
-
preview: preview(summary),
|
|
287
|
-
sms: null,
|
|
288
|
-
email: null,
|
|
289
|
-
push: null,
|
|
290
|
-
chat
|
|
291
|
-
});
|
|
292
|
-
var WHATSAPP = /^whatsapp:/i;
|
|
293
|
-
var twilio = async (context) => {
|
|
294
|
-
const messages = list(await context.read("/outbox"), "messages");
|
|
295
|
-
return messages.flatMap((m) => {
|
|
296
|
-
const providerId = str(m.id) ?? str(m.sid) ?? "";
|
|
297
|
-
const body = str(m.body) ?? "";
|
|
298
|
-
const recipient = str(m.to) ?? "";
|
|
299
|
-
const verify = m.kind === "verify";
|
|
300
|
-
const whatsapp = m.channel === "whatsapp" || WHATSAPP.test(recipient) || WHATSAPP.test(str(m.from) ?? "");
|
|
301
|
-
const to = recipient.replace(WHATSAPP, "");
|
|
302
|
-
const origin = str(m.from) ?? str(m.messagingServiceSid) ?? (verify ? "Verify" : "Twilio");
|
|
303
|
-
const sender = whatsapp ? `whatsapp:${origin.replace(WHATSAPP, "")}` : origin;
|
|
304
|
-
const common = {
|
|
305
|
-
context,
|
|
306
|
-
service: "twilio",
|
|
307
|
-
providerId,
|
|
308
|
-
from: { name: verify && !m.from ? "Verify" : null, address: sender },
|
|
309
|
-
createdAt: iso(m.createdAt),
|
|
310
|
-
status: str(m.status),
|
|
311
|
-
raw: m
|
|
312
|
-
};
|
|
313
|
-
if (m.channel === "email")
|
|
314
|
-
return emailNotifications(common, [to], {
|
|
315
|
-
subject: "Your verification code",
|
|
316
|
-
text: body
|
|
317
|
-
});
|
|
318
|
-
return [
|
|
319
|
-
smsNotification(
|
|
320
|
-
{ ...common, to },
|
|
321
|
-
{
|
|
322
|
-
body,
|
|
323
|
-
code: str(m.code),
|
|
324
|
-
media: strings(m.mediaUrls),
|
|
325
|
-
...whatsapp ? { via: "whatsapp" } : {}
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
];
|
|
329
|
-
});
|
|
330
|
-
};
|
|
331
|
-
var resend = async (context) => list(await context.read("/outbox"), "messages").flatMap((m) => {
|
|
332
|
-
const cc = strings(m.cc);
|
|
333
|
-
const bcc = strings(m.bcc);
|
|
334
|
-
return emailNotifications(
|
|
335
|
-
{
|
|
336
|
-
context,
|
|
337
|
-
service: "resend",
|
|
338
|
-
providerId: str(m.id) ?? "",
|
|
339
|
-
from: parseAddress(str(m.from) ?? ""),
|
|
340
|
-
createdAt: iso(m.createdAt),
|
|
341
|
-
status: m.scheduledAt ? "scheduled" : "delivered",
|
|
342
|
-
raw: m
|
|
343
|
-
},
|
|
344
|
-
[...strings(m.to), ...cc, ...bcc],
|
|
345
|
-
{
|
|
346
|
-
subject: str(m.subject) ?? "",
|
|
347
|
-
html: str(m.html),
|
|
348
|
-
text: str(m.text),
|
|
349
|
-
cc,
|
|
350
|
-
bcc,
|
|
351
|
-
replyTo: strings(m.replyTo),
|
|
352
|
-
headers: Object.fromEntries(Object.entries(row(m.headers)).map(([k, v]) => [k, String(v)])),
|
|
353
|
-
attachments: list(m.attachments, "").map((a) => ({
|
|
354
|
-
filename: str(a.filename) ?? "attachment",
|
|
355
|
-
contentType: str(a.contentType),
|
|
356
|
-
size: typeof a.size === "number" ? a.size : null
|
|
357
|
-
}))
|
|
358
|
-
}
|
|
359
|
-
);
|
|
360
|
-
});
|
|
361
|
-
var platformOf = (value) => value === "android" || value === "ios" || value === "web" ? value : "unknown";
|
|
362
|
-
var fcm = async (context) => list(await context.read("/outbox"), "messages").map((m) => {
|
|
363
|
-
const wire = row(m.wire);
|
|
364
|
-
const notification = row(m.notification ?? wire.notification);
|
|
365
|
-
const android = row(row(m.android ?? wire.android).notification);
|
|
366
|
-
const aps = row(row(row(m.apns ?? wire.apns).payload).aps);
|
|
367
|
-
const alert = isRow(aps.alert) ? aps.alert : { body: aps.alert };
|
|
368
|
-
const webpush = row(row(wire.webpush).notification);
|
|
369
|
-
const platform = platformOf(m.platform);
|
|
370
|
-
const pick = (key) => (platform === "android" ? str(android[key]) : null) ?? (platform === "ios" ? str(alert[key]) : null) ?? (platform === "web" ? str(webpush[key]) : null) ?? str(notification[key]);
|
|
371
|
-
const image = (platform === "android" ? str(android.image) : null) ?? str(row(row(m.apns ?? wire.apns).fcm_options).image) ?? str(notification.image);
|
|
372
|
-
const project = str(m.project) ?? "app";
|
|
373
|
-
return pushNotification(
|
|
374
|
-
{
|
|
375
|
-
context,
|
|
376
|
-
service: "fcm",
|
|
377
|
-
providerId: str(m.id) ?? str(m.name) ?? "",
|
|
378
|
-
to: str(m.token) ?? "",
|
|
379
|
-
from: { name: project, address: str(m.name) ?? project },
|
|
380
|
-
createdAt: iso(m.acceptedAt),
|
|
381
|
-
status: str(m.state),
|
|
382
|
-
raw: m
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
title: pick("title"),
|
|
386
|
-
body: pick("body"),
|
|
387
|
-
imageUrl: image,
|
|
388
|
-
app: project,
|
|
389
|
-
platform,
|
|
390
|
-
data: Object.fromEntries(
|
|
391
|
-
Object.entries(row(m.data ?? wire.data)).map(([k, v]) => [k, String(v)])
|
|
392
|
-
),
|
|
393
|
-
badge: typeof aps.badge === "number" ? aps.badge : null,
|
|
394
|
-
sound: str(aps.sound) ?? str(android.sound)
|
|
395
|
-
}
|
|
396
|
-
);
|
|
397
|
-
});
|
|
398
|
-
var stateRecords = async (read, collection) => {
|
|
399
|
-
const out = [];
|
|
400
|
-
let after = null;
|
|
401
|
-
for (let page = 0; page < 100; page++) {
|
|
402
|
-
const query = after === null ? "" : `&after=${encodeURIComponent(String(after))}`;
|
|
403
|
-
const result = row(await read(`/state/${collection}?limit=200&order=oldest${query}`));
|
|
404
|
-
for (const record of list(result, "records")) out.push(record);
|
|
405
|
-
if (result.next === null || result.next === void 0) break;
|
|
406
|
-
after = result.next;
|
|
407
|
-
}
|
|
408
|
-
return out;
|
|
409
|
-
};
|
|
410
|
-
var ses = async (context) => (await stateRecords(context.read, "ses_messages")).flatMap((record) => {
|
|
411
|
-
const v = row(record.value);
|
|
412
|
-
const destination = row(v.Destination);
|
|
413
|
-
const common = {
|
|
414
|
-
context,
|
|
415
|
-
service: "ses",
|
|
416
|
-
providerId: str(v.MessageId) ?? str(record.id) ?? "",
|
|
417
|
-
createdAt: iso(v.Timestamp),
|
|
418
|
-
status: "delivered",
|
|
419
|
-
raw: v
|
|
420
|
-
};
|
|
421
|
-
const raw = row(v.RawMessage);
|
|
422
|
-
if (raw.Data !== void 0) {
|
|
423
|
-
const mime = parseMime(decodeRawMessage(str(raw.Data) ?? ""));
|
|
424
|
-
const recipients = strings(v.Destinations);
|
|
425
|
-
return emailNotifications(
|
|
426
|
-
{ ...common, from: parseAddress(str(v.Source) ?? mime.from ?? "") },
|
|
427
|
-
recipients.length ? recipients : [...mime.to, ...mime.cc],
|
|
428
|
-
{
|
|
429
|
-
subject: mime.subject,
|
|
430
|
-
html: mime.html,
|
|
431
|
-
text: mime.text,
|
|
432
|
-
cc: mime.cc,
|
|
433
|
-
attachments: mime.attachments,
|
|
434
|
-
headers: mime.headers,
|
|
435
|
-
replyTo: addressList(mime.headers["reply-to"])
|
|
436
|
-
}
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
const message = row(v.Message);
|
|
440
|
-
const body = row(message.Body);
|
|
441
|
-
const cc = strings(destination.CcAddresses);
|
|
442
|
-
const bcc = strings(destination.BccAddresses);
|
|
443
|
-
return emailNotifications(
|
|
444
|
-
{ ...common, from: parseAddress(str(v.Source) ?? "") },
|
|
445
|
-
[...strings(destination.ToAddresses), ...cc, ...bcc],
|
|
446
|
-
{
|
|
447
|
-
subject: str(row(message.Subject).Data) ?? "",
|
|
448
|
-
html: str(row(body.Html).Data),
|
|
449
|
-
text: str(row(body.Text).Data),
|
|
450
|
-
cc,
|
|
451
|
-
bcc,
|
|
452
|
-
replyTo: strings(v.ReplyToAddresses)
|
|
453
|
-
}
|
|
454
|
-
);
|
|
455
|
-
});
|
|
456
|
-
var snsBody = (v, protocol) => {
|
|
457
|
-
const message = str(v.Message) ?? "";
|
|
458
|
-
if (v.MessageStructure !== "json") return message;
|
|
459
|
-
try {
|
|
460
|
-
const parsed = row(JSON.parse(message));
|
|
461
|
-
return str(parsed[protocol]) ?? str(parsed.default) ?? message;
|
|
462
|
-
} catch {
|
|
463
|
-
return message;
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
var sns = async (context) => {
|
|
467
|
-
const [messages, subscriptions] = await Promise.all([
|
|
468
|
-
stateRecords(context.read, "sns_messages"),
|
|
469
|
-
stateRecords(context.read, "sns_subscriptions")
|
|
470
|
-
]);
|
|
471
|
-
return messages.flatMap((record) => {
|
|
472
|
-
const v = row(record.value);
|
|
473
|
-
const providerId = str(v.MessageId) ?? str(record.id) ?? "";
|
|
474
|
-
const common = { context, service: "sns", createdAt: iso(v.Timestamp), raw: v };
|
|
475
|
-
const phone = str(v.PhoneNumber);
|
|
476
|
-
if (phone)
|
|
477
|
-
return [
|
|
478
|
-
smsNotification(
|
|
479
|
-
{
|
|
480
|
-
...common,
|
|
481
|
-
providerId,
|
|
482
|
-
to: phone,
|
|
483
|
-
from: { name: null, address: "SNS" },
|
|
484
|
-
status: "delivered"
|
|
485
|
-
},
|
|
486
|
-
{ body: snsBody(v, "sms") }
|
|
487
|
-
)
|
|
488
|
-
];
|
|
489
|
-
const topicArn = str(v.TopicArn) ?? "";
|
|
490
|
-
const topicName = topicArn.split(":").at(-1) ?? "SNS";
|
|
491
|
-
return subscriptions.flatMap((sub) => {
|
|
492
|
-
const s = row(sub.value);
|
|
493
|
-
if (s.TopicArn !== topicArn) return [];
|
|
494
|
-
const endpoint = str(s.Endpoint) ?? "";
|
|
495
|
-
const subId = `${providerId}@${str(s.SubscriptionArn) ?? endpoint}`;
|
|
496
|
-
if (s.Protocol === "sms")
|
|
497
|
-
return [
|
|
498
|
-
smsNotification(
|
|
499
|
-
{
|
|
500
|
-
...common,
|
|
501
|
-
providerId: subId,
|
|
502
|
-
to: endpoint,
|
|
503
|
-
from: { name: topicName, address: topicName },
|
|
504
|
-
status: "delivered"
|
|
505
|
-
},
|
|
506
|
-
{ body: snsBody(v, "sms") }
|
|
507
|
-
)
|
|
508
|
-
];
|
|
509
|
-
if (s.Protocol === "email" || s.Protocol === "email-json") {
|
|
510
|
-
const text = s.Protocol === "email-json" ? JSON.stringify(
|
|
511
|
-
{
|
|
512
|
-
Type: "Notification",
|
|
513
|
-
MessageId: providerId,
|
|
514
|
-
TopicArn: topicArn,
|
|
515
|
-
Subject: v.Subject ?? null,
|
|
516
|
-
Message: snsBody(v, "email-json")
|
|
517
|
-
},
|
|
518
|
-
null,
|
|
519
|
-
2
|
|
520
|
-
) : `${snsBody(v, "email")}
|
|
521
|
-
|
|
522
|
-
--
|
|
523
|
-
If you wish to stop receiving notifications from this topic, please unsubscribe.
|
|
524
|
-
|
|
525
|
-
Please do not reply directly to this email. If you have any questions or comments regarding this email, please contact us at https://aws.amazon.com/support`;
|
|
526
|
-
return emailNotifications(
|
|
527
|
-
{
|
|
528
|
-
...common,
|
|
529
|
-
providerId: subId,
|
|
530
|
-
from: { name: "AWS Notifications", address: "no-reply@sns.amazonaws.com" },
|
|
531
|
-
status: "delivered"
|
|
532
|
-
},
|
|
533
|
-
[endpoint],
|
|
534
|
-
{ subject: str(v.Subject) ?? "AWS Notification Message", text }
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
return [];
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
var escapeHtml = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
542
|
-
var templatePreview = (m) => {
|
|
543
|
-
const data = Object.entries(row(m.messageData));
|
|
544
|
-
const rows = data.map(
|
|
545
|
-
([k, v]) => `<tr><td style="padding:6px 12px;color:#6b7280;font:13px system-ui">${escapeHtml(k)}</td><td style="padding:6px 12px;font:13px ui-monospace,monospace">${escapeHtml(typeof v === "string" ? v : JSON.stringify(v))}</td></tr>`
|
|
546
|
-
).join("");
|
|
547
|
-
const links = strings(m.links).map(
|
|
548
|
-
(href) => `<p style="font:13px system-ui"><a href="${escapeHtml(href)}">${escapeHtml(href)}</a></p>`
|
|
549
|
-
).join("");
|
|
550
|
-
return `<div style="font:14px system-ui;color:#111827;padding:8px"><p style="margin:0 0 4px;color:#6b7280;font-size:12px">Customer.io transactional message <b>${escapeHtml(str(m.transactionalMessageId) ?? "")}</b></p><p style="margin:0 0 12px;color:#6b7280;font-size:12px">The template body is rendered by Customer.io; these are the <code>message_data</code> values it was sent with.</p>${rows ? `<table style="border-collapse:collapse;border:1px solid #e5e7eb;border-radius:8px">${rows}</table>` : "<p><i>No message_data.</i></p>"}${links}</div>`;
|
|
551
|
-
};
|
|
552
|
-
var customerio = async (context) => list(await context.read("/outbox"), "messages").flatMap((m) => {
|
|
553
|
-
const identifiers = row(m.identifiers);
|
|
554
|
-
const to = str(m.to) ?? str(identifiers.email) ?? str(identifiers.id) ?? "";
|
|
555
|
-
const state = str(m.state);
|
|
556
|
-
const common = {
|
|
557
|
-
context,
|
|
558
|
-
service: "customerio",
|
|
559
|
-
providerId: str(m.id) ?? "",
|
|
560
|
-
createdAt: iso(m.createdAt),
|
|
561
|
-
status: state,
|
|
562
|
-
raw: m
|
|
563
|
-
};
|
|
564
|
-
const templateId = str(m.transactionalMessageId) ?? "message";
|
|
565
|
-
if (m.channel === "sms") {
|
|
566
|
-
const data = row(m.messageData);
|
|
567
|
-
const body = str(data.body) ?? str(data.message) ?? str(data.text) ?? `[${templateId}] ${Object.entries(data).map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ")}`.trim();
|
|
568
|
-
return [
|
|
569
|
-
smsNotification(
|
|
570
|
-
{ ...common, to, from: { name: null, address: str(m.from) ?? "Customer.io" } },
|
|
571
|
-
{ body }
|
|
572
|
-
)
|
|
573
|
-
];
|
|
574
|
-
}
|
|
575
|
-
if (m.channel === "email")
|
|
576
|
-
return emailNotifications(
|
|
577
|
-
{ ...common, from: parseAddress(str(m.from) ?? "Customer.io <no-reply@customer.io>") },
|
|
578
|
-
[to],
|
|
579
|
-
{
|
|
580
|
-
subject: str(m.subject) ?? `Transactional message ${templateId}`,
|
|
581
|
-
html: templatePreview(m),
|
|
582
|
-
attachments: strings(m.attachments).map((filename) => ({
|
|
583
|
-
filename,
|
|
584
|
-
contentType: null,
|
|
585
|
-
size: null
|
|
586
|
-
}))
|
|
587
|
-
}
|
|
588
|
-
);
|
|
589
|
-
return [];
|
|
590
|
-
});
|
|
591
|
-
var mailosaurAddress = (value) => {
|
|
592
|
-
const a = row(value);
|
|
593
|
-
return str(a.email) ?? str(a.phone) ?? str(a.phoneNumber) ?? "";
|
|
594
|
-
};
|
|
595
|
-
var mailosaur = async (context) => list(await context.read("/outbox"), "messages").flatMap((entry) => {
|
|
596
|
-
const m = row(entry.message);
|
|
597
|
-
const from = row(list(m.from, "")[0]);
|
|
598
|
-
const recipients = list(m.to, "").map(mailosaurAddress).filter(Boolean);
|
|
599
|
-
const common = {
|
|
600
|
-
context,
|
|
601
|
-
service: "mailosaur",
|
|
602
|
-
providerId: str(entry.id) ?? str(m.id) ?? "",
|
|
603
|
-
createdAt: iso(m.received ?? entry.createdAt),
|
|
604
|
-
status: "received",
|
|
605
|
-
raw: entry
|
|
606
|
-
};
|
|
607
|
-
const html = str(row(m.html).body);
|
|
608
|
-
const text = str(row(m.text).body);
|
|
609
|
-
if (m.type === "SMS")
|
|
610
|
-
return recipients.map(
|
|
611
|
-
(to) => smsNotification(
|
|
612
|
-
{
|
|
613
|
-
...common,
|
|
614
|
-
to,
|
|
615
|
-
from: { name: str(from.name) || null, address: mailosaurAddress(from) }
|
|
616
|
-
},
|
|
617
|
-
{ body: text ?? (html ? stripHtml(html) : "") }
|
|
618
|
-
)
|
|
619
|
-
);
|
|
620
|
-
return emailNotifications(
|
|
621
|
-
{ ...common, from: { name: str(from.name) || null, address: mailosaurAddress(from) } },
|
|
622
|
-
[...recipients, ...list(m.cc, "").map(mailosaurAddress)],
|
|
623
|
-
{
|
|
624
|
-
subject: str(m.subject) ?? "",
|
|
625
|
-
html,
|
|
626
|
-
text,
|
|
627
|
-
cc: list(m.cc, "").map(mailosaurAddress),
|
|
628
|
-
attachments: list(m.attachments, "").map((a) => ({
|
|
629
|
-
filename: str(a.fileName) ?? str(a.filename) ?? "attachment",
|
|
630
|
-
contentType: str(a.contentType),
|
|
631
|
-
size: typeof a.length === "number" ? a.length : null
|
|
632
|
-
}))
|
|
633
|
-
}
|
|
634
|
-
);
|
|
635
|
-
});
|
|
636
|
-
var mrkdwnText = (text, names) => text.replace(/<@([A-Z0-9]+)(?:\|([^>]*))?>/g, (_, id, label) => {
|
|
637
|
-
return `@${label || names.get(id) || id}`;
|
|
638
|
-
}).replace(/<#([A-Z0-9]+)(?:\|([^>]*))?>/g, (_, id, label) => {
|
|
639
|
-
return `#${label || names.get(id) || id}`;
|
|
640
|
-
}).replace(/<!(here|channel|everyone)(?:\|[^>]*)?>/g, "@$1").replace(/<([^|>]+)\|([^>]*)>/g, "$2").replace(/<([^>]+)>/g, "$1").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
641
|
-
var blockText = (value, out = []) => {
|
|
642
|
-
if (Array.isArray(value)) for (const item of value) blockText(item, out);
|
|
643
|
-
if (!isRow(value)) return out;
|
|
644
|
-
for (const key of ["pretext", "title", "text", "alt_text", "footer"]) {
|
|
645
|
-
const text = value[key];
|
|
646
|
-
if (typeof text === "string" && text.trim() !== "") out.push(text);
|
|
647
|
-
else blockText(text, out);
|
|
648
|
-
}
|
|
649
|
-
for (const field of list(value.fields, "")) {
|
|
650
|
-
const pair = [str(field.title), str(field.value)].filter(Boolean).join(": ");
|
|
651
|
-
if (pair) out.push(pair);
|
|
652
|
-
else blockText(field, out);
|
|
653
|
-
}
|
|
654
|
-
blockText(value.elements, out);
|
|
655
|
-
blockText(value.blocks, out);
|
|
656
|
-
return out;
|
|
657
|
-
};
|
|
658
|
-
var optional = (read, path) => read(path).catch(() => null);
|
|
659
|
-
var slack = async (context) => {
|
|
660
|
-
const [outbox, channelList, userList, settings] = await Promise.all([
|
|
661
|
-
context.read("/outbox"),
|
|
662
|
-
optional(context.read, "/channels"),
|
|
663
|
-
optional(context.read, "/users"),
|
|
664
|
-
optional(context.read, "/settings")
|
|
665
|
-
]);
|
|
666
|
-
const team = row(settings);
|
|
667
|
-
const names = /* @__PURE__ */ new Map();
|
|
668
|
-
const people = /* @__PURE__ */ new Map();
|
|
669
|
-
for (const channel of list(channelList, "channels"))
|
|
670
|
-
if (str(channel.id) && str(channel.name))
|
|
671
|
-
names.set(str(channel.id) ?? "", str(channel.name) ?? "");
|
|
672
|
-
for (const user of list(userList, "users")) {
|
|
673
|
-
const id = str(user.id) ?? "";
|
|
674
|
-
people.set(id, user);
|
|
675
|
-
names.set(id, str(user.name) ?? id);
|
|
676
|
-
}
|
|
677
|
-
const bot = str(team.botUserId);
|
|
678
|
-
return list(outbox, "messages").map((m) => {
|
|
679
|
-
const webhook = str(m.webhook);
|
|
680
|
-
const channel = str(m.channel) ?? webhook ?? "";
|
|
681
|
-
const name = strings(m.to).find((entry) => entry.startsWith("#")) ?? names.get(channel);
|
|
682
|
-
const ephemeral = m.ephemeral === true;
|
|
683
|
-
const author = webhook ? null : ephemeral ? bot : str(m.user) ?? bot;
|
|
684
|
-
const person = row(author ? people.get(author) : null);
|
|
685
|
-
const text = str(m.text) ?? "";
|
|
686
|
-
const blocks = Array.isArray(m.blocks) ? m.blocks : [];
|
|
687
|
-
const attachments = Array.isArray(m.attachments) ? m.attachments : [];
|
|
688
|
-
const summary = text || [...blockText(blocks), ...blockText(attachments)].join(" ");
|
|
689
|
-
const body = JSON.stringify([text, blocks, attachments]);
|
|
690
|
-
const mentioned = Object.fromEntries([...names].filter(([id]) => id && body.includes(id)));
|
|
691
|
-
return chatNotification(
|
|
692
|
-
{
|
|
693
|
-
context,
|
|
694
|
-
service: "slack",
|
|
695
|
-
providerId: str(m.id) ?? `${channel}:${str(m.ts) ?? ""}`,
|
|
696
|
-
to: webhook ?? (name ? `#${name.replace(/^#/, "")}` : channel),
|
|
697
|
-
from: webhook ? { name: "Incoming Webhook", address: "incoming-webhook" } : {
|
|
698
|
-
name: str(person.real_name) ?? str(person.name) ?? null,
|
|
699
|
-
address: author ?? "bot"
|
|
700
|
-
},
|
|
701
|
-
createdAt: iso(m.createdAt),
|
|
702
|
-
status: ephemeral ? "ephemeral" : null,
|
|
703
|
-
raw: m
|
|
704
|
-
},
|
|
705
|
-
{
|
|
706
|
-
text,
|
|
707
|
-
workspace: str(team.teamName) ?? str(m.workspace),
|
|
708
|
-
method: str(m.method) ?? (webhook ? "incoming-webhook" : "chat.postMessage"),
|
|
709
|
-
blocks,
|
|
710
|
-
attachments,
|
|
711
|
-
threadTs: str(m.thread_ts),
|
|
712
|
-
ephemeral,
|
|
713
|
-
edited: isRow(m.edited),
|
|
714
|
-
reactions: list(m.reactions, "").map((reaction) => ({
|
|
715
|
-
name: str(reaction.name) ?? "",
|
|
716
|
-
count: typeof reaction.count === "number" ? reaction.count : 1
|
|
717
|
-
})),
|
|
718
|
-
names: mentioned
|
|
719
|
-
},
|
|
720
|
-
mrkdwnText(summary, names)
|
|
721
|
-
);
|
|
722
|
-
});
|
|
723
|
-
};
|
|
724
|
-
var READERS = {
|
|
725
|
-
twilio,
|
|
726
|
-
resend,
|
|
727
|
-
fcm,
|
|
728
|
-
ses,
|
|
729
|
-
sns,
|
|
730
|
-
customerio,
|
|
731
|
-
mailosaur,
|
|
732
|
-
slack
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
// src/ui/page.ts
|
|
736
|
-
var escapeHtml2 = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
737
|
-
var renderPage = ({
|
|
738
|
-
title,
|
|
739
|
-
defaultTab = "notifications"
|
|
740
|
-
}) => `<!doctype html>
|
|
741
|
-
<html lang="en">
|
|
742
|
-
<head>
|
|
743
|
-
<meta charset="utf-8">
|
|
744
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
745
|
-
<meta name="color-scheme" content="dark">
|
|
746
|
-
<title>${escapeHtml2(title)} \xB7 Mockingbird</title>
|
|
747
|
-
<link rel="icon" href="data:image/svg+xml,${encodeURIComponent(
|
|
748
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#0a84ff"/><path d="M9 13a7 7 0 0 1 14 0v5l2 3H7l2-3z" fill="#fff"/><circle cx="16" cy="24.5" r="2.5" fill="#fff"/></svg>'
|
|
749
|
-
)}">
|
|
750
|
-
<style>${PAGE_STYLES}${DASHBOARD_PAGE_STYLES}${STYLES}${DASHBOARD_STYLES}</style>
|
|
751
|
-
</head>
|
|
752
|
-
<body>
|
|
753
|
-
<div id="app" data-title="${escapeHtml2(title)}" data-default-tab="${defaultTab}"><div class="boot">Loading notifications\u2026</div></div>
|
|
754
|
-
<script type="module" src="./ui.js"></script>
|
|
755
|
-
</body>
|
|
756
|
-
</html>`;
|
|
757
|
-
|
|
758
|
-
// src/harness.ts
|
|
759
|
-
var json = (status, body, headers = {}) => new Response(JSON.stringify(body, null, 2), {
|
|
760
|
-
status,
|
|
761
|
-
headers: { "content-type": "application/json; charset=utf-8", ...headers }
|
|
762
|
-
});
|
|
763
|
-
var errorBody = (status, message) => json(status, { error: { type: "mockingbird_notifications", message } });
|
|
764
|
-
var REDISCOVER_MS = 2e3;
|
|
765
|
-
var DUPLICATE_WINDOW_MS = 1e4;
|
|
766
|
-
var fingerprint = (n) => [
|
|
767
|
-
n.channel,
|
|
768
|
-
n.namespace,
|
|
769
|
-
n.to.toLowerCase(),
|
|
770
|
-
n.from.address.toLowerCase(),
|
|
771
|
-
n.email?.subject ?? "",
|
|
772
|
-
n.preview
|
|
773
|
-
].join("\0");
|
|
774
|
-
var dedupe = (items) => {
|
|
775
|
-
const senders = /* @__PURE__ */ new Map();
|
|
776
|
-
for (const n of items)
|
|
777
|
-
if (n.service !== "mailosaur") {
|
|
778
|
-
const key = fingerprint(n);
|
|
779
|
-
senders.set(key, [...senders.get(key) ?? [], Date.parse(n.createdAt)]);
|
|
780
|
-
}
|
|
781
|
-
return items.filter((n) => {
|
|
782
|
-
if (n.service !== "mailosaur") return true;
|
|
783
|
-
const at = Date.parse(n.createdAt);
|
|
784
|
-
return !(senders.get(fingerprint(n)) ?? []).some((t) => Math.abs(t - at) <= DUPLICATE_WINDOW_MS);
|
|
785
|
-
});
|
|
786
|
-
};
|
|
787
|
-
var byTime = (a, b) => a.createdAt === b.createdAt ? a.id.localeCompare(b.id) : a.createdAt < b.createdAt ? -1 : 1;
|
|
788
|
-
var createNotificationHarness = (options = {}) => {
|
|
789
|
-
if (!options.fleet && !options.manifest && !options.services)
|
|
790
|
-
throw new Error("createNotificationHarness: pass fleet, manifest or services");
|
|
791
|
-
const fetchImpl = options.fetch ?? ((request) => fetch(request));
|
|
792
|
-
const authHeaders = options.adminKey ? { "x-mockingbird-admin-key": options.adminKey } : {};
|
|
793
|
-
const headersFor = (name) => {
|
|
794
|
-
const key = options.adminKeys?.[name];
|
|
795
|
-
return key ? { "x-mockingbird-admin-key": key } : authHeaders;
|
|
796
|
-
};
|
|
797
|
-
const followAll = (options.namespaces ?? (options.fleet ? "all" : void 0)) === "all";
|
|
798
|
-
const watched = new Set(
|
|
799
|
-
Array.isArray(options.namespaces) ? options.namespaces : ["default"]
|
|
800
|
-
);
|
|
801
|
-
const buckets = /* @__PURE__ */ new Map();
|
|
802
|
-
const statuses = /* @__PURE__ */ new Map();
|
|
803
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
804
|
-
const explicit = options.services ? endpointsFromServices(options.services, fetchImpl) : [];
|
|
805
|
-
let endpoints = explicit;
|
|
806
|
-
const explicitAdmins = options.services ? adminTargetsFromServices(options.services, fetchImpl) : [];
|
|
807
|
-
let admins = explicitAdmins;
|
|
808
|
-
let discoveredAt = 0;
|
|
809
|
-
let discoveryError = null;
|
|
810
|
-
let discovering = null;
|
|
811
|
-
const rejected = /* @__PURE__ */ new Set();
|
|
812
|
-
const rediscover = async (force = false) => {
|
|
813
|
-
if (!options.fleet && !options.manifest) return;
|
|
814
|
-
if (!force && Date.now() - discoveredAt < REDISCOVER_MS) return;
|
|
815
|
-
discovering ??= (async () => {
|
|
816
|
-
try {
|
|
817
|
-
let found = [];
|
|
818
|
-
let foundAdmins = [];
|
|
819
|
-
if (options.fleet) {
|
|
820
|
-
const fleet = await discoverFleet(options.fleet, fetchImpl, authHeaders);
|
|
821
|
-
found = fleet.endpoints;
|
|
822
|
-
foundAdmins = fleet.admins;
|
|
823
|
-
if (followAll) for (const ns of fleet.namespaces) watched.add(ns);
|
|
824
|
-
} else if (options.manifest) {
|
|
825
|
-
const manifest = typeof options.manifest === "function" ? await options.manifest() : options.manifest;
|
|
826
|
-
found = endpointsFromManifest(manifest, fetchImpl);
|
|
827
|
-
foundAdmins = adminTargetsFromManifest(manifest, fetchImpl);
|
|
828
|
-
}
|
|
829
|
-
admins = [
|
|
830
|
-
...explicitAdmins,
|
|
831
|
-
...foundAdmins.filter((a) => !explicitAdmins.some((x) => x.name === a.name))
|
|
832
|
-
];
|
|
833
|
-
const known = new Map(endpoints.map((e) => [`${e.name}|${e.adminUrl}`, e.service]));
|
|
834
|
-
endpoints = [
|
|
835
|
-
...explicit,
|
|
836
|
-
...found.filter(
|
|
837
|
-
(e) => !explicit.some((x) => x.name === e.name) && !rejected.has(`${e.name}|${e.adminUrl}`)
|
|
838
|
-
).map((e) => ({
|
|
839
|
-
...e,
|
|
840
|
-
service: e.service ?? known.get(`${e.name}|${e.adminUrl}`) ?? null
|
|
841
|
-
}))
|
|
842
|
-
];
|
|
843
|
-
discoveryError = null;
|
|
844
|
-
} catch (error) {
|
|
845
|
-
discoveryError = error instanceof Error ? error.message : String(error);
|
|
846
|
-
} finally {
|
|
847
|
-
discoveredAt = Date.now();
|
|
848
|
-
discovering = null;
|
|
849
|
-
}
|
|
850
|
-
})();
|
|
851
|
-
await discovering;
|
|
852
|
-
};
|
|
853
|
-
const adminGet = (endpoint, namespace) => async (path) => {
|
|
854
|
-
const response = await endpoint.fetch(
|
|
855
|
-
new Request(`${endpoint.adminUrl}${path}`, {
|
|
856
|
-
headers: {
|
|
857
|
-
...headersFor(endpoint.name),
|
|
858
|
-
"x-mockingbird-namespace": namespace,
|
|
859
|
-
accept: "application/json"
|
|
860
|
-
}
|
|
861
|
-
})
|
|
862
|
-
);
|
|
863
|
-
if (!response.ok) {
|
|
864
|
-
const text = await response.text().catch(() => "");
|
|
865
|
-
throw new Error(`GET ${path}: HTTP ${response.status} ${text.slice(0, 200)}`);
|
|
866
|
-
}
|
|
867
|
-
return response.json();
|
|
868
|
-
};
|
|
869
|
-
const identify = async (endpoint) => {
|
|
870
|
-
if (endpoint.service) return;
|
|
871
|
-
const health = await adminGet(endpoint, "default")("/health");
|
|
872
|
-
endpoint.service = asServiceKind(health.service);
|
|
873
|
-
if (!endpoint.service) throw new Error(`not a messaging emulator (${String(health.service)})`);
|
|
874
|
-
};
|
|
875
|
-
const bucket = (namespace) => {
|
|
876
|
-
let b = buckets.get(namespace);
|
|
877
|
-
if (!b) {
|
|
878
|
-
b = { notifications: /* @__PURE__ */ new Map(), inFlight: null, queued: null, version: 0 };
|
|
879
|
-
buckets.set(namespace, b);
|
|
880
|
-
}
|
|
881
|
-
return b;
|
|
882
|
-
};
|
|
883
|
-
const readAll = async (namespace) => {
|
|
884
|
-
await rediscover();
|
|
885
|
-
const results = await Promise.all(
|
|
886
|
-
endpoints.map(async (endpoint) => {
|
|
887
|
-
const key = endpoint.name;
|
|
888
|
-
const status = statuses.get(key) ?? {
|
|
889
|
-
name: endpoint.name,
|
|
890
|
-
service: endpoint.service,
|
|
891
|
-
url: endpoint.adminUrl,
|
|
892
|
-
ok: false,
|
|
893
|
-
error: null,
|
|
894
|
-
count: 0,
|
|
895
|
-
lastSyncAt: null
|
|
896
|
-
};
|
|
897
|
-
statuses.set(key, status);
|
|
898
|
-
try {
|
|
899
|
-
await identify(endpoint);
|
|
900
|
-
const service = endpoint.service;
|
|
901
|
-
if (!service) return { ok: false };
|
|
902
|
-
const items = await READERS[service]({
|
|
903
|
-
source: endpoint.name,
|
|
904
|
-
namespace,
|
|
905
|
-
read: adminGet(endpoint, namespace)
|
|
906
|
-
});
|
|
907
|
-
Object.assign(status, {
|
|
908
|
-
service,
|
|
909
|
-
url: endpoint.adminUrl,
|
|
910
|
-
ok: true,
|
|
911
|
-
error: null,
|
|
912
|
-
lastSyncAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
913
|
-
});
|
|
914
|
-
return { ok: true, items };
|
|
915
|
-
} catch (error) {
|
|
916
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
917
|
-
if (message.startsWith("not a messaging emulator")) {
|
|
918
|
-
statuses.delete(key);
|
|
919
|
-
rejected.add(`${endpoint.name}|${endpoint.adminUrl}`);
|
|
920
|
-
endpoints = endpoints.filter((e) => e !== endpoint);
|
|
921
|
-
return { ok: false };
|
|
922
|
-
}
|
|
923
|
-
Object.assign(status, { url: endpoint.adminUrl, ok: false, error: message });
|
|
924
|
-
discoveredAt = 0;
|
|
925
|
-
return { ok: false, source: endpoint.name };
|
|
926
|
-
}
|
|
927
|
-
})
|
|
928
|
-
);
|
|
929
|
-
const b = bucket(namespace);
|
|
930
|
-
const failed = new Set(results.flatMap((r) => "source" in r && r.source ? [r.source] : []));
|
|
931
|
-
const fresh = dedupe(results.flatMap((r) => r.ok ? r.items : []));
|
|
932
|
-
const next = /* @__PURE__ */ new Map();
|
|
933
|
-
for (const n of b.notifications.values()) if (failed.has(n.source)) next.set(n.id, n);
|
|
934
|
-
for (const n of fresh) next.set(n.id, n);
|
|
935
|
-
const added = [...next.values()].filter((n) => !b.notifications.has(n.id)).sort(byTime);
|
|
936
|
-
const removed = [...b.notifications.keys()].some((id) => !next.has(id));
|
|
937
|
-
const changed = added.length > 0 || removed || [...next.values()].some((n) => b.notifications.get(n.id)?.status !== n.status);
|
|
938
|
-
b.notifications = next;
|
|
939
|
-
for (const status of statuses.values())
|
|
940
|
-
status.count = [...buckets.values()].reduce(
|
|
941
|
-
(sum, bk) => sum + [...bk.notifications.values()].filter((n) => n.source === status.name).length,
|
|
942
|
-
0
|
|
943
|
-
);
|
|
944
|
-
if (changed) {
|
|
945
|
-
b.version++;
|
|
946
|
-
for (const listener of listeners) listener({ namespace, added, version: b.version });
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
const sync = (namespace = "default") => {
|
|
950
|
-
watched.add(namespace);
|
|
951
|
-
const b = bucket(namespace);
|
|
952
|
-
if (!b.inFlight) {
|
|
953
|
-
b.inFlight = readAll(namespace).finally(() => {
|
|
954
|
-
b.inFlight = null;
|
|
955
|
-
});
|
|
956
|
-
return b.inFlight;
|
|
957
|
-
}
|
|
958
|
-
b.queued ??= b.inFlight.then(() => {
|
|
959
|
-
b.queued = null;
|
|
960
|
-
return sync(namespace);
|
|
961
|
-
});
|
|
962
|
-
return b.queued;
|
|
963
|
-
};
|
|
964
|
-
const list2 = async (filter = {}) => {
|
|
965
|
-
const namespace = filter.namespace ?? "default";
|
|
966
|
-
await sync(namespace);
|
|
967
|
-
return [...bucket(namespace).notifications.values()].filter((n) => matches(n, { ...filter, namespace })).sort(byTime);
|
|
968
|
-
};
|
|
969
|
-
const waitFor = async (filter, wait = {}) => {
|
|
970
|
-
const timeoutMs = wait.timeoutMs ?? 1e4;
|
|
971
|
-
const count = wait.count ?? 1;
|
|
972
|
-
const deadline = Date.now() + timeoutMs;
|
|
973
|
-
for (; ; ) {
|
|
974
|
-
const found = await list2(filter);
|
|
975
|
-
if (found.length >= count) return found;
|
|
976
|
-
if (Date.now() >= deadline) {
|
|
977
|
-
const error = new Error(
|
|
978
|
-
`timed out after ${timeoutMs}ms waiting for ${count} notification(s) matching ${JSON.stringify(filter)}; found ${found.length}`
|
|
979
|
-
);
|
|
980
|
-
Object.assign(error, { found });
|
|
981
|
-
throw error;
|
|
982
|
-
}
|
|
983
|
-
await new Promise(
|
|
984
|
-
(resolve) => setTimeout(resolve, Math.min(100, Math.max(0, deadline - Date.now())))
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
const interval = options.pollIntervalMs ?? 750;
|
|
989
|
-
const timer = interval > 0 ? setInterval(() => {
|
|
990
|
-
for (const namespace of watched) void sync(namespace).catch(() => {
|
|
991
|
-
});
|
|
992
|
-
}, interval) : null;
|
|
993
|
-
timer?.unref?.();
|
|
994
|
-
const events = (namespace, signal) => {
|
|
995
|
-
watched.add(namespace);
|
|
996
|
-
const encoder = new TextEncoder();
|
|
997
|
-
let cleanup = () => {
|
|
998
|
-
};
|
|
999
|
-
return new ReadableStream({
|
|
1000
|
-
start(controller) {
|
|
1001
|
-
const send = (event, data) => {
|
|
1002
|
-
try {
|
|
1003
|
-
controller.enqueue(encoder.encode(`event: ${event}
|
|
1004
|
-
data: ${JSON.stringify(data)}
|
|
1005
|
-
|
|
1006
|
-
`));
|
|
1007
|
-
} catch {
|
|
1008
|
-
cleanup();
|
|
1009
|
-
}
|
|
1010
|
-
};
|
|
1011
|
-
const listener = (event) => {
|
|
1012
|
-
if (event.namespace === namespace) send("change", event);
|
|
1013
|
-
};
|
|
1014
|
-
listeners.add(listener);
|
|
1015
|
-
const heartbeat = setInterval(() => send("sources", [...statuses.values()]), 2e3);
|
|
1016
|
-
cleanup = () => {
|
|
1017
|
-
listeners.delete(listener);
|
|
1018
|
-
clearInterval(heartbeat);
|
|
1019
|
-
};
|
|
1020
|
-
signal.addEventListener("abort", () => {
|
|
1021
|
-
cleanup();
|
|
1022
|
-
try {
|
|
1023
|
-
controller.close();
|
|
1024
|
-
} catch {
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
send("hello", { namespace, version: bucket(namespace).version });
|
|
1028
|
-
void sync(namespace).catch(() => {
|
|
1029
|
-
});
|
|
1030
|
-
},
|
|
1031
|
-
cancel() {
|
|
1032
|
-
cleanup();
|
|
1033
|
-
}
|
|
1034
|
-
});
|
|
1035
|
-
};
|
|
1036
|
-
const namespacesList = () => [.../* @__PURE__ */ new Set([...watched, ...buckets.keys()])].sort();
|
|
1037
|
-
const title = options.title ?? "Notifications";
|
|
1038
|
-
const gateway = options.admin ? options.admin({
|
|
1039
|
-
targets: async () => {
|
|
1040
|
-
await rediscover();
|
|
1041
|
-
return admins;
|
|
1042
|
-
},
|
|
1043
|
-
headers: headersFor,
|
|
1044
|
-
title
|
|
1045
|
-
}) : null;
|
|
1046
|
-
const handle = async (request) => {
|
|
1047
|
-
const url = new URL(request.url);
|
|
1048
|
-
const path = url.pathname.replace(/\/+$/, "") || "/";
|
|
1049
|
-
if (path === "/admin" || path.startsWith("/admin/"))
|
|
1050
|
-
return gateway ? gateway.fetch(request) : errorBody(404, `no route ${path}`);
|
|
1051
|
-
if (request.method !== "GET" && request.method !== "HEAD")
|
|
1052
|
-
return errorBody(405, "the notification harness is read-only");
|
|
1053
|
-
if (path === "/" || path === "/index.html")
|
|
1054
|
-
return new Response(
|
|
1055
|
-
renderPage({ title, defaultTab: options.defaultTab ?? "notifications" }),
|
|
1056
|
-
{
|
|
1057
|
-
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" }
|
|
1058
|
-
}
|
|
1059
|
-
);
|
|
1060
|
-
if (path === "/api/admin") {
|
|
1061
|
-
await rediscover();
|
|
1062
|
-
const fleet = options.fleet?.replace(/\/+$/, "");
|
|
1063
|
-
return json(200, {
|
|
1064
|
-
admin: gateway ? await gateway.config() : null,
|
|
1065
|
-
emulators: admins.map((a) => ({ name: a.name, target: a.target, adminUrl: a.adminUrl })),
|
|
1066
|
-
fleet: fleet ? {
|
|
1067
|
-
adminBase: fleet,
|
|
1068
|
-
consoleUrl: fleet.replace(/\/fleet$/, "/ui"),
|
|
1069
|
-
error: discoveryError
|
|
1070
|
-
} : null
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
if (path === "/ui.js")
|
|
1074
|
-
return new Response(BROWSER_JS, {
|
|
1075
|
-
headers: { "content-type": "text/javascript; charset=utf-8", "cache-control": "no-store" }
|
|
1076
|
-
});
|
|
1077
|
-
if (path === "/api/health") return json(200, { status: "ok", sources: [...statuses.values()] });
|
|
1078
|
-
if (path === "/api/sources") {
|
|
1079
|
-
await rediscover();
|
|
1080
|
-
return json(200, {
|
|
1081
|
-
discoveryError,
|
|
1082
|
-
sources: endpoints.map(
|
|
1083
|
-
(e) => statuses.get(e.name) ?? {
|
|
1084
|
-
name: e.name,
|
|
1085
|
-
service: e.service,
|
|
1086
|
-
url: e.adminUrl,
|
|
1087
|
-
ok: false,
|
|
1088
|
-
error: null,
|
|
1089
|
-
count: 0,
|
|
1090
|
-
lastSyncAt: null
|
|
1091
|
-
}
|
|
1092
|
-
),
|
|
1093
|
-
services: SERVICE_KINDS
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
if (path === "/api/namespaces") {
|
|
1097
|
-
await rediscover();
|
|
1098
|
-
return json(200, { namespaces: namespacesList() });
|
|
1099
|
-
}
|
|
1100
|
-
let filter;
|
|
1101
|
-
try {
|
|
1102
|
-
filter = filterFromSearch(url.searchParams);
|
|
1103
|
-
} catch (error) {
|
|
1104
|
-
return errorBody(400, error instanceof Error ? error.message : String(error));
|
|
1105
|
-
}
|
|
1106
|
-
const namespace = filter.namespace ?? "default";
|
|
1107
|
-
if (path === "/api/events")
|
|
1108
|
-
return new Response(events(namespace, request.signal), {
|
|
1109
|
-
headers: {
|
|
1110
|
-
"content-type": "text/event-stream",
|
|
1111
|
-
"cache-control": "no-store",
|
|
1112
|
-
connection: "keep-alive"
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
if (path === "/api/notifications") {
|
|
1116
|
-
const found = await list2(filter);
|
|
1117
|
-
if (url.searchParams.get("order") === "newest") found.reverse();
|
|
1118
|
-
return json(200, { namespace, version: bucket(namespace).version, notifications: found });
|
|
1119
|
-
}
|
|
1120
|
-
if (path === "/api/notifications/latest") {
|
|
1121
|
-
const found = await list2(filter);
|
|
1122
|
-
const latest = found.at(-1);
|
|
1123
|
-
return latest ? json(200, latest) : errorBody(404, "no notification matches");
|
|
1124
|
-
}
|
|
1125
|
-
if (path === "/api/wait") {
|
|
1126
|
-
const timeoutMs = Number(url.searchParams.get("timeoutMs") ?? 1e4);
|
|
1127
|
-
const count = Number(url.searchParams.get("count") ?? 1);
|
|
1128
|
-
if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > 12e4)
|
|
1129
|
-
return errorBody(400, "timeoutMs: expected 0\u2013120000");
|
|
1130
|
-
if (!Number.isInteger(count) || count < 1)
|
|
1131
|
-
return errorBody(400, "count: expected a positive integer");
|
|
1132
|
-
try {
|
|
1133
|
-
return json(200, { namespace, notifications: await waitFor(filter, { timeoutMs, count }) });
|
|
1134
|
-
} catch (error) {
|
|
1135
|
-
return json(408, {
|
|
1136
|
-
error: {
|
|
1137
|
-
type: "mockingbird_notifications",
|
|
1138
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1139
|
-
},
|
|
1140
|
-
notifications: error.found ?? []
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
const one = /^\/api\/notifications\/(.+)$/.exec(path);
|
|
1145
|
-
if (one) {
|
|
1146
|
-
const id = decodeURIComponent(one[1] ?? "");
|
|
1147
|
-
const ns = id.split(":")[1] ?? namespace;
|
|
1148
|
-
await sync(ns);
|
|
1149
|
-
const found = bucket(ns).notifications.get(id);
|
|
1150
|
-
return found ? json(200, found) : errorBody(404, `no notification ${id}`);
|
|
1151
|
-
}
|
|
1152
|
-
return errorBody(404, `no route ${path}`);
|
|
1153
|
-
};
|
|
1154
|
-
return {
|
|
1155
|
-
fetch: async (request) => {
|
|
1156
|
-
try {
|
|
1157
|
-
return await handle(request);
|
|
1158
|
-
} catch (error) {
|
|
1159
|
-
return errorBody(500, error instanceof Error ? error.message : String(error));
|
|
1160
|
-
}
|
|
1161
|
-
},
|
|
1162
|
-
sync,
|
|
1163
|
-
list: list2,
|
|
1164
|
-
waitFor,
|
|
1165
|
-
sources: () => [...statuses.values()],
|
|
1166
|
-
close: () => {
|
|
1167
|
-
if (timer) clearInterval(timer);
|
|
1168
|
-
listeners.clear();
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
export {
|
|
1174
|
-
parseMime,
|
|
1175
|
-
createNotificationHarness
|
|
1176
|
-
};
|
|
1177
|
-
//# sourceMappingURL=chunk-GHIEYY5B.js.map
|