@eum-agent/system-notifications 0.0.0-stage → 1.0.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/ui/ui.js ADDED
@@ -0,0 +1,1568 @@
1
+ import { Alert, Button, Disclosure, DisclosureSummary, NavEntryBody, Panel, Popover, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipTrigger, goToSession, isOnline, localeLeaves, navEntryClass, onInboxCandidates, openInbox, pageKey, sessionTitle, useConnection, useFailureToast, useGateway, useInbox, useNotices, useOpenSession, usePage, usePendingRequests, usePlugins, useSessions, useTranslation, useTriggers } from "@eum-agent/host/framework";
2
+ import React, { createContext, createElement, forwardRef, useContext, useEffect, useMemo, useState } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region ui-src/activation.ts
5
+ /** Acquires optional native resources before installing this feature's observers. */
6
+ function activateNativeFeature(ctx, feature, start) {
7
+ const native = ctx.services.get("native-client-features");
8
+ if (!native) {
9
+ start();
10
+ return;
11
+ }
12
+ native.activate(feature, ctx.signal).then(() => {
13
+ if (!ctx.signal.aborted) start();
14
+ }).catch(() => {});
15
+ }
16
+ //#endregion
17
+ //#region ui-src/i18n.ts
18
+ /** Platform browser strings share the host's language and React translation runtime. */
19
+ var translations;
20
+ /** Binds this activation's registered namespace without reconstructing the owner's namespace. */
21
+ function configureTranslations(ctx) {
22
+ translations = ctx.i18n;
23
+ }
24
+ /** Observes the shared language while resolving platform-owned copy. */
25
+ function useTranslation$1() {
26
+ const shared = useTranslation();
27
+ if (!translations) throw new Error("platform browser translations are not registered");
28
+ return {
29
+ ...shared,
30
+ t: translations.t
31
+ };
32
+ }
33
+ /** Resolves notification text through this activation's own registered namespace. */
34
+ function platformText(key, options) {
35
+ if (!translations) throw new Error("platform browser translations are not registered");
36
+ return translations.t(key, options);
37
+ }
38
+ var en_US_default = {
39
+ notifications: {
40
+ "problems": {
41
+ "preferencesRead": "Notification preferences could not be read. Refresh the state and try again.",
42
+ "preferencesWrite": "Notification preferences could not be saved. This page keeps your selection; refresh the state and try again.",
43
+ "unavailable": "Notifications are unavailable. Check platform permission and refresh the state.",
44
+ "submit": "The notification could not be submitted. Check your system or browser notification settings and try again.",
45
+ "baseline": "The inbox could not be loaded. Check the connection and retry manually.",
46
+ "offline": "Reconnect before loading the inbox.",
47
+ "unknown": "The notification operation failed. Refresh the state and try again."
48
+ },
49
+ "refresh": "Refresh notification state",
50
+ "summaryTitle": "YaoGuang · {{category}}",
51
+ "title": "System notifications",
52
+ "hint": "Reminders follow the inbox on this client; read state stays in the inbox.",
53
+ "enabled": "Enable system notifications",
54
+ "permissionLabel": "Permission",
55
+ "permission": {
56
+ "default": "Not requested",
57
+ "granted": "Allowed",
58
+ "denied": "Denied",
59
+ "unsupported": "Unsupported",
60
+ "system-managed": "Managed by the operating system"
61
+ },
62
+ "request": "Request permission",
63
+ "browserDenied": "Allow notifications for this site in your browser settings, then refresh.",
64
+ "desktopManaged": "Manage notification permission and Focus modes in your system settings.",
65
+ "unsupported": "This browser does not support notifications.",
66
+ "privacy": "Notifications may show session names, which can contain the first message or attachment name. Turn notifications off before screen sharing if needed.",
67
+ "test": "Send test notification",
68
+ "submitted": "Test submitted. The operating system controls whether it appears.",
69
+ "baselineLoading": "Loading the inbox baseline; reminders are paused.",
70
+ "baselineFailed": "The inbox baseline could not be loaded. Reminders are paused until you retry.",
71
+ "baselineOffline": "Connect to load the inbox baseline.",
72
+ "retryBaseline": "Retry inbox baseline",
73
+ "genericSource": "YaoGuang activity",
74
+ "testTitle": "YaoGuang · Test notification",
75
+ "testBody": "A test reminder from this client.",
76
+ "category": {
77
+ "request": "Approval needed",
78
+ "turnCompleted": "Turn completed",
79
+ "turnFailed": "Turn failed",
80
+ "turnInterrupted": "Turn interrupted",
81
+ "subprocessEnded": "Process ended",
82
+ "subprocessFailed": "Process failed",
83
+ "participantJoined": "Participant joined",
84
+ "triggerFailed": "Trigger failed",
85
+ "plugin": "Plugin reminder"
86
+ }
87
+ },
88
+ inbox: {
89
+ "center": "Inbox",
90
+ "goAnswer": "Answer",
91
+ "goApprove": "Review",
92
+ "viewSession": "View session",
93
+ "emptyWaiting": "No requests waiting",
94
+ "offline": "Disconnected. Showing the last received messages.",
95
+ "previous": "Previous",
96
+ "next": "Next",
97
+ "deliveryFailed": "Notification delivery failed",
98
+ "commandFailed": "Background command failed",
99
+ "commandEnded": "Background command ended",
100
+ "outcome": {
101
+ "completed": "Session completed",
102
+ "failed": "Session failed",
103
+ "interrupted": "Session stopped"
104
+ },
105
+ "label": "Inbox",
106
+ "labelCount": "Inbox, {{count}} to look at",
107
+ "labelCount_one": "Inbox, {{count}} to look at",
108
+ "waiting": "Needs you",
109
+ "triggerRun": "Task “{{name}}” failed: {{reason}}",
110
+ "triggerReason": {
111
+ "previous-running": "previous run still in progress",
112
+ "target-busy": "target session busy",
113
+ "missed": "missed",
114
+ "agent-removed": "agent deleted",
115
+ "workspace-removed": "workspace deleted",
116
+ "session-missing": "target session not found",
117
+ "no-model": "no model available",
118
+ "turn-failed": "run failed",
119
+ "turn-interrupted": "run interrupted",
120
+ "gateway-stopped": "gateway stopped"
121
+ },
122
+ "participantJoined": "“{{session}}” invited you: {{reason}}",
123
+ "title": "Notifications",
124
+ "unreadCount": "{{count}} unread",
125
+ "unread": "Unread",
126
+ "untitled": "New session",
127
+ "empty": "No notifications",
128
+ "turnCompleted": "“{{session}}” finished",
129
+ "turnFailed": "“{{session}}” failed",
130
+ "turnInterrupted": "“{{session}}” was interrupted",
131
+ "processEnded": "Background command ended: {{command}}",
132
+ "processFailed": "Background command failed: {{command}}",
133
+ "generic": "A new message",
134
+ "pushFailed": "Could not push to {{notifier}}: {{reason}}",
135
+ "goToSession": "Go to session",
136
+ "clear": "Clear",
137
+ "clearRead": "Clear read",
138
+ "sessionMissing": "That session no longer exists"
139
+ },
140
+ requests: { "approvalOf": "{{tool}} asks for permission" },
141
+ common: {
142
+ "working": "Working…",
143
+ "retry": "Retry"
144
+ }
145
+ };
146
+ var zh_CN_default = {
147
+ notifications: {
148
+ "problems": {
149
+ "preferencesRead": "通知偏好读取失败,请刷新状态后重试。",
150
+ "preferencesWrite": "通知偏好未能保存;本页仍保留所选设置,请刷新状态后重试。",
151
+ "unavailable": "通知暂不可用,请检查平台权限并刷新状态。",
152
+ "submit": "通知未能提交,请检查系统或浏览器通知设置后重试。",
153
+ "baseline": "收件箱加载失败,请检查连接后手动重试。",
154
+ "offline": "请重新连接后再加载收件箱。",
155
+ "unknown": "通知操作失败,请刷新状态后重试。"
156
+ },
157
+ "refresh": "刷新通知状态",
158
+ "summaryTitle": "瑶光 · {{category}}",
159
+ "title": "系统通知",
160
+ "hint": "此客户端根据收件箱提醒;已读状态仍以收件箱为准。",
161
+ "enabled": "启用系统通知",
162
+ "permissionLabel": "通知权限",
163
+ "permission": {
164
+ "default": "尚未请求",
165
+ "granted": "已允许",
166
+ "denied": "已拒绝",
167
+ "unsupported": "不支持",
168
+ "system-managed": "由系统管理"
169
+ },
170
+ "request": "请求通知权限",
171
+ "browserDenied": "请在浏览器的网站设置中允许通知,再刷新状态。",
172
+ "desktopManaged": "请在系统设置中管理通知权限和专注模式。",
173
+ "unsupported": "此浏览器不支持系统通知。",
174
+ "privacy": "通知可能显示会话名称,其中可能含首条消息片段或附件名称。共享屏幕前可关闭通知。",
175
+ "test": "发送测试通知",
176
+ "submitted": "测试已提交;是否展示由操作系统决定。",
177
+ "baselineLoading": "正在加载收件箱基线,提醒暂时暂停。",
178
+ "baselineFailed": "收件箱基线加载失败。请手动重试后恢复提醒。",
179
+ "baselineOffline": "连接后可加载收件箱基线。",
180
+ "retryBaseline": "重新加载收件箱基线",
181
+ "genericSource": "瑶光动态",
182
+ "testTitle": "瑶光 · 测试通知",
183
+ "testBody": "来自此客户端的测试提醒。",
184
+ "category": {
185
+ "request": "等待审批",
186
+ "turnCompleted": "回合完成",
187
+ "turnFailed": "回合失败",
188
+ "turnInterrupted": "回合中断",
189
+ "subprocessEnded": "进程结束",
190
+ "subprocessFailed": "进程失败",
191
+ "participantJoined": "参与者加入",
192
+ "triggerFailed": "触发失败",
193
+ "plugin": "插件提醒"
194
+ }
195
+ },
196
+ inbox: {
197
+ "center": "消息中心",
198
+ "goAnswer": "前往回答",
199
+ "goApprove": "前往审批",
200
+ "viewSession": "查看会话",
201
+ "emptyWaiting": "暂时没有待处理请求",
202
+ "offline": "连接已断开,显示上次收到的内容",
203
+ "previous": "上一条",
204
+ "next": "下一条",
205
+ "deliveryFailed": "通知推送失败",
206
+ "commandFailed": "后台命令运行失败",
207
+ "commandEnded": "后台命令已结束",
208
+ "outcome": {
209
+ "completed": "会话已完成",
210
+ "failed": "会话出错了",
211
+ "interrupted": "会话已停止"
212
+ },
213
+ "label": "消息",
214
+ "labelCount": "消息,{{count}} 项待看",
215
+ "waiting": "待你处理",
216
+ "triggerRun": "任务「{{name}}」执行失败:{{reason}}",
217
+ "triggerReason": {
218
+ "previous-running": "上次执行尚未结束",
219
+ "target-busy": "目标会话繁忙",
220
+ "missed": "已错过",
221
+ "agent-removed": "智能体已删除",
222
+ "workspace-removed": "工作空间已删除",
223
+ "session-missing": "目标会话不存在",
224
+ "no-model": "没有可用模型",
225
+ "turn-failed": "执行失败",
226
+ "turn-interrupted": "执行中断",
227
+ "gateway-stopped": "网关已停止"
228
+ },
229
+ "participantJoined": "「{{session}}」邀请你加入:{{reason}}",
230
+ "title": "通知",
231
+ "unreadCount": "{{count}} 条未读",
232
+ "unread": "未读",
233
+ "untitled": "新会话",
234
+ "empty": "暂无通知",
235
+ "turnCompleted": "「{{session}}」已完成",
236
+ "turnFailed": "「{{session}}」出错了",
237
+ "turnInterrupted": "「{{session}}」已中断",
238
+ "processEnded": "后台命令已结束:{{command}}",
239
+ "processFailed": "后台命令失败:{{command}}",
240
+ "generic": "有一条新消息",
241
+ "pushFailed": "推送到 {{notifier}} 失败:{{reason}}",
242
+ "goToSession": "前往会话",
243
+ "clear": "清除",
244
+ "clearRead": "清除已读",
245
+ "sessionMissing": "会话不存在"
246
+ },
247
+ requests: { "approvalOf": "{{tool}} 请求授权" },
248
+ common: {
249
+ "working": "处理中……",
250
+ "retry": "重试"
251
+ }
252
+ };
253
+ //#endregion
254
+ //#region ui-src/catalogues.ts
255
+ /** Registers this owner's localized client copy for its activation. */
256
+ function registerTranslations(ctx) {
257
+ configureTranslations(ctx);
258
+ ctx.i18n.register({
259
+ "en-US": localeLeaves(en_US_default),
260
+ "zh-CN": localeLeaves(zh_CN_default)
261
+ }, "zh-CN");
262
+ }
263
+ //#endregion
264
+ //#region ../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.2.18_react@19.2.8_use-sync-external-store@1.7.0_react@19.2.8_/node_modules/zustand/esm/vanilla.mjs
265
+ var createStoreImpl = (createState) => {
266
+ let state;
267
+ const listeners = /* @__PURE__ */ new Set();
268
+ const setState = (partial, replace) => {
269
+ const nextState = typeof partial === "function" ? partial(state) : partial;
270
+ if (!Object.is(nextState, state)) {
271
+ const previousState = state;
272
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
273
+ listeners.forEach((listener) => listener(state, previousState));
274
+ }
275
+ };
276
+ const getState = () => state;
277
+ const getInitialState = () => initialState;
278
+ const subscribe = (listener) => {
279
+ listeners.add(listener);
280
+ return () => listeners.delete(listener);
281
+ };
282
+ const api = {
283
+ setState,
284
+ getState,
285
+ getInitialState,
286
+ subscribe
287
+ };
288
+ const initialState = state = createState(setState, getState, api);
289
+ return api;
290
+ };
291
+ var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
292
+ //#endregion
293
+ //#region ../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.2.18_react@19.2.8_use-sync-external-store@1.7.0_react@19.2.8_/node_modules/zustand/esm/react.mjs
294
+ var identity = (arg) => arg;
295
+ function useStore(api, selector = identity) {
296
+ const slice = React.useSyncExternalStore(api.subscribe, React.useCallback(() => selector(api.getState()), [api, selector]), React.useCallback(() => selector(api.getInitialState()), [api, selector]));
297
+ React.useDebugValue(slice);
298
+ return slice;
299
+ }
300
+ var createImpl = (createState) => {
301
+ const api = createStore(createState);
302
+ const useBoundStore = (selector) => useStore(api, selector);
303
+ Object.assign(useBoundStore, api);
304
+ return useBoundStore;
305
+ };
306
+ var create = ((createState) => createState ? createImpl(createState) : createImpl);
307
+ //#endregion
308
+ //#region ui-src/lib/notifications/host.ts
309
+ var installed;
310
+ var ownsInstalled = true;
311
+ var listeners = /* @__PURE__ */ new Set();
312
+ /** Returns the current injected platform host, or undefined before entry-point initialization. */
313
+ function notificationHost() {
314
+ return installed;
315
+ }
316
+ /** Installs the page's host; replacement/disposal withdraws and disposes only that host. */
317
+ function installNotificationHost(host, options = {}) {
318
+ if (installed !== host && ownsInstalled) installed?.dispose();
319
+ installed = host;
320
+ ownsInstalled = options.dispose !== false;
321
+ for (const listener of listeners) listener({ host });
322
+ return () => {
323
+ if (installed !== host) return;
324
+ installed = void 0;
325
+ if (options.dispose !== false) host.dispose();
326
+ for (const listener of listeners) listener({ host: void 0 });
327
+ };
328
+ }
329
+ /** Bridges safe native/browser state changes; a replaced host cannot overwrite current state. */
330
+ function notifyNotificationStateChanged(state, host) {
331
+ if (!installed || host !== void 0 && installed !== host) return;
332
+ for (const listener of listeners) listener({
333
+ host: installed,
334
+ state
335
+ });
336
+ }
337
+ /** Observes host replacement and pushed state; no platform or component subscription is created. */
338
+ function onNotificationHostChanged(listener) {
339
+ listeners.add(listener);
340
+ return () => {
341
+ listeners.delete(listener);
342
+ };
343
+ }
344
+ //#endregion
345
+ //#region ui-src/store/notifications.ts
346
+ /** Local notification settings and inbox readiness shared by settings and platform adapters. */
347
+ var revision = 0;
348
+ var running = 0;
349
+ var hostEpoch = 0;
350
+ var retry;
351
+ /** Keeps platform diagnostics within the documented public failure categories. */
352
+ function notificationProblem(error) {
353
+ const code = error instanceof Error ? error.message : error?.code;
354
+ return code === "preferences-read" || code === "preferences-write" || code === "notification-unavailable" ? code : "notification-submit";
355
+ }
356
+ async function perform(action) {
357
+ const host = notificationHost();
358
+ const current = ++revision;
359
+ const epoch = hostEpoch;
360
+ running++;
361
+ useNotifications.setState({ pending: true });
362
+ try {
363
+ if (!host) throw new Error("notification-unavailable");
364
+ const state = await action(host);
365
+ if (notificationHost() === host && current === revision) useNotifications.setState({
366
+ ...state,
367
+ initialized: true
368
+ });
369
+ } catch (error) {
370
+ if (notificationHost() === host && current === revision) useNotifications.setState({
371
+ lastProblem: notificationProblem(error),
372
+ initialized: true
373
+ });
374
+ throw new Error(notificationProblem(error));
375
+ } finally {
376
+ if (epoch === hostEpoch) {
377
+ running--;
378
+ useNotifications.setState({ pending: running > 0 });
379
+ }
380
+ }
381
+ }
382
+ /** Current client-local state; no preference or failure is written to the gateway. */
383
+ var useNotifications = create()(() => ({
384
+ initialized: false,
385
+ pending: false,
386
+ enabled: true,
387
+ permission: "unsupported",
388
+ lastProblem: null,
389
+ baselineStatus: useInbox.getState().baselineStatus,
390
+ baselineProblem: useInbox.getState().baselineProblem,
391
+ refresh: () => perform((host) => host.state()),
392
+ setEnabled: (enabled) => perform((host) => host.setEnabled(enabled)),
393
+ requestPermission: () => perform((host) => host.requestPermission()),
394
+ test: () => perform(async (host) => {
395
+ await host.test();
396
+ return host.state();
397
+ }),
398
+ retryBaseline: () => retry ? retry() : Promise.reject(/* @__PURE__ */ new Error("inbox-offline"))
399
+ }));
400
+ /** Observes hosts and inbox readiness only while the notification feature is active. */
401
+ function initNotificationsStore() {
402
+ const initial = useInbox.getState();
403
+ useNotifications.setState({
404
+ baselineStatus: initial.baselineStatus,
405
+ baselineProblem: initial.baselineProblem
406
+ });
407
+ const stopHost = onNotificationHostChanged(({ host, state }) => {
408
+ revision++;
409
+ if (!state) {
410
+ hostEpoch++;
411
+ running = 0;
412
+ useNotifications.setState({ pending: false });
413
+ }
414
+ if (state) useNotifications.setState({
415
+ ...state,
416
+ initialized: true
417
+ });
418
+ else if (host) {
419
+ useNotifications.setState({ initialized: false });
420
+ useNotifications.getState().refresh().catch(() => {});
421
+ } else useNotifications.setState({
422
+ initialized: false,
423
+ permission: "unsupported",
424
+ lastProblem: null
425
+ });
426
+ });
427
+ const stopInbox = useInbox.subscribe((state) => {
428
+ useNotifications.setState({
429
+ baselineStatus: state.baselineStatus,
430
+ baselineProblem: state.baselineProblem
431
+ });
432
+ });
433
+ return () => {
434
+ stopInbox();
435
+ stopHost();
436
+ revision++;
437
+ hostEpoch++;
438
+ running = 0;
439
+ useNotifications.setState({
440
+ pending: false,
441
+ initialized: false,
442
+ permission: "unsupported"
443
+ });
444
+ };
445
+ }
446
+ /** Binds the one gateway coordinator's manual retry without introducing a second subscription. */
447
+ function installBaselineRetry(action) {
448
+ retry = action;
449
+ return () => {
450
+ if (retry === action) retry = void 0;
451
+ };
452
+ }
453
+ /** Records a detectable submission failure only while its host remains installed. */
454
+ function reportNotificationFailure(error, host) {
455
+ if (notificationHost() !== host) return;
456
+ revision++;
457
+ useNotifications.setState({ lastProblem: notificationProblem(error) });
458
+ }
459
+ //#endregion
460
+ //#region ui-src/components/settings/notifications.tsx
461
+ /** Client-local permission and reminder readiness; initialization never requests permission. */
462
+ function NotificationsPanel() {
463
+ const { t } = useTranslation$1();
464
+ const { initialized, pending, enabled, permission, lastProblem, baselineStatus, baselineProblem, refresh, setEnabled, requestPermission, test, retryBaseline } = useNotifications();
465
+ const problemMessage = (code) => {
466
+ switch (code) {
467
+ case "preferences-read": return t("notifications.problems.preferencesRead");
468
+ case "preferences-write": return t("notifications.problems.preferencesWrite");
469
+ case "notification-unavailable": return t("notifications.problems.unavailable");
470
+ case "notification-submit": return t("notifications.problems.submit");
471
+ case "inbox-baseline": return t("notifications.problems.baseline");
472
+ case "inbox-offline": return t("notifications.problems.offline");
473
+ default: return t("notifications.problems.unknown");
474
+ }
475
+ };
476
+ const [submitted, setSubmitted] = useState(false);
477
+ useEffect(() => {
478
+ refresh().catch(() => {});
479
+ }, [refresh]);
480
+ const toggle = (next) => {
481
+ setSubmitted(false);
482
+ if (next && permission === "default") requestPermission().then(() => {
483
+ if (useNotifications.getState().permission === "granted") return setEnabled(true);
484
+ }).catch(() => {});
485
+ else setEnabled(next).catch(() => {});
486
+ };
487
+ const canTest = initialized && enabled && (permission === "granted" || permission === "system-managed");
488
+ return /* @__PURE__ */ jsxs("div", {
489
+ className: "flex min-w-0 flex-col gap-6",
490
+ children: [
491
+ /* @__PURE__ */ jsx(Panel, {
492
+ title: t("notifications.enabled"),
493
+ hint: t("notifications.hint"),
494
+ level: "field",
495
+ inline: true,
496
+ children: /* @__PURE__ */ jsx("div", {
497
+ className: "flex min-w-0 justify-end",
498
+ children: /* @__PURE__ */ jsx(Switch, {
499
+ "aria-label": t("notifications.enabled"),
500
+ checked: enabled,
501
+ disabled: !initialized || pending || permission === "unsupported",
502
+ onCheckedChange: toggle
503
+ })
504
+ })
505
+ }),
506
+ /* @__PURE__ */ jsx(Panel, {
507
+ title: t("notifications.permissionLabel"),
508
+ hint: permission === "denied" ? t("notifications.browserDenied") : permission === "system-managed" ? t("notifications.desktopManaged") : initialized && permission === "unsupported" ? t("notifications.unsupported") : void 0,
509
+ level: "field",
510
+ inline: true,
511
+ children: /* @__PURE__ */ jsxs("div", {
512
+ className: "flex min-w-0 flex-wrap items-center justify-end gap-3",
513
+ children: [/* @__PURE__ */ jsx("p", {
514
+ className: "text-xs text-muted-foreground",
515
+ children: initialized ? t(`notifications.permission.${permission}`) : t("common.working")
516
+ }), permission === "default" && /* @__PURE__ */ jsx(Button, {
517
+ type: "button",
518
+ variant: "secondary",
519
+ size: "sm",
520
+ disabled: !initialized || pending,
521
+ onClick: () => void requestPermission().catch(() => {}),
522
+ children: t("notifications.request")
523
+ })]
524
+ })
525
+ }),
526
+ lastProblem && lastProblem !== "inbox-offline" && /* @__PURE__ */ jsx(Alert, {
527
+ tone: "destructive",
528
+ role: "alert",
529
+ children: problemMessage(lastProblem)
530
+ }),
531
+ /* @__PURE__ */ jsxs("div", {
532
+ className: "flex min-w-0 flex-col gap-3",
533
+ children: [
534
+ /* @__PURE__ */ jsx("p", {
535
+ className: "text-xs leading-relaxed text-muted-foreground",
536
+ children: t("notifications.privacy")
537
+ }),
538
+ /* @__PURE__ */ jsxs("div", {
539
+ className: "flex flex-wrap gap-2",
540
+ children: [/* @__PURE__ */ jsx(Button, {
541
+ type: "button",
542
+ variant: "secondary",
543
+ size: "sm",
544
+ disabled: pending || !canTest,
545
+ onClick: () => {
546
+ setSubmitted(false);
547
+ test().then(() => setSubmitted(true)).catch(() => {});
548
+ },
549
+ children: t("notifications.test")
550
+ }), /* @__PURE__ */ jsx(Button, {
551
+ type: "button",
552
+ variant: "ghost",
553
+ size: "sm",
554
+ disabled: pending,
555
+ onClick: () => void refresh().catch(() => {}),
556
+ children: t("notifications.refresh")
557
+ })]
558
+ }),
559
+ submitted && /* @__PURE__ */ jsx("p", {
560
+ role: "status",
561
+ className: "text-xs leading-relaxed text-muted-foreground",
562
+ children: t("notifications.submitted")
563
+ })
564
+ ]
565
+ }),
566
+ (baselineStatus === "failed" || baselineStatus === "loading") && /* @__PURE__ */ jsxs(Alert, {
567
+ tone: baselineStatus === "failed" ? "warning" : "neutral",
568
+ role: "status",
569
+ children: [
570
+ /* @__PURE__ */ jsx("p", { children: t(baselineStatus === "failed" ? "notifications.baselineFailed" : "notifications.baselineLoading") }),
571
+ baselineProblem && /* @__PURE__ */ jsx("p", {
572
+ className: "mt-1 text-xs",
573
+ children: problemMessage(baselineProblem)
574
+ }),
575
+ /* @__PURE__ */ jsx(Button, {
576
+ className: "mt-2",
577
+ type: "button",
578
+ variant: "secondary",
579
+ size: "sm",
580
+ disabled: pending || baselineStatus !== "failed",
581
+ onClick: () => void retryBaseline().catch(() => {}),
582
+ children: t("notifications.retryBaseline")
583
+ })
584
+ ]
585
+ })
586
+ ]
587
+ });
588
+ }
589
+ //#endregion
590
+ //#region ui-src/lib/notifications/text.ts
591
+ /** Rejects blank identities/headings and clips text without splitting surrogate pairs. */
592
+ function boundedNotification(payload) {
593
+ if (!payload.id.trim() || !payload.title.trim()) throw new Error("notification-unavailable");
594
+ return {
595
+ id: payload.id,
596
+ title: Array.from(payload.title).slice(0, 80).join(""),
597
+ body: Array.from(payload.body).slice(0, 160).join("")
598
+ };
599
+ }
600
+ //#endregion
601
+ //#region ui-src/lib/notifications/browser.ts
602
+ /** Browser Notifications API implementation, initialized by the page entry point. */
603
+ var STORAGE_KEY = "yaoguang.notifications";
604
+ /** Creates a page-owned host; permission is requested only by an explicit user action. */
605
+ function createBrowserNotificationHost(options = {}) {
606
+ const retained = /* @__PURE__ */ new Set();
607
+ let disposed = false;
608
+ let enabled = true;
609
+ let preferenceProblem = null;
610
+ let submissionProblem = null;
611
+ try {
612
+ const saved = localStorage.getItem(STORAGE_KEY);
613
+ if (saved !== null) {
614
+ const parsed = JSON.parse(saved);
615
+ if (typeof parsed !== "object" || parsed === null || typeof parsed.enabled !== "boolean") throw new Error("preferences-read");
616
+ enabled = parsed.enabled;
617
+ }
618
+ } catch {
619
+ preferenceProblem = "preferences-read";
620
+ }
621
+ const supported = () => globalThis.isSecureContext === true && typeof Notification !== "undefined";
622
+ const state = () => ({
623
+ enabled,
624
+ permission: supported() ? Notification.permission : "unsupported",
625
+ lastProblem: preferenceProblem ?? submissionProblem
626
+ });
627
+ const push = () => {
628
+ if (!disposed) notifyNotificationStateChanged(state(), host);
629
+ };
630
+ const host = {
631
+ async state() {
632
+ return state();
633
+ },
634
+ async setEnabled(value) {
635
+ if (disposed) throw new Error("notification-unavailable");
636
+ enabled = value;
637
+ try {
638
+ localStorage.setItem(STORAGE_KEY, JSON.stringify({ enabled }));
639
+ preferenceProblem = null;
640
+ } catch {
641
+ preferenceProblem = "preferences-write";
642
+ }
643
+ push();
644
+ return state();
645
+ },
646
+ async requestPermission() {
647
+ if (disposed) throw new Error("notification-unavailable");
648
+ if (supported() && Notification.permission === "default") try {
649
+ await Notification.requestPermission();
650
+ } catch {
651
+ submissionProblem = "notification-unavailable";
652
+ }
653
+ if (disposed) throw new Error("notification-unavailable");
654
+ push();
655
+ return state();
656
+ },
657
+ async show(payload) {
658
+ if (disposed || !enabled || !supported() || Notification.permission !== "granted") throw new Error("notification-unavailable");
659
+ const text = boundedNotification(payload);
660
+ try {
661
+ const notification = new Notification(text.title, {
662
+ body: text.body,
663
+ tag: text.id
664
+ });
665
+ retained.add(notification);
666
+ notification.onclick = () => {
667
+ if (disposed) return;
668
+ try {
669
+ window.focus();
670
+ } catch {}
671
+ (options.openInbox ?? openInbox)();
672
+ };
673
+ notification.onerror = () => {
674
+ submissionProblem = "notification-submit";
675
+ push();
676
+ };
677
+ notification.onclose = () => {
678
+ retained.delete(notification);
679
+ notification.onclick = notification.onerror = notification.onclose = null;
680
+ };
681
+ submissionProblem = null;
682
+ push();
683
+ } catch {
684
+ submissionProblem = "notification-submit";
685
+ push();
686
+ throw new Error("notification-submit");
687
+ }
688
+ },
689
+ async test() {
690
+ await host.show({
691
+ id: "yaoguang-notification-test",
692
+ title: platformText("notifications.testTitle", { defaultValue: "YaoGuang test notification" }),
693
+ body: platformText("notifications.testBody", { defaultValue: "Notification submitted by this client." })
694
+ });
695
+ },
696
+ dispose() {
697
+ if (disposed) return;
698
+ disposed = true;
699
+ window.removeEventListener("focus", push);
700
+ for (const notification of retained) {
701
+ notification.onclick = notification.onerror = notification.onclose = null;
702
+ notification.close();
703
+ }
704
+ retained.clear();
705
+ }
706
+ };
707
+ window.addEventListener("focus", push);
708
+ return host;
709
+ }
710
+ //#endregion
711
+ //#region ui-src/devices.ts
712
+ /** Selects the client notification implementation for one active feature. */
713
+ function connectNotificationDevice(ctx) {
714
+ function install() {
715
+ const native = ctx.services.get("native-notifications");
716
+ const host = native ?? createBrowserNotificationHost();
717
+ const stop = installNotificationHost(host, { dispose: native === void 0 });
718
+ const unlisten = host.subscribe?.((state) => notifyNotificationStateChanged(state, host));
719
+ return () => {
720
+ unlisten?.();
721
+ stop();
722
+ };
723
+ }
724
+ let stop = install();
725
+ const off = ctx.services.subscribe("native-notifications", () => {
726
+ stop();
727
+ stop = install();
728
+ });
729
+ return () => {
730
+ off();
731
+ stop();
732
+ };
733
+ }
734
+ //#endregion
735
+ //#region ui-src/lib/notifications/summary.ts
736
+ /** Safe notification text derived from inbox category and existing source labels. */
737
+ function category(item) {
738
+ const detail = item.detail;
739
+ switch (detail.category) {
740
+ case "human-request": return platformText("notifications.category.request", { defaultValue: "Request" });
741
+ case "turn-ended":
742
+ switch (detail.outcome.kind) {
743
+ case "completed": return platformText("notifications.category.turnCompleted", { defaultValue: "Turn completed" });
744
+ case "failed": return platformText("notifications.category.turnFailed", { defaultValue: "Turn failed" });
745
+ case "interrupted": return platformText("notifications.category.turnInterrupted", { defaultValue: "Turn interrupted" });
746
+ }
747
+ break;
748
+ case "subprocess-ended": return detail.ending.kind === "exited" && detail.ending.code === 0 ? platformText("notifications.category.subprocessEnded", { defaultValue: "Process ended" }) : platformText("notifications.category.subprocessFailed", { defaultValue: "Process failed" });
749
+ case "participant-joined": return platformText("notifications.category.participantJoined", { defaultValue: "Participant joined" });
750
+ case "trigger-run": return platformText("notifications.category.triggerFailed", { defaultValue: "Trigger failed" });
751
+ case "plugin": return platformText("notifications.category.plugin", { defaultValue: "Plugin notice" });
752
+ }
753
+ return platformText("notifications.genericSource", { defaultValue: "Notification center" });
754
+ }
755
+ /** Excludes free-form details, commands, reasons, links and plugin-provided text. */
756
+ function notificationSummary(item) {
757
+ const generic = platformText("notifications.genericSource", { defaultValue: "Notification center" });
758
+ const session = useSessions.getState().sessions.find((one) => one.sessionId === item.sessionId);
759
+ const body = session ? sessionTitle(session, useTriggers.getState().triggers, generic) : item.owner.startsWith("plugin:") ? item.owner.slice(7) : generic;
760
+ return boundedNotification({
761
+ id: item.id,
762
+ title: platformText("notifications.summaryTitle", {
763
+ category: category(item),
764
+ defaultValue: "YaoGuang · {{category}}"
765
+ }),
766
+ body
767
+ });
768
+ }
769
+ //#endregion
770
+ //#region ui-src/lib/notifications/coordinator.ts
771
+ /** Platform reminder delivery observes the framework's silent-baseline inbox stream. */
772
+ /** Registers reminders for this browser module activation and rejects all late work on withdrawal. */
773
+ function registerInboxNotifications(ctx) {
774
+ let generation = 0;
775
+ let connection = useConnection.getState().status;
776
+ const offConnection = useConnection.subscribe((state) => {
777
+ if (state.status !== connection) {
778
+ connection = state.status;
779
+ generation++;
780
+ }
781
+ });
782
+ const stopRetry = installBaselineRetry(() => {
783
+ if (useConnection.getState().status !== "online") return Promise.reject(/* @__PURE__ */ new Error("inbox-offline"));
784
+ return useInbox.getState().retry();
785
+ });
786
+ const stop = onInboxCandidates((items) => {
787
+ const host = notificationHost();
788
+ if (!host) return;
789
+ const epoch = generation;
790
+ const current = () => epoch === generation && !ctx.signal.aborted && useConnection.getState().status === "online" && notificationHost() === host;
791
+ for (const item of items) (async () => {
792
+ try {
793
+ const state = await host.state();
794
+ if (!current() || !state.enabled || state.permission !== "granted" && state.permission !== "system-managed") return;
795
+ await host.show(notificationSummary(item));
796
+ } catch (error) {
797
+ if (current()) reportNotificationFailure(error, host);
798
+ }
799
+ })();
800
+ });
801
+ return () => {
802
+ generation++;
803
+ offConnection();
804
+ stop();
805
+ stopRetry();
806
+ };
807
+ }
808
+ //#endregion
809
+ //#region ui-src/shell/inbox.css?inline
810
+ var inbox_default = "/* --------------------------------------------------------------- inbox ----\n The nav inbox: category tabs, one message and a source/action band. */\n.inbox-count {\n position: absolute;\n top: 2px;\n right: 2px;\n min-width: 16px;\n height: 16px;\n padding-inline: 4px;\n border-radius: var(--radius-pill);\n background: var(--muted-foreground);\n color: var(--background);\n font-size: 10px;\n font-weight: 600;\n line-height: 16px;\n text-align: center;\n font-variant-numeric: tabular-nums;\n}\n.inbox-count[data-tone=\"warning\"] {\n background: var(--warning);\n color: var(--warning-foreground);\n}\n/* Semantic fills resolve against the selected palette, including dark mode. */\n:root {\n --inbox-warning-fill: color-mix(in srgb, var(--warning) 12%, var(--popover));\n --inbox-success-fill: color-mix(in srgb, var(--success) 12%, var(--popover));\n --inbox-failure-fill: color-mix(in srgb, var(--destructive) 10%, var(--popover));\n}\n.inbox-popover[data-slot=\"popover-content\"] {\n padding: 0;\n overflow: hidden;\n}\n.inbox-panel[data-slot=\"tabs\"] {\n gap: 0;\n max-height: min(36rem, var(--available-height, 36rem));\n}\n.inbox-navigation {\n display: flex;\n flex: none;\n align-items: center;\n gap: 16px;\n padding: 0 12px;\n border-top: 1px solid var(--border);\n}\n.inbox-tabs[data-slot=\"tabs-list\"] {\n flex: 1;\n align-self: stretch;\n min-height: 42px;\n padding: 0;\n border: 0;\n}\n.inbox-tabs [data-slot=\"tabs-trigger\"] {\n height: auto;\n}\n.inbox-tabs [data-slot=\"tabs-trigger\"] > span {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n.inbox-tabs [data-active] {\n color: var(--primary);\n}\n.inbox-tab-count {\n min-width: 20px;\n padding-inline: 5px;\n border-radius: var(--radius-xs);\n background: var(--muted);\n color: var(--muted-foreground);\n font-size: 10px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n}\n[data-active] .inbox-tab-count {\n background: var(--accent);\n color: var(--primary);\n}\n.inbox-viewport {\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.inbox-viewport > [role=\"tabpanel\"],\n.inbox-viewport article {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n}\n.inbox-message {\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n}\n.inbox-message-icon {\n display: grid;\n place-items: center;\n flex: none;\n width: 38px;\n height: 38px;\n border-radius: var(--radius-control);\n background: var(--muted);\n color: var(--muted-foreground);\n}\n.inbox-message-icon svg {\n width: 23px;\n height: 23px;\n}\n.inbox-message-icon[data-tone=\"warning\"] {\n color: var(--warning);\n background: var(--inbox-warning-fill);\n}\n.inbox-message-icon[data-tone=\"success\"] {\n color: var(--success);\n background: var(--inbox-success-fill);\n}\n.inbox-message-icon[data-tone=\"failure\"] {\n color: var(--destructive);\n background: var(--inbox-failure-fill);\n}\n.inbox-copy {\n flex: 1;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.inbox-copy h3 {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 14px;\n font-weight: 600;\n line-height: 1.6;\n}\n.inbox-copy > p {\n margin-top: 8px;\n color: var(--muted-foreground);\n font-size: 12px;\n line-height: 1.85;\n white-space: pre-wrap;\n}\n.inbox-actions {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 12px;\n border-top: 1px solid var(--border);\n background: var(--secondary);\n}\n.inbox-source {\n min-width: 0;\n flex: 1;\n color: var(--muted-foreground);\n font-weight: 400;\n}\n.inbox-source time {\n display: block;\n margin-top: 3px;\n font-size: 10px;\n font-variant-numeric: tabular-nums;\n}\n.inbox-session {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 11px;\n}\n.inbox-buttons {\n display: flex;\n flex: none;\n align-items: center;\n gap: 7px;\n}\n.inbox-actions .ui-button {\n font-size: 12px;\n}\n.inbox-footer {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 0 12px 10px;\n background: var(--secondary);\n color: var(--muted-foreground);\n font-size: 10px;\n}\n.inbox-footer > .ui-button {\n margin-inline-start: auto;\n font-size: 10px;\n}\n.inbox-pager {\n display: flex;\n flex: none;\n align-items: center;\n gap: 8px;\n margin-inline-start: auto;\n}\n.inbox-pager > span {\n min-width: 34px;\n text-align: center;\n font-size: 11px;\n font-variant-numeric: tabular-nums;\n}\n.inbox-pager .ui-button {\n width: 28px;\n padding: 0;\n}\n.inbox-empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 12px;\n min-height: 160px;\n padding: 20px;\n color: var(--muted-foreground);\n font-size: 12px;\n}\n.inbox-empty svg {\n width: 24px;\n height: 24px;\n}\n.inbox-deliveries {\n margin-top: 10px;\n color: var(--destructive);\n font-size: 11px;\n}\n.inbox-deliveries summary {\n cursor: pointer;\n}\n.inbox-deliveries p {\n margin-top: 6px;\n white-space: pre-wrap;\n}\n.inbox-offline {\n padding: 10px 12px;\n color: var(--warning);\n background: var(--inbox-warning-fill);\n font-size: 11px;\n}\n@media (max-width: 540px) {\n .inbox-navigation {\n gap: 8px;\n }\n .inbox-tabs [data-slot=\"tabs-trigger\"] > span {\n gap: 6px;\n }\n .inbox-navigation .inbox-pager {\n gap: 4px;\n }\n .inbox-navigation .inbox-pager > span {\n min-width: 28px;\n }\n .inbox-message-icon {\n width: 36px;\n height: 36px;\n }\n .inbox-actions {\n gap: 8px;\n }\n .inbox-buttons {\n gap: 5px;\n }\n .inbox-actions .ui-button {\n font-size: 11px;\n padding-inline: 8px;\n }\n}\n";
811
+ //#endregion
812
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
813
+ /**
814
+ * @license lucide-react v1.40.0 - ISC
815
+ *
816
+ * This source code is licensed under the ISC license.
817
+ * See the LICENSE file in the root directory of this source tree.
818
+ */
819
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
820
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
821
+ }).join(" ").trim();
822
+ //#endregion
823
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
824
+ /**
825
+ * @license lucide-react v1.40.0 - ISC
826
+ *
827
+ * This source code is licensed under the ISC license.
828
+ * See the LICENSE file in the root directory of this source tree.
829
+ */
830
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
831
+ //#endregion
832
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
833
+ /**
834
+ * @license lucide-react v1.40.0 - ISC
835
+ *
836
+ * This source code is licensed under the ISC license.
837
+ * See the LICENSE file in the root directory of this source tree.
838
+ */
839
+ var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
840
+ //#endregion
841
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
842
+ /**
843
+ * @license lucide-react v1.40.0 - ISC
844
+ *
845
+ * This source code is licensed under the ISC license.
846
+ * See the LICENSE file in the root directory of this source tree.
847
+ */
848
+ var toPascalCase = (string) => {
849
+ const camelCase = toCamelCase(string);
850
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
851
+ };
852
+ //#endregion
853
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/defaultAttributes.mjs
854
+ /**
855
+ * @license lucide-react v1.40.0 - ISC
856
+ *
857
+ * This source code is licensed under the ISC license.
858
+ * See the LICENSE file in the root directory of this source tree.
859
+ */
860
+ var defaultAttributes = {
861
+ xmlns: "http://www.w3.org/2000/svg",
862
+ width: 24,
863
+ height: 24,
864
+ viewBox: "0 0 24 24",
865
+ fill: "none",
866
+ stroke: "currentColor",
867
+ strokeWidth: 2,
868
+ strokeLinecap: "round",
869
+ strokeLinejoin: "round"
870
+ };
871
+ //#endregion
872
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
873
+ /**
874
+ * @license lucide-react v1.40.0 - ISC
875
+ *
876
+ * This source code is licensed under the ISC license.
877
+ * See the LICENSE file in the root directory of this source tree.
878
+ */
879
+ var hasA11yProp = (props) => {
880
+ for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
881
+ return false;
882
+ };
883
+ //#endregion
884
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/context.mjs
885
+ /**
886
+ * @license lucide-react v1.40.0 - ISC
887
+ *
888
+ * This source code is licensed under the ISC license.
889
+ * See the LICENSE file in the root directory of this source tree.
890
+ */
891
+ var LucideContext = createContext({});
892
+ var useLucideContext = () => useContext(LucideContext);
893
+ //#endregion
894
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/Icon.mjs
895
+ /**
896
+ * @license lucide-react v1.40.0 - ISC
897
+ *
898
+ * This source code is licensed under the ISC license.
899
+ * See the LICENSE file in the root directory of this source tree.
900
+ */
901
+ var Icon = forwardRef(({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
902
+ const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {};
903
+ const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
904
+ return createElement("svg", {
905
+ ref,
906
+ ...defaultAttributes,
907
+ width: size ?? contextSize ?? defaultAttributes.width,
908
+ height: size ?? contextSize ?? defaultAttributes.height,
909
+ stroke: color ?? contextColor,
910
+ strokeWidth: calculatedStrokeWidth,
911
+ className: mergeClasses("lucide", contextClass, className),
912
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
913
+ ...rest
914
+ }, [...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
915
+ });
916
+ //#endregion
917
+ //#region ../../../node_modules/.pnpm/lucide-react@1.40.0_react@19.2.8/node_modules/lucide-react/dist/esm/createLucideIcon.mjs
918
+ /**
919
+ * @license lucide-react v1.40.0 - ISC
920
+ *
921
+ * This source code is licensed under the ISC license.
922
+ * See the LICENSE file in the root directory of this source tree.
923
+ */
924
+ var createLucideIcon = (iconName, iconNode) => {
925
+ const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
926
+ ref,
927
+ iconNode,
928
+ className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
929
+ ...props
930
+ }));
931
+ Component.displayName = toPascalCase(iconName);
932
+ return Component;
933
+ };
934
+ /**
935
+ * @license lucide-react v1.40.0 - ISC
936
+ *
937
+ * This source code is licensed under the ISC license.
938
+ * See the LICENSE file in the root directory of this source tree.
939
+ */
940
+ var ArrowUpRight = createLucideIcon("arrow-up-right", [["path", {
941
+ d: "M7 7h10v10",
942
+ key: "1tivn9"
943
+ }], ["path", {
944
+ d: "M7 17 17 7",
945
+ key: "1vkiza"
946
+ }]]);
947
+ /**
948
+ * @license lucide-react v1.40.0 - ISC
949
+ *
950
+ * This source code is licensed under the ISC license.
951
+ * See the LICENSE file in the root directory of this source tree.
952
+ */
953
+ var Bell = createLucideIcon("bell", [["path", {
954
+ d: "M10.268 21a2 2 0 0 0 3.464 0",
955
+ key: "vwvbt9"
956
+ }], ["path", {
957
+ d: "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",
958
+ key: "11g9vi"
959
+ }]]);
960
+ /**
961
+ * @license lucide-react v1.40.0 - ISC
962
+ *
963
+ * This source code is licensed under the ISC license.
964
+ * See the LICENSE file in the root directory of this source tree.
965
+ */
966
+ var Check = createLucideIcon("check", [["path", {
967
+ d: "M20 6 9 17l-5-5",
968
+ key: "1gmf2c"
969
+ }]]);
970
+ /**
971
+ * @license lucide-react v1.40.0 - ISC
972
+ *
973
+ * This source code is licensed under the ISC license.
974
+ * See the LICENSE file in the root directory of this source tree.
975
+ */
976
+ var ChevronLeft = createLucideIcon("chevron-left", [["path", {
977
+ d: "m15 18-6-6 6-6",
978
+ key: "1wnfg3"
979
+ }]]);
980
+ /**
981
+ * @license lucide-react v1.40.0 - ISC
982
+ *
983
+ * This source code is licensed under the ISC license.
984
+ * See the LICENSE file in the root directory of this source tree.
985
+ */
986
+ var ChevronRight = createLucideIcon("chevron-right", [["path", {
987
+ d: "m9 18 6-6-6-6",
988
+ key: "mthhwq"
989
+ }]]);
990
+ /**
991
+ * @license lucide-react v1.40.0 - ISC
992
+ *
993
+ * This source code is licensed under the ISC license.
994
+ * See the LICENSE file in the root directory of this source tree.
995
+ */
996
+ var CircleQuestionMark = createLucideIcon("circle-question-mark", [
997
+ ["circle", {
998
+ cx: "12",
999
+ cy: "12",
1000
+ r: "10",
1001
+ key: "1mglay"
1002
+ }],
1003
+ ["path", {
1004
+ d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",
1005
+ key: "1u773s"
1006
+ }],
1007
+ ["path", {
1008
+ d: "M12 17h.01",
1009
+ key: "p32p05"
1010
+ }]
1011
+ ]);
1012
+ /**
1013
+ * @license lucide-react v1.40.0 - ISC
1014
+ *
1015
+ * This source code is licensed under the ISC license.
1016
+ * See the LICENSE file in the root directory of this source tree.
1017
+ */
1018
+ var ShieldCheck = createLucideIcon("shield-check", [["path", {
1019
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
1020
+ key: "oel41y"
1021
+ }], ["path", {
1022
+ d: "m9 12 2 2 4-4",
1023
+ key: "dzmm74"
1024
+ }]]);
1025
+ /**
1026
+ * @license lucide-react v1.40.0 - ISC
1027
+ *
1028
+ * This source code is licensed under the ISC license.
1029
+ * See the LICENSE file in the root directory of this source tree.
1030
+ */
1031
+ var Square = createLucideIcon("square", [["rect", {
1032
+ width: "18",
1033
+ height: "18",
1034
+ x: "3",
1035
+ y: "3",
1036
+ rx: "2",
1037
+ key: "afitv7"
1038
+ }]]);
1039
+ /**
1040
+ * @license lucide-react v1.40.0 - ISC
1041
+ *
1042
+ * This source code is licensed under the ISC license.
1043
+ * See the LICENSE file in the root directory of this source tree.
1044
+ */
1045
+ var TriangleAlert = createLucideIcon("triangle-alert", [
1046
+ ["path", {
1047
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
1048
+ key: "wmoenq"
1049
+ }],
1050
+ ["path", {
1051
+ d: "M12 9v4",
1052
+ key: "juzpu7"
1053
+ }],
1054
+ ["path", {
1055
+ d: "M12 17h.01",
1056
+ key: "p32p05"
1057
+ }]
1058
+ ]);
1059
+ //#endregion
1060
+ //#region ui-src/shell/describe.ts
1061
+ /** Names an external request without requiring the chat owner. */
1062
+ function requestTitle(pending, t) {
1063
+ if (pending.source === "async") return pending.request.title;
1064
+ return pending.request.kind === "approval" ? t("requests.approvalOf", { tool: pending.request.toolName }) : pending.request.questions[0]?.text ?? "";
1065
+ }
1066
+ /** What an inbox notice says on one line, and the glyph it carries. `name`
1067
+ * reads a session's title for the line; an unknown category is a generic
1068
+ * line, never an error. */
1069
+ function noticeText(item, t, name) {
1070
+ const detail = item.detail;
1071
+ switch (detail.category) {
1072
+ case "turn-ended": {
1073
+ const session = name(item.sessionId);
1074
+ if (detail.outcome.kind === "completed") return {
1075
+ text: t("inbox.turnCompleted", { session }),
1076
+ tone: "success"
1077
+ };
1078
+ if (detail.outcome.kind === "failed") return {
1079
+ text: t("inbox.turnFailed", { session }),
1080
+ tone: "failure"
1081
+ };
1082
+ return {
1083
+ text: t("inbox.turnInterrupted", { session }),
1084
+ tone: "neutral"
1085
+ };
1086
+ }
1087
+ case "subprocess-ended": {
1088
+ const failed = detail.ending.kind === "exited" && detail.ending.code !== 0 || detail.ending.kind === "signalled" || detail.ending.kind === "timed-out";
1089
+ return {
1090
+ text: t(failed ? "inbox.processFailed" : "inbox.processEnded", { command: detail.command }),
1091
+ tone: failed ? "failure" : "success"
1092
+ };
1093
+ }
1094
+ case "plugin": return {
1095
+ text: detail.title,
1096
+ tone: detail.tone
1097
+ };
1098
+ case "trigger-run": return {
1099
+ text: t("inbox.triggerRun", {
1100
+ name: detail.name,
1101
+ reason: t(`inbox.triggerReason.${detail.reason}`)
1102
+ }),
1103
+ tone: "failure"
1104
+ };
1105
+ case "participant-joined": return {
1106
+ text: t("inbox.participantJoined", {
1107
+ session: name(item.sessionId),
1108
+ reason: detail.reason
1109
+ }),
1110
+ tone: "neutral"
1111
+ };
1112
+ default: return {
1113
+ text: t("inbox.generic"),
1114
+ tone: "neutral"
1115
+ };
1116
+ }
1117
+ }
1118
+ //#endregion
1119
+ //#region ui-src/shell/inbox-panel.tsx
1120
+ /** Tabbed, single-item inbox browsing. Requests stay actionable in their sessions;
1121
+ * notices can be cleared here. Each category retains its own position. */
1122
+ function splitText(text) {
1123
+ const [title = "", ...rest] = text.trim().split(/\r?\n/);
1124
+ return {
1125
+ title,
1126
+ body: rest.join("\n").trim()
1127
+ };
1128
+ }
1129
+ function requestText(pending, t) {
1130
+ const request = pending.request;
1131
+ const heading = splitText(requestTitle(pending, t));
1132
+ const body = pending.source === "async" || request.kind === "approval" ? request.questions.map((question) => question.text).join("\n\n") : heading.body;
1133
+ return {
1134
+ title: heading.title,
1135
+ body: [...new Set([
1136
+ request.reason,
1137
+ body,
1138
+ request.warning
1139
+ ].filter(Boolean))].join("\n\n")
1140
+ };
1141
+ }
1142
+ function noticeContent(item, t, name) {
1143
+ const { text, tone } = noticeText(item, t, name);
1144
+ const detail = item.detail;
1145
+ if (detail.category === "plugin") return {
1146
+ title: detail.title,
1147
+ body: detail.body ?? "",
1148
+ tone
1149
+ };
1150
+ if (detail.category === "turn-ended") return {
1151
+ title: t(`inbox.outcome.${detail.outcome.kind}`),
1152
+ body: "",
1153
+ tone
1154
+ };
1155
+ if (detail.category === "subprocess-ended") return {
1156
+ title: t(tone === "failure" ? "inbox.commandFailed" : "inbox.commandEnded"),
1157
+ body: detail.command,
1158
+ tone
1159
+ };
1160
+ return {
1161
+ ...splitText(text),
1162
+ tone
1163
+ };
1164
+ }
1165
+ function usePosition(ids) {
1166
+ const [position, setPosition] = useState({
1167
+ id: ids[0],
1168
+ index: 0
1169
+ });
1170
+ const found = position.id === void 0 ? -1 : ids.indexOf(position.id);
1171
+ const index = found < 0 ? Math.min(position.index, Math.max(0, ids.length - 1)) : found;
1172
+ const id = ids[index];
1173
+ useEffect(() => {
1174
+ if (position.id !== id || position.index !== index) setPosition({
1175
+ id,
1176
+ index
1177
+ });
1178
+ }, [
1179
+ id,
1180
+ index,
1181
+ position.id,
1182
+ position.index
1183
+ ]);
1184
+ return {
1185
+ index,
1186
+ move: (next) => setPosition({
1187
+ id: ids[next],
1188
+ index: next
1189
+ })
1190
+ };
1191
+ }
1192
+ /** Displays category counts, one message and its source, plus bounded paging.
1193
+ * The caller supplies pending requests oldest first and notices newest first. */
1194
+ function InboxPanel({ elsewhere, notices, onGone, signal }) {
1195
+ const { t: translate, i18n } = useTranslation$1();
1196
+ const t = translate;
1197
+ const client = useGateway();
1198
+ const fail = useFailureToast();
1199
+ const online = useConnection(isOnline);
1200
+ const sessions = useSessions((state) => state.sessions);
1201
+ const triggers = useTriggers((state) => state.triggers);
1202
+ const items = useInbox((state) => state.items);
1203
+ const unreadKey = notices.filter((item) => item.readAt === null).map((item) => item.id).join("\0");
1204
+ useEffect(() => {
1205
+ if (signal.aborted || unreadKey === "") return;
1206
+ client.call("inbox.read", { ids: unreadKey.split("\0") }).catch(() => {});
1207
+ }, [
1208
+ unreadKey,
1209
+ client,
1210
+ signal
1211
+ ]);
1212
+ const [tab, setTab] = useState(elsewhere.length > 0 ? "waiting" : "notices");
1213
+ const [busy, setBusy] = useState(false);
1214
+ const requests = usePosition(elsewhere.map((item) => item.itemId));
1215
+ const notifications = usePosition(notices.map((item) => item.id));
1216
+ const name = (id) => sessionTitle(sessions.find((one) => one.sessionId === id), triggers, t("inbox.untitled"));
1217
+ const pending = elsewhere[requests.index];
1218
+ const notice = notices[notifications.index];
1219
+ const requestItem = pending === void 0 ? void 0 : items.find((item) => item.id === pending.itemId);
1220
+ const count = tab === "waiting" ? elsewhere.length : notices.length;
1221
+ const position = tab === "waiting" ? requests : notifications;
1222
+ async function clear(item) {
1223
+ setBusy(true);
1224
+ try {
1225
+ if (item) await client.call("inbox.clear", { ids: [item.id] });
1226
+ else await client.call("inbox.clearRead");
1227
+ } catch (error) {
1228
+ fail(error);
1229
+ } finally {
1230
+ setBusy(false);
1231
+ }
1232
+ }
1233
+ async function open(sessionId) {
1234
+ setBusy(true);
1235
+ try {
1236
+ if (await goToSession(client, sessionId)) onGone();
1237
+ else fail(t("inbox.sessionMissing"));
1238
+ } catch (error) {
1239
+ fail(error);
1240
+ } finally {
1241
+ setBusy(false);
1242
+ }
1243
+ }
1244
+ function source(sessionId, createdAt, owner = "") {
1245
+ const title = sessionId === null ? owner : name(sessionId);
1246
+ return /* @__PURE__ */ jsxs("div", {
1247
+ className: "inbox-source",
1248
+ children: [/* @__PURE__ */ jsx("span", {
1249
+ className: "inbox-session",
1250
+ title,
1251
+ children: title
1252
+ }), createdAt !== void 0 && /* @__PURE__ */ jsx("time", {
1253
+ dateTime: new Date(createdAt).toISOString(),
1254
+ title: new Date(createdAt).toLocaleString(i18n.language),
1255
+ children: new Intl.DateTimeFormat(i18n.language, {
1256
+ month: "2-digit",
1257
+ day: "2-digit",
1258
+ hour: "2-digit",
1259
+ minute: "2-digit"
1260
+ }).format(createdAt)
1261
+ })]
1262
+ });
1263
+ }
1264
+ const requestCopy = pending && requestText(pending, t);
1265
+ const noticeCopy = notice && noticeContent(notice, t, name);
1266
+ const RequestIcon = pending?.request.kind === "approval" ? ShieldCheck : CircleQuestionMark;
1267
+ const NoticeIcon = noticeCopy?.tone === "failure" ? TriangleAlert : noticeCopy?.tone === "success" ? Check : notice?.detail.category === "turn-ended" ? Square : Bell;
1268
+ return /* @__PURE__ */ jsxs(Tabs, {
1269
+ value: tab,
1270
+ onValueChange: (value) => setTab(String(value)),
1271
+ size: "sm",
1272
+ variant: "footer",
1273
+ className: "inbox-panel",
1274
+ children: [
1275
+ /* @__PURE__ */ jsxs("div", {
1276
+ className: "inbox-viewport",
1277
+ children: [/* @__PURE__ */ jsx(TabsContent, {
1278
+ value: "waiting",
1279
+ "data-slot": "inbox-waiting",
1280
+ children: pending && requestCopy ? /* @__PURE__ */ jsxs("article", {
1281
+ "data-request": pending.request.requestId,
1282
+ children: [/* @__PURE__ */ jsxs("div", {
1283
+ className: "inbox-message",
1284
+ children: [/* @__PURE__ */ jsx("span", {
1285
+ className: "inbox-message-icon",
1286
+ "data-tone": "warning",
1287
+ children: /* @__PURE__ */ jsx(RequestIcon, { "aria-hidden": "true" })
1288
+ }), /* @__PURE__ */ jsxs("div", {
1289
+ className: "inbox-copy",
1290
+ children: [/* @__PURE__ */ jsx("h3", {
1291
+ title: requestCopy.title,
1292
+ children: requestCopy.title
1293
+ }), requestCopy.body && /* @__PURE__ */ jsx("p", { children: requestCopy.body })]
1294
+ })]
1295
+ }), /* @__PURE__ */ jsxs("div", {
1296
+ className: "inbox-actions",
1297
+ children: [source(pending.sessionId, requestItem?.createdAt), /* @__PURE__ */ jsxs(Button, {
1298
+ size: "sm",
1299
+ variant: "primary",
1300
+ disabled: !online || busy,
1301
+ onClick: () => void open(pending.sessionId),
1302
+ children: [t(pending.request.kind === "approval" ? "inbox.goApprove" : "inbox.goAnswer"), /* @__PURE__ */ jsx(ArrowUpRight, {
1303
+ "aria-hidden": "true",
1304
+ className: "size-3.5"
1305
+ })]
1306
+ })]
1307
+ })]
1308
+ }) : /* @__PURE__ */ jsxs("div", {
1309
+ className: "inbox-empty",
1310
+ children: [/* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("p", { children: t("inbox.emptyWaiting") })]
1311
+ })
1312
+ }), /* @__PURE__ */ jsx(TabsContent, {
1313
+ value: "notices",
1314
+ "data-slot": "inbox-notices",
1315
+ children: notice && noticeCopy ? /* @__PURE__ */ jsxs("article", {
1316
+ "data-item": notice.id,
1317
+ "data-unread": notice.readAt === null,
1318
+ children: [/* @__PURE__ */ jsxs("div", {
1319
+ className: "inbox-message",
1320
+ children: [/* @__PURE__ */ jsx("span", {
1321
+ className: "inbox-message-icon",
1322
+ "data-tone": noticeCopy.tone,
1323
+ children: /* @__PURE__ */ jsx(NoticeIcon, { "aria-hidden": "true" })
1324
+ }), /* @__PURE__ */ jsxs("div", {
1325
+ className: "inbox-copy",
1326
+ children: [
1327
+ /* @__PURE__ */ jsx("h3", {
1328
+ title: noticeCopy.title,
1329
+ children: noticeCopy.title
1330
+ }),
1331
+ noticeCopy.body && /* @__PURE__ */ jsx("p", { children: noticeCopy.body }),
1332
+ notice.readAt === null && /* @__PURE__ */ jsx("span", {
1333
+ className: "sr-only",
1334
+ children: t("inbox.unread")
1335
+ }),
1336
+ notice.deliveries.some((one) => one.state === "failed") && /* @__PURE__ */ jsxs(Disclosure, {
1337
+ className: "inbox-deliveries",
1338
+ children: [/* @__PURE__ */ jsx(DisclosureSummary, { children: t("inbox.deliveryFailed") }), notice.deliveries.filter((one) => one.state === "failed").map((one) => /* @__PURE__ */ jsx("p", { children: t("inbox.pushFailed", {
1339
+ notifier: one.notifier,
1340
+ reason: one.reason ?? ""
1341
+ }) }, one.notifier))]
1342
+ }, notice.id)
1343
+ ]
1344
+ })]
1345
+ }), /* @__PURE__ */ jsxs("div", {
1346
+ className: "inbox-actions",
1347
+ children: [source(notice.sessionId, notice.createdAt, notice.owner), /* @__PURE__ */ jsxs("div", {
1348
+ className: "inbox-buttons",
1349
+ children: [/* @__PURE__ */ jsx(Button, {
1350
+ size: "sm",
1351
+ variant: "outline",
1352
+ disabled: !online || busy,
1353
+ onClick: () => void clear(notice),
1354
+ children: t("inbox.clear")
1355
+ }), notice.sessionId !== null && /* @__PURE__ */ jsxs(Button, {
1356
+ size: "sm",
1357
+ variant: "primary",
1358
+ disabled: !online || busy,
1359
+ onClick: () => void open(notice.sessionId),
1360
+ children: [t("inbox.viewSession"), /* @__PURE__ */ jsx(ArrowUpRight, {
1361
+ "aria-hidden": "true",
1362
+ className: "size-3.5"
1363
+ })]
1364
+ })]
1365
+ })]
1366
+ })]
1367
+ }) : /* @__PURE__ */ jsxs("div", {
1368
+ className: "inbox-empty",
1369
+ children: [/* @__PURE__ */ jsx(Bell, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("p", { children: t("inbox.empty") })]
1370
+ })
1371
+ })]
1372
+ }),
1373
+ tab === "notices" && notices.some((item) => item.readAt !== null) && /* @__PURE__ */ jsx("div", {
1374
+ className: "inbox-footer",
1375
+ children: /* @__PURE__ */ jsx(Button, {
1376
+ size: "sm",
1377
+ variant: "outline",
1378
+ disabled: !online || busy,
1379
+ onClick: () => void clear(),
1380
+ children: t("inbox.clearRead")
1381
+ })
1382
+ }),
1383
+ /* @__PURE__ */ jsxs("div", {
1384
+ className: "inbox-navigation",
1385
+ children: [/* @__PURE__ */ jsxs(TabsList, {
1386
+ className: "inbox-tabs",
1387
+ "aria-label": t("inbox.center"),
1388
+ children: [/* @__PURE__ */ jsxs(TabsTrigger, {
1389
+ value: "waiting",
1390
+ children: [
1391
+ t("inbox.waiting"),
1392
+ " ",
1393
+ /* @__PURE__ */ jsx("span", {
1394
+ className: "inbox-tab-count",
1395
+ children: elsewhere.length
1396
+ })
1397
+ ]
1398
+ }), /* @__PURE__ */ jsxs(TabsTrigger, {
1399
+ value: "notices",
1400
+ children: [
1401
+ t("inbox.title"),
1402
+ " ",
1403
+ /* @__PURE__ */ jsx("span", {
1404
+ className: "inbox-tab-count",
1405
+ children: notices.length
1406
+ })
1407
+ ]
1408
+ })]
1409
+ }), count > 1 && /* @__PURE__ */ jsxs("div", {
1410
+ className: "inbox-pager",
1411
+ children: [
1412
+ /* @__PURE__ */ jsx(Button, {
1413
+ size: "sm",
1414
+ variant: "ghost",
1415
+ "aria-label": t("inbox.previous"),
1416
+ title: t("inbox.previous"),
1417
+ disabled: position.index === 0,
1418
+ onClick: () => position.move(position.index - 1),
1419
+ children: /* @__PURE__ */ jsx(ChevronLeft, {
1420
+ "aria-hidden": "true",
1421
+ className: "size-3.5"
1422
+ })
1423
+ }),
1424
+ /* @__PURE__ */ jsxs("span", {
1425
+ "aria-live": "polite",
1426
+ "aria-atomic": "true",
1427
+ children: [
1428
+ position.index + 1,
1429
+ " / ",
1430
+ count
1431
+ ]
1432
+ }),
1433
+ /* @__PURE__ */ jsx(Button, {
1434
+ size: "sm",
1435
+ variant: "ghost",
1436
+ "aria-label": t("inbox.next"),
1437
+ title: t("inbox.next"),
1438
+ disabled: position.index === count - 1,
1439
+ onClick: () => position.move(position.index + 1),
1440
+ children: /* @__PURE__ */ jsx(ChevronRight, {
1441
+ "aria-hidden": "true",
1442
+ className: "size-3.5"
1443
+ })
1444
+ })
1445
+ ]
1446
+ })]
1447
+ })
1448
+ ]
1449
+ });
1450
+ }
1451
+ //#endregion
1452
+ //#region ui-src/shell/inbox.tsx
1453
+ /** The nav inbox counts requests waiting elsewhere and unread notices. Opening
1454
+ * the popover reads its notices; requests are answered in their own session. */
1455
+ /** Opens the global inbox from the nav. */
1456
+ function InboxEntry({ signal }) {
1457
+ const { t } = useTranslation$1();
1458
+ const client = useGateway();
1459
+ const open = useInbox((state) => state.open);
1460
+ const setOpen = useInbox((state) => state.setOpen);
1461
+ const baselineStatus = useInbox((state) => state.baselineStatus);
1462
+ const selected = useOpenSession()?.sessionId ?? null;
1463
+ const current = pageKey(usePage());
1464
+ const shown = usePlugins((state) => state.contributions.some((entry) => entry.key === current && entry.slot === "shell.nav.page" && entry.contribution.sessionScoped)) ? selected : null;
1465
+ const pending = usePendingRequests();
1466
+ const elsewhere = useMemo(() => pending.filter((one) => one.sessionId !== shown), [pending, shown]);
1467
+ const notices = useNotices();
1468
+ const unread = notices.filter((item) => item.readAt === null);
1469
+ const count = elsewhere.length + unread.length;
1470
+ const label = count === 0 ? t("inbox.label") : t("inbox.labelCount", { count });
1471
+ useEffect(() => () => setOpen(false), [setOpen]);
1472
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsxs(Popover, {
1473
+ label: t("inbox.title"),
1474
+ open,
1475
+ onOpenChange: setOpen,
1476
+ side: "inline-end",
1477
+ align: "end",
1478
+ width: 420,
1479
+ className: "inbox-popover",
1480
+ trigger: /* @__PURE__ */ jsxs(TooltipTrigger, {
1481
+ render: /* @__PURE__ */ jsx(Button, {
1482
+ variant: "plain",
1483
+ "data-slot": "nav-entry",
1484
+ "data-entry": "inbox",
1485
+ "aria-label": label,
1486
+ className: navEntryClass({
1487
+ named: false,
1488
+ current: false
1489
+ })
1490
+ }),
1491
+ children: [/* @__PURE__ */ jsx(NavEntryBody, {
1492
+ Icon: Bell,
1493
+ label,
1494
+ named: false,
1495
+ current: false
1496
+ }), count > 0 && /* @__PURE__ */ jsx("span", {
1497
+ "data-slot": "inbox-count",
1498
+ "aria-hidden": "true",
1499
+ className: "inbox-count",
1500
+ "data-tone": elsewhere.length > 0 ? "warning" : void 0,
1501
+ children: count > 99 ? "99+" : count
1502
+ })]
1503
+ }),
1504
+ children: [
1505
+ baselineStatus === "loading" && /* @__PURE__ */ jsx("p", {
1506
+ role: "status",
1507
+ className: "p-3 text-xs text-muted-foreground",
1508
+ children: t("common.working")
1509
+ }),
1510
+ baselineStatus === "failed" && /* @__PURE__ */ jsx(Button, {
1511
+ variant: "ghost",
1512
+ onClick: () => void useInbox.getState().load(client),
1513
+ children: t("common.retry")
1514
+ }),
1515
+ /* @__PURE__ */ jsx(InboxPanel, {
1516
+ signal,
1517
+ elsewhere,
1518
+ notices,
1519
+ onGone: () => setOpen(false)
1520
+ })
1521
+ ]
1522
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1523
+ side: "inline-end",
1524
+ sideOffset: 10,
1525
+ children: label
1526
+ })] }) });
1527
+ }
1528
+ //#endregion
1529
+ //#region ui-src/index.tsx
1530
+ /** Browser module version understood by the host. */
1531
+ var runtimeVersion = 5;
1532
+ /** This feature consumes optional native device ports. */
1533
+ var provides = [];
1534
+ /** Owns inbox browsing and settings; starts device reminders after optional native acquisition. */
1535
+ function register(ctx) {
1536
+ registerTranslations(ctx);
1537
+ useInbox.getState().setOpen(false);
1538
+ ctx.styles.add(inbox_default, {
1539
+ layer: "unlayered",
1540
+ scope: "document"
1541
+ });
1542
+ ctx.slots.register("shell.nav.secondary", {
1543
+ id: "inbox",
1544
+ order: 0,
1545
+ component: () => /* @__PURE__ */ jsx(InboxEntry, { signal: ctx.signal })
1546
+ });
1547
+ ctx.signal.addEventListener("abort", () => useInbox.getState().setOpen(false), { once: true });
1548
+ ctx.slots.register("shell.settings.category", {
1549
+ id: "notifications",
1550
+ label: () => ctx.i18n.t("notifications.title"),
1551
+ icon: "bell",
1552
+ region: "preset",
1553
+ order: 68,
1554
+ component: NotificationsPanel
1555
+ });
1556
+ activateNativeFeature(ctx, "system-notifications", () => {
1557
+ const stops = [
1558
+ initNotificationsStore(),
1559
+ connectNotificationDevice(ctx),
1560
+ registerInboxNotifications(ctx)
1561
+ ];
1562
+ ctx.signal.addEventListener("abort", () => {
1563
+ for (const stop of stops.toReversed()) stop();
1564
+ }, { once: true });
1565
+ });
1566
+ }
1567
+ //#endregion
1568
+ export { provides, register, runtimeVersion };