dsh-sideby-note 0.0.0-stage → 0.1.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.
@@ -0,0 +1,4425 @@
1
+ window.__ModuleLoader__.load({ id: "dsh-sideby-note", factory: (require) => {
2
+
3
+ var module = { exports: {} }; var exports = module.exports;
4
+ // \0rolldown/runtime.js
5
+ var __create = Object.create;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ }
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+
30
+ let react = require("react");
31
+ react = __toESM(react, 1);
32
+ let react_dom_client = require("react-dom/client");
33
+ react_dom_client = __toESM(react_dom_client, 1);
34
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
35
+ _deepseek_ai_dsh_client_ui_primitives = __toESM(_deepseek_ai_dsh_client_ui_primitives, 1);
36
+ let react_dom = require("react-dom");
37
+ react_dom = __toESM(react_dom, 1);
38
+
39
+ // \0dsh-css:src/client/styles/panel.css.mjs
40
+ var panel_css_default = "/*\n * Panel, composer dock, header entry and toast styles.\n *\n * Only DSH semantic aliases and the shared scale are used here — no palette of\n * its own. The entry point injects this sheet once for the whole frame, because\n * the dock mounts outside the panel tree.\n */\n/* ── 1 令牌 · 只映射 DSH 语义别名与共享尺度,不新建调色板 ─────────── */\nbody{--an-space-1:4px;--an-space-2:8px;--an-space-3:12px;--an-space-4:16px;--an-space-5:24px;--an-space-6:32px;--an-radius-pill:999px;--an-fs-caption:12px;--an-lh-caption:20px;--an-fs-row:13px;--an-lh-row:20px;--an-fs-title:14px;--an-lh-title:20px;--an-hover:var(--dsw-alias-interactive-bg-hover);--an-active:var(--dsw-alias-interactive-bg-active);--an-field:var(--dsw-alias-bg-layer-1);--an-field-line:var(--dsw-alias-border-l4);--an-divider:var(--dsw-alias-border-l2);--an-dur-fast:var(--ds-transition-duration-fast);--an-dur-base:var(--ds-transition-duration);--an-dur-spin:700ms;--an-ease:var(--ds-ease-in-out);--an-transition:background-color var(--an-dur-fast) var(--an-ease),border-color var(--an-dur-fast) var(--an-ease),color var(--an-dur-fast) var(--an-ease),opacity var(--an-dur-fast) var(--an-ease),transform var(--an-dur-fast) var(--an-ease),box-shadow var(--an-dur-fast) var(--an-ease)}\n\n/* ── 2 浮层 · 菜单材质 + 三层阴影,边框为 0(发丝线在阴影第一层) ── */\n.dsh-an-popover{position:fixed;z-index:1000;box-sizing:border-box;display:flex;flex-direction:column;gap:var(--an-space-3);min-height:0;padding:var(--an-space-4);border:0;border-radius:var(--dsw-radius-panel);background:var(--dsh-an-panelSurface);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:var(--an-fs-row);line-height:var(--an-lh-row);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2,var(--an-divider));--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2,var(--dsw-alias-scrollbar-bg-l2,var(--an-divider)));--dsh-an-panelSurface:var(--dsw-alias-bg-layer-2);--dsh-an-listGutter:var(--an-space-4);--dsh-an-scrollRail:9px;--dsh-an-scrollInset:2px;overflow:hidden;animation:dsh-an-pop-in var(--an-dur-base) var(--an-ease) both}\n.dsh-an-popoverRight{padding-left:var(--an-space-4)}\n\n/* ── 3 面板头 · 标题与计数同一行,动作收在右侧 ───────────────────── */\n.dsh-an-popHead{display:flex;align-items:center;justify-content:space-between;gap:var(--an-space-3);min-width:0}\n.dsh-an-popTitleLine{display:flex;align-items:center;gap:var(--an-space-3);flex:1 1 auto;min-width:0}\n.dsh-an-popTitle{min-width:0;overflow:hidden;font-size:var(--an-fs-title);line-height:var(--an-lh-title);font-weight:500;color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis}\n.dsh-an-popMeta{min-width:0;margin:0;overflow:hidden;font-size:var(--an-fs-caption);line-height:16px;color:var(--dsw-alias-label-secondary);font-weight:400;font-variant-numeric:tabular-nums;white-space:nowrap;text-overflow:ellipsis}\n.dsh-an-popActions{display:flex;align-items:center;flex:none;gap:var(--an-space-2)}\n.dsh-an-popClose,.dsh-an-settingsBtn{display:grid;place-items:center;flex:none;width:24px;height:24px;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-popClose:active,.dsh-an-settingsBtn:active{background:var(--an-active)}\n.dsh-an-settingsBtn[data-active=\"true\"]{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-settingsBtn{position:relative}\n.dsh-an-updateDot{position:absolute;top:3px;right:3px;width:6px;height:6px;border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-brand-primary);box-shadow:0 0 0 2px var(--dsh-an-panelSurface)}\n/* The list-scope switch sits at the far right of the title line. */\n.dsh-an-scope{display:inline-flex;align-items:center;flex:none;box-sizing:border-box;height:24px;padding:1px;margin-left:auto;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-bg-layer-1)}\n.dsh-an-scopeBtn{display:inline-flex;align-items:center;justify-content:center;height:20px;padding:0 var(--an-space-2);border:0;border-radius:var(--an-radius-pill);corner-shape:round;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:var(--an-fs-caption);line-height:16px;font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-scopeBtn[data-active=\"true\"]{background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}\n.dsh-an-scopeBtn:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:1px}\n\n/* ── 4 添加区 · 嵌套表单组 R16,字段 0.5px 发丝线 ──────────────────── */\n.dsh-an-add{display:flex;flex-direction:column;gap:var(--an-space-2);padding:var(--an-space-3);border:0.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill);transition:var(--an-transition)}\n.dsh-an-add:focus-within{border-color:var(--dsw-alias-state-business-primary)}\n.dsh-an-input{display:block;flex:0 0 auto;width:100%;min-width:0;box-sizing:border-box;min-height:var(--an-lh-row);max-height:120px;padding:0;border:0;outline:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-row);line-height:var(--an-lh-row);resize:none;overflow-y:auto;overflow-x:hidden}\n.dsh-an-input::placeholder{color:var(--dsw-alias-label-secondary)}\n.dsh-an-addFoot{display:flex;align-items:center;justify-content:space-between;gap:var(--an-space-2);width:100%;min-width:0}\n.dsh-an-addShortcut{min-width:0;overflow:hidden;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis}\n.dsh-an-addBtn{display:inline-flex;align-items:center;justify-content:center;flex:none;height:28px;padding:0 var(--an-space-2);border:0;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-addBtn:active{background:var(--dsw-alias-button-primary-dimmed);transform:scale(.97)}\n.dsh-an-addBtn[disabled]{background:transparent;color:var(--dsw-alias-label-secondary);box-shadow:inset 0 0 0 0.5px var(--an-field-line);cursor:not-allowed}\n\n/* ── 5 分区与列表 · 9px 轨道内嵌 2px,底部羽化只盖内容不盖滚动条 ──── */\n/* The viewport grows into the popover padding so the 9px rail does not steal from the cards; the list pays the padding back minus the rail, so cards and the add field keep one content width at every panel size. */\n.dsh-an-listViewport{position:relative;display:flex;flex-direction:column;flex:1 1 auto;min-height:0;margin-right:calc(var(--dsh-an-listGutter) * -1)}\n/* Bottom edge treatment: a viewport-fixed alpha mask over the scroller itself, exactly like the DSH scroll areas. The first gradient fades the last 48px to transparent; the second keeps the 9px scrollbar rail opaque so the thumb stays crisp. There is no backdrop-filter layer, so there is no hard compositing edge to see. */\n.dsh-an-listViewport[data-bottom=\"true\"] .dsh-an-listArea{--dsh-an-fadeHeight:calc(var(--an-space-6) + var(--an-space-4));-webkit-mask-image:linear-gradient(to bottom,currentColor 0,currentColor calc(100% - var(--dsh-an-fadeHeight)),transparent 100%),linear-gradient(to right,transparent calc(100% - var(--dsh-an-scrollRail)),currentColor calc(100% - var(--dsh-an-scrollRail)));mask-image:linear-gradient(to bottom,currentColor 0,currentColor calc(100% - var(--dsh-an-fadeHeight)),transparent 100%),linear-gradient(to right,transparent calc(100% - var(--dsh-an-scrollRail)),currentColor calc(100% - var(--dsh-an-scrollRail)));-webkit-mask-composite:source-over;mask-composite:add}\n/* Geometry only: the shared DSH skin paints the thumb, so the plugin declares no scrollbar pseudo-elements. The popover already binds the l2 thumb pair for the menu material. */\n.dsh-an-listArea{--dsh-scrollbar-width:var(--dsh-an-scrollRail);--dsh-scrollbar-thumb-border:var(--dsh-an-scrollInset);display:flex;flex-direction:column;flex:1 1 auto;min-height:0;padding-right:calc(var(--dsh-an-listGutter) - var(--dsh-an-scrollRail));overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable}\n/* The settings card rides the same rail as the list. When the panel is shorter than the card, the viewport takes the squeeze and scrolls instead of letting the card run under the popover's clipped bottom edge; the card keeps one content width in both states. */\n.dsh-an-settingsViewport{display:flex;flex-direction:column;flex:0 1 auto;min-height:0;margin-right:calc(var(--dsh-an-listGutter) * -1);padding-right:calc(var(--dsh-an-listGutter) - var(--dsh-an-scrollRail));overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable;--dsh-scrollbar-width:var(--dsh-an-scrollRail);--dsh-scrollbar-thumb-border:var(--dsh-an-scrollInset)}\n/* While settings is open the list yields its height first, so the card keeps its natural height until there is nothing left to take from the list. */\n.dsh-an-popover[data-settings=\"true\"] .dsh-an-listViewport{flex-shrink:10000}\n.dsh-an-listSection{display:flex;flex-direction:column;gap:var(--an-space-2);min-width:0}\n.dsh-an-listSection+.dsh-an-listSection{margin-top:var(--an-space-2)}\n.dsh-an-sectionHead,.dsh-an-doneHead{position:sticky;top:0;z-index:3;display:flex;align-items:center;justify-content:space-between;gap:var(--an-space-3);min-height:28px;margin:0;padding:var(--an-space-1) 0;background:transparent;transition:background-color var(--an-dur-fast) var(--an-ease)}\n.dsh-an-sectionHead[data-stuck],.dsh-an-doneHead[data-stuck]{background:var(--dsh-an-panelSurface,var(--dsw-alias-bg-layer-2))}\n.dsh-an-doneToggle{display:flex;align-items:center;gap:var(--an-space-2);flex:none;min-width:0;margin:0;padding:var(--an-space-1) var(--an-space-2) var(--an-space-1) 0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;text-align:left;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-doneToggle:active{background:var(--an-active)}\n.dsh-an-doneToggle[disabled]{color:var(--dsw-alias-label-tertiary);cursor:not-allowed;pointer-events:none}\n.dsh-an-chevron{display:flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px;color:var(--dsw-alias-label-secondary);transition:transform var(--an-dur-fast) var(--an-ease)}\n.dsh-an-chevron[data-open=\"true\"]{transform:rotate(90deg)}\n.dsh-an-sectionCount{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 var(--an-space-1);border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary);font-size:var(--an-fs-caption);line-height:16px;font-weight:500;font-variant-numeric:tabular-nums}\n.dsh-an-clear{display:inline-flex;align-items:center;flex:none;height:24px;margin-left:auto;padding:0 var(--an-space-2);border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-clear:active{background:var(--an-active);color:var(--dsw-alias-label-primary)}\n.dsh-an-clearConfirm{display:flex;align-items:center;justify-content:space-between;gap:var(--an-space-2);min-width:0;margin-top:var(--an-space-1);padding:var(--an-space-2);border:0.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill)}\n.dsh-an-clearConfirmText{flex:1 1 auto;min-width:0;margin:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}\n.dsh-an-clearConfirmActions{display:flex;align-items:center;flex:none;gap:var(--an-space-1)}\n.dsh-an-doneRows{margin-top:var(--an-space-2)}\n.dsh-an-rows{list-style:none;margin:0;padding:0;border:0.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill);overflow:hidden}\n.dsh-an-row{display:flex;align-items:flex-start;gap:var(--an-space-2);padding:var(--an-space-2);border-top:0.5px solid var(--an-divider);transition:var(--an-transition)}\n.dsh-an-row:first-child{border-top:0}\n\n/* ── 6 一行便笺 · 勾选圈 14px,命中区 24px ─────────────────────────── */\n.dsh-an-check{display:flex;align-items:center;justify-content:center;flex:none;width:24px;height:24px;margin:-2px 0 0;padding:0;border:0;border-radius:var(--an-radius-pill);corner-shape:round;background:transparent;color:transparent;font:inherit;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-checkCircle{display:flex;align-items:center;justify-content:center;width:14px;height:14px;box-sizing:border-box;border:0.5px solid var(--dsw-alias-label-tertiary);border-radius:var(--an-radius-pill);corner-shape:round;background:transparent;color:transparent;transition:border-color var(--an-dur-fast) var(--an-ease),background-color var(--an-dur-fast) var(--an-ease),color var(--an-dur-fast) var(--an-ease),transform var(--an-dur-fast) var(--an-ease)}\n.dsh-an-check:active .dsh-an-checkCircle{transform:scale(.9)}\n.dsh-an-check[aria-checked=\"true\"] .dsh-an-checkCircle{border-color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}\n.dsh-an-itemBody{display:flex;flex:1;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-text{display:block;width:100%;margin:0;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-row);line-height:var(--an-lh-row);text-align:left;white-space:pre-wrap;overflow-wrap:anywhere;user-select:text;-webkit-user-select:text}\n.dsh-an-rowDone .dsh-an-text{color:var(--dsw-alias-label-secondary);text-decoration:line-through;text-decoration-thickness:1px;text-decoration-color:var(--dsw-alias-label-tertiary)}\n.dsh-an-rowFoot{display:flex;align-items:center;justify-content:space-between;gap:var(--an-space-2);min-height:24px}\n.dsh-an-meta{flex:0 1 auto;min-width:0;overflow:hidden;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;text-overflow:ellipsis}\n\n/* ── 7 行操作 · 图标按钮 H24/R8,触摸端常显 ────────────────────────── */\n.dsh-an-actions{display:flex;flex:none;gap:var(--an-space-1)}\n.dsh-an-iconBtn{position:relative;display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-iconBtn:active{background:var(--an-active);color:var(--dsw-alias-label-primary);transform:scale(.94)}\n.dsh-an-iconBtn:disabled,.dsh-an-iconBtn[disabled]{color:var(--dsw-alias-label-tertiary);cursor:not-allowed;pointer-events:none}\n.dsh-an-glyphFlip{transform:scaleX(-1)}\n.dsh-an-forwardMark{position:absolute;right:0;bottom:0;display:flex;align-items:center;justify-content:center;width:10px;height:10px;border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-label-secondary);color:var(--dsw-alias-label-primary-foreground);pointer-events:none}\n\n/* ── 8 紧凑文字按钮 · 清空确认 ─────────────────────────────────── */\n.dsh-an-mini{display:inline-flex;align-items:center;justify-content:center;flex:none;height:24px;padding:0 var(--an-space-2);border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-mini:active{background:var(--an-active)}\n.dsh-an-mini[disabled]{color:var(--dsw-alias-label-tertiary);cursor:not-allowed;pointer-events:none}\n.dsh-an-miniDanger{border-color:transparent;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground)}\n.dsh-an-miniDanger:active{background:var(--dsw-alias-state-error-primary)}\n\n/* ── 9 空态 · 虚线 1px,说明 12/次级墨色 ──────────────────────────── */\n.dsh-an-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--an-space-2);padding:var(--an-space-5) var(--an-space-4);border:1px dashed var(--an-divider);border-radius:var(--dsw-radius-lg);text-align:center}\n.dsh-an-emptyIcon{display:flex;align-items:center;justify-content:center;width:32px;height:32px;margin:0 0 var(--an-space-1);border-radius:var(--dsw-radius-md);background:var(--an-hover);color:var(--dsw-alias-label-secondary)}\n.dsh-an-emptyTitle{font-size:var(--an-fs-row);line-height:var(--an-lh-row);font-weight:500;color:var(--dsw-alias-label-primary)}\n.dsh-an-emptyBody{max-width:36ch;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}\n\n/* ── 10 设置 · 分组 R16,项间 0.5px 分隔线,链接走 --dsw-alias-link ── */\n.dsh-an-settings{--dsh-an-settingIndent:var(--an-space-3);display:flex;flex-direction:column;gap:var(--an-space-2);margin:0;padding:var(--an-space-3);border:0.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill)}\n.dsh-an-settingsHead{font-size:var(--an-fs-row);line-height:var(--an-lh-row);font-weight:500;color:var(--dsw-alias-label-primary)}\n.dsh-an-settingGroup{display:flex;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-settingGroup+.dsh-an-settingGroup{margin-top:var(--an-space-2);padding-top:var(--an-space-2);border-top:0.5px solid var(--an-divider)}\n.dsh-an-settingLabel{font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;color:var(--dsw-alias-label-secondary)}\n.dsh-an-settingBody{display:flex;flex-direction:column;gap:var(--an-space-1);padding-left:var(--dsh-an-settingIndent)}\n.dsh-an-settingItem{display:flex;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-settingItem+.dsh-an-settingItem{margin-top:var(--an-space-2);padding-top:var(--an-space-2);border-top:0.5px solid var(--an-divider)}\n.dsh-an-settingChoices{display:flex;flex-direction:column;gap:var(--an-space-1)}\n.dsh-an-settingChoice{display:flex;align-items:flex-start;gap:var(--an-space-2);font-size:var(--an-fs-row);line-height:var(--an-lh-row);color:var(--dsw-alias-label-primary);cursor:pointer}\n.dsh-an-settingChoice input{appearance:none;flex:none;width:14px;height:14px;margin:calc((var(--an-lh-row) - 14px) / 2) 0 0;box-sizing:border-box;border:0.5px solid var(--dsw-alias-label-tertiary);border-radius:var(--an-radius-pill);corner-shape:round;background:transparent;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-settingChoice input:checked{border-color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-brand-primary);box-shadow:inset 0 0 0 3px var(--an-field)}\n.dsh-an-settingInput{box-sizing:border-box;width:100%;height:28px;padding:0 var(--an-space-2);border:0.5px solid var(--an-field-line);border-radius:var(--dsw-radius-sm);background:var(--an-field);color:var(--dsw-alias-label-primary);font-family:inherit;font-size:var(--an-fs-row);line-height:var(--an-lh-row);font-weight:500;outline:0;transition:var(--an-transition)}\n.dsh-an-settingItem>.dsh-an-settingInput{font-family:inherit;font-size:var(--an-fs-row);line-height:var(--an-lh-row);font-weight:500}\n.dsh-an-settingInput:focus{border-color:var(--dsw-alias-state-business-primary)}\n/* 前缀提示词改为文本域:min-height 兜住三行,空态也不会被内联高度压扁 */\n.dsh-an-settingTextarea{display:block;height:auto;min-height:calc(var(--an-lh-row) + var(--an-space-4) + 2px);padding:var(--an-space-2);resize:none;overflow-y:auto;white-space:pre-wrap;overflow-wrap:anywhere}\n.dsh-an-settingHint{margin:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary)}\n.dsh-an-settingHintNote{margin-top:var(--an-space-1)}\n.dsh-an-settingBrand{display:flex;flex-direction:column;gap:2px;min-width:0}\n.dsh-an-settingBrandName{font-size:var(--an-fs-row);line-height:var(--an-lh-row);font-weight:500;color:var(--dsw-alias-label-primary)}\n.dsh-an-settingBrandTagline{font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}\n.dsh-an-settingAbout{display:flex;align-items:center;gap:var(--an-space-2);flex-wrap:wrap;min-width:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary)}\n.dsh-an-settingAbout>span{flex:none}\n.dsh-an-settingAbout .dsh-an-updateHint{flex:0 1 auto;min-width:0}\n.dsh-an-settingMetaRow{display:flex;align-items:baseline;gap:var(--an-space-1);min-width:0;overflow:hidden;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);white-space:nowrap}\n.dsh-an-settingMetaRow>span{flex:none}\n.dsh-an-settingDot{flex:none;color:var(--dsw-alias-label-tertiary)}\n.dsh-an-settingLink{flex:0 1 auto;min-width:0;overflow:hidden;color:var(--dsw-alias-link);font-weight:500;text-decoration:none;text-overflow:ellipsis;transition:var(--an-transition)}\n.dsh-an-settingLink:focus-visible{text-decoration:underline;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px}\n/* 更新中心:检查入口、可展开的更新说明与更新动作,全部走共享令牌 */\n.dsh-an-updateCheck{flex:none;height:24px;padding:0 var(--an-space-2);border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-updateCheck:active{background:var(--an-active)}\n.dsh-an-updateCheck:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}\n.dsh-an-updateCheck:focus-visible{outline-offset:2px}\n.dsh-an-updateHint{margin:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}\n.dsh-an-updateHintError{color:var(--dsw-alias-state-error-primary)}\n.dsh-an-updateCard{display:flex;flex-direction:column;gap:var(--an-space-2);margin-top:var(--an-space-1);padding:var(--an-space-2);border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1)}\n.dsh-an-updateTitle{font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;color:var(--dsw-alias-label-primary)}\n.dsh-an-updateFull:focus-visible,.dsh-an-updateLinkBtn:focus-visible{text-decoration:underline;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px}\n.dsh-an-updateFull{flex:none;color:var(--dsw-alias-link);font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;text-decoration:none;transition:var(--an-transition)}\n.dsh-an-updateNotes{display:flex;flex-direction:column;gap:var(--an-space-2);max-height:220px;overflow-y:auto;padding-right:0;overscroll-behavior:contain;--dsh-scrollbar-width:var(--dsh-an-scrollRail);--dsh-scrollbar-thumb-border:var(--dsh-an-scrollInset);scrollbar-gutter:stable}\n.dsh-an-updateNotes[data-fade=\"true\"]{--dsh-an-fadeHeight:var(--an-space-5);-webkit-mask-image:linear-gradient(to bottom,currentColor 0,currentColor calc(100% - var(--dsh-an-fadeHeight)),transparent 100%),linear-gradient(to right,transparent calc(100% - var(--dsh-an-scrollRail)),currentColor calc(100% - var(--dsh-an-scrollRail)));mask-image:linear-gradient(to bottom,currentColor 0,currentColor calc(100% - var(--dsh-an-fadeHeight)),transparent 100%),linear-gradient(to right,transparent calc(100% - var(--dsh-an-scrollRail)),currentColor calc(100% - var(--dsh-an-scrollRail)));-webkit-mask-composite:source-over;mask-composite:add}\n.dsh-an-updateVersions{display:flex;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-updateVersion{display:flex;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-updateVersion+.dsh-an-updateVersion{padding-top:var(--an-space-1);border-top:0.5px solid var(--an-divider)}\n.dsh-an-updateVersionHead{display:flex;align-items:center;gap:var(--an-space-1);width:100%;padding:2px 0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;text-align:left;cursor:pointer}\n.dsh-an-updateVersionHead:active{background:var(--an-active)}\n.dsh-an-updateVersionHead:focus-visible{text-decoration:underline;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px}\n.dsh-an-updateChevron{display:flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px;color:var(--dsw-alias-label-secondary);font-size:var(--an-fs-caption);transition:transform var(--an-dur-fast) var(--an-ease)}\n.dsh-an-updateChevron[data-open=\"true\"]{transform:rotate(90deg)}\n.dsh-an-updateVersionLabel{font-variant-numeric:tabular-nums}\n.dsh-an-updateLatest{display:inline-flex;align-items:center;justify-content:center;flex:none;min-width:18px;height:18px;padding:0 var(--an-space-1);border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary);font-size:var(--an-fs-caption);line-height:16px;font-weight:500}\n.dsh-an-updateVersionBody{display:flex;flex-direction:column;gap:var(--an-space-2);padding-left:var(--an-space-4);min-width:0}\n.dsh-an-updateGroup{display:flex;flex-direction:column;gap:var(--an-space-1);min-width:0}\n.dsh-an-updateGroupTitle{font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;color:var(--dsw-alias-label-secondary)}\n.dsh-an-updateItems{display:flex;flex-direction:column;gap:var(--an-space-1);margin:0;padding-left:var(--an-space-4);color:var(--dsw-alias-label-primary)}\n.dsh-an-updateItem{font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);overflow-wrap:anywhere}\n.dsh-an-updateItem strong{font-weight:500}\n.dsh-an-updateActions{display:flex;align-items:center;gap:var(--an-space-2);flex-wrap:wrap;min-width:0}\n.dsh-an-updatePrimary{display:inline-flex;align-items:center;justify-content:center;flex:none;height:24px;padding:0 var(--an-space-3);border:0;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-updatePrimary:active{background:var(--dsw-alias-button-primary-dimmed)}\n.dsh-an-updatePrimary:disabled{opacity:.55;cursor:default}\n.dsh-an-updatePrimary:focus-visible{outline-offset:2px}\n.dsh-an-updateDone{display:flex;align-items:center;gap:var(--an-space-2);flex-wrap:wrap;min-width:0}\n.dsh-an-updateErrorRow{display:flex;align-items:baseline;gap:var(--an-space-2);flex-wrap:wrap;min-width:0}\n.dsh-an-updateError{flex:1 1 auto;min-width:0;margin:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-state-error-primary);overflow-wrap:anywhere}\n.dsh-an-updateLinkBtn{padding:0;border:0;background:transparent;color:var(--dsw-alias-link);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer}\n.dsh-an-updateFallback{display:flex;align-items:center;gap:var(--an-space-2);flex-wrap:wrap;min-width:0;padding-top:var(--an-space-1);border-top:0.5px solid var(--an-divider)}\n.dsh-an-updateFallback .dsh-an-updateHint{flex:1 1 100%;min-width:0}\n.dsh-an-updateCopy{flex:none;height:24px;padding:0 var(--an-space-2);border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);font-weight:500;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-updateCopy:active{background:var(--an-active)}\n.dsh-an-updateCopy:focus-visible{outline-offset:2px}\n\n/* ── 11 面板脚注 · 存储状态就地提示,错误用状态色 ─────────────────── */\n.dsh-an-popFoot{margin:0;font-size:var(--an-fs-caption);line-height:var(--an-lh-caption);color:var(--dsw-alias-label-secondary)}\n.dsh-an-error{color:var(--dsw-alias-state-error-primary)}\n\n/* ── 12 会话顶部入口 · H28/R8,计数徽标为胶囊 ──────────────────────── */\n.dsh-an-headerBtn{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;transition:var(--an-transition)}\n.dsh-an-headerBtn:active{background:var(--an-active);color:var(--dsw-alias-label-primary)}\n.dsh-an-headerBtn[data-active=\"true\"]{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-headerBtn[data-disabled=\"true\"]{color:var(--dsw-alias-label-tertiary);cursor:not-allowed;pointer-events:none}\n.dsh-an-headerIcon{display:flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px;color:currentColor}\n.dsh-an-headerCount{position:absolute;top:-2px;right:-2px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 var(--an-space-1);border:0.5px solid var(--dsw-alias-bg-base);border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-secondary);font-size:var(--an-fs-caption);line-height:14px;font-weight:500;font-variant-numeric:tabular-nums}\n\n/* ── 13 拖拽把手 · 8px 命中带,3px 视觉条 ─────────────────────────── */\n.dsh-an-resizeHandle{position:absolute;left:0;top:0;bottom:0;z-index:2;display:flex;align-items:center;justify-content:center;width:var(--an-space-2);cursor:ew-resize;touch-action:none;outline:0}\n.dsh-an-resizeHandle::before{content:\"\";width:3px;height:var(--an-space-6);border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-border-l4);transition:transform var(--an-dur-fast) var(--an-ease),background-color var(--an-dur-fast) var(--an-ease)}\n.dsh-an-resizeHandle:focus-visible::before{background:var(--dsw-alias-label-secondary)}\n.dsh-an-resizeHandle:focus-visible{outline-offset:-2px;border-radius:var(--dsw-radius-sm)}\n.dsh-an-resizeHandleBottom{position:absolute;left:50%;bottom:0;z-index:2;display:flex;align-items:center;justify-content:center;width:var(--an-space-6);height:var(--an-space-3);transform:translateX(-50%);cursor:ns-resize;touch-action:none;outline:0}\n.dsh-an-resizeHandleBottom::before{content:\"\";width:var(--an-space-5);height:3px;border-radius:var(--an-radius-pill);corner-shape:round;background:var(--dsw-alias-border-l4);transition:transform var(--an-dur-fast) var(--an-ease),background-color var(--an-dur-fast) var(--an-ease)}\n.dsh-an-resizeHandleBottom:focus-visible::before{background:var(--dsw-alias-label-secondary)}\n.dsh-an-resizeHandleBottom:focus-visible{outline-offset:-2px;border-radius:var(--dsw-radius-sm)}\n\n/* ── 14 加载 · 控件内 12px 环,文字隐藏,不报\"进行中\" ──────────────── */\n[data-loading=\"true\"]{position:relative;color:transparent!important;pointer-events:none;cursor:progress}\n[data-loading=\"true\"]>*{visibility:hidden}\n[data-loading=\"true\"]::after{content:\"\";position:absolute;left:50%;top:50%;box-sizing:border-box;width:12px;height:12px;margin:-6px 0 0 -6px;border:1.5px solid var(--dsw-alias-label-secondary);border-top-color:transparent;border-radius:var(--an-radius-pill);corner-shape:round;animation:dsh-an-spin var(--an-dur-spin) linear infinite}\n\n/* ── 15 悬停 · 只在支持 hover 的设备上启用(触摸端常显操作) ────────── */\n@media (hover:hover){\n.dsh-an-row:hover{background:var(--an-hover)}\n.dsh-an-actions{opacity:0;pointer-events:none}\n.dsh-an-row:hover .dsh-an-actions,.dsh-an-row:focus-within .dsh-an-actions{opacity:1;pointer-events:auto}\n.dsh-an-iconBtn:hover{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-popClose:hover,.dsh-an-settingsBtn:hover{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-scopeBtn:hover:not([data-active=\"true\"]){background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-addBtn:hover:not([disabled]){background:var(--dsw-alias-button-primary-hover)}\n.dsh-an-mini:hover:not([disabled]){background:var(--an-hover)}\n.dsh-an-miniDanger:hover:not([disabled]){background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}\n.dsh-an-clear:hover{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-doneToggle:hover{background:var(--an-hover)}\n.dsh-an-check:hover .dsh-an-checkCircle{border-color:var(--dsw-alias-label-primary)}\n.dsh-an-settingChoice:hover input{border-color:var(--dsw-alias-label-primary)}\n.dsh-an-settingLink:hover{text-decoration:underline;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px}\n.dsh-an-updatePrimary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}\n.dsh-an-headerBtn:hover{background:var(--an-hover);color:var(--dsw-alias-label-primary)}\n.dsh-an-resizeHandle:hover::before{transform:scaleY(1.4);background:var(--dsw-alias-label-secondary)}\n.dsh-an-resizeHandleBottom:hover::before{transform:scaleX(1.4);background:var(--dsw-alias-label-secondary)}\n}\n\n/* ── 16 动效 · 只动 opacity/transform,错峰出场封顶 ─────────────────── */\n@media (prefers-reduced-motion:no-preference){\n.dsh-an-rows>.dsh-an-row{animation:dsh-an-row-in var(--an-dur-base) var(--an-ease) both}\n.dsh-an-rows>.dsh-an-row:nth-child(2){animation-delay:var(--an-space-1)}\n.dsh-an-rows>.dsh-an-row:nth-child(3){animation-delay:var(--an-space-2)}\n.dsh-an-rows>.dsh-an-row:nth-child(4){animation-delay:calc(var(--an-space-2) + var(--an-space-1))}\n.dsh-an-rows>.dsh-an-row:nth-child(n+5){animation-delay:var(--an-space-3)}\n}\n@keyframes dsh-an-pop-in{from{opacity:0}to{opacity:1}}\n@keyframes dsh-an-row-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}\n@keyframes dsh-an-spin{to{transform:rotate(360deg)}}\n@media (prefers-reduced-motion:reduce){\n.dsh-an-popover,.dsh-an-rows>.dsh-an-row,.dsh-an-chevron,[data-loading=\"true\"]::after{animation:none}\n.dsh-an-popover,.dsh-an-row,.dsh-an-actions,.dsh-an-iconBtn{transition-duration:1ms}\n}\n\n/* ── 17 窄视口 · 390 基准下收紧内边距,主操作全部可达 ──────────────── */\n@media (max-width:480px){\n.dsh-an-popover{padding:var(--an-space-3);--dsh-an-listGutter:var(--an-space-3)}\n.dsh-an-popoverRight{padding-left:var(--an-space-4)}\n.dsh-an-popHead{gap:var(--an-space-2)}\n.dsh-an-add{padding:var(--an-space-2) var(--an-space-3)}\n.dsh-an-sectionHead,.dsh-an-doneHead{min-height:24px}\n}\n\n";
41
+
42
+ // src/client/constants.ts
43
+ /**
44
+ * Plugin identity, storage keys, limits and platform helpers.
45
+ *
46
+ * Everything whose value is part of the on-disk contract lives here; the
47
+ * storage modules and the panel import it instead of repeating literals.
48
+ */
49
+ /** Locale namespace of this plugin's copy (also binds the renderer's `t` prop). */
50
+ const NS = "dsh-sideby-note";
51
+ /** Sidebar launcher id and the main panel key it addresses. */
52
+ const PANEL_ID = "dsh-sideby-note";
53
+ /** Session-scoped memo store used by the popover and the session-header entry. */
54
+ const SESSION_STORAGE_KEY = "dsh.aside-note";
55
+ /** Notes shared by every session of one workspace; kept beside the session key. */
56
+ const WORKSPACE_STORAGE_KEY = "dsh.aside-note.workspaces";
57
+ /** Unsaved add/edit drafts, restored when the panel is reopened. */
58
+ const DRAFT_STORAGE_KEY = "dsh.aside-note.drafts";
59
+ /** Notes already forwarded to the composer, per session; marks the forward button. */
60
+ const FORWARDED_STORAGE_KEY = "dsh.aside-note.forwarded";
61
+ /** Shown in the in-panel settings; keep in sync with package.json. */
62
+ const PLUGIN_VERSION = "0.1.0";
63
+ const PLUGIN_AUTHOR = "阿三石";
64
+ const PLUGIN_REPO_URL = "https://github.com/LighghtEeloo/dsh-sideby-note";
65
+ const PLUGIN_REPO_LABEL = "github.com/LighghtEeloo/dsh-sideby-note";
66
+ /** Send preference; persisted across panel openings. Enter sends by default. */
67
+ const SEND_SHORTCUT_KEY = "dsh.aside-note.send-shortcut";
68
+ /** Lead-in written before a forwarded note; empty means no prefix. */
69
+ const FORWARD_PREFIX_STORAGE_KEY = "dsh.aside-note.forward-prefix";
70
+ const SEND_SHORTCUT_DEFAULT = "enter";
71
+ /** macOS names the command modifier with a symbol; other platforms say Ctrl. */
72
+ const IS_MAC = (() => {
73
+ try {
74
+ const platform = navigator.userAgentData && navigator.userAgentData.platform || navigator.platform || "";
75
+ return /mac/i.test(String(platform));
76
+ } catch {
77
+ return false;
78
+ }
79
+ })();
80
+ const MOD_LABEL = IS_MAC ? "⌘" : "Ctrl";
81
+ /** Whether the key event carries this platform's command modifier. */
82
+ function isSendModifier(event) {
83
+ return IS_MAC ? event.metaKey === true : event.ctrlKey === true;
84
+ }
85
+ /** Last chosen list scope: the workspace list or the session list. */
86
+ const SCOPE_MODE_KEY = "dsh.aside-note.scope-mode";
87
+ const SCOPE_MODE_DEFAULT = "workspace";
88
+ /** Remembered expand/collapse state of the open/completed sections. */
89
+ const SECTION_STATE_KEY = "dsh.aside-note.sections";
90
+ const SECTION_STATE_DEFAULT = {
91
+ open: true,
92
+ done: false
93
+ };
94
+ /** How long the inline clear-completed confirmation waits before it dismisses itself. */
95
+ const CLEAR_CONFIRM_MS = 5e3;
96
+ /** Persisted width of the experimental right-side panel. */
97
+ const PANEL_WIDTH_KEY = "dsh.aside-note.panel-width";
98
+ /** Persisted height of the experimental right-side panel; 0 means content-sized. */
99
+ const PANEL_HEIGHT_KEY = "dsh.aside-note.panel-height";
100
+
101
+ // src/client/i18n/de.ts
102
+ /** German copy; a missing key fails the typecheck rather than falling back at runtime. */
103
+ const de = {
104
+ "nav.label": "Sideby Note",
105
+ "title": "Sideby Note",
106
+ "popover.title": "Sideby Note",
107
+ "popover.close": "Sideby Note schließen",
108
+ "popover.count": "{open} offen · {total} gesamt",
109
+ "popover.completed": "Erledigt",
110
+ "popover.clearCancel": "Abbrechen",
111
+ "popover.clearConfirm": "{n} erledigte Notizen löschen?",
112
+ "popover.clearConfirmAction": "Löschen",
113
+ "popover.clearDone": "Erledigte löschen",
114
+ "popover.local": "Notizen werden nur auf diesem Gerät gespeichert",
115
+ "scope.label": "Notizbereich",
116
+ "scope.workspace": "Arbeitsbereich",
117
+ "scope.session": "Sitzung",
118
+ "scope.workspaceHint": "Zur Liste des Arbeitsbereichs wechseln, die alle Sitzungen teilen",
119
+ "scope.sessionHint": "Zur Sitzungsliste wechseln, die nur in dieser Sitzung sichtbar ist",
120
+ "scope.newSessionHint": "Vorerst ist nur die Liste des Arbeitsbereichs verfügbar; die Sitzungsliste erscheint, sobald die Sitzung beginnt",
121
+ "popover.empty.title": "Noch keine Notizen",
122
+ "popover.empty.body": "Ideen entwerfen, während der Agent arbeitet",
123
+ "settings.open": "Einstellungen",
124
+ "settings.title": "Einstellungen",
125
+ "settings.about": "Info",
126
+ "settings.tagline": "Ideen entwerfen, während der Agent arbeitet.",
127
+ "settings.version": "Version",
128
+ "settings.author": "Autor",
129
+ "settings.project": "Quellcode",
130
+ "settings.shortcut": "Sende-Tastenkürzel",
131
+ "settings.shortcutCtrlEnter": "{mod}+Enter sendet, Enter für eine neue Zeile",
132
+ "settings.shortcutEnter": "Enter sendet, {mod}+Enter für eine neue Zeile",
133
+ "settings.forward": "Ein-Klick-Weiterleitung",
134
+ "settings.forwardPrefixItem": "Präfix-Prompt",
135
+ "settings.forwardPrefixHint": "Beim Weiterleiten in ein leeres Eingabefeld wird dieser Prompt vor der Notiz eingefügt; leer lassen, um nur die Notiz weiterzuleiten",
136
+ "add.placeholder": "Eine notieren",
137
+ "add.shortcut": "{mod}+Enter sendet · Enter für eine neue Zeile",
138
+ "add.shortcutEnter": "Enter sendet · {mod}+Enter für eine neue Zeile",
139
+ "add.action": "Hinzufügen",
140
+ "list.open": "Offen",
141
+ "list.allDone.title": "Nichts mehr offen",
142
+ "list.allDone.body": "Weitere Notiz hinzufügen oder unten die erledigten aufklappen, um zurückzublicken",
143
+ "item.markDone": "Als erledigt markieren",
144
+ "item.markOpen": "Als offen markieren",
145
+ "item.copy": "Kopieren",
146
+ "item.forward": "An Chat weiterleiten",
147
+ "item.forwarded": "An Chat weitergeleitet — klicken, um die Markierung zu entfernen",
148
+ "item.recall": "Zurückholen",
149
+ "time.now": "gerade eben",
150
+ "time.minutes": "vor {n} Min.",
151
+ "time.hours": "vor {n} Std.",
152
+ "time.days": "vor {n} T.",
153
+ "time.createdDone": "Erstellt {created} · Erledigt {completed}",
154
+ "storage.failed": "Lokaler Speicher ist nicht verfügbar; Änderungen werden möglicherweise nicht gespeichert",
155
+ "forward.prefix": "Diese Aufgabe erledigen:",
156
+ "resize.width": "Breite von Sideby Note ändern",
157
+ "resize.height": "Höhe von Sideby Note ändern",
158
+ "resize.hint": "Zum Ändern ziehen, zum Zurücksetzen doppelklicken",
159
+ "dock.open": "Sideby Note öffnen",
160
+ "dock.count": "{n} offen",
161
+ "header.tooltip": "Sideby Note · {n} offen",
162
+ "header.tooltipEmpty": "Sideby Note",
163
+ "toast.copied": "Kopiert",
164
+ "toast.copyFailed": "Kopieren fehlgeschlagen — erneut versuchen",
165
+ "toast.forwarded": "An Chat weitergeleitet",
166
+ "toast.unforwarded": "Weiterleitungsmarkierung entfernt",
167
+ "toast.forwardFailed": "Kein Eingabefeld gefunden — nichts weitergeleitet",
168
+ "toast.recalled": "Zurück in das Eingabefeld geholt",
169
+ "toast.recallBlocked": "Im Eingabefeld steht bereits Text – zuerst senden oder leeren",
170
+ "toast.cleared": "Erledigte gelöscht",
171
+ "toast.saveFailed": "Speichern fehlgeschlagen — nichts geändert",
172
+ "update.label": "Update verfügbar",
173
+ "update.tip": "Version {version} ist jetzt verfügbar — Versionshinweise öffnen",
174
+ "update.check": "Nach Updates suchen",
175
+ "update.checking": "Prüfen…",
176
+ "update.retryCheck": "Prüfung wiederholen",
177
+ "update.current": "Sie sind auf dem neuesten Stand",
178
+ "update.checkFailed": "Prüfung fehlgeschlagen — später erneut versuchen",
179
+ "update.available": "Version {version} ist verfügbar",
180
+ "update.notesTitle": "Versionshinweise",
181
+ "update.notesLoading": "Versionshinweise werden geladen…",
182
+ "update.notesMissing": "Für diese Version gibt es noch keine Versionshinweise",
183
+ "update.historyCount": "{n} Versionen enthalten",
184
+ "update.latest": "Neueste",
185
+ "update.olderNotes": "Frühere Versionen stehen in den vollständigen Versionshinweisen",
186
+ "update.notesFailed": "Versionshinweise konnten nicht geladen werden — vollständige Hinweise öffnen",
187
+ "update.full": "Vollständige Versionshinweise",
188
+ "update.now": "Jetzt aktualisieren",
189
+ "update.starting": "Update wird vorbereitet…",
190
+ "update.updating": "Wird aktualisiert…",
191
+ "update.updated": "Auf {version} aktualisiert",
192
+ "update.refresh": "Seite neu laden",
193
+ "update.restartHint": "DSH manuell neu starten, um das Update abzuschließen",
194
+ "update.failed": "Update fehlgeschlagen: {reason}",
195
+ "update.notInstalled": "Dieses Plugin ist im aktuellen Profil nicht installiert und kann daher nicht in der App aktualisiert werden",
196
+ "update.forbidden": "Das automatische Update hat diese Anfrage abgelehnt",
197
+ "update.rejected": "Das automatische Update wurde nicht ausgeführt; ein verlinkter Checkout aktualisiert sich aus seinem eigenen Verzeichnis",
198
+ "update.busy": "Ein anderes Update läuft bereits — gleich erneut versuchen",
199
+ "update.timeout": "Zeitüberschreitung beim Warten auf das Update-Ergebnis — später erneut versuchen",
200
+ "update.bundleInUse": "Dieses Plugin wird verwendet und Desktop entfernt es nicht zuerst; die Host-Route installiert darüber — falls das weiterhin fehlschlägt, den Befehl unten ausführen",
201
+ "update.alreadyInstalled": "Dieses DSH ersetzt ein Paket erst nach dem Entfernen, daher kann es nicht über die aktuelle Kopie installieren; den Befehl unten ausführen",
202
+ "update.managementRequired": "Dieses Profil wird von der Desktop-App verwaltet, das automatische Update kann es nicht ändern; den Befehl unten ausführen",
203
+ "update.notRemovable": "Die Desktop-App verwaltet dieses Plugin und das automatische Update kann es nicht entfernen; den Befehl unten ausführen",
204
+ "update.stopProfile": "Zum Entfernen muss dieses Profil zuerst gestoppt werden; den Befehl unten ausführen",
205
+ "update.incompatible": "Diese Version ist nicht mit dem laufenden DSH kompatibel, daher hat der Host sie abgelehnt",
206
+ "update.versionMismatch": "Die installierte Version ist nicht die angeforderte — ein Spiegel oder die Altersgrenze für Releases hat sie möglicherweise ersetzt; später erneut versuchen oder manuell installieren",
207
+ "update.downgrade": "Abgelehnt: Die Zielversion ist älter als die installierte",
208
+ "update.autoUnavailable": "Dieser Host bietet keine automatische Update-Route; den Befehl unten ausführen",
209
+ "update.manualHint": "Oder direkt aktualisieren: {command} in einem Terminal ausführen oder auf der Plugins-Seite aktualisieren und dann neu laden",
210
+ "update.copyPrompt": "Update-Prompt kopieren",
211
+ "update.prompt": "Aktualisiere das DSH-Plugin Sideby Note auf {version} mit: {command}. Lade die Seite neu, wenn es fertig ist."
212
+ };
213
+
214
+ // src/client/i18n/en.ts
215
+ /** English copy; a missing key fails the typecheck rather than falling back at runtime. */
216
+ const en = {
217
+ "nav.label": "Sideby Note",
218
+ "title": "Sideby Note",
219
+ "popover.title": "Sideby Note",
220
+ "popover.close": "Close Sideby Note",
221
+ "popover.count": "{open} open · {total} total",
222
+ "popover.completed": "Completed",
223
+ "popover.clearCancel": "Cancel",
224
+ "popover.clearConfirm": "Clear {n} completed notes?",
225
+ "popover.clearConfirmAction": "Clear",
226
+ "popover.clearDone": "Clear completed",
227
+ "popover.local": "Notes are saved only on this device",
228
+ "scope.label": "Note scope",
229
+ "scope.workspace": "Workspace",
230
+ "scope.session": "Session",
231
+ "scope.workspaceHint": "Switch to the workspace list, shared by all sessions",
232
+ "scope.sessionHint": "Switch to the session list, visible only in this session",
233
+ "scope.newSessionHint": "Only the workspace list is available for now; the session list appears once the session starts",
234
+ "popover.empty.title": "No notes yet",
235
+ "popover.empty.body": "Asynchronously draft your ideas while the agent is working",
236
+ "settings.open": "Settings",
237
+ "settings.title": "Settings",
238
+ "settings.about": "About",
239
+ "settings.tagline": "Asynchronously draft your ideas while the agent is working.",
240
+ "settings.version": "Version",
241
+ "settings.author": "Author",
242
+ "settings.project": "Source",
243
+ "settings.shortcut": "Send shortcut",
244
+ "settings.shortcutCtrlEnter": "{mod}+Enter sends, Enter for a new line",
245
+ "settings.shortcutEnter": "Enter sends, {mod}+Enter for a new line",
246
+ "settings.forward": "One-click forward",
247
+ "settings.forwardPrefixItem": "Prefix prompt",
248
+ "settings.forwardPrefixHint": "When forwarding into an empty composer, this prompt is written before the note; leave it empty to forward the note on its own",
249
+ "add.placeholder": "Jot one down",
250
+ "add.shortcut": "{mod}+Enter sends · Enter for a new line",
251
+ "add.shortcutEnter": "Enter sends · {mod}+Enter for a new line",
252
+ "add.action": "Add",
253
+ "list.open": "Open",
254
+ "list.allDone.title": "Nothing left open",
255
+ "list.allDone.body": "Add another note, or expand completed below to look back",
256
+ "item.markDone": "Mark as done",
257
+ "item.markOpen": "Mark as open",
258
+ "item.copy": "Copy",
259
+ "item.forward": "Forward to chat",
260
+ "item.forwarded": "Forwarded to chat — click to remove the mark",
261
+ "item.recall": "Rewind",
262
+ "time.now": "just now",
263
+ "time.minutes": "{n} min ago",
264
+ "time.hours": "{n} hr ago",
265
+ "time.days": "{n} d ago",
266
+ "time.createdDone": "Created {created} · Completed {completed}",
267
+ "storage.failed": "Local storage is unavailable; changes may not persist",
268
+ "forward.prefix": "Complete this task:",
269
+ "resize.width": "Resize Sideby Note width",
270
+ "resize.height": "Resize Sideby Note height",
271
+ "resize.hint": "Drag to resize, double-click to reset",
272
+ "dock.open": "Open Sideby Note",
273
+ "dock.count": "{n} open",
274
+ "header.tooltip": "Sideby Note · {n} open",
275
+ "header.tooltipEmpty": "Sideby Note",
276
+ "toast.copied": "Copied",
277
+ "toast.copyFailed": "Copy failed — try again",
278
+ "toast.forwarded": "Forwarded to chat",
279
+ "toast.unforwarded": "Forward mark removed",
280
+ "toast.forwardFailed": "No composer found — nothing was forwarded",
281
+ "toast.recalled": "Moved back to the input",
282
+ "toast.recallBlocked": "The input already has text — send or clear it first",
283
+ "toast.cleared": "Cleared completed",
284
+ "toast.saveFailed": "Save failed — nothing changed",
285
+ "update.label": "Update available",
286
+ "update.tip": "Version {version} is now available — open the release notes",
287
+ "update.check": "Check for updates",
288
+ "update.checking": "Checking…",
289
+ "update.retryCheck": "Retry check",
290
+ "update.current": "You're up to date",
291
+ "update.checkFailed": "Check failed — try again later",
292
+ "update.available": "Version {version} is available",
293
+ "update.notesTitle": "Release notes",
294
+ "update.notesLoading": "Loading release notes…",
295
+ "update.notesMissing": "No release notes to show for this version yet",
296
+ "update.historyCount": "{n} releases included",
297
+ "update.latest": "Latest",
298
+ "update.olderNotes": "Earlier releases are in the full release notes",
299
+ "update.notesFailed": "Could not load the release notes — open the full notes",
300
+ "update.full": "Full release notes",
301
+ "update.now": "Update now",
302
+ "update.starting": "Preparing the update…",
303
+ "update.updating": "Updating…",
304
+ "update.updated": "Updated to {version}",
305
+ "update.refresh": "Refresh page",
306
+ "update.restartHint": "Restart DSH manually to finish the update",
307
+ "update.failed": "Update failed: {reason}",
308
+ "update.notInstalled": "This plugin is not installed in the current profile, so it cannot be updated in-app",
309
+ "update.forbidden": "The automatic update refused this request",
310
+ "update.rejected": "The automatic update did not run; a linked checkout updates from its own directory",
311
+ "update.busy": "Another update is already running — try again shortly",
312
+ "update.timeout": "Timed out waiting for the update result — try again later",
313
+ "update.bundleInUse": "This plugin is in use, and Desktop will not remove it first; the host route installs over it — if that still fails, run the command below",
314
+ "update.alreadyInstalled": "This DSH only replaces a package after removing it, so it cannot install over the current copy; run the command below",
315
+ "update.managementRequired": "This profile is managed by the desktop app, so the automatic update cannot change it; run the command below",
316
+ "update.notRemovable": "The desktop app manages this plugin and the automatic update cannot remove it; run the command below",
317
+ "update.stopProfile": "Removing it requires stopping this profile first; run the command below",
318
+ "update.incompatible": "This version is not compatible with the running DSH, so the host refused it",
319
+ "update.versionMismatch": "The installed version is not the one requested — a mirror or the release-age hold may have substituted it; retry later or install manually",
320
+ "update.downgrade": "Refused: the target version is older than the installed one",
321
+ "update.autoUnavailable": "This host offers no automatic update route; run the command below",
322
+ "update.manualHint": "Or update directly: run {command} in a terminal, or update from the Plugins page, then reload",
323
+ "update.copyPrompt": "Copy update prompt",
324
+ "update.prompt": "Update the DSH plugin Sideby Note to {version} by running: {command}. Reload the page when it finishes."
325
+ };
326
+
327
+ // src/client/i18n/es.ts
328
+ /** Spanish copy; a missing key fails the typecheck rather than falling back at runtime. */
329
+ const es = {
330
+ "nav.label": "Sideby Note",
331
+ "title": "Sideby Note",
332
+ "popover.title": "Sideby Note",
333
+ "popover.close": "Cerrar Sideby Note",
334
+ "popover.count": "{open} abiertas · {total} en total",
335
+ "popover.completed": "Completadas",
336
+ "popover.clearCancel": "Cancelar",
337
+ "popover.clearConfirm": "¿Borrar {n} notas completadas?",
338
+ "popover.clearConfirmAction": "Borrar",
339
+ "popover.clearDone": "Borrar completadas",
340
+ "popover.local": "Las notas se guardan solo en este dispositivo",
341
+ "scope.label": "Ámbito de las notas",
342
+ "scope.workspace": "Espacio de trabajo",
343
+ "scope.session": "Sesión",
344
+ "scope.workspaceHint": "Cambiar a la lista del espacio de trabajo, compartida por todas las sesiones",
345
+ "scope.sessionHint": "Cambiar a la lista de la sesión, visible solo en esta sesión",
346
+ "scope.newSessionHint": "Por ahora solo está disponible la lista del espacio de trabajo; la lista de la sesión aparecerá cuando se inicie la sesión",
347
+ "popover.empty.title": "Aún no hay notas",
348
+ "popover.empty.body": "Esboza tus ideas de forma asíncrona mientras el agente trabaja",
349
+ "settings.open": "Ajustes",
350
+ "settings.title": "Ajustes",
351
+ "settings.about": "Acerca de",
352
+ "settings.tagline": "Esboza tus ideas de forma asíncrona mientras el agente trabaja.",
353
+ "settings.version": "Versión",
354
+ "settings.author": "Autor",
355
+ "settings.project": "Código fuente",
356
+ "settings.shortcut": "Atajo de envío",
357
+ "settings.shortcutCtrlEnter": "{mod}+Intro envía, Intro para una nueva línea",
358
+ "settings.shortcutEnter": "Intro envía, {mod}+Intro para una nueva línea",
359
+ "settings.forward": "Reenvío con un clic",
360
+ "settings.forwardPrefixItem": "Indicación de prefijo",
361
+ "settings.forwardPrefixHint": "Al reenviar a un cuadro de texto vacío, esta indicación se escribe antes de la nota; déjala vacía para reenviar solo la nota",
362
+ "add.placeholder": "Anota una",
363
+ "add.shortcut": "{mod}+Intro envía · Intro para una nueva línea",
364
+ "add.shortcutEnter": "Intro envía · {mod}+Intro para una nueva línea",
365
+ "add.action": "Añadir",
366
+ "list.open": "Abiertas",
367
+ "list.allDone.title": "No queda nada abierto",
368
+ "list.allDone.body": "Añade otra nota o despliega las completadas para revisarlas",
369
+ "item.markDone": "Marcar como completada",
370
+ "item.markOpen": "Marcar como abierta",
371
+ "item.copy": "Copiar",
372
+ "item.forward": "Reenviar al chat",
373
+ "item.forwarded": "Reenviada al chat — haz clic para quitar la marca",
374
+ "item.recall": "Devolver",
375
+ "time.now": "ahora mismo",
376
+ "time.minutes": "hace {n} min",
377
+ "time.hours": "hace {n} h",
378
+ "time.days": "hace {n} d",
379
+ "time.createdDone": "Creada {created} · Completada {completed}",
380
+ "storage.failed": "El almacenamiento local no está disponible; es posible que los cambios no se guarden",
381
+ "forward.prefix": "Completa esta tarea:",
382
+ "resize.width": "Cambiar el ancho de Sideby Note",
383
+ "resize.height": "Cambiar la altura de Sideby Note",
384
+ "resize.hint": "Arrastra para cambiar el tamaño, doble clic para restablecer",
385
+ "dock.open": "Abrir Sideby Note",
386
+ "dock.count": "{n} abiertas",
387
+ "header.tooltip": "Sideby Note · {n} abiertas",
388
+ "header.tooltipEmpty": "Sideby Note",
389
+ "toast.copied": "Copiado",
390
+ "toast.copyFailed": "Error al copiar — inténtalo de nuevo",
391
+ "toast.forwarded": "Reenviada al chat",
392
+ "toast.unforwarded": "Marca de reenvío eliminada",
393
+ "toast.forwardFailed": "No se encontró el cuadro de texto — no se reenvió nada",
394
+ "toast.recalled": "Devuelta al cuadro de texto",
395
+ "toast.recallBlocked": "El cuadro de texto ya tiene contenido; envíalo o bórralo primero",
396
+ "toast.cleared": "Completadas borradas",
397
+ "toast.saveFailed": "Error al guardar — nada cambió",
398
+ "update.label": "Actualización disponible",
399
+ "update.tip": "La versión {version} ya está disponible — abre las notas de la versión",
400
+ "update.check": "Buscar actualizaciones",
401
+ "update.checking": "Comprobando…",
402
+ "update.retryCheck": "Reintentar comprobación",
403
+ "update.current": "Estás al día",
404
+ "update.checkFailed": "Error en la comprobación — inténtalo más tarde",
405
+ "update.available": "La versión {version} está disponible",
406
+ "update.notesTitle": "Notas de la versión",
407
+ "update.notesLoading": "Cargando notas de la versión…",
408
+ "update.notesMissing": "Aún no hay notas de la versión para esta versión",
409
+ "update.historyCount": "{n} versiones incluidas",
410
+ "update.latest": "Más reciente",
411
+ "update.olderNotes": "Las versiones anteriores están en las notas completas",
412
+ "update.notesFailed": "No se pudieron cargar las notas de la versión — abre las notas completas",
413
+ "update.full": "Notas completas de la versión",
414
+ "update.now": "Actualizar ahora",
415
+ "update.starting": "Preparando la actualización…",
416
+ "update.updating": "Actualizando…",
417
+ "update.updated": "Actualizado a {version}",
418
+ "update.refresh": "Recargar página",
419
+ "update.restartHint": "Reinicia DSH manualmente para finalizar la actualización",
420
+ "update.failed": "Error en la actualización: {reason}",
421
+ "update.notInstalled": "Este complemento no está instalado en el perfil actual, por lo que no se puede actualizar desde la aplicación",
422
+ "update.forbidden": "La actualización automática rechazó esta solicitud",
423
+ "update.rejected": "La actualización automática no se ejecutó; una copia vinculada se actualiza desde su propio directorio",
424
+ "update.busy": "Ya hay otra actualización en curso — inténtalo de nuevo en breve",
425
+ "update.timeout": "Se agotó el tiempo de espera del resultado — inténtalo más tarde",
426
+ "update.bundleInUse": "Este complemento está en uso y Desktop no lo eliminará primero; la ruta del host instala encima — si sigue fallando, ejecuta el comando de abajo",
427
+ "update.alreadyInstalled": "Este DSH solo reemplaza un paquete tras eliminarlo, así que no puede instalar sobre la copia actual; ejecuta el comando de abajo",
428
+ "update.managementRequired": "La aplicación de escritorio gestiona este perfil, así que la actualización automática no puede cambiarlo; ejecuta el comando de abajo",
429
+ "update.notRemovable": "La aplicación de escritorio gestiona este complemento y la actualización automática no puede eliminarlo; ejecuta el comando de abajo",
430
+ "update.stopProfile": "Para eliminarlo primero hay que detener este perfil; ejecuta el comando de abajo",
431
+ "update.incompatible": "Esta versión no es compatible con el DSH en ejecución, así que el host la rechazó",
432
+ "update.versionMismatch": "La versión instalada no es la solicitada — un espejo o la retención por antigüedad de la versión puede haberla sustituido; reinténtalo más tarde o instala manualmente",
433
+ "update.downgrade": "Rechazado: la versión de destino es anterior a la instalada",
434
+ "update.autoUnavailable": "Este host no ofrece una ruta de actualización automática; ejecuta el comando de abajo",
435
+ "update.manualHint": "O actualiza directamente: ejecuta {command} en un terminal, o actualiza desde la página de Complementos y recarga",
436
+ "update.copyPrompt": "Copiar prompt de actualización",
437
+ "update.prompt": "Actualiza el complemento DSH Sideby Note a {version} ejecutando: {command}. Recarga la página cuando termine."
438
+ };
439
+
440
+ // src/client/i18n/fr.ts
441
+ /** French copy; a missing key fails the typecheck rather than falling back at runtime. */
442
+ const fr = {
443
+ "nav.label": "Sideby Note",
444
+ "title": "Sideby Note",
445
+ "popover.title": "Sideby Note",
446
+ "popover.close": "Fermer Sideby Note",
447
+ "popover.count": "{open} ouvertes · {total} au total",
448
+ "popover.completed": "Terminées",
449
+ "popover.clearCancel": "Annuler",
450
+ "popover.clearConfirm": "Effacer {n} notes terminées ?",
451
+ "popover.clearConfirmAction": "Effacer",
452
+ "popover.clearDone": "Effacer les terminées",
453
+ "popover.local": "Les notes sont enregistrées uniquement sur cet appareil",
454
+ "scope.label": "Portée des notes",
455
+ "scope.workspace": "Espace de travail",
456
+ "scope.session": "Session",
457
+ "scope.workspaceHint": "Passer à la liste de l'espace de travail, partagée par toutes les sessions",
458
+ "scope.sessionHint": "Passer à la liste de la session, visible uniquement dans cette session",
459
+ "scope.newSessionHint": "Seule la liste de l'espace de travail est disponible pour l'instant ; la liste de la session apparaîtra au démarrage de la session",
460
+ "popover.empty.title": "Aucune note pour l'instant",
461
+ "popover.empty.body": "Rédigez vos idées de façon asynchrone pendant que l'agent travaille",
462
+ "settings.open": "Paramètres",
463
+ "settings.title": "Paramètres",
464
+ "settings.about": "À propos",
465
+ "settings.tagline": "Rédigez vos idées de façon asynchrone pendant que l'agent travaille.",
466
+ "settings.version": "Version",
467
+ "settings.author": "Auteur",
468
+ "settings.project": "Source",
469
+ "settings.shortcut": "Raccourci d'envoi",
470
+ "settings.shortcutCtrlEnter": "{mod}+Entrée envoie, Entrée pour un saut de ligne",
471
+ "settings.shortcutEnter": "Entrée envoie, {mod}+Entrée pour un saut de ligne",
472
+ "settings.forward": "Transfert en un clic",
473
+ "settings.forwardPrefixItem": "Invite de préfixe",
474
+ "settings.forwardPrefixHint": "Lors d'un transfert vers une zone de saisie vide, cette invite est écrite avant la note ; laissez-la vide pour transférer uniquement la note",
475
+ "add.placeholder": "Notez-en une",
476
+ "add.shortcut": "{mod}+Entrée envoie · Entrée pour un saut de ligne",
477
+ "add.shortcutEnter": "Entrée envoie · {mod}+Entrée pour un saut de ligne",
478
+ "add.action": "Ajouter",
479
+ "list.open": "Ouvertes",
480
+ "list.allDone.title": "Plus rien d'ouvert",
481
+ "list.allDone.body": "Ajoutez une autre note ou dépliez les notes terminées ci-dessous pour les revoir",
482
+ "item.markDone": "Marquer comme terminée",
483
+ "item.markOpen": "Marquer comme ouverte",
484
+ "item.copy": "Copier",
485
+ "item.forward": "Transférer vers le chat",
486
+ "item.forwarded": "Transférée vers le chat — cliquez pour retirer la marque",
487
+ "item.recall": "Renvoyer",
488
+ "time.now": "à l'instant",
489
+ "time.minutes": "il y a {n} min",
490
+ "time.hours": "il y a {n} h",
491
+ "time.days": "il y a {n} j",
492
+ "time.createdDone": "Créée {created} · Terminée {completed}",
493
+ "storage.failed": "Le stockage local n'est pas disponible ; les modifications peuvent ne pas être conservées",
494
+ "forward.prefix": "Terminez cette tâche :",
495
+ "resize.width": "Redimensionner la largeur d'Sideby Note",
496
+ "resize.height": "Redimensionner la hauteur d'Sideby Note",
497
+ "resize.hint": "Faites glisser pour redimensionner, double-cliquez pour réinitialiser",
498
+ "dock.open": "Ouvrir Sideby Note",
499
+ "dock.count": "{n} ouvertes",
500
+ "header.tooltip": "Sideby Note · {n} ouvertes",
501
+ "header.tooltipEmpty": "Sideby Note",
502
+ "toast.copied": "Copié",
503
+ "toast.copyFailed": "Échec de la copie — réessayez",
504
+ "toast.forwarded": "Transférée vers le chat",
505
+ "toast.unforwarded": "Marque de transfert retirée",
506
+ "toast.forwardFailed": "Aucune zone de saisie trouvée — rien n'a été transféré",
507
+ "toast.recalled": "Renvoyée dans la zone de saisie",
508
+ "toast.recallBlocked": "La zone de saisie contient déjà du texte ; envoyez-le ou effacez-le d'abord",
509
+ "toast.cleared": "Notes terminées effacées",
510
+ "toast.saveFailed": "Échec de l'enregistrement — rien n'a changé",
511
+ "update.label": "Mise à jour disponible",
512
+ "update.tip": "La version {version} est disponible — ouvrez les notes de version",
513
+ "update.check": "Rechercher des mises à jour",
514
+ "update.checking": "Vérification…",
515
+ "update.retryCheck": "Réessayer la vérification",
516
+ "update.current": "Vous êtes à jour",
517
+ "update.checkFailed": "Échec de la vérification — réessayez plus tard",
518
+ "update.available": "La version {version} est disponible",
519
+ "update.notesTitle": "Notes de version",
520
+ "update.notesLoading": "Chargement des notes de version…",
521
+ "update.notesMissing": "Aucune note de version à afficher pour le moment",
522
+ "update.historyCount": "{n} versions incluses",
523
+ "update.latest": "Dernière",
524
+ "update.olderNotes": "Les versions précédentes figurent dans les notes complètes",
525
+ "update.notesFailed": "Impossible de charger les notes de version — ouvrez les notes complètes",
526
+ "update.full": "Notes de version complètes",
527
+ "update.now": "Mettre à jour maintenant",
528
+ "update.starting": "Préparation de la mise à jour…",
529
+ "update.updating": "Mise à jour…",
530
+ "update.updated": "Mis à jour vers {version}",
531
+ "update.refresh": "Actualiser la page",
532
+ "update.restartHint": "Redémarrez DSH manuellement pour terminer la mise à jour",
533
+ "update.failed": "Échec de la mise à jour : {reason}",
534
+ "update.notInstalled": "Ce plugin n'est pas installé dans le profil actuel, il ne peut donc pas être mis à jour depuis l'application",
535
+ "update.forbidden": "La mise à jour automatique a refusé cette demande",
536
+ "update.rejected": "La mise à jour automatique ne s'est pas exécutée ; un checkout lié se met à jour depuis son propre répertoire",
537
+ "update.busy": "Une autre mise à jour est déjà en cours — réessayez bientôt",
538
+ "update.timeout": "Délai d'attente du résultat dépassé — réessayez plus tard",
539
+ "update.bundleInUse": "Ce plugin est en cours d'utilisation et Desktop ne le supprimera pas d'abord ; la route de l'hôte installe par-dessus — si cela échoue encore, exécutez la commande ci-dessous",
540
+ "update.alreadyInstalled": "Ce DSH ne remplace un paquet qu'après l'avoir supprimé, il ne peut donc pas s'installer par-dessus la copie actuelle ; exécutez la commande ci-dessous",
541
+ "update.managementRequired": "Ce profil est géré par l'application de bureau, la mise à jour automatique ne peut donc pas le modifier ; exécutez la commande ci-dessous",
542
+ "update.notRemovable": "L'application de bureau gère ce plugin et la mise à jour automatique ne peut pas le supprimer ; exécutez la commande ci-dessous",
543
+ "update.stopProfile": "Pour le supprimer, il faut d'abord arrêter ce profil ; exécutez la commande ci-dessous",
544
+ "update.incompatible": "Cette version n'est pas compatible avec le DSH en cours d'exécution, l'hôte l'a donc refusée",
545
+ "update.versionMismatch": "La version installée n'est pas celle demandée — un miroir ou la rétention liée à l'ancienneté a pu la remplacer ; réessayez plus tard ou installez manuellement",
546
+ "update.downgrade": "Refusé : la version cible est plus ancienne que celle installée",
547
+ "update.autoUnavailable": "Cet hôte ne propose pas de route de mise à jour automatique ; exécutez la commande ci-dessous",
548
+ "update.manualHint": "Ou mettez à jour directement : exécutez {command} dans un terminal, ou mettez à jour depuis la page Plugins, puis rechargez",
549
+ "update.copyPrompt": "Copier l'invite de mise à jour",
550
+ "update.prompt": "Mettez à jour le plugin DSH Sideby Note vers {version} en exécutant : {command}. Rechargez la page une fois terminé."
551
+ };
552
+
553
+ // src/client/i18n/ja.ts
554
+ /** Japanese copy; a missing key fails the typecheck rather than falling back at runtime. */
555
+ const ja = {
556
+ "nav.label": "Sideby Note",
557
+ "title": "Sideby Note",
558
+ "popover.title": "Sideby Note",
559
+ "popover.close": "Sideby Noteを閉じる",
560
+ "popover.count": "{open} 件未完了 · 全 {total} 件",
561
+ "popover.completed": "完了済み",
562
+ "popover.clearCancel": "キャンセル",
563
+ "popover.clearConfirm": "完了したメモ {n} 件を削除しますか?",
564
+ "popover.clearConfirmAction": "削除",
565
+ "popover.clearDone": "完了済みを削除",
566
+ "popover.local": "メモはこの端末にのみ保存されます",
567
+ "scope.label": "メモの範囲",
568
+ "scope.workspace": "ワークスペース",
569
+ "scope.session": "セッション",
570
+ "scope.workspaceHint": "すべてのセッションで共有されるワークスペースのリストに切り替えます",
571
+ "scope.sessionHint": "このセッションだけに表示されるセッションのリストに切り替えます",
572
+ "scope.newSessionHint": "現在はワークスペースのリストのみ利用できます。セッションを開始するとセッションのリストが表示されます",
573
+ "popover.empty.title": "メモはまだありません",
574
+ "popover.empty.body": "エージェントが作業している間に、アイデアを非同期で書き留める",
575
+ "settings.open": "設定",
576
+ "settings.title": "設定",
577
+ "settings.about": "このプラグインについて",
578
+ "settings.tagline": "エージェントが作業している間に、アイデアを非同期で書き留める。",
579
+ "settings.version": "バージョン",
580
+ "settings.author": "作者",
581
+ "settings.project": "ソース",
582
+ "settings.shortcut": "送信ショートカット",
583
+ "settings.shortcutCtrlEnter": "{mod}+Enter で送信、Enter で改行",
584
+ "settings.shortcutEnter": "Enter で送信、{mod}+Enter で改行",
585
+ "settings.forward": "ワンクリック転送",
586
+ "settings.forwardPrefixItem": "プレフィックスのプロンプト",
587
+ "settings.forwardPrefixHint": "空の入力欄に転送するとき、このプロンプトがメモの前に書き込まれます。空欄のままにするとメモだけを転送します",
588
+ "add.placeholder": "ひとつメモする",
589
+ "add.shortcut": "{mod}+Enter で送信 · Enter で改行",
590
+ "add.shortcutEnter": "Enter で送信 · {mod}+Enter で改行",
591
+ "add.action": "追加",
592
+ "list.open": "未完了",
593
+ "list.allDone.title": "未完了のメモはありません",
594
+ "list.allDone.body": "さらに追加するか、下の完了済みを展開して振り返れます",
595
+ "item.markDone": "完了にする",
596
+ "item.markOpen": "未完了に戻す",
597
+ "item.copy": "コピー",
598
+ "item.forward": "チャットに転送",
599
+ "item.forwarded": "チャットに転送済み — クリックでマークを解除",
600
+ "item.recall": "戻す",
601
+ "time.now": "たった今",
602
+ "time.minutes": "{n} 分前",
603
+ "time.hours": "{n} 時間前",
604
+ "time.days": "{n} 日前",
605
+ "time.createdDone": "作成 {created} · 完了 {completed}",
606
+ "storage.failed": "ローカルストレージを利用できません。変更は保存されない可能性があります",
607
+ "forward.prefix": "このタスクを完了してください:",
608
+ "resize.width": "Sideby Note の幅を変更",
609
+ "resize.height": "Sideby Note の高さを変更",
610
+ "resize.hint": "ドラッグでサイズ変更、ダブルクリックでリセット",
611
+ "dock.open": "Sideby Note を開く",
612
+ "dock.count": "{n} 件未完了",
613
+ "header.tooltip": "Sideby Note · {n} 件未完了",
614
+ "header.tooltipEmpty": "Sideby Note",
615
+ "toast.copied": "コピーしました",
616
+ "toast.copyFailed": "コピーに失敗しました — もう一度お試しください",
617
+ "toast.forwarded": "チャットに転送しました",
618
+ "toast.unforwarded": "転送マークを解除しました",
619
+ "toast.forwardFailed": "入力欄が見つかりません — 転送されませんでした",
620
+ "toast.recalled": "入力欄に戻しました",
621
+ "toast.recallBlocked": "入力欄に文字があります。送信するかクリアしてください",
622
+ "toast.cleared": "完了済みを削除しました",
623
+ "toast.saveFailed": "保存に失敗しました — 変更はありません",
624
+ "update.label": "更新があります",
625
+ "update.tip": "バージョン {version} が利用可能です — リリースノートを開く",
626
+ "update.check": "更新を確認",
627
+ "update.checking": "確認中…",
628
+ "update.retryCheck": "確認を再試行",
629
+ "update.current": "最新バージョンです",
630
+ "update.checkFailed": "確認に失敗しました — 後でもう一度お試しください",
631
+ "update.available": "バージョン {version} が利用可能です",
632
+ "update.notesTitle": "リリースノート",
633
+ "update.notesLoading": "リリースノートを読み込み中…",
634
+ "update.notesMissing": "このバージョンのリリースノートはまだありません",
635
+ "update.historyCount": "{n} 件のリリースを掲載",
636
+ "update.latest": "最新",
637
+ "update.olderNotes": "以前のリリースは完全なリリースノートにあります",
638
+ "update.notesFailed": "リリースノートを読み込めませんでした — 完全なノートを開いてください",
639
+ "update.full": "完全なリリースノート",
640
+ "update.now": "今すぐ更新",
641
+ "update.starting": "更新を準備しています…",
642
+ "update.updating": "更新中…",
643
+ "update.updated": "{version} に更新しました",
644
+ "update.refresh": "ページを再読み込み",
645
+ "update.restartHint": "更新を完了するには DSH を手動で再起動してください",
646
+ "update.failed": "更新に失敗しました:{reason}",
647
+ "update.notInstalled": "このプラグインは現在のプロファイルにインストールされていないため、アプリ内で更新できません",
648
+ "update.forbidden": "自動更新がこのリクエストを拒否しました",
649
+ "update.rejected": "自動更新は実行されませんでした。リンクされたチェックアウトはそのディレクトリから更新されます",
650
+ "update.busy": "別の更新が実行中です — しばらくしてからお試しください",
651
+ "update.timeout": "更新結果の待機がタイムアウトしました — 後でもう一度お試しください",
652
+ "update.bundleInUse": "このプラグインは使用中で、Desktop は先に削除しません。ホスト経由のインストールで上書きします — それでも失敗する場合は下のコマンドを実行してください",
653
+ "update.alreadyInstalled": "この DSH はパッケージを削除してからでないと置き換えられないため、現在のコピーに上書きインストールできません。下のコマンドを実行してください",
654
+ "update.managementRequired": "このプロファイルはデスクトップアプリが管理しているため、自動更新では変更できません。下のコマンドを実行してください",
655
+ "update.notRemovable": "デスクトップアプリがこのプラグインを管理しており、自動更新では削除できません。下のコマンドを実行してください",
656
+ "update.stopProfile": "削除するには先にこのプロファイルを停止する必要があります。下のコマンドを実行してください",
657
+ "update.incompatible": "このバージョンは実行中の DSH と互換性がないため、ホストが拒否しました",
658
+ "update.versionMismatch": "インストールされたバージョンが要求したものと異なります — ミラーまたはリリース時期の制限が置き換えた可能性があります。後で再試行するか手動でインストールしてください",
659
+ "update.downgrade": "拒否されました:対象バージョンがインストール済みより古いです",
660
+ "update.autoUnavailable": "このホストは自動更新ルートを提供していません。下のコマンドを実行してください",
661
+ "update.manualHint": "または直接更新:ターミナルで {command} を実行するか、プラグインページから更新してから再読み込みしてください",
662
+ "update.copyPrompt": "更新プロンプトをコピー",
663
+ "update.prompt": "DSH プラグイン Sideby Note を {version} に更新するには、次を実行してください:{command}。完了したらページを再読み込みしてください。"
664
+ };
665
+
666
+ // src/client/i18n/pt.ts
667
+ /** Brazilian Portuguese copy; a missing key fails the typecheck rather than falling back at runtime. */
668
+ const pt = {
669
+ "nav.label": "Sideby Note",
670
+ "title": "Sideby Note",
671
+ "popover.title": "Sideby Note",
672
+ "popover.close": "Fechar Sideby Note",
673
+ "popover.count": "{open} abertas · {total} no total",
674
+ "popover.completed": "Concluídas",
675
+ "popover.clearCancel": "Cancelar",
676
+ "popover.clearConfirm": "Limpar {n} notas concluídas?",
677
+ "popover.clearConfirmAction": "Limpar",
678
+ "popover.clearDone": "Limpar concluídas",
679
+ "popover.local": "As notas são salvas apenas neste dispositivo",
680
+ "scope.label": "Escopo das notas",
681
+ "scope.workspace": "Espaço de trabalho",
682
+ "scope.session": "Sessão",
683
+ "scope.workspaceHint": "Mudar para a lista do espaço de trabalho, compartilhada por todas as sessões",
684
+ "scope.sessionHint": "Mudar para a lista da sessão, visível apenas nesta sessão",
685
+ "scope.newSessionHint": "Por enquanto, apenas a lista do espaço de trabalho está disponível; a lista da sessão aparece quando a sessão começar",
686
+ "popover.empty.title": "Nenhuma nota ainda",
687
+ "popover.empty.body": "Esboce suas ideias de forma assíncrona enquanto o agente trabalha",
688
+ "settings.open": "Configurações",
689
+ "settings.title": "Configurações",
690
+ "settings.about": "Sobre",
691
+ "settings.tagline": "Esboce suas ideias de forma assíncrona enquanto o agente trabalha.",
692
+ "settings.version": "Versão",
693
+ "settings.author": "Autor",
694
+ "settings.project": "Código-fonte",
695
+ "settings.shortcut": "Atalho de envio",
696
+ "settings.shortcutCtrlEnter": "{mod}+Enter envia, Enter para uma nova linha",
697
+ "settings.shortcutEnter": "Enter envia, {mod}+Enter para uma nova linha",
698
+ "settings.forward": "Encaminhamento com um clique",
699
+ "settings.forwardPrefixItem": "Prompt de prefixo",
700
+ "settings.forwardPrefixHint": "Ao encaminhar para um campo de texto vazio, este prompt é escrito antes da nota; deixe vazio para encaminhar apenas a nota",
701
+ "add.placeholder": "Anote uma",
702
+ "add.shortcut": "{mod}+Enter envia · Enter para uma nova linha",
703
+ "add.shortcutEnter": "Enter envia · {mod}+Enter para uma nova linha",
704
+ "add.action": "Adicionar",
705
+ "list.open": "Abertas",
706
+ "list.allDone.title": "Nada mais em aberto",
707
+ "list.allDone.body": "Adicione outra nota ou expanda as concluídas abaixo para revisar",
708
+ "item.markDone": "Marcar como concluída",
709
+ "item.markOpen": "Marcar como aberta",
710
+ "item.copy": "Copiar",
711
+ "item.forward": "Encaminhar para o chat",
712
+ "item.forwarded": "Encaminhada para o chat — clique para remover a marca",
713
+ "item.recall": "Devolver",
714
+ "time.now": "agora mesmo",
715
+ "time.minutes": "há {n} min",
716
+ "time.hours": "há {n} h",
717
+ "time.days": "há {n} d",
718
+ "time.createdDone": "Criada {created} · Concluída {completed}",
719
+ "storage.failed": "O armazenamento local não está disponível; as alterações podem não ser salvas",
720
+ "forward.prefix": "Conclua esta tarefa:",
721
+ "resize.width": "Redimensionar a largura do Sideby Note",
722
+ "resize.height": "Redimensionar a altura do Sideby Note",
723
+ "resize.hint": "Arraste para redimensionar, clique duas vezes para redefinir",
724
+ "dock.open": "Abrir Sideby Note",
725
+ "dock.count": "{n} abertas",
726
+ "header.tooltip": "Sideby Note · {n} abertas",
727
+ "header.tooltipEmpty": "Sideby Note",
728
+ "toast.copied": "Copiado",
729
+ "toast.copyFailed": "Falha ao copiar — tente novamente",
730
+ "toast.forwarded": "Encaminhada para o chat",
731
+ "toast.unforwarded": "Marca de encaminhamento removida",
732
+ "toast.forwardFailed": "Nenhum campo de texto encontrado — nada foi encaminhado",
733
+ "toast.recalled": "Devolvida para a caixa de texto",
734
+ "toast.recallBlocked": "A caixa de texto já tem conteúdo; envie ou limpe primeiro",
735
+ "toast.cleared": "Concluídas limpas",
736
+ "toast.saveFailed": "Falha ao salvar — nada mudou",
737
+ "update.label": "Atualização disponível",
738
+ "update.tip": "A versão {version} já está disponível — abra as notas da versão",
739
+ "update.check": "Verificar atualizações",
740
+ "update.checking": "Verificando…",
741
+ "update.retryCheck": "Tentar verificação novamente",
742
+ "update.current": "Você está na versão mais recente",
743
+ "update.checkFailed": "Falha na verificação — tente mais tarde",
744
+ "update.available": "A versão {version} está disponível",
745
+ "update.notesTitle": "Notas da versão",
746
+ "update.notesLoading": "Carregando notas da versão…",
747
+ "update.notesMissing": "Ainda não há notas da versão para esta versão",
748
+ "update.historyCount": "{n} versões incluídas",
749
+ "update.latest": "Mais recente",
750
+ "update.olderNotes": "As versões anteriores estão nas notas completas",
751
+ "update.notesFailed": "Não foi possível carregar as notas da versão — abra as notas completas",
752
+ "update.full": "Notas completas da versão",
753
+ "update.now": "Atualizar agora",
754
+ "update.starting": "Preparando a atualização…",
755
+ "update.updating": "Atualizando…",
756
+ "update.updated": "Atualizado para {version}",
757
+ "update.refresh": "Atualizar página",
758
+ "update.restartHint": "Reinicie o DSH manualmente para concluir a atualização",
759
+ "update.failed": "Falha na atualização: {reason}",
760
+ "update.notInstalled": "Este plugin não está instalado no perfil atual, então não pode ser atualizado no aplicativo",
761
+ "update.forbidden": "A atualização automática recusou esta solicitação",
762
+ "update.rejected": "A atualização automática não foi executada; uma cópia vinculada é atualizada a partir do próprio diretório",
763
+ "update.busy": "Outra atualização já está em andamento — tente novamente em breve",
764
+ "update.timeout": "Tempo esgotado aguardando o resultado da atualização — tente mais tarde",
765
+ "update.bundleInUse": "Este plugin está em uso e o Desktop não o removerá primeiro; a rota do host instala por cima — se ainda falhar, execute o comando abaixo",
766
+ "update.alreadyInstalled": "Este DSH só substitui um pacote depois de removê-lo, então não pode instalar sobre a cópia atual; execute o comando abaixo",
767
+ "update.managementRequired": "Este perfil é gerenciado pelo aplicativo desktop, então a atualização automática não pode alterá-lo; execute o comando abaixo",
768
+ "update.notRemovable": "O aplicativo desktop gerencia este plugin e a atualização automática não pode removê-lo; execute o comando abaixo",
769
+ "update.stopProfile": "Para removê-lo é preciso parar este perfil primeiro; execute o comando abaixo",
770
+ "update.incompatible": "Esta versão não é compatível com o DSH em execução, então o host a recusou",
771
+ "update.versionMismatch": "A versão instalada não é a solicitada — um espelho ou a retenção por idade da versão pode tê-la substituído; tente mais tarde ou instale manualmente",
772
+ "update.downgrade": "Recusado: a versão de destino é mais antiga que a instalada",
773
+ "update.autoUnavailable": "Este host não oferece rota de atualização automática; execute o comando abaixo",
774
+ "update.manualHint": "Ou atualize diretamente: execute {command} em um terminal, ou atualize na página de Plugins e recarregue",
775
+ "update.copyPrompt": "Copiar prompt de atualização",
776
+ "update.prompt": "Atualize o plugin DSH Sideby Note para {version} executando: {command}. Recarregue a página quando terminar."
777
+ };
778
+
779
+ // src/client/i18n/ru.ts
780
+ /** Russian copy; a missing key fails the typecheck rather than falling back at runtime. */
781
+ const ru = {
782
+ "nav.label": "Sideby Note",
783
+ "title": "Sideby Note",
784
+ "popover.title": "Sideby Note",
785
+ "popover.close": "Закрыть Sideby Note",
786
+ "popover.count": "{open} открыто · всего {total}",
787
+ "popover.completed": "Выполнено",
788
+ "popover.clearCancel": "Отмена",
789
+ "popover.clearConfirm": "Очистить выполненные заметки ({n})?",
790
+ "popover.clearConfirmAction": "Очистить",
791
+ "popover.clearDone": "Очистить выполненные",
792
+ "popover.local": "Заметки сохраняются только на этом устройстве",
793
+ "scope.label": "Область заметок",
794
+ "scope.workspace": "Рабочая область",
795
+ "scope.session": "Сеанс",
796
+ "scope.workspaceHint": "Переключиться на список рабочей области, общий для всех сеансов",
797
+ "scope.sessionHint": "Переключиться на список сеанса, видимый только в этом сеансе",
798
+ "scope.newSessionHint": "Пока доступен только список рабочей области; список сеанса появится после начала сеанса",
799
+ "popover.empty.title": "Заметок пока нет",
800
+ "popover.empty.body": "Набрасывайте идеи асинхронно, пока агент работает",
801
+ "settings.open": "Настройки",
802
+ "settings.title": "Настройки",
803
+ "settings.about": "О плагине",
804
+ "settings.tagline": "Набрасывайте идеи асинхронно, пока агент работает.",
805
+ "settings.version": "Версия",
806
+ "settings.author": "Автор",
807
+ "settings.project": "Исходный код",
808
+ "settings.shortcut": "Сочетание для отправки",
809
+ "settings.shortcutCtrlEnter": "{mod}+Enter отправляет, Enter — новая строка",
810
+ "settings.shortcutEnter": "Enter отправляет, {mod}+Enter — новая строка",
811
+ "settings.forward": "Пересылка в один клик",
812
+ "settings.forwardPrefixItem": "Префикс-запрос",
813
+ "settings.forwardPrefixHint": "При пересылке в пустое поле ввода этот запрос записывается перед заметкой; оставьте пустым, чтобы переслать только заметку",
814
+ "add.placeholder": "Записать",
815
+ "add.shortcut": "{mod}+Enter отправляет · Enter — новая строка",
816
+ "add.shortcutEnter": "Enter отправляет · {mod}+Enter — новая строка",
817
+ "add.action": "Добавить",
818
+ "list.open": "Открыто",
819
+ "list.allDone.title": "Открытых заметок нет",
820
+ "list.allDone.body": "Добавьте заметку или разверните выполненные ниже, чтобы вспомнить",
821
+ "item.markDone": "Отметить выполненной",
822
+ "item.markOpen": "Отметить открытой",
823
+ "item.copy": "Копировать",
824
+ "item.forward": "Переслать в чат",
825
+ "item.forwarded": "Переслано в чат — нажмите, чтобы убрать отметку",
826
+ "item.recall": "Вернуть",
827
+ "time.now": "только что",
828
+ "time.minutes": "{n} мин назад",
829
+ "time.hours": "{n} ч назад",
830
+ "time.days": "{n} дн. назад",
831
+ "time.createdDone": "Создано {created} · Выполнено {completed}",
832
+ "storage.failed": "Локальное хранилище недоступно; изменения могут не сохраниться",
833
+ "forward.prefix": "Выполните эту задачу:",
834
+ "resize.width": "Изменить ширину Sideby Note",
835
+ "resize.height": "Изменить высоту Sideby Note",
836
+ "resize.hint": "Перетащите для изменения размера, двойной щелчок для сброса",
837
+ "dock.open": "Открыть Sideby Note",
838
+ "dock.count": "{n} открыто",
839
+ "header.tooltip": "Sideby Note · {n} открыто",
840
+ "header.tooltipEmpty": "Sideby Note",
841
+ "toast.copied": "Скопировано",
842
+ "toast.copyFailed": "Не удалось скопировать — повторите попытку",
843
+ "toast.forwarded": "Переслано в чат",
844
+ "toast.unforwarded": "Отметка пересылки удалена",
845
+ "toast.forwardFailed": "Поле ввода не найдено — ничего не переслано",
846
+ "toast.recalled": "Возвращено в поле ввода",
847
+ "toast.recallBlocked": "В поле ввода уже есть текст — сначала отправьте или очистите его",
848
+ "toast.cleared": "Выполненные очищены",
849
+ "toast.saveFailed": "Не удалось сохранить — ничего не изменено",
850
+ "update.label": "Доступно обновление",
851
+ "update.tip": "Доступна версия {version} — откройте примечания к выпуску",
852
+ "update.check": "Проверить обновления",
853
+ "update.checking": "Проверка…",
854
+ "update.retryCheck": "Повторить проверку",
855
+ "update.current": "У вас последняя версия",
856
+ "update.checkFailed": "Проверка не удалась — повторите позже",
857
+ "update.available": "Доступна версия {version}",
858
+ "update.notesTitle": "Примечания к выпуску",
859
+ "update.notesLoading": "Загрузка примечаний к выпуску…",
860
+ "update.notesMissing": "Для этой версии пока нет примечаний к выпуску",
861
+ "update.historyCount": "Включено выпусков: {n}",
862
+ "update.latest": "Последний",
863
+ "update.olderNotes": "Предыдущие выпуски — в полных примечаниях",
864
+ "update.notesFailed": "Не удалось загрузить примечания к выпуску — откройте полные примечания",
865
+ "update.full": "Полные примечания к выпуску",
866
+ "update.now": "Обновить сейчас",
867
+ "update.starting": "Подготовка обновления…",
868
+ "update.updating": "Обновление…",
869
+ "update.updated": "Обновлено до {version}",
870
+ "update.refresh": "Обновить страницу",
871
+ "update.restartHint": "Перезапустите DSH вручную, чтобы завершить обновление",
872
+ "update.failed": "Ошибка обновления: {reason}",
873
+ "update.notInstalled": "Этот плагин не установлен в текущем профиле, поэтому его нельзя обновить из приложения",
874
+ "update.forbidden": "Автоматическое обновление отклонило этот запрос",
875
+ "update.rejected": "Автоматическое обновление не запустилось; связанная копия обновляется из своего каталога",
876
+ "update.busy": "Другое обновление уже выполняется — повторите чуть позже",
877
+ "update.timeout": "Истекло время ожидания результата обновления — повторите позже",
878
+ "update.bundleInUse": "Плагин используется, и Desktop не станет удалять его первым; маршрут хоста устанавливает поверх — если это не сработает, выполните команду ниже",
879
+ "update.alreadyInstalled": "Этот DSH заменяет пакет только после удаления, поэтому не может установиться поверх текущей копии; выполните команду ниже",
880
+ "update.managementRequired": "Этот профиль управляется приложением Desktop, поэтому автоматическое обновление не может его изменить; выполните команду ниже",
881
+ "update.notRemovable": "Плагин управляется приложением Desktop, и автоматическое обновление не может его удалить; выполните команду ниже",
882
+ "update.stopProfile": "Для удаления сначала нужно остановить этот профиль; выполните команду ниже",
883
+ "update.incompatible": "Эта версия несовместима с запущенным DSH, поэтому хост отклонил её",
884
+ "update.versionMismatch": "Установленная версия не совпадает с запрошенной — зеркало или ограничение по возрасту релиза могли её подменить; повторите позже или установите вручную",
885
+ "update.downgrade": "Отклонено: целевая версия старше установленной",
886
+ "update.autoUnavailable": "Этот хост не предлагает автоматическое обновление; выполните команду ниже",
887
+ "update.manualHint": "Или обновитесь напрямую: выполните {command} в терминале либо обновитесь со страницы плагинов и перезагрузите",
888
+ "update.copyPrompt": "Скопировать запрос на обновление",
889
+ "update.prompt": "Обновите плагин DSH Sideby Note до {version}, выполнив: {command}. Перезагрузите страницу по завершении."
890
+ };
891
+
892
+ // src/client/i18n/zh.ts
893
+ /** Chinese copy — the single source of truth for the message keys. */
894
+ const zh = {
895
+ "nav.label": "边记部",
896
+ "title": "边记部",
897
+ "popover.title": "边记部",
898
+ "popover.close": "关闭边记部",
899
+ "popover.count": "{open} 未完成 · {total} 条",
900
+ "popover.completed": "已完成",
901
+ "popover.clearCancel": "取消",
902
+ "popover.clearConfirm": "清除 {n} 项已完成记录?",
903
+ "popover.clearConfirmAction": "确认清除",
904
+ "popover.clearDone": "清除已完成",
905
+ "popover.local": "便笺数据仅保存在本地",
906
+ "scope.label": "便笺范围",
907
+ "scope.workspace": "工作区",
908
+ "scope.session": "会话",
909
+ "scope.workspaceHint": "切换到工作区清单,所有会话共享",
910
+ "scope.sessionHint": "切换到会话清单,只属于当前会话",
911
+ "scope.newSessionHint": "当前只能记到工作区,会话开始后可切换",
912
+ "popover.empty.title": "边记摸鱼中..",
913
+ "popover.empty.body": "趁 agent 工作时,异步记下你的想法",
914
+ "settings.open": "设置",
915
+ "settings.title": "设置",
916
+ "settings.about": "关于",
917
+ "settings.tagline": "趁 agent 工作时,异步记下你的想法",
918
+ "settings.version": "版本",
919
+ "settings.author": "作者",
920
+ "settings.project": "源代码",
921
+ "settings.shortcut": "发送快捷键",
922
+ "settings.shortcutCtrlEnter": "{mod}+Enter 发送,Enter 换行",
923
+ "settings.shortcutEnter": "Enter 发送,{mod}+Enter 换行",
924
+ "settings.forward": "一键转发",
925
+ "settings.forwardPrefixItem": "前缀提示词",
926
+ "settings.forwardPrefixHint": "转发到会话时,若输入框为空,会先写入这段提示词,再追加记录内容;留空则只转发记录内容",
927
+ "add.placeholder": "随手记一条",
928
+ "add.shortcut": "{mod}+Enter 发送 · Enter 换行",
929
+ "add.shortcutEnter": "Enter 发送 · {mod}+Enter 换行",
930
+ "add.action": "添加",
931
+ "list.open": "未完成",
932
+ "list.allDone.title": "未完成的都清空了",
933
+ "list.allDone.body": "可以继续添加,或展开下方回看已完成",
934
+ "item.markDone": "标记为完成",
935
+ "item.markOpen": "标记为未完成",
936
+ "item.copy": "复制",
937
+ "item.forward": "转发到会话",
938
+ "item.forwarded": "已转发到会话,点击可移除标识",
939
+ "item.recall": "退回",
940
+ "time.now": "刚刚",
941
+ "time.minutes": "{n} 分钟前",
942
+ "time.hours": "{n} 小时前",
943
+ "time.days": "{n} 天前",
944
+ "time.createdDone": "{created}创建,{completed}完成",
945
+ "storage.failed": "本地存储不可用,改动不会保留",
946
+ "forward.prefix": "完成以下任务:",
947
+ "resize.width": "调整边记部宽度",
948
+ "resize.height": "调整边记部高度",
949
+ "resize.hint": "拖动调整,双击复位",
950
+ "dock.open": "打开边记部",
951
+ "dock.count": "{n} 项未完成",
952
+ "header.tooltip": "边记部 · {n} 项未完成",
953
+ "header.tooltipEmpty": "边记部",
954
+ "toast.copied": "已复制",
955
+ "toast.copyFailed": "复制失败,请重试",
956
+ "toast.forwarded": "已转发到会话",
957
+ "toast.unforwarded": "已取消转发标识",
958
+ "toast.forwardFailed": "没有找到输入框,转发失败",
959
+ "toast.recalled": "已退回输入框",
960
+ "toast.recallBlocked": "输入框已有内容,请先发送或清空",
961
+ "toast.cleared": "已清除已完成",
962
+ "toast.saveFailed": "保存失败,内容没有改动",
963
+ "update.label": "有新版本",
964
+ "update.tip": "新版本 {version} 已发布,点击查看更新说明",
965
+ "update.check": "检查更新",
966
+ "update.checking": "正在检查…",
967
+ "update.retryCheck": "重试检查",
968
+ "update.current": "已是最新版本",
969
+ "update.checkFailed": "检查失败,请稍后重试",
970
+ "update.available": "有新版本 {version}",
971
+ "update.notesTitle": "更新说明",
972
+ "update.notesLoading": "正在读取更新说明…",
973
+ "update.notesMissing": "这个版本还没有可显示的更新说明",
974
+ "update.historyCount": "本次更新包含 {n} 个版本",
975
+ "update.latest": "最新",
976
+ "update.olderNotes": "更早的版本请见完整更新说明",
977
+ "update.notesFailed": "更新说明读取失败,可打开完整更新说明查看",
978
+ "update.full": "完整更新说明",
979
+ "update.now": "立即更新",
980
+ "update.starting": "正在准备更新…",
981
+ "update.updating": "正在更新…",
982
+ "update.updated": "已更新到 {version}",
983
+ "update.refresh": "刷新页面",
984
+ "update.restartHint": "请手动重启 DSH 以完成更新",
985
+ "update.failed": "更新失败:{reason}",
986
+ "update.notInstalled": "当前 profile 中没有安装这个插件,无法在应用内更新",
987
+ "update.forbidden": "自动更新被拒绝,这次请求没有执行",
988
+ "update.rejected": "自动更新没有执行;link 安装的插件需要在 checkout 中更新后刷新",
989
+ "update.busy": "更新正在执行另一个任务,请稍后再试",
990
+ "update.timeout": "等待更新结果超时,请稍后再试",
991
+ "update.bundleInUse": "这个插件正被当前 DSH 使用中,桌面端不允许先移除再安装;宿主通道会就地覆盖,若仍失败请用下面的命令",
992
+ "update.alreadyInstalled": "这个 DSH 只支持先移除再安装,无法原地覆盖;请用下面的命令",
993
+ "update.managementRequired": "这个 profile 由桌面端自己管理,自动更新无法改动它;请用下面的命令",
994
+ "update.notRemovable": "这个插件由桌面端管理,自动更新不能移除它;请用下面的命令",
995
+ "update.stopProfile": "移除它需要先停止这个 profile;请用下面的命令",
996
+ "update.incompatible": "这个版本与当前 DSH 不兼容,宿主拒绝了安装",
997
+ "update.versionMismatch": "装到的版本与目标不一致(可能被镜像或发布保护替换);可稍后重试或手动安装",
998
+ "update.downgrade": "拒绝降级:目标版本低于当前已装版本",
999
+ "update.autoUnavailable": "这台宿主没有可用的自动更新通道;请用下面的命令",
1000
+ "update.manualHint": "也可以直接更新:在终端执行 {command},或到「插件」页更新,装好后刷新页面即可",
1001
+ "update.copyPrompt": "拷贝更新提示词",
1002
+ "update.prompt": "帮我更新 DSH 插件 Sideby Note(边记部)到 {version}:在终端执行 {command},装好后刷新页面。"
1003
+ };
1004
+
1005
+ // src/client/i18n/index.ts
1006
+ /** Every DSH-official locale, in the shape `locale.register` expects. */
1007
+ const DICT = {
1008
+ zh,
1009
+ en,
1010
+ ja,
1011
+ es,
1012
+ fr,
1013
+ de,
1014
+ ru,
1015
+ pt
1016
+ };
1017
+ /** Interpolate `{name}` placeholders; an absent value leaves the placeholder alone. */
1018
+ function fill(template, vars) {
1019
+ return String(template).replace(/\{(\w+)\}/g, (match, name) => {
1020
+ return vars && vars[name] !== void 0 && vars[name] !== null ? String(vars[name]) : match;
1021
+ });
1022
+ }
1023
+ /**
1024
+ * Translate through the locale service, falling back to the bundled copy.
1025
+ *
1026
+ * `say` stays string-keyed for now: the panel passes keys through props and
1027
+ * literal objects, so a stricter key type waits until those call sites settle.
1028
+ */
1029
+ function makeSay(ctx, getLocaleId) {
1030
+ const locale = ctx.get("locale");
1031
+ const bound = locale && typeof locale.bind === "function" ? locale.bind(NS) : null;
1032
+ return (key) => {
1033
+ if (bound) try {
1034
+ const value = bound(key);
1035
+ if (typeof value === "string" && value && value !== key) return value;
1036
+ } catch {}
1037
+ const language = String(getLocaleId()).split("-")[0].toLowerCase();
1038
+ return (DICT[language] || DICT.en)[key] || DICT.en[key] || key;
1039
+ };
1040
+ }
1041
+
1042
+ // src/client/scope.ts
1043
+ const EMPTY = {
1044
+ sessionId: "",
1045
+ workspaceId: "",
1046
+ title: "",
1047
+ sessionIds: [],
1048
+ ready: true
1049
+ };
1050
+ let binding = EMPTY;
1051
+ let version = 0;
1052
+ const listeners = /* @__PURE__ */ new Set();
1053
+ const text$2 = (value) => value ? String(value) : "";
1054
+ const notify = () => {
1055
+ version += 1;
1056
+ for (const listener of listeners) listener();
1057
+ };
1058
+ /** Subscribe to binding changes; used by the open panel to gain session scope. */
1059
+ function subscribeScope(listener) {
1060
+ listeners.add(listener);
1061
+ return () => {
1062
+ listeners.delete(listener);
1063
+ };
1064
+ }
1065
+ /** Monotonic version of the binding, read by useSyncExternalStore. */
1066
+ function scopeVersion() {
1067
+ return version;
1068
+ }
1069
+ /**
1070
+ * Resolve the workspace of the captured session; null clears the binding.
1071
+ * `ready` is false only when the session is still the blank new-session page.
1072
+ */
1073
+ function bindWorkspace(sessionId, workspace, ready = true) {
1074
+ const next = workspace ? {
1075
+ sessionId: text$2(sessionId),
1076
+ workspaceId: text$2(workspace.workspaceId),
1077
+ title: text$2(workspace.title),
1078
+ sessionIds: Array.isArray(workspace.sessionIds) ? workspace.sessionIds.map(text$2).filter(Boolean) : [],
1079
+ ready: ready !== false
1080
+ } : {
1081
+ ...EMPTY,
1082
+ sessionId: text$2(sessionId),
1083
+ ready: ready !== false
1084
+ };
1085
+ if (next.sessionId === binding.sessionId && next.workspaceId === binding.workspaceId && next.title === binding.title && next.sessionIds.join("\0") === binding.sessionIds.join("\0") && next.ready === binding.ready) return false;
1086
+ binding = next;
1087
+ notify();
1088
+ return true;
1089
+ }
1090
+ /** The workspace list available to this session, or null outside a workspace. */
1091
+ function workspaceScopeForSession(sessionId) {
1092
+ const id = text$2(sessionId);
1093
+ if (id && binding.sessionId === id && binding.workspaceId) return {
1094
+ kind: "workspace",
1095
+ id: binding.workspaceId,
1096
+ title: binding.title,
1097
+ sessionIds: binding.sessionIds
1098
+ };
1099
+ return null;
1100
+ }
1101
+ /** Whether the captured session has moved past the blank new-session page. */
1102
+ function sessionReadyFor(sessionId) {
1103
+ const id = text$2(sessionId);
1104
+ if (!id || binding.sessionId !== id) return true;
1105
+ return binding.ready;
1106
+ }
1107
+ /** Whether the panel may offer the session list at all. */
1108
+ function canUseSessionScope(sessionId) {
1109
+ return Boolean(text$2(sessionId)) && sessionReadyFor(sessionId);
1110
+ }
1111
+ /** The list this session reads and writes under the chosen scope mode. */
1112
+ function scopeForSession(sessionId, mode = "workspace") {
1113
+ const workspace = workspaceScopeForSession(sessionId);
1114
+ if (workspace && (mode !== "session" || !sessionReadyFor(sessionId))) return workspace;
1115
+ const id = text$2(sessionId);
1116
+ return {
1117
+ kind: "session",
1118
+ id,
1119
+ title: "",
1120
+ sessionIds: id ? [id] : []
1121
+ };
1122
+ }
1123
+ /** Stable key for the forward marks of one list. */
1124
+ function scopeKey(scope) {
1125
+ if (!scope || !scope.id) return "";
1126
+ return scope.kind === "workspace" ? `ws:${scope.id}` : String(scope.id);
1127
+ }
1128
+ /**
1129
+ * Stable key for the drafts of a conversation.
1130
+ *
1131
+ * Drafts belong to the workspace, not to the tab the panel is showing: every
1132
+ * member conversation shares one buffer, so neither switching conversations
1133
+ * nor switching the workspace/session scope strands half-typed text. The save
1134
+ * itself still uses the scope selected at that moment. A session outside a
1135
+ * workspace keeps its own buffer.
1136
+ */
1137
+ function draftKeyForSession(sessionId) {
1138
+ const workspace = workspaceScopeForSession(sessionId);
1139
+ return workspace ? scopeKey(workspace) : text$2(sessionId);
1140
+ }
1141
+
1142
+ // src/client/domain/forward.ts
1143
+ /** Append one note to the conversation composer (Lexical contenteditable or textarea). */
1144
+ /** Session whose conversation is on screen; the dock keeps this current. */
1145
+ let targetSessionId = "";
1146
+ /** Point forwarding at the conversation the user currently has open. */
1147
+ function setForwardTarget(sessionId) {
1148
+ targetSessionId = sessionId ? String(sessionId) : "";
1149
+ }
1150
+ /** The visible conversation root of the target session, when the host marks one. */
1151
+ function conversationRoot() {
1152
+ if (!targetSessionId) return null;
1153
+ for (const node of document.querySelectorAll("[data-conversation-session]")) if (node.getAttribute("data-conversation-session") === targetSessionId) return node;
1154
+ return null;
1155
+ }
1156
+ function appendToConversation(text, prefix = "") {
1157
+ const note = String(text || "").replace(/^\s+|\s+$/g, "");
1158
+ if (!note) return false;
1159
+ const bullet = `- ${note}`;
1160
+ const lead = prefix ? String(prefix).trim() : "";
1161
+ const emptyBlock = lead ? `${lead}\n${bullet}` : bullet;
1162
+ const visible = (node) => {
1163
+ const rect = node.getBoundingClientRect();
1164
+ return rect.width > 0 && rect.height > 0;
1165
+ };
1166
+ const root = conversationRoot() || document;
1167
+ const specific = [...root.querySelectorAll("[data-composer-input]")].filter(visible);
1168
+ const editor = (specific.length ? specific : [...root.querySelectorAll("[contenteditable=\"true\"][role=\"textbox\"], textarea[role=\"textbox\"]")].filter(visible))[0];
1169
+ if (!editor) return false;
1170
+ /** Payload for a composer whose current plain text is `current`. */
1171
+ const payloadFor = (current) => {
1172
+ const value = typeof current === "string" ? current : "";
1173
+ if (!value.trim()) return emptyBlock;
1174
+ return value.endsWith("\n") ? bullet : `\n${bullet}`;
1175
+ };
1176
+ if (editor.tagName === "TEXTAREA") {
1177
+ const textarea = editor;
1178
+ const current = textarea.value;
1179
+ const payload = payloadFor(current);
1180
+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value").set.call(textarea, `${current}${payload}`);
1181
+ textarea.dispatchEvent(new Event("input", { bubbles: true }));
1182
+ textarea.focus();
1183
+ const end = textarea.value.length;
1184
+ textarea.setSelectionRange(end, end);
1185
+ return true;
1186
+ }
1187
+ const payload = payloadFor(typeof editor.innerText === "string" ? editor.innerText : "");
1188
+ editor.focus();
1189
+ try {
1190
+ const range = document.createRange();
1191
+ range.selectNodeContents(editor);
1192
+ range.collapse(false);
1193
+ const selection = window.getSelection();
1194
+ selection.removeAllRanges();
1195
+ selection.addRange(range);
1196
+ } catch {}
1197
+ try {
1198
+ const data = new DataTransfer();
1199
+ data.setData("text/plain", payload);
1200
+ const event = new ClipboardEvent("paste", {
1201
+ bubbles: true,
1202
+ cancelable: true,
1203
+ clipboardData: data
1204
+ });
1205
+ if (!editor.dispatchEvent(event)) return true;
1206
+ } catch {}
1207
+ try {
1208
+ return document.execCommand("insertText", false, payload);
1209
+ } catch {
1210
+ return false;
1211
+ }
1212
+ }
1213
+
1214
+ // src/client/storage/codec.ts
1215
+ /** The browser store, or null when storage is blocked. */
1216
+ /** The browser store, or null when storage is blocked. */
1217
+ function storage() {
1218
+ try {
1219
+ return window.localStorage;
1220
+ } catch {
1221
+ return null;
1222
+ }
1223
+ }
1224
+
1225
+ // src/client/storage/prefs.ts
1226
+ /** Panel geometry, list scope, send shortcut, forward prefix and section state. */
1227
+ /** Read the persisted right-panel width, clamped for the current viewport. */
1228
+ function readPanelWidth() {
1229
+ const ls = storage();
1230
+ const max = Math.min(720, Math.max(280, window.innerWidth - 32));
1231
+ try {
1232
+ const saved = ls && Number(ls.getItem("dsh.aside-note.panel-width"));
1233
+ if (Number.isFinite(saved) && saved > 0) return Math.max(280, Math.min(max, saved));
1234
+ } catch {}
1235
+ return Math.max(280, Math.min(max, 360));
1236
+ }
1237
+ /** Persist the right-panel width so it survives reopening the popover. */
1238
+ function writePanelWidth(width) {
1239
+ const ls = storage();
1240
+ if (!ls) return;
1241
+ try {
1242
+ ls.setItem(PANEL_WIDTH_KEY, String(Math.round(width)));
1243
+ } catch {}
1244
+ }
1245
+ /** Read the persisted right-panel height; 0 means content-sized. */
1246
+ function readPanelHeight() {
1247
+ const ls = storage();
1248
+ try {
1249
+ const saved = ls && Number(ls.getItem("dsh.aside-note.panel-height"));
1250
+ if (Number.isFinite(saved) && saved > 0) return saved;
1251
+ } catch {}
1252
+ return 0;
1253
+ }
1254
+ /** Persist the right-panel height; 0 restores content sizing. */
1255
+ function writePanelHeight(height) {
1256
+ const ls = storage();
1257
+ if (!ls) return;
1258
+ try {
1259
+ if (height > 0) ls.setItem(PANEL_HEIGHT_KEY, String(Math.round(height)));
1260
+ else ls.removeItem(PANEL_HEIGHT_KEY);
1261
+ } catch {}
1262
+ }
1263
+ /** Read the last chosen list scope; "workspace" is the default. */
1264
+ function readScopeMode() {
1265
+ try {
1266
+ return (storage() && storage().getItem("dsh.aside-note.scope-mode")) === "session" ? "session" : SCOPE_MODE_DEFAULT;
1267
+ } catch {
1268
+ return SCOPE_MODE_DEFAULT;
1269
+ }
1270
+ }
1271
+ function writeScopeMode(mode) {
1272
+ try {
1273
+ const ls = storage();
1274
+ if (ls) ls.setItem(SCOPE_MODE_KEY, mode === "session" ? "session" : "workspace");
1275
+ } catch {}
1276
+ }
1277
+ /** Read the Enter-to-send preference. */
1278
+ function readSendShortcut() {
1279
+ try {
1280
+ const saved = storage() && storage().getItem("dsh.aside-note.send-shortcut");
1281
+ return saved === "enter" || saved === "ctrl-enter" ? saved : SEND_SHORTCUT_DEFAULT;
1282
+ } catch {
1283
+ return SEND_SHORTCUT_DEFAULT;
1284
+ }
1285
+ }
1286
+ function writeSendShortcut(value) {
1287
+ try {
1288
+ const ls = storage();
1289
+ if (ls) ls.setItem(SEND_SHORTCUT_KEY, value === "enter" ? "enter" : "ctrl-enter");
1290
+ } catch {}
1291
+ }
1292
+ /** Read the user's forward lead-in; an empty string means no prefix. */
1293
+ function readForwardPrefix() {
1294
+ try {
1295
+ const raw = storage() && storage().getItem("dsh.aside-note.forward-prefix");
1296
+ return typeof raw === "string" ? raw.slice(0, 80) : "";
1297
+ } catch {
1298
+ return "";
1299
+ }
1300
+ }
1301
+ function writeForwardPrefix(value) {
1302
+ try {
1303
+ const ls = storage();
1304
+ if (ls) ls.setItem(FORWARD_PREFIX_STORAGE_KEY, String(value || "").slice(0, 80));
1305
+ } catch {}
1306
+ }
1307
+ /** Remembered section state; corrupt or missing storage falls back to defaults. */
1308
+ function readSectionState() {
1309
+ const fallback = {
1310
+ open: SECTION_STATE_DEFAULT.open,
1311
+ done: SECTION_STATE_DEFAULT.done
1312
+ };
1313
+ const ls = storage();
1314
+ if (!ls) return fallback;
1315
+ try {
1316
+ const raw = ls.getItem(SECTION_STATE_KEY);
1317
+ if (!raw) return fallback;
1318
+ const saved = JSON.parse(raw);
1319
+ if (!saved || typeof saved !== "object") return fallback;
1320
+ return {
1321
+ open: typeof saved.open === "boolean" ? saved.open : fallback.open,
1322
+ done: typeof saved.done === "boolean" ? saved.done : fallback.done
1323
+ };
1324
+ } catch {
1325
+ return fallback;
1326
+ }
1327
+ }
1328
+ /** Persist the section state immediately; storage failures are ignored. */
1329
+ function writeSectionState(state) {
1330
+ const ls = storage();
1331
+ if (!ls) return;
1332
+ try {
1333
+ ls.setItem(SECTION_STATE_KEY, JSON.stringify({
1334
+ open: state.open === true,
1335
+ done: state.done === true
1336
+ }));
1337
+ } catch {}
1338
+ }
1339
+
1340
+ // src/client/storage/drafts.ts
1341
+ /**
1342
+ * The unsaved composer draft, so closing the panel never loses text.
1343
+ *
1344
+ * Records are keyed by draft scope, not by conversation: inside a workspace
1345
+ * every member session shares one buffer (`ws:<workspaceId>`), so switching
1346
+ * conversations or the workspace/session scope never strands half-typed text.
1347
+ * A session outside a workspace keeps its own key. Saving still writes the
1348
+ * list selected at that moment. The map field stays `sessions` so the existing
1349
+ * store keeps its shape.
1350
+ */
1351
+ const keyOf = (value) => value ? String(value) : "";
1352
+ /** Empty unsaved-draft store. */
1353
+ function emptyDraftStore() {
1354
+ return {
1355
+ version: 1,
1356
+ sessions: {}
1357
+ };
1358
+ }
1359
+ /** Read the unsaved composer draft; corrupt or unavailable reads as empty. */
1360
+ function readDraftStore() {
1361
+ const ls = storage();
1362
+ if (!ls) return emptyDraftStore();
1363
+ try {
1364
+ const raw = ls.getItem(DRAFT_STORAGE_KEY);
1365
+ if (!raw) return emptyDraftStore();
1366
+ const parsed = JSON.parse(raw);
1367
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return emptyDraftStore();
1368
+ const sessions = parsed.sessions;
1369
+ if (!sessions || typeof sessions !== "object" || Array.isArray(sessions)) return emptyDraftStore();
1370
+ return {
1371
+ version: 1,
1372
+ sessions
1373
+ };
1374
+ } catch {
1375
+ return emptyDraftStore();
1376
+ }
1377
+ }
1378
+ function writeDraftStore(store) {
1379
+ const ls = storage();
1380
+ if (!ls) return;
1381
+ try {
1382
+ ls.setItem(DRAFT_STORAGE_KEY, JSON.stringify(store));
1383
+ } catch {}
1384
+ }
1385
+ /** The unsaved composer draft of one scope (a workspace or a lone session). */
1386
+ function readScopeDrafts(key) {
1387
+ const id = keyOf(key);
1388
+ const record = id ? readDraftStore().sessions[id] : null;
1389
+ if (!record || typeof record !== "object" || Array.isArray(record)) return { add: "" };
1390
+ return { add: typeof record.add === "string" ? record.add : "" };
1391
+ }
1392
+ function pruneDraftScope(store, key) {
1393
+ const record = store.sessions[key];
1394
+ if (!record) return;
1395
+ if (!(typeof record.add === "string" && record.add.length > 0)) delete store.sessions[key];
1396
+ }
1397
+ function saveAddDraft(key, text) {
1398
+ const id = keyOf(key);
1399
+ if (!id) return;
1400
+ const store = readDraftStore();
1401
+ const record = store.sessions[id] || {};
1402
+ const value = String(text || "").slice(0, 280);
1403
+ if (value) record.add = value;
1404
+ else delete record.add;
1405
+ delete record.edits;
1406
+ store.sessions[id] = record;
1407
+ pruneDraftScope(store, id);
1408
+ writeDraftStore(store);
1409
+ }
1410
+ function clearAddDraft(key) {
1411
+ saveAddDraft(key, "");
1412
+ }
1413
+ /**
1414
+ * Move a conversation's pre-workspace draft under the shared workspace key.
1415
+ *
1416
+ * Runs once per workspace: the draft the user is looking at becomes the shared
1417
+ * buffer, and the workspace members' per-session copies are retired so that
1418
+ * clearing the buffer cannot resurrect them. A no-op outside a workspace, once
1419
+ * the shared key exists, or when the legacy record holds no text.
1420
+ */
1421
+ function ensureDraftScope(key, sessionId, sessionIds) {
1422
+ const target = keyOf(key);
1423
+ const source = keyOf(sessionId);
1424
+ if (!target || !source || target === source) return false;
1425
+ const members = (Array.isArray(sessionIds) ? sessionIds : []).map(keyOf).filter(Boolean);
1426
+ const store = readDraftStore();
1427
+ if (store.sessions[target]) return false;
1428
+ const legacy = store.sessions[source];
1429
+ if (!legacy || typeof legacy !== "object" || Array.isArray(legacy)) return false;
1430
+ const add = typeof legacy.add === "string" ? legacy.add.slice(0, 280) : "";
1431
+ if (!add) return false;
1432
+ store.sessions[target] = { add };
1433
+ for (const member of members) delete store.sessions[member];
1434
+ delete store.sessions[source];
1435
+ writeDraftStore(store);
1436
+ return true;
1437
+ }
1438
+
1439
+ // src/client/domain/id.ts
1440
+ /** Stable ids for notes and drafts. */
1441
+ function uid() {
1442
+ try {
1443
+ if (globalThis.crypto && typeof globalThis.crypto.randomUUID === "function") return globalThis.crypto.randomUUID();
1444
+ } catch {}
1445
+ return `todo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 9)}`;
1446
+ }
1447
+
1448
+ // src/client/domain/items.ts
1449
+ /** Note shape, ordering and relative time copy. */
1450
+ /**
1451
+ * Sanitize one session's notes. The store is user-editable, so treat
1452
+ * every field defensively and preserve the authored order.
1453
+ */
1454
+ function normalizeItems(items) {
1455
+ if (!Array.isArray(items)) return [];
1456
+ const seen = /* @__PURE__ */ new Set();
1457
+ const normalized = [];
1458
+ for (const raw of items) {
1459
+ if (!raw || typeof raw !== "object") continue;
1460
+ const text = String(raw.text || "").trim().slice(0, 280);
1461
+ if (!text) continue;
1462
+ let id = typeof raw.id === "string" && raw.id ? raw.id : uid();
1463
+ if (seen.has(id)) id = uid();
1464
+ seen.add(id);
1465
+ const done = raw.done === true;
1466
+ const createdAt = Number.isFinite(raw.createdAt) ? raw.createdAt : Date.now();
1467
+ const updatedAt = Number.isFinite(raw.updatedAt) ? raw.updatedAt : createdAt;
1468
+ normalized.push({
1469
+ id,
1470
+ text,
1471
+ done,
1472
+ createdAt,
1473
+ updatedAt,
1474
+ ...done && Number.isFinite(raw.completedAt) ? { completedAt: raw.completedAt } : {}
1475
+ });
1476
+ if (normalized.length >= 300) break;
1477
+ }
1478
+ return normalized;
1479
+ }
1480
+ /** Relative age copy for a note's creation stamp. */
1481
+ function ageLabel(time, say, localeId) {
1482
+ const stamp = Number.isFinite(time) ? time : Date.now();
1483
+ const elapsed = Math.max(0, Date.now() - stamp);
1484
+ if (elapsed < 6e4) return say("time.now");
1485
+ const minutes = Math.floor(elapsed / 6e4);
1486
+ if (minutes < 60) return say("time.minutes", { n: minutes });
1487
+ const hours = Math.floor(minutes / 60);
1488
+ if (hours < 24) return say("time.hours", { n: hours });
1489
+ const days = Math.floor(hours / 24);
1490
+ if (days < 7) return say("time.days", { n: days });
1491
+ try {
1492
+ return new Intl.DateTimeFormat(localeId, {
1493
+ month: "short",
1494
+ day: "numeric"
1495
+ }).format(stamp);
1496
+ } catch {
1497
+ return "";
1498
+ }
1499
+ }
1500
+ /**
1501
+ * Best-known completion stamp for a done note. Newer records carry
1502
+ * `completedAt`; older ones only have `updatedAt`, so fall back in order
1503
+ * until a finite time is found. Returns 0 when the item has no usable stamp.
1504
+ */
1505
+ function completedStamp(item) {
1506
+ if (!item) return 0;
1507
+ const candidates = [
1508
+ item.completedAt,
1509
+ item.updatedAt,
1510
+ item.createdAt
1511
+ ];
1512
+ for (const time of candidates) if (Number.isFinite(time)) return time;
1513
+ return 0;
1514
+ }
1515
+ /** Newest completion first; updatedAt then createdAt keep equal stamps stable. */
1516
+ function compareDoneItems(a, b) {
1517
+ const byCompletion = completedStamp(b) - completedStamp(a);
1518
+ if (byCompletion) return byCompletion;
1519
+ const aUpdated = Number.isFinite(a && a.updatedAt) ? a.updatedAt : 0;
1520
+ const bUpdated = Number.isFinite(b && b.updatedAt) ? b.updatedAt : 0;
1521
+ if (aUpdated !== bUpdated) return bUpdated - aUpdated;
1522
+ const aCreated = Number.isFinite(a && a.createdAt) ? a.createdAt : 0;
1523
+ return (Number.isFinite(b && b.createdAt) ? b.createdAt : 0) - aCreated;
1524
+ }
1525
+ /** Done notes show creation and completion age; open ones show creation age only. */
1526
+ function metaLabel(item, say, localeId) {
1527
+ const created = ageLabel(item && item.createdAt, say, localeId);
1528
+ if (!item || item.done !== true) return created;
1529
+ return say("time.createdDone", {
1530
+ created,
1531
+ completed: ageLabel(completedStamp(item) || (item ? item.createdAt : 0), say, localeId)
1532
+ });
1533
+ }
1534
+
1535
+ // src/client/storage/events.ts
1536
+ /**
1537
+ * Same-tab change bus.
1538
+ *
1539
+ * The `storage` event only crosses tabs, so a write here wakes the readers in
1540
+ * this tab — the header count and an open panel.
1541
+ */
1542
+ /** Same-tab subscribers, so the composer dock's count follows panel edits. */
1543
+ const TODO_LISTENERS = /* @__PURE__ */ new Set();
1544
+ /** Notify same-tab readers after a successful write (storage events only cross tabs). */
1545
+ function notifyTodoChange() {
1546
+ for (const listener of TODO_LISTENERS) try {
1547
+ listener();
1548
+ } catch (error) {
1549
+ console.error("dsh-sideby-note: listener failed", error);
1550
+ }
1551
+ }
1552
+
1553
+ // src/client/storage/session.ts
1554
+ /**
1555
+ * Session-scoped notes in one localStorage record.
1556
+ *
1557
+ * The shape stays at v1: workspace notes now live under
1558
+ * `WORKSPACE_STORAGE_KEY`, so the session key existing users already have is
1559
+ * never rewritten into a new schema.
1560
+ */
1561
+ /** Empty note store. */
1562
+ function emptySessionStore() {
1563
+ return {
1564
+ version: 1,
1565
+ sessions: {}
1566
+ };
1567
+ }
1568
+ const bucket$1 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
1569
+ /** Read the whole note store; corrupt or unavailable reads as empty. */
1570
+ function readSessionStore() {
1571
+ const ls = storage();
1572
+ if (!ls) return emptySessionStore();
1573
+ try {
1574
+ const raw = ls.getItem(SESSION_STORAGE_KEY);
1575
+ if (!raw) return emptySessionStore();
1576
+ const parsed = JSON.parse(raw);
1577
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return emptySessionStore();
1578
+ return {
1579
+ version: 1,
1580
+ sessions: bucket$1(parsed.sessions)
1581
+ };
1582
+ } catch {
1583
+ return emptySessionStore();
1584
+ }
1585
+ }
1586
+ /** Persist the whole session store; the single writer for this key. */
1587
+ function writeSessionStore(store) {
1588
+ const ls = storage();
1589
+ if (!ls) return false;
1590
+ try {
1591
+ ls.setItem(SESSION_STORAGE_KEY, JSON.stringify({
1592
+ version: 1,
1593
+ sessions: bucket$1(store && store.sessions)
1594
+ }));
1595
+ notifyTodoChange();
1596
+ return true;
1597
+ } catch {
1598
+ return false;
1599
+ }
1600
+ }
1601
+ /** Read one session's memo record. */
1602
+ function readSessionRecord(sessionId) {
1603
+ const key = sessionId ? String(sessionId) : "";
1604
+ if (!key) return {
1605
+ items: [],
1606
+ updatedAt: 0
1607
+ };
1608
+ const record = readSessionStore().sessions[key];
1609
+ return {
1610
+ items: normalizeItems(record && record.items),
1611
+ updatedAt: record && Number.isFinite(record.updatedAt) ? record.updatedAt : 0
1612
+ };
1613
+ }
1614
+ /** Persist one session's memo record. */
1615
+ function writeSessionRecord(sessionId, record) {
1616
+ const key = sessionId ? String(sessionId) : "";
1617
+ if (!key) return false;
1618
+ const store = readSessionStore();
1619
+ store.sessions[key] = {
1620
+ sessionId: key,
1621
+ updatedAt: record.updatedAt || Date.now(),
1622
+ items: normalizeItems(record.items)
1623
+ };
1624
+ return writeSessionStore(store);
1625
+ }
1626
+
1627
+ // src/client/storage/workspace.ts
1628
+ /**
1629
+ * Workspace-scoped notes.
1630
+ *
1631
+ * Stored under `WORKSPACE_STORAGE_KEY`, beside the session key, so adding
1632
+ * workspace lists never changes the shape of existing per-session data. One
1633
+ * list is shared by every session of a workspace. The first time a workspace
1634
+ * is seen, notes already written per session are folded in once;
1635
+ * `seededSessionIds` records that so a later delete is not undone by the merge
1636
+ * running again.
1637
+ */
1638
+ const text$1 = (value) => value ? String(value) : "";
1639
+ const bucket = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
1640
+ function seededOf(record) {
1641
+ const raw = record && record.seededSessionIds;
1642
+ if (!Array.isArray(raw)) return [];
1643
+ const seen = /* @__PURE__ */ new Set();
1644
+ const next = [];
1645
+ for (const value of raw) {
1646
+ const id = text$1(value);
1647
+ if (!id || seen.has(id)) continue;
1648
+ seen.add(id);
1649
+ next.push(id);
1650
+ }
1651
+ return next;
1652
+ }
1653
+ /** Empty workspace-note store. */
1654
+ function emptyWorkspaceStore() {
1655
+ return {
1656
+ version: 1,
1657
+ workspaces: {}
1658
+ };
1659
+ }
1660
+ /** Read the workspace-note store; corrupt or unavailable reads as empty. */
1661
+ function readWorkspaceStore() {
1662
+ const ls = storage();
1663
+ if (!ls) return emptyWorkspaceStore();
1664
+ try {
1665
+ const raw = ls.getItem(WORKSPACE_STORAGE_KEY);
1666
+ if (!raw) return emptyWorkspaceStore();
1667
+ const parsed = JSON.parse(raw);
1668
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return emptyWorkspaceStore();
1669
+ return {
1670
+ version: 1,
1671
+ workspaces: bucket(parsed.workspaces)
1672
+ };
1673
+ } catch {
1674
+ return emptyWorkspaceStore();
1675
+ }
1676
+ }
1677
+ /** Persist the whole workspace-note store. */
1678
+ function writeWorkspaceStore(store) {
1679
+ const ls = storage();
1680
+ if (!ls) return false;
1681
+ try {
1682
+ ls.setItem(WORKSPACE_STORAGE_KEY, JSON.stringify({
1683
+ version: 1,
1684
+ workspaces: bucket(store && store.workspaces)
1685
+ }));
1686
+ notifyTodoChange();
1687
+ return true;
1688
+ } catch {
1689
+ return false;
1690
+ }
1691
+ }
1692
+ /** One workspace's memo record. */
1693
+ function readWorkspaceRecord(workspaceId) {
1694
+ const key = text$1(workspaceId);
1695
+ if (!key) return {
1696
+ items: [],
1697
+ updatedAt: 0,
1698
+ seededSessionIds: []
1699
+ };
1700
+ const record = readWorkspaceStore().workspaces[key];
1701
+ return {
1702
+ items: normalizeItems(record && record.items),
1703
+ updatedAt: record && Number.isFinite(record.updatedAt) ? record.updatedAt : 0,
1704
+ seededSessionIds: seededOf(record)
1705
+ };
1706
+ }
1707
+ /** Persist one workspace's memo record. */
1708
+ function writeWorkspaceRecord(workspaceId, record) {
1709
+ const key = text$1(workspaceId);
1710
+ if (!key) return false;
1711
+ const store = readWorkspaceStore();
1712
+ const previous = store.workspaces[key];
1713
+ const seededSource = Array.isArray(record.seededSessionIds) ? record : previous;
1714
+ store.workspaces[key] = {
1715
+ workspaceId: key,
1716
+ updatedAt: record.updatedAt || Date.now(),
1717
+ items: normalizeItems(record.items),
1718
+ seededSessionIds: seededOf(seededSource)
1719
+ };
1720
+ return writeWorkspaceStore(store);
1721
+ }
1722
+ /**
1723
+ * Fold the member sessions' existing notes into the workspace list once.
1724
+ * Returns whether the store changed; repeated calls are cheap and idempotent.
1725
+ */
1726
+ function ensureWorkspaceRecord(workspaceId, sessionIds) {
1727
+ const key = text$1(workspaceId);
1728
+ if (!key) return false;
1729
+ const previous = readWorkspaceStore().workspaces[key];
1730
+ const seeded = new Set(seededOf(previous));
1731
+ const items = normalizeItems(previous && previous.items);
1732
+ const seen = new Set(items.map((item) => item.id));
1733
+ let changed = !previous;
1734
+ if (!changed && Array.isArray(sessionIds)) for (const value of sessionIds) {
1735
+ const sessionId = text$1(value);
1736
+ if (!sessionId) continue;
1737
+ if (!seeded.has(sessionId)) {
1738
+ changed = true;
1739
+ break;
1740
+ }
1741
+ }
1742
+ if (!changed) return false;
1743
+ const sessionStore = readSessionStore();
1744
+ for (const value of Array.isArray(sessionIds) ? sessionIds : []) {
1745
+ const sessionId = text$1(value);
1746
+ if (!sessionId || seeded.has(sessionId)) continue;
1747
+ seeded.add(sessionId);
1748
+ changed = true;
1749
+ const sessionRecord = sessionStore.sessions[sessionId];
1750
+ for (const item of normalizeItems(sessionRecord && sessionRecord.items)) {
1751
+ if (seen.has(item.id)) continue;
1752
+ seen.add(item.id);
1753
+ items.push(item);
1754
+ }
1755
+ }
1756
+ return writeWorkspaceRecord(key, {
1757
+ items,
1758
+ updatedAt: previous && Number.isFinite(previous.updatedAt) ? previous.updatedAt : Date.now(),
1759
+ seededSessionIds: [...seeded]
1760
+ });
1761
+ }
1762
+
1763
+ // src/client/ui/primitives.ts
1764
+ /**
1765
+ * Shared glyphs and the tooltip wrapper.
1766
+ *
1767
+ * Glyphs come from the product icon set; this plugin draws none of its own, so
1768
+ * stroke weight, optical size and currentColor stay consistent with the shell.
1769
+ * Tooltip and Toast are the seeded primitives — the bundle keeps them external.
1770
+ */
1771
+ const h$12 = react.default.createElement;
1772
+ const PRIMITIVES = _deepseek_ai_dsh_client_ui_primitives;
1773
+ const Tooltip = typeof PRIMITIVES.Tooltip === "function" ? PRIMITIVES.Tooltip : null;
1774
+ const Toast = typeof PRIMITIVES.Toast === "function" ? PRIMITIVES.Toast : null;
1775
+ const icon = (name) => typeof PRIMITIVES[name] === "function" ? PRIMITIVES[name] : null;
1776
+ /**
1777
+ * Glyphs come from the shared product icon set; this plugin draws none of
1778
+ * its own, so stroke weight, optical size and currentColor stay consistent
1779
+ * with the surrounding shell.
1780
+ */
1781
+ function Glyph(props) {
1782
+ const Component = icon(props.name);
1783
+ if (!Component) return null;
1784
+ return h$12(Component, {
1785
+ size: props.size,
1786
+ className: props.className
1787
+ });
1788
+ }
1789
+ const IconCheck = (props) => h$12(Glyph, {
1790
+ name: "IconCheckOutlineMedium",
1791
+ size: props && props.size ? props.size : 12
1792
+ });
1793
+ const IconCopy = () => h$12(Glyph, {
1794
+ name: "IconCopyOutlineRegular",
1795
+ size: 14
1796
+ });
1797
+ const IconForward = () => h$12(Glyph, {
1798
+ name: "IconShareOutlineRegular",
1799
+ size: 14
1800
+ });
1801
+ const IconGear = () => h$12(Glyph, {
1802
+ name: "IconSettingsOutlineRegular",
1803
+ size: 14
1804
+ });
1805
+ /**
1806
+ * Rewind is the product refresh arc mirrored to run counter-clockwise (↺):
1807
+ * the set has no undo glyph, and flipping keeps the shell's stroke and size.
1808
+ */
1809
+ const IconRewind = () => h$12(Glyph, {
1810
+ name: "IconRefreshOutlineRegular",
1811
+ size: 14,
1812
+ className: "dsh-an-glyphFlip"
1813
+ });
1814
+ const IconChevron = () => h$12(Glyph, {
1815
+ name: "IconChevronRightOutlineRegular",
1816
+ size: 12
1817
+ });
1818
+ const IconEmpty = () => h$12(Glyph, {
1819
+ name: "IconChecklistOutlineRegular",
1820
+ size: 18
1821
+ });
1822
+ const IconClose = () => h$12(Glyph, {
1823
+ name: "IconCloseOutlineRegular",
1824
+ size: 14
1825
+ });
1826
+ /** Wrap one icon-only control in the shared tooltip; a bare button when absent. */
1827
+ function withTooltip(label, node) {
1828
+ if (!Tooltip) return node;
1829
+ return h$12(Tooltip, {
1830
+ label,
1831
+ side: "top",
1832
+ portal: true,
1833
+ gap: 6
1834
+ }, node);
1835
+ }
1836
+
1837
+ // src/client/ui/toastSeat.ts
1838
+ /** Frame-wide toast seat: one notice at a time, dismissed when it fades. */
1839
+ const h$11 = react.default.createElement;
1840
+ const TOAST_COPY = {
1841
+ copied: {
1842
+ key: "toast.copied",
1843
+ tone: "success"
1844
+ },
1845
+ forwarded: {
1846
+ key: "toast.forwarded",
1847
+ tone: "success"
1848
+ },
1849
+ unforwarded: {
1850
+ key: "toast.unforwarded",
1851
+ tone: "success"
1852
+ },
1853
+ recalled: {
1854
+ key: "toast.recalled",
1855
+ tone: "success"
1856
+ },
1857
+ recallBlocked: { key: "toast.recallBlocked" },
1858
+ cleared: {
1859
+ key: "toast.cleared",
1860
+ tone: "success"
1861
+ },
1862
+ copyFailed: { key: "toast.copyFailed" },
1863
+ forwardFailed: { key: "toast.forwardFailed" },
1864
+ saveFailed: { key: "toast.saveFailed" }
1865
+ };
1866
+ const WarningIcon = icon("IconWarningOutlineRegular");
1867
+ /**
1868
+ * Settled outcomes (copy, forward, recall, write failure) live in the frame,
1869
+ * not inside the panel: the panel unmounts on close, the banner must not.
1870
+ */
1871
+ function createToastSeat(tr) {
1872
+ const source = (() => {
1873
+ let notice = null;
1874
+ let sequence = 0;
1875
+ const listeners = /* @__PURE__ */ new Set();
1876
+ const publish = (next) => {
1877
+ notice = next;
1878
+ for (const listener of listeners) listener();
1879
+ };
1880
+ return {
1881
+ hooks: { notice: {
1882
+ getSnapshot: () => notice,
1883
+ subscribe: (listener) => {
1884
+ listeners.add(listener);
1885
+ return () => {
1886
+ listeners.delete(listener);
1887
+ };
1888
+ }
1889
+ } },
1890
+ show(kind) {
1891
+ sequence += 1;
1892
+ publish({
1893
+ kind,
1894
+ sequence
1895
+ });
1896
+ },
1897
+ dismiss() {
1898
+ publish(null);
1899
+ }
1900
+ };
1901
+ })();
1902
+ /** The slot the layout mounts once; it owns the only visible notice. */
1903
+ function ToastHost(props) {
1904
+ const notice = react.default.useSyncExternalStore(source.hooks.notice.subscribe, source.hooks.notice.getSnapshot);
1905
+ if (!notice || !Toast) return null;
1906
+ const copy = TOAST_COPY[notice.kind] || TOAST_COPY.saveFailed;
1907
+ const bound = props && typeof props.t === "function" ? props.t(copy.key) : "";
1908
+ const text = bound && bound !== copy.key ? bound : tr(copy.key);
1909
+ return h$11(Toast, {
1910
+ key: notice.sequence,
1911
+ text,
1912
+ tone: copy.tone,
1913
+ icon: copy.tone ? void 0 : WarningIcon ? h$11(WarningIcon, { size: 16 }) : void 0,
1914
+ onDone: source.dismiss
1915
+ });
1916
+ }
1917
+ return {
1918
+ show: source.show,
1919
+ ToastHost
1920
+ };
1921
+ }
1922
+
1923
+ // src/client/ui/headerEntry.ts
1924
+ /**
1925
+ * The host-owned notes button in the conversation header.
1926
+ *
1927
+ * It is a plain DOM node beside the shell's utilities row: a React portal there
1928
+ * would be reconciled away. The glyph is inlined for the same reason.
1929
+ */
1930
+ const HEADER_ICON = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.3\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M3.25 2.75h6.5l3 3v7.5c0 .55-.45 1-1 1H3.25c-.55 0-1-.45-1-1V3.75c0-.55.45-1 1-1Z\"/><path d=\"M9.75 2.75v3h3\"/><path d=\"M4.9 7.6h5.4M4.9 9.9h3.6\" stroke-linecap=\"round\"/></svg>";
1931
+ function createHeaderEntry({ getSessionId, getActiveAnchor, getLocaleId, tr, onOpen }) {
1932
+ const refresh = () => {
1933
+ const sessionId = getSessionId();
1934
+ let button = document.querySelector(".dsh-an-headerBtn");
1935
+ if (!sessionId) {
1936
+ if (button) button.remove();
1937
+ return;
1938
+ }
1939
+ const ready = sessionReadyFor(sessionId);
1940
+ const workspace = workspaceScopeForSession(sessionId);
1941
+ if (!ready && !workspace) {
1942
+ if (button) button.remove();
1943
+ return;
1944
+ }
1945
+ const utilities = document.querySelector("[class*=\"_headerUtilities\"]");
1946
+ const corner = ready ? null : document.querySelector("[class*=\"_headerCorner\"]");
1947
+ const host = utilities || corner;
1948
+ if (!host) {
1949
+ if (button) button.remove();
1950
+ return;
1951
+ }
1952
+ const scope = scopeForSession(sessionId, readScopeMode());
1953
+ const store = readSessionStore();
1954
+ const open = (scope.kind === "workspace" ? readWorkspaceRecord(scope.id).items : normalizeItems(store.sessions[sessionId] && store.sessions[sessionId].items)).filter((item) => !item.done).length;
1955
+ if (!button) {
1956
+ button = document.createElement("button");
1957
+ button.type = "button";
1958
+ button.className = "dsh-an-headerBtn";
1959
+ button.addEventListener("pointerdown", (event) => event.stopPropagation());
1960
+ button.addEventListener("click", (event) => {
1961
+ event.preventDefault();
1962
+ event.stopPropagation();
1963
+ onOpen(getSessionId(), button);
1964
+ });
1965
+ }
1966
+ if (host === corner) {
1967
+ if (host.firstElementChild !== button) host.insertBefore(button, host.firstElementChild);
1968
+ } else if (button.parentElement !== host) host.appendChild(button);
1969
+ button.dataset.anchor = host === utilities ? "utilities" : "corner";
1970
+ button.dataset.active = getActiveAnchor() === button ? "true" : "false";
1971
+ button.dataset.scope = scope.kind;
1972
+ const signature = `${getLocaleId()}:${scopeKey(scope)}:${open}`;
1973
+ if (button.dataset.signature !== signature) {
1974
+ const icon = document.createElement("span");
1975
+ icon.className = "dsh-an-headerIcon";
1976
+ icon.innerHTML = HEADER_ICON;
1977
+ button.replaceChildren(icon);
1978
+ if (open > 0) {
1979
+ const count = document.createElement("span");
1980
+ count.className = "dsh-an-headerCount";
1981
+ count.textContent = open > 99 ? "99+" : String(open);
1982
+ button.appendChild(count);
1983
+ }
1984
+ button.dataset.signature = signature;
1985
+ }
1986
+ button.dataset.sessionId = sessionId;
1987
+ button.title = open > 0 ? tr("header.tooltip", { n: open }) : tr("header.tooltipEmpty");
1988
+ button.setAttribute("aria-label", open > 0 ? `${tr("dock.open")}, ${tr("dock.count", { n: open })}` : tr("dock.open"));
1989
+ };
1990
+ /** Watch the store, the DOM and the viewport; returns the cleanup. */
1991
+ const attach = (onDispose) => {
1992
+ let scheduled = false;
1993
+ const schedule = () => {
1994
+ if (scheduled) return;
1995
+ scheduled = true;
1996
+ requestAnimationFrame(() => {
1997
+ scheduled = false;
1998
+ refresh();
1999
+ });
2000
+ };
2001
+ const onStorage = (event) => {
2002
+ if (event.key === "dsh.aside-note" || event.key === "dsh.aside-note.workspaces" || event.key === "dsh.aside-note.scope-mode") schedule();
2003
+ };
2004
+ TODO_LISTENERS.add(schedule);
2005
+ window.addEventListener("storage", onStorage);
2006
+ const observer = new MutationObserver(schedule);
2007
+ observer.observe(document.body, {
2008
+ childList: true,
2009
+ subtree: true
2010
+ });
2011
+ refresh();
2012
+ return () => {
2013
+ TODO_LISTENERS.delete(schedule);
2014
+ window.removeEventListener("storage", onStorage);
2015
+ observer.disconnect();
2016
+ onDispose();
2017
+ for (const button of document.querySelectorAll(".dsh-an-headerBtn")) button.remove();
2018
+ };
2019
+ };
2020
+ return {
2021
+ refresh,
2022
+ attach
2023
+ };
2024
+ }
2025
+
2026
+ // src/client/ui/useSessionMemoStore.ts
2027
+ /** Notes for the active scope plus a synchronous writer that never invents state. */
2028
+ /** Read the record the current scope renders. */
2029
+ function readScope(scope) {
2030
+ return scope.kind === "workspace" ? readWorkspaceRecord(scope.id) : readSessionRecord(scope.id);
2031
+ }
2032
+ /** Write the record the current scope renders. */
2033
+ function writeScope(scope, record) {
2034
+ return scope.kind === "workspace" ? writeWorkspaceRecord(scope.id, record) : writeSessionRecord(scope.id, record);
2035
+ }
2036
+ /** Notes of one list (a workspace, or a single session) and their writer. */
2037
+ function useMemoStore(scope) {
2038
+ const kind = scope && scope.kind === "workspace" ? "workspace" : "session";
2039
+ const id = scope && scope.id ? String(scope.id) : "";
2040
+ const scopeRef = react.default.useRef({
2041
+ kind,
2042
+ id
2043
+ });
2044
+ scopeRef.current = {
2045
+ kind,
2046
+ id
2047
+ };
2048
+ const [record, setRecord] = react.default.useState(() => readScope(scopeRef.current));
2049
+ const [syncError, setSyncError] = react.default.useState(false);
2050
+ const recordRef = react.default.useRef(record);
2051
+ recordRef.current = record;
2052
+ react.default.useEffect(() => {
2053
+ setRecord(readScope(scopeRef.current));
2054
+ setSyncError(false);
2055
+ }, [kind, id]);
2056
+ react.default.useEffect(() => {
2057
+ const onStorage = (event) => {
2058
+ if (event.key !== "dsh.aside-note" && event.key !== "dsh.aside-note.workspaces") return;
2059
+ setRecord(readScope(scopeRef.current));
2060
+ };
2061
+ const onLocal = () => setRecord(readScope(scopeRef.current));
2062
+ TODO_LISTENERS.add(onLocal);
2063
+ window.addEventListener("storage", onStorage);
2064
+ return () => {
2065
+ TODO_LISTENERS.delete(onLocal);
2066
+ window.removeEventListener("storage", onStorage);
2067
+ };
2068
+ }, []);
2069
+ return {
2070
+ record,
2071
+ syncError,
2072
+ commit: react.default.useCallback((updater) => {
2073
+ const current = recordRef.current || {
2074
+ items: [],
2075
+ updatedAt: 0
2076
+ };
2077
+ const nextItems = normalizeItems(updater(current.items || []));
2078
+ const next = {
2079
+ ...current,
2080
+ items: nextItems,
2081
+ updatedAt: Date.now()
2082
+ };
2083
+ const ok = writeScope(scopeRef.current, next);
2084
+ setSyncError(!ok);
2085
+ if (!ok) return false;
2086
+ recordRef.current = next;
2087
+ setRecord(next);
2088
+ return true;
2089
+ }, [])
2090
+ };
2091
+ }
2092
+
2093
+ // src/client/ui/position.ts
2094
+ /**
2095
+ * Mark the section head that is actually pinned to the scroller's top edge.
2096
+ * Sticky heads stay transparent in flow; only the pinned one takes the menu
2097
+ * group-header fill, so no full-width layer sits over the list at rest.
2098
+ */
2099
+ function syncStickyHeads(node) {
2100
+ const areaTop = node.getBoundingClientRect().top;
2101
+ for (const head of node.querySelectorAll(".dsh-an-sectionHead, .dsh-an-doneHead")) {
2102
+ const section = head.parentElement;
2103
+ if (!section) continue;
2104
+ const rect = section.getBoundingClientRect();
2105
+ head.toggleAttribute("data-stuck", rect.top < areaTop && rect.bottom > areaTop);
2106
+ }
2107
+ }
2108
+ /**
2109
+ * Frame-owned top safety margin for floating surfaces. Read from the layout
2110
+ * rather than baked in, so macOS window chrome and the Windows titlebar both
2111
+ * keep their clearance without this page touching the global variable.
2112
+ */
2113
+ function overlayTopFloor(margin) {
2114
+ try {
2115
+ const raw = getComputedStyle(document.body).getPropertyValue("--dsh-frame-overlay-top").trim();
2116
+ const value = Number.parseFloat(raw);
2117
+ if (Number.isFinite(value) && value > 0) return Math.max(margin, value);
2118
+ } catch {}
2119
+ return margin;
2120
+ }
2121
+ /**
2122
+ * Fixed panel placement: a right-side panel for the experimental entry,
2123
+ * otherwise below the anchor. Both stay inside the viewport margin, and the
2124
+ * gap side is only abandoned when the opposite side genuinely fits.
2125
+ */
2126
+ function memoPopoverStyle(anchor, placement, requestedWidth, requestedHeight) {
2127
+ const margin = window.innerWidth <= 480 ? 12 : 16;
2128
+ const topFloor = overlayTopFloor(margin);
2129
+ const available = Math.max(280, window.innerWidth - margin * 2);
2130
+ const width = Math.max(280, Math.min(720, available, requestedWidth || 360));
2131
+ if (placement === "right") {
2132
+ const rect = anchor && anchor.isConnected ? anchor.getBoundingClientRect() : null;
2133
+ let desiredRight = rect && rect.width > 0 ? rect.right : window.innerWidth - margin;
2134
+ const sidebar = [...document.querySelectorAll("[data-sidebar-right-panel][data-sidebar-right-open]")].find((node) => {
2135
+ const box = node.getBoundingClientRect();
2136
+ return box.width > 24 && box.left > 0 && box.left < window.innerWidth - 24;
2137
+ });
2138
+ if (sidebar) desiredRight = Math.min(desiredRight, sidebar.getBoundingClientRect().left - 8);
2139
+ const rightInset = Math.max(margin, Math.min(window.innerWidth - margin, window.innerWidth - desiredRight));
2140
+ const top = rect && rect.width > 0 ? Math.max(topFloor, Math.round(rect.bottom + 8)) : topFloor;
2141
+ const maxHeight = Math.max(160, window.innerHeight - top - margin);
2142
+ const height = requestedHeight ? Math.max(Math.min(240, maxHeight), Math.min(maxHeight, requestedHeight)) : 0;
2143
+ const style = {
2144
+ right: `${rightInset}px`,
2145
+ left: "auto",
2146
+ top: `${top}px`,
2147
+ width: `${width}px`,
2148
+ maxHeight: `${maxHeight}px`
2149
+ };
2150
+ if (height) style.height = `${height}px`;
2151
+ return style;
2152
+ }
2153
+ const maxHeight = Math.max(160, Math.min(460, window.innerHeight - topFloor - margin));
2154
+ if (!anchor) return {
2155
+ left: `${margin}px`,
2156
+ top: `${topFloor}px`,
2157
+ width: `${width}px`,
2158
+ maxHeight: `${maxHeight}px`
2159
+ };
2160
+ const rect = anchor.getBoundingClientRect();
2161
+ const left = rect.left < 420 ? Math.max(margin, rect.left) : Math.max(margin, Math.min(rect.right - width, window.innerWidth - width - margin));
2162
+ let top = rect.bottom + 8;
2163
+ if (top + maxHeight > window.innerHeight - margin) top = Math.max(topFloor, rect.top - maxHeight - 8);
2164
+ return {
2165
+ left: `${left}px`,
2166
+ top: `${top}px`,
2167
+ width: `${width}px`,
2168
+ maxHeight: `${maxHeight}px`
2169
+ };
2170
+ }
2171
+
2172
+ // src/client/ui/usePanelGeometry.ts
2173
+ /** Panel geometry: remembered width/height, pointer and keyboard resize, placement. */
2174
+ function usePanelGeometry(anchorRef, placement, panelRef) {
2175
+ const [panelWidth, setPanelWidth] = react.default.useState(readPanelWidth);
2176
+ const [panelHeight, setPanelHeight] = react.default.useState(readPanelHeight);
2177
+ const [style, setStyle] = react.default.useState(() => memoPopoverStyle(anchorRef.current, placement, panelWidth, panelHeight));
2178
+ const panelWidthRef = react.default.useRef(panelWidth);
2179
+ const panelHeightRef = react.default.useRef(panelHeight);
2180
+ const lastStyleRef = react.default.useRef("");
2181
+ const updatePosition = react.default.useCallback(() => {
2182
+ if (anchorRef.current || placement === "right") {
2183
+ const next = memoPopoverStyle(anchorRef.current, placement, panelWidth, panelHeight);
2184
+ const key = JSON.stringify(next);
2185
+ if (key === lastStyleRef.current) return;
2186
+ lastStyleRef.current = key;
2187
+ setStyle(next);
2188
+ }
2189
+ }, [
2190
+ anchorRef,
2191
+ placement,
2192
+ panelWidth,
2193
+ panelHeight
2194
+ ]);
2195
+ react.default.useEffect(() => {
2196
+ panelWidthRef.current = panelWidth;
2197
+ }, [panelWidth]);
2198
+ react.default.useEffect(() => {
2199
+ panelHeightRef.current = panelHeight;
2200
+ }, [panelHeight]);
2201
+ const clampPanelWidth = (value) => {
2202
+ const max = Math.min(720, Math.max(280, window.innerWidth - 32));
2203
+ return Math.max(280, Math.min(max, value));
2204
+ };
2205
+ const commitPanelWidth = (value) => {
2206
+ const next = clampPanelWidth(value);
2207
+ panelWidthRef.current = next;
2208
+ setPanelWidth(next);
2209
+ writePanelWidth(next);
2210
+ };
2211
+ const startPanelResize = (event) => {
2212
+ if (event.button !== 0) return;
2213
+ event.preventDefault();
2214
+ const startX = event.clientX;
2215
+ const startWidth = panelWidthRef.current;
2216
+ const onMove = (moveEvent) => {
2217
+ const next = clampPanelWidth(startWidth + (startX - moveEvent.clientX));
2218
+ panelWidthRef.current = next;
2219
+ setPanelWidth(next);
2220
+ };
2221
+ const onUp = () => {
2222
+ window.removeEventListener("pointermove", onMove);
2223
+ window.removeEventListener("pointerup", onUp);
2224
+ document.body.style.userSelect = "";
2225
+ document.body.style.cursor = "";
2226
+ writePanelWidth(panelWidthRef.current);
2227
+ };
2228
+ window.addEventListener("pointermove", onMove);
2229
+ window.addEventListener("pointerup", onUp, { once: true });
2230
+ document.body.style.userSelect = "none";
2231
+ document.body.style.cursor = "ew-resize";
2232
+ };
2233
+ const onPanelResizeKeyDown = (event) => {
2234
+ if (event.key === "ArrowLeft") {
2235
+ event.preventDefault();
2236
+ commitPanelWidth(panelWidthRef.current + 16);
2237
+ } else if (event.key === "ArrowRight") {
2238
+ event.preventDefault();
2239
+ commitPanelWidth(panelWidthRef.current - 16);
2240
+ } else if (event.key === "Home") {
2241
+ event.preventDefault();
2242
+ commitPanelWidth(360);
2243
+ }
2244
+ };
2245
+ const clampPanelHeight = (value) => {
2246
+ const max = Math.max(240, window.innerHeight - 64 - 16);
2247
+ return Math.max(240, Math.min(max, value));
2248
+ };
2249
+ const commitPanelHeight = (value) => {
2250
+ const next = value > 0 ? clampPanelHeight(value) : 0;
2251
+ panelHeightRef.current = next;
2252
+ setPanelHeight(next);
2253
+ writePanelHeight(next);
2254
+ };
2255
+ const startPanelHeightResize = (event) => {
2256
+ if (event.button !== 0) return;
2257
+ event.preventDefault();
2258
+ const startY = event.clientY;
2259
+ const startHeight = panelHeightRef.current || (panelRef.current ? panelRef.current.getBoundingClientRect().height : 360);
2260
+ const onMove = (moveEvent) => {
2261
+ const next = clampPanelHeight(startHeight + (moveEvent.clientY - startY));
2262
+ panelHeightRef.current = next;
2263
+ setPanelHeight(next);
2264
+ };
2265
+ const onUp = () => {
2266
+ window.removeEventListener("pointermove", onMove);
2267
+ window.removeEventListener("pointerup", onUp);
2268
+ document.body.style.userSelect = "";
2269
+ document.body.style.cursor = "";
2270
+ writePanelHeight(panelHeightRef.current);
2271
+ };
2272
+ window.addEventListener("pointermove", onMove);
2273
+ window.addEventListener("pointerup", onUp, { once: true });
2274
+ document.body.style.userSelect = "none";
2275
+ document.body.style.cursor = "ns-resize";
2276
+ };
2277
+ const onPanelHeightKeyDown = (event) => {
2278
+ if (event.key === "ArrowDown") {
2279
+ event.preventDefault();
2280
+ commitPanelHeight((panelHeightRef.current || 360) + 16);
2281
+ } else if (event.key === "ArrowUp") {
2282
+ event.preventDefault();
2283
+ commitPanelHeight((panelHeightRef.current || 360) - 16);
2284
+ } else if (event.key === "Home") {
2285
+ event.preventDefault();
2286
+ commitPanelHeight(0);
2287
+ }
2288
+ };
2289
+ react.default.useLayoutEffect(() => {
2290
+ updatePosition();
2291
+ window.addEventListener("resize", updatePosition);
2292
+ window.addEventListener("scroll", updatePosition, true);
2293
+ return () => {
2294
+ window.removeEventListener("resize", updatePosition);
2295
+ window.removeEventListener("scroll", updatePosition, true);
2296
+ };
2297
+ }, [updatePosition]);
2298
+ react.default.useEffect(() => {
2299
+ const anchor = anchorRef.current;
2300
+ if (!anchor || typeof ResizeObserver !== "function") return void 0;
2301
+ const target = anchor.closest("[class*=\"_header\"]") || anchor;
2302
+ const observer = new ResizeObserver(updatePosition);
2303
+ observer.observe(target);
2304
+ return () => observer.disconnect();
2305
+ }, [anchorRef, updatePosition]);
2306
+ react.default.useEffect(() => {
2307
+ const timer = window.setInterval(updatePosition, 400);
2308
+ return () => window.clearInterval(timer);
2309
+ }, [updatePosition]);
2310
+ return {
2311
+ style,
2312
+ commitPanelWidth,
2313
+ commitPanelHeight,
2314
+ startPanelResize,
2315
+ startPanelHeightResize,
2316
+ onPanelResizeKeyDown,
2317
+ onPanelHeightKeyDown
2318
+ };
2319
+ }
2320
+
2321
+ // src/client/ui/useSections.ts
2322
+ /** Open/completed section visibility, remembered across panel opens. */
2323
+ function useSections() {
2324
+ const [initial] = react.default.useState(readSectionState);
2325
+ const [showOpen, setShowOpen] = react.default.useState(initial.open);
2326
+ const [showDone, setShowDone] = react.default.useState(initial.done);
2327
+ const sectionsRef = react.default.useRef(initial);
2328
+ /** Apply one section state and remember it right away, using the next value. */
2329
+ const applySections = (next) => {
2330
+ sectionsRef.current = next;
2331
+ setShowOpen(next.open);
2332
+ setShowDone(next.done);
2333
+ writeSectionState(next);
2334
+ };
2335
+ return {
2336
+ sectionsRef,
2337
+ showOpen,
2338
+ showDone,
2339
+ applySections,
2340
+ toggleOpen: () => applySections({
2341
+ open: !sectionsRef.current.open,
2342
+ done: sectionsRef.current.done
2343
+ }),
2344
+ toggleDone: () => applySections({
2345
+ open: sectionsRef.current.open,
2346
+ done: !sectionsRef.current.done
2347
+ })
2348
+ };
2349
+ }
2350
+
2351
+ // src/client/storage/forwarded.ts
2352
+ /** Per-session forwarded marks behind the forward button. */
2353
+ /** Empty forwarded-flag store; shape is { version, sessions: { [sessionId]: { [itemId]: true } } }. */
2354
+ function emptyForwardedStore() {
2355
+ return {
2356
+ version: 1,
2357
+ sessions: {}
2358
+ };
2359
+ }
2360
+ /** Read the forwarded-flag store; corrupt or unavailable reads as empty. */
2361
+ function readForwardedStore() {
2362
+ const ls = storage();
2363
+ if (!ls) return emptyForwardedStore();
2364
+ try {
2365
+ const raw = ls.getItem(FORWARDED_STORAGE_KEY);
2366
+ if (!raw) return emptyForwardedStore();
2367
+ const parsed = JSON.parse(raw);
2368
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return emptyForwardedStore();
2369
+ const sessions = parsed.sessions;
2370
+ if (!sessions || typeof sessions !== "object" || Array.isArray(sessions)) return emptyForwardedStore();
2371
+ return {
2372
+ version: 1,
2373
+ sessions
2374
+ };
2375
+ } catch {
2376
+ return emptyForwardedStore();
2377
+ }
2378
+ }
2379
+ function writeForwardedStore(store) {
2380
+ const ls = storage();
2381
+ if (!ls) return false;
2382
+ try {
2383
+ ls.setItem(FORWARDED_STORAGE_KEY, JSON.stringify(store));
2384
+ return true;
2385
+ } catch {
2386
+ return false;
2387
+ }
2388
+ }
2389
+ /** Keep only `true` flags on non-empty ids; anything else in the stored record is dropped. */
2390
+ function normalizeForwardedRecord(record) {
2391
+ if (!record || typeof record !== "object" || Array.isArray(record)) return {};
2392
+ const next = {};
2393
+ for (const [itemId, flag] of Object.entries(record)) if (itemId && flag === true) next[itemId] = true;
2394
+ return next;
2395
+ }
2396
+ /** Forwarded item ids of one session, as an id -> true map. */
2397
+ function readForwardedIds(sessionId) {
2398
+ const key = sessionId ? String(sessionId) : "";
2399
+ if (!key) return {};
2400
+ return normalizeForwardedRecord(readForwardedStore().sessions[key]);
2401
+ }
2402
+ /** Remember that one note was forwarded; best effort, never blocks the send. */
2403
+ function markForwarded(sessionId, itemId) {
2404
+ const key = sessionId ? String(sessionId) : "";
2405
+ const id = itemId ? String(itemId) : "";
2406
+ if (!key || !id) return false;
2407
+ const store = readForwardedStore();
2408
+ store.sessions[key] = {
2409
+ ...normalizeForwardedRecord(store.sessions[key]),
2410
+ [id]: true
2411
+ };
2412
+ return writeForwardedStore(store);
2413
+ }
2414
+ /** Drop forwarded flags that can no longer be rendered (deleted or cleared notes). */
2415
+ function forgetForwarded(sessionId, itemIds) {
2416
+ const key = sessionId ? String(sessionId) : "";
2417
+ if (!key) return false;
2418
+ const ids = Array.isArray(itemIds) ? itemIds : [itemIds];
2419
+ const store = readForwardedStore();
2420
+ const record = normalizeForwardedRecord(store.sessions[key]);
2421
+ let changed = false;
2422
+ for (const rawId of ids) {
2423
+ const id = rawId ? String(rawId) : "";
2424
+ if (!id || !record[id]) continue;
2425
+ delete record[id];
2426
+ changed = true;
2427
+ }
2428
+ if (!changed) return false;
2429
+ if (Object.keys(record).length) store.sessions[key] = record;
2430
+ else delete store.sessions[key];
2431
+ return writeForwardedStore(store);
2432
+ }
2433
+
2434
+ // src/client/ui/useForwardMarks.ts
2435
+ /** Which notes of this list were forwarded, plus the toggle-off bookkeeping. */
2436
+ /**
2437
+ * Forward marks belong to the list, not to the conversation: the same note
2438
+ * stays marked while the user moves between sessions of one workspace.
2439
+ */
2440
+ function useForwardMarks(scopeKey) {
2441
+ const key = scopeKey ? String(scopeKey) : "";
2442
+ const [forwardedIds, setForwardedIds] = react.default.useState(() => readForwardedIds(key));
2443
+ const keyRef = react.default.useRef(key);
2444
+ react.default.useEffect(() => {
2445
+ if (keyRef.current === key) return;
2446
+ keyRef.current = key;
2447
+ setForwardedIds(readForwardedIds(key));
2448
+ }, [key]);
2449
+ /** Drop forwarded flags for notes that no longer render (deleted or cleared). */
2450
+ const forgetForwardedItems = (itemIds) => {
2451
+ const ids = (Array.isArray(itemIds) ? itemIds : [itemIds]).filter(Boolean);
2452
+ if (!ids.length) return;
2453
+ forgetForwarded(key, ids);
2454
+ setForwardedIds((current) => {
2455
+ if (!ids.some((id) => current[id])) return current;
2456
+ const next = { ...current };
2457
+ for (const id of ids) delete next[id];
2458
+ return next;
2459
+ });
2460
+ };
2461
+ /** Remember a successful forward so the forward button keeps its check after closing the panel. */
2462
+ const rememberForwarded = (item) => {
2463
+ const id = item && item.id ? String(item.id) : "";
2464
+ if (!id) return;
2465
+ markForwarded(key, id);
2466
+ setForwardedIds((current) => current[id] ? current : {
2467
+ ...current,
2468
+ [id]: true
2469
+ });
2470
+ };
2471
+ /** Toggle the forward mark off; the note and its open/done state stay untouched. */
2472
+ const unrememberForwarded = (item) => {
2473
+ const id = item && item.id ? String(item.id) : "";
2474
+ if (!id) return;
2475
+ forgetForwardedItems(id);
2476
+ };
2477
+ return {
2478
+ forwardedIds,
2479
+ rememberForwarded,
2480
+ unrememberForwarded,
2481
+ forgetForwardedItems
2482
+ };
2483
+ }
2484
+
2485
+ // src/client/ui/usePanelSettings.ts
2486
+ /** Inline settings: send shortcut and the forward lead-in, both persisted. */
2487
+ function usePanelSettings() {
2488
+ const [showSettings, setShowSettings] = react.default.useState(false);
2489
+ const [sendShortcut, setSendShortcut] = react.default.useState(readSendShortcut);
2490
+ const [forwardPrefix, setForwardPrefix] = react.default.useState(readForwardPrefix);
2491
+ const prefixRef = react.default.useRef(null);
2492
+ react.default.useLayoutEffect(() => {
2493
+ const node = prefixRef.current;
2494
+ if (!node) return;
2495
+ node.style.height = "auto";
2496
+ node.style.height = `${Math.min(138, node.scrollHeight + 2)}px`;
2497
+ }, [forwardPrefix, showSettings]);
2498
+ const chooseShortcut = (value) => {
2499
+ setSendShortcut(value);
2500
+ writeSendShortcut(value);
2501
+ };
2502
+ const changeForwardPrefix = (value) => {
2503
+ const next = String(value || "").slice(0, 80);
2504
+ setForwardPrefix(next);
2505
+ writeForwardPrefix(next);
2506
+ };
2507
+ return {
2508
+ showSettings,
2509
+ setShowSettings,
2510
+ sendShortcut,
2511
+ chooseShortcut,
2512
+ forwardPrefix,
2513
+ changeForwardPrefix,
2514
+ prefixRef
2515
+ };
2516
+ }
2517
+
2518
+ // src/client/update/releaseHistory.ts
2519
+ /** Enough history to explain a long gap without turning the card into a feed. */
2520
+ const MAX_RELEASE_HISTORY = 6;
2521
+ function core(version) {
2522
+ return String(version ?? "").replace(/^v/i, "").split("-", 1)[0].split(".").map((part) => Number.parseInt(part, 10) || 0);
2523
+ }
2524
+ /** A version carrying a prerelease part, e.g. `1.2.0-beta.1`. */
2525
+ function isPrerelease(version) {
2526
+ return /^\D*\d+\.\d+\.\d+-/.test(String(version ?? "").trim());
2527
+ }
2528
+ /**
2529
+ * Full ordering of two versions, prerelease identifiers included.
2530
+ *
2531
+ * A beta build asks for the notes between `1.2.0-beta.1` and `1.2.0-beta.2`;
2532
+ * comparing the cores alone would call those equal and leave the card with no
2533
+ * notes at all, which is exactly the case a beta test needs to read.
2534
+ */
2535
+ function compareVersions(a, b) {
2536
+ const left = core(a);
2537
+ const right = core(b);
2538
+ for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
2539
+ const difference = (left[index] || 0) - (right[index] || 0);
2540
+ if (difference !== 0) return difference > 0 ? 1 : -1;
2541
+ }
2542
+ const leftPre = prerelease(a);
2543
+ const rightPre = prerelease(b);
2544
+ if (leftPre.length === 0 && rightPre.length === 0) return 0;
2545
+ if (leftPre.length === 0) return 1;
2546
+ if (rightPre.length === 0) return -1;
2547
+ for (let index = 0; index < Math.max(leftPre.length, rightPre.length); index += 1) {
2548
+ const x = leftPre[index];
2549
+ const y = rightPre[index];
2550
+ if (x === void 0) return -1;
2551
+ if (y === void 0) return 1;
2552
+ if (x === y) continue;
2553
+ const xNumeric = /^\d+$/.test(x);
2554
+ const yNumeric = /^\d+$/.test(y);
2555
+ if (xNumeric && yNumeric) return Number(x) > Number(y) ? 1 : -1;
2556
+ if (xNumeric) return -1;
2557
+ if (yNumeric) return 1;
2558
+ return x > y ? 1 : -1;
2559
+ }
2560
+ return 0;
2561
+ }
2562
+ /** The prerelease identifiers of a version, or an empty list. */
2563
+ function prerelease(version) {
2564
+ const normalized = String(version ?? "").trim().replace(/^v/i, "");
2565
+ const dash = normalized.indexOf("-");
2566
+ if (dash === -1) return [];
2567
+ const tail = normalized.slice(dash + 1).split("+")[0];
2568
+ return tail === "" ? [] : tail.split(".");
2569
+ }
2570
+ /** A `x.y.z` or `x.y.z-prerelease` tag, with the `v` prefix and whitespace removed. */
2571
+ function normalizeVersion(version) {
2572
+ const normalized = String(version ?? "").trim().replace(/^v/i, "");
2573
+ return /^\d+(\.\d+)*(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(normalized) ? normalized : "";
2574
+ }
2575
+ /**
2576
+ * Filter the feed down to the releases the user is about to receive:
2577
+ * newer than `current`, not newer than `latest`, newest first, capped.
2578
+ */
2579
+ function selectReleaseHistory(list, query) {
2580
+ const max = query.max && query.max > 0 ? query.max : 6;
2581
+ const seen = /* @__PURE__ */ new Set();
2582
+ const entries = [];
2583
+ const allowPrerelease = isPrerelease(query.current) && isPrerelease(query.latest ?? "");
2584
+ for (const item of Array.isArray(list) ? list : []) {
2585
+ const release = item;
2586
+ if (!release || typeof release !== "object") continue;
2587
+ if (release.draft === true) continue;
2588
+ if (release.prerelease === true && !allowPrerelease) continue;
2589
+ const version = normalizeVersion(typeof release.version === "string" ? release.version : release.tag_name);
2590
+ if (!version || seen.has(version)) continue;
2591
+ if (compareVersions(version, query.current) <= 0) continue;
2592
+ if (query.latest && compareVersions(version, query.latest) > 0) continue;
2593
+ seen.add(version);
2594
+ const url = release.url ?? release.html_url;
2595
+ const publishedAt = release.publishedAt ?? release.published_at;
2596
+ entries.push({
2597
+ version,
2598
+ body: typeof release.body === "string" ? release.body : "",
2599
+ url: typeof url === "string" ? url : "",
2600
+ publishedAt: typeof publishedAt === "string" ? publishedAt : ""
2601
+ });
2602
+ }
2603
+ entries.sort((a, b) => compareVersions(b.version, a.version));
2604
+ return {
2605
+ entries: entries.slice(0, max),
2606
+ truncated: entries.length > max
2607
+ };
2608
+ }
2609
+
2610
+ // src/client/update/latest.ts
2611
+ /**
2612
+ * Published-version probes: the version number and the release notes behind it.
2613
+ *
2614
+ * The panel is usually installed from a checkout, not from a store, so it asks
2615
+ * the npm registry first and falls back to the GitHub Release tag. Everything
2616
+ * here is dependency-injected and free of widget state so the contract test can
2617
+ * exercise the source order, the one-hour cache and the comparison in Node.
2618
+ */
2619
+ /** npm metadata endpoints in fallback order; the mirror covers slow npmjs routes. */
2620
+ const UPDATE_REGISTRY_HOSTS = ["https://registry.npmjs.org", "https://registry.npmmirror.com"];
2621
+ /** GitHub's REST host for this repo, derived from the displayed repo URL. */
2622
+ const UPDATE_GITHUB_API = `${PLUGIN_REPO_URL.replace("https://github.com/", "https://api.github.com/repos/")}/releases`;
2623
+ /** Second source: a GitHub Release, for checkouts that are not published to npm. */
2624
+ const UPDATE_GITHUB_RELEASE_URL = `${UPDATE_GITHUB_API}/latest`;
2625
+ /** The releases feed; one page is enough for the gap the card is willing to show. */
2626
+ const UPDATE_GITHUB_RELEASES_URL = `${UPDATE_GITHUB_API}?per_page=50`;
2627
+ /** A resolved version is reused for an hour, including a miss, to keep opens quiet. */
2628
+ const UPDATE_TTL_MS = 36e5;
2629
+ /** A manual check should not hang the panel on a black-holed network. */
2630
+ const UPDATE_TIMEOUT_MS = 8e3;
2631
+ /** A version carrying a prerelease part, e.g. `1.2.0-beta.1`. */
2632
+ function isPrereleaseVersion(version) {
2633
+ return /^\D*\d+\.\d+\.\d+-/.test(version.trim());
2634
+ }
2635
+ /**
2636
+ * A prerelease on a channel this project actually publishes.
2637
+ *
2638
+ * `1.1.2-beta.1` is a build someone installed on purpose and it should check
2639
+ * for updates like any other release; `2.1.0-dev` is a local build and must not
2640
+ * nag. The suffix alone cannot tell them apart, so the channel names do.
2641
+ */
2642
+ function isPublishedChannel(version) {
2643
+ return /^\d+\.\d+\.\d+-(?:alpha|beta|rc)\./.test(version.trim());
2644
+ }
2645
+ /**
2646
+ * Full ordering, tolerant of a `v` prefix and short forms, with the prerelease
2647
+ * identifiers compared as semver does: a release outranks any prerelease on the
2648
+ * same core, `rc.1` sorts below `rc.2`, and a numeric identifier sorts below an
2649
+ * alphanumeric one.
2650
+ *
2651
+ * The prerelease part matters here: a beta build must see the next beta as an
2652
+ * update, which a comparison over the core alone would call "the same version".
2653
+ */
2654
+ function compareVersionOrder(a, b) {
2655
+ const parse = (version) => {
2656
+ const [core, ...rest] = version.trim().replace(/^v/, "").split("-");
2657
+ const parts = core.split(".").map((part) => parseInt(part, 10));
2658
+ if (parts.length === 0 || parts.some((part) => Number.isNaN(part))) return null;
2659
+ const prerelease = rest.join("-");
2660
+ return {
2661
+ core: parts,
2662
+ prerelease: prerelease === "" ? [] : prerelease.split(".")
2663
+ };
2664
+ };
2665
+ const next = parse(a);
2666
+ const have = parse(b);
2667
+ if (next === null && have === null) return 0;
2668
+ if (next === null) return -1;
2669
+ if (have === null) return 1;
2670
+ for (let index = 0; index < Math.max(next.core.length, have.core.length); index += 1) {
2671
+ const left = next.core[index] || 0;
2672
+ const right = have.core[index] || 0;
2673
+ if (left !== right) return left > right ? 1 : -1;
2674
+ }
2675
+ if (next.prerelease.length === 0 && have.prerelease.length === 0) return 0;
2676
+ if (next.prerelease.length === 0) return 1;
2677
+ if (have.prerelease.length === 0) return -1;
2678
+ for (let index = 0; index < Math.max(next.prerelease.length, have.prerelease.length); index += 1) {
2679
+ const left = next.prerelease[index];
2680
+ const right = have.prerelease[index];
2681
+ if (left === void 0) return -1;
2682
+ if (right === void 0) return 1;
2683
+ if (left === right) continue;
2684
+ const leftNumeric = /^\d+$/.test(left);
2685
+ const rightNumeric = /^\d+$/.test(right);
2686
+ if (leftNumeric && rightNumeric) return Number(left) > Number(right) ? 1 : -1;
2687
+ if (leftNumeric) return -1;
2688
+ if (rightNumeric) return 1;
2689
+ return left > right ? 1 : -1;
2690
+ }
2691
+ return 0;
2692
+ }
2693
+ /** Whether `latest` is a newer release than `current`. */
2694
+ function isNewerVersion(latest, current) {
2695
+ return compareVersionOrder(latest, current) > 0;
2696
+ }
2697
+ /** A fetch that gives up after {@link UPDATE_TIMEOUT_MS} instead of hanging. */
2698
+ function fetchWithTimeout(fetchImpl, url) {
2699
+ if (typeof AbortController !== "function") return Promise.resolve().then(() => fetchImpl(url));
2700
+ const controller = new AbortController();
2701
+ const timer = setTimeout(() => controller.abort(), UPDATE_TIMEOUT_MS);
2702
+ return Promise.resolve().then(() => fetchImpl(url, { signal: controller.signal })).finally(() => clearTimeout(timer));
2703
+ }
2704
+ function createUpdateProbe(options = {}) {
2705
+ const fetchImpl = options.fetchImpl || ((url, init) => fetch(url, init));
2706
+ const now = options.now || (() => Date.now());
2707
+ const ttlMs = options.ttlMs || 36e5;
2708
+ let cached = null;
2709
+ function readJson(url) {
2710
+ return fetchWithTimeout(fetchImpl, url).then((response) => response.ok ? response.json() : null).catch(() => null);
2711
+ }
2712
+ function readNpmVersion(host, channel) {
2713
+ return readJson(`${host}/dsh-sideby-note/${channel}`).then((body) => body !== null && typeof body.version === "string" ? body.version : null);
2714
+ }
2715
+ function readGitHubVersion() {
2716
+ return readJson(UPDATE_GITHUB_RELEASE_URL).then((body) => {
2717
+ const tag = body !== null && typeof body.tag_name === "string" ? body.tag_name : "";
2718
+ return tag === "" ? null : tag.replace(/^v/, "");
2719
+ });
2720
+ }
2721
+ function latest() {
2722
+ if (cached === null || now() - cached.at >= ttlMs) {
2723
+ const channels = isPrereleaseVersion(options.currentVersion ?? "") ? ["latest", "next"] : ["latest"];
2724
+ cached = {
2725
+ at: now(),
2726
+ promise: (async () => {
2727
+ let best = null;
2728
+ for (const host of UPDATE_REGISTRY_HOSTS) {
2729
+ let answered = false;
2730
+ for (const channel of channels) {
2731
+ const version = await readNpmVersion(host, channel);
2732
+ if (version === null) continue;
2733
+ answered = true;
2734
+ if (channel !== "latest" && !isPrereleaseVersion(version)) continue;
2735
+ if (best === null || isNewerVersion(version, best)) best = version;
2736
+ }
2737
+ if (answered) return best;
2738
+ }
2739
+ return best ?? readGitHubVersion();
2740
+ })()
2741
+ };
2742
+ }
2743
+ return cached.promise;
2744
+ }
2745
+ /** Drop the cached answer so the next call reads the network again. */
2746
+ function reset() {
2747
+ cached = null;
2748
+ }
2749
+ return {
2750
+ latest,
2751
+ reset
2752
+ };
2753
+ }
2754
+ /** Process-wide probe: one fetch per hour no matter how often the panel opens. */
2755
+ const updateProbe = createUpdateProbe({ currentVersion: PLUGIN_VERSION });
2756
+ function fetchLatestVersion() {
2757
+ return updateProbe.latest();
2758
+ }
2759
+ function readJsonWithTimeout(fetchImpl, url) {
2760
+ return fetchWithTimeout(fetchImpl, url).then((response) => response.ok ? response.json() : null).catch(() => null);
2761
+ }
2762
+ /**
2763
+ * Fetch the releases between the running build and the published version.
2764
+ * GitHub is the only source: the notes live on the Release, not in the npm
2765
+ * manifest. A missing feed falls back to the single newest tag, and a missing
2766
+ * release (a tag pushed without a Release) leaves the card with links only.
2767
+ */
2768
+ function createReleaseHistoryProbe(options = {}) {
2769
+ const fetchImpl = options.fetchImpl || ((url, init) => fetch(url, init));
2770
+ const now = options.now || (() => Date.now());
2771
+ const ttlMs = options.ttlMs || 36e5;
2772
+ const cached = /* @__PURE__ */ new Map();
2773
+ function latest(current, target) {
2774
+ const key = `${current}..${target}`;
2775
+ const hit = cached.get(key);
2776
+ if (hit && now() - hit.at < ttlMs) return hit.promise;
2777
+ const entry = {
2778
+ at: now(),
2779
+ promise: (async () => {
2780
+ const list = await readJsonWithTimeout(fetchImpl, UPDATE_GITHUB_RELEASES_URL);
2781
+ if (Array.isArray(list)) return selectReleaseHistory(list.map((item) => ({
2782
+ version: typeof item?.tag_name === "string" ? item.tag_name : item?.version,
2783
+ body: item?.body,
2784
+ url: item?.html_url,
2785
+ prerelease: item?.prerelease,
2786
+ draft: item?.draft,
2787
+ publishedAt: item?.published_at
2788
+ })), {
2789
+ current,
2790
+ latest: target,
2791
+ max: 6
2792
+ });
2793
+ const single = await readJsonWithTimeout(fetchImpl, `${UPDATE_GITHUB_API}/tags/v${encodeURIComponent(target)}`);
2794
+ if (single === null) return {
2795
+ entries: [],
2796
+ truncated: false
2797
+ };
2798
+ const tag = typeof single.tag_name === "string" ? single.tag_name.replace(/^v/, "") : target;
2799
+ return {
2800
+ entries: [{
2801
+ version: tag,
2802
+ body: typeof single.body === "string" ? single.body : "",
2803
+ url: typeof single.html_url === "string" && single.html_url ? single.html_url : `${PLUGIN_REPO_URL}/releases/tag/v${encodeURIComponent(tag)}`,
2804
+ publishedAt: typeof single.published_at === "string" ? single.published_at : ""
2805
+ }],
2806
+ truncated: false
2807
+ };
2808
+ })()
2809
+ };
2810
+ cached.set(key, entry);
2811
+ return entry.promise;
2812
+ }
2813
+ function reset() {
2814
+ cached.clear();
2815
+ }
2816
+ return {
2817
+ latest,
2818
+ reset
2819
+ };
2820
+ }
2821
+ /** Process-wide history probe, cached per version gap for an hour. */
2822
+ const releaseHistoryProbe = createReleaseHistoryProbe();
2823
+ function fetchReleaseHistory(current, target) {
2824
+ return releaseHistoryProbe.latest(current, target);
2825
+ }
2826
+ /** Manual check: forget both cached answers so the next calls hit the network. */
2827
+ function resetUpdateChecks() {
2828
+ updateProbe.reset();
2829
+ releaseHistoryProbe.reset();
2830
+ }
2831
+
2832
+ // src/client/update/releaseNotes.ts
2833
+ /** Bounds taken from the published-notes convention, not an editorial limit. */
2834
+ const MAX_NOTE_GROUPS = 6;
2835
+ const MAX_NOTE_ITEMS = 40;
2836
+ const MAX_NOTE_ITEM_CHARS = 600;
2837
+ const MARKER_RE = /<!--\s*app-update-notes:([A-Za-z-]+):start\s*-->([\s\S]*?)<!--\s*app-update-notes:\1:end\s*-->/g;
2838
+ const GROUP_RE = /^#{2,4}\s+(.+?)\s*$/;
2839
+ const ITEM_RE = /^\s*[-*]\s+(.+?)\s*$/;
2840
+ const LEAD_RE = /^([^。..!?!?::]{1,40}?[::])\s*(\S[\s\S]*)$/;
2841
+ const TRAILING_PR_REFS_RE = /\s*(?:[((]\s*#\d+(?:\s*[,,、]\s*#\d+)*\s*[))])\s*$/;
2842
+ const HTML_TAG_RE = /<\/?[A-Za-z][^>]*>/g;
2843
+ const IMAGE_RE = /!\[[^\]]*\]\([^)]*\)/g;
2844
+ const LINK_RE = /\[([^\]]+)\]\([^)]*\)/g;
2845
+ const CODE_RE = /`([^`]+)`/g;
2846
+ const STRONG_RE = /\*\*([^*]+)\*\*|__([^_]+)__/g;
2847
+ const EMPHASIS_RE = /\*([^*]+)\*|_([^_]+)_/g;
2848
+ const WHITESPACE_RE = /\s+/g;
2849
+ const ENTITIES = {
2850
+ amp: "&",
2851
+ apos: "'",
2852
+ gt: ">",
2853
+ lt: "<",
2854
+ nbsp: " ",
2855
+ quot: "\""
2856
+ };
2857
+ function decodeEntities(value) {
2858
+ return value.replace(/&(#x[0-9a-f]+|#\d+|amp|apos|gt|lt|nbsp|quot);/gi, (match, entity) => {
2859
+ const lower = entity.toLowerCase();
2860
+ if (Object.prototype.hasOwnProperty.call(ENTITIES, lower)) return ENTITIES[lower];
2861
+ const codePoint = lower.startsWith("#x") ? Number.parseInt(lower.slice(2), 16) : Number.parseInt(lower.slice(1), 10);
2862
+ if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111) return match;
2863
+ try {
2864
+ return String.fromCodePoint(codePoint);
2865
+ } catch {
2866
+ return match;
2867
+ }
2868
+ });
2869
+ }
2870
+ /** Flatten one line of release-note markdown to readable plain text. */
2871
+ function noteText(value) {
2872
+ return decodeEntities(String(value ?? "").replace(HTML_TAG_RE, "").replace(IMAGE_RE, "").replace(LINK_RE, "$1").replace(CODE_RE, "$1").replace(STRONG_RE, (_match, strong, underscored) => strong || underscored).replace(EMPHASIS_RE, (_match, italic, underscored) => italic || underscored).replace(TRAILING_PR_REFS_RE, "")).replace(WHITESPACE_RE, " ").trim();
2873
+ }
2874
+ /** Split "**Topic:** rest" into its bold lead and the remaining body. */
2875
+ function splitNoteLead(value) {
2876
+ const text = noteText(value);
2877
+ const match = LEAD_RE.exec(text);
2878
+ return match ? {
2879
+ lead: match[1].trim(),
2880
+ body: match[2].trim()
2881
+ } : {
2882
+ lead: "",
2883
+ body: text
2884
+ };
2885
+ }
2886
+ function truncate(value, maxChars) {
2887
+ const characters = Array.from(value);
2888
+ return characters.length <= maxChars ? value : `${characters.slice(0, maxChars - 1).join("").trimEnd()}…`;
2889
+ }
2890
+ /**
2891
+ * Locale fallback order for a DSH locale id. A Chinese UI reads the `zh` block,
2892
+ * everything else reads `en`; either falls back to the other when a release
2893
+ * only shipped one language.
2894
+ */
2895
+ function noteLocalesFor(locale) {
2896
+ return String(locale ?? "").toLowerCase().startsWith("zh") ? ["zh", "en"] : ["en", "zh"];
2897
+ }
2898
+ /** The notes block for this locale, or an empty string when the release has none. */
2899
+ function extractUpdateNotes(body, locale) {
2900
+ const blocks = /* @__PURE__ */ new Map();
2901
+ for (const match of String(body ?? "").matchAll(MARKER_RE)) {
2902
+ const key = match[1].toLowerCase();
2903
+ if (!blocks.has(key)) blocks.set(key, match[2]);
2904
+ }
2905
+ for (const key of noteLocalesFor(locale)) {
2906
+ const block = blocks.get(key);
2907
+ if (block && block.trim()) return block.trim();
2908
+ }
2909
+ return "";
2910
+ }
2911
+ /** Parse one marker block into headings and bullets. */
2912
+ function parseReleaseNotes(markdown) {
2913
+ const drafts = [];
2914
+ let current = null;
2915
+ for (const rawLine of String(markdown ?? "").split(/\r?\n/)) {
2916
+ const line = rawLine.trimEnd();
2917
+ const heading = GROUP_RE.exec(line);
2918
+ if (heading) {
2919
+ current = {
2920
+ title: noteText(heading[1]),
2921
+ bullets: []
2922
+ };
2923
+ drafts.push(current);
2924
+ continue;
2925
+ }
2926
+ const item = ITEM_RE.exec(line);
2927
+ if (item) {
2928
+ if (current === null) {
2929
+ current = {
2930
+ title: "",
2931
+ bullets: []
2932
+ };
2933
+ drafts.push(current);
2934
+ }
2935
+ current.bullets.push(item[1]);
2936
+ continue;
2937
+ }
2938
+ if (line.trim() && current !== null && current.bullets.length > 0) {
2939
+ const last = current.bullets.length - 1;
2940
+ current.bullets[last] = `${current.bullets[last]} ${line.trim()}`;
2941
+ }
2942
+ }
2943
+ const parsed = [];
2944
+ for (const draft of drafts) {
2945
+ const items = [];
2946
+ for (const bullet of draft.bullets) {
2947
+ const text = truncate(noteText(bullet), 600);
2948
+ if (text) items.push(splitNoteLead(text));
2949
+ if (items.length >= 40) break;
2950
+ }
2951
+ if (items.length > 0) parsed.push({
2952
+ title: draft.title,
2953
+ items
2954
+ });
2955
+ if (parsed.length >= 6) break;
2956
+ }
2957
+ return parsed;
2958
+ }
2959
+ /** Convenience for the panel: extract and parse in one step. */
2960
+ function updateNotesForLocale(body, locale) {
2961
+ return parseReleaseNotes(extractUpdateNotes(body, locale));
2962
+ }
2963
+
2964
+ // src/client/update/host.ts
2965
+ /**
2966
+ * The host-side update, as the panel sees it.
2967
+ *
2968
+ * The host half of this package exposes two same-origin endpoints; a browser
2969
+ * cannot install a package itself. Nothing here throws: every branch answers
2970
+ * with a value the card can render, because "the host has no update route"
2971
+ * falls back to the manual command rather than looking like a failed install.
2972
+ */
2973
+ /** Where the host listens; keep in sync with `host/route.js`. */
2974
+ const HOST_APPLY_PATH = "/dsh-sideby-note/update/apply";
2975
+ /** An install can be slow (pnpm download, build scripts) but not unbounded. */
2976
+ const APPLY_TIMEOUT_MS = 3e5;
2977
+ function text(value) {
2978
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
2979
+ }
2980
+ /**
2981
+ * Ask the host to install `target` over the running copy.
2982
+ *
2983
+ * @param target exact version, as the version check resolved it
2984
+ */
2985
+ async function applyHostUpdate(target) {
2986
+ const controller = typeof AbortController === "function" ? new AbortController() : void 0;
2987
+ let timedOut = false;
2988
+ const timer = setTimeout(() => {
2989
+ timedOut = true;
2990
+ controller?.abort();
2991
+ }, APPLY_TIMEOUT_MS);
2992
+ let response;
2993
+ try {
2994
+ response = await fetch(HOST_APPLY_PATH, {
2995
+ method: "POST",
2996
+ headers: { "content-type": "application/json" },
2997
+ body: JSON.stringify({ target }),
2998
+ ...controller === void 0 ? {} : { signal: controller.signal }
2999
+ });
3000
+ } catch {
3001
+ if (timedOut) return {
3002
+ kind: "error",
3003
+ code: "UPDATE_TIMEOUT",
3004
+ message: "the host update timed out",
3005
+ retryable: true
3006
+ };
3007
+ return { kind: "unavailable" };
3008
+ } finally {
3009
+ clearTimeout(timer);
3010
+ }
3011
+ if (response.status === 404) return { kind: "unavailable" };
3012
+ let body;
3013
+ try {
3014
+ body = await response.json();
3015
+ } catch {
3016
+ return { kind: "unavailable" };
3017
+ }
3018
+ if (body?.ok === true) return {
3019
+ kind: "ok",
3020
+ route: body.route === "dsh-plugin" || body.route === "package-manager" || body.route === "none" ? body.route : "dsh",
3021
+ ...text(body.previousVersion) === void 0 ? {} : { previousVersion: text(body.previousVersion) },
3022
+ installedVersion: text(body.installedVersion) ?? target,
3023
+ updated: body.updated === true,
3024
+ restartRequired: body.restartRequired === true,
3025
+ ...text(body.output) === void 0 ? {} : { output: text(body.output) }
3026
+ };
3027
+ return {
3028
+ kind: "error",
3029
+ code: text(body?.code) ?? "UPDATE_FAILED",
3030
+ message: text(body?.message) ?? "the host refused the update",
3031
+ retryable: body?.retryable === true,
3032
+ ...text(body?.hint) === void 0 ? {} : { hint: text(body.hint) }
3033
+ };
3034
+ }
3035
+
3036
+ // src/client/domain/clipboard.ts
3037
+ /** Clipboard write with a synchronous fallback. */
3038
+ /** Copy plain text, with a synchronous fallback for restricted clipboards. */
3039
+ async function copyText(text) {
3040
+ try {
3041
+ if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
3042
+ await navigator.clipboard.writeText(text);
3043
+ return true;
3044
+ }
3045
+ } catch {}
3046
+ try {
3047
+ const area = document.createElement("textarea");
3048
+ area.value = text;
3049
+ area.setAttribute("readonly", "");
3050
+ area.style.position = "fixed";
3051
+ area.style.opacity = "0";
3052
+ document.body.appendChild(area);
3053
+ area.select();
3054
+ const ok = document.execCommand("copy");
3055
+ area.remove();
3056
+ return ok;
3057
+ } catch {
3058
+ return false;
3059
+ }
3060
+ }
3061
+
3062
+ // src/client/ui/useUpdateCenter.ts
3063
+ /**
3064
+ * Update centre state for the settings card.
3065
+ *
3066
+ * Three things are allowed to be independent here: the published version check
3067
+ * (auto on open, manual on demand), the release notes behind that version
3068
+ * (loaded as soon as an update is offered), and the in-app update itself
3069
+ * (one host request that installs over the running copy). Keeping them separate
3070
+ * means a missing release body cannot take the version check down with it.
3071
+ *
3072
+ * The panel never runs a package manager itself. When the host has no update
3073
+ * route, the card falls back to the exact command the host reports, or pins the
3074
+ * offered version when the failure has no command of its own.
3075
+ */
3076
+ const CHECK_IDLE = {
3077
+ status: "idle",
3078
+ latestVersion: null,
3079
+ checkedAt: null
3080
+ };
3081
+ const NOTES_IDLE = {
3082
+ status: "idle",
3083
+ entries: [],
3084
+ truncated: false
3085
+ };
3086
+ const RUN_IDLE = {
3087
+ phase: "idle",
3088
+ failureCode: null,
3089
+ message: null,
3090
+ retryable: false,
3091
+ refreshRequired: false,
3092
+ restartRequired: false,
3093
+ installedVersion: null
3094
+ };
3095
+ /**
3096
+ * A manual check stays on screen for at least this long. A fast registry answer
3097
+ * would otherwise flip the button back in a few milliseconds, which reads as
3098
+ * "did that do anything?" and invites repeat clicks.
3099
+ */
3100
+ const MIN_CHECK_MS = 3e3;
3101
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3102
+ function terminalRun(phase, patch = {}) {
3103
+ return {
3104
+ ...RUN_IDLE,
3105
+ phase,
3106
+ ...patch
3107
+ };
3108
+ }
3109
+ function useUpdateCenter(localeId) {
3110
+ const [check, setCheck] = react.default.useState(CHECK_IDLE);
3111
+ const [notes, setNotes] = react.default.useState(NOTES_IDLE);
3112
+ const [expandedVersions, setExpandedVersions] = react.default.useState({});
3113
+ const [run, setRun] = react.default.useState(RUN_IDLE);
3114
+ const disposed = react.default.useRef(false);
3115
+ const runRef = react.default.useRef(RUN_IDLE);
3116
+ runRef.current = run;
3117
+ /** The offered version, readable from callbacks without re-creating them. */
3118
+ const latestRef = react.default.useRef(null);
3119
+ latestRef.current = check.latestVersion;
3120
+ /** Set before the first await so the same panel cannot start two operations. */
3121
+ const starting = react.default.useRef(false);
3122
+ react.default.useEffect(() => {
3123
+ disposed.current = false;
3124
+ return () => {
3125
+ disposed.current = true;
3126
+ };
3127
+ }, []);
3128
+ const latestVersion = check.latestVersion;
3129
+ react.default.useEffect(() => {
3130
+ if ("0.1.0".includes("-") && !isPublishedChannel("0.1.0")) return void 0;
3131
+ let active = true;
3132
+ fetchLatestVersion().then((version) => {
3133
+ if (!active) return;
3134
+ if (version === null) return;
3135
+ if (isNewerVersion(version, "0.1.0")) setCheck({
3136
+ status: "available",
3137
+ latestVersion: version,
3138
+ checkedAt: Date.now()
3139
+ });
3140
+ else setCheck({
3141
+ status: "current",
3142
+ latestVersion: null,
3143
+ checkedAt: Date.now()
3144
+ });
3145
+ });
3146
+ return () => {
3147
+ active = false;
3148
+ };
3149
+ }, []);
3150
+ const checkNow = react.default.useCallback(async () => {
3151
+ if (check.status === "checking") return;
3152
+ resetUpdateChecks();
3153
+ const startedAt = Date.now();
3154
+ const previousOffer = check.latestVersion;
3155
+ setCheck((previous) => ({
3156
+ ...previous,
3157
+ status: "checking"
3158
+ }));
3159
+ setRun(RUN_IDLE);
3160
+ const version = await fetchLatestVersion();
3161
+ const remaining = MIN_CHECK_MS - (Date.now() - startedAt);
3162
+ if (remaining > 0) await sleep(remaining);
3163
+ if (disposed.current) return;
3164
+ if (version === null) {
3165
+ setCheck({
3166
+ status: "error",
3167
+ latestVersion: previousOffer,
3168
+ checkedAt: Date.now()
3169
+ });
3170
+ return;
3171
+ }
3172
+ if (isNewerVersion(version, "0.1.0")) {
3173
+ const sameRelease = previousOffer !== null && version === previousOffer;
3174
+ setCheck({
3175
+ status: "available",
3176
+ latestVersion: version,
3177
+ checkedAt: Date.now()
3178
+ });
3179
+ if (!sameRelease) {
3180
+ setNotes(NOTES_IDLE);
3181
+ setExpandedVersions({});
3182
+ }
3183
+ } else {
3184
+ setCheck({
3185
+ status: "current",
3186
+ latestVersion: null,
3187
+ checkedAt: Date.now()
3188
+ });
3189
+ setNotes(NOTES_IDLE);
3190
+ setExpandedVersions({});
3191
+ }
3192
+ }, [check.status, check.latestVersion]);
3193
+ const toggleVersion = react.default.useCallback((version) => {
3194
+ setExpandedVersions((previous) => ({
3195
+ ...previous,
3196
+ [version]: previous[version] !== true
3197
+ }));
3198
+ }, []);
3199
+ react.default.useEffect(() => {
3200
+ if (check.status !== "available" || check.latestVersion === null) return void 0;
3201
+ if (notes.status !== "idle") return void 0;
3202
+ let active = true;
3203
+ setNotes((previous) => ({
3204
+ ...previous,
3205
+ status: "loading"
3206
+ }));
3207
+ fetchReleaseHistory(PLUGIN_VERSION, check.latestVersion).then((result) => {
3208
+ if (!active) return;
3209
+ const entries = result.entries.map((entry) => ({
3210
+ version: entry.version,
3211
+ url: entry.url,
3212
+ groups: updateNotesForLocale(entry.body, localeId)
3213
+ }));
3214
+ if (entries.length === 0) {
3215
+ setNotes({
3216
+ status: "error",
3217
+ entries: [],
3218
+ truncated: false
3219
+ });
3220
+ return;
3221
+ }
3222
+ setNotes({
3223
+ status: "ready",
3224
+ entries,
3225
+ truncated: result.truncated
3226
+ });
3227
+ const newest = entries[0].version;
3228
+ setExpandedVersions({ [newest]: true });
3229
+ });
3230
+ return () => {
3231
+ active = false;
3232
+ };
3233
+ }, [
3234
+ check.status,
3235
+ check.latestVersion,
3236
+ localeId
3237
+ ]);
3238
+ const startUpdate = react.default.useCallback(async () => {
3239
+ if (starting.current) return;
3240
+ if (runRef.current.phase === "starting" || runRef.current.phase === "running") return;
3241
+ if (runRef.current.phase === "done" && runRef.current.installedVersion === latestRef.current) return;
3242
+ starting.current = true;
3243
+ try {
3244
+ setRun(terminalRun("starting"));
3245
+ const target = latestRef.current;
3246
+ if (target === null) {
3247
+ setRun(terminalRun("error", {
3248
+ failureCode: "AUTO_UPDATE_UNAVAILABLE",
3249
+ retryable: false
3250
+ }));
3251
+ return;
3252
+ }
3253
+ setRun(terminalRun("running"));
3254
+ const host = await applyHostUpdate(target);
3255
+ if (disposed.current) return;
3256
+ if (host.kind === "ok") {
3257
+ setRun(terminalRun("done", {
3258
+ installedVersion: host.installedVersion,
3259
+ refreshRequired: !host.restartRequired,
3260
+ restartRequired: host.restartRequired
3261
+ }));
3262
+ return;
3263
+ }
3264
+ if (host.kind === "error") {
3265
+ setRun(terminalRun("error", {
3266
+ failureCode: host.code,
3267
+ message: host.hint ?? host.message,
3268
+ retryable: host.retryable
3269
+ }));
3270
+ return;
3271
+ }
3272
+ setRun(terminalRun("error", {
3273
+ failureCode: "AUTO_UPDATE_UNAVAILABLE",
3274
+ retryable: false
3275
+ }));
3276
+ } finally {
3277
+ starting.current = false;
3278
+ }
3279
+ }, []);
3280
+ const refreshPage = react.default.useCallback(() => {
3281
+ try {
3282
+ window.location.reload();
3283
+ } catch {}
3284
+ }, []);
3285
+ /** Copy the ready-to-paste update prompt; the caller reports the outcome. */
3286
+ const copyPrompt = react.default.useCallback((text) => copyText(text), []);
3287
+ const fullReleaseUrl = notes.entries[0]?.url || (latestVersion ? `${"https://github.com/LighghtEeloo/dsh-sideby-note"}/releases/tag/v${latestVersion}` : null);
3288
+ return {
3289
+ check,
3290
+ latestVersion,
3291
+ notes,
3292
+ expandedVersions,
3293
+ releasesUrl: `${PLUGIN_REPO_URL}/releases`,
3294
+ run,
3295
+ fullReleaseUrl,
3296
+ checkNow,
3297
+ toggleVersion,
3298
+ startUpdate,
3299
+ refreshPage,
3300
+ copyPrompt
3301
+ };
3302
+ }
3303
+
3304
+ // src/client/ui/useComposerDraft.ts
3305
+ /** The add box: draft persistence, auto-grow, send chords and newline insertion. */
3306
+ function useComposerDraft({ draftKey, commit, report, sendShortcut }) {
3307
+ const key = draftKey ? String(draftKey) : "";
3308
+ const [draft, setDraft] = react.default.useState(() => readScopeDrafts(key).add);
3309
+ const addRef = react.default.useRef(null);
3310
+ const composingRef = react.default.useRef(false);
3311
+ const resizeAdd = (node) => {
3312
+ if (!node) return;
3313
+ node.style.height = "auto";
3314
+ node.style.height = `${node.scrollHeight + 2}px`;
3315
+ };
3316
+ react.default.useEffect(() => {
3317
+ resizeAdd(addRef.current);
3318
+ }, [draft]);
3319
+ const hasFinePointer = () => typeof window.matchMedia !== "function" || window.matchMedia("(hover: hover) and (pointer: fine)").matches;
3320
+ react.default.useLayoutEffect(() => {
3321
+ const node = addRef.current;
3322
+ if (!node) return;
3323
+ if (!hasFinePointer()) return;
3324
+ node.focus();
3325
+ const end = node.value.length;
3326
+ try {
3327
+ node.setSelectionRange(end, end);
3328
+ } catch {}
3329
+ }, []);
3330
+ const add = () => {
3331
+ const text = draft.trim().slice(0, 280);
3332
+ if (!text) return;
3333
+ const now = Date.now();
3334
+ if (!commit((currentItems) => [{
3335
+ id: uid(),
3336
+ text,
3337
+ done: false,
3338
+ createdAt: now,
3339
+ updatedAt: now
3340
+ }, ...currentItems])) {
3341
+ report("saveFailed");
3342
+ return;
3343
+ }
3344
+ setDraft("");
3345
+ clearAddDraft(key);
3346
+ };
3347
+ /**
3348
+ * Replace the composer with a recalled note and put the caret at its end.
3349
+ *
3350
+ * This is the only text editor for a note: the row leaves the list and its
3351
+ * text lands here, where the user can change it and submit it again.
3352
+ */
3353
+ const recall = (text) => {
3354
+ const value = String(text || "").slice(0, 280);
3355
+ setDraft(value);
3356
+ saveAddDraft(key, value);
3357
+ window.requestAnimationFrame(() => {
3358
+ const node = addRef.current;
3359
+ if (!node) return;
3360
+ if (hasFinePointer()) {
3361
+ node.focus();
3362
+ const end = node.value.length;
3363
+ try {
3364
+ node.setSelectionRange(end, end);
3365
+ } catch {}
3366
+ }
3367
+ resizeAdd(node);
3368
+ });
3369
+ };
3370
+ const insertDraftNewline = (node) => {
3371
+ if (!node) return;
3372
+ const start = node.selectionStart === null ? node.value.length : node.selectionStart;
3373
+ const end = node.selectionEnd === null ? start : node.selectionEnd;
3374
+ const next = `${node.value.slice(0, start)}\n${node.value.slice(end)}`;
3375
+ setDraft(next);
3376
+ saveAddDraft(key, next);
3377
+ window.requestAnimationFrame(() => {
3378
+ node.selectionStart = start + 1;
3379
+ node.selectionEnd = start + 1;
3380
+ resizeAdd(node);
3381
+ });
3382
+ };
3383
+ const onDraftChange = (event) => {
3384
+ const value = event.target.value;
3385
+ setDraft(value);
3386
+ saveAddDraft(key, value);
3387
+ resizeAdd(event.target);
3388
+ };
3389
+ const onDraftKeyDown = (event) => {
3390
+ const composing = event.isComposing || event.nativeEvent && event.nativeEvent.isComposing;
3391
+ if (event.key === "Escape") {
3392
+ event.currentTarget.blur();
3393
+ return;
3394
+ }
3395
+ if (event.key !== "Enter") return;
3396
+ if (composing) {
3397
+ event.preventDefault();
3398
+ return;
3399
+ }
3400
+ const chord = event.ctrlKey || event.metaKey;
3401
+ const platformModifier = isSendModifier(event);
3402
+ if (sendShortcut === "enter" ? !chord && !event.shiftKey : platformModifier) {
3403
+ event.preventDefault();
3404
+ add();
3405
+ return;
3406
+ }
3407
+ if (sendShortcut === "enter" && (chord || event.shiftKey)) {
3408
+ event.preventDefault();
3409
+ insertDraftNewline(event.currentTarget);
3410
+ }
3411
+ };
3412
+ return {
3413
+ draft,
3414
+ addRef,
3415
+ composingRef,
3416
+ add,
3417
+ recall,
3418
+ onDraftChange,
3419
+ onDraftKeyDown
3420
+ };
3421
+ }
3422
+
3423
+ // src/client/ui/useNoteActions.ts
3424
+ /** Row actions: toggle a note and take it back into the composer. */
3425
+ function useNoteActions({ commit, report, forgetForwardedItems }) {
3426
+ const toggle = (item) => {
3427
+ if (!commit((currentItems) => currentItems.map((candidate) => {
3428
+ if (candidate.id !== item.id) return candidate;
3429
+ const now = Date.now();
3430
+ return {
3431
+ ...candidate,
3432
+ done: !candidate.done,
3433
+ updatedAt: now,
3434
+ ...candidate.done ? { completedAt: void 0 } : { completedAt: now }
3435
+ };
3436
+ }))) report("saveFailed");
3437
+ };
3438
+ /**
3439
+ * Remove a note so its text can be recalled into the composer.
3440
+ *
3441
+ * A failed write keeps the row, its text and its forward flag exactly as
3442
+ * they were; the caller writes the recalled text only after this succeeds.
3443
+ */
3444
+ const takeBack = (item) => {
3445
+ if (!commit((currentItems) => currentItems.filter((candidate) => candidate.id !== item.id))) {
3446
+ report("saveFailed");
3447
+ return false;
3448
+ }
3449
+ forgetForwardedItems(item.id);
3450
+ return true;
3451
+ };
3452
+ return {
3453
+ toggle,
3454
+ takeBack
3455
+ };
3456
+ }
3457
+
3458
+ // src/client/ui/useClearConfirm.ts
3459
+ /** The inline second confirmation for clearing completed notes. */
3460
+ function useClearConfirm({ sessionId, showDone, doneCount, onConfirm }) {
3461
+ const [confirmClear, setConfirmClear] = react.default.useState(false);
3462
+ const clearConfirmTimerRef = react.default.useRef(0);
3463
+ /** Drop the pending auto-dismiss clock without touching state. */
3464
+ const stopClearConfirmTimer = () => {
3465
+ if (!clearConfirmTimerRef.current) return;
3466
+ window.clearTimeout(clearConfirmTimerRef.current);
3467
+ clearConfirmTimerRef.current = 0;
3468
+ };
3469
+ /** Close the inline band and drop its pending timer. */
3470
+ const dismissClearConfirm = () => {
3471
+ stopClearConfirmTimer();
3472
+ setConfirmClear(false);
3473
+ };
3474
+ /** Open the inline band; it retires itself after a short pause. */
3475
+ const askClearConfirm = () => {
3476
+ stopClearConfirmTimer();
3477
+ setConfirmClear(true);
3478
+ clearConfirmTimerRef.current = window.setTimeout(() => {
3479
+ clearConfirmTimerRef.current = 0;
3480
+ setConfirmClear(false);
3481
+ }, CLEAR_CONFIRM_MS);
3482
+ };
3483
+ /** Only the destructive confirm action reaches the clear routine. */
3484
+ const confirmClearDone = () => {
3485
+ dismissClearConfirm();
3486
+ onConfirm();
3487
+ };
3488
+ react.default.useEffect(() => () => stopClearConfirmTimer(), []);
3489
+ react.default.useEffect(() => {
3490
+ if (confirmClear && (!showDone || doneCount === 0)) dismissClearConfirm();
3491
+ }, [
3492
+ confirmClear,
3493
+ showDone,
3494
+ doneCount
3495
+ ]);
3496
+ react.default.useEffect(() => {
3497
+ dismissClearConfirm();
3498
+ }, [sessionId]);
3499
+ return {
3500
+ confirmClear,
3501
+ askClearConfirm,
3502
+ dismissClearConfirm,
3503
+ confirmClearDone
3504
+ };
3505
+ }
3506
+
3507
+ // src/client/ui/useListEdge.ts
3508
+ /** Tracks whether the note list can still scroll down, and updates sticky heads. */
3509
+ function useListEdge({ items, showOpen, showDone }) {
3510
+ const listRef = react.default.useRef(null);
3511
+ const [listHasMore, setListHasMore] = react.default.useState(false);
3512
+ /** The bottom fade exists only while the list can still scroll down. */
3513
+ const syncListEdge = react.default.useCallback(() => {
3514
+ const node = listRef.current;
3515
+ if (!node) return;
3516
+ syncStickyHeads(node);
3517
+ const more = node.scrollTop + node.clientHeight < node.scrollHeight - 1;
3518
+ setListHasMore((current) => current === more ? current : more);
3519
+ }, []);
3520
+ react.default.useEffect(() => {
3521
+ const node = listRef.current;
3522
+ if (!node) return void 0;
3523
+ syncListEdge();
3524
+ if (typeof ResizeObserver !== "function") return void 0;
3525
+ const observer = new ResizeObserver(syncListEdge);
3526
+ observer.observe(node);
3527
+ for (const section of node.children) observer.observe(section);
3528
+ return () => observer.disconnect();
3529
+ }, [
3530
+ items,
3531
+ showOpen,
3532
+ showDone,
3533
+ syncListEdge
3534
+ ]);
3535
+ return {
3536
+ listRef,
3537
+ listHasMore,
3538
+ syncListEdge
3539
+ };
3540
+ }
3541
+
3542
+ // src/client/ui/useOutsideDismiss.ts
3543
+ /** Close the panel on an outside pointerdown or Escape. */
3544
+ function useOutsideDismiss(panelRef, anchorRef, onClose) {
3545
+ react.default.useEffect(() => {
3546
+ const onPointerDown = (event) => {
3547
+ if (panelRef.current && panelRef.current.contains(event.target)) return;
3548
+ if (anchorRef.current && anchorRef.current.contains(event.target)) return;
3549
+ onClose();
3550
+ };
3551
+ const onKeyDown = (event) => {
3552
+ if (event.key === "Escape") onClose();
3553
+ };
3554
+ document.addEventListener("pointerdown", onPointerDown, true);
3555
+ document.addEventListener("keydown", onKeyDown);
3556
+ return () => {
3557
+ document.removeEventListener("pointerdown", onPointerDown, true);
3558
+ document.removeEventListener("keydown", onKeyDown);
3559
+ };
3560
+ }, [onClose, anchorRef]);
3561
+ }
3562
+
3563
+ // src/client/ui/TodoRow.ts
3564
+ /** One note: checkbox, the row actions and the forward mark. */
3565
+ const h$10 = react.default.createElement;
3566
+ function TodoRow(props) {
3567
+ const { item, done, say, onToast, onToggle, onRecall, forwardPrefix, forwarded = false, onForwarded, onUnforwarded } = props;
3568
+ const [pending, setPending] = react.default.useState("");
3569
+ const mountedRef = react.default.useRef(true);
3570
+ react.default.useEffect(() => {
3571
+ mountedRef.current = true;
3572
+ return () => {
3573
+ mountedRef.current = false;
3574
+ };
3575
+ }, []);
3576
+ const copy = async () => {
3577
+ if (pending) return;
3578
+ setPending("copy");
3579
+ let ok = false;
3580
+ try {
3581
+ ok = await copyText(item.text);
3582
+ } finally {
3583
+ if (mountedRef.current) setPending("");
3584
+ }
3585
+ if (!mountedRef.current) return;
3586
+ if (onToast) onToast(ok ? "copied" : "copyFailed");
3587
+ };
3588
+ const forward = () => {
3589
+ if (forwarded) {
3590
+ if (onUnforwarded) onUnforwarded(item);
3591
+ if (onToast) onToast("unforwarded");
3592
+ return;
3593
+ }
3594
+ if (!appendToConversation(item.text, forwardPrefix)) {
3595
+ if (onToast) onToast("forwardFailed");
3596
+ return;
3597
+ }
3598
+ if (onForwarded) onForwarded(item);
3599
+ if (onToast) onToast("forwarded");
3600
+ };
3601
+ const toggleCheck = () => onToggle(item);
3602
+ const checked = done === true;
3603
+ return h$10("li", { className: done ? "dsh-an-row dsh-an-rowDone" : "dsh-an-row" }, h$10("button", {
3604
+ type: "button",
3605
+ className: "dsh-an-check",
3606
+ role: "checkbox",
3607
+ "aria-checked": checked ? "true" : "false",
3608
+ "aria-label": say(done ? "item.markOpen" : "item.markDone"),
3609
+ onClick: toggleCheck
3610
+ }, h$10("span", { className: "dsh-an-checkCircle" }, checked ? h$10(IconCheck, { size: 9 }) : null)), h$10("div", { className: "dsh-an-itemBody" }, h$10("div", { className: "dsh-an-text" }, item.text), h$10("div", { className: "dsh-an-rowFoot" }, h$10("span", {
3611
+ className: "dsh-an-meta",
3612
+ title: metaLabel(item, say, props.localeId)
3613
+ }, metaLabel(item, say, props.localeId)), h$10("div", { className: "dsh-an-actions" }, withTooltip(say("item.copy"), h$10("button", {
3614
+ type: "button",
3615
+ className: "dsh-an-iconBtn",
3616
+ "aria-label": say("item.copy"),
3617
+ "aria-busy": pending === "copy" ? "true" : "false",
3618
+ "data-loading": pending === "copy" ? "true" : void 0,
3619
+ onClick: copy
3620
+ }, h$10(IconCopy, null))), done ? null : withTooltip(say(forwarded ? "item.forwarded" : "item.forward"), h$10("button", {
3621
+ type: "button",
3622
+ className: "dsh-an-iconBtn",
3623
+ "aria-label": say(forwarded ? "item.forwarded" : "item.forward"),
3624
+ "data-forwarded": forwarded ? "true" : void 0,
3625
+ onClick: forward
3626
+ }, h$10(IconForward, null), forwarded ? h$10("span", {
3627
+ className: "dsh-an-forwardMark",
3628
+ "aria-hidden": true
3629
+ }, h$10(IconCheck, { size: 8 })) : null)), withTooltip(say("item.recall"), h$10("button", {
3630
+ type: "button",
3631
+ className: "dsh-an-iconBtn",
3632
+ "aria-label": say("item.recall"),
3633
+ onClick: () => onRecall(item)
3634
+ }, h$10(IconRewind, null)))))));
3635
+ }
3636
+
3637
+ // src/client/ui/ScopeSwitch.tsx
3638
+ /** Segmented switch between the workspace list and the session list. */
3639
+ const h$9 = react.default.createElement;
3640
+ function ScopeSwitch(props) {
3641
+ const { say, mode, canUseSession, onChange } = props;
3642
+ const options = [{
3643
+ value: "workspace",
3644
+ label: say("scope.workspace")
3645
+ }, ...canUseSession ? [{
3646
+ value: "session",
3647
+ label: say("scope.session")
3648
+ }] : []];
3649
+ return h$9("div", {
3650
+ className: "dsh-an-scope",
3651
+ role: "group",
3652
+ "aria-label": say("scope.label")
3653
+ }, options.map((option) => h$9(react.default.Fragment, { key: option.value }, withTooltip(option.value === "session" ? say("scope.sessionHint") : canUseSession ? say("scope.workspaceHint") : say("scope.newSessionHint"), h$9("button", {
3654
+ type: "button",
3655
+ className: "dsh-an-scopeBtn",
3656
+ "data-scope-mode": option.value,
3657
+ "data-active": mode === option.value ? "true" : void 0,
3658
+ "aria-pressed": mode === option.value,
3659
+ onClick: () => onChange(option.value)
3660
+ }, option.label)))));
3661
+ }
3662
+
3663
+ // src/client/ui/PanelHead.ts
3664
+ /** Panel title, counts, the list-scope switch and the settings/close actions. */
3665
+ const h$8 = react.default.createElement;
3666
+ function PanelHead(props) {
3667
+ const { say, openCount, total, showSettings, onToggleSettings, onClose, newerVersion, scopeMode, canUseWorkspace, canUseSession, onScopeChange } = props;
3668
+ return h$8("div", { className: "dsh-an-popHead" }, h$8("div", { className: "dsh-an-popTitleLine" }, h$8("div", { className: "dsh-an-popTitle" }, say("popover.title")), h$8("p", { className: "dsh-an-popMeta" }, say("popover.count", {
3669
+ open: openCount,
3670
+ total
3671
+ })), canUseWorkspace ? h$8(ScopeSwitch, {
3672
+ say,
3673
+ mode: scopeMode,
3674
+ canUseSession,
3675
+ onChange: onScopeChange
3676
+ }) : null), h$8("div", { className: "dsh-an-popActions" }, withTooltip(say("settings.open"), h$8("button", {
3677
+ type: "button",
3678
+ className: "dsh-an-settingsBtn",
3679
+ "data-active": showSettings ? "true" : void 0,
3680
+ "aria-label": newerVersion ? `${say("settings.open")} · ${say("update.tip", { version: `v${newerVersion}` })}` : say("settings.open"),
3681
+ "aria-expanded": showSettings,
3682
+ onClick: onToggleSettings
3683
+ }, h$8(IconGear, null), newerVersion ? h$8("span", {
3684
+ className: "dsh-an-updateDot",
3685
+ "aria-hidden": true
3686
+ }) : null)), withTooltip(say("popover.close"), h$8("button", {
3687
+ type: "button",
3688
+ className: "dsh-an-popClose",
3689
+ "aria-label": say("popover.close"),
3690
+ onClick: onClose
3691
+ }, h$8(IconClose, null)))));
3692
+ }
3693
+
3694
+ // src/client/ui/UpdateNotice.ts
3695
+ /**
3696
+ * Settings › About › update centre.
3697
+ *
3698
+ * One compact card: the published version, the release notes it ships with, and
3699
+ * the update action. The notes load and show as soon as an update is offered —
3700
+ * they are not hidden behind a disclosure. The action is a button, never
3701
+ * automatic: one host request installs the offered version, and the panel
3702
+ * reports the outcome instead of guessing.
3703
+ *
3704
+ * When the host has no update route, or refuses the install in a way a terminal
3705
+ * command can get past, the card states the exact command — with one click to
3706
+ * copy a ready-to-paste prompt for an agent. The panel never runs a package
3707
+ * manager itself.
3708
+ *
3709
+ * A jump across several versions lists each release separately: the newest one
3710
+ * opens by default and the ones behind it expand on demand, so a 2.0.0 install
3711
+ * upgrading to 2.3.0 can read 2.1.0, 2.2.0 and 2.3.0 in order. The full release
3712
+ * page opens from the link beside the update button.
3713
+ */
3714
+ const h$7 = react.default.createElement;
3715
+ const NOTES_ID = "dsh-an-update-notes";
3716
+ const UPDATE_PACKAGE = "dsh-sideby-note";
3717
+ /** Failure codes the card can explain without echoing the host's message. */
3718
+ const FAILURE_COPY = {
3719
+ PLUGIN_NOT_INSTALLED: "update.notInstalled",
3720
+ UPDATE_FORBIDDEN: "update.forbidden",
3721
+ UPDATE_REJECTED: "update.rejected",
3722
+ OPERATION_BUSY: "update.busy",
3723
+ UPDATE_TIMEOUT: "update.timeout",
3724
+ "bundle-in-use": "update.bundleInUse",
3725
+ "already-installed": "update.alreadyInstalled",
3726
+ "management-required": "update.managementRequired",
3727
+ "not-removable": "update.notRemovable",
3728
+ "stop-profile": "update.stopProfile",
3729
+ "incompatible-version": "update.incompatible",
3730
+ RESOLVED_VERSION_MISMATCH: "update.versionMismatch",
3731
+ DOWNGRADE_DETECTED: "update.downgrade",
3732
+ AUTO_UPDATE_UNAVAILABLE: "update.autoUnavailable"
3733
+ };
3734
+ /** Refusals a terminal command can actually get past. */
3735
+ const MANUAL_FALLBACK = /* @__PURE__ */ new Set([
3736
+ "OPERATION_BUSY",
3737
+ "bundle-in-use",
3738
+ "already-installed",
3739
+ "management-required",
3740
+ "not-removable",
3741
+ "stop-profile",
3742
+ "AUTO_UPDATE_UNAVAILABLE"
3743
+ ]);
3744
+ function UpdateNotice(props) {
3745
+ const { say, latestVersion, notes, expandedVersions, run, fullReleaseUrl } = props;
3746
+ const notesRef = react.default.useRef(null);
3747
+ const [fade, setFade] = react.default.useState(false);
3748
+ const syncFade = react.default.useCallback(() => {
3749
+ const node = notesRef.current;
3750
+ if (!node) {
3751
+ setFade(false);
3752
+ return;
3753
+ }
3754
+ const overflow = node.scrollHeight > node.clientHeight + 1;
3755
+ const atBottom = node.scrollTop + node.clientHeight >= node.scrollHeight - 1;
3756
+ setFade(overflow && !atBottom);
3757
+ }, []);
3758
+ react.default.useEffect(() => {
3759
+ const node = notesRef.current;
3760
+ if (!node) return void 0;
3761
+ const frame = requestAnimationFrame(syncFade);
3762
+ const onScroll = () => syncFade();
3763
+ node.addEventListener("scroll", onScroll, { passive: true });
3764
+ let observer = null;
3765
+ if (typeof ResizeObserver === "function") {
3766
+ observer = new ResizeObserver(syncFade);
3767
+ observer.observe(node);
3768
+ }
3769
+ window.addEventListener("resize", syncFade);
3770
+ return () => {
3771
+ cancelAnimationFrame(frame);
3772
+ node.removeEventListener("scroll", onScroll);
3773
+ window.removeEventListener("resize", syncFade);
3774
+ observer?.disconnect();
3775
+ };
3776
+ }, [
3777
+ notes.status,
3778
+ notes.entries,
3779
+ expandedVersions,
3780
+ syncFade
3781
+ ]);
3782
+ if (latestVersion === null) return null;
3783
+ const phase = run.phase;
3784
+ const busy = phase === "starting" || phase === "running";
3785
+ const failureKey = run.failureCode ? FAILURE_COPY[run.failureCode] : "";
3786
+ /**
3787
+ * The host reports the exact command (with the profile directory) for the
3788
+ * failures a terminal can get past. When a refusal has no command of its own,
3789
+ * pin the offered version here so a later release cannot slip in between the
3790
+ * card and the paste.
3791
+ */
3792
+ const manualCommand = react.default.useMemo(() => {
3793
+ const hinted = run.message?.trim() ?? "";
3794
+ const prerelease = isPrereleaseVersion(latestVersion);
3795
+ const hintPinsTarget = hinted.includes(latestVersion);
3796
+ const hintPinsRegistry = !prerelease || hinted.includes("--registry=https://registry.npmjs.org/");
3797
+ if (/^npx\s/u.test(hinted) && hintPinsTarget && hintPinsRegistry) return hinted;
3798
+ return `npx -y${prerelease ? " --registry=https://registry.npmjs.org/" : ""} ${prerelease ? `${UPDATE_PACKAGE}@${latestVersion}` : UPDATE_PACKAGE} install --version ${latestVersion}`;
3799
+ }, [run.message, latestVersion]);
3800
+ /**
3801
+ * No host route, or a refusal a terminal can get past: the user needs the
3802
+ * command now, not a "try again later" with nothing behind it. The panel never
3803
+ * runs a package manager itself.
3804
+ */
3805
+ const manual = run.failureCode !== null && MANUAL_FALLBACK.has(run.failureCode);
3806
+ /**
3807
+ * Hand the user a prompt they can paste into an agent. The command pins the
3808
+ * version this card offered, so a release published between render and click
3809
+ * cannot silently change the target.
3810
+ */
3811
+ const copyPrompt = () => {
3812
+ const text = say("update.prompt", {
3813
+ version: latestVersion,
3814
+ command: manualCommand
3815
+ });
3816
+ Promise.resolve(props.onCopyPrompt(text)).then((ok) => {
3817
+ if (typeof props.onToast === "function") props.onToast(ok ? "copied" : "copyFailed");
3818
+ });
3819
+ };
3820
+ const noteGroups = (list) => list.map((group, index) => h$7("div", {
3821
+ key: `${group.title}-${index}`,
3822
+ className: "dsh-an-updateGroup"
3823
+ }, group.title ? h$7("div", { className: "dsh-an-updateGroupTitle" }, group.title) : null, h$7("ul", { className: "dsh-an-updateItems" }, group.items.map((item, itemIndex) => h$7("li", {
3824
+ key: itemIndex,
3825
+ className: "dsh-an-updateItem"
3826
+ }, item.lead ? h$7("strong", null, item.lead) : null, item.lead ? " " : null, item.body)))));
3827
+ const entryBody = (entry) => entry.groups.length > 0 ? noteGroups(entry.groups) : h$7("p", { className: "dsh-an-updateHint" }, say("update.notesMissing"));
3828
+ const notesBody = notes.status === "loading" ? h$7("p", { className: "dsh-an-updateHint" }, say("update.notesLoading")) : notes.status === "error" ? h$7("p", { className: "dsh-an-updateHint" }, say("update.notesFailed")) : notes.status === "ready" && notes.entries.length === 1 ? entryBody(notes.entries[0]) : notes.status === "ready" ? h$7("div", { className: "dsh-an-updateVersions" }, h$7("p", { className: "dsh-an-updateHint" }, say("update.historyCount", { n: notes.entries.length })), notes.entries.map((entry, index) => {
3829
+ const open = expandedVersions[entry.version] === true;
3830
+ return h$7("div", {
3831
+ key: entry.version,
3832
+ className: "dsh-an-updateVersion"
3833
+ }, h$7("button", {
3834
+ type: "button",
3835
+ className: "dsh-an-updateVersionHead",
3836
+ "aria-expanded": open,
3837
+ "aria-controls": `${NOTES_ID}-${entry.version}`,
3838
+ onClick: () => props.onToggleVersion(entry.version)
3839
+ }, h$7("span", {
3840
+ className: "dsh-an-updateChevron",
3841
+ "data-open": open ? "true" : "false",
3842
+ "aria-hidden": true
3843
+ }, "▸"), h$7("span", { className: "dsh-an-updateVersionLabel" }, `v${entry.version}`), index === 0 ? h$7("span", { className: "dsh-an-updateLatest" }, say("update.latest")) : null), open ? h$7("div", {
3844
+ id: `${NOTES_ID}-${entry.version}`,
3845
+ className: "dsh-an-updateVersionBody"
3846
+ }, entryBody(entry)) : null);
3847
+ }), notes.truncated ? h$7("a", {
3848
+ className: "dsh-an-updateFull",
3849
+ href: props.releasesUrl,
3850
+ target: "_blank",
3851
+ rel: "noreferrer"
3852
+ }, say("update.olderNotes")) : null) : null;
3853
+ return h$7("div", { className: "dsh-an-updateCard" }, h$7("div", { className: "dsh-an-updateTitle" }, say("update.available", { version: `v${latestVersion}` })), h$7("div", {
3854
+ id: NOTES_ID,
3855
+ ref: notesRef,
3856
+ className: "dsh-an-updateNotes",
3857
+ role: "region",
3858
+ "aria-label": say("update.notesTitle"),
3859
+ "data-fade": fade ? "true" : void 0
3860
+ }, notesBody), h$7("div", { className: "dsh-an-updateActions" }, phase === "done" ? h$7("div", { className: "dsh-an-updateDone" }, h$7("span", { className: "dsh-an-updateHint" }, say("update.updated", { version: run.installedVersion ? `v${run.installedVersion}` : `v${latestVersion}` })), h$7("button", {
3861
+ type: "button",
3862
+ className: "dsh-an-updatePrimary",
3863
+ onClick: props.onRefresh
3864
+ }, say("update.refresh"))) : h$7("button", {
3865
+ type: "button",
3866
+ className: "dsh-an-updatePrimary",
3867
+ disabled: busy,
3868
+ "aria-busy": busy,
3869
+ onClick: () => props.onStartUpdate()
3870
+ }, busy ? phase === "running" ? say("update.updating") : say("update.starting") : say("update.now")), fullReleaseUrl ? h$7("a", {
3871
+ className: "dsh-an-updateFull",
3872
+ href: fullReleaseUrl,
3873
+ target: "_blank",
3874
+ rel: "noreferrer"
3875
+ }, say("update.full")) : null), phase === "error" ? h$7("div", { className: "dsh-an-updateErrorRow" }, h$7("p", {
3876
+ className: "dsh-an-updateError",
3877
+ role: "status"
3878
+ }, failureKey ? say(failureKey) : say("update.failed", { reason: run.message || run.failureCode || "" }))) : null, manual ? h$7("div", { className: "dsh-an-updateFallback" }, h$7("p", { className: "dsh-an-updateHint" }, say("update.manualHint", { command: manualCommand })), h$7("button", {
3879
+ type: "button",
3880
+ className: "dsh-an-updateCopy",
3881
+ onClick: copyPrompt
3882
+ }, say("update.copyPrompt"))) : null, run.phase === "done" && run.restartRequired ? h$7("p", { className: "dsh-an-updateHint" }, say("update.restartHint")) : null);
3883
+ }
3884
+
3885
+ // src/client/ui/SettingsPanel.ts
3886
+ /** Settings card: send shortcut, forward prefix and about. */
3887
+ const h$6 = react.default.createElement;
3888
+ function SettingsPanel(props) {
3889
+ const { say, sendShortcut, chooseShortcut, forwardPrefix, changeForwardPrefix, prefixRef, update } = props;
3890
+ return h$6("div", { className: "dsh-an-settings" }, h$6("div", { className: "dsh-an-settingsHead" }, say("settings.title")), h$6("div", { className: "dsh-an-settingGroup" }, h$6("div", { className: "dsh-an-settingLabel" }, say("settings.shortcut")), h$6("div", { className: "dsh-an-settingBody" }, h$6("div", { className: "dsh-an-settingChoices" }, h$6("label", { className: "dsh-an-settingChoice" }, h$6("input", {
3891
+ type: "radio",
3892
+ name: "dsh-an-send-shortcut",
3893
+ checked: sendShortcut === "enter",
3894
+ onChange: () => chooseShortcut("enter")
3895
+ }), h$6("span", null, say("settings.shortcutEnter", { mod: MOD_LABEL }))), h$6("label", { className: "dsh-an-settingChoice" }, h$6("input", {
3896
+ type: "radio",
3897
+ name: "dsh-an-send-shortcut",
3898
+ checked: sendShortcut === "ctrl-enter",
3899
+ onChange: () => chooseShortcut("ctrl-enter")
3900
+ }), h$6("span", null, say("settings.shortcutCtrlEnter", { mod: MOD_LABEL })))))), h$6("div", { className: "dsh-an-settingGroup" }, h$6("div", { className: "dsh-an-settingLabel" }, say("settings.forward")), h$6("div", { className: "dsh-an-settingBody" }, h$6("div", { className: "dsh-an-settingItem" }, h$6("textarea", {
3901
+ id: "dsh-an-forward-prefix",
3902
+ ref: prefixRef,
3903
+ className: "dsh-an-settingInput dsh-an-settingTextarea",
3904
+ value: forwardPrefix,
3905
+ rows: 1,
3906
+ maxLength: 80,
3907
+ placeholder: say("forward.prefix"),
3908
+ "aria-label": say("settings.forwardPrefixItem"),
3909
+ "aria-describedby": "dsh-an-forward-prefix-hint",
3910
+ style: {
3911
+ fontFamily: "inherit",
3912
+ fontSize: "var(--an-fs-row)",
3913
+ lineHeight: "var(--an-lh-row)",
3914
+ fontWeight: 500
3915
+ },
3916
+ onChange: (event) => changeForwardPrefix(event.target.value)
3917
+ }), h$6("p", {
3918
+ id: "dsh-an-forward-prefix-hint",
3919
+ className: "dsh-an-settingHint"
3920
+ }, say("settings.forwardPrefixHint"))))), h$6("div", { className: "dsh-an-settingGroup" }, h$6("div", { className: "dsh-an-settingLabel" }, say("settings.about")), h$6("div", { className: "dsh-an-settingBody" }, h$6("div", { className: "dsh-an-settingBrand" }, h$6("span", { className: "dsh-an-settingBrandName" }, say("title")), h$6("span", { className: "dsh-an-settingBrandTagline" }, say("settings.tagline"))), h$6("div", { className: "dsh-an-settingAbout" }, h$6("span", { className: "dsh-an-settingAboutVersion" }, `${say("settings.version")} ${PLUGIN_VERSION}`), h$6("button", {
3921
+ type: "button",
3922
+ className: "dsh-an-updateCheck",
3923
+ disabled: update.check.status === "checking",
3924
+ onClick: update.checkNow
3925
+ }, say(update.check.status === "checking" ? "update.checking" : update.check.status === "error" ? "update.retryCheck" : "update.check")), update.check.status === "current" ? h$6("span", {
3926
+ className: "dsh-an-updateHint",
3927
+ role: "status"
3928
+ }, say("update.current")) : null, update.check.status === "error" ? h$6("span", {
3929
+ className: "dsh-an-updateHint dsh-an-updateHintError",
3930
+ role: "status"
3931
+ }, say("update.checkFailed")) : null), update.latestVersion ? h$6(UpdateNotice, {
3932
+ say,
3933
+ latestVersion: update.latestVersion,
3934
+ notes: update.notes,
3935
+ expandedVersions: update.expandedVersions,
3936
+ releasesUrl: update.releasesUrl,
3937
+ run: update.run,
3938
+ fullReleaseUrl: update.fullReleaseUrl,
3939
+ onToggleVersion: update.toggleVersion,
3940
+ onStartUpdate: update.startUpdate,
3941
+ onRefresh: update.refreshPage,
3942
+ onCopyPrompt: update.copyPrompt,
3943
+ onToast: props.onToast
3944
+ }) : null, h$6("div", { className: "dsh-an-settingMetaRow" }, h$6("span", null, say("settings.author")), h$6("span", {
3945
+ className: "dsh-an-settingDot",
3946
+ "aria-hidden": true
3947
+ }, "·"), h$6("span", null, PLUGIN_AUTHOR)), h$6("div", { className: "dsh-an-settingMetaRow" }, h$6("span", null, say("settings.project")), h$6("span", {
3948
+ className: "dsh-an-settingDot",
3949
+ "aria-hidden": true
3950
+ }, "·"), h$6("a", {
3951
+ className: "dsh-an-settingLink",
3952
+ href: PLUGIN_REPO_URL,
3953
+ target: "_blank",
3954
+ rel: "noreferrer",
3955
+ title: PLUGIN_REPO_URL
3956
+ }, PLUGIN_REPO_LABEL)))));
3957
+ }
3958
+
3959
+ // src/client/ui/ComposerForm.ts
3960
+ /** The add form: one growing textarea, the shortcut hint and the submit button. */
3961
+ const h$5 = react.default.createElement;
3962
+ function ComposerForm(props) {
3963
+ const { say, draft, inputRef, sendShortcut, onDraftChange, onCompositionStart, onCompositionEnd, onKeyDown, onSubmit } = props;
3964
+ return h$5("form", {
3965
+ className: "dsh-an-add",
3966
+ onSubmit
3967
+ }, h$5("textarea", {
3968
+ ref: inputRef,
3969
+ className: "dsh-an-input",
3970
+ value: draft,
3971
+ rows: 1,
3972
+ maxLength: 280,
3973
+ placeholder: say("add.placeholder"),
3974
+ "aria-label": say("add.placeholder"),
3975
+ onChange: onDraftChange,
3976
+ onCompositionStart,
3977
+ onCompositionEnd,
3978
+ onKeyDown
3979
+ }), h$5("div", { className: "dsh-an-addFoot" }, h$5("span", { className: "dsh-an-addShortcut" }, say(sendShortcut === "enter" ? "add.shortcutEnter" : "add.shortcut", { mod: MOD_LABEL })), h$5("button", {
3980
+ type: "submit",
3981
+ className: "dsh-an-addBtn",
3982
+ disabled: !draft.trim()
3983
+ }, say("add.action"))));
3984
+ }
3985
+
3986
+ // src/client/ui/ClearConfirm.ts
3987
+ /** Inline second confirmation for clearing the completed notes. */
3988
+ const h$4 = react.default.createElement;
3989
+ function ClearConfirm(props) {
3990
+ const { say, count, onCancel, onConfirm } = props;
3991
+ return h$4("div", {
3992
+ className: "dsh-an-clearConfirm",
3993
+ role: "group",
3994
+ "aria-live": "polite",
3995
+ "aria-label": say("popover.clearConfirm", { n: count })
3996
+ }, h$4("p", { className: "dsh-an-clearConfirmText" }, say("popover.clearConfirm", { n: count })), h$4("div", { className: "dsh-an-clearConfirmActions" }, h$4("button", {
3997
+ type: "button",
3998
+ className: "dsh-an-mini",
3999
+ onClick: onCancel
4000
+ }, say("popover.clearCancel")), h$4("button", {
4001
+ type: "button",
4002
+ className: "dsh-an-mini dsh-an-miniDanger",
4003
+ onClick: onConfirm
4004
+ }, say("popover.clearConfirmAction"))));
4005
+ }
4006
+
4007
+ // src/client/ui/EmptyState.ts
4008
+ const h$3 = react.default.createElement;
4009
+ function EmptyState(props) {
4010
+ return h$3("div", { className: "dsh-an-empty" }, h$3("div", { className: "dsh-an-emptyIcon" }, h$3(IconEmpty, null)), h$3("div", { className: "dsh-an-emptyTitle" }, props.title), h$3("div", { className: "dsh-an-emptyBody" }, props.body));
4011
+ }
4012
+
4013
+ // src/client/ui/NoteList.ts
4014
+ /** Open/completed sections, their sticky heads, rows and the clear confirmation. */
4015
+ const h$2 = react.default.createElement;
4016
+ function NoteList(props) {
4017
+ const { say, listRef, listHasMore, syncListEdge, showOpen, toggleOpen, openItems, openCount, total, row, showDone, toggleDone, doneItems, confirmClear, askClearConfirm, dismissClearConfirm, confirmClearDone } = props;
4018
+ return h$2("div", {
4019
+ className: "dsh-an-listViewport",
4020
+ "data-bottom": listHasMore ? "true" : void 0
4021
+ }, h$2("div", {
4022
+ className: "dsh-an-listArea",
4023
+ ref: listRef,
4024
+ onScroll: syncListEdge
4025
+ }, h$2("div", { className: "dsh-an-listSection" }, h$2("div", { className: "dsh-an-sectionHead" }, h$2("button", {
4026
+ type: "button",
4027
+ className: "dsh-an-doneToggle",
4028
+ "aria-expanded": showOpen ? "true" : "false",
4029
+ onClick: toggleOpen
4030
+ }, h$2("span", {
4031
+ className: "dsh-an-chevron",
4032
+ "data-open": showOpen ? "true" : "false"
4033
+ }, h$2(IconChevron, null)), say("list.open"), openCount ? h$2("span", { className: "dsh-an-sectionCount" }, String(openCount)) : null)), showOpen ? openItems.length ? h$2("ul", { className: "dsh-an-rows" }, openItems.map(row)) : h$2(EmptyState, {
4034
+ title: say(total ? "list.allDone.title" : "popover.empty.title"),
4035
+ body: say(total ? "list.allDone.body" : "popover.empty.body")
4036
+ }) : null), doneItems.length ? h$2("div", { className: "dsh-an-listSection" }, h$2("div", { className: "dsh-an-doneHead" }, h$2("button", {
4037
+ type: "button",
4038
+ className: "dsh-an-doneToggle",
4039
+ "aria-expanded": showDone ? "true" : "false",
4040
+ onClick: toggleDone
4041
+ }, h$2("span", {
4042
+ className: "dsh-an-chevron",
4043
+ "data-open": showDone ? "true" : "false"
4044
+ }, h$2(IconChevron, null)), say("popover.completed"), h$2("span", { className: "dsh-an-sectionCount" }, String(doneItems.length))), showDone ? h$2("button", {
4045
+ type: "button",
4046
+ className: "dsh-an-clear",
4047
+ "aria-expanded": confirmClear ? "true" : "false",
4048
+ onClick: askClearConfirm
4049
+ }, say("popover.clearDone")) : null), showDone && confirmClear ? h$2(ClearConfirm, {
4050
+ say,
4051
+ count: doneItems.length,
4052
+ onCancel: dismissClearConfirm,
4053
+ onConfirm: confirmClearDone
4054
+ }) : null, showDone ? h$2("ul", { className: "dsh-an-rows dsh-an-doneRows" }, doneItems.map(row)) : null) : null));
4055
+ }
4056
+
4057
+ // src/client/ui/MemoPopover.ts
4058
+ /**
4059
+ * The floating notes panel.
4060
+ *
4061
+ * State, handlers and effects for the list in view; the markup lives in the
4062
+ * sibling components, the geometry in usePanelGeometry and the store in
4063
+ * useSessionMemoStore.
4064
+ */
4065
+ const h$1 = react.default.createElement;
4066
+ function MemoPopover(props) {
4067
+ const say = props.say;
4068
+ const localeId = props.localeId;
4069
+ const sessionId = props.sessionId || "";
4070
+ /** The header switch remembers its choice; a workspace-less session stays session-scoped. */
4071
+ const [mode, setMode] = react.default.useState(() => readScopeMode());
4072
+ react.default.useEffect(() => {
4073
+ const onStorage = (event) => {
4074
+ if (event && event.key === "dsh.aside-note.scope-mode") setMode(readScopeMode());
4075
+ };
4076
+ window.addEventListener("storage", onStorage);
4077
+ return () => window.removeEventListener("storage", onStorage);
4078
+ }, []);
4079
+ react.default.useSyncExternalStore(subscribeScope, scopeVersion, scopeVersion);
4080
+ const canUseWorkspace = Boolean(workspaceScopeForSession(sessionId));
4081
+ const canUseSession = canUseSessionScope(sessionId);
4082
+ const effectiveMode = canUseSession ? mode : "workspace";
4083
+ const scope = scopeForSession(sessionId, effectiveMode);
4084
+ const draftKey = draftKeyForSession(sessionId);
4085
+ /** Settled outcomes go to the frame-wide toast host, not to inline marks. */
4086
+ const report = typeof props.onToast === "function" ? props.onToast : () => {};
4087
+ const { record, syncError, commit } = useMemoStore(scope);
4088
+ const { sectionsRef, showOpen, showDone, toggleOpen, toggleDone, applySections } = useSections();
4089
+ const { forwardedIds, rememberForwarded, unrememberForwarded, forgetForwardedItems } = useForwardMarks(scopeKey(scope));
4090
+ const { showSettings, setShowSettings, sendShortcut, chooseShortcut, forwardPrefix, changeForwardPrefix, prefixRef } = usePanelSettings();
4091
+ const update = useUpdateCenter(localeId);
4092
+ const newerVersion = update.latestVersion;
4093
+ const { draft, addRef, composingRef, add, recall, onDraftChange, onDraftKeyDown } = useComposerDraft({
4094
+ draftKey,
4095
+ commit,
4096
+ report,
4097
+ sendShortcut
4098
+ });
4099
+ const { toggle, takeBack } = useNoteActions({
4100
+ commit,
4101
+ report,
4102
+ forgetForwardedItems
4103
+ });
4104
+ const { confirmClear, askClearConfirm, dismissClearConfirm, confirmClearDone } = useClearConfirm({
4105
+ sessionId,
4106
+ showDone,
4107
+ doneCount: record.items.filter((item) => item.done).length,
4108
+ onConfirm: () => clearDone()
4109
+ });
4110
+ const panelRef = react.default.useRef(null);
4111
+ const { style, commitPanelWidth, commitPanelHeight, startPanelResize, startPanelHeightResize, onPanelResizeKeyDown, onPanelHeightKeyDown } = usePanelGeometry(props.anchorRef, props.placement, panelRef);
4112
+ const items = record.items || [];
4113
+ const openItems = items.filter((item) => !item.done);
4114
+ const doneItems = items.filter((item) => item.done).sort(compareDoneItems);
4115
+ const openCount = openItems.length;
4116
+ const total = items.length;
4117
+ const { listRef, listHasMore, syncListEdge } = useListEdge({
4118
+ items,
4119
+ showOpen,
4120
+ showDone
4121
+ });
4122
+ useOutsideDismiss(panelRef, props.anchorRef, props.onClose);
4123
+ const chooseScope = (next) => {
4124
+ if (next === mode) return;
4125
+ if (next === "session" && !canUseSession) return;
4126
+ if (next === "workspace" && !canUseWorkspace) return;
4127
+ if (next === "workspace") {
4128
+ const workspace = scopeForSession(sessionId, "workspace");
4129
+ if (workspace.kind === "workspace") ensureWorkspaceRecord(workspace.id, workspace.sessionIds);
4130
+ }
4131
+ writeScopeMode(next);
4132
+ setMode(next);
4133
+ dismissClearConfirm();
4134
+ notifyTodoChange();
4135
+ };
4136
+ const clearDone = () => {
4137
+ const clearedItems = items.filter((item) => item.done);
4138
+ if (!commit((currentItems) => currentItems.filter((item) => !item.done))) {
4139
+ report("saveFailed");
4140
+ return;
4141
+ }
4142
+ report("cleared");
4143
+ forgetForwardedItems(clearedItems.map((item) => item.id));
4144
+ applySections({
4145
+ open: sectionsRef.current.open,
4146
+ done: false
4147
+ });
4148
+ };
4149
+ /**
4150
+ * 退回 moves the note's text into the top composer and removes the row.
4151
+ * The composer is the only text editor, so recalling over an existing draft
4152
+ * would silently destroy it; ask the user to send or clear it first instead.
4153
+ */
4154
+ const recallItem = (item) => {
4155
+ if (draft.trim()) {
4156
+ report("recallBlocked");
4157
+ return;
4158
+ }
4159
+ if (!takeBack(item)) return;
4160
+ recall(item.text);
4161
+ report("recalled");
4162
+ };
4163
+ const row = (item) => h$1(TodoRow, {
4164
+ key: item.id,
4165
+ item,
4166
+ done: item.done,
4167
+ say,
4168
+ localeId,
4169
+ onToast: report,
4170
+ onToggle: toggle,
4171
+ onRecall: recallItem,
4172
+ forwardPrefix: forwardPrefix.trim() ? forwardPrefix : say("forward.prefix"),
4173
+ forwarded: forwardedIds[item.id] === true,
4174
+ onForwarded: rememberForwarded,
4175
+ onUnforwarded: unrememberForwarded
4176
+ });
4177
+ const content = h$1("div", {
4178
+ ref: panelRef,
4179
+ className: props.placement === "right" ? "dsh-an-popover dsh-an-popoverRight" : "dsh-an-popover",
4180
+ style,
4181
+ "data-settings": showSettings ? "true" : void 0,
4182
+ role: "dialog",
4183
+ "aria-label": say("popover.title")
4184
+ }, props.placement === "right" ? h$1("div", {
4185
+ className: "dsh-an-resizeHandle",
4186
+ role: "separator",
4187
+ "aria-orientation": "vertical",
4188
+ "aria-label": say("resize.width"),
4189
+ tabIndex: 0,
4190
+ title: say("resize.hint"),
4191
+ onPointerDown: startPanelResize,
4192
+ onDoubleClick: () => commitPanelWidth(360),
4193
+ onKeyDown: onPanelResizeKeyDown
4194
+ }) : null, props.placement === "right" ? h$1("div", {
4195
+ className: "dsh-an-resizeHandleBottom",
4196
+ role: "separator",
4197
+ "aria-orientation": "horizontal",
4198
+ "aria-label": say("resize.height"),
4199
+ tabIndex: 0,
4200
+ title: say("resize.hint"),
4201
+ onPointerDown: startPanelHeightResize,
4202
+ onDoubleClick: () => commitPanelHeight(0),
4203
+ onKeyDown: onPanelHeightKeyDown
4204
+ }) : null, h$1(PanelHead, {
4205
+ say,
4206
+ openCount,
4207
+ total,
4208
+ showSettings,
4209
+ onToggleSettings: () => setShowSettings((value) => !value),
4210
+ onClose: props.onClose,
4211
+ newerVersion,
4212
+ scopeMode: effectiveMode,
4213
+ canUseWorkspace,
4214
+ canUseSession,
4215
+ onScopeChange: chooseScope
4216
+ }), showSettings ? h$1("div", { className: "dsh-an-settingsViewport" }, h$1(SettingsPanel, {
4217
+ say,
4218
+ sendShortcut,
4219
+ chooseShortcut,
4220
+ forwardPrefix,
4221
+ changeForwardPrefix,
4222
+ prefixRef,
4223
+ update,
4224
+ onToast: report
4225
+ })) : null, h$1(ComposerForm, {
4226
+ say,
4227
+ draft,
4228
+ inputRef: addRef,
4229
+ sendShortcut,
4230
+ onDraftChange,
4231
+ onCompositionStart: () => {
4232
+ composingRef.current = true;
4233
+ },
4234
+ onCompositionEnd: () => {
4235
+ composingRef.current = false;
4236
+ },
4237
+ onKeyDown: onDraftKeyDown,
4238
+ onSubmit: (event) => {
4239
+ event.preventDefault();
4240
+ if (composingRef.current) return;
4241
+ add();
4242
+ }
4243
+ }), h$1(NoteList, {
4244
+ say,
4245
+ listRef,
4246
+ listHasMore,
4247
+ syncListEdge,
4248
+ showOpen,
4249
+ toggleOpen,
4250
+ openItems,
4251
+ openCount,
4252
+ total,
4253
+ row,
4254
+ showDone,
4255
+ toggleDone,
4256
+ doneItems,
4257
+ confirmClear,
4258
+ askClearConfirm,
4259
+ dismissClearConfirm,
4260
+ confirmClearDone
4261
+ }), h$1("div", {
4262
+ className: "dsh-an-popFoot",
4263
+ role: "status"
4264
+ }, h$1("span", { className: syncError ? "dsh-an-error" : void 0 }, say(syncError ? "storage.failed" : "popover.local"))));
4265
+ return react_dom.default.createPortal(content, document.body);
4266
+ }
4267
+
4268
+ // src/client/index.ts
4269
+ /**
4270
+ * Sideby Note browser half.
4271
+ *
4272
+ * The plugin entry: injects the stylesheet, binds the locale namespace and
4273
+ * seats the two slots (session capture + frame-wide toast host) plus the
4274
+ * host-owned header entry. Copy, storage, domain rules and the panel UI live
4275
+ * in their own modules; P2 splits the remaining UI out of this file.
4276
+ */
4277
+ const h = react.default.createElement;
4278
+ /** Hosts without ui-workspace (and the bundle test) keep the session list. */
4279
+ const useNoWorkspace = () => null;
4280
+ /** Hosts without a session list cannot tell a new session from an old one. */
4281
+ const useNoSessions = () => void 0;
4282
+ /** Compact floating memo list, anchored to the entry that opened it. */
4283
+ function apply(ctx) {
4284
+ const locale = ctx.get("locale");
4285
+ ctx.effect(() => {
4286
+ const style = document.createElement("style");
4287
+ style.dataset.dshPlugin = "dsh-sideby-note";
4288
+ style.textContent = panel_css_default;
4289
+ document.head.appendChild(style);
4290
+ return () => {
4291
+ style.remove();
4292
+ };
4293
+ }, "dsh-sideby-note: styles");
4294
+ if (locale && typeof locale.register === "function") ctx.effect(() => locale.register(NS, DICT), "dsh-sideby-note: dictionaries");
4295
+ const localeId = () => {
4296
+ try {
4297
+ const current = locale && typeof locale.getLocale === "function" ? locale.getLocale() : null;
4298
+ const id = current && (current.id || current.locale);
4299
+ return typeof id === "string" && id ? id : "en";
4300
+ } catch {
4301
+ return "en";
4302
+ }
4303
+ };
4304
+ const say = makeSay(ctx, localeId);
4305
+ const tr = (key, vars) => fill(say(key), vars);
4306
+ let activePopover = null;
4307
+ let activeSessionId = "";
4308
+ const toastSeat = createToastSeat(tr);
4309
+ let refreshHeaderEntry = () => {};
4310
+ const closeMemoPopover = () => {
4311
+ const current = activePopover;
4312
+ activePopover = null;
4313
+ if (!current) return;
4314
+ const hadFocus = current.container.contains(document.activeElement);
4315
+ try {
4316
+ current.root.unmount();
4317
+ } catch {}
4318
+ current.container.remove();
4319
+ const anchor = current.anchor;
4320
+ if (hadFocus && anchor && anchor.isConnected && typeof anchor.focus === "function") anchor.focus({ preventScroll: true });
4321
+ refreshHeaderEntry();
4322
+ };
4323
+ const openMemoPopover = (sessionId, anchor, placement = "popover") => {
4324
+ if (activePopover && activePopover.anchor === anchor) {
4325
+ closeMemoPopover();
4326
+ return;
4327
+ }
4328
+ closeMemoPopover();
4329
+ const scope = scopeForSession(sessionId, readScopeMode());
4330
+ if (scope.kind === "workspace") ensureWorkspaceRecord(scope.id, scope.sessionIds);
4331
+ const workspace = workspaceScopeForSession(sessionId);
4332
+ if (workspace) ensureDraftScope(draftKeyForSession(sessionId), sessionId, workspace.sessionIds);
4333
+ setForwardTarget(sessionId);
4334
+ const container = document.createElement("div");
4335
+ container.dataset.dshMemoPopoverRoot = "true";
4336
+ document.body.appendChild(container);
4337
+ const root = react_dom_client.default.createRoot(container);
4338
+ activePopover = {
4339
+ container,
4340
+ root,
4341
+ anchor,
4342
+ placement
4343
+ };
4344
+ root.render(h(MemoPopover, {
4345
+ sessionId,
4346
+ say: tr,
4347
+ localeId: localeId(),
4348
+ anchorRef: { current: anchor },
4349
+ placement,
4350
+ onClose: closeMemoPopover,
4351
+ onToast: (kind) => toastSeat.show(kind)
4352
+ }));
4353
+ refreshHeaderEntry();
4354
+ };
4355
+ const headerEntry = createHeaderEntry({
4356
+ getSessionId: () => activeSessionId,
4357
+ getActiveAnchor: () => activePopover ? activePopover.anchor : null,
4358
+ getLocaleId: () => localeId(),
4359
+ tr,
4360
+ onOpen: (sessionId, anchor) => openMemoPopover(sessionId, anchor, "right")
4361
+ });
4362
+ refreshHeaderEntry = headerEntry.refresh;
4363
+ ctx.effect(() => headerEntry.attach(() => closeMemoPopover()), "dsh-sideby-note: right-side entry");
4364
+ function BoundSessionCapture(props) {
4365
+ const sessionId = props.sessionId || "";
4366
+ const useWorkspaces = typeof props.useWorkspaces === "function" ? props.useWorkspaces : useNoWorkspace;
4367
+ const useSessions = typeof props.useSessions === "function" ? props.useSessions : useNoSessions;
4368
+ const snapshot = useWorkspaces((state) => state);
4369
+ const summary = useSessions((state) => state && state.byId ? state.byId[sessionId] : void 0);
4370
+ const sessionReady = !(summary && summary.blank === true);
4371
+ const workspace = react.default.useMemo(() => {
4372
+ return (snapshot && Array.isArray(snapshot.items) ? snapshot.items : []).find((candidate) => candidate && Array.isArray(candidate.sessionIds) && candidate.sessionIds.includes(sessionId)) || null;
4373
+ }, [snapshot, sessionId]);
4374
+ const workspaceRef = react.default.useRef({
4375
+ sessionId: "",
4376
+ workspaceId: ""
4377
+ });
4378
+ react.default.useEffect(() => {
4379
+ const workspaceId = workspace ? String(workspace.workspaceId) : "";
4380
+ const previous = workspaceRef.current;
4381
+ const workspaceChanged = previous.sessionId === sessionId && previous.workspaceId !== workspaceId;
4382
+ workspaceRef.current = {
4383
+ sessionId,
4384
+ workspaceId
4385
+ };
4386
+ bindWorkspace(sessionId, workspace, sessionReady);
4387
+ if (activeSessionId !== sessionId) {
4388
+ activeSessionId = sessionId;
4389
+ setForwardTarget(sessionId);
4390
+ closeMemoPopover();
4391
+ } else if (workspaceChanged) closeMemoPopover();
4392
+ if (workspace) ensureWorkspaceRecord(workspace.workspaceId, workspace.sessionIds);
4393
+ refreshHeaderEntry();
4394
+ }, [
4395
+ sessionId,
4396
+ workspace,
4397
+ sessionReady
4398
+ ]);
4399
+ return null;
4400
+ }
4401
+ ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
4402
+ name: "conversation.composer.dock",
4403
+ id: PANEL_ID,
4404
+ order: 30,
4405
+ locale: NS
4406
+ }, BoundSessionCapture));
4407
+ ctx.slots.inject("conversation.hero.options", () => ctx.slots.register({
4408
+ name: "conversation.hero.options",
4409
+ id: `${PANEL_ID}.new-session`,
4410
+ order: 30,
4411
+ locale: NS
4412
+ }, BoundSessionCapture));
4413
+ ctx.slots.inject("shell.overlay", () => ctx.slots.register({
4414
+ name: "shell.overlay",
4415
+ id: `${PANEL_ID}.toast`,
4416
+ order: 60,
4417
+ locale: NS
4418
+ }, toastSeat.ToastHost));
4419
+ }
4420
+ module.exports = {
4421
+ inject: ["slots"],
4422
+ apply
4423
+ };
4424
+
4425
+ return module.exports; } });