@v587d/capital-generation 2.27.0 → 2.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@
7
7
  - **第三位(patch)**:不破坏既有工具 / 配置 / 会话的新增与修复(如 2.1.1、2.1.2)。
8
8
  - **第二位(minor)**:有需要用户知晓的行为变更,且段内附迁移说明(如 2.1.0 的图表呈现通道重做、2.2.0 的数据源与检索来源扩容、2.4.0 的**必须换宿主版本**、2.9.0 的选择器收敛与质检前置——本插件自己的工具与数据契约没变,所以只抬第二位)。
9
9
 
10
+ ## [2.27.1] - 2026-11-18
11
+
12
+ 修掉「分时」块在收盘后必现的加载失败,以及失败态里那个看不出是按钮的「重试」。
13
+
14
+ ### Fixed
15
+
16
+ - **盘后一次"重述"把整块分时判死**:腾讯收盘后会补一根把当日成交额改低的收尾行(300803.SZ:15:29 那行比 15:28 少 263,680.82 元,成交量不变),而分时解析是**先**做"累计量不许倒退"的护栏、**再**按 15:00 截掉盘后行——护栏于是在一根永远不会上图的盘后行上抛错,整块图被判成坏数据。现在先截断再判断;累计量回退当作上游重述(语义是"这一分钟没有新成交"),delta 归零、累计取高水位继续累加;只剩**时间倒流**仍响亮失败(那才会让横轴回头)。
17
+ - **失败原因不再被吞掉**:面板此前只留宿主回执里的 `code`,`message`("上游没有及时回话"一类)在客户端被丢弃,用户只能看到一句「分时加载失败」。现在 `message` 随失败一起进状态,显示在标题下面;同一套失败态给「日K」复用。
18
+ - **「重试」改成真按钮**:原来用的 `.cwd-pill` 背景色与它所在空态盒同色,在 300px 高的虚线框里就是一段可点的文字。新 `.cwd-retry` 与右上角「刷新行情」同一套配方(34px 高 / 10px 圆角 / 12.5px / 主色描边 + 刷新图标 / 悬停、按下与焦点环),空态盒也从虚线改实底。
19
+ - **上游故障不再冒充"该市场没有数据"**:三个分时入口全挂时原本返回 `trend_unavailable`,面板会显示"该市场暂时没有分时数据"的空态(没有重试键),把可恢复的上游故障说成市场能力缺失。现在区分成 `trend_upstream_unavailable` / `kline_upstream_unavailable`(可重试),`*_unavailable` 只留给真正没有该市场数据的情况(港美股指数、场外美股等);报文读不懂与连不上也各有各的码。
20
+
21
+ ### Notes
22
+
23
+ - 五个包版本同步抬到 `2.27.1`;`LOCAL_FETCH_CLIENT_VERSION` 与 `WIND_CLIENT_VERSION` 随版本号更新。用户侧无需迁移。
24
+ - 宿主新增一行失败日志:`capital-watchlist: <route> <标的> → <错误码>`(只记上游与存储故障,代码格式错误、已移出清单这类调用方问题不记)——面板只有一句话,排障靠它。**这一行要重启 dsh 才会出现**(宿主半边没有热更新);前端半边刷新页面即生效。
25
+ - 回归:`test/trend-fixtures.mjs` 收了 300803.SZ 那根收盘后报文的原文,解析护栏用例据此断言盘后行不上图、回退不产生负量、日总量取报价口径;另有「失败原因整条链路」(回执 message → 面板文案)与重试按钮 `type="button"` 的断言。详见 `docs/design/watchlist-intraday-v0.1.md` §11.7。
26
+
10
27
  ## [2.27.0] - 2026-11-18
11
28
 
12
29
  「自选股」行情工作台补上两张图:当日分时(价格、均价、昨收基准与成交量)和历史日 K(蜡烛、四条均线、成交量)。分时 A 股与港股走腾讯公开入口、美股走东财,日 K 三个市场都走腾讯(与 `get_kline` 同一套解析)。
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green" alt="License"></a>
4
4
  <a href="https://github.com/v587d/capital-generation"><img src="https://img.shields.io/badge/Financial%20Market-CN%20%7C%20HK%20%7C%20US-orange" alt="Market·CN+HK+US"></a>
5
5
  <a href="https://github.com/deepseek-ai"><img src="https://img.shields.io/badge/DSH%20Baseline-0.2.2--rc.2-blue" alt="DSH@0.2.2-rc.2"></a>
6
- <a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.27.0-9cf" alt="Version"></a>
6
+ <a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.27.1-9cf" alt="Version"></a>
7
7
  <a href="https://www.npmjs.com/package/@v587d/capital-generation"><img src="https://img.shields.io/npm/v/%40v587d%2Fcapital-generation" alt="npm version"></a>
8
8
  </p>
9
9
 
@@ -191,7 +191,7 @@ Capital Generation 是运行在 [DeepSeek Harness(DSH)](https://github.com/d
191
191
  - **安装后找不到模式?** 确认插件出现在「插件」→ 已安装列表;Web / CLI profile 安装后要重启该 profile,并在新会话选择模式。选择器里应看到自动模式、行情专家、资讯专员;分析师和绘图专员是自动模式的内部角色,不会出现在这里。
192
192
  - **配置在哪?** 打开「插件」→ 已安装的 **Capital Generation**,插件介绍下方就是「数据源 / 投研自动化 / 精选 Skills / 包含的组件 / 分析环境」五格,五把密钥都在第一格;第二格可指定任务统一使用的默认工作区,也能改自动检查间隔与最长运行时间等上限;第五格准备 Python 分析环境;不在 DSH 的普通「设置」页面,也不用点进任何一行组件。保存密钥后新建会话再试。
193
193
  - **升级到 2.9.0 后,分析师和绘图专员去哪了?** 这一版把它们收进自动模式内部,不再出现在选择器与预设管理里,避免误开一个没有取数入口的空会话。旧会话仍能按原身份恢复;新任务直接用自动模式提出即可。
194
- - **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.27.0` 或 `@2.27.0`。
194
+ - **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.27.1` 或 `@2.27.1`。
195
195
  - **刚发布的新版本装不到?** 桌面端取包时会跳过**刚发布不久**的版本(宿主侧包管理器的发布冷却策略,实测会静默装成上一个版本),国内镜像的同步也可能滞后一段时间。急着用最新代码,改用仓库地址安装最直接;但仓库地址安装的是 git 依赖,插件页不显示「版本」检查。
196
196
  - **插件页的「版本」段怎么用?** 只有用包名从 npm 安装的版本才有;它只列比当前新的版本。回旧版要先卸载,再安装 `@v587d/capital-generation@版本号`(桌面端地址末尾加 `#v版本号`);旧版必须匹配当前 DSH 基线,对应关系见 [CHANGELOG 的 Migration](CHANGELOG.md)。
197
197
  - **网页抓取失败?** 配置卡片中的「允许启动本地提取网页内容」默认开启:AnySearch 提取失败时可尝试本机直连。关闭后,本机直连的具名来源查询也不可用;请检查该开关和网络连接。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-automation",
3
- "version": "2.27.0",
3
+ "version": "2.27.1",
4
4
  "description": "CapGen 投研自动化:独立 host bundle(固定 capital_automation 域、单 scheduler owner、/capital-automation 路由与浏览器页面)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-charts",
3
- "version": "2.27.0",
3
+ "version": "2.27.1",
4
4
  "description": "自动模式的图表前端组件(浏览器半边 + 序列旁路路由):由 @v587d/capital-generation 随包携带并作为 host 平面行挂载。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/config",
3
- "version": "2.27.0",
3
+ "version": "2.27.1",
4
4
  "description": "自动模式的取数凭据与偏好配置行:卡片坐在 @v587d/capital-generation 插件主页的「配置」段,点这一行本身没有表单。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -211,8 +211,6 @@ async function fetchTencentTrend(target, signal, now) {
211
211
  const high = numberOrNull(qt[33]);
212
212
  const low = numberOrNull(qt[34]);
213
213
  const rows = [];
214
- let previousVolume = 0;
215
- let previousAmount = 0;
216
214
  for (const raw of series.data) {
217
215
  if (typeof raw !== 'string')
218
216
  throw sourceError(`Tencent minute trend ${symbol} row is not a string`, 'trend_parse_failed');
@@ -227,11 +225,6 @@ async function fetchTencentTrend(target, signal, now) {
227
225
  const cumAmount = requiredNumber(amountText, 'cumulative amount');
228
226
  if (price <= 0)
229
227
  throw sourceError(`Tencent minute trend ${symbol} returned a non-positive price at ${stamp}`, 'trend_parse_failed');
230
- if (cumVolume < previousVolume || cumAmount < previousAmount) {
231
- throw sourceError(`Tencent minute trend ${symbol} cumulative totals moved backwards at ${stamp}`, 'trend_parse_failed');
232
- }
233
- previousVolume = cumVolume;
234
- previousAmount = cumAmount;
235
228
  rows.push({ time: `${stamp.slice(0, 2)}:${stamp.slice(2)}`, price, cumVolume, cumAmount });
236
229
  }
237
230
  if (rows.length === 0)
@@ -252,11 +245,19 @@ async function fetchTencentTrend(target, signal, now) {
252
245
  const points = [];
253
246
  let previousKeptVolume = 0;
254
247
  let previousKeptAmount = 0;
248
+ let previousTime = '';
255
249
  for (const row of kept) {
256
- const volume = row.cumVolume - previousKeptVolume;
257
- const amount = row.cumAmount - previousKeptAmount;
258
- previousKeptVolume = row.cumVolume;
259
- previousKeptAmount = row.cumAmount;
250
+ if (previousTime !== '' && row.time < previousTime) {
251
+ throw sourceError(`Tencent minute trend ${symbol} time moved backwards at ${row.time}`, 'trend_parse_failed');
252
+ }
253
+ previousTime = row.time;
254
+ // Tencent restates the running totals when a print settles (300803.SZ 2026-11-18: the final row
255
+ // carried 0.04% less turnover than the row before it). A restatement is not corruption: it means
256
+ // "no new trade", so the delta clamps to zero and the running total keeps its high-water mark.
257
+ const volume = Math.max(0, row.cumVolume - previousKeptVolume);
258
+ const amount = Math.max(0, row.cumAmount - previousKeptAmount);
259
+ previousKeptVolume = Math.max(previousKeptVolume, row.cumVolume);
260
+ previousKeptAmount = Math.max(previousKeptAmount, row.cumAmount);
260
261
  const shares = row.cumVolume * lot;
261
262
  const avg = target.isIndex || shares <= 0 ? null : row.cumAmount / shares;
262
263
  points.push([row.time, row.price, avg, volume, amount]);
@@ -3,7 +3,7 @@
3
3
  * Known limit: DNS resolves per request but the IP is not pinned to the connection,
4
4
  * so a rebinding window remains (same trade-off as dsh-search-first).
5
5
  */
6
- export declare const LOCAL_FETCH_CLIENT_VERSION = "2.27.0";
6
+ export declare const LOCAL_FETCH_CLIENT_VERSION = "2.27.1";
7
7
  export declare const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
8
8
  export type LocalFetchErrorCode = 'ABORTED' | 'TIMEOUT' | 'INVALID_URL' | 'BLOCKED_URL' | 'DNS' | 'REDIRECT' | 'HTTP' | 'TOO_LARGE' | 'UNSUPPORTED_CONTENT_TYPE';
9
9
  export declare class LocalFetchError extends Error {
@@ -4,7 +4,7 @@
4
4
  * so a rebinding window remains (same trade-off as dsh-search-first).
5
5
  */
6
6
  import { htmlToMarkdown, stripInvisibleText } from './html-markdown.js';
7
- export const LOCAL_FETCH_CLIENT_VERSION = '2.27.0';
7
+ export const LOCAL_FETCH_CLIENT_VERSION = '2.27.1';
8
8
  export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
9
9
  export class LocalFetchError extends Error {
10
10
  code;
@@ -35,7 +35,7 @@ export interface WindCallResult {
35
35
  code?: WindErrorCode;
36
36
  }
37
37
  /** Must match `package.json` version; a test pins the two together. */
38
- export declare const WIND_CLIENT_VERSION = "2.27.0";
38
+ export declare const WIND_CLIENT_VERSION = "2.27.1";
39
39
  export interface WindClient {
40
40
  callTool(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<WindCallResult>;
41
41
  }
@@ -19,7 +19,7 @@ export const WIND_SERVER_ENDPOINTS = {
19
19
  analytics_data: 'https://mcp.wind.com.cn/vserver_analytics_data/mcp/',
20
20
  };
21
21
  /** Must match `package.json` version; a test pins the two together. */
22
- export const WIND_CLIENT_VERSION = '2.27.0';
22
+ export const WIND_CLIENT_VERSION = '2.27.1';
23
23
  function errorText(error) {
24
24
  return error instanceof Error ? error.message : String(error);
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-generation",
3
- "version": "2.27.0",
3
+ "version": "2.27.1",
4
4
  "description": "Capital Generation:面向中国散户的 AI 投资助手插件(自动模式 Agent Preset)",
5
5
  "icon": "assets/cg-icon.png",
6
6
  "author": "v587d",
@@ -5,7 +5,7 @@ window.__ModuleLoader__.load({
5
5
  var module = { exports: {} }
6
6
  var exports = module.exports
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
8
- "use strict";var Te=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var At=Object.prototype.hasOwnProperty;var Tt=(t,a,i)=>()=>{if(i)throw i[0];try{return t&&(a=t(t=0)),a}catch(r){throw i=[r],r}};var zt=(t,a)=>{for(var i in a)Te(t,i,{get:a[i],enumerable:!0})},Ht=(t,a,i,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of Mt(a))!At.call(t,s)&&s!==i&&Te(t,s,{get:()=>a[s],enumerable:!(r=Ct(a,s))||r.enumerable});return t};var Pt=t=>Ht(Te({},"__esModule",{value:!0}),t);var Ke={};zt(Ke,{ASSET_TYPES:()=>Et,HOLDABLE_ASSET_TYPES:()=>qe,MAX_ROW_WEIGHT_PCT:()=>Ft,MAX_TOTAL_WEIGHT_PCT:()=>Ot,holdingWeight:()=>Be,isHoldable:()=>Rt,otherHeldWeightPct:()=>We,weightCeiling:()=>It});var Et,qe,Rt,Ft,Ot,Be,We,It,Qe=Tt(()=>{"use strict";Et=["a-share","a-share-index","fund-etf","hk-stock","hk-index","us-stock","us-index"],qe=["a-share","fund-etf","hk-stock","us-stock"],Rt=t=>qe.includes(t?.asset_type),Ft=100,Ot=120,Be=t=>t?.holding===null||t?.holding===void 0?0:t?.holding?.weight_pct??0,We=(t,a)=>t.reduce((i,r)=>r?.thscode===a?i:i+Be(r),0),It=(t,a)=>Math.max(0,Math.min(100,120-We(t,a)))});var{createElement:e,useEffect:ge,useRef:Le,useState:A}=require("react"),{createSnapshotStore:Lt}=require("@deepseek-ai/dsh-client-store"),{IconChecklistOutlineRegular:ke,IconCloseOutlineRegular:Ye,IconDatabaseOutlineRegular:Ut,IconEllipsisOutlineRegular:nt,IconGoalOutlineRegular:rt,IconListPenOutlineRegular:jt,IconPinOutlineRegular:ot,IconRefreshOutlineRegular:ct,IconSearchOutlineRegular:dt,IconTrashOutlineRegular:Re,Menu:Fe,MenuItemButton:Ne,Modal:Dt,Switch:Gt}=require("@deepseek-ai/dsh-client-ui-primitives"),{isHoldable:Ve,weightCeiling:pt}=(Qe(),Pt(Ke)),he="capital-watchlist",fe="capital.watchlist",Xe="conversation.input.overlay",Ze="/capital-watchlist",qt="capital-generation",Bt=300,ze=10,Je="capital-watchlist-css",Wt={"command.label":"\u81EA\u9009\u80A1","command.description":"\u6DFB\u52A0 / \u67E5\u770B / \u5220\u9664\u81EA\u9009\u80A1",title:"\u81EA\u9009\u80A1",close:"\u5173\u95ED",searchPlaceholder:"\u8F93\u5165\u8BC1\u5238\u4EE3\u7801\u6216\u540D\u79F0\uFF0C\u652F\u6301A\u80A1/\u6E2F\u80A1/\u7F8E\u80A1",add:"\u6DFB\u52A0",added:"\u5DF2\u6DFB\u52A0",refreshing:"\u5237\u65B0\u4E2D\u2026",refresh:"\u5237\u65B0\u62A5\u4EF7",loading:"\u6B63\u5728\u8BFB\u53D6\u6E05\u5355\u2026",empty:"\u8FD8\u6CA1\u6709\u81EA\u9009\u80A1\uFF0C\u7528\u4E0A\u9762\u7684\u8F93\u5165\u6846\u6DFB\u52A0\u3002",colName:"\u540D\u79F0",colQuote:"\u6700\u65B0\u4EF7 / \u6DA8\u8DCC\u5E45",colAction:"\u64CD\u4F5C",updated:"\u66F4\u65B0\u65F6\u95F4",notRefreshed:"\u672A\u5237\u65B0",stale:"\u4E0A\u4E00\u6B21\u5FEB\u7167",exchangeTime:"\u4EA4\u6613\u6240\u65F6\u95F4",noChangePct:"\u6682\u65E0\u6DA8\u8DCC\u6570\u636E",typeAShare:"A\u80A1",typeHkStock:"\u6E2F\u80A1",typeUsStock:"\u7F8E\u80A1",typeAIndex:"A\u6307",typeHkIndex:"\u6E2F\u6307",typeUsIndex:"\u7F8E\u6307",kindStock:"\u80A1\u7968",kindIndex:"\u6307\u6570",kindEtf:"ETF",remove:"\u79FB\u9664",more:"\u66F4\u591A",pin:"\u7F6E\u9876",holdingWeightLabel:"\u6301\u4ED3\u6BD4\u4F8B",holdingStepper:"\u6301\u4ED3\u6BD4\u4F8B\uFF08\u6BCF\u6863 10 \u4E2A\u767E\u5206\u70B9\uFF09",holdingStepUp:"\u589E\u52A0\u6301\u4ED3\u6BD4\u4F8B",holdingStepDown:"\u51CF\u5C11\u6301\u4ED3\u6BD4\u4F8B",holdingName:"\u6301\u4ED3",predict:"\u9884\u6D4B",predictTip:"AI\u9884\u6D4B",review:"\u590D\u76D8",reviewTip:"AI\u590D\u76D8",predictPromptPrefix:"\u8BF7\u9884\u6D4B ",predictPromptSuffix:"\uFF1A\u672A\u6765 5 \u4E2A\u4EA4\u6613\u65E5\u7684\u8D70\u52BF\u4E0E\u5173\u952E\u70B9\u4F4D\uFF0C\u8BF4\u660E\u4F9D\u636E\uFF0C\u5E76\u7ED9\u51FA\u5224\u65AD\u7684\u4E0D\u786E\u5B9A\u6027\u3002",reviewPromptPrefix:"\u8BF7\u590D\u76D8 ",reviewPromptSuffix:"\uFF1A\u4ECA\u65E5\u8D70\u52BF\u4E0E\u91CF\u4EF7\u3001\u8FD1 20 \u65E5\u8D8B\u52BF\u3001\u57FA\u7840\u9762\u3001\u6D88\u606F\u9762\uFF0C\u7ED9\u51FA\u7ED3\u8BBA\u548C\u5FC5\u8981\u98CE\u9669\u8BC4\u4F30\u3002",searching:"\u641C\u7D22\u4E2D\u2026",composingHint:"\u8F93\u5165\u5B8C\u6210\u540E\u81EA\u52A8\u641C\u7D22",clearInput:"\u6E05\u7A7A\u8F93\u5165",confirmTitle:"\u786E\u8BA4\u79FB\u9664\uFF1F",confirmDescPrefix:"\u786E\u5B9A\u5C06 ",confirmDescSuffix:" \u4ECE\u81EA\u9009\u4E2D\u79FB\u9664\u5417\uFF1F",confirmCancel:"\u53D6\u6D88",confirmOk:"\u786E\u8BA4\u79FB\u9664",truncated:"\u6CA1\u6709\u66F4\u591A\uFF0C\u8BF7\u8F93\u5165\u51C6\u786E\u7684\u8BC1\u5238\u4EE3\u7801\u6216\u540D\u79F0\u3002",filterAll:"\u5168\u90E8",filterLabel:"\u6309\u5E02\u573A\u7B5B\u9009\u5019\u9009",filterNoHit:"\u8FD9\u4E2A\u5E02\u573A\u4E0B\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684\u3002",noHit:"\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684\uFF08A\u80A1 / \u6E2F\u80A1 / \u7F8E\u80A1\uFF0C\u542B\u6307\u6570\u4E0E\u573A\u5185\u57FA\u91D1\uFF09\u3002","error.invalid_query":"\u8F93\u5165\u4E0D\u88AB\u63A5\u53D7","error.not_found":"\u6CA1\u6709\u627E\u5230\u8BE5\u6807\u7684","error.ambiguous":"\u547D\u4E2D\u591A\u6761\uFF0C\u8BF7\u4ECE\u5019\u9009\u91CC\u9009\u4E00\u6761","error.list_full":"\u81EA\u9009\u80A1\u6700\u591A {max} \u6761\uFF0C\u5148\u5220\u4E00\u6761\u518D\u52A0","error.list_full_noMax":"\u81EA\u9009\u80A1\u5DF2\u8FBE\u4E0A\u9650\uFF0C\u5148\u5220\u4E00\u6761\u518D\u52A0","error.credential_missing":"\u672A\u914D\u7F6E Fuyao \u5BC6\u94A5\uFF1A\u5728\u300C\u63D2\u4EF6\u300D\u9875\u7684 \u81EA\u52A8\u6A21\u5F0F\u5361\u7247\u91CC\u586B API Key\uFF08\u53EA\u5F71\u54CD A \u80A1\u90A3\u4E00\u8DEF\uFF0C\u6E2F\u7F8E\u80A1\u7167\u5E38\u7528\uFF09","error.rate_limited":"\u884C\u60C5\u670D\u52A1\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.fuyao_unavailable":"A \u80A1\u884C\u60C5\u6682\u65F6\u53D6\u4E0D\u5230\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.tencent_unavailable":"\u6E2F\u7F8E\u80A1\u884C\u60C5\u6682\u65F6\u53D6\u4E0D\u5230\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.quote_unavailable":"\u8BE5\u6807\u7684\u6CA1\u6709\u53EF\u7528\u62A5\u4EF7","error.refresh_timeout":"\u5237\u65B0\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.store_unavailable":"\u81EA\u9009\u80A1\u5B58\u50A8\u4E0D\u53EF\u7528","error.unauthorized":"\u767B\u5F55\u72B6\u6001\u5DF2\u5931\u6548\uFF1A\u8BF7\u5148\u56DE\u5230\u5BBF\u4E3B\u7A97\u53E3\u91CD\u65B0\u767B\u5F55",errorSuffix:"\uFF08\u5176\u4ED6\u6807\u7684\u4ECD\u662F\u4E0A\u4E00\u6B21\u6210\u529F\u5FEB\u7167\uFF09","partial.a-share":"A \u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","partial.hk":"\u6E2F\u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","partial.us":"\u7F8E\u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","desk.panel":"\u81EA\u9009\u80A1","desk.title":"\u81EA\u9009\u80A1\u884C\u60C5\u5DE5\u4F5C\u53F0","desk.refresh":"\u5237\u65B0\u884C\u60C5","desk.refreshing":"\u5237\u65B0\u4E2D\u2026","desk.loading":"\u6B63\u5728\u8BFB\u53D6\u81EA\u9009\u80A1\u2026","desk.lastUpdate":"\u6700\u8FD1\u66F4\u65B0","desk.notRefreshed":"\u672A\u5237\u65B0","desk.filter":"\u7B5B\u9009\u6807\u7684","desk.filterPlaceholder":"\u540D\u79F0\u6216\u4EE3\u7801","desk.group":"\u5206\u7EC4","desk.allGroups":"\u5168\u90E8","desk.newGroup":"\u5206\u7EC4\u540D\u79F0","desk.createGroup":"\u65B0\u5EFA","desk.deleteGroup":"\u5220\u9664\u5206\u7EC4","desk.noGroup":"\u672A\u5206\u7EC4","desk.more":"\u66F4\u591A\u64CD\u4F5C","desk.noGroupYet":"\u8FD8\u6CA1\u6709\u5206\u7EC4","desk.pin":"\u7F6E\u9876","desk.remove":"\u79FB\u9664","desk.removeHint":"\u518D\u70B9\u4E00\u6B21\u5220\u9664\u6309\u94AE\u786E\u8BA4\u79FB\u9664","desk.cancel":"\u53D6\u6D88","desk.empty":"\u8FD8\u6CA1\u6709\u81EA\u9009\u80A1","desk.emptyHint":"\u7528\u8F93\u5165\u6846\u7684\u300C\u81EA\u9009\u80A1\u300D\u9762\u677F\u6DFB\u52A0\u6807\u7684\uFF0C\u8FD9\u91CC\u4F1A\u540C\u6B65\u663E\u793A\u3002","desk.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684","desk.noMatchHint":"\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u5207\u56DE\u300C\u5168\u90E8\u300D\u5206\u7EC4\u3002","desk.selectHint":"\u9009\u62E9\u4E00\u53EA\u6807\u7684\u67E5\u770B\u8BE6\u60C5","desk.selectHintBody":"\u5DE6\u4FA7\u5217\u8868\u6309\u5206\u7EC4\u7B5B\u9009\uFF1B\u9009\u4E2D\u540E\u8FD9\u91CC\u663E\u793A\u62A5\u4EF7\u3001\u5206\u65F6\u4E0E\u6210\u4EA4\u91CF\u3002","desk.intraday":"\u5206\u65F6","desk.trendLoading":"\u6B63\u5728\u8BFB\u53D6\u5206\u65F6\u2026","desk.trendUnavailable":"\u8BE5\u5E02\u573A\u6682\u65F6\u6CA1\u6709\u5206\u65F6\u6570\u636E","desk.trendUnavailableHint":"\u573A\u5916\u7F8E\u80A1\u4E0E\u90E8\u5206\u6D77\u5916\u6307\u6570\u6CA1\u6709\u5206\u65F6\u6E90\uFF0C\u8FD9\u91CC\u4E0D\u753B\u5047\u8D70\u52BF\u3002","desk.trendError":"\u5206\u65F6\u52A0\u8F7D\u5931\u8D25","desk.trendRetry":"\u91CD\u8BD5","desk.daily":"\u65E5K","desk.fold":"\u6536\u8D77","desk.unfold":"\u5C55\u5F00","desk.adjustQfq":"\u524D\u590D\u6743","desk.klineLoading":"\u6B63\u5728\u8BFB\u53D6\u65E5K\u2026","desk.klineError":"\u65E5K\u6682\u65F6\u53D6\u4E0D\u5230","desk.klineUnavailable":"\u8BE5\u5E02\u573A\u6682\u65F6\u6CA1\u6709\u65E5K\u6570\u636E","desk.klineUnavailableHint":"\u6E2F\u7F8E\u80A1\u6307\u6570\u53EA\u6709\u5206\u65F6\uFF0C\u6CA1\u6709\u53EF\u7528\u7684\u65E5\u7EBF\u5E8F\u5217","desk.kOpen":"\u5F00","desk.kHigh":"\u9AD8","desk.kLow":"\u4F4E","desk.kClose":"\u6536","desk.trendLive":"\u76D8\u4E2D","desk.trendClosed":"\u6536\u76D8","desk.trendPrevious":"\u4E0A\u4E00\u4EA4\u6613\u65E5","desk.trendStale":"\u6570\u636E\u6EDE\u540E","desk.trendOpen":"\u4ECA\u5F00","desk.trendHigh":"\u6700\u9AD8","desk.trendLow":"\u6700\u4F4E","desk.trendAvg":"\u5747\u4EF7","desk.trendVolume":"\u6210\u4EA4\u91CF","desk.trendAmount":"\u6210\u4EA4\u989D","desk.lot":"\u624B","desk.share":"\u80A1","desk.trendZoneUs":"\u7F8E\u4E1C","desk.trendZoneHk":"\u9999\u6E2F","desk.capturedAt":"\u884C\u60C5\u65F6\u95F4","desk.groupsOf":"\u6240\u5C5E\u5206\u7EC4","desk.kind":"\u6807\u7684\u7C7B\u578B","desk.colName":"\u540D\u79F0","desk.colPrice":"\u6700\u65B0","desk.colChange":"\u6DA8\u8DCC","desk.colAction":"\u64CD\u4F5C","desk.loadFailed":"\u81EA\u9009\u80A1\u670D\u52A1\u6682\u4E0D\u53EF\u7528"},Kt={"command.label":"Watchlist","command.description":"Add / view / remove watched symbols",title:"Watchlist",close:"Close",searchPlaceholder:"Symbol code or name \u2014 A-share / HK / US",add:"Add",added:"Added",refreshing:"Refreshing\u2026",refresh:"Refresh quotes",loading:"Loading list\u2026",empty:"No symbols yet \u2014 use the input above to add one.",colName:"Symbol",colQuote:"Last / change",colAction:"Actions",updated:"Updated",notRefreshed:"Not refreshed",stale:"last snapshot",exchangeTime:"exchange time",noChangePct:"No change data yet",typeAShare:"A-Share",typeHkStock:"HK",typeUsStock:"US",typeAIndex:"A-Index",typeHkIndex:"HK-Index",typeUsIndex:"US-Index",kindStock:"stock",kindIndex:"index",kindEtf:"ETF",remove:"Remove",more:"More",pin:"Pin to top",holdingWeightLabel:"Holding weight",holdingStepper:"Holding weight, in steps of 10 percentage points",holdingStepUp:"Increase holding weight",holdingStepDown:"Decrease holding weight",holdingName:"Holding",predict:"Predict",predictTip:"AI prediction",review:"Review",reviewTip:"AI review",predictPromptPrefix:"Predict ",predictPromptSuffix:" over the next 5 sessions: the likely path and key levels, the evidence behind the call, and how uncertain it is.",reviewPromptPrefix:"Review ",reviewPromptSuffix:" with today's trend and volume, the last 20 sessions, fundamental, news, then a conclusion and the necessary risks analysis.",searching:"Searching\u2026",composingHint:"Search runs when you finish typing",clearInput:"Clear input",confirmTitle:"Remove this symbol?",confirmDescPrefix:"Remove ",confirmDescSuffix:" from your watchlist?",confirmCancel:"Cancel",confirmOk:"Remove",truncated:"No more candidates \u2014 enter an accurate code or name.",filterAll:"All",filterLabel:"Filter candidates by market",filterNoHit:"No matching symbol in this market.",noHit:"No matching symbol (A-share / HK / US, including indices and listed funds).","error.invalid_query":"Input not accepted","error.not_found":"Symbol not found","error.ambiguous":"Multiple hits \u2014 pick one candidate","error.list_full":"Watchlist holds at most {max} symbols \u2014 remove one first","error.list_full_noMax":"Watchlist is full \u2014 remove one first","error.credential_missing":"No Fuyao API key: set it on the Capital card in the Plugins page (A-share quotes only \u2014 HK and US keep working)","error.rate_limited":"Quote service is rate limited \u2014 try again later","error.fuyao_unavailable":"A-share quotes unavailable \u2014 try again later","error.tencent_unavailable":"HK / US quotes unavailable \u2014 try again later","error.quote_unavailable":"No quote for this symbol","error.refresh_timeout":"Refresh timed out \u2014 try again later","error.store_unavailable":"Watchlist storage unavailable","error.unauthorized":"Session expired \u2014 sign back in to the host first",errorSuffix:" (other symbols still show their last good snapshot)","partial.a-share":"A-share search unavailable: ","partial.hk":"HK search unavailable: ","partial.us":"US search unavailable: ","desk.panel":"Watchlist","desk.title":"Watchlist market desk","desk.refresh":"Refresh quotes","desk.refreshing":"Refreshing\u2026","desk.loading":"Loading watchlist\u2026","desk.lastUpdate":"Last update","desk.notRefreshed":"Not refreshed","desk.filter":"Filter symbols","desk.filterPlaceholder":"Name or code","desk.group":"Group","desk.allGroups":"All","desk.newGroup":"Group name","desk.createGroup":"Create","desk.deleteGroup":"Delete group","desk.noGroup":"Ungrouped","desk.more":"More actions","desk.noGroupYet":"No groups yet","desk.pin":"Pin","desk.remove":"Remove","desk.removeHint":"Press remove again to confirm","desk.cancel":"Cancel","desk.empty":"No symbols yet","desk.emptyHint":"Add symbols from the watchlist panel in the composer; they appear here.","desk.noMatch":"No symbols match","desk.noMatchHint":"Try another term, or switch back to All.","desk.selectHint":"Select a symbol","desk.selectHintBody":"The left list filters by group; the quote, intraday and volume panels follow the selection.","desk.intraday":"Intraday","desk.trendLoading":"Loading intraday\u2026","desk.trendUnavailable":"No intraday series for this market","desk.trendUnavailableHint":"OTC US lines and some overseas indices have no intraday source; nothing is drawn to fill the gap.","desk.trendError":"Intraday failed to load","desk.trendRetry":"Retry","desk.daily":"Daily","desk.fold":"Collapse","desk.unfold":"Expand","desk.adjustQfq":"Forward-adjusted","desk.klineLoading":"Loading daily bars\u2026","desk.klineError":"Daily bars are unavailable","desk.klineUnavailable":"No daily bars for this market","desk.klineUnavailableHint":"HK/US indices carry an intraday series only","desk.kOpen":"Open","desk.kHigh":"High","desk.kLow":"Low","desk.kClose":"Close","desk.trendLive":"Live","desk.trendClosed":"Closed","desk.trendPrevious":"Previous session","desk.trendStale":"Stale","desk.trendOpen":"Open","desk.trendHigh":"High","desk.trendLow":"Low","desk.trendAvg":"VWAP","desk.trendVolume":"Volume","desk.trendAmount":"Turnover","desk.lot":"lots","desk.share":"shares","desk.trendZoneUs":"ET","desk.trendZoneHk":"HK","desk.capturedAt":"As of","desk.groupsOf":"Groups","desk.kind":"Instrument","desk.colName":"Symbol","desk.colPrice":"Last","desk.colChange":"Change","desk.colAction":"Actions","desk.loadFailed":"Watchlist service unavailable"},Qt={"a-share":"typeAShare","hk-stock":"typeHkStock","us-stock":"typeUsStock","a-share-index":"typeAIndex","hk-index":"typeHkIndex","us-index":"typeUsIndex","fund-etf":"typeAShare"},Yt={"a-share":"kindStock","hk-stock":"kindStock","us-stock":"kindStock","a-share-index":"kindIndex","hk-index":"kindIndex","us-index":"kindIndex","fund-etf":"kindEtf"};function ht(t,a){let i=Qt[t];return i===void 0?String(t??""):a(i)}function Vt(t,a){let i=Yt[t];return i===void 0?String(t??""):a(i)}var Xt=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u2028\u2029\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]/gu;function xe(t){return String(t??"").replace(Xt,"")}function ce(t){return Array.isArray(t)?t.map(a=>a===null||typeof a!="object"?a:{...a,name:xe(a.name)}):t}var Zt={"a-share":"capital-watchlist-tag-cn","a-share-index":"capital-watchlist-tag-cn","fund-etf":"capital-watchlist-tag-cn","hk-stock":"capital-watchlist-tag-hk","hk-index":"capital-watchlist-tag-hk","us-stock":"capital-watchlist-tag-us","us-index":"capital-watchlist-tag-us"},ut=[{id:"all"},{id:"cn",label:"CN"},{id:"hk",label:"HK"},{id:"us",label:"US"}],et=t=>t.exchange==="HK"?"hk":t.exchange==="US"?"us":"cn",Jt=`
8
+ "use strict";var ze=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var zt=Object.prototype.hasOwnProperty;var Tt=(t,a,i)=>()=>{if(i)throw i[0];try{return t&&(a=t(t=0)),a}catch(r){throw i=[r],r}};var Ht=(t,a)=>{for(var i in a)ze(t,i,{get:a[i],enumerable:!0})},Pt=(t,a,i,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of At(a))!zt.call(t,s)&&s!==i&&ze(t,s,{get:()=>a[s],enumerable:!(r=Mt(a,s))||r.enumerable});return t};var Et=t=>Pt(ze({},"__esModule",{value:!0}),t);var Ye={};Ht(Ye,{ASSET_TYPES:()=>Rt,HOLDABLE_ASSET_TYPES:()=>We,MAX_ROW_WEIGHT_PCT:()=>Ot,MAX_TOTAL_WEIGHT_PCT:()=>It,holdingWeight:()=>Ke,isHoldable:()=>Ft,otherHeldWeightPct:()=>Qe,weightCeiling:()=>Lt});var Rt,We,Ft,Ot,It,Ke,Qe,Lt,Ve=Tt(()=>{"use strict";Rt=["a-share","a-share-index","fund-etf","hk-stock","hk-index","us-stock","us-index"],We=["a-share","fund-etf","hk-stock","us-stock"],Ft=t=>We.includes(t?.asset_type),Ot=100,It=120,Ke=t=>t?.holding===null||t?.holding===void 0?0:t?.holding?.weight_pct??0,Qe=(t,a)=>t.reduce((i,r)=>r?.thscode===a?i:i+Ke(r),0),Lt=(t,a)=>Math.max(0,Math.min(100,120-Qe(t,a)))});var{createElement:e,useEffect:ge,useRef:Ue,useState:A}=require("react"),{createSnapshotStore:Ut}=require("@deepseek-ai/dsh-client-store"),{IconChecklistOutlineRegular:ke,IconCloseOutlineRegular:Xe,IconDatabaseOutlineRegular:jt,IconEllipsisOutlineRegular:ot,IconGoalOutlineRegular:ct,IconListPenOutlineRegular:Dt,IconPinOutlineRegular:dt,IconRefreshOutlineRegular:Re,IconSearchOutlineRegular:pt,IconTrashOutlineRegular:Fe,Menu:Oe,MenuItemButton:Ne,Modal:Gt,Switch:qt}=require("@deepseek-ai/dsh-client-ui-primitives"),{isHoldable:Ze,weightCeiling:ht}=(Ve(),Et(Ye)),he="capital-watchlist",fe="capital.watchlist",Je="conversation.input.overlay",et="/capital-watchlist",Bt="capital-generation",Wt=300,Te=10,tt="capital-watchlist-css",Kt={"command.label":"\u81EA\u9009\u80A1","command.description":"\u6DFB\u52A0 / \u67E5\u770B / \u5220\u9664\u81EA\u9009\u80A1",title:"\u81EA\u9009\u80A1",close:"\u5173\u95ED",searchPlaceholder:"\u8F93\u5165\u8BC1\u5238\u4EE3\u7801\u6216\u540D\u79F0\uFF0C\u652F\u6301A\u80A1/\u6E2F\u80A1/\u7F8E\u80A1",add:"\u6DFB\u52A0",added:"\u5DF2\u6DFB\u52A0",refreshing:"\u5237\u65B0\u4E2D\u2026",refresh:"\u5237\u65B0\u62A5\u4EF7",loading:"\u6B63\u5728\u8BFB\u53D6\u6E05\u5355\u2026",empty:"\u8FD8\u6CA1\u6709\u81EA\u9009\u80A1\uFF0C\u7528\u4E0A\u9762\u7684\u8F93\u5165\u6846\u6DFB\u52A0\u3002",colName:"\u540D\u79F0",colQuote:"\u6700\u65B0\u4EF7 / \u6DA8\u8DCC\u5E45",colAction:"\u64CD\u4F5C",updated:"\u66F4\u65B0\u65F6\u95F4",notRefreshed:"\u672A\u5237\u65B0",stale:"\u4E0A\u4E00\u6B21\u5FEB\u7167",exchangeTime:"\u4EA4\u6613\u6240\u65F6\u95F4",noChangePct:"\u6682\u65E0\u6DA8\u8DCC\u6570\u636E",typeAShare:"A\u80A1",typeHkStock:"\u6E2F\u80A1",typeUsStock:"\u7F8E\u80A1",typeAIndex:"A\u6307",typeHkIndex:"\u6E2F\u6307",typeUsIndex:"\u7F8E\u6307",kindStock:"\u80A1\u7968",kindIndex:"\u6307\u6570",kindEtf:"ETF",remove:"\u79FB\u9664",more:"\u66F4\u591A",pin:"\u7F6E\u9876",holdingWeightLabel:"\u6301\u4ED3\u6BD4\u4F8B",holdingStepper:"\u6301\u4ED3\u6BD4\u4F8B\uFF08\u6BCF\u6863 10 \u4E2A\u767E\u5206\u70B9\uFF09",holdingStepUp:"\u589E\u52A0\u6301\u4ED3\u6BD4\u4F8B",holdingStepDown:"\u51CF\u5C11\u6301\u4ED3\u6BD4\u4F8B",holdingName:"\u6301\u4ED3",predict:"\u9884\u6D4B",predictTip:"AI\u9884\u6D4B",review:"\u590D\u76D8",reviewTip:"AI\u590D\u76D8",predictPromptPrefix:"\u8BF7\u9884\u6D4B ",predictPromptSuffix:"\uFF1A\u672A\u6765 5 \u4E2A\u4EA4\u6613\u65E5\u7684\u8D70\u52BF\u4E0E\u5173\u952E\u70B9\u4F4D\uFF0C\u8BF4\u660E\u4F9D\u636E\uFF0C\u5E76\u7ED9\u51FA\u5224\u65AD\u7684\u4E0D\u786E\u5B9A\u6027\u3002",reviewPromptPrefix:"\u8BF7\u590D\u76D8 ",reviewPromptSuffix:"\uFF1A\u4ECA\u65E5\u8D70\u52BF\u4E0E\u91CF\u4EF7\u3001\u8FD1 20 \u65E5\u8D8B\u52BF\u3001\u57FA\u7840\u9762\u3001\u6D88\u606F\u9762\uFF0C\u7ED9\u51FA\u7ED3\u8BBA\u548C\u5FC5\u8981\u98CE\u9669\u8BC4\u4F30\u3002",searching:"\u641C\u7D22\u4E2D\u2026",composingHint:"\u8F93\u5165\u5B8C\u6210\u540E\u81EA\u52A8\u641C\u7D22",clearInput:"\u6E05\u7A7A\u8F93\u5165",confirmTitle:"\u786E\u8BA4\u79FB\u9664\uFF1F",confirmDescPrefix:"\u786E\u5B9A\u5C06 ",confirmDescSuffix:" \u4ECE\u81EA\u9009\u4E2D\u79FB\u9664\u5417\uFF1F",confirmCancel:"\u53D6\u6D88",confirmOk:"\u786E\u8BA4\u79FB\u9664",truncated:"\u6CA1\u6709\u66F4\u591A\uFF0C\u8BF7\u8F93\u5165\u51C6\u786E\u7684\u8BC1\u5238\u4EE3\u7801\u6216\u540D\u79F0\u3002",filterAll:"\u5168\u90E8",filterLabel:"\u6309\u5E02\u573A\u7B5B\u9009\u5019\u9009",filterNoHit:"\u8FD9\u4E2A\u5E02\u573A\u4E0B\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684\u3002",noHit:"\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684\uFF08A\u80A1 / \u6E2F\u80A1 / \u7F8E\u80A1\uFF0C\u542B\u6307\u6570\u4E0E\u573A\u5185\u57FA\u91D1\uFF09\u3002","error.invalid_query":"\u8F93\u5165\u4E0D\u88AB\u63A5\u53D7","error.not_found":"\u6CA1\u6709\u627E\u5230\u8BE5\u6807\u7684","error.ambiguous":"\u547D\u4E2D\u591A\u6761\uFF0C\u8BF7\u4ECE\u5019\u9009\u91CC\u9009\u4E00\u6761","error.list_full":"\u81EA\u9009\u80A1\u6700\u591A {max} \u6761\uFF0C\u5148\u5220\u4E00\u6761\u518D\u52A0","error.list_full_noMax":"\u81EA\u9009\u80A1\u5DF2\u8FBE\u4E0A\u9650\uFF0C\u5148\u5220\u4E00\u6761\u518D\u52A0","error.credential_missing":"\u672A\u914D\u7F6E Fuyao \u5BC6\u94A5\uFF1A\u5728\u300C\u63D2\u4EF6\u300D\u9875\u7684 \u81EA\u52A8\u6A21\u5F0F\u5361\u7247\u91CC\u586B API Key\uFF08\u53EA\u5F71\u54CD A \u80A1\u90A3\u4E00\u8DEF\uFF0C\u6E2F\u7F8E\u80A1\u7167\u5E38\u7528\uFF09","error.rate_limited":"\u884C\u60C5\u670D\u52A1\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.fuyao_unavailable":"A \u80A1\u884C\u60C5\u6682\u65F6\u53D6\u4E0D\u5230\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.tencent_unavailable":"\u6E2F\u7F8E\u80A1\u884C\u60C5\u6682\u65F6\u53D6\u4E0D\u5230\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.quote_unavailable":"\u8BE5\u6807\u7684\u6CA1\u6709\u53EF\u7528\u62A5\u4EF7","error.refresh_timeout":"\u5237\u65B0\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5","error.store_unavailable":"\u81EA\u9009\u80A1\u5B58\u50A8\u4E0D\u53EF\u7528","error.unauthorized":"\u767B\u5F55\u72B6\u6001\u5DF2\u5931\u6548\uFF1A\u8BF7\u5148\u56DE\u5230\u5BBF\u4E3B\u7A97\u53E3\u91CD\u65B0\u767B\u5F55",errorSuffix:"\uFF08\u5176\u4ED6\u6807\u7684\u4ECD\u662F\u4E0A\u4E00\u6B21\u6210\u529F\u5FEB\u7167\uFF09","partial.a-share":"A \u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","partial.hk":"\u6E2F\u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","partial.us":"\u7F8E\u80A1\u68C0\u7D22\u4E0D\u53EF\u7528\uFF1A","desk.panel":"\u81EA\u9009\u80A1","desk.title":"\u81EA\u9009\u80A1\u884C\u60C5\u5DE5\u4F5C\u53F0","desk.refresh":"\u5237\u65B0\u884C\u60C5","desk.refreshing":"\u5237\u65B0\u4E2D\u2026","desk.loading":"\u6B63\u5728\u8BFB\u53D6\u81EA\u9009\u80A1\u2026","desk.lastUpdate":"\u6700\u8FD1\u66F4\u65B0","desk.notRefreshed":"\u672A\u5237\u65B0","desk.filter":"\u7B5B\u9009\u6807\u7684","desk.filterPlaceholder":"\u540D\u79F0\u6216\u4EE3\u7801","desk.group":"\u5206\u7EC4","desk.allGroups":"\u5168\u90E8","desk.newGroup":"\u5206\u7EC4\u540D\u79F0","desk.createGroup":"\u65B0\u5EFA","desk.deleteGroup":"\u5220\u9664\u5206\u7EC4","desk.noGroup":"\u672A\u5206\u7EC4","desk.more":"\u66F4\u591A\u64CD\u4F5C","desk.noGroupYet":"\u8FD8\u6CA1\u6709\u5206\u7EC4","desk.pin":"\u7F6E\u9876","desk.remove":"\u79FB\u9664","desk.removeHint":"\u518D\u70B9\u4E00\u6B21\u5220\u9664\u6309\u94AE\u786E\u8BA4\u79FB\u9664","desk.cancel":"\u53D6\u6D88","desk.empty":"\u8FD8\u6CA1\u6709\u81EA\u9009\u80A1","desk.emptyHint":"\u7528\u8F93\u5165\u6846\u7684\u300C\u81EA\u9009\u80A1\u300D\u9762\u677F\u6DFB\u52A0\u6807\u7684\uFF0C\u8FD9\u91CC\u4F1A\u540C\u6B65\u663E\u793A\u3002","desk.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u6807\u7684","desk.noMatchHint":"\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u5207\u56DE\u300C\u5168\u90E8\u300D\u5206\u7EC4\u3002","desk.selectHint":"\u9009\u62E9\u4E00\u53EA\u6807\u7684\u67E5\u770B\u8BE6\u60C5","desk.selectHintBody":"\u5DE6\u4FA7\u5217\u8868\u6309\u5206\u7EC4\u7B5B\u9009\uFF1B\u9009\u4E2D\u540E\u8FD9\u91CC\u663E\u793A\u62A5\u4EF7\u3001\u5206\u65F6\u4E0E\u6210\u4EA4\u91CF\u3002","desk.intraday":"\u5206\u65F6","desk.trendLoading":"\u6B63\u5728\u8BFB\u53D6\u5206\u65F6\u2026","desk.trendUnavailable":"\u8BE5\u5E02\u573A\u6682\u65F6\u6CA1\u6709\u5206\u65F6\u6570\u636E","desk.trendUnavailableHint":"\u573A\u5916\u7F8E\u80A1\u4E0E\u90E8\u5206\u6D77\u5916\u6307\u6570\u6CA1\u6709\u5206\u65F6\u6E90\uFF0C\u8FD9\u91CC\u4E0D\u753B\u5047\u8D70\u52BF\u3002","desk.trendError":"\u5206\u65F6\u52A0\u8F7D\u5931\u8D25","desk.retry":"\u91CD\u8BD5","desk.daily":"\u65E5K","desk.fold":"\u6536\u8D77","desk.unfold":"\u5C55\u5F00","desk.adjustQfq":"\u524D\u590D\u6743","desk.klineLoading":"\u6B63\u5728\u8BFB\u53D6\u65E5K\u2026","desk.klineError":"\u65E5K\u52A0\u8F7D\u5931\u8D25","desk.klineUnavailable":"\u8BE5\u5E02\u573A\u6682\u65F6\u6CA1\u6709\u65E5K\u6570\u636E","desk.klineUnavailableHint":"\u6E2F\u7F8E\u80A1\u6307\u6570\u53EA\u6709\u5206\u65F6\uFF0C\u6CA1\u6709\u53EF\u7528\u7684\u65E5\u7EBF\u5E8F\u5217","desk.kOpen":"\u5F00","desk.kHigh":"\u9AD8","desk.kLow":"\u4F4E","desk.kClose":"\u6536","desk.trendLive":"\u76D8\u4E2D","desk.trendClosed":"\u6536\u76D8","desk.trendPrevious":"\u4E0A\u4E00\u4EA4\u6613\u65E5","desk.trendStale":"\u6570\u636E\u6EDE\u540E","desk.trendOpen":"\u4ECA\u5F00","desk.trendHigh":"\u6700\u9AD8","desk.trendLow":"\u6700\u4F4E","desk.trendAvg":"\u5747\u4EF7","desk.trendVolume":"\u6210\u4EA4\u91CF","desk.trendAmount":"\u6210\u4EA4\u989D","desk.lot":"\u624B","desk.share":"\u80A1","desk.trendZoneUs":"\u7F8E\u4E1C","desk.trendZoneHk":"\u9999\u6E2F","desk.capturedAt":"\u884C\u60C5\u65F6\u95F4","desk.groupsOf":"\u6240\u5C5E\u5206\u7EC4","desk.kind":"\u6807\u7684\u7C7B\u578B","desk.colName":"\u540D\u79F0","desk.colPrice":"\u6700\u65B0","desk.colChange":"\u6DA8\u8DCC","desk.colAction":"\u64CD\u4F5C","desk.loadFailed":"\u81EA\u9009\u80A1\u670D\u52A1\u6682\u4E0D\u53EF\u7528"},Qt={"command.label":"Watchlist","command.description":"Add / view / remove watched symbols",title:"Watchlist",close:"Close",searchPlaceholder:"Symbol code or name \u2014 A-share / HK / US",add:"Add",added:"Added",refreshing:"Refreshing\u2026",refresh:"Refresh quotes",loading:"Loading list\u2026",empty:"No symbols yet \u2014 use the input above to add one.",colName:"Symbol",colQuote:"Last / change",colAction:"Actions",updated:"Updated",notRefreshed:"Not refreshed",stale:"last snapshot",exchangeTime:"exchange time",noChangePct:"No change data yet",typeAShare:"A-Share",typeHkStock:"HK",typeUsStock:"US",typeAIndex:"A-Index",typeHkIndex:"HK-Index",typeUsIndex:"US-Index",kindStock:"stock",kindIndex:"index",kindEtf:"ETF",remove:"Remove",more:"More",pin:"Pin to top",holdingWeightLabel:"Holding weight",holdingStepper:"Holding weight, in steps of 10 percentage points",holdingStepUp:"Increase holding weight",holdingStepDown:"Decrease holding weight",holdingName:"Holding",predict:"Predict",predictTip:"AI prediction",review:"Review",reviewTip:"AI review",predictPromptPrefix:"Predict ",predictPromptSuffix:" over the next 5 sessions: the likely path and key levels, the evidence behind the call, and how uncertain it is.",reviewPromptPrefix:"Review ",reviewPromptSuffix:" with today's trend and volume, the last 20 sessions, fundamental, news, then a conclusion and the necessary risks analysis.",searching:"Searching\u2026",composingHint:"Search runs when you finish typing",clearInput:"Clear input",confirmTitle:"Remove this symbol?",confirmDescPrefix:"Remove ",confirmDescSuffix:" from your watchlist?",confirmCancel:"Cancel",confirmOk:"Remove",truncated:"No more candidates \u2014 enter an accurate code or name.",filterAll:"All",filterLabel:"Filter candidates by market",filterNoHit:"No matching symbol in this market.",noHit:"No matching symbol (A-share / HK / US, including indices and listed funds).","error.invalid_query":"Input not accepted","error.not_found":"Symbol not found","error.ambiguous":"Multiple hits \u2014 pick one candidate","error.list_full":"Watchlist holds at most {max} symbols \u2014 remove one first","error.list_full_noMax":"Watchlist is full \u2014 remove one first","error.credential_missing":"No Fuyao API key: set it on the Capital card in the Plugins page (A-share quotes only \u2014 HK and US keep working)","error.rate_limited":"Quote service is rate limited \u2014 try again later","error.fuyao_unavailable":"A-share quotes unavailable \u2014 try again later","error.tencent_unavailable":"HK / US quotes unavailable \u2014 try again later","error.quote_unavailable":"No quote for this symbol","error.refresh_timeout":"Refresh timed out \u2014 try again later","error.store_unavailable":"Watchlist storage unavailable","error.unauthorized":"Session expired \u2014 sign back in to the host first",errorSuffix:" (other symbols still show their last good snapshot)","partial.a-share":"A-share search unavailable: ","partial.hk":"HK search unavailable: ","partial.us":"US search unavailable: ","desk.panel":"Watchlist","desk.title":"Watchlist market desk","desk.refresh":"Refresh quotes","desk.refreshing":"Refreshing\u2026","desk.loading":"Loading watchlist\u2026","desk.lastUpdate":"Last update","desk.notRefreshed":"Not refreshed","desk.filter":"Filter symbols","desk.filterPlaceholder":"Name or code","desk.group":"Group","desk.allGroups":"All","desk.newGroup":"Group name","desk.createGroup":"Create","desk.deleteGroup":"Delete group","desk.noGroup":"Ungrouped","desk.more":"More actions","desk.noGroupYet":"No groups yet","desk.pin":"Pin","desk.remove":"Remove","desk.removeHint":"Press remove again to confirm","desk.cancel":"Cancel","desk.empty":"No symbols yet","desk.emptyHint":"Add symbols from the watchlist panel in the composer; they appear here.","desk.noMatch":"No symbols match","desk.noMatchHint":"Try another term, or switch back to All.","desk.selectHint":"Select a symbol","desk.selectHintBody":"The left list filters by group; the quote, intraday and volume panels follow the selection.","desk.intraday":"Intraday","desk.trendLoading":"Loading intraday\u2026","desk.trendUnavailable":"No intraday series for this market","desk.trendUnavailableHint":"OTC US lines and some overseas indices have no intraday source; nothing is drawn to fill the gap.","desk.trendError":"Intraday failed to load","desk.retry":"Retry","desk.daily":"Daily","desk.fold":"Collapse","desk.unfold":"Expand","desk.adjustQfq":"Forward-adjusted","desk.klineLoading":"Loading daily bars\u2026","desk.klineError":"Daily bars failed to load","desk.klineUnavailable":"No daily bars for this market","desk.klineUnavailableHint":"HK/US indices carry an intraday series only","desk.kOpen":"Open","desk.kHigh":"High","desk.kLow":"Low","desk.kClose":"Close","desk.trendLive":"Live","desk.trendClosed":"Closed","desk.trendPrevious":"Previous session","desk.trendStale":"Stale","desk.trendOpen":"Open","desk.trendHigh":"High","desk.trendLow":"Low","desk.trendAvg":"VWAP","desk.trendVolume":"Volume","desk.trendAmount":"Turnover","desk.lot":"lots","desk.share":"shares","desk.trendZoneUs":"ET","desk.trendZoneHk":"HK","desk.capturedAt":"As of","desk.groupsOf":"Groups","desk.kind":"Instrument","desk.colName":"Symbol","desk.colPrice":"Last","desk.colChange":"Change","desk.colAction":"Actions","desk.loadFailed":"Watchlist service unavailable"},Yt={"a-share":"typeAShare","hk-stock":"typeHkStock","us-stock":"typeUsStock","a-share-index":"typeAIndex","hk-index":"typeHkIndex","us-index":"typeUsIndex","fund-etf":"typeAShare"},Vt={"a-share":"kindStock","hk-stock":"kindStock","us-stock":"kindStock","a-share-index":"kindIndex","hk-index":"kindIndex","us-index":"kindIndex","fund-etf":"kindEtf"};function ut(t,a){let i=Yt[t];return i===void 0?String(t??""):a(i)}function Xt(t,a){let i=Vt[t];return i===void 0?String(t??""):a(i)}var Zt=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u2028\u2029\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]/gu;function xe(t){return String(t??"").replace(Zt,"")}function ce(t){return Array.isArray(t)?t.map(a=>a===null||typeof a!="object"?a:{...a,name:xe(a.name)}):t}var Jt={"a-share":"capital-watchlist-tag-cn","a-share-index":"capital-watchlist-tag-cn","fund-etf":"capital-watchlist-tag-cn","hk-stock":"capital-watchlist-tag-hk","hk-index":"capital-watchlist-tag-hk","us-stock":"capital-watchlist-tag-us","us-index":"capital-watchlist-tag-us"},wt=[{id:"all"},{id:"cn",label:"CN"},{id:"hk",label:"HK"},{id:"us",label:"US"}],at=t=>t.exchange==="HK"?"hk":t.exchange==="US"?"us":"cn",ea=`
9
9
  .capital-watchlist-dialog.capital-watchlist-dialog { width: min(420px, 92vw); max-height: 100%; padding: 0; gap: 0; border-radius: 18px; }
10
10
  .capital-watchlist-card { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-radius: 18px; --capital-watchlist-up: #d1493f; --capital-watchlist-down: #17a063; --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2); --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2); }
11
11
  .capital-watchlist-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 20px 14px; }
@@ -197,6 +197,13 @@ window.__ModuleLoader__.load({
197
197
  .cwd-chart { flex: 1; min-height: 150px; display: grid; place-items: center; padding: 12px; border: 1px dashed var(--dsw-alias-border-l2); border-radius: 10px; background: repeating-linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-border-l2) 60%, transparent) 0 1px, transparent 1px 36px), var(--dsw-alias-bg-module-platform); text-align: center; }
198
198
  .cwd-charttext { font-size: 12.5px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
199
199
  .cwd-charthint { margin-top: 4px; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
200
+ .cwd-chartfail { border-style: solid; background: var(--dsw-alias-bg-module-platform); }
201
+ .cwd-chartfail .cwd-charttext { color: var(--dsw-alias-label-primary); }
202
+ .cwd-fallback { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 360px; }
203
+ .cwd-retry { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-top: 12px; height: 34px; padding: 0 14px; border: .5px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 38%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 12%, transparent); color: var(--dsw-alias-state-business-primary); font-family: inherit; font-size: 12.5px; line-height: 20px; font-weight: 500; cursor: pointer; }
204
+ .cwd-retry:hover { background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 22%, transparent); }
205
+ .cwd-retry:active { background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent); }
206
+ .cwd-retry:focus-visible { outline: 2px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 60%, transparent); outline-offset: 2px; }
200
207
  .cwd-trendstats { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 2px 14px; min-width: 0; }
201
208
  .cwd-trendstat { display: flex; align-items: baseline; gap: 5px; font-size: 11px; line-height: 17px; }
202
209
  .cwd-trendstat span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@@ -247,8 +254,8 @@ window.__ModuleLoader__.load({
247
254
  .cwd-skeleton { display: block; height: 12px; border-radius: 6px; background: var(--dsw-alias-bg-skeleton); }
248
255
  @media (max-width: 1040px) { .cwd-body { flex: none; grid-template-columns: minmax(0, 1fr); gap: 16px; height: auto; max-height: none; } .cwd-card { height: auto; } .cwd-tablebody { flex: none; max-height: 60vh; } .cwd-chart { flex: none; height: 200px; } .cwd-chartbox { flex: none; height: 260px; } .cwd-klinebox { flex: none; height: 260px; } .cwd-block-chart, .cwd-block-kline { flex: none; } }
249
256
  @media (max-width: 720px) { .cwd-inner { padding: 20px 16px 32px; } .cwd-thead, .cwd-row { grid-template-columns: minmax(0, 1.5fr) 78px 72px 36px; gap: 8px; } .cwd-thead { padding: 8px 10px; } .cwd-row { padding: 9px 10px; } }
250
- `;function ea(){let t=globalThis.document;if(!t||typeof t.createElement!="function"||t.querySelector(`style[data-${Je}]`))return;let a=t.createElement("style");a.setAttribute(`data-${Je}`,""),a.textContent=Jt;let i=t.head??t.body;if(!(i===void 0||typeof i.appendChild!="function"))return i.appendChild(a),()=>a.remove()}async function B(t,{query:a,body:i,signal:r}={}){let s=a!==void 0?`${Ze}${t}?${a}`:`${Ze}${t}`,u=i===void 0?{method:"GET",cache:"no-store",credentials:"same-origin",signal:r}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),credentials:"same-origin",signal:r},g=await fetch(s,u),c=await g.text(),d={};try{d=c.length>0?JSON.parse(c):{}}catch{d={}}if(g.ok===!0&&d.ok===!0)return d;let x=typeof d.code=="string"&&d.code.length>0?d.code:g.status===401||g.status===403?"unauthorized":"fuyao_unavailable",N=new Error(x);throw N.code=x,N.candidates=d.candidates,N.limit=d.limit,N}var tt=()=>({open:!1,loading:!1,refreshing:!1,searching:!1,items:[],candidates:[],truncated:!1,marketFilter:"all",query:"",dropdownOpen:!1,rowMenu:null,pendingRemove:null,refreshed_at:null,error:null,searchError:null,searchPartial:null,addError:null,loadError:null,failures:{},composing:!1,pendingSearch:!1}),Oe=class{constructor(){this.store=Lt(tt()),this.searchController=null,this.timer=null,this.pending=null,this.lastQuery=null,this.holdingOps=new Map}get state(){return this.store}get snapshot(){return this.store.getSnapshot()}patch(a){this.store.update(i=>Object.assign(i,a))}open(){this.patch({...tt(),open:!0,loading:!0}),this.load().then(()=>this.refresh(),()=>this.patch({loading:!1}))}close(){this.timer!==null&&clearTimeout(this.timer),this.searchController!==null&&this.searchController.abort(),this.lastQuery=null,this.patch({open:!1,rowMenu:null,composing:!1,pendingSearch:!1}),this.holdingOps.clear()}async load(){try{let a=await B("/list");this.holdingOps.clear(),this.patch({items:ce(a.items)??[],seeded_at:a.seeded_at,loading:!1,loadError:null})}catch(a){throw this.patch({loading:!1,loadError:{code:a.code??"fuyao_unavailable"}}),a}}refresh(){if(this.pending!==null)return this.pending;this.patch({refreshing:!0});let a=B("/refresh",{body:{}}).then(i=>{let r={};for(let g of i.failures??[])r[g.thscode]=g.code;let s=ce(i.items),u=s??this.snapshot.items;s!==null&&this.holdingOps.clear(),this.patch({items:u,refreshed_at:i.refreshed_at??this.snapshot.refreshed_at,failures:r,error:i.error?{code:i.error.code,partial:u.length>0&&u.some(g=>r[g.thscode]===void 0)}:null})}).catch(i=>{this.patch({error:{code:i.code??"fuyao_unavailable",partial:this.snapshot.items.some(r=>r.quote!==null)}})}).finally(()=>{this.patch({refreshing:!1}),this.pending=null});return this.pending=a,a}onQueryChange(a,i){let r=a.trim(),s=i===void 0?this.snapshot.composing===!0:i===!0;if(this.patch({query:a,searchError:null,composing:s,dropdownOpen:r.length>0}),this.timer!==null&&clearTimeout(this.timer),r.length===0){this.searchController!==null&&this.searchController.abort(),this.lastQuery=null,this.patch({candidates:[],truncated:!1,searching:!1,pendingSearch:!1});return}r===this.lastQuery&&this.snapshot.pendingSearch===!1||(this.patch({candidates:[],truncated:!1,pendingSearch:!s}),s!==!0&&(this.timer=setTimeout(()=>this.search(r),Bt)))}beginComposition(){this.timer!==null&&clearTimeout(this.timer),this.patch({composing:!0})}endComposition(a){this.onQueryChange(a,!1)}hideDropdown(){this.patch({dropdownOpen:!1})}setMarketFilter(a){ut.some(i=>i.id===a)&&this.patch({marketFilter:a})}toggleRowMenu(a){this.patch({rowMenu:this.snapshot.rowMenu===a?null:a})}closeRowMenu(){this.snapshot.rowMenu!==null&&this.patch({rowMenu:null})}setPendingRemove(a){this.patch({pendingRemove:a??null})}replaceRow(a){let[i]=ce([a]);i===void 0||typeof i?.thscode!="string"||this.patch({items:this.snapshot.items.map(r=>r.thscode===i.thscode?i:r)})}async search(a){this.lastQuery=a,this.searchController!==null&&this.searchController.abort();let i=new AbortController;this.searchController=i,this.patch({searching:!0,searchError:null,searchPartial:null});let r=()=>this.snapshot.query.trim()===a;try{let s=await B("/search",{query:`q=${encodeURIComponent(a)}`,signal:i.signal});if(!r()){this.patch({searching:!1});return}this.patch({candidates:ce(s.items)??[],truncated:s.truncated===!0,searching:!1,pendingSearch:!1,searchPartial:Array.isArray(s.partial)&&s.partial.length>0?s.partial:null})}catch(s){if(s.name==="AbortError"||(this.lastQuery===a&&(this.lastQuery=null),!r()))return;this.patch({candidates:[],truncated:!1,searching:!1,pendingSearch:!1,searchError:{code:s.code??"fuyao_unavailable"},searchPartial:null})}}async add(a){try{await B("/add",{body:{thscode:a.thscode}})}catch(r){this.patch({addError:{code:r.code??"fuyao_unavailable",candidates:r.candidates,limit:r.limit}}),r.candidates!==void 0&&this.patch({candidates:r.candidates,truncated:!1});return}this.patch({addError:null,candidates:this.snapshot.candidates.map(r=>r.thscode===a.thscode?{...r,in_list:!0}:r)}),await this.load().catch(()=>{}),await this.refresh();let i=this.snapshot.items.find(r=>r.thscode===a.thscode);i!==void 0&&i.quote===null&&this.snapshot.failures[a.thscode]===void 0&&await this.refresh()}async remove(a){let i=this.snapshot.items;this.patch({items:i.filter(r=>r.thscode!==a),rowMenu:null});try{await B("/remove",{body:{thscode:a}}),this.snapshot.addError?.code==="list_full"&&this.patch({addError:null})}catch{this.patch({items:i})}}async pin(a){let i=this.snapshot.items,r=i.find(s=>s.thscode===a);if(r!==void 0){this.patch({items:[r,...i.filter(s=>s.thscode!==a)],rowMenu:null});try{let s=await B("/pin",{body:{thscode:a}});Array.isArray(s.items)&&this.patch({items:ce(s.items)})}catch{let s=this.snapshot.items,u=i.map(c=>s.find(d=>d.thscode===c.thscode)).filter(Boolean),g=new Set(u.map(c=>c.thscode));this.patch({items:[...u,...s.filter(c=>!g.has(c.thscode))]})}}}async writeHolding(a,i,r){let s=this.snapshot.items.find(d=>d.thscode===a);if(s===void 0)return;let u=this.holdingOps.get(a)??{seq:0,baseline:s};this.holdingOps.set(a,u);let g=++u.seq;this.patch({items:this.snapshot.items.map(d=>d.thscode===a?r(d):d)});let c=()=>this.holdingOps.get(a)!==u||u.seq!==g;try{let d=await B("/holding",{body:i});if(c())return;this.replaceRow(d.item),u.baseline=d.item??r(s),this.holdingOps.delete(a)}catch{if(c())return;this.replaceRow(u.baseline),this.holdingOps.delete(a)}}markHolding(a,i){return this.writeHolding(a,{thscode:a,weight_pct:i},r=>({...r,holding:{weight_pct:i,marked_at:Date.now()}}))}clearHolding(a){return this.writeHolding(a,{thscode:a,clear:!0},i=>{let r={...i};return delete r.holding,r})}stepHolding(a,i){let r=this.snapshot.items,s=r.find(g=>g.thscode===a)?.holding?.weight_pct;if(typeof s!="number"&&i<0)return;let u=Math.min(pt(r,a),Math.max(0,(typeof s=="number"?s:0)+i));if(u!==s)return this.markHolding(a,u)}async copyToClipboard(){let a=this.snapshot.items.map(i=>[i.thscode,xe(i.name),i.asset_type,i.quote?.price??"",i.quote?.change_pct??"",i.quote?.captured_at??""].join(" ")).join(`
251
- `);return await navigator.clipboard.writeText(a),a}dispose(){this.timer!==null&&clearTimeout(this.timer),this.searchController!==null&&this.searchController.abort()}};function $e(t){if(typeof t!="number"||!Number.isFinite(t))return"";let a=new Date(t),i=r=>String(r).padStart(2,"0");return`${i(a.getMonth()+1)}-${i(a.getDate())} ${i(a.getHours())}:${i(a.getMinutes())}`}function Se({assetType:t,t:a}){return e("span",{className:`capital-watchlist-tag ${Zt[t]??"capital-watchlist-tag-cn"}`},ht(t,a))}function ta(t,a,i){let r=xe(t.name);return`${a(`${i}PromptPrefix`)}${r} (${t.thscode} \xB7 ${Vt(t.asset_type,a)})${a(`${i}PromptSuffix`)}`}function aa({quote:t,failureCode:a,refreshing:i,t:r}){let s=a!==void 0;if(t==null)return i===!0?e("div",{className:"capital-watchlist-quote"},e("span",{className:"capital-watchlist-skeleton capital-watchlist-skeleton-price"}),e("span",{className:"capital-watchlist-skeleton capital-watchlist-skeleton-change"})):s?e("div",{className:"capital-watchlist-quote",title:r(`error.${a}`)},e("div",{className:"capital-watchlist-price capital-watchlist-quotefailed"},"\u2014")):e("div",{className:"capital-watchlist-quote"},e("div",{className:"capital-watchlist-price"},r("notRefreshed")));let u=typeof t.change_pct=="number"&&Number.isFinite(t.change_pct),g=u?`${t.change_pct>0?"+":""}${t.change_pct.toFixed(2)}%`:"\u2014",c=s?"capital-watchlist-stale":u?t.change_pct>0?"capital-watchlist-up":t.change_pct<0?"capital-watchlist-down":"capital-watchlist-flat":"capital-watchlist-nodata",d=typeof t.source_time=="string"&&t.source_time.length>0?`${r("exchangeTime")} ${t.source_time}`:"",x=[];return s?x.push(`${r(`error.${a}`)} \xB7 ${r("stale")} ${$e(t.captured_at)}`):u||x.push(r("noChangePct")),d.length>0&&x.push(d),e("div",{className:"capital-watchlist-quote",title:x.length===0?void 0:x.join(" \xB7 ")},e("div",{className:s?"capital-watchlist-price capital-watchlist-stale":"capital-watchlist-price"},t.price.toFixed(2)),e("div",{className:`capital-watchlist-change ${c}`},g))}function ia(t,a){if(a.code!=="list_full")return t(`error.${a.code}`);let i=a.limit;return typeof i!="number"||!Number.isFinite(i)?t("error.list_full_noMax"):t("error.list_full").replace("{max}",String(i))}function sa(t,a){let i=t?.weight_pct;return i==null?a("holdingName"):`${a("holdingName")} ${i}%`}function la(t,a){let i=`${t.name} ${t.ticker}`;return t.holding===null||t.holding===void 0?i:`${i} \xB7 ${sa(t.holding,a)}`}function na({useDialog:t,surface:a,t:i,inputActions:r}){let s=t(n=>n),[u,g]=A(!1),[c,d]=A(null),x=s.pendingRemove??null;if(ge(()=>()=>a.dispose(),[a]),!s.open)return null;let N=s.dropdownOpen===!0,$=x!==null,D=n=>{if(n.key==="Escape"){if($){n.stopPropagation(),a.setPendingRemove(null);return}N&&(n.stopPropagation(),a.hideDropdown())}},v=n=>{if(!N)return;let C=n.relatedTarget;C!=null&&n.currentTarget?.contains?.(C)===!0||a.hideDropdown()},I=s.error,P=I==null?null:e("p",{className:"capital-watchlist-notice",role:"alert","data-code":I.code},`${i(`error.${I.code}`)}${I.partial===!0?i("errorSuffix"):""}`),G=(n,C)=>{r.insertText(ta(n,i,C),r.captureInsertion())===!0&&a.close()},E=s.marketFilter==="all"?s.candidates:s.candidates.filter(n=>et(n)===s.marketFilter),z={all:s.candidates.length,cn:0,hk:0,us:0};for(let n of s.candidates)z[et(n)]+=1;let Y=s.candidates.length===0?null:e("div",{className:"capital-watchlist-filter",role:"group","aria-label":i("filterLabel")},ut.map(n=>e("button",{key:n.id,type:"button",className:"capital-watchlist-filterbtn","aria-pressed":s.marketFilter===n.id,onClick:()=>a.setMarketFilter(n.id)},e("span",{className:"capital-watchlist-filterlabel"},n.id==="all"?i("filterAll"):n.label),e("span",{className:"capital-watchlist-filtercount"},String(z[n.id]))))),te=N?e("div",{className:"capital-watchlist-dropdown","aria-label":i("title"),"data-menu-material":"translucent"},Y,e("div",{className:"capital-watchlist-options",role:"listbox","aria-label":i("title")},E.map(n=>e("button",{key:n.thscode,type:"button",role:"option",className:"capital-watchlist-option",title:n.name,"aria-disabled":n.in_list===!0||c===n.thscode,onClick:()=>{n.in_list===!0||c===n.thscode||(g(!0),d(n.thscode),a.add(n).finally(()=>{g(!1),d(null)}))}},e("span",{className:"capital-watchlist-optionmain"},e("span",{className:"capital-watchlist-optionname"},n.name),e("span",{className:"capital-watchlist-codeline"},e("span",{className:"capital-watchlist-optioncode"},n.thscode),e(Se,{assetType:n.asset_type,t:i}))),e("span",{className:"capital-watchlist-addbtn","data-state":n.in_list===!0?"added":"idle"},n.in_list===!0?i("added"):i("add")))),s.truncated===!0&&E.length>0?e("div",{className:"capital-watchlist-hint capital-watchlist-endhint"},i("truncated")):null),s.composing===!0?e("div",{className:"capital-watchlist-hint"},i("composingHint")):s.searching===!0||s.pendingSearch===!0?e("div",{className:"capital-watchlist-hint"},i("searching")):s.searchError!==null&&s.searchError!==void 0?e("div",{className:"capital-watchlist-hint capital-watchlist-searcherror",role:"alert","data-code":s.searchError.code},i(`error.${s.searchError.code}`)):s.candidates.length===0?e("div",{className:"capital-watchlist-hint"},i("noHit")):E.length===0?e("div",{className:"capital-watchlist-hint","data-filter":s.marketFilter},i("filterNoHit")):null,...(s.searchPartial??[]).map(n=>e("div",{key:`partial-${n.market}`,className:"capital-watchlist-hint capital-watchlist-searcherror",role:"status","data-market":n.market,"data-code":n.code},`${i(`partial.${n.market}`)}${i(`error.${n.code}`)}`))):null,ae=s.items.length===0?null:e("div",{className:"capital-watchlist-grid capital-watchlist-head"},e("span",null,i("colName")),e("span",{className:"capital-watchlist-quote"},i("colQuote")),e("span",{className:"capital-watchlist-headaction"},i("colAction"))),V=s.loadError!==null&&s.loadError!==void 0?e("p",{className:"capital-watchlist-empty capital-watchlist-loaderror",role:"alert","data-code":s.loadError.code},i(`error.${s.loadError.code}`)):e("p",{className:"capital-watchlist-empty"},i("empty")),L=s.loading?e("p",{className:"capital-watchlist-empty"},i("loading")):s.items.length===0?V:e("div",{className:N?"capital-watchlist-list capital-watchlist-list-open":"capital-watchlist-list"},s.items.map((n,C)=>{let R=n.holding!==null&&n.holding!==void 0,k=n.holding?.weight_pct,H=Ve(n)||R,W=pt(s.items,n.thscode),T=!R||k===null||k===void 0||k<=0,K=(typeof k=="number"?k:0)+ze>W;return e("div",{key:n.thscode,className:"capital-watchlist-grid capital-watchlist-row","data-thscode":n.thscode},e("span",{className:"capital-watchlist-namewrap"},e("span",{className:R?"capital-watchlist-name capital-watchlist-name-held":"capital-watchlist-name",title:la(n,i)},n.name),e("span",{className:"capital-watchlist-codeline"},e("span",{className:"capital-watchlist-code"},n.ticker),e(Se,{assetType:n.asset_type,t:i}))),e(aa,{quote:n.quote,failureCode:s.failures[n.thscode],refreshing:s.refreshing,t:i}),e("span",{className:"capital-watchlist-rowactions"},e("button",{type:"button",className:"capital-watchlist-predict",disabled:u,title:i("predictTip"),"aria-label":`${i("predict")} ${n.name}`,onClick:()=>G(n,"predict")},e(rt,{size:14})),e("button",{type:"button",className:"capital-watchlist-review",disabled:u,title:i("reviewTip"),"aria-label":`${i("review")} ${n.name}`,onClick:()=>G(n,"review")},e(jt,{size:14})),e(Fe,{open:s.rowMenu===n.thscode,anchor:e("button",{type:"button",className:"capital-watchlist-more",disabled:u,title:i("more"),"aria-label":`${i("more")} ${n.name}`,"aria-haspopup":"menu","aria-expanded":s.rowMenu===n.thscode,onClick:()=>a.toggleRowMenu(n.thscode)},e(nt,{size:14})),items:[{id:"pin",label:i("pin"),icon:e(ot,{size:14}),disabled:C===0}],children:[...H?[e("div",{key:"holding-check",role:"group","aria-label":i("holdingName"),className:"capital-watchlist-checkrow"},e("span",{className:"capital-watchlist-checkicon","aria-hidden":"true"},e(Ut,{size:14})),e("span",{className:"capital-watchlist-checklabel"},i("holdingName")),e(Gt,{checked:R,disabled:u,label:i("holdingName"),onChange:j=>j?a.markHolding(n.thscode,null):a.clearHolding(n.thscode)}))]:[],...R&&Ve(n)?[e("div",{key:"holding-step",className:"capital-watchlist-stepper",role:"group","aria-label":i("holdingStepper")},e("span",{className:"capital-watchlist-stepperlabel"},i("holdingWeightLabel")),e("span",{className:"capital-watchlist-stepperline"},e("button",{type:"button",className:"capital-watchlist-stepperbtn","aria-label":i("holdingStepDown"),disabled:T,onClick:()=>a.stepHolding(n.thscode,-ze)},"\u2212"),e("span",{className:typeof k=="number"?"capital-watchlist-stepperreadout":"capital-watchlist-stepperreadout capital-watchlist-stepperplaceholder",role:"status"},typeof k=="number"?`${k}%`:`0~${W}`),e("button",{type:"button",className:"capital-watchlist-stepperbtn","aria-label":i("holdingStepUp"),title:`0~${W}`,disabled:K,onClick:()=>a.stepHolding(n.thscode,ze)},"+")))]:[],e(Ne,{key:"remove",danger:!0,separatorBefore:!0,icon:e(Re,{size:14}),onSelect:()=>{a.closeRowMenu(),a.setPendingRemove(n)}},i("remove"))],onSelect:j=>{j==="pin"&&(a.closeRowMenu(),a.pin(n.thscode))},onClose:()=>a.closeRowMenu(),align:"end",portal:!0,listClassName:"capital-watchlist-rows",className:"capital-watchlist-actions"})))})),U=e("div",{className:$?"capital-watchlist-confirm capital-watchlist-confirm-open":"capital-watchlist-confirm","aria-hidden":$?void 0:"true"},e("div",{className:"capital-watchlist-confirmbox",role:$?"alertdialog":void 0,"aria-label":i("confirmTitle")},e("div",{className:"capital-watchlist-confirmtitle"},i("confirmTitle")),$?e("p",{className:"capital-watchlist-confirmdesc"},i("confirmDescPrefix"),e("strong",null,`${x.name} \xB7 ${x.ticker}`),i("confirmDescSuffix")):null,e("div",{className:"capital-watchlist-confirmactions"},e("button",{type:"button",className:"capital-watchlist-confirmbtn",onClick:()=>a.setPendingRemove(null)},i("confirmCancel")),e("button",{type:"button",className:"capital-watchlist-confirmbtn capital-watchlist-confirmdanger",onClick:()=>{let n=x;a.setPendingRemove(null),n!==null&&a.remove(n.thscode)}},i("confirmOk")))));return e(Dt,{open:!0,onClose:()=>a.close(),title:i("title"),headless:!0,shortcutModal:"watchlist",className:"capital-watchlist-dialog"},e("div",{className:"capital-watchlist-card",onKeyDown:D},e("div",{className:"capital-watchlist-header"},e("h2",{className:"capital-watchlist-title"},i("title")),e("button",{type:"button",className:"capital-watchlist-close","aria-label":i("close"),onClick:()=>a.close()},e(Ye,{size:14}))),e("div",{className:"capital-watchlist-search",onBlur:v},e("div",{className:"capital-watchlist-field"},e("span",{className:"capital-watchlist-searchicon"},e(dt,{size:16})),e("input",{className:"capital-watchlist-input","data-modal-autofocus":!0,value:s.query,placeholder:i("searchPlaceholder"),onChange:n=>a.onQueryChange(n.target.value,n.isComposing),onCompositionStart:()=>a.beginComposition(),onCompositionEnd:n=>a.endComposition(n.target.value)}),s.query.length>0?e("button",{type:"button",className:"capital-watchlist-clear",title:i("clearInput"),"aria-label":i("clearInput"),onMouseDown:n=>n.preventDefault(),onClick:()=>a.onQueryChange("",!1)},e(Ye,{size:12})):null),te),s.addError!==null&&s.addError!==void 0?e("p",{className:"capital-watchlist-adderror",role:"status","data-code":s.addError.code},ia(i,s.addError)):null,ae,L,e("div",{className:"capital-watchlist-footer"},e("div",{className:"capital-watchlist-footcol"},e("button",{type:"button",className:"capital-watchlist-refresh",disabled:s.refreshing||u,onClick:()=>{a.refresh()}},e(ct,{size:14}),s.refreshing?i("refreshing"):i("refresh")),P),e("span",{className:"capital-watchlist-updated"},`${i("updated")} ${s.refreshed_at===null||s.refreshed_at===void 0?i("notRefreshed"):$e(s.refreshed_at)}`)),U))}var at=`${he}:desk`,wt="capital.watchlist.desk.groups.v1",le="__all__",He=0,Pe=0;function ra(){let t={names:[],assignments:{}};try{let a=JSON.parse(localStorage.getItem(wt)??"{}");return a===null||typeof a!="object"||!Array.isArray(a.names)||a.assignments===null||typeof a.assignments!="object"?t:{names:a.names.filter(i=>typeof i=="string"&&i.length>0).slice(0,20),assignments:a.assignments}}catch{return t}}function oa(t){try{localStorage.setItem(wt,JSON.stringify(t))}catch{}}var Ee=(t,a)=>{let i=t.assignments[a];return Array.isArray(i)?i:[]},it=t=>t!=null&&typeof t.change_pct=="number"&&Number.isFinite(t.change_pct)?t.change_pct:null,Ie=t=>t===null?"cwd-flat":t>0?"cwd-up":t<0?"cwd-down":"cwd-flat",_e=t=>t===null?"\u2014":`${t>0?"+":""}${t.toFixed(2)}%`,mt=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),st=t=>t!=null&&typeof t.price=="number"&&Number.isFinite(t.price)?mt.format(t.price):"\u2014",F=t=>typeof t=="number"&&Number.isFinite(t)?mt.format(t):"\u2014";function Ue(t,a=2){if(typeof t!="number"||!Number.isFinite(t))return"\u2014";let i=Math.abs(t);return i>=1e8?`${(t/1e8).toFixed(a)}\u4EBF`:i>=1e4?`${(t/1e4).toFixed(a)}\u4E07`:new Intl.NumberFormat("en-US",{maximumFractionDigits:a}).format(t)}var ca=t=>typeof t=="string"&&t.length>=5?Number(t.slice(0,2))*60+Number(t.slice(3,5)):0;function je(t,a,i){let r=Ue(t);return r==="\u2014"?r:a==="lot"?`${r}${i("desk.lot")}`:a==="share"?`${r}${i("desk.share")}`:r}function da(t,a){let i=Ue(t);return i==="\u2014"||a==null||a==="CNY"?i:`${i} ${a}`}var lt={"a-share":[[570,690],[780,900]],hk:[[570,720],[780,960]],us:[[570,960]]},pa=t=>`${String(Math.floor(t/60)).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`;function ha(t){let a=[],i=0;for(let[r,s]of lt[t]??lt.us)a.push([r,s,i]),i+=s-r;return{spans:a,total:i}}function ua(t,a){for(let[i,r,s]of t.spans){if(a<=i)return s;if(a<r)return s+a-i}return t.total}function wa(t){let a=[];for(let[i,r,s]of t.spans)for(let u=i;u<=r;u+=30){let g=s+u-i;(a.length===0||a[a.length-1].slot!==g)&&a.push({time:pa(u),slot:g})}return a}function ma({data:t,t:a}){let[i,r]=A({width:720,height:300}),[s,u]=A(null),g=Le(null);ge(()=>{let h=g.current;if(h==null)return;let p=()=>{let q=h.getBoundingClientRect();if(!(q.width>0)||!(q.height>0))return;let J=Math.max(280,Math.round(q.width)),we=Math.max(180,Math.round(q.height));r(be=>Math.abs(be.width-J)<2&&Math.abs(be.height-we)<2?be:{width:J,height:we})};if(p(),typeof ResizeObserver>"u")return;let Q=new ResizeObserver(p);return Q.observe(h),()=>Q.disconnect()},[]);let c=t.points,d=t.prev_close,x=i.width,N=i.height,$=66,D=54,v=12,I=18,P=Math.round(Math.min(70,Math.max(30,N*.22))),G=Math.max(60,N-v-I-P-10),E=Math.max(60,x-$-D),z=ha(t.market),Y=E/z.total,te=c.map(h=>h[1]),ae=Math.min(d,...te),V=Math.max(d,...te),L=(V-ae)*.06||Math.max(V*.002,.01),U=ae-L,n=V+L,C=h=>v+(n-h)/(n-U)*G,R=c.map(h=>ua(z,ca(h[0]))),k=h=>$+h*Y,H=k(R[0]).toFixed(1),W=k(R[c.length-1]).toFixed(1),T=t.last===null||t.last>=d?"up":"down",K=T==="up"?"var(--capital-watchlist-up)":"var(--capital-watchlist-down)",j=c.map((h,p)=>`${p===0?"M":"L"}${k(R[p]).toFixed(1)} ${C(h[1]).toFixed(1)}`).join(""),ue=(v+G).toFixed(1),b=`${j}L${W} ${ue}L${H} ${ue}Z`,ie=c.reduce((h,p,Q)=>p[2]===null?h:`${h}${h===""?"M":"L"}${k(R[Q]).toFixed(1)} ${C(p[2]).toFixed(1)}`,""),X=v+G+10,ee=Math.max(1,...c.map(h=>h[3]??0)),se=Math.max(1,Math.min(10,Y*.72)),ne=C(d),ye=[0,1,2,3,4].map(h=>{let p=U+(n-U)*h/4;return{value:p,y:C(p),pct:(p-d)/d*100}}).filter(h=>Math.abs(h.y-ne)>9),de=z.spans.length>1?z.spans[1][2]:null,o=wa(z),y=x>=620?1:2,O=o.filter((h,p)=>p%y===0||p===o.length-1),S=s===null||s<0||s>=c.length?null:c[s],Z=S===null?0:k(R[s]),M=S===null?0:C(S[1]),pe=Math.min(x-172,Math.max(8,Z+12)),ve=`${t.thscode} ${t.session_date??""} ${a("desk.intraday")} \xB7 ${a("desk.trendOpen")} ${F(t.open)} \xB7 ${a("desk.trendHigh")} ${F(t.high)} \xB7 ${a("desk.trendLow")} ${F(t.low)} \xB7 ${a("desk.trendAvg")} ${F(t.avg)}`,Ce=h=>{let p=h.currentTarget.getBoundingClientRect();if(!(p.width>0))return;let Q=Math.max(0,Math.min(z.total,(h.clientX-p.left-$)/E*z.total)),q=0;for(let J=1;J<R.length;J+=1)Math.abs(R[J]-Q)<Math.abs(R[q]-Q)&&(q=J);u(q)};return e("div",{className:"cwd-chartbox",ref:g},e("svg",{className:"cwd-chartsvg",viewBox:`0 0 ${x} ${N}`,role:"img","aria-label":ve,onPointerMove:Ce,onPointerLeave:()=>u(null)},e("defs",null,e("linearGradient",{id:"cwd-trend-fill",x1:"0",y1:"0",x2:"0",y2:"1"},e("stop",{offset:"0%",style:{stopColor:K,stopOpacity:.2}}),e("stop",{offset:"100%",style:{stopColor:K,stopOpacity:0}}))),ye.map(h=>e("g",{key:`grid-${h.value.toFixed(4)}`},e("line",{className:"cwd-chartgrid",x1:$,x2:$+E,y1:h.y,y2:h.y}),e("text",{className:"cwd-chartaxis",x:$-8,y:h.y+3.5,textAnchor:"end"},F(h.value)),e("text",{className:"cwd-chartaxis",x:$+E+8,y:h.y+3.5},`${h.pct>0?"+":""}${h.pct.toFixed(2)}%`))),O.map(h=>e("line",{key:`grid-${h.time}`,className:"cwd-chartgrid",x1:k(h.slot),x2:k(h.slot),y1:v,y2:X+P})),de===null?null:e("line",{className:"cwd-chartsep",x1:k(de),x2:k(de),y1:v,y2:X+P}),e("path",{className:"cwd-chartarea",d:b,fill:"url(#cwd-trend-fill)"}),c.map((h,p)=>{let Q=h[3]??0,q=Math.max(0,Q/ee*P),J=p===0?d:c[p-1][1],we=k(R[p]+.5);return e("rect",{key:`vol-${p}`,className:h[1]>=J?"cwd-vol-up":"cwd-vol-down",x:Math.min($+E-se,Math.max($,we-se/2)).toFixed(1),y:(X+P-q).toFixed(1),width:se.toFixed(1),height:Math.max(.5,q).toFixed(1)})}),e("path",{className:"cwd-chartline",d:j,style:{stroke:K}}),ie===""?null:e("path",{className:"cwd-chartavg",d:ie}),e("line",{className:"cwd-chartbase",x1:$,x2:$+E,y1:ne,y2:ne,strokeDasharray:"4 3"}),e("text",{className:"cwd-chartaxis cwd-chartbaselabel",x:$-8,y:ne+3.5,textAnchor:"end"},F(d)),O.map(h=>e("text",{key:`tick-${h.time}`,className:"cwd-chartaxis",x:k(h.slot),y:N-5,textAnchor:h.slot===0?"start":h.slot>=z.total?"end":"middle"},h.time)),S===null?null:e("g",null,e("line",{className:"cwd-chartcross",x1:Z,x2:Z,y1:v,y2:X+P}),e("line",{className:"cwd-chartcross",x1:$,x2:$+E,y1:M,y2:M}),e("circle",{className:`cwd-chartdot ${T==="up"?"cwd-up":"cwd-down"}`,cx:Z,cy:M,r:3}))),S===null?null:e("div",{className:"cwd-charttip",style:{left:`${pe}px`}},e("div",{className:"cwd-charttiptime"},S[0]),e("div",{className:`cwd-charttipprice ${T==="up"?"cwd-up":"cwd-down"}`},`${F(S[1])} ${_e((S[1]-d)/d*100)}`),S[2]===null?null:e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendAvg")),e("span",null,F(S[2]))),S[3]===null?null:e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendVolume")),e("span",null,je(S[3],t.volume_unit,a)))))}function ft(t,a){let i=new Array(t.length).fill(null),r=0;for(let s=0;s<t.length;s+=1)r+=t[s].close,s>=a&&(r-=t[s-a].close),s>=a-1&&(i[s]=r/a);return i}var gt=[5,10,20,60];function fa({data:t,t:a}){let[i,r]=A({width:720,height:300}),[s,u]=A(null),g=Le(null);ge(()=>{let o=g.current;if(o==null)return;let y=()=>{let S=o.getBoundingClientRect();if(!(S.width>0)||!(S.height>0))return;let Z=Math.max(280,Math.round(S.width)),M=Math.max(180,Math.round(S.height));r(pe=>Math.abs(pe.width-Z)<2&&Math.abs(pe.height-M)<2?pe:{width:Z,height:M})};if(y(),typeof ResizeObserver>"u")return;let O=new ResizeObserver(y);return O.observe(o),()=>O.disconnect()},[]);let c=t.bars,d=i.width,x=i.height,N=66,$=54,D=10,v=18,I=Math.round(Math.min(64,Math.max(28,x*.2))),P=Math.max(60,x-D-v-I-12),G=Math.max(60,d-N-$),E=G/Math.max(1,c.length),z=Math.max(1,Math.min(14,E*.62)),Y=Math.max(...c.map(o=>o.high)),te=Math.min(...c.map(o=>o.low)),ae=(Y-te)*.06||Math.max(Y*.01,.01),V=Y+ae,L=te-ae,U=o=>D+(V-o)/(V-L)*P,n=o=>N+(o+.5)*E,C=D+P+12,R=Math.max(1,...c.map(o=>o.volume)),k=o=>o/R*I,H=gt.map(o=>({window:o,values:ft(c,o)})),W=o=>o.reduce((y,O,S)=>O===null?y:`${y}${y===""?"M":"L"}${n(S).toFixed(1)} ${U(O).toFixed(1)}`,""),T=[];for(let o=0;o<c.length;o+=1){let y=c[o].date.slice(5,7);(o===0||y!==c[o-1].date.slice(5,7))&&T.push({index:o,month:y})}let K=T.length>1?(T[1].index-T[0].index)*E:Number.POSITIVE_INFINITY,j=T.map((o,y)=>({index:o.index,label:y===0&&K>=56?`${c[o.index].date.slice(0,4)}/${o.month}`:o.month})),ue=[0,1,2,3,4].map(o=>{let y=V-(V-L)*o/4;return{value:y,y:U(y)}}),b=s===null||s<0||s>=c.length?null:c[s],ie=b===null?0:n(s),X=b===null?0:U(b.close),ee=s===null||s<=0?null:c[s-1].close,se=b===null||ee===null||ee<=0?null:(b.close-ee)/ee*100,ne=Math.min(d-186,Math.max(8,ie+12)),ye=`${t.thscode} ${a("desk.daily")} \xB7 ${c.length} \xB7 ${F(c[c.length-1].close)}`,de=o=>{let y=o.currentTarget.getBoundingClientRect();if(!(y.width>0))return;let O=Math.round((o.clientX-y.left-N)/E-.5);u(Math.max(0,Math.min(c.length-1,O)))};return e("div",{className:"cwd-klinebox",ref:g},e("svg",{className:"cwd-chartsvg",viewBox:`0 0 ${d} ${x}`,role:"img","aria-label":ye,onPointerMove:de,onPointerLeave:()=>u(null)},ue.map(o=>e("g",{key:`grid-${o.value.toFixed(4)}`},e("line",{className:"cwd-chartgrid",x1:N,x2:N+G,y1:o.y,y2:o.y}),e("text",{className:"cwd-chartaxis",x:N-8,y:o.y+3.5,textAnchor:"end"},F(o.value)))),j.map(o=>e("g",{key:`tick-${o.index}`},e("line",{className:"cwd-chartgrid",x1:n(o.index),x2:n(o.index),y1:D,y2:C+I}),e("text",{className:"cwd-chartaxis",x:n(o.index),y:x-5,textAnchor:o.index===0?"start":"middle"},o.label))),c.map((o,y)=>{let O=Math.max(.5,k(o.volume));return e("rect",{key:`vol-${o.date}`,className:o.close>=o.open?"cwd-vol-up":"cwd-vol-down",x:(n(y)-z/2).toFixed(1),y:(C+I-O).toFixed(1),width:z.toFixed(1),height:O.toFixed(1)})}),e("text",{className:"cwd-chartaxis",x:N-8,y:C+8,textAnchor:"end"},Ue(R)),c.map((o,y)=>{let O=U(o.open),S=U(o.close),Z=Math.min(O,S),M=Math.max(.8,Math.abs(S-O));return e("g",{key:`bar-${o.date}`,className:o.close>=o.open?"cwd-candle-up":"cwd-candle-down"},e("line",{x1:n(y).toFixed(1),x2:n(y).toFixed(1),y1:U(o.high).toFixed(1),y2:U(o.low).toFixed(1)}),e("rect",{x:(n(y)-z/2).toFixed(1),y:Z.toFixed(1),width:z.toFixed(1),height:M.toFixed(1)}))}),H.map(o=>{let y=W(o.values);return y===""?null:e("path",{key:`ma-${o.window}`,className:`cwd-maline cwd-ma${o.window}`,d:y})}),b===null?null:e("g",null,e("line",{className:"cwd-chartcross",x1:ie,x2:ie,y1:D,y2:C+I}),e("line",{className:"cwd-chartcross",x1:N,x2:N+G,y1:X,y2:X}))),b===null?null:e("div",{className:"cwd-charttip",style:{left:`${ne}px`}},e("div",{className:"cwd-charttiptime"},b.date),e("div",{className:`cwd-charttipprice ${Ie(se)}`},`${F(b.close)} ${_e(se)}`),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.kOpen")),e("span",null,F(b.open)),e("span",null,a("desk.kHigh")),e("span",null,F(b.high))),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.kLow")),e("span",null,F(b.low)),e("span",null,a("desk.kClose")),e("span",null,F(b.close))),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendVolume")),e("span",null,je(b.volume,t.volume_unit,a)))))}function ga({size:t=18}){return e("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},e("path",{d:"M4 19V5"}),e("path",{d:"M4 19h16"}),e("path",{d:"m7 15 3-4 3 2 5-7"}),e("circle",{cx:18,cy:6,r:1.4,fill:"currentColor",stroke:"none"}))}function xa({t}){let[a,i]=A([]),[r,s]=A(!0),[u,g]=A(!1),[c,d]=A(null),[x,N]=A({}),[$,D]=A(null),[v,I]=A(ra),[P,G]=A(le),[E,z]=A(!1),[Y,te]=A(""),[ae,V]=A(""),[L,U]=A(null),[n,C]=A(null),[R,k]=A(null),[H,W]=A({status:"idle",data:null,code:null}),[T,K]=A({status:"idle",data:null,code:null}),[j,ue]=A(!1),b=Le(!0);ge(()=>(b.current=!0,()=>{b.current=!1}),[]),ge(()=>{oa(v)},[v]);let ie=l=>{let m=ce(l.items);Array.isArray(m)&&i(m);let f={};for(let w of l.failures??[])w!==null&&typeof w=="object"&&typeof w.thscode=="string"&&(f[w.thscode]=w.code);N(f),typeof l.refreshed_at=="number"&&d(l.refreshed_at),D(l.error!==void 0&&l.error!==null&&typeof l.error.code=="string"?l.error.code:null)},X=async(l,m={})=>{if(typeof l!="string"||l.length===0){W({status:"idle",data:null,code:null}),K({status:"idle",data:null,code:null});return}let f=He+=1;W(w=>({status:"loading",data:w.data!==null&&w.data.thscode===l?w.data:null,code:null}));try{let w=`thscode=${encodeURIComponent(l)}${m.bust===!0?"&refresh=1":""}`,_=await B("/trend",{query:w});if(!b.current||f!==He)return;W({status:"ready",data:_,code:null})}catch(w){if(!b.current||f!==He)return;let _=typeof w?.code=="string"?w.code:"trend_unavailable";W({status:_==="trend_unavailable"?"unavailable":"error",data:null,code:_})}},ee=async(l,m={})=>{if(typeof l!="string"||l.length===0){K({status:"idle",data:null,code:null});return}let f=Pe+=1;K(w=>({status:"loading",data:w.data!==null&&w.data.thscode===l?w.data:null,code:null}));try{let w=`thscode=${encodeURIComponent(l)}${m.bust===!0?"&refresh=1":""}`,_=await B("/kline",{query:w});if(!b.current||f!==Pe)return;K({status:"ready",data:_,code:null})}catch(w){if(!b.current||f!==Pe)return;let _=typeof w?.code=="string"?w.code:"kline_unavailable";K({status:_==="kline_unavailable"?"unavailable":"error",data:null,code:_})}},se=l=>{U(l),X(l),ee(l)};ge(()=>{let l=!1;return(async()=>{try{let f=await B("/list");if(l)return;let w=ce(f.items)??[];i(w);let _=typeof w[0]?.thscode=="string"?w[0].thscode:null;U(re=>re!==null?re:_),_!==null&&(X(_),ee(_))}catch(f){l||D(f.code??"load_failed");return}finally{l||s(!1)}try{let f=await B("/refresh",{body:{}});l||ie(f)}catch(f){l||D(f.code??"fuyao_unavailable")}})(),()=>{l=!0}},[]);let ne=async()=>{if(!u){g(!0);try{let l=await B("/refresh",{body:{}});b.current&&ie(l),b.current&&L!==null&&(X(L,{bust:!0}),ee(L,{bust:!0}))}catch(l){b.current&&D(l.code??"fuyao_unavailable")}finally{b.current&&g(!1)}}},ye=async l=>{let m=a;C(null),i(m.filter(f=>f.thscode!==l)),L===l&&(U(null),W({status:"idle",data:null,code:null}));try{await B("/remove",{body:{thscode:l}})}catch{b.current&&i(m)}},de=async l=>{let m=a,f=m.find(w=>w.thscode===l);if(f!==void 0){i([f,...m.filter(w=>w.thscode!==l)]);try{let w=await B("/pin",{body:{thscode:l}});Array.isArray(w.items)&&b.current&&i(ce(w.items))}catch{b.current&&i(m)}}},o=()=>{let l=Y.trim();l.length===0||l===le||v.names.includes(l)||(I({names:[...v.names,l],assignments:v.assignments}),te(""),G(l))},y=l=>{if(l===le)return;let m={};for(let[f,w]of Object.entries(v.assignments)){let _=(Array.isArray(w)?w:[]).filter(re=>re!==l);_.length>0&&(m[f]=_)}I({names:v.names.filter(f=>f!==l),assignments:m}),G(le),z(!1)},O=(l,m)=>{let f=Ee(v,l),w=f.includes(m)?f.filter(re=>re!==m):[...f,m],_={...v.assignments};w.length===0?delete _[l]:_[l]=w,I({names:v.names,assignments:_})},S=ae.trim().toLowerCase(),Z=a.filter(l=>P!==le&&!Ee(v,l.thscode).includes(P)?!1:S.length===0?!0:[l.name,l.thscode,l.ticker].some(m=>typeof m=="string"&&m.toLowerCase().includes(S))),M=L===null?null:a.find(l=>l.thscode===L)??null,pe=[{id:le,label:t("desk.allGroups"),icon:P===le?e(ke,{size:14}):void 0}].concat(v.names.map(l=>({id:l,label:l,icon:P===l?e(ke,{size:14}):void 0}))),ve=l=>{if(H.status!=="ready"||H.data===null||H.data.thscode!==l.thscode||typeof H.data.last!="number")return l.quote;let m=H.data.prev_close;return{price:H.data.last,change_pct:m>0?(H.data.last-m)/m*100:null}},Ce=Z.map((l,m)=>{let f=ve(l),w=it(f),_=x[l.thscode],re=Ee(v,l.thscode),De=L===l.thscode,Ge=_===void 0?void 0:t(`error.${_}`),Ae=R===l.thscode;return e("div",{key:l.thscode,className:"cwd-row",role:"listitem","aria-current":De?"true":void 0,onClick:oe=>{oe.target.closest(".cwd-rowactions")===null&&se(l.thscode)}},e("button",{type:"button",className:"cwd-cellname","aria-pressed":De,onClick:()=>se(l.thscode)},e("span",{className:"cwd-nameline"},e("span",{className:"cwd-nametext",title:l.name},xe(l.name)),e(Se,{assetType:l.asset_type,t})),e("span",{className:"cwd-codeline"},e("span",{className:"cwd-code"},l.thscode))),e("div",{className:_===void 0?"cwd-price":"cwd-price cwd-stale",title:Ge},st(f)),e("div",{className:`cwd-pct ${Ie(w)}`,title:Ge},_e(w)),e("div",{className:"cwd-rowactions"},e(Fe,{open:Ae,anchor:e("button",{type:"button",className:"cwd-iconbtn",title:t("desk.more"),"aria-label":`${t("desk.more")} ${l.name}`,"aria-haspopup":"menu","aria-expanded":Ae,onClick:()=>{C(null),k(Ae?null:l.thscode)}},e(nt,{size:16})),items:[{id:"pin",label:t("desk.pin"),icon:e(ot,{size:14}),disabled:m===0}],children:[...v.names.length===0?[e("div",{key:"no-group",className:"cwd-menuhint"},t("desk.noGroupYet"))]:v.names.map(oe=>e(Ne,{key:`group:${oe}`,icon:re.includes(oe)?e(ke,{size:14}):void 0,onSelect:()=>O(l.thscode,oe)},oe)),e(Ne,{key:"remove",danger:!0,separatorBefore:!0,icon:e(Re,{size:14}),onSelect:()=>{k(null),C(l)}},t("desk.remove"))],onSelect:oe=>{oe==="pin"&&(k(null),de(l.thscode))},onClose:()=>k(null),align:"end",portal:!0,listClassName:"cwd-menulist"})))}),h=r?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.loading"))):a.length===0?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.empty")),e("p",{className:"cwd-emptyhint"},t("desk.emptyHint"))):Z.length===0?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.noMatch")),e("p",{className:"cwd-emptyhint"},t("desk.noMatchHint"))):e("div",{className:"cwd-tablebody",role:"list","aria-label":t("desk.title")},Ce),p=H.status==="ready"?H.data:null,Q=p!==null&&M!==null&&p.thscode===M.thscode&&typeof p.last=="number",q=M===null?null:ve(M),J=it(q),we=Q?p.points[p.points.length-1][0]:null,be=Q&&p.market==="us"?` ${t("desk.trendZoneUs")}`:"",xt=Q?`${String(p.session_date??"").slice(5)} ${we}${be}`.trim():M===null||M.quote===null||M.quote===void 0?t("desk.notRefreshed"):$e(M.quote.captured_at)||t("desk.notRefreshed"),Me=p===null||p.market==="a-share"?"":` ${t(p.market==="us"?"desk.trendZoneUs":"desk.trendZoneHk")}`,bt=p===null?H.status==="loading"?t("desk.trendLoading"):H.status==="error"?t("desk.trendError"):"":p.session_status==="live"?`${p.stale?t("desk.trendStale"):t("desk.trendLive")}${Me} \xB7 ${p.points[p.points.length-1][0]}`:p.session_status==="closed"?`${p.session_date??""} ${t("desk.trendClosed")}${Me}`:`${t("desk.trendPrevious")} ${p.session_date??""}${Me}`,yt=p===null?null:e("div",{className:"cwd-trendstats"},...[[t("desk.trendOpen"),F(p.open)],[t("desk.trendHigh"),F(p.high)],[t("desk.trendLow"),F(p.low)],[t("desk.trendAvg"),F(p.avg)],[t("desk.trendVolume"),je(p.volume,p.volume_unit,t)],[t("desk.trendAmount"),da(p.amount,p.currency)]].map(([l,m])=>e("div",{key:l,className:"cwd-trendstat"},e("span",null,l),e("span",{title:m},m)))),vt=p!==null?e(ma,{key:p.thscode,data:p,t}):e("div",{className:"cwd-chart"},e("div",null,e("div",{className:"cwd-charttext"},H.status==="error"?t("desk.trendError"):H.status==="loading"?t("desk.trendLoading"):t("desk.trendUnavailable")),H.status==="unavailable"?e("div",{className:"cwd-charthint"},t("desk.trendUnavailableHint")):null,H.status==="error"?e("button",{type:"button",className:"cwd-pill",onClick:()=>{X(L,{bust:!0})}},t("desk.trendRetry")):null)),me=T.status==="ready"&&Array.isArray(T.data?.bars)&&T.data.bars.length>0?T.data:null,kt=me===null?T.status==="loading"?t("desk.klineLoading"):T.status==="error"?t("desk.klineError"):"":t("desk.adjustQfq"),Nt=me===null?null:e("div",{className:"cwd-malegend"},...gt.map(l=>{let m=ft(me.bars,l),f=m[m.length-1];return e("span",{key:l,className:`cwd-malegenditem cwd-ma${l}`},`MA${l} ${f==null?"\u2014":F(f)}`)})),$t=me!==null?e(fa,{key:me.thscode,data:me,t}):e("div",{className:"cwd-chart"},e("div",null,e("div",{className:"cwd-charttext"},T.status==="error"?t("desk.klineError"):T.status==="loading"?t("desk.klineLoading"):t("desk.klineUnavailable")),T.status==="unavailable"?e("div",{className:"cwd-charthint"},t("desk.klineUnavailableHint")):null,T.status==="error"?e("button",{type:"button",className:"cwd-pill",onClick:()=>{ee(L,{bust:!0})}},t("desk.trendRetry")):null)),St=e("div",{className:"cwd-block cwd-block-kline"},e("div",{className:"cwd-blockhead"},e("span",{className:"cwd-blocktitle"},t("desk.daily")),Nt,e("span",{className:"cwd-blocknote"},kt)),$t),_t=M===null?e("div",{className:"cwd-card"},e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.selectHint")),e("p",{className:"cwd-emptyhint"},t("desk.selectHintBody")))):e("div",{className:"cwd-card"},e("div",{className:"cwd-detail"},e("div",{className:"cwd-detailhead"},e("div",{style:{minWidth:0}},e("div",{className:"cwd-detailname"},e("span",{className:"cwd-detailtext",title:M.name},xe(M.name)),e(Se,{assetType:M.asset_type,t})),e("div",{className:"cwd-detailcode"},M.thscode))),e("div",{className:"cwd-quoterow"},e("div",{className:"cwd-bigquote"},e("span",{className:"cwd-bigprice"},st(q)),e("span",{className:`cwd-bigpct ${Ie(J)}`},_e(J))),e("div",{className:"cwd-meta"},e("div",{className:"cwd-metaitem"},e("div",{className:"cwd-metalabel"},t("desk.capturedAt")),e("div",{className:"cwd-metavalue"},xt)),e("div",{className:"cwd-metaitem"},e("div",{className:"cwd-metalabel"},t("desk.kind")),e("div",{className:"cwd-metavalue"},ht(M.asset_type,t))))),e("div",{className:j?"cwd-block cwd-block-chart cwd-folded":"cwd-block cwd-block-chart"},e("div",{className:"cwd-blockhead"},e("span",{className:"cwd-blocktitle"},t("desk.intraday")),j?null:yt,e("span",{className:"cwd-blocknote"},bt),e("button",{type:"button",className:"cwd-blockfold","aria-expanded":j?"false":"true",onClick:()=>ue(!j)},t(j?"desk.unfold":"desk.fold"))),j?null:vt),St));return e("div",{className:"cwd-page"},e("div",{className:"cwd-inner"},e("header",{className:"cwd-head"},e("h1",{className:"cwd-title"},t("desk.title")),e("div",{className:"cwd-headactions"},e("span",{className:"cwd-updated"},`${t("desk.lastUpdate")} ${c===null?t("desk.notRefreshed"):$e(c)}`),e("button",{type:"button",className:"cwd-refresh",disabled:u,onClick:()=>{ne()}},e(ct,{size:14}),t(u?"desk.refreshing":"desk.refresh")))),e("div",{className:"cwd-body"},e("section",{className:"cwd-card"},e("div",{className:"cwd-toolbar"},e("label",{className:"cwd-field"},e(dt,{size:14}),e("input",{type:"text",value:ae,placeholder:t("desk.filterPlaceholder"),"aria-label":t("desk.filter"),onChange:l=>V(l.target.value)})),e(Fe,{open:E,anchor:e("button",{type:"button",className:"cwd-pill","aria-haspopup":"menu","aria-expanded":E,"aria-label":t("desk.group"),onClick:()=>z(!E)},e(rt,{size:14}),e("span",null,P===le?t("desk.allGroups"):P)),items:pe,children:P===le?[]:[e(Ne,{key:"delete-group",danger:!0,separatorBefore:!0,icon:e(Re,{size:14}),onSelect:()=>y(P)},t("desk.deleteGroup"))],onSelect:l=>{z(!1),G(l)},onClose:()=>z(!1),align:"start",portal:!0,listClassName:"cwd-menulist"}),e("div",{className:"cwd-groupcreate"},e("input",{type:"text",value:Y,maxLength:20,placeholder:t("desk.newGroup"),"aria-label":t("desk.newGroup"),onChange:l=>te(l.target.value),onKeyDown:l=>{l.key==="Enter"&&o()}}),e("button",{type:"button",className:"cwd-pill",disabled:Y.trim().length===0,onClick:o},t("desk.createGroup")))),$===null?null:e("div",{className:"cwd-error",role:"alert"},t($==="load_failed"?"desk.loadFailed":`error.${$}`)),n===null?null:e("div",{className:"cwd-notice cwd-notice-danger"},e("span",null,`${t("desk.removeHint")} \xB7 ${xe(n.name)}`),e("button",{type:"button",className:"cwd-pill",onClick:()=>C(null)},t("desk.cancel"))),e("div",{className:"cwd-thead",role:"row"},e("span",null,t("desk.colName")),e("span",{className:"cwd-right"},t("desk.colPrice")),e("span",{className:"cwd-right"},t("desk.colChange")),e("span",{className:"cwd-right"},t("desk.colAction"))),h),e("aside",null,_t))))}function ba(t){t.effect(ea,`${he}: styles`),t.effect(()=>t.locale.register(fe,{zh:Wt,en:Kt}),`${he}: dictionaries`);let a=new Map,i=c=>{let d=a.get(c);return d===void 0&&(d=new Oe,a.set(c,d)),d};t.effect(()=>()=>{for(let c of a.values())c.dispose();a.clear()},`${he}: per-session surfaces`);let r=c=>{let x=t.sessions?.list?.getSnapshot?.().byId?.[c]?.projectionValues?.agentPreset;return typeof x=="string"?x:void 0},s=new Set,u=c=>{let d=r(c);return d!==void 0?d===qt:(s.has(c)||(s.add(c),Promise.resolve(t.sessions?.refreshProjections?.(c)).catch(()=>{})),!1)};t.slots.inject(Xe,()=>t.slots.register({name:Xe,id:"capital-watchlist-dialog",order:3,locale:fe,inject:c=>{let d=i(c);return{hooks:{dialog:d.state},surface:d}}},na));let g=t.locale.bind(fe);t.slots.inject("main",()=>t.slots.register({name:"main",key:at,locale:fe},xa)),t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:at,order:12,locale:fe,label:()=>g("desk.panel")},ga)),t.inject(["commandUi"],c=>{let d=t.locale.bind(fe);c.effect(()=>c.commandUi.register({name:"watchlist",label:()=>d("command.label"),description:()=>d("command.description"),icon:ke,available:x=>u(x.sessionId),ui:{kind:"action",run:x=>{i(x.sessionId).open()}}}),`${he}: /watchlist contribution`)}),t.logger?.info?.(`${he}: \u5BA2\u6237\u7AEF\u534A\u8FB9\u5DF2\u6302\u8F7D\uFF08/watchlist \u83DC\u5355\u884C + \u81EA\u9009\u80A1\u5F39\u7A97\uFF09`)}exports.name=he;exports.inject=["slots","locale","commandUi","sessions"];exports.apply=ba;
257
+ `;function ta(){let t=globalThis.document;if(!t||typeof t.createElement!="function"||t.querySelector(`style[data-${tt}]`))return;let a=t.createElement("style");a.setAttribute(`data-${tt}`,""),a.textContent=ea;let i=t.head??t.body;if(!(i===void 0||typeof i.appendChild!="function"))return i.appendChild(a),()=>a.remove()}async function W(t,{query:a,body:i,signal:r}={}){let s=a!==void 0?`${et}${t}?${a}`:`${et}${t}`,w=i===void 0?{method:"GET",cache:"no-store",credentials:"same-origin",signal:r}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),credentials:"same-origin",signal:r},g=await fetch(s,w),c=await g.text(),d={};try{d=c.length>0?JSON.parse(c):{}}catch{d={}}if(g.ok===!0&&d.ok===!0)return d;let x=typeof d.code=="string"&&d.code.length>0?d.code:g.status===401||g.status===403?"unauthorized":"fuyao_unavailable",k=new Error(x);throw k.code=x,k.detail=typeof d.message=="string"&&d.message.length>0?d.message:null,k.candidates=d.candidates,k.limit=d.limit,k}var it=()=>({open:!1,loading:!1,refreshing:!1,searching:!1,items:[],candidates:[],truncated:!1,marketFilter:"all",query:"",dropdownOpen:!1,rowMenu:null,pendingRemove:null,refreshed_at:null,error:null,searchError:null,searchPartial:null,addError:null,loadError:null,failures:{},composing:!1,pendingSearch:!1}),Ie=class{constructor(){this.store=Ut(it()),this.searchController=null,this.timer=null,this.pending=null,this.lastQuery=null,this.holdingOps=new Map}get state(){return this.store}get snapshot(){return this.store.getSnapshot()}patch(a){this.store.update(i=>Object.assign(i,a))}open(){this.patch({...it(),open:!0,loading:!0}),this.load().then(()=>this.refresh(),()=>this.patch({loading:!1}))}close(){this.timer!==null&&clearTimeout(this.timer),this.searchController!==null&&this.searchController.abort(),this.lastQuery=null,this.patch({open:!1,rowMenu:null,composing:!1,pendingSearch:!1}),this.holdingOps.clear()}async load(){try{let a=await W("/list");this.holdingOps.clear(),this.patch({items:ce(a.items)??[],seeded_at:a.seeded_at,loading:!1,loadError:null})}catch(a){throw this.patch({loading:!1,loadError:{code:a.code??"fuyao_unavailable"}}),a}}refresh(){if(this.pending!==null)return this.pending;this.patch({refreshing:!0});let a=W("/refresh",{body:{}}).then(i=>{let r={};for(let g of i.failures??[])r[g.thscode]=g.code;let s=ce(i.items),w=s??this.snapshot.items;s!==null&&this.holdingOps.clear(),this.patch({items:w,refreshed_at:i.refreshed_at??this.snapshot.refreshed_at,failures:r,error:i.error?{code:i.error.code,partial:w.length>0&&w.some(g=>r[g.thscode]===void 0)}:null})}).catch(i=>{this.patch({error:{code:i.code??"fuyao_unavailable",partial:this.snapshot.items.some(r=>r.quote!==null)}})}).finally(()=>{this.patch({refreshing:!1}),this.pending=null});return this.pending=a,a}onQueryChange(a,i){let r=a.trim(),s=i===void 0?this.snapshot.composing===!0:i===!0;if(this.patch({query:a,searchError:null,composing:s,dropdownOpen:r.length>0}),this.timer!==null&&clearTimeout(this.timer),r.length===0){this.searchController!==null&&this.searchController.abort(),this.lastQuery=null,this.patch({candidates:[],truncated:!1,searching:!1,pendingSearch:!1});return}r===this.lastQuery&&this.snapshot.pendingSearch===!1||(this.patch({candidates:[],truncated:!1,pendingSearch:!s}),s!==!0&&(this.timer=setTimeout(()=>this.search(r),Wt)))}beginComposition(){this.timer!==null&&clearTimeout(this.timer),this.patch({composing:!0})}endComposition(a){this.onQueryChange(a,!1)}hideDropdown(){this.patch({dropdownOpen:!1})}setMarketFilter(a){wt.some(i=>i.id===a)&&this.patch({marketFilter:a})}toggleRowMenu(a){this.patch({rowMenu:this.snapshot.rowMenu===a?null:a})}closeRowMenu(){this.snapshot.rowMenu!==null&&this.patch({rowMenu:null})}setPendingRemove(a){this.patch({pendingRemove:a??null})}replaceRow(a){let[i]=ce([a]);i===void 0||typeof i?.thscode!="string"||this.patch({items:this.snapshot.items.map(r=>r.thscode===i.thscode?i:r)})}async search(a){this.lastQuery=a,this.searchController!==null&&this.searchController.abort();let i=new AbortController;this.searchController=i,this.patch({searching:!0,searchError:null,searchPartial:null});let r=()=>this.snapshot.query.trim()===a;try{let s=await W("/search",{query:`q=${encodeURIComponent(a)}`,signal:i.signal});if(!r()){this.patch({searching:!1});return}this.patch({candidates:ce(s.items)??[],truncated:s.truncated===!0,searching:!1,pendingSearch:!1,searchPartial:Array.isArray(s.partial)&&s.partial.length>0?s.partial:null})}catch(s){if(s.name==="AbortError"||(this.lastQuery===a&&(this.lastQuery=null),!r()))return;this.patch({candidates:[],truncated:!1,searching:!1,pendingSearch:!1,searchError:{code:s.code??"fuyao_unavailable"},searchPartial:null})}}async add(a){try{await W("/add",{body:{thscode:a.thscode}})}catch(r){this.patch({addError:{code:r.code??"fuyao_unavailable",candidates:r.candidates,limit:r.limit}}),r.candidates!==void 0&&this.patch({candidates:r.candidates,truncated:!1});return}this.patch({addError:null,candidates:this.snapshot.candidates.map(r=>r.thscode===a.thscode?{...r,in_list:!0}:r)}),await this.load().catch(()=>{}),await this.refresh();let i=this.snapshot.items.find(r=>r.thscode===a.thscode);i!==void 0&&i.quote===null&&this.snapshot.failures[a.thscode]===void 0&&await this.refresh()}async remove(a){let i=this.snapshot.items;this.patch({items:i.filter(r=>r.thscode!==a),rowMenu:null});try{await W("/remove",{body:{thscode:a}}),this.snapshot.addError?.code==="list_full"&&this.patch({addError:null})}catch{this.patch({items:i})}}async pin(a){let i=this.snapshot.items,r=i.find(s=>s.thscode===a);if(r!==void 0){this.patch({items:[r,...i.filter(s=>s.thscode!==a)],rowMenu:null});try{let s=await W("/pin",{body:{thscode:a}});Array.isArray(s.items)&&this.patch({items:ce(s.items)})}catch{let s=this.snapshot.items,w=i.map(c=>s.find(d=>d.thscode===c.thscode)).filter(Boolean),g=new Set(w.map(c=>c.thscode));this.patch({items:[...w,...s.filter(c=>!g.has(c.thscode))]})}}}async writeHolding(a,i,r){let s=this.snapshot.items.find(d=>d.thscode===a);if(s===void 0)return;let w=this.holdingOps.get(a)??{seq:0,baseline:s};this.holdingOps.set(a,w);let g=++w.seq;this.patch({items:this.snapshot.items.map(d=>d.thscode===a?r(d):d)});let c=()=>this.holdingOps.get(a)!==w||w.seq!==g;try{let d=await W("/holding",{body:i});if(c())return;this.replaceRow(d.item),w.baseline=d.item??r(s),this.holdingOps.delete(a)}catch{if(c())return;this.replaceRow(w.baseline),this.holdingOps.delete(a)}}markHolding(a,i){return this.writeHolding(a,{thscode:a,weight_pct:i},r=>({...r,holding:{weight_pct:i,marked_at:Date.now()}}))}clearHolding(a){return this.writeHolding(a,{thscode:a,clear:!0},i=>{let r={...i};return delete r.holding,r})}stepHolding(a,i){let r=this.snapshot.items,s=r.find(g=>g.thscode===a)?.holding?.weight_pct;if(typeof s!="number"&&i<0)return;let w=Math.min(ht(r,a),Math.max(0,(typeof s=="number"?s:0)+i));if(w!==s)return this.markHolding(a,w)}async copyToClipboard(){let a=this.snapshot.items.map(i=>[i.thscode,xe(i.name),i.asset_type,i.quote?.price??"",i.quote?.change_pct??"",i.quote?.captured_at??""].join(" ")).join(`
258
+ `);return await navigator.clipboard.writeText(a),a}dispose(){this.timer!==null&&clearTimeout(this.timer),this.searchController!==null&&this.searchController.abort()}};function $e(t){if(typeof t!="number"||!Number.isFinite(t))return"";let a=new Date(t),i=r=>String(r).padStart(2,"0");return`${i(a.getMonth()+1)}-${i(a.getDate())} ${i(a.getHours())}:${i(a.getMinutes())}`}function Se({assetType:t,t:a}){return e("span",{className:`capital-watchlist-tag ${Jt[t]??"capital-watchlist-tag-cn"}`},ut(t,a))}function aa(t,a,i){let r=xe(t.name);return`${a(`${i}PromptPrefix`)}${r} (${t.thscode} \xB7 ${Xt(t.asset_type,a)})${a(`${i}PromptSuffix`)}`}function ia({quote:t,failureCode:a,refreshing:i,t:r}){let s=a!==void 0;if(t==null)return i===!0?e("div",{className:"capital-watchlist-quote"},e("span",{className:"capital-watchlist-skeleton capital-watchlist-skeleton-price"}),e("span",{className:"capital-watchlist-skeleton capital-watchlist-skeleton-change"})):s?e("div",{className:"capital-watchlist-quote",title:r(`error.${a}`)},e("div",{className:"capital-watchlist-price capital-watchlist-quotefailed"},"\u2014")):e("div",{className:"capital-watchlist-quote"},e("div",{className:"capital-watchlist-price"},r("notRefreshed")));let w=typeof t.change_pct=="number"&&Number.isFinite(t.change_pct),g=w?`${t.change_pct>0?"+":""}${t.change_pct.toFixed(2)}%`:"\u2014",c=s?"capital-watchlist-stale":w?t.change_pct>0?"capital-watchlist-up":t.change_pct<0?"capital-watchlist-down":"capital-watchlist-flat":"capital-watchlist-nodata",d=typeof t.source_time=="string"&&t.source_time.length>0?`${r("exchangeTime")} ${t.source_time}`:"",x=[];return s?x.push(`${r(`error.${a}`)} \xB7 ${r("stale")} ${$e(t.captured_at)}`):w||x.push(r("noChangePct")),d.length>0&&x.push(d),e("div",{className:"capital-watchlist-quote",title:x.length===0?void 0:x.join(" \xB7 ")},e("div",{className:s?"capital-watchlist-price capital-watchlist-stale":"capital-watchlist-price"},t.price.toFixed(2)),e("div",{className:`capital-watchlist-change ${c}`},g))}function sa(t,a){if(a.code!=="list_full")return t(`error.${a.code}`);let i=a.limit;return typeof i!="number"||!Number.isFinite(i)?t("error.list_full_noMax"):t("error.list_full").replace("{max}",String(i))}function la(t,a){let i=t?.weight_pct;return i==null?a("holdingName"):`${a("holdingName")} ${i}%`}function na(t,a){let i=`${t.name} ${t.ticker}`;return t.holding===null||t.holding===void 0?i:`${i} \xB7 ${la(t.holding,a)}`}function ra({useDialog:t,surface:a,t:i,inputActions:r}){let s=t(n=>n),[w,g]=A(!1),[c,d]=A(null),x=s.pendingRemove??null;if(ge(()=>()=>a.dispose(),[a]),!s.open)return null;let k=s.dropdownOpen===!0,S=x!==null,G=n=>{if(n.key==="Escape"){if(S){n.stopPropagation(),a.setPendingRemove(null);return}k&&(n.stopPropagation(),a.hideDropdown())}},N=n=>{if(!k)return;let C=n.relatedTarget;C!=null&&n.currentTarget?.contains?.(C)===!0||a.hideDropdown()},I=s.error,T=I==null?null:e("p",{className:"capital-watchlist-notice",role:"alert","data-code":I.code},`${i(`error.${I.code}`)}${I.partial===!0?i("errorSuffix"):""}`),q=(n,C)=>{r.insertText(aa(n,i,C),r.captureInsertion())===!0&&a.close()},H=s.marketFilter==="all"?s.candidates:s.candidates.filter(n=>at(n)===s.marketFilter),z={all:s.candidates.length,cn:0,hk:0,us:0};for(let n of s.candidates)z[at(n)]+=1;let V=s.candidates.length===0?null:e("div",{className:"capital-watchlist-filter",role:"group","aria-label":i("filterLabel")},wt.map(n=>e("button",{key:n.id,type:"button",className:"capital-watchlist-filterbtn","aria-pressed":s.marketFilter===n.id,onClick:()=>a.setMarketFilter(n.id)},e("span",{className:"capital-watchlist-filterlabel"},n.id==="all"?i("filterAll"):n.label),e("span",{className:"capital-watchlist-filtercount"},String(z[n.id]))))),ae=k?e("div",{className:"capital-watchlist-dropdown","aria-label":i("title"),"data-menu-material":"translucent"},V,e("div",{className:"capital-watchlist-options",role:"listbox","aria-label":i("title")},H.map(n=>e("button",{key:n.thscode,type:"button",role:"option",className:"capital-watchlist-option",title:n.name,"aria-disabled":n.in_list===!0||c===n.thscode,onClick:()=>{n.in_list===!0||c===n.thscode||(g(!0),d(n.thscode),a.add(n).finally(()=>{g(!1),d(null)}))}},e("span",{className:"capital-watchlist-optionmain"},e("span",{className:"capital-watchlist-optionname"},n.name),e("span",{className:"capital-watchlist-codeline"},e("span",{className:"capital-watchlist-optioncode"},n.thscode),e(Se,{assetType:n.asset_type,t:i}))),e("span",{className:"capital-watchlist-addbtn","data-state":n.in_list===!0?"added":"idle"},n.in_list===!0?i("added"):i("add")))),s.truncated===!0&&H.length>0?e("div",{className:"capital-watchlist-hint capital-watchlist-endhint"},i("truncated")):null),s.composing===!0?e("div",{className:"capital-watchlist-hint"},i("composingHint")):s.searching===!0||s.pendingSearch===!0?e("div",{className:"capital-watchlist-hint"},i("searching")):s.searchError!==null&&s.searchError!==void 0?e("div",{className:"capital-watchlist-hint capital-watchlist-searcherror",role:"alert","data-code":s.searchError.code},i(`error.${s.searchError.code}`)):s.candidates.length===0?e("div",{className:"capital-watchlist-hint"},i("noHit")):H.length===0?e("div",{className:"capital-watchlist-hint","data-filter":s.marketFilter},i("filterNoHit")):null,...(s.searchPartial??[]).map(n=>e("div",{key:`partial-${n.market}`,className:"capital-watchlist-hint capital-watchlist-searcherror",role:"status","data-market":n.market,"data-code":n.code},`${i(`partial.${n.market}`)}${i(`error.${n.code}`)}`))):null,ie=s.items.length===0?null:e("div",{className:"capital-watchlist-grid capital-watchlist-head"},e("span",null,i("colName")),e("span",{className:"capital-watchlist-quote"},i("colQuote")),e("span",{className:"capital-watchlist-headaction"},i("colAction"))),X=s.loadError!==null&&s.loadError!==void 0?e("p",{className:"capital-watchlist-empty capital-watchlist-loaderror",role:"alert","data-code":s.loadError.code},i(`error.${s.loadError.code}`)):e("p",{className:"capital-watchlist-empty"},i("empty")),L=s.loading?e("p",{className:"capital-watchlist-empty"},i("loading")):s.items.length===0?X:e("div",{className:k?"capital-watchlist-list capital-watchlist-list-open":"capital-watchlist-list"},s.items.map((n,C)=>{let P=n.holding!==null&&n.holding!==void 0,$=n.holding?.weight_pct,F=Ze(n)||P,K=ht(s.items,n.thscode),R=!P||$===null||$===void 0||$<=0,Q=(typeof $=="number"?$:0)+Te>K;return e("div",{key:n.thscode,className:"capital-watchlist-grid capital-watchlist-row","data-thscode":n.thscode},e("span",{className:"capital-watchlist-namewrap"},e("span",{className:P?"capital-watchlist-name capital-watchlist-name-held":"capital-watchlist-name",title:na(n,i)},n.name),e("span",{className:"capital-watchlist-codeline"},e("span",{className:"capital-watchlist-code"},n.ticker),e(Se,{assetType:n.asset_type,t:i}))),e(ia,{quote:n.quote,failureCode:s.failures[n.thscode],refreshing:s.refreshing,t:i}),e("span",{className:"capital-watchlist-rowactions"},e("button",{type:"button",className:"capital-watchlist-predict",disabled:w,title:i("predictTip"),"aria-label":`${i("predict")} ${n.name}`,onClick:()=>q(n,"predict")},e(ct,{size:14})),e("button",{type:"button",className:"capital-watchlist-review",disabled:w,title:i("reviewTip"),"aria-label":`${i("review")} ${n.name}`,onClick:()=>q(n,"review")},e(Dt,{size:14})),e(Oe,{open:s.rowMenu===n.thscode,anchor:e("button",{type:"button",className:"capital-watchlist-more",disabled:w,title:i("more"),"aria-label":`${i("more")} ${n.name}`,"aria-haspopup":"menu","aria-expanded":s.rowMenu===n.thscode,onClick:()=>a.toggleRowMenu(n.thscode)},e(ot,{size:14})),items:[{id:"pin",label:i("pin"),icon:e(dt,{size:14}),disabled:C===0}],children:[...F?[e("div",{key:"holding-check",role:"group","aria-label":i("holdingName"),className:"capital-watchlist-checkrow"},e("span",{className:"capital-watchlist-checkicon","aria-hidden":"true"},e(jt,{size:14})),e("span",{className:"capital-watchlist-checklabel"},i("holdingName")),e(qt,{checked:P,disabled:w,label:i("holdingName"),onChange:j=>j?a.markHolding(n.thscode,null):a.clearHolding(n.thscode)}))]:[],...P&&Ze(n)?[e("div",{key:"holding-step",className:"capital-watchlist-stepper",role:"group","aria-label":i("holdingStepper")},e("span",{className:"capital-watchlist-stepperlabel"},i("holdingWeightLabel")),e("span",{className:"capital-watchlist-stepperline"},e("button",{type:"button",className:"capital-watchlist-stepperbtn","aria-label":i("holdingStepDown"),disabled:R,onClick:()=>a.stepHolding(n.thscode,-Te)},"\u2212"),e("span",{className:typeof $=="number"?"capital-watchlist-stepperreadout":"capital-watchlist-stepperreadout capital-watchlist-stepperplaceholder",role:"status"},typeof $=="number"?`${$}%`:`0~${K}`),e("button",{type:"button",className:"capital-watchlist-stepperbtn","aria-label":i("holdingStepUp"),title:`0~${K}`,disabled:Q,onClick:()=>a.stepHolding(n.thscode,Te)},"+")))]:[],e(Ne,{key:"remove",danger:!0,separatorBefore:!0,icon:e(Fe,{size:14}),onSelect:()=>{a.closeRowMenu(),a.setPendingRemove(n)}},i("remove"))],onSelect:j=>{j==="pin"&&(a.closeRowMenu(),a.pin(n.thscode))},onClose:()=>a.closeRowMenu(),align:"end",portal:!0,listClassName:"capital-watchlist-rows",className:"capital-watchlist-actions"})))})),U=e("div",{className:S?"capital-watchlist-confirm capital-watchlist-confirm-open":"capital-watchlist-confirm","aria-hidden":S?void 0:"true"},e("div",{className:"capital-watchlist-confirmbox",role:S?"alertdialog":void 0,"aria-label":i("confirmTitle")},e("div",{className:"capital-watchlist-confirmtitle"},i("confirmTitle")),S?e("p",{className:"capital-watchlist-confirmdesc"},i("confirmDescPrefix"),e("strong",null,`${x.name} \xB7 ${x.ticker}`),i("confirmDescSuffix")):null,e("div",{className:"capital-watchlist-confirmactions"},e("button",{type:"button",className:"capital-watchlist-confirmbtn",onClick:()=>a.setPendingRemove(null)},i("confirmCancel")),e("button",{type:"button",className:"capital-watchlist-confirmbtn capital-watchlist-confirmdanger",onClick:()=>{let n=x;a.setPendingRemove(null),n!==null&&a.remove(n.thscode)}},i("confirmOk")))));return e(Gt,{open:!0,onClose:()=>a.close(),title:i("title"),headless:!0,shortcutModal:"watchlist",className:"capital-watchlist-dialog"},e("div",{className:"capital-watchlist-card",onKeyDown:G},e("div",{className:"capital-watchlist-header"},e("h2",{className:"capital-watchlist-title"},i("title")),e("button",{type:"button",className:"capital-watchlist-close","aria-label":i("close"),onClick:()=>a.close()},e(Xe,{size:14}))),e("div",{className:"capital-watchlist-search",onBlur:N},e("div",{className:"capital-watchlist-field"},e("span",{className:"capital-watchlist-searchicon"},e(pt,{size:16})),e("input",{className:"capital-watchlist-input","data-modal-autofocus":!0,value:s.query,placeholder:i("searchPlaceholder"),onChange:n=>a.onQueryChange(n.target.value,n.isComposing),onCompositionStart:()=>a.beginComposition(),onCompositionEnd:n=>a.endComposition(n.target.value)}),s.query.length>0?e("button",{type:"button",className:"capital-watchlist-clear",title:i("clearInput"),"aria-label":i("clearInput"),onMouseDown:n=>n.preventDefault(),onClick:()=>a.onQueryChange("",!1)},e(Xe,{size:12})):null),ae),s.addError!==null&&s.addError!==void 0?e("p",{className:"capital-watchlist-adderror",role:"status","data-code":s.addError.code},sa(i,s.addError)):null,ie,L,e("div",{className:"capital-watchlist-footer"},e("div",{className:"capital-watchlist-footcol"},e("button",{type:"button",className:"capital-watchlist-refresh",disabled:s.refreshing||w,onClick:()=>{a.refresh()}},e(Re,{size:14}),s.refreshing?i("refreshing"):i("refresh")),T),e("span",{className:"capital-watchlist-updated"},`${i("updated")} ${s.refreshed_at===null||s.refreshed_at===void 0?i("notRefreshed"):$e(s.refreshed_at)}`)),U))}var st=`${he}:desk`,mt="capital.watchlist.desk.groups.v1",ne="__all__",He=0,Pe=0;function oa(){let t={names:[],assignments:{}};try{let a=JSON.parse(localStorage.getItem(mt)??"{}");return a===null||typeof a!="object"||!Array.isArray(a.names)||a.assignments===null||typeof a.assignments!="object"?t:{names:a.names.filter(i=>typeof i=="string"&&i.length>0).slice(0,20),assignments:a.assignments}}catch{return t}}function ca(t){try{localStorage.setItem(mt,JSON.stringify(t))}catch{}}var Ee=(t,a)=>{let i=t.assignments[a];return Array.isArray(i)?i:[]},lt=t=>t!=null&&typeof t.change_pct=="number"&&Number.isFinite(t.change_pct)?t.change_pct:null,Le=t=>t===null?"cwd-flat":t>0?"cwd-up":t<0?"cwd-down":"cwd-flat",_e=t=>t===null?"\u2014":`${t>0?"+":""}${t.toFixed(2)}%`,ft=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),nt=t=>t!=null&&typeof t.price=="number"&&Number.isFinite(t.price)?ft.format(t.price):"\u2014",E=t=>typeof t=="number"&&Number.isFinite(t)?ft.format(t):"\u2014";function je(t,a=2){if(typeof t!="number"||!Number.isFinite(t))return"\u2014";let i=Math.abs(t);return i>=1e8?`${(t/1e8).toFixed(a)}\u4EBF`:i>=1e4?`${(t/1e4).toFixed(a)}\u4E07`:new Intl.NumberFormat("en-US",{maximumFractionDigits:a}).format(t)}var da=t=>typeof t=="string"&&t.length>=5?Number(t.slice(0,2))*60+Number(t.slice(3,5)):0;function De(t,a,i){let r=je(t);return r==="\u2014"?r:a==="lot"?`${r}${i("desk.lot")}`:a==="share"?`${r}${i("desk.share")}`:r}function pa(t,a){let i=je(t);return i==="\u2014"||a==null||a==="CNY"?i:`${i} ${a}`}var rt={"a-share":[[570,690],[780,900]],hk:[[570,720],[780,960]],us:[[570,960]]},ha=t=>`${String(Math.floor(t/60)).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`;function ua(t){let a=[],i=0;for(let[r,s]of rt[t]??rt.us)a.push([r,s,i]),i+=s-r;return{spans:a,total:i}}function wa(t,a){for(let[i,r,s]of t.spans){if(a<=i)return s;if(a<r)return s+a-i}return t.total}function ma(t){let a=[];for(let[i,r,s]of t.spans)for(let w=i;w<=r;w+=30){let g=s+w-i;(a.length===0||a[a.length-1].slot!==g)&&a.push({time:ha(w),slot:g})}return a}function fa({data:t,t:a}){let[i,r]=A({width:720,height:300}),[s,w]=A(null),g=Ue(null);ge(()=>{let h=g.current;if(h==null)return;let p=()=>{let B=h.getBoundingClientRect();if(!(B.width>0)||!(B.height>0))return;let ee=Math.max(280,Math.round(B.width)),we=Math.max(180,Math.round(B.height));r(be=>Math.abs(be.width-ee)<2&&Math.abs(be.height-we)<2?be:{width:ee,height:we})};if(p(),typeof ResizeObserver>"u")return;let Y=new ResizeObserver(p);return Y.observe(h),()=>Y.disconnect()},[]);let c=t.points,d=t.prev_close,x=i.width,k=i.height,S=66,G=54,N=12,I=18,T=Math.round(Math.min(70,Math.max(30,k*.22))),q=Math.max(60,k-N-I-T-10),H=Math.max(60,x-S-G),z=ua(t.market),V=H/z.total,ae=c.map(h=>h[1]),ie=Math.min(d,...ae),X=Math.max(d,...ae),L=(X-ie)*.06||Math.max(X*.002,.01),U=ie-L,n=X+L,C=h=>N+(n-h)/(n-U)*q,P=c.map(h=>wa(z,da(h[0]))),$=h=>S+h*V,F=$(P[0]).toFixed(1),K=$(P[c.length-1]).toFixed(1),R=t.last===null||t.last>=d?"up":"down",Q=R==="up"?"var(--capital-watchlist-up)":"var(--capital-watchlist-down)",j=c.map((h,p)=>`${p===0?"M":"L"}${$(P[p]).toFixed(1)} ${C(h[1]).toFixed(1)}`).join(""),ue=(N+q).toFixed(1),b=`${j}L${K} ${ue}L${F} ${ue}Z`,se=c.reduce((h,p,Y)=>p[2]===null?h:`${h}${h===""?"M":"L"}${$(P[Y]).toFixed(1)} ${C(p[2]).toFixed(1)}`,""),Z=N+q+10,te=Math.max(1,...c.map(h=>h[3]??0)),le=Math.max(1,Math.min(10,V*.72)),re=C(d),ye=[0,1,2,3,4].map(h=>{let p=U+(n-U)*h/4;return{value:p,y:C(p),pct:(p-d)/d*100}}).filter(h=>Math.abs(h.y-re)>9),de=z.spans.length>1?z.spans[1][2]:null,o=ma(z),y=x>=620?1:2,O=o.filter((h,p)=>p%y===0||p===o.length-1),_=s===null||s<0||s>=c.length?null:c[s],J=_===null?0:$(P[s]),M=_===null?0:C(_[1]),pe=Math.min(x-172,Math.max(8,J+12)),ve=`${t.thscode} ${t.session_date??""} ${a("desk.intraday")} \xB7 ${a("desk.trendOpen")} ${E(t.open)} \xB7 ${a("desk.trendHigh")} ${E(t.high)} \xB7 ${a("desk.trendLow")} ${E(t.low)} \xB7 ${a("desk.trendAvg")} ${E(t.avg)}`,Ce=h=>{let p=h.currentTarget.getBoundingClientRect();if(!(p.width>0))return;let Y=Math.max(0,Math.min(z.total,(h.clientX-p.left-S)/H*z.total)),B=0;for(let ee=1;ee<P.length;ee+=1)Math.abs(P[ee]-Y)<Math.abs(P[B]-Y)&&(B=ee);w(B)};return e("div",{className:"cwd-chartbox",ref:g},e("svg",{className:"cwd-chartsvg",viewBox:`0 0 ${x} ${k}`,role:"img","aria-label":ve,onPointerMove:Ce,onPointerLeave:()=>w(null)},e("defs",null,e("linearGradient",{id:"cwd-trend-fill",x1:"0",y1:"0",x2:"0",y2:"1"},e("stop",{offset:"0%",style:{stopColor:Q,stopOpacity:.2}}),e("stop",{offset:"100%",style:{stopColor:Q,stopOpacity:0}}))),ye.map(h=>e("g",{key:`grid-${h.value.toFixed(4)}`},e("line",{className:"cwd-chartgrid",x1:S,x2:S+H,y1:h.y,y2:h.y}),e("text",{className:"cwd-chartaxis",x:S-8,y:h.y+3.5,textAnchor:"end"},E(h.value)),e("text",{className:"cwd-chartaxis",x:S+H+8,y:h.y+3.5},`${h.pct>0?"+":""}${h.pct.toFixed(2)}%`))),O.map(h=>e("line",{key:`grid-${h.time}`,className:"cwd-chartgrid",x1:$(h.slot),x2:$(h.slot),y1:N,y2:Z+T})),de===null?null:e("line",{className:"cwd-chartsep",x1:$(de),x2:$(de),y1:N,y2:Z+T}),e("path",{className:"cwd-chartarea",d:b,fill:"url(#cwd-trend-fill)"}),c.map((h,p)=>{let Y=h[3]??0,B=Math.max(0,Y/te*T),ee=p===0?d:c[p-1][1],we=$(P[p]+.5);return e("rect",{key:`vol-${p}`,className:h[1]>=ee?"cwd-vol-up":"cwd-vol-down",x:Math.min(S+H-le,Math.max(S,we-le/2)).toFixed(1),y:(Z+T-B).toFixed(1),width:le.toFixed(1),height:Math.max(.5,B).toFixed(1)})}),e("path",{className:"cwd-chartline",d:j,style:{stroke:Q}}),se===""?null:e("path",{className:"cwd-chartavg",d:se}),e("line",{className:"cwd-chartbase",x1:S,x2:S+H,y1:re,y2:re,strokeDasharray:"4 3"}),e("text",{className:"cwd-chartaxis cwd-chartbaselabel",x:S-8,y:re+3.5,textAnchor:"end"},E(d)),O.map(h=>e("text",{key:`tick-${h.time}`,className:"cwd-chartaxis",x:$(h.slot),y:k-5,textAnchor:h.slot===0?"start":h.slot>=z.total?"end":"middle"},h.time)),_===null?null:e("g",null,e("line",{className:"cwd-chartcross",x1:J,x2:J,y1:N,y2:Z+T}),e("line",{className:"cwd-chartcross",x1:S,x2:S+H,y1:M,y2:M}),e("circle",{className:`cwd-chartdot ${R==="up"?"cwd-up":"cwd-down"}`,cx:J,cy:M,r:3}))),_===null?null:e("div",{className:"cwd-charttip",style:{left:`${pe}px`}},e("div",{className:"cwd-charttiptime"},_[0]),e("div",{className:`cwd-charttipprice ${R==="up"?"cwd-up":"cwd-down"}`},`${E(_[1])} ${_e((_[1]-d)/d*100)}`),_[2]===null?null:e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendAvg")),e("span",null,E(_[2]))),_[3]===null?null:e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendVolume")),e("span",null,De(_[3],t.volume_unit,a)))))}function gt(t,a){let i=new Array(t.length).fill(null),r=0;for(let s=0;s<t.length;s+=1)r+=t[s].close,s>=a&&(r-=t[s-a].close),s>=a-1&&(i[s]=r/a);return i}var xt=[5,10,20,60];function ga({data:t,t:a}){let[i,r]=A({width:720,height:300}),[s,w]=A(null),g=Ue(null);ge(()=>{let o=g.current;if(o==null)return;let y=()=>{let _=o.getBoundingClientRect();if(!(_.width>0)||!(_.height>0))return;let J=Math.max(280,Math.round(_.width)),M=Math.max(180,Math.round(_.height));r(pe=>Math.abs(pe.width-J)<2&&Math.abs(pe.height-M)<2?pe:{width:J,height:M})};if(y(),typeof ResizeObserver>"u")return;let O=new ResizeObserver(y);return O.observe(o),()=>O.disconnect()},[]);let c=t.bars,d=i.width,x=i.height,k=66,S=54,G=10,N=18,I=Math.round(Math.min(64,Math.max(28,x*.2))),T=Math.max(60,x-G-N-I-12),q=Math.max(60,d-k-S),H=q/Math.max(1,c.length),z=Math.max(1,Math.min(14,H*.62)),V=Math.max(...c.map(o=>o.high)),ae=Math.min(...c.map(o=>o.low)),ie=(V-ae)*.06||Math.max(V*.01,.01),X=V+ie,L=ae-ie,U=o=>G+(X-o)/(X-L)*T,n=o=>k+(o+.5)*H,C=G+T+12,P=Math.max(1,...c.map(o=>o.volume)),$=o=>o/P*I,F=xt.map(o=>({window:o,values:gt(c,o)})),K=o=>o.reduce((y,O,_)=>O===null?y:`${y}${y===""?"M":"L"}${n(_).toFixed(1)} ${U(O).toFixed(1)}`,""),R=[];for(let o=0;o<c.length;o+=1){let y=c[o].date.slice(5,7);(o===0||y!==c[o-1].date.slice(5,7))&&R.push({index:o,month:y})}let Q=R.length>1?(R[1].index-R[0].index)*H:Number.POSITIVE_INFINITY,j=R.map((o,y)=>({index:o.index,label:y===0&&Q>=56?`${c[o.index].date.slice(0,4)}/${o.month}`:o.month})),ue=[0,1,2,3,4].map(o=>{let y=X-(X-L)*o/4;return{value:y,y:U(y)}}),b=s===null||s<0||s>=c.length?null:c[s],se=b===null?0:n(s),Z=b===null?0:U(b.close),te=s===null||s<=0?null:c[s-1].close,le=b===null||te===null||te<=0?null:(b.close-te)/te*100,re=Math.min(d-186,Math.max(8,se+12)),ye=`${t.thscode} ${a("desk.daily")} \xB7 ${c.length} \xB7 ${E(c[c.length-1].close)}`,de=o=>{let y=o.currentTarget.getBoundingClientRect();if(!(y.width>0))return;let O=Math.round((o.clientX-y.left-k)/H-.5);w(Math.max(0,Math.min(c.length-1,O)))};return e("div",{className:"cwd-klinebox",ref:g},e("svg",{className:"cwd-chartsvg",viewBox:`0 0 ${d} ${x}`,role:"img","aria-label":ye,onPointerMove:de,onPointerLeave:()=>w(null)},ue.map(o=>e("g",{key:`grid-${o.value.toFixed(4)}`},e("line",{className:"cwd-chartgrid",x1:k,x2:k+q,y1:o.y,y2:o.y}),e("text",{className:"cwd-chartaxis",x:k-8,y:o.y+3.5,textAnchor:"end"},E(o.value)))),j.map(o=>e("g",{key:`tick-${o.index}`},e("line",{className:"cwd-chartgrid",x1:n(o.index),x2:n(o.index),y1:G,y2:C+I}),e("text",{className:"cwd-chartaxis",x:n(o.index),y:x-5,textAnchor:o.index===0?"start":"middle"},o.label))),c.map((o,y)=>{let O=Math.max(.5,$(o.volume));return e("rect",{key:`vol-${o.date}`,className:o.close>=o.open?"cwd-vol-up":"cwd-vol-down",x:(n(y)-z/2).toFixed(1),y:(C+I-O).toFixed(1),width:z.toFixed(1),height:O.toFixed(1)})}),e("text",{className:"cwd-chartaxis",x:k-8,y:C+8,textAnchor:"end"},je(P)),c.map((o,y)=>{let O=U(o.open),_=U(o.close),J=Math.min(O,_),M=Math.max(.8,Math.abs(_-O));return e("g",{key:`bar-${o.date}`,className:o.close>=o.open?"cwd-candle-up":"cwd-candle-down"},e("line",{x1:n(y).toFixed(1),x2:n(y).toFixed(1),y1:U(o.high).toFixed(1),y2:U(o.low).toFixed(1)}),e("rect",{x:(n(y)-z/2).toFixed(1),y:J.toFixed(1),width:z.toFixed(1),height:M.toFixed(1)}))}),F.map(o=>{let y=K(o.values);return y===""?null:e("path",{key:`ma-${o.window}`,className:`cwd-maline cwd-ma${o.window}`,d:y})}),b===null?null:e("g",null,e("line",{className:"cwd-chartcross",x1:se,x2:se,y1:G,y2:C+I}),e("line",{className:"cwd-chartcross",x1:k,x2:k+q,y1:Z,y2:Z}))),b===null?null:e("div",{className:"cwd-charttip",style:{left:`${re}px`}},e("div",{className:"cwd-charttiptime"},b.date),e("div",{className:`cwd-charttipprice ${Le(le)}`},`${E(b.close)} ${_e(le)}`),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.kOpen")),e("span",null,E(b.open)),e("span",null,a("desk.kHigh")),e("span",null,E(b.high))),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.kLow")),e("span",null,E(b.low)),e("span",null,a("desk.kClose")),e("span",null,E(b.close))),e("div",{className:"cwd-charttiprow"},e("span",null,a("desk.trendVolume")),e("span",null,De(b.volume,t.volume_unit,a)))))}function xa({size:t=18}){return e("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},e("path",{d:"M4 19V5"}),e("path",{d:"M4 19h16"}),e("path",{d:"m7 15 3-4 3 2 5-7"}),e("circle",{cx:18,cy:6,r:1.4,fill:"currentColor",stroke:"none"}))}function ba({t}){let[a,i]=A([]),[r,s]=A(!0),[w,g]=A(!1),[c,d]=A(null),[x,k]=A({}),[S,G]=A(null),[N,I]=A(oa),[T,q]=A(ne),[H,z]=A(!1),[V,ae]=A(""),[ie,X]=A(""),[L,U]=A(null),[n,C]=A(null),[P,$]=A(null),[F,K]=A({status:"idle",data:null,code:null,detail:null}),[R,Q]=A({status:"idle",data:null,code:null,detail:null}),[j,ue]=A(!1),b=Ue(!0);ge(()=>(b.current=!0,()=>{b.current=!1}),[]),ge(()=>{ca(N)},[N]);let se=l=>{let m=ce(l.items);Array.isArray(m)&&i(m);let f={};for(let u of l.failures??[])u!==null&&typeof u=="object"&&typeof u.thscode=="string"&&(f[u.thscode]=u.code);k(f),typeof l.refreshed_at=="number"&&d(l.refreshed_at),G(l.error!==void 0&&l.error!==null&&typeof l.error.code=="string"?l.error.code:null)},Z=async(l,m={})=>{if(typeof l!="string"||l.length===0){K({status:"idle",data:null,code:null,detail:null}),Q({status:"idle",data:null,code:null,detail:null});return}let f=He+=1;K(u=>({status:"loading",data:u.data!==null&&u.data.thscode===l?u.data:null,code:null,detail:null}));try{let u=`thscode=${encodeURIComponent(l)}${m.bust===!0?"&refresh=1":""}`,v=await W("/trend",{query:u});if(!b.current||f!==He)return;K({status:"ready",data:v,code:null,detail:null})}catch(u){if(!b.current||f!==He)return;let v=typeof u?.code=="string"?u.code:"trend_unavailable",D=typeof u?.detail=="string"&&u.detail.length>0?u.detail:null;K({status:v==="trend_unavailable"?"unavailable":"error",data:null,code:v,detail:D})}},te=async(l,m={})=>{if(typeof l!="string"||l.length===0){Q({status:"idle",data:null,code:null,detail:null});return}let f=Pe+=1;Q(u=>({status:"loading",data:u.data!==null&&u.data.thscode===l?u.data:null,code:null,detail:null}));try{let u=`thscode=${encodeURIComponent(l)}${m.bust===!0?"&refresh=1":""}`,v=await W("/kline",{query:u});if(!b.current||f!==Pe)return;Q({status:"ready",data:v,code:null,detail:null})}catch(u){if(!b.current||f!==Pe)return;let v=typeof u?.code=="string"?u.code:"kline_unavailable",D=typeof u?.detail=="string"&&u.detail.length>0?u.detail:null;Q({status:v==="kline_unavailable"?"unavailable":"error",data:null,code:v,detail:D})}},le=l=>{U(l),Z(l),te(l)};ge(()=>{let l=!1;return(async()=>{try{let f=await W("/list");if(l)return;let u=ce(f.items)??[];i(u);let v=typeof u[0]?.thscode=="string"?u[0].thscode:null;U(D=>D!==null?D:v),v!==null&&(Z(v),te(v))}catch(f){l||G(f.code??"load_failed");return}finally{l||s(!1)}try{let f=await W("/refresh",{body:{}});l||se(f)}catch(f){l||G(f.code??"fuyao_unavailable")}})(),()=>{l=!0}},[]);let re=async()=>{if(!w){g(!0);try{let l=await W("/refresh",{body:{}});b.current&&se(l),b.current&&L!==null&&(Z(L,{bust:!0}),te(L,{bust:!0}))}catch(l){b.current&&G(l.code??"fuyao_unavailable")}finally{b.current&&g(!1)}}},ye=async l=>{let m=a;C(null),i(m.filter(f=>f.thscode!==l)),L===l&&(U(null),K({status:"idle",data:null,code:null,detail:null}));try{await W("/remove",{body:{thscode:l}})}catch{b.current&&i(m)}},de=async l=>{let m=a,f=m.find(u=>u.thscode===l);if(f!==void 0){i([f,...m.filter(u=>u.thscode!==l)]);try{let u=await W("/pin",{body:{thscode:l}});Array.isArray(u.items)&&b.current&&i(ce(u.items))}catch{b.current&&i(m)}}},o=()=>{let l=V.trim();l.length===0||l===ne||N.names.includes(l)||(I({names:[...N.names,l],assignments:N.assignments}),ae(""),q(l))},y=l=>{if(l===ne)return;let m={};for(let[f,u]of Object.entries(N.assignments)){let v=(Array.isArray(u)?u:[]).filter(D=>D!==l);v.length>0&&(m[f]=v)}I({names:N.names.filter(f=>f!==l),assignments:m}),q(ne),z(!1)},O=(l,m)=>{let f=Ee(N,l),u=f.includes(m)?f.filter(D=>D!==m):[...f,m],v={...N.assignments};u.length===0?delete v[l]:v[l]=u,I({names:N.names,assignments:v})},_=ie.trim().toLowerCase(),J=a.filter(l=>T!==ne&&!Ee(N,l.thscode).includes(T)?!1:_.length===0?!0:[l.name,l.thscode,l.ticker].some(m=>typeof m=="string"&&m.toLowerCase().includes(_))),M=L===null?null:a.find(l=>l.thscode===L)??null,pe=[{id:ne,label:t("desk.allGroups"),icon:T===ne?e(ke,{size:14}):void 0}].concat(N.names.map(l=>({id:l,label:l,icon:T===l?e(ke,{size:14}):void 0}))),ve=l=>{if(F.status!=="ready"||F.data===null||F.data.thscode!==l.thscode||typeof F.data.last!="number")return l.quote;let m=F.data.prev_close;return{price:F.data.last,change_pct:m>0?(F.data.last-m)/m*100:null}},Ce=J.map((l,m)=>{let f=ve(l),u=lt(f),v=x[l.thscode],D=Ee(N,l.thscode),qe=L===l.thscode,Be=v===void 0?void 0:t(`error.${v}`),Ae=P===l.thscode;return e("div",{key:l.thscode,className:"cwd-row",role:"listitem","aria-current":qe?"true":void 0,onClick:oe=>{oe.target.closest(".cwd-rowactions")===null&&le(l.thscode)}},e("button",{type:"button",className:"cwd-cellname","aria-pressed":qe,onClick:()=>le(l.thscode)},e("span",{className:"cwd-nameline"},e("span",{className:"cwd-nametext",title:l.name},xe(l.name)),e(Se,{assetType:l.asset_type,t})),e("span",{className:"cwd-codeline"},e("span",{className:"cwd-code"},l.thscode))),e("div",{className:v===void 0?"cwd-price":"cwd-price cwd-stale",title:Be},nt(f)),e("div",{className:`cwd-pct ${Le(u)}`,title:Be},_e(u)),e("div",{className:"cwd-rowactions"},e(Oe,{open:Ae,anchor:e("button",{type:"button",className:"cwd-iconbtn",title:t("desk.more"),"aria-label":`${t("desk.more")} ${l.name}`,"aria-haspopup":"menu","aria-expanded":Ae,onClick:()=>{C(null),$(Ae?null:l.thscode)}},e(ot,{size:16})),items:[{id:"pin",label:t("desk.pin"),icon:e(dt,{size:14}),disabled:m===0}],children:[...N.names.length===0?[e("div",{key:"no-group",className:"cwd-menuhint"},t("desk.noGroupYet"))]:N.names.map(oe=>e(Ne,{key:`group:${oe}`,icon:D.includes(oe)?e(ke,{size:14}):void 0,onSelect:()=>O(l.thscode,oe)},oe)),e(Ne,{key:"remove",danger:!0,separatorBefore:!0,icon:e(Fe,{size:14}),onSelect:()=>{$(null),C(l)}},t("desk.remove"))],onSelect:oe=>{oe==="pin"&&($(null),de(l.thscode))},onClose:()=>$(null),align:"end",portal:!0,listClassName:"cwd-menulist"})))}),h=r?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.loading"))):a.length===0?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.empty")),e("p",{className:"cwd-emptyhint"},t("desk.emptyHint"))):J.length===0?e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.noMatch")),e("p",{className:"cwd-emptyhint"},t("desk.noMatchHint"))):e("div",{className:"cwd-tablebody",role:"list","aria-label":t("desk.title")},Ce),p=F.status==="ready"?F.data:null,Y=p!==null&&M!==null&&p.thscode===M.thscode&&typeof p.last=="number",B=M===null?null:ve(M),ee=lt(B),we=Y?p.points[p.points.length-1][0]:null,be=Y&&p.market==="us"?` ${t("desk.trendZoneUs")}`:"",bt=Y?`${String(p.session_date??"").slice(5)} ${we}${be}`.trim():M===null||M.quote===null||M.quote===void 0?t("desk.notRefreshed"):$e(M.quote.captured_at)||t("desk.notRefreshed"),Me=p===null||p.market==="a-share"?"":` ${t(p.market==="us"?"desk.trendZoneUs":"desk.trendZoneHk")}`,yt=p===null?F.status==="loading"?t("desk.trendLoading"):F.status==="error"?t("desk.trendError"):"":p.session_status==="live"?`${p.stale?t("desk.trendStale"):t("desk.trendLive")}${Me} \xB7 ${p.points[p.points.length-1][0]}`:p.session_status==="closed"?`${p.session_date??""} ${t("desk.trendClosed")}${Me}`:`${t("desk.trendPrevious")} ${p.session_date??""}${Me}`,vt=p===null?null:e("div",{className:"cwd-trendstats"},...[[t("desk.trendOpen"),E(p.open)],[t("desk.trendHigh"),E(p.high)],[t("desk.trendLow"),E(p.low)],[t("desk.trendAvg"),E(p.avg)],[t("desk.trendVolume"),De(p.volume,p.volume_unit,t)],[t("desk.trendAmount"),pa(p.amount,p.currency)]].map(([l,m])=>e("div",{key:l,className:"cwd-trendstat"},e("span",null,l),e("span",{title:m},m)))),Ge=(l,m,f=null)=>{let u=l.status==="error"?m.error:l.status==="loading"?m.loading:m.unavailable,v=l.status==="error"?l.detail:l.status==="unavailable"?m.hint:null,D=l.status==="error"&&f!==null;return e("div",{className:D?"cwd-chart cwd-chartfail":"cwd-chart"},e("div",{className:"cwd-fallback"},e("div",{className:"cwd-charttext"},u),v==null||v.length===0?null:e("div",{className:"cwd-charthint"},v),D?e("button",{type:"button",className:"cwd-retry",onClick:f.onClick},e(Re,{size:14}),e("span",null,t("desk.retry"))):null))},kt=p!==null?e(fa,{key:p.thscode,data:p,t}):Ge(F,{error:t("desk.trendError"),loading:t("desk.trendLoading"),unavailable:t("desk.trendUnavailable"),hint:t("desk.trendUnavailableHint")},{onClick:()=>{Z(L,{bust:!0})}}),me=R.status==="ready"&&Array.isArray(R.data?.bars)&&R.data.bars.length>0?R.data:null,Nt=me===null?R.status==="loading"?t("desk.klineLoading"):R.status==="error"?t("desk.klineError"):"":t("desk.adjustQfq"),$t=me===null?null:e("div",{className:"cwd-malegend"},...xt.map(l=>{let m=gt(me.bars,l),f=m[m.length-1];return e("span",{key:l,className:`cwd-malegenditem cwd-ma${l}`},`MA${l} ${f==null?"\u2014":E(f)}`)})),St=me!==null?e(ga,{key:me.thscode,data:me,t}):Ge(R,{error:t("desk.klineError"),loading:t("desk.klineLoading"),unavailable:t("desk.klineUnavailable"),hint:t("desk.klineUnavailableHint")},{onClick:()=>{te(L,{bust:!0})}}),_t=e("div",{className:"cwd-block cwd-block-kline"},e("div",{className:"cwd-blockhead"},e("span",{className:"cwd-blocktitle"},t("desk.daily")),$t,e("span",{className:"cwd-blocknote"},Nt)),St),Ct=M===null?e("div",{className:"cwd-card"},e("div",{className:"cwd-empty"},e("div",{className:"cwd-emptytitle"},t("desk.selectHint")),e("p",{className:"cwd-emptyhint"},t("desk.selectHintBody")))):e("div",{className:"cwd-card"},e("div",{className:"cwd-detail"},e("div",{className:"cwd-detailhead"},e("div",{style:{minWidth:0}},e("div",{className:"cwd-detailname"},e("span",{className:"cwd-detailtext",title:M.name},xe(M.name)),e(Se,{assetType:M.asset_type,t})),e("div",{className:"cwd-detailcode"},M.thscode))),e("div",{className:"cwd-quoterow"},e("div",{className:"cwd-bigquote"},e("span",{className:"cwd-bigprice"},nt(B)),e("span",{className:`cwd-bigpct ${Le(ee)}`},_e(ee))),e("div",{className:"cwd-meta"},e("div",{className:"cwd-metaitem"},e("div",{className:"cwd-metalabel"},t("desk.capturedAt")),e("div",{className:"cwd-metavalue"},bt)),e("div",{className:"cwd-metaitem"},e("div",{className:"cwd-metalabel"},t("desk.kind")),e("div",{className:"cwd-metavalue"},ut(M.asset_type,t))))),e("div",{className:j?"cwd-block cwd-block-chart cwd-folded":"cwd-block cwd-block-chart"},e("div",{className:"cwd-blockhead"},e("span",{className:"cwd-blocktitle"},t("desk.intraday")),j?null:vt,e("span",{className:"cwd-blocknote"},yt),e("button",{type:"button",className:"cwd-blockfold","aria-expanded":j?"false":"true",onClick:()=>ue(!j)},t(j?"desk.unfold":"desk.fold"))),j?null:kt),_t));return e("div",{className:"cwd-page"},e("div",{className:"cwd-inner"},e("header",{className:"cwd-head"},e("h1",{className:"cwd-title"},t("desk.title")),e("div",{className:"cwd-headactions"},e("span",{className:"cwd-updated"},`${t("desk.lastUpdate")} ${c===null?t("desk.notRefreshed"):$e(c)}`),e("button",{type:"button",className:"cwd-refresh",disabled:w,onClick:()=>{re()}},e(Re,{size:14}),t(w?"desk.refreshing":"desk.refresh")))),e("div",{className:"cwd-body"},e("section",{className:"cwd-card"},e("div",{className:"cwd-toolbar"},e("label",{className:"cwd-field"},e(pt,{size:14}),e("input",{type:"text",value:ie,placeholder:t("desk.filterPlaceholder"),"aria-label":t("desk.filter"),onChange:l=>X(l.target.value)})),e(Oe,{open:H,anchor:e("button",{type:"button",className:"cwd-pill","aria-haspopup":"menu","aria-expanded":H,"aria-label":t("desk.group"),onClick:()=>z(!H)},e(ct,{size:14}),e("span",null,T===ne?t("desk.allGroups"):T)),items:pe,children:T===ne?[]:[e(Ne,{key:"delete-group",danger:!0,separatorBefore:!0,icon:e(Fe,{size:14}),onSelect:()=>y(T)},t("desk.deleteGroup"))],onSelect:l=>{z(!1),q(l)},onClose:()=>z(!1),align:"start",portal:!0,listClassName:"cwd-menulist"}),e("div",{className:"cwd-groupcreate"},e("input",{type:"text",value:V,maxLength:20,placeholder:t("desk.newGroup"),"aria-label":t("desk.newGroup"),onChange:l=>ae(l.target.value),onKeyDown:l=>{l.key==="Enter"&&o()}}),e("button",{type:"button",className:"cwd-pill",disabled:V.trim().length===0,onClick:o},t("desk.createGroup")))),S===null?null:e("div",{className:"cwd-error",role:"alert"},t(S==="load_failed"?"desk.loadFailed":`error.${S}`)),n===null?null:e("div",{className:"cwd-notice cwd-notice-danger"},e("span",null,`${t("desk.removeHint")} \xB7 ${xe(n.name)}`),e("button",{type:"button",className:"cwd-pill",onClick:()=>C(null)},t("desk.cancel"))),e("div",{className:"cwd-thead",role:"row"},e("span",null,t("desk.colName")),e("span",{className:"cwd-right"},t("desk.colPrice")),e("span",{className:"cwd-right"},t("desk.colChange")),e("span",{className:"cwd-right"},t("desk.colAction"))),h),e("aside",null,Ct))))}function ya(t){t.effect(ta,`${he}: styles`),t.effect(()=>t.locale.register(fe,{zh:Kt,en:Qt}),`${he}: dictionaries`);let a=new Map,i=c=>{let d=a.get(c);return d===void 0&&(d=new Ie,a.set(c,d)),d};t.effect(()=>()=>{for(let c of a.values())c.dispose();a.clear()},`${he}: per-session surfaces`);let r=c=>{let x=t.sessions?.list?.getSnapshot?.().byId?.[c]?.projectionValues?.agentPreset;return typeof x=="string"?x:void 0},s=new Set,w=c=>{let d=r(c);return d!==void 0?d===Bt:(s.has(c)||(s.add(c),Promise.resolve(t.sessions?.refreshProjections?.(c)).catch(()=>{})),!1)};t.slots.inject(Je,()=>t.slots.register({name:Je,id:"capital-watchlist-dialog",order:3,locale:fe,inject:c=>{let d=i(c);return{hooks:{dialog:d.state},surface:d}}},ra));let g=t.locale.bind(fe);t.slots.inject("main",()=>t.slots.register({name:"main",key:st,locale:fe},ba)),t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:st,order:12,locale:fe,label:()=>g("desk.panel")},xa)),t.inject(["commandUi"],c=>{let d=t.locale.bind(fe);c.effect(()=>c.commandUi.register({name:"watchlist",label:()=>d("command.label"),description:()=>d("command.description"),icon:ke,available:x=>w(x.sessionId),ui:{kind:"action",run:x=>{i(x.sessionId).open()}}}),`${he}: /watchlist contribution`)}),t.logger?.info?.(`${he}: \u5BA2\u6237\u7AEF\u534A\u8FB9\u5DF2\u6302\u8F7D\uFF08/watchlist \u83DC\u5355\u884C + \u81EA\u9009\u80A1\u5F39\u7A97\uFF09`)}exports.name=he;exports.inject=["slots","locale","commandUi","sessions"];exports.apply=ya;
252
259
  return module.exports
253
260
  },
254
261
  })
@@ -144,13 +144,13 @@ const zh = {
144
144
  'desk.trendUnavailable': '该市场暂时没有分时数据',
145
145
  'desk.trendUnavailableHint': '场外美股与部分海外指数没有分时源,这里不画假走势。',
146
146
  'desk.trendError': '分时加载失败',
147
- 'desk.trendRetry': '重试',
147
+ 'desk.retry': '重试',
148
148
  'desk.daily': '日K',
149
149
  'desk.fold': '收起',
150
150
  'desk.unfold': '展开',
151
151
  'desk.adjustQfq': '前复权',
152
152
  'desk.klineLoading': '正在读取日K…',
153
- 'desk.klineError': '日K暂时取不到',
153
+ 'desk.klineError': '日K加载失败',
154
154
  'desk.klineUnavailable': '该市场暂时没有日K数据',
155
155
  'desk.klineUnavailableHint': '港美股指数只有分时,没有可用的日线序列',
156
156
  'desk.kOpen': '开',
@@ -291,13 +291,13 @@ const en = {
291
291
  'desk.trendUnavailable': 'No intraday series for this market',
292
292
  'desk.trendUnavailableHint': 'OTC US lines and some overseas indices have no intraday source; nothing is drawn to fill the gap.',
293
293
  'desk.trendError': 'Intraday failed to load',
294
- 'desk.trendRetry': 'Retry',
294
+ 'desk.retry': 'Retry',
295
295
  'desk.daily': 'Daily',
296
296
  'desk.fold': 'Collapse',
297
297
  'desk.unfold': 'Expand',
298
298
  'desk.adjustQfq': 'Forward-adjusted',
299
299
  'desk.klineLoading': 'Loading daily bars…',
300
- 'desk.klineError': 'Daily bars are unavailable',
300
+ 'desk.klineError': 'Daily bars failed to load',
301
301
  'desk.klineUnavailable': 'No daily bars for this market',
302
302
  'desk.klineUnavailableHint': 'HK/US indices carry an intraday series only',
303
303
  'desk.kOpen': 'Open',
@@ -593,6 +593,13 @@ const CSS = `
593
593
  .cwd-chart { flex: 1; min-height: 150px; display: grid; place-items: center; padding: 12px; border: 1px dashed var(--dsw-alias-border-l2); border-radius: 10px; background: repeating-linear-gradient(180deg, color-mix(in srgb, var(--dsw-alias-border-l2) 60%, transparent) 0 1px, transparent 1px 36px), var(--dsw-alias-bg-module-platform); text-align: center; }
594
594
  .cwd-charttext { font-size: 12.5px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
595
595
  .cwd-charthint { margin-top: 4px; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
596
+ .cwd-chartfail { border-style: solid; background: var(--dsw-alias-bg-module-platform); }
597
+ .cwd-chartfail .cwd-charttext { color: var(--dsw-alias-label-primary); }
598
+ .cwd-fallback { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 360px; }
599
+ .cwd-retry { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-top: 12px; height: 34px; padding: 0 14px; border: .5px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 38%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 12%, transparent); color: var(--dsw-alias-state-business-primary); font-family: inherit; font-size: 12.5px; line-height: 20px; font-weight: 500; cursor: pointer; }
600
+ .cwd-retry:hover { background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 22%, transparent); }
601
+ .cwd-retry:active { background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent); }
602
+ .cwd-retry:focus-visible { outline: 2px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 60%, transparent); outline-offset: 2px; }
596
603
  .cwd-trendstats { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 2px 14px; min-width: 0; }
597
604
  .cwd-trendstat { display: flex; align-items: baseline; gap: 5px; font-size: 11px; line-height: 17px; }
598
605
  .cwd-trendstat span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@@ -681,6 +688,9 @@ async function call(path, { query, body, signal } = {}) {
681
688
  : (response.status === 401 || response.status === 403) ? 'unauthorized' : 'fuyao_unavailable'
682
689
  const error = new Error(code)
683
690
  error.code = code
691
+ // The host's sentence already names what failed (timeout / garbled payload / upstream down);
692
+ // the pane prints it under the title instead of guessing from the code.
693
+ error.detail = typeof payload.message === 'string' && payload.message.length > 0 ? payload.message : null
684
694
  error.candidates = payload.candidates
685
695
  error.limit = payload.limit
686
696
  throw error
@@ -1989,8 +1999,8 @@ function WatchlistDeskPage({ t }) {
1989
1999
  const [selected, setSelected] = useState(null)
1990
2000
  const [pendingRemove, setPendingRemove] = useState(null)
1991
2001
  const [rowMenu, setRowMenu] = useState(null)
1992
- const [trend, setTrend] = useState({ status: 'idle', data: null, code: null })
1993
- const [kline, setKline] = useState({ status: 'idle', data: null, code: null })
2002
+ const [trend, setTrend] = useState({ status: 'idle', data: null, code: null, detail: null })
2003
+ const [kline, setKline] = useState({ status: 'idle', data: null, code: null, detail: null })
1994
2004
  // Folded = the intraday pane keeps only its title row, so the daily pane gets the whole column.
1995
2005
  const [trendFolded, setTrendFolded] = useState(false)
1996
2006
  const alive = useRef(true)
@@ -2020,41 +2030,43 @@ function WatchlistDeskPage({ t }) {
2020
2030
  */
2021
2031
  const loadTrend = async (thscode, options = {}) => {
2022
2032
  if (typeof thscode !== 'string' || thscode.length === 0) {
2023
- setTrend({ status: 'idle', data: null, code: null })
2024
- setKline({ status: 'idle', data: null, code: null })
2033
+ setTrend({ status: 'idle', data: null, code: null, detail: null })
2034
+ setKline({ status: 'idle', data: null, code: null, detail: null })
2025
2035
  return
2026
2036
  }
2027
2037
  const request = (deskTrendSequence += 1)
2028
- setTrend((previous) => ({ status: 'loading', data: previous.data !== null && previous.data.thscode === thscode ? previous.data : null, code: null }))
2038
+ setTrend((previous) => ({ status: 'loading', data: previous.data !== null && previous.data.thscode === thscode ? previous.data : null, code: null, detail: null }))
2029
2039
  try {
2030
2040
  const query = `thscode=${encodeURIComponent(thscode)}${options.bust === true ? '&refresh=1' : ''}`
2031
2041
  const payload = await call('/trend', { query })
2032
2042
  if (!alive.current || request !== deskTrendSequence) return
2033
- setTrend({ status: 'ready', data: payload, code: null })
2043
+ setTrend({ status: 'ready', data: payload, code: null, detail: null })
2034
2044
  } catch (failure) {
2035
2045
  if (!alive.current || request !== deskTrendSequence) return
2036
2046
  const code = typeof failure?.code === 'string' ? failure.code : 'trend_unavailable'
2037
- setTrend({ status: code === 'trend_unavailable' ? 'unavailable' : 'error', data: null, code })
2047
+ const detail = typeof failure?.detail === 'string' && failure.detail.length > 0 ? failure.detail : null
2048
+ setTrend({ status: code === 'trend_unavailable' ? 'unavailable' : 'error', data: null, code, detail })
2038
2049
  }
2039
2050
  }
2040
2051
 
2041
2052
  /** Same shape as `loadTrend`: the daily pane has its own request, so one slow history never blocks a tick. */
2042
2053
  const loadKline = async (thscode, options = {}) => {
2043
2054
  if (typeof thscode !== 'string' || thscode.length === 0) {
2044
- setKline({ status: 'idle', data: null, code: null })
2055
+ setKline({ status: 'idle', data: null, code: null, detail: null })
2045
2056
  return
2046
2057
  }
2047
2058
  const request = (deskKlineSequence += 1)
2048
- setKline((previous) => ({ status: 'loading', data: previous.data !== null && previous.data.thscode === thscode ? previous.data : null, code: null }))
2059
+ setKline((previous) => ({ status: 'loading', data: previous.data !== null && previous.data.thscode === thscode ? previous.data : null, code: null, detail: null }))
2049
2060
  try {
2050
2061
  const query = `thscode=${encodeURIComponent(thscode)}${options.bust === true ? '&refresh=1' : ''}`
2051
2062
  const payload = await call('/kline', { query })
2052
2063
  if (!alive.current || request !== deskKlineSequence) return
2053
- setKline({ status: 'ready', data: payload, code: null })
2064
+ setKline({ status: 'ready', data: payload, code: null, detail: null })
2054
2065
  } catch (failure) {
2055
2066
  if (!alive.current || request !== deskKlineSequence) return
2056
2067
  const code = typeof failure?.code === 'string' ? failure.code : 'kline_unavailable'
2057
- setKline({ status: code === 'kline_unavailable' ? 'unavailable' : 'error', data: null, code })
2068
+ const detail = typeof failure?.detail === 'string' && failure.detail.length > 0 ? failure.detail : null
2069
+ setKline({ status: code === 'kline_unavailable' ? 'unavailable' : 'error', data: null, code, detail })
2058
2070
  }
2059
2071
  }
2060
2072
 
@@ -2120,7 +2132,7 @@ function WatchlistDeskPage({ t }) {
2120
2132
  setItems(before.filter((row) => row.thscode !== thscode))
2121
2133
  if (selected === thscode) {
2122
2134
  setSelected(null)
2123
- setTrend({ status: 'idle', data: null, code: null })
2135
+ setTrend({ status: 'idle', data: null, code: null, detail: null })
2124
2136
  }
2125
2137
  try {
2126
2138
  await call('/remove', { body: { thscode } })
@@ -2305,16 +2317,34 @@ function WatchlistDeskPage({ t }) {
2305
2317
  ].map(([label, value]) => h('div', { key: label, className: 'cwd-trendstat' },
2306
2318
  h('span', null, label), h('span', { title: value }, value))))
2307
2319
 
2320
+ /**
2321
+ * One look for both panes when there is nothing to draw: the host's own sentence says what went
2322
+ * wrong, and the retry is a real button — inside an empty 300px box a borderless pill reads as
2323
+ * plain text, which is exactly what makes a dead pane look unrecoverable.
2324
+ */
2325
+ const chartFallback = (state, labels, retry = null) => {
2326
+ const title = state.status === 'error' ? labels.error : state.status === 'loading' ? labels.loading : labels.unavailable
2327
+ const reason = state.status === 'error' ? state.detail : state.status === 'unavailable' ? labels.hint : null
2328
+ const showRetry = state.status === 'error' && retry !== null
2329
+ return h('div', { className: showRetry ? 'cwd-chart cwd-chartfail' : 'cwd-chart' },
2330
+ h('div', { className: 'cwd-fallback' },
2331
+ h('div', { className: 'cwd-charttext' }, title),
2332
+ reason === null || reason === undefined || reason.length === 0 ? null : h('div', { className: 'cwd-charthint' }, reason),
2333
+ showRetry
2334
+ ? h('button', { type: 'button', className: 'cwd-retry', onClick: retry.onClick },
2335
+ h(IconRefreshOutlineRegular, { size: 14 }),
2336
+ h('span', null, t('desk.retry')))
2337
+ : null))
2338
+ }
2339
+
2308
2340
  const trendBody = trendData !== null
2309
2341
  ? h(IntradayChart, { key: trendData.thscode, data: trendData, t })
2310
- : h('div', { className: 'cwd-chart' }, h('div', null,
2311
- h('div', { className: 'cwd-charttext' }, trend.status === 'error' ? t('desk.trendError') : trend.status === 'loading' ? t('desk.trendLoading') : t('desk.trendUnavailable')),
2312
- trend.status === 'unavailable'
2313
- ? h('div', { className: 'cwd-charthint' }, t('desk.trendUnavailableHint'))
2314
- : null,
2315
- trend.status === 'error'
2316
- ? h('button', { type: 'button', className: 'cwd-pill', onClick: () => { void loadTrend(selected, { bust: true }) } }, t('desk.trendRetry'))
2317
- : null))
2342
+ : chartFallback(trend, {
2343
+ error: t('desk.trendError'),
2344
+ loading: t('desk.trendLoading'),
2345
+ unavailable: t('desk.trendUnavailable'),
2346
+ hint: t('desk.trendUnavailableHint'),
2347
+ }, { onClick: () => { void loadTrend(selected, { bust: true }) } })
2318
2348
  const klineData = kline.status === 'ready' && Array.isArray(kline.data?.bars) && kline.data.bars.length > 0 ? kline.data : null
2319
2349
  const klineNote = klineData === null
2320
2350
  ? (kline.status === 'loading' ? t('desk.klineLoading') : kline.status === 'error' ? t('desk.klineError') : '')
@@ -2328,12 +2358,12 @@ function WatchlistDeskPage({ t }) {
2328
2358
  }))
2329
2359
  const klineBody = klineData !== null
2330
2360
  ? h(DailyChart, { key: klineData.thscode, data: klineData, t })
2331
- : h('div', { className: 'cwd-chart' }, h('div', null,
2332
- h('div', { className: 'cwd-charttext' }, kline.status === 'error' ? t('desk.klineError') : kline.status === 'loading' ? t('desk.klineLoading') : t('desk.klineUnavailable')),
2333
- kline.status === 'unavailable' ? h('div', { className: 'cwd-charthint' }, t('desk.klineUnavailableHint')) : null,
2334
- kline.status === 'error'
2335
- ? h('button', { type: 'button', className: 'cwd-pill', onClick: () => { void loadKline(selected, { bust: true }) } }, t('desk.trendRetry'))
2336
- : null))
2361
+ : chartFallback(kline, {
2362
+ error: t('desk.klineError'),
2363
+ loading: t('desk.klineLoading'),
2364
+ unavailable: t('desk.klineUnavailable'),
2365
+ hint: t('desk.klineUnavailableHint'),
2366
+ }, { onClick: () => { void loadKline(selected, { bust: true }) } })
2337
2367
  const klineBlock = h('div', { className: 'cwd-block cwd-block-kline' },
2338
2368
  h('div', { className: 'cwd-blockhead' },
2339
2369
  h('span', { className: 'cwd-blocktitle' }, t('desk.daily')),
@@ -969,27 +969,33 @@ export function createWatchlistService(options = {}) {
969
969
  }
970
970
  }
971
971
 
972
+ /** A body we cannot read: empty series, changed row shape, unreadable field. */
973
+ const PARSE_FAILURES = new Set(['tencent_parse_failed', 'tencent_invalid_response', 'tencent_empty_response'])
974
+
972
975
  /** Upstream failures degrade to one block in the desk, never to a whole-route error. */
973
976
  function trendFailure(error) {
974
977
  const name = typeof error?.name === 'string' ? error.name : ''
975
- if (name === 'AbortError' || name === 'TimeoutError') return { ok: false, code: 'trend_timeout', message: '分时数据请求超时' }
978
+ if (name === 'AbortError' || name === 'TimeoutError') return { ok: false, code: 'trend_timeout', message: '上游没有及时回话' }
976
979
  const code = typeof error?.code === 'string' ? error.code : ''
977
- if (code === 'trend_unavailable' || code === 'trend_parse_failed') return { ok: false, code, message: '分时数据暂时取不到' }
980
+ if (PARSE_FAILURES.has(code) || code === 'trend_parse_failed') return { ok: false, code: 'trend_parse_failed', message: '上游这次回的报文不完整' }
981
+ if (code === 'trend_unavailable') return { ok: false, code, message: '该市场暂时没有分时数据' }
978
982
  if (code === 'rate_limited' || code === 'tencent_rate_limit' || code === 'eastmoney_rate_limit') {
979
983
  return { ok: false, code: 'rate_limited', message: '行情服务限流,请稍后再试' }
980
984
  }
981
- return { ok: false, code: 'trend_unavailable', message: '分时数据暂时取不到' }
985
+ // "All three minute hosts are down" is an upstream outage, not a market without data: the desk
986
+ // must not answer it with the market hint.
987
+ return { ok: false, code: 'trend_upstream_unavailable', message: '行情源这次没有给出分时' }
982
988
  }
983
989
 
984
990
  function klineFailure(error) {
985
991
  const name = typeof error?.name === 'string' ? error.name : ''
986
- if (name === 'AbortError' || name === 'TimeoutError') return { ok: false, code: 'kline_timeout', message: '日K数据请求超时' }
992
+ if (name === 'AbortError' || name === 'TimeoutError') return { ok: false, code: 'kline_timeout', message: '上游没有及时回话' }
987
993
  const code = typeof error?.code === 'string' ? error.code : ''
988
- if (code === 'tencent_parse_failed' || code === 'trend_parse_failed') return { ok: false, code: 'kline_parse_failed', message: '日K数据解析失败' }
994
+ if (PARSE_FAILURES.has(code) || code === 'trend_parse_failed') return { ok: false, code: 'kline_parse_failed', message: '上游这次回的报文不完整' }
989
995
  if (code === 'rate_limited' || code === 'tencent_rate_limit' || code === 'eastmoney_rate_limit') {
990
996
  return { ok: false, code: 'rate_limited', message: '行情服务限流,请稍后再试' }
991
997
  }
992
- return { ok: false, code: 'kline_unavailable', message: '日K数据暂时取不到' }
998
+ return { ok: false, code: 'kline_upstream_unavailable', message: '行情源这次没有给出日线' }
993
999
  }
994
1000
 
995
1001
  /** Only whole-batch failures become batch errors (rate limit, missing key, service down). */
@@ -1055,9 +1061,11 @@ const FAILURE_STATUS = {
1055
1061
  trend_unavailable: 502,
1056
1062
  trend_timeout: 504,
1057
1063
  trend_parse_failed: 502,
1064
+ trend_upstream_unavailable: 502,
1058
1065
  kline_unavailable: 502,
1059
1066
  kline_timeout: 504,
1060
1067
  kline_parse_failed: 502,
1068
+ kline_upstream_unavailable: 502,
1061
1069
  ambiguous: 409,
1062
1070
  list_full: 409,
1063
1071
  credential_missing: 503,
@@ -1133,10 +1141,12 @@ export function createRouteHandler(service, options = {}) {
1133
1141
  }
1134
1142
  if (method === 'GET' && pathname === '/list') return send(res, 200, await service.list())
1135
1143
  if (method === 'GET' && pathname === '/kline') {
1136
- return sendBusiness(res, await service.kline({ thscode: searchParams.get('thscode') ?? '', refresh: searchParams.get('refresh') === '1' }))
1144
+ const thscode = searchParams.get('thscode') ?? ''
1145
+ return sendBusiness(res, logUpstreamFailure(options.logger, 'kline', thscode, await service.kline({ thscode, refresh: searchParams.get('refresh') === '1' })))
1137
1146
  }
1138
1147
  if (method === 'GET' && pathname === '/trend') {
1139
- return sendBusiness(res, await service.trend({ thscode: searchParams.get('thscode') ?? '', refresh: searchParams.get('refresh') === '1' }))
1148
+ const thscode = searchParams.get('thscode') ?? ''
1149
+ return sendBusiness(res, logUpstreamFailure(options.logger, 'trend', thscode, await service.trend({ thscode, refresh: searchParams.get('refresh') === '1' })))
1140
1150
  }
1141
1151
  if (method === 'GET' && pathname === '/search') return sendBusiness(res, await service.search(searchParams.get('q') ?? ''))
1142
1152
  send(res, 404, { ok: false, code: 'not_found', message: 'unknown watchlist route' })
@@ -1151,6 +1161,20 @@ function storeCause(error) {
1151
1161
  return [error?.code, error?.message ?? error].filter(Boolean).join(':') || 'unknown'
1152
1162
  }
1153
1163
 
1164
+ /** Caller mistakes (a stale row, a bad code) are not incidents; only upstream and storage faults are. */
1165
+ const REQUEST_FAULTS = new Set(['invalid_query', 'not_watched', 'not_found', 'ambiguous', 'list_full'])
1166
+
1167
+ /**
1168
+ * The panel shows one sentence and nothing else, so the failure code has to land somewhere the
1169
+ * maintainer can read it back: the host log names the route, the symbol and the upstream code.
1170
+ */
1171
+ function logUpstreamFailure(logger, route, thscode, result) {
1172
+ if (result?.ok !== true && !REQUEST_FAULTS.has(result.code)) {
1173
+ logger?.warn?.(`capital-watchlist: ${route} ${thscode} → ${result.code}${result.reason === undefined ? '' : ` (${result.reason})`}`)
1174
+ }
1175
+ return result
1176
+ }
1177
+
1154
1178
  function sendBusiness(res, result) {
1155
1179
  if (result.ok === true) return send(res, 200, result)
1156
1180
  return send(res, FAILURE_STATUS[result.code] ?? 400, result)
@@ -1207,7 +1231,7 @@ export function apply(ctx) {
1207
1231
  const dispose = webCtx.webServer.register({
1208
1232
  kind: 'prefix',
1209
1233
  path: ROUTE_PATH,
1210
- handler: createRouteHandler(service, { authorize }),
1234
+ handler: createRouteHandler(service, { authorize, logger: ctx.logger }),
1211
1235
  })
1212
1236
  return () => {
1213
1237
  if (typeof dispose === 'function') dispose()
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/watchlist",
3
- "version": "2.27.0",
3
+ "version": "2.27.1",
4
4
  "description": "自动模式的用户自选股(宿主级清单 + Fuyao 报价快照 + /capital-watchlist 路由 + 输入框菜单弹窗):由 @v587d/capital-generation 随包携带并作为 host 平面行挂载。",
5
5
  "license": "MIT",
6
6
  "type": "module",