dsh-mishu 0.0.1 → 0.5.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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -0
  3. package/cordis.patch.yml +5 -0
  4. package/lib/client.js +1324 -0
  5. package/lib/core/ask.js +132 -0
  6. package/lib/core/board.js +200 -0
  7. package/lib/core/brief.js +208 -0
  8. package/lib/core/exec.js +68 -0
  9. package/lib/core/explain.js +71 -0
  10. package/lib/core/fold.js +89 -0
  11. package/lib/core/github/client.js +152 -0
  12. package/lib/core/github/facts.js +173 -0
  13. package/lib/core/github/rules.js +274 -0
  14. package/lib/core/github/sync.js +112 -0
  15. package/lib/core/github/token.js +79 -0
  16. package/lib/core/i18n.js +54 -0
  17. package/lib/core/index.js +40 -0
  18. package/lib/core/mail/account.js +78 -0
  19. package/lib/core/mail/imap.js +98 -0
  20. package/lib/core/mail/rules.js +69 -0
  21. package/lib/core/mail/sync.js +72 -0
  22. package/lib/core/manual.js +157 -0
  23. package/lib/core/matters.js +54 -0
  24. package/lib/core/recur.js +73 -0
  25. package/lib/core/secrets.js +170 -0
  26. package/lib/core/settings.js +99 -0
  27. package/lib/core/store.js +322 -0
  28. package/lib/core/time.js +111 -0
  29. package/lib/dsh/api.js +270 -0
  30. package/lib/dsh/config.js +23 -0
  31. package/lib/dsh/plugin.js +167 -0
  32. package/lib/dsh/runtime.js +120 -0
  33. package/lib/dsh/tools.js +184 -0
  34. package/lib/index.js +11 -0
  35. package/lib/types/core/ask.d.ts +41 -0
  36. package/lib/types/core/board.d.ts +108 -0
  37. package/lib/types/core/brief.d.ts +33 -0
  38. package/lib/types/core/exec.d.ts +28 -0
  39. package/lib/types/core/explain.d.ts +22 -0
  40. package/lib/types/core/fold.d.ts +28 -0
  41. package/lib/types/core/github/client.d.ts +152 -0
  42. package/lib/types/core/github/facts.d.ts +104 -0
  43. package/lib/types/core/github/rules.d.ts +39 -0
  44. package/lib/types/core/github/sync.d.ts +37 -0
  45. package/lib/types/core/github/token.d.ts +39 -0
  46. package/lib/types/core/i18n.d.ts +31 -0
  47. package/lib/types/core/index.d.ts +33 -0
  48. package/lib/types/core/mail/account.d.ts +72 -0
  49. package/lib/types/core/mail/imap.d.ts +44 -0
  50. package/lib/types/core/mail/rules.d.ts +12 -0
  51. package/lib/types/core/mail/sync.d.ts +30 -0
  52. package/lib/types/core/manual.d.ts +54 -0
  53. package/lib/types/core/matters.d.ts +32 -0
  54. package/lib/types/core/recur.d.ts +30 -0
  55. package/lib/types/core/secrets.d.ts +45 -0
  56. package/lib/types/core/settings.d.ts +39 -0
  57. package/lib/types/core/store.d.ts +143 -0
  58. package/lib/types/core/time.d.ts +37 -0
  59. package/lib/types/dsh/api.d.ts +20 -0
  60. package/lib/types/dsh/config.d.ts +25 -0
  61. package/lib/types/dsh/plugin.d.ts +13 -0
  62. package/lib/types/dsh/runtime.d.ts +40 -0
  63. package/lib/types/dsh/tools.d.ts +43 -0
  64. package/lib/types/index.d.ts +11 -0
  65. package/package.json +50 -4
  66. package/docs//350/260/203/347/240/224/344/270/216/350/256/276/350/256/241.md +0 -90
package/lib/client.js ADDED
@@ -0,0 +1,1324 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-mishu",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/client/index.tsx
26
+ var index_exports = {};
27
+ __export(index_exports, {
28
+ PACKAGE_NAME: () => PACKAGE_NAME,
29
+ PANEL_ID: () => PANEL_ID,
30
+ apply: () => apply,
31
+ inject: () => inject
32
+ });
33
+ module.exports = __toCommonJS(index_exports);
34
+
35
+ // src/client/Board.tsx
36
+ var import_react3 = require("react");
37
+
38
+ // src/client/api.ts
39
+ async function post(path, body) {
40
+ try {
41
+ const res = await fetch(new URL(`/api/dsh-mishu${path}`, document.baseURI), {
42
+ method: "POST",
43
+ credentials: "same-origin",
44
+ headers: { "content-type": "application/json" },
45
+ body: JSON.stringify(body)
46
+ });
47
+ const value = await res.json().catch(() => null);
48
+ if (value === null) return { ok: false, message: `HTTP ${res.status}` };
49
+ return value;
50
+ } catch (error) {
51
+ return { ok: false, message: error instanceof Error ? error.message : String(error) };
52
+ }
53
+ }
54
+ var mishuApi = {
55
+ board: (lang) => post("/board", { lang }),
56
+ sync: (lang) => post("/sync", { lang }),
57
+ action: (lang, target, id, action, days) => post("/action", { lang, target, id, action, ...days === void 0 ? {} : { days } }),
58
+ detail: (lang, id) => post("/detail", { lang, id }),
59
+ preview: (lang, item) => post("/preview", { lang, item }),
60
+ add: (lang, item) => post("/add", { lang, item }),
61
+ ask: (lang, ask) => post("/ask", { lang, ask })
62
+ };
63
+ var settingsApi = {
64
+ load: (lang) => post("/settings", { lang }),
65
+ save: (lang, settings) => post("/settings/save", { lang, settings }),
66
+ testGithub: (lang) => post("/github/test", { lang }),
67
+ saveToken: (lang, token) => post("/github/token/save", { lang, token }),
68
+ deleteToken: (lang) => post("/github/token/delete", { lang }),
69
+ saveMail: (lang, account, password) => post("/mail/save", { lang, account, password }),
70
+ testMail: (lang, account, password) => post("/mail/test", { lang, account, password }),
71
+ deleteMail: (lang, id) => post("/mail/delete", { lang, id }),
72
+ syncMail: (lang, id) => post("/mail/sync", { lang, id })
73
+ };
74
+
75
+ // src/client/AskAI.tsx
76
+ var import_react = require("react");
77
+
78
+ // src/client/text.ts
79
+ function uiLang(locale) {
80
+ return (locale ?? "").toLowerCase().startsWith("zh") ? "zh" : "en";
81
+ }
82
+ var zh = {
83
+ title: "\u5C0F\u79D8\u4E66",
84
+ sync: "\u540C\u6B65",
85
+ syncing: "\u540C\u6B65\u4E2D\u2026",
86
+ loading: "\u6B63\u5728\u8BFB\u53D6\u2026",
87
+ handle: "\u8981\u4F60\u5904\u7406",
88
+ remember: "\u6211\u8BB0\u7740",
89
+ done: "\u66FF\u4F60\u529E\u4E86",
90
+ metricHandle: "\u8981\u4F60\u5904\u7406",
91
+ metricOverdue: "\u8FC7\u671F",
92
+ metricSoon: "7 \u5929\u5185\u5230\u671F",
93
+ metricClosed: "\u4ECA\u5929\u66FF\u4F60\u5173\u6389",
94
+ metricShadow: "\u5F85\u4F60\u6838\u5BF9",
95
+ shadowTag: "\u5F71\u5B50",
96
+ open: "\u6253\u5F00",
97
+ markDone: "\u529E\u5B8C\u4E86",
98
+ snooze: "\u660E\u5929\u518D\u8BF4",
99
+ dismiss: "\u5FFD\u7565",
100
+ unsnooze: "\u73B0\u5728\u5904\u7406",
101
+ reopen: "\u6062\u590D",
102
+ stop: "\u4E0D\u518D\u63D0\u9192",
103
+ emptyHandle: "\u6CA1\u6709\u8981\u4F60\u5904\u7406\u7684\u4E8B\u3002",
104
+ emptyRemember: "\u8FD8\u6CA1\u6709\u8981\u8BB0\u7740\u7684\u4E8B\u3002",
105
+ emptyDone: "\u6700\u8FD1 7 \u5929\u6CA1\u6709\u66FF\u4F60\u5173\u6389\u4EC0\u4E48\u3002",
106
+ doneHint: '\u5224\u9519\u4E86\u5C31\u70B9"\u6062\u590D"\uFF0C\u8FD9\u6761\u89C4\u5219\u4F1A\u8BB0\u4E0B\u8FD9\u6B21\u7EA0\u6B63\u3002',
107
+ shadow: (n) => `\u5F71\u5B50\u6A21\u5F0F\uFF1A\u5DF2\u5224\u5B9A\u7ED3\u675F\u7684 ${n} \u6761 GitHub \u901A\u77E5\uFF0C\u6253\u5F00\u81EA\u52A8\u6807\u5DF2\u8BFB\u540E\u4F1A\u88AB\u6807\u6210\u5DF2\u8BFB\u3002\u73B0\u5728\u4E00\u6761\u4E5F\u6CA1\u6807\u3002`,
108
+ dropDone: "\u653E\u5230\u8FD9\u91CC = \u529E\u5B8C\u4E86",
109
+ dropRemember: "\u653E\u5230\u8FD9\u91CC = \u660E\u5929\u518D\u63D0\u9192",
110
+ add: "\u4EA4\u4EE3\u4E00\u4EF6\u4E8B",
111
+ addTitle: "\u4E8B\u9879",
112
+ addTitlePlaceholder: "\u4EA4\u623F\u79DF",
113
+ addDue: "\u65E5\u671F",
114
+ addRepeat: "\u91CD\u590D",
115
+ addCategory: "\u7C7B\u522B",
116
+ addNote: "\u5907\u6CE8",
117
+ repeats: { none: "\u4E0D\u91CD\u590D", weekly: "\u6BCF\u5468", monthly: "\u6BCF\u6708", yearly: "\u6BCF\u5E74" },
118
+ categories: { other: "\u5176\u4ED6", bill: "\u8D26\u5355", document: "\u8BC1\u4EF6", birthday: "\u751F\u65E5\u7EAA\u5FF5\u65E5", renewal: "\u7EED\u8D39\u7EED\u4FDD" },
119
+ save: "\u8BB0\u4E0B",
120
+ cancel: "\u53D6\u6D88",
121
+ previewHint: "\u586B\u597D\u4E8B\u9879\u548C\u65E5\u671F\u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u5C0F\u79D8\u4E66\u7406\u89E3\u7684\u5185\u5BB9\u3002",
122
+ chatHint: '\u4E5F\u53EF\u4EE5\u76F4\u63A5\u5728\u5BF9\u8BDD\u91CC\u8BF4\uFF0C\u6BD4\u5982"\u62A4\u7167 2027 \u5E74 3 \u6708 10 \u65E5\u5230\u671F"\u3002',
123
+ failed: "\u64CD\u4F5C\u6CA1\u6210\u529F\uFF1A",
124
+ what: "\u662F\u4EC0\u4E48",
125
+ why: "\u95EE\u9898\u5728\u54EA",
126
+ whyDone: "\u4E3A\u4EC0\u4E48\u5173\u6389",
127
+ whyKeep: "\u60C5\u51B5",
128
+ fix: "\u600E\u4E48\u529E",
129
+ did: "\u5C0F\u79D8\u4E66\u505A\u4E86\u4EC0\u4E48",
130
+ messages: (n) => `\u6765\u81EA\u8FD9 ${n} \u6761\u901A\u77E5`,
131
+ explainDone: "\u600E\u4E48\u56DE\u4E8B",
132
+ detail: "\u8BE6\u60C5",
133
+ hide: "\u6536\u8D77",
134
+ resize: "\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6\uFF0C\u53CC\u51FB\u6062\u590D\u7B49\u5BBD",
135
+ tabBoard: "\u770B\u677F",
136
+ tabSettings: "\u8BBE\u7F6E",
137
+ all: "\u5168\u90E8",
138
+ sourceGithub: "GitHub",
139
+ sourceMail: "\u90AE\u4EF6",
140
+ sourceManual: "\u4EA4\u4EE3",
141
+ sGeneral: "\u901A\u7528",
142
+ sLanguage: "\u8BED\u8A00",
143
+ sLanguageAuto: "\u8DDF\u968F\u7CFB\u7EDF",
144
+ sLead: "\u63D0\u524D\u591A\u5C11\u5929\u63D0\u9192\uFF08\u6309\u7C7B\u522B\uFF09",
145
+ sSave: "\u4FDD\u5B58",
146
+ sSaved: "\u5DF2\u4FDD\u5B58",
147
+ sGithub: "GitHub",
148
+ sGithubOn: "\u76EF\u7740 GitHub \u901A\u77E5",
149
+ sToken: "Token",
150
+ sTokenEnv: (name) => `\u4ECE\u73AF\u5883\u53D8\u91CF ${name} \u8BFB\u53D6`,
151
+ sTokenGh: "\u7528 GitHub CLI\uFF08gh\uFF09\u767B\u5F55\u7684\u8D26\u53F7\uFF0Ctoken \u5728\u7CFB\u7EDF\u94A5\u5319\u4E32\u91CC",
152
+ sTokenKeychain: "\u4F60\u5728\u8FD9\u91CC\u586B\u7684 token\uFF0C\u5B58\u5728\u7CFB\u7EDF\u94A5\u5319\u4E32\u91CC",
153
+ sTokenPaste: "\u586B\u4E00\u4E2A GitHub token",
154
+ sTokenHow: "\u7528 classic token\uFF0C\u52FE\u9009 notifications\uFF1B\u8981\u770B\u79C1\u6709\u4ED3\u5E93\u518D\u52FE repo\u3002GitHub \u7684\u901A\u77E5\u63A5\u53E3\u4E0D\u8BA4 fine-grained token\u3002token \u53EA\u5B58\u8FDB\u7CFB\u7EDF\u94A5\u5319\u4E32\uFF0C\u4E0D\u5199\u8FDB\u4EFB\u4F55\u6587\u4EF6\u3002",
155
+ sTokenNew: "\u53BB GitHub \u751F\u6210\uFF08\u6743\u9650\u5DF2\u52FE\u597D\uFF09",
156
+ sTokenSave: "\u68C0\u67E5\u5E76\u4FDD\u5B58",
157
+ sTokenSaved: (login) => `\u4FDD\u5B58\u597D\u4E86\uFF0C\u8D26\u53F7 ${login}`,
158
+ sTokenReplace: "\u6362\u4E00\u4E2A token",
159
+ sTokenRemove: "\u79FB\u9664 token",
160
+ sTokenRemoveConfirm: "\u4ECE\u94A5\u5319\u4E32\u91CC\u79FB\u9664\u8FD9\u4E2A token\uFF1F",
161
+ sTokenNoKeychain: (env, why) => `\u8FD9\u53F0\u7535\u8111\u6CA1\u6709\u53EF\u7528\u7684\u7CFB\u7EDF\u94A5\u5319\u4E32\uFF08${why}\uFF09\uFF0Ctoken \u6CA1\u6CD5\u4FDD\u5B58\u3002\u53EF\u4EE5\u5728\u542F\u52A8 DSH \u7684\u73AF\u5883\u91CC\u8BBE\u7F6E ${env}\uFF0C\u518D\u91CD\u542F DSH\u3002`,
162
+ sTest: "\u6D4B\u8BD5\u8FDE\u63A5",
163
+ sTesting: "\u6B63\u5728\u6D4B\u8BD5\u2026",
164
+ sGithubOk: (login) => `\u8FDE\u4E0A\u4E86\uFF0C\u8D26\u53F7 ${login}`,
165
+ sMarkRead: "\u5728 GitHub \u4E0A\u6807\u5DF2\u8BFB",
166
+ sMarkOff: "\u5173\u95ED\uFF1A\u5B8C\u5168\u4E0D\u78B0 GitHub \u4E0A\u7684\u5DF2\u8BFB\u72B6\u6001",
167
+ sMarkShadow: "\u5F71\u5B50\u6A21\u5F0F\uFF1A\u53EA\u8BB0\u4E0B\u4F1A\u6807\u54EA\u4E9B\uFF0C\u4E0D\u771F\u6807\uFF08\u63A8\u8350\u5148\u7528\uFF09",
168
+ sMarkOn: "\u6253\u5F00\uFF1A\u628A\u5224\u5B9A\u7ED3\u675F\u7684\u901A\u77E5\u5728 GitHub \u4E0A\u6807\u6210\u5DF2\u8BFB",
169
+ sMarkConfirm: '\u6253\u5F00\u540E\uFF0C\u5C0F\u79D8\u4E66\u4F1A\u5728 GitHub \u4E0A\u628A\u5224\u5B9A\u5DF2\u7ECF\u7ED3\u675F\u7684\u901A\u77E5\u6807\u6210\u5DF2\u8BFB\uFF08\u8FD8\u5728"\u8981\u4F60\u5904\u7406"\u91CC\u7684\u6C38\u8FDC\u4E0D\u4F1A\u88AB\u6807\uFF09\u3002\u6807\u9519\u7684\u53EF\u4EE5\u5728 GitHub \u4E0A\u91CD\u65B0\u6807\u6210\u672A\u8BFB\u3002\u786E\u8BA4\u6253\u5F00\u5417\uFF1F',
170
+ sConfirm: "\u786E\u8BA4\u6253\u5F00",
171
+ sCancel: "\u53D6\u6D88",
172
+ sMail: "\u90AE\u7BB1",
173
+ sMailPrivacy: "\u53EA\u8BFB\uFF1A\u5C0F\u79D8\u4E66\u7528\u53EA\u8BFB\u65B9\u5F0F\u6253\u5F00\u6536\u4EF6\u7BB1\uFF0C\u53EA\u770B\u53D1\u4EF6\u4EBA\u3001\u6536\u4EF6\u4EBA\u3001\u6807\u9898\u548C\u51E0\u4E2A\u90AE\u4EF6\u5934\uFF0C\u4E0D\u8BFB\u6B63\u6587\uFF0C\u4E5F\u4E0D\u4F1A\u628A\u90AE\u4EF6\u6807\u6210\u5DF2\u8BFB\u3002",
174
+ sSecretsAt: (kind) => `\u5BC6\u7801\u4FDD\u5B58\u5728\uFF1A${kind}\uFF08\u52A0\u5BC6\u4FDD\u5B58\uFF0C\u4E0D\u5199\u8FDB\u4EFB\u4F55\u6587\u4EF6\uFF09`,
175
+ sSecretsNone: (why) => `\u8FD9\u53F0\u7535\u8111\u4E0A\u6CA1\u6709\u53EF\u7528\u7684\u7CFB\u7EDF\u94A5\u5319\u4E32\uFF1A${why}\u3002\u5BC6\u7801\u4E0D\u4F1A\u88AB\u4FDD\u5B58\uFF1B\u8D26\u6237\u7167\u6837\u80FD\u4FDD\u5B58\uFF0C\u5BC6\u7801\u7528\u73AF\u5883\u53D8\u91CF\u63D0\u4F9B\uFF0C\u53D8\u91CF\u540D\u5199\u5728\u6BCF\u4E2A\u8D26\u6237\u4E0B\u9762\u3002`,
176
+ sPasswordTestOnly: "\u6CA1\u6709\u94A5\u5319\u4E32\uFF1A\u8FD9\u91CC\u586B\u7684\u53EA\u7528\u6765\u6D4B\u8BD5\u8FDE\u63A5\uFF0C\u4E0D\u4F1A\u4FDD\u5B58",
177
+ secretKinds: { macos: "macOS \u94A5\u5319\u4E32", windows: "Windows \u51ED\u636E\u7BA1\u7406\u5668", linux: "Linux \u5BC6\u94A5\u73AF\uFF08Secret Service\uFF09", memory: "\u5185\u5B58\uFF08\u6D4B\u8BD5\u7528\uFF09" },
178
+ sNoAccounts: "\u8FD8\u6CA1\u6709\u6DFB\u52A0\u90AE\u7BB1\u3002",
179
+ sAddAccount: "+ \u6DFB\u52A0\u90AE\u7BB1",
180
+ sEdit: "\u7F16\u8F91",
181
+ sDelete: "\u5220\u9664",
182
+ sDeleteConfirm: "\u5220\u9664\u8FD9\u4E2A\u90AE\u7BB1\u8D26\u6237\uFF1F\u5B83\u7684\u5BC6\u7801\u4F1A\u4ECE\u94A5\u5319\u4E32\u91CC\u5220\u6389\uFF0C\u8FD8\u6CA1\u5904\u7406\u7684\u90AE\u4EF6\u4E8B\u9879\u4F1A\u88AB\u5173\u6389\u3002",
183
+ sCheckNow: "\u73B0\u5728\u6536\u4E00\u6B21",
184
+ sProvider: "\u90AE\u7BB1\u670D\u52A1\u5546",
185
+ sAddress: "\u90AE\u7BB1\u5730\u5740",
186
+ sLabel: "\u540D\u79F0\uFF08\u53EF\u9009\uFF09",
187
+ sUser: "\u7528\u6237\u540D\uFF08\u4E00\u822C\u5C31\u662F\u90AE\u7BB1\u5730\u5740\uFF09",
188
+ sPassword: "\u5BC6\u7801 / \u6388\u6743\u7801",
189
+ sPasswordKeep: "\u5DF2\u4FDD\u5B58\uFF1B\u4E0D\u6539\u5C31\u7559\u7A7A",
190
+ sHost: "IMAP \u670D\u52A1\u5668",
191
+ sPort: "\u7AEF\u53E3",
192
+ sSecure: "SSL/TLS",
193
+ sSince: "\u53EA\u770B\u6700\u8FD1\u51E0\u5929\u7684\u672A\u8BFB\u90AE\u4EF6",
194
+ sEnabled: "\u542F\u7528",
195
+ sMailOk: (n) => `\u8FDE\u4E0A\u4E86\uFF0C\u6700\u8FD1\u6709 ${n} \u5C01\u672A\u8BFB\u90AE\u4EF6`,
196
+ sEnvHint: (name) => `\u6CA1\u6709\u627E\u5230\u5BC6\u7801\u3002\u70B9\u300C\u7F16\u8F91\u300D\u91CD\u65B0\u586B\u4E00\u6B21\uFF1B\u8FD9\u53F0\u7535\u8111\u6CA1\u6709\u94A5\u5319\u4E32\u7684\u8BDD\uFF0C\u5728\u542F\u52A8 DSH \u7684\u73AF\u5883\u91CC\u8BBE\u7F6E ${name}=\u6388\u6743\u7801\uFF0C\u518D\u91CD\u542F DSH\u3002`,
197
+ sNeverChecked: "\u8FD8\u6CA1\u6536\u8FC7",
198
+ sFeishu: "\u98DE\u4E66",
199
+ sComing: "\u5373\u5C06\u63A5\u5165",
200
+ ai: "+AI",
201
+ aiTitle: "\u5728\u5BF9\u8BDD\u91CC\u95EE AI\uFF1A\u628A\u8FD9\u4EF6\u4E8B\u653E\u8FDB\u4E00\u4E2A\u65B0\u5BF9\u8BDD\u7684\u8F93\u5165\u6846\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\uFF0C\u4F60\u770B\u8FC7\u518D\u6309\u53D1\u9001",
202
+ aiOpened: "\u5DF2\u653E\u8FDB\u65B0\u5BF9\u8BDD\u7684\u8F93\u5165\u6846\uFF0C\u770B\u8FC7\u540E\u6309\u53D1\u9001\u5C31\u884C",
203
+ aiCopied: "\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF0C\u7C98\u8D34\u5230\u5BF9\u8BDD\u91CC\u5C31\u80FD\u95EE",
204
+ aiFailed: "\u6CA1\u80FD\u6253\u5F00\u5BF9\u8BDD\uFF1A"
205
+ };
206
+ var en = {
207
+ title: "Secretary",
208
+ sync: "Sync",
209
+ syncing: "Syncing\u2026",
210
+ loading: "Loading\u2026",
211
+ handle: "To handle",
212
+ remember: "Keeping for you",
213
+ done: "Done for you",
214
+ metricHandle: "To handle",
215
+ metricOverdue: "overdue",
216
+ metricSoon: "Due in 7 days",
217
+ metricClosed: "Closed today",
218
+ metricShadow: "To review",
219
+ shadowTag: "shadow",
220
+ open: "Open",
221
+ markDone: "Done",
222
+ snooze: "Tomorrow",
223
+ dismiss: "Dismiss",
224
+ unsnooze: "Handle now",
225
+ reopen: "Reopen",
226
+ stop: "Stop",
227
+ emptyHandle: "Nothing needs you right now.",
228
+ emptyRemember: "Nothing to keep yet.",
229
+ emptyDone: "Nothing closed in the last 7 days.",
230
+ doneHint: "If one is wrong, reopen it; the rule records the correction.",
231
+ shadow: (n) => `Shadow mode: ${n} resolved GitHub notifications would be marked read once you turn it on. None has been.`,
232
+ dropDone: "Drop here to mark done",
233
+ dropRemember: "Drop here to snooze until tomorrow",
234
+ add: "Tell me something",
235
+ addTitle: "What",
236
+ addTitlePlaceholder: "Pay rent",
237
+ addDue: "Date",
238
+ addRepeat: "Repeat",
239
+ addCategory: "Category",
240
+ addNote: "Note",
241
+ repeats: { none: "Once", weekly: "Weekly", monthly: "Monthly", yearly: "Yearly" },
242
+ categories: { other: "Other", bill: "Bill", document: "Document", birthday: "Birthday", renewal: "Renewal" },
243
+ save: "Save",
244
+ cancel: "Cancel",
245
+ previewHint: "Fill in what and when to see what the secretary understood.",
246
+ chatHint: 'You can also say it in the chat, e.g. "my passport expires on 2027-03-10".',
247
+ failed: "That did not work: ",
248
+ what: "What",
249
+ why: "The problem",
250
+ whyDone: "Why it was closed",
251
+ whyKeep: "Status",
252
+ fix: "What to do",
253
+ did: "What the secretary did",
254
+ messages: (n) => `From these ${n} notifications`,
255
+ explainDone: "What happened",
256
+ detail: "Details",
257
+ hide: "Hide",
258
+ resize: "Drag to resize; double-click to make them equal",
259
+ tabBoard: "Board",
260
+ tabSettings: "Settings",
261
+ all: "All",
262
+ sourceGithub: "GitHub",
263
+ sourceMail: "Mail",
264
+ sourceManual: "Noted",
265
+ sGeneral: "General",
266
+ sLanguage: "Language",
267
+ sLanguageAuto: "Follow the system",
268
+ sLead: "Days of warning, by category",
269
+ sSave: "Save",
270
+ sSaved: "Saved",
271
+ sGithub: "GitHub",
272
+ sGithubOn: "Watch GitHub notifications",
273
+ sToken: "Token",
274
+ sTokenEnv: (name) => `Read from the environment variable ${name}`,
275
+ sTokenGh: "The account the GitHub CLI (gh) is signed in to; the token stays in the system keychain",
276
+ sTokenKeychain: "The token you pasted here, kept in the system keychain",
277
+ sTokenPaste: "Paste a GitHub token",
278
+ sTokenHow: "Use a classic token with the notifications scope, plus repo for private repositories. GitHub's notifications API does not take fine-grained tokens. The token goes to the system keychain only, never to a file.",
279
+ sTokenNew: "Create one on GitHub (scopes pre-ticked)",
280
+ sTokenSave: "Check and save",
281
+ sTokenSaved: (login) => `Saved; signed in as ${login}`,
282
+ sTokenReplace: "Use another token",
283
+ sTokenRemove: "Remove token",
284
+ sTokenRemoveConfirm: "Remove this token from the keychain?",
285
+ sTokenNoKeychain: (env, why) => `No usable system keychain on this computer (${why}), so the token cannot be saved. Set ${env} in the environment DSH starts from, then restart DSH.`,
286
+ sTest: "Test connection",
287
+ sTesting: "Testing\u2026",
288
+ sGithubOk: (login) => `Connected as ${login}`,
289
+ sMarkRead: "Mark read on GitHub",
290
+ sMarkOff: "Off: never touch read state on GitHub",
291
+ sMarkShadow: "Shadow: only record what would be marked (start here)",
292
+ sMarkOn: "On: mark resolved notifications read on GitHub",
293
+ sMarkConfirm: 'Once on, the secretary marks notifications it judged resolved as read on GitHub (anything still under "To handle" is never marked). You can mark them unread again on GitHub. Turn it on?',
294
+ sConfirm: "Turn on",
295
+ sCancel: "Cancel",
296
+ sMail: "Mail",
297
+ sMailPrivacy: "Read-only: the secretary opens your inbox read-only and looks at sender, recipients, subject and a few headers only. It never reads bodies and never marks mail read.",
298
+ sSecretsAt: (kind) => `Passwords are kept in: ${kind} (encrypted, never written to a file)`,
299
+ sSecretsNone: (why) => `No usable system keychain on this computer: ${why}. Passwords are not saved; you can still save accounts and give each password through the environment variable shown under it.`,
300
+ sPasswordTestOnly: "No keychain: used only to test the connection, not saved",
301
+ secretKinds: { macos: "the macOS Keychain", windows: "Windows Credential Manager", linux: "the Linux keyring (Secret Service)", memory: "memory (tests)" },
302
+ sNoAccounts: "No mail account yet.",
303
+ sAddAccount: "+ Add a mail account",
304
+ sEdit: "Edit",
305
+ sDelete: "Delete",
306
+ sDeleteConfirm: "Delete this mail account? Its password is removed from the keychain and its open mail items are closed.",
307
+ sCheckNow: "Check now",
308
+ sProvider: "Provider",
309
+ sAddress: "Email address",
310
+ sLabel: "Name (optional)",
311
+ sUser: "User name (usually the address)",
312
+ sPassword: "Password / app password",
313
+ sPasswordKeep: "Saved; leave empty to keep it",
314
+ sHost: "IMAP server",
315
+ sPort: "Port",
316
+ sSecure: "SSL/TLS",
317
+ sSince: "Only look at unread mail from the last \u2026 days",
318
+ sEnabled: "Enabled",
319
+ sMailOk: (n) => `Connected; ${n} unread messages recently`,
320
+ sEnvHint: (name) => `No password found. Click Edit and enter it again; if this computer has no keychain, set ${name}=<app password> in the environment DSH starts from, then restart DSH.`,
321
+ sNeverChecked: "Not checked yet",
322
+ sFeishu: "Feishu / Lark",
323
+ sComing: "Coming soon",
324
+ ai: "+AI",
325
+ aiTitle: "Ask AI in a chat: puts this into a new chat's input box, unsent; read it, then press send",
326
+ aiOpened: "Put into a new chat's input box; read it and press send",
327
+ aiCopied: "Copied; paste it into a chat to ask",
328
+ aiFailed: "Could not open a chat: "
329
+ };
330
+ var TEXT = { zh, en };
331
+
332
+ // src/client/AskAI.tsx
333
+ var import_jsx_runtime = require("react/jsx-runtime");
334
+ async function copy(text) {
335
+ try {
336
+ await navigator.clipboard.writeText(text);
337
+ return true;
338
+ } catch {
339
+ return false;
340
+ }
341
+ }
342
+ function AskAI({ topic, lang, locale, openChat: openChat2, compact = false }) {
343
+ const t = TEXT[lang];
344
+ const [note, setNote] = (0, import_react.useState)();
345
+ const [busy, setBusy] = (0, import_react.useState)(false);
346
+ const ask = async () => {
347
+ setBusy(true);
348
+ const result = await mishuApi.ask(locale(), topic);
349
+ setBusy(false);
350
+ if (!result.ok) {
351
+ setNote({ ok: false, text: `${t.aiFailed}${result.message}` });
352
+ return;
353
+ }
354
+ if (openChat2(result.prompt)) {
355
+ setNote({ ok: true, text: t.aiOpened });
356
+ } else {
357
+ setNote(await copy(result.prompt) ? { ok: true, text: t.aiCopied } : { ok: false, text: `${t.aiFailed}clipboard` });
358
+ }
359
+ setTimeout(() => setNote(void 0), 6e3);
360
+ };
361
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "mishu-ai-wrap", children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
+ "button",
364
+ {
365
+ type: "button",
366
+ className: `mishu-ai ${compact ? "compact" : ""}`,
367
+ title: t.aiTitle,
368
+ "aria-label": t.aiTitle,
369
+ disabled: busy,
370
+ onClick: (event) => {
371
+ event.stopPropagation();
372
+ void ask();
373
+ },
374
+ children: t.ai
375
+ }
376
+ ),
377
+ note === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `mishu-ai-note ${note.ok ? "" : "mishu-danger"}`, role: "status", children: note.text })
378
+ ] });
379
+ }
380
+
381
+ // src/client/Settings.tsx
382
+ var import_react2 = require("react");
383
+ var import_jsx_runtime2 = require("react/jsx-runtime");
384
+ var CATEGORIES = ["document", "bill", "birthday", "renewal", "other"];
385
+ function MishuSettings({ lang, locale, openChat: openChat2 }) {
386
+ const t = TEXT[lang];
387
+ const [view, setView] = (0, import_react2.useState)();
388
+ const [error, setError] = (0, import_react2.useState)();
389
+ const [note, setNote] = (0, import_react2.useState)();
390
+ const [lead, setLead] = (0, import_react2.useState)({});
391
+ const [githubTest, setGithubTest] = (0, import_react2.useState)();
392
+ const [confirmOn, setConfirmOn] = (0, import_react2.useState)(false);
393
+ const [pasting, setPasting] = (0, import_react2.useState)(false);
394
+ const [editing, setEditing] = (0, import_react2.useState)();
395
+ const take = (result, saved) => {
396
+ if (result.ok) {
397
+ setView(result.view);
398
+ setLead(result.view.settings.leadDays);
399
+ setError(void 0);
400
+ setNote(saved);
401
+ } else {
402
+ setError(result.message);
403
+ }
404
+ };
405
+ (0, import_react2.useEffect)(() => {
406
+ void settingsApi.load(locale()).then((r) => take(r));
407
+ }, [locale]);
408
+ if (view === void 0) {
409
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-settings", children: error === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-empty", children: t.loading }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-error", children: [
410
+ t.failed,
411
+ error
412
+ ] }) });
413
+ }
414
+ const save = async (settings) => take(await settingsApi.save(locale(), settings), t.sSaved);
415
+ const token = view.github.token;
416
+ const secretKind = t.secretKinds[view.secrets.kind] ?? view.secrets.kind;
417
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-settings", children: [
418
+ error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-error", children: [
419
+ t.failed,
420
+ error
421
+ ] }),
422
+ note === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-ok", children: note }),
423
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "mishu-panel", children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t.sGeneral }),
425
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
426
+ t.sLanguage,
427
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { value: view.settings.language, onChange: (e) => {
428
+ void save({ language: e.target.value });
429
+ }, children: [
430
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "auto", children: t.sLanguageAuto }),
431
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "zh", children: "\u4E2D\u6587" }),
432
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "en", children: "English" })
433
+ ] })
434
+ ] }),
435
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-field", children: t.sLead }),
436
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-grid5", children: CATEGORIES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
437
+ t.categories[c],
438
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "number", min: 0, max: 366, value: lead[c] ?? 0, onChange: (e) => setLead({ ...lead, [c]: Number(e.target.value) }) })
439
+ ] }, c)) }),
440
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => {
441
+ void save({ leadDays: lead });
442
+ }, children: t.sSave })
443
+ ] }),
444
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "mishu-panel", children: [
445
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t.sGithub }),
446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-check", children: [
447
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: view.settings.githubEnabled, onChange: (e) => {
448
+ void save({ githubEnabled: e.target.checked });
449
+ } }),
450
+ t.sGithubOn
451
+ ] }),
452
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-row-explain", children: [
453
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mishu-row-label", children: t.sToken }),
454
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: token.found ? "" : "mishu-danger", children: token.found ? token.from === "env" ? t.sTokenEnv(view.github.tokenEnv) : token.from === "keychain" ? t.sTokenKeychain : t.sTokenGh : token.text })
455
+ ] }),
456
+ token.found ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-actions", children: [
457
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => {
458
+ setGithubTest(t.sTesting);
459
+ void settingsApi.testGithub(locale()).then((r) => setGithubTest(r.ok ? t.sGithubOk(r.login) : `${t.failed}${r.message}`));
460
+ }, children: t.sTest }),
461
+ token.from === "env" || pasting ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => setPasting(true), children: t.sTokenReplace }),
462
+ token.from === "keychain" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => {
463
+ if (window.confirm(t.sTokenRemoveConfirm)) void settingsApi.deleteToken(locale()).then((r) => {
464
+ setGithubTest(void 0);
465
+ take(r);
466
+ });
467
+ }, children: t.sTokenRemove }) : null,
468
+ githubTest === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mishu-hint", children: githubTest })
469
+ ] }) : null,
470
+ !token.found || pasting ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TokenForm, { view, lang, locale, onSaved: (next, login) => {
471
+ setPasting(false);
472
+ setGithubTest(t.sTokenSaved(login));
473
+ take({ ok: true, view: next });
474
+ }, onCancel: token.found ? () => setPasting(false) : void 0 }) : null,
475
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
476
+ t.sMarkRead,
477
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { value: view.settings.markRead, onChange: (e) => {
478
+ const value = e.target.value;
479
+ if (value === "on") setConfirmOn(true);
480
+ else void save({ markRead: value });
481
+ }, children: [
482
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "off", children: t.sMarkOff }),
483
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "shadow", children: t.sMarkShadow }),
484
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "on", children: t.sMarkOn })
485
+ ] })
486
+ ] }),
487
+ confirmOn ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-banner", children: [
488
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: t.sMarkConfirm }),
489
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-actions", children: [
490
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => {
491
+ setConfirmOn(false);
492
+ void save({ markRead: "on" });
493
+ }, children: t.sConfirm }),
494
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => setConfirmOn(false), children: t.sCancel })
495
+ ] })
496
+ ] }) : null
497
+ ] }),
498
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "mishu-panel", children: [
499
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t.sMail }),
500
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-hint", children: t.sMailPrivacy }),
501
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: view.secrets.available ? "mishu-hint" : "mishu-hint mishu-warn", children: view.secrets.available ? t.sSecretsAt(secretKind) : t.sSecretsNone(view.secrets.why ?? secretKind) }),
502
+ view.accounts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-empty", children: t.sNoAccounts }) : view.accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
503
+ AccountRow,
504
+ {
505
+ account,
506
+ lang,
507
+ locale,
508
+ openChat: openChat2,
509
+ onEdit: () => setEditing({ ...account }),
510
+ onView: (next) => take(next)
511
+ },
512
+ account.id
513
+ )),
514
+ editing === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn mishu-add-toggle", onClick: () => setEditing({ preset: "qq", sinceDays: 14, enabled: true }), children: t.sAddAccount }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AccountForm, { draft: editing, view, lang, locale, openChat: openChat2, onDone: (next) => {
515
+ setEditing(void 0);
516
+ if (next !== void 0) take({ ok: true, view: next }, t.sSaved);
517
+ } })
518
+ ] }),
519
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "mishu-panel", children: [
520
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t.sFeishu }),
521
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-hint", children: t.sComing })
522
+ ] })
523
+ ] });
524
+ }
525
+ function TokenForm({ view, lang, locale, onSaved, onCancel }) {
526
+ const t = TEXT[lang];
527
+ const [token, setToken] = (0, import_react2.useState)("");
528
+ const [busy, setBusy] = (0, import_react2.useState)(false);
529
+ const [message, setMessage] = (0, import_react2.useState)();
530
+ if (!view.secrets.available) {
531
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-hint mishu-warn", children: t.sTokenNoKeychain(view.github.tokenEnv, view.secrets.why ?? "") });
532
+ }
533
+ const save = async () => {
534
+ setBusy(true);
535
+ setMessage(void 0);
536
+ const r = await settingsApi.saveToken(locale(), token);
537
+ setBusy(false);
538
+ if (r.ok) {
539
+ setToken("");
540
+ onSaved(r.view, r.login);
541
+ } else {
542
+ setMessage(r.message);
543
+ }
544
+ };
545
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-add", children: [
546
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
547
+ t.sTokenPaste,
548
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "password", value: token, autoComplete: "off", spellCheck: false, placeholder: "ghp_\u2026", onChange: (e) => {
549
+ setToken(e.target.value);
550
+ setMessage(void 0);
551
+ } })
552
+ ] }),
553
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-hint", children: t.sTokenHow }),
554
+ message === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-preview mishu-danger", children: message }),
555
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-actions", children: [
556
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => window.open(view.github.newTokenUrl, "_blank", "noopener"), children: t.sTokenNew }),
557
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: busy || token.trim() === "", onClick: () => {
558
+ void save();
559
+ }, children: busy ? t.sTesting : t.sTokenSave }),
560
+ onCancel === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: onCancel, children: t.sCancel })
561
+ ] })
562
+ ] });
563
+ }
564
+ function AccountRow({ account, lang, locale, openChat: openChat2, onEdit, onView }) {
565
+ const t = TEXT[lang];
566
+ const [busy, setBusy] = (0, import_react2.useState)(false);
567
+ const report = account.report;
568
+ const status = report === null ? t.sNeverChecked : report.error !== void 0 ? report.error[lang] : lang === "zh" ? `${new Date(report.at).toLocaleString()} \u6536\u4FE1\uFF0C${report.messages} \u5C01\u672A\u8BFB` : `checked ${new Date(report.at).toLocaleString()}, ${report.messages} unread`;
569
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-card", children: [
570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-card-title", children: [
571
+ account.label,
572
+ account.enabled ? "" : ` (${lang === "zh" ? "\u5DF2\u505C\u7528" : "disabled"})`
573
+ ] }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-card-meta", children: [
575
+ account.address,
576
+ " \xB7 ",
577
+ account.host,
578
+ ":",
579
+ account.port
580
+ ] }),
581
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `mishu-card-note ${report?.error === void 0 ? "" : "mishu-danger"}`, children: [
582
+ status,
583
+ report?.error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AskAI, { topic: { kind: "mail-error", accountId: account.id }, lang, locale, openChat: openChat2, compact: true })
584
+ ] }),
585
+ account.hasPassword ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-card-note mishu-warn", children: t.sEnvHint(account.envName) }),
586
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-actions", children: [
587
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", disabled: busy, onClick: () => {
588
+ setBusy(true);
589
+ void settingsApi.syncMail(locale(), account.id).then((r) => {
590
+ setBusy(false);
591
+ onView(r);
592
+ });
593
+ }, children: busy ? t.sTesting : t.sCheckNow }),
594
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: onEdit, children: t.sEdit }),
595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => {
596
+ if (window.confirm(t.sDeleteConfirm)) void settingsApi.deleteMail(locale(), account.id).then(onView);
597
+ }, children: t.sDelete })
598
+ ] })
599
+ ] });
600
+ }
601
+ function AccountForm({ draft, view, lang, locale, openChat: openChat2, onDone }) {
602
+ const t = TEXT[lang];
603
+ const [account, setAccount] = (0, import_react2.useState)(draft);
604
+ const [password, setPassword] = (0, import_react2.useState)("");
605
+ const [message, setMessage] = (0, import_react2.useState)();
606
+ const [busy, setBusy] = (0, import_react2.useState)(false);
607
+ const preset = view.presets.find((p) => p.id === account.preset) ?? view.presets[view.presets.length - 1];
608
+ const custom = preset.id === "custom";
609
+ const existing = draft.id !== void 0;
610
+ const set = (patch) => {
611
+ setAccount({ ...account, ...patch });
612
+ setMessage(void 0);
613
+ };
614
+ const test = async () => {
615
+ setBusy(true);
616
+ setMessage({ ok: true, text: t.sTesting });
617
+ const r = await settingsApi.testMail(locale(), account, password);
618
+ setBusy(false);
619
+ setMessage(r.ok ? { ok: true, text: t.sMailOk(r.unread) } : { ok: false, text: r.message });
620
+ };
621
+ const save = async () => {
622
+ setBusy(true);
623
+ const r = await settingsApi.saveMail(locale(), account, password);
624
+ setBusy(false);
625
+ if (r.ok) {
626
+ setPassword("");
627
+ onDone(r.view);
628
+ } else {
629
+ setMessage({ ok: false, text: r.message });
630
+ }
631
+ };
632
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-add", children: [
633
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
634
+ t.sProvider,
635
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { value: account.preset, onChange: (e) => set({ preset: e.target.value }), children: view.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: p.id, children: p.label }, p.id)) })
636
+ ] }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: preset.supported ? "mishu-hint" : "mishu-hint mishu-danger", children: [
638
+ preset.howTo,
639
+ preset.supported ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AskAI, { topic: { kind: "mail-setup", preset: preset.id }, lang, locale, openChat: openChat2, compact: true }) : null
640
+ ] }),
641
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
642
+ t.sAddress,
643
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "email", value: account.address ?? "", autoComplete: "off", onChange: (e) => set({ address: e.target.value }) })
644
+ ] }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-row", children: [
646
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
647
+ t.sLabel,
648
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: account.label ?? "", onChange: (e) => set({ label: e.target.value }) })
649
+ ] }),
650
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
651
+ t.sUser,
652
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: account.user ?? "", placeholder: account.address ?? "", autoComplete: "off", onChange: (e) => set({ user: e.target.value }) })
653
+ ] })
654
+ ] }),
655
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
656
+ t.sPassword,
657
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "password", value: password, autoComplete: "new-password", placeholder: existing && view.secrets.available ? t.sPasswordKeep : "", onChange: (e) => {
658
+ setPassword(e.target.value);
659
+ setMessage(void 0);
660
+ } })
661
+ ] }),
662
+ view.secrets.available ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mishu-hint mishu-warn", children: t.sPasswordTestOnly }),
663
+ custom ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-row", children: [
664
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
665
+ t.sHost,
666
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: account.host ?? "", onChange: (e) => set({ host: e.target.value }) })
667
+ ] }),
668
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
669
+ t.sPort,
670
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "number", value: account.port ?? 993, onChange: (e) => set({ port: Number(e.target.value) }) })
671
+ ] })
672
+ ] }) : null,
673
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-row", children: [
674
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-field", children: [
675
+ t.sSince,
676
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "number", min: 1, max: 90, value: account.sinceDays ?? 14, onChange: (e) => set({ sinceDays: Number(e.target.value) }) })
677
+ ] }),
678
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "mishu-check", children: [
679
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: account.enabled !== false, onChange: (e) => set({ enabled: e.target.checked }) }),
680
+ t.sEnabled
681
+ ] })
682
+ ] }),
683
+ message === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `mishu-preview ${message.ok ? "" : "mishu-danger"}`, children: [
684
+ message.text,
685
+ message.ok || !preset.supported ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AskAI, { topic: { kind: "mail-setup", preset: preset.id, error: message.text }, lang, locale, openChat: openChat2, compact: true })
686
+ ] }),
687
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mishu-actions", children: [
688
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", disabled: busy || !preset.supported, onClick: () => {
689
+ void test();
690
+ }, children: t.sTest }),
691
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: busy || !preset.supported, onClick: () => {
692
+ void save();
693
+ }, children: t.sSave }),
694
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => onDone(), children: t.sCancel })
695
+ ] })
696
+ ] });
697
+ }
698
+
699
+ // src/client/Board.tsx
700
+ var import_jsx_runtime3 = require("react/jsx-runtime");
701
+ var SOURCE_KEY = "dsh-mishu.source";
702
+ function loadSource() {
703
+ try {
704
+ const value = localStorage.getItem(SOURCE_KEY);
705
+ if (value === "github" || value === "mail" || value === "manual") return value;
706
+ } catch {
707
+ }
708
+ return "all";
709
+ }
710
+ var REFRESH_MS = 6e4;
711
+ var WIDTHS_KEY = "dsh-mishu.columns";
712
+ var EQUAL = [1, 1, 1];
713
+ var MIN_COLUMN_PX = 220;
714
+ function dropAction(card, from, to) {
715
+ if (card.target !== "matter" || from === to) return void 0;
716
+ if (to === "done") return "done";
717
+ if (to === "remember" && from === "handle") return "snooze";
718
+ if (to === "handle" && from === "remember") return "unsnooze";
719
+ return void 0;
720
+ }
721
+ function loadWidths() {
722
+ try {
723
+ const value = JSON.parse(localStorage.getItem(WIDTHS_KEY) ?? "null");
724
+ if (Array.isArray(value) && value.length === 3 && value.every((v2) => typeof v2 === "number" && v2 > 0)) return value;
725
+ } catch {
726
+ }
727
+ return EQUAL;
728
+ }
729
+ function saveWidths(widths) {
730
+ try {
731
+ localStorage.setItem(WIDTHS_KEY, JSON.stringify(widths));
732
+ } catch {
733
+ }
734
+ }
735
+ function MishuBoard({ locale, openChat: openChat2 }) {
736
+ const [board, setBoard] = (0, import_react3.useState)();
737
+ const [error, setError] = (0, import_react3.useState)();
738
+ const [busy, setBusy] = (0, import_react3.useState)(false);
739
+ const [syncing, setSyncing] = (0, import_react3.useState)(false);
740
+ const [dropOn, setDropOn] = (0, import_react3.useState)();
741
+ const [widths, setWidths] = (0, import_react3.useState)(loadWidths);
742
+ const [tab, setTab] = (0, import_react3.useState)("board");
743
+ const [source, setSourceState] = (0, import_react3.useState)(loadSource);
744
+ const setSource = (next) => {
745
+ setSourceState(next);
746
+ try {
747
+ localStorage.setItem(SOURCE_KEY, next);
748
+ } catch {
749
+ }
750
+ };
751
+ const dragged = (0, import_react3.useRef)(void 0);
752
+ const columnsRef = (0, import_react3.useRef)(null);
753
+ const lang = board?.lang ?? uiLang(locale());
754
+ const t = TEXT[lang];
755
+ const take = (0, import_react3.useCallback)((result) => {
756
+ if (result.ok) {
757
+ setBoard(result.board);
758
+ setError(void 0);
759
+ } else {
760
+ setError(result.message);
761
+ }
762
+ }, []);
763
+ const load = (0, import_react3.useCallback)(() => mishuApi.board(locale()).then(take), [locale, take]);
764
+ (0, import_react3.useEffect)(() => {
765
+ void load();
766
+ const timer = setInterval(() => {
767
+ void load();
768
+ }, REFRESH_MS);
769
+ const onFocus = () => {
770
+ void load();
771
+ };
772
+ window.addEventListener("focus", onFocus);
773
+ return () => {
774
+ clearInterval(timer);
775
+ window.removeEventListener("focus", onFocus);
776
+ };
777
+ }, [load]);
778
+ const act = async (card2, action) => {
779
+ if (action === "open") {
780
+ if (card2.url !== null) window.open(card2.url, "_blank", "noopener");
781
+ return;
782
+ }
783
+ setBusy(true);
784
+ take(await mishuApi.action(locale(), card2.target, card2.id, action));
785
+ setBusy(false);
786
+ };
787
+ const sync = async () => {
788
+ setSyncing(true);
789
+ take(await mishuApi.sync(locale()));
790
+ setSyncing(false);
791
+ };
792
+ const startResize = (index) => (event) => {
793
+ const container = columnsRef.current;
794
+ if (container === null) return;
795
+ event.preventDefault();
796
+ const handle = event.currentTarget;
797
+ handle.setPointerCapture(event.pointerId);
798
+ const startX = event.clientX;
799
+ const start = widths;
800
+ const total = start[0] + start[1] + start[2];
801
+ const usable = container.getBoundingClientRect().width - 2 * 10;
802
+ const minFr = MIN_COLUMN_PX / usable * total;
803
+ let latest = start;
804
+ const move = (e) => {
805
+ const delta = (e.clientX - startX) / usable * total;
806
+ const pair = start[index] + start[index + 1];
807
+ const left = Math.min(pair - minFr, Math.max(minFr, start[index] + delta));
808
+ const next = [...start];
809
+ next[index] = left;
810
+ next[index + 1] = pair - left;
811
+ latest = next;
812
+ setWidths(next);
813
+ };
814
+ const up = () => {
815
+ handle.removeEventListener("pointermove", move);
816
+ handle.removeEventListener("pointerup", up);
817
+ handle.removeEventListener("pointercancel", up);
818
+ saveWidths(latest);
819
+ };
820
+ handle.addEventListener("pointermove", move);
821
+ handle.addEventListener("pointerup", up);
822
+ handle.addEventListener("pointercancel", up);
823
+ };
824
+ const resetWidths = () => {
825
+ setWidths(EQUAL);
826
+ saveWidths(EQUAL);
827
+ };
828
+ const dropProps = (column) => ({
829
+ onDragOver: (event) => {
830
+ const drag = dragged.current;
831
+ if (drag === void 0 || dropAction(drag.card, drag.from, column) === void 0) return;
832
+ event.preventDefault();
833
+ setDropOn(column);
834
+ },
835
+ onDragLeave: () => setDropOn((current) => current === column ? void 0 : current),
836
+ onDrop: (event) => {
837
+ event.preventDefault();
838
+ setDropOn(void 0);
839
+ const drag = dragged.current;
840
+ dragged.current = void 0;
841
+ const action = drag === void 0 ? void 0 : dropAction(drag.card, drag.from, column);
842
+ if (drag !== void 0 && action !== void 0) void act(drag.card, action);
843
+ }
844
+ });
845
+ const label = {
846
+ open: t.open,
847
+ done: t.markDone,
848
+ snooze: t.snooze,
849
+ dismiss: t.dismiss,
850
+ unsnooze: t.unsnooze,
851
+ reopen: t.reopen,
852
+ stop: t.stop
853
+ };
854
+ const card = (item, column) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
855
+ Card,
856
+ {
857
+ item,
858
+ column,
859
+ lang,
860
+ locale,
861
+ busy,
862
+ label,
863
+ openChat: openChat2,
864
+ onAct: (action) => {
865
+ void act(item, action);
866
+ },
867
+ onDragStart: () => {
868
+ dragged.current = { card: item, from: column };
869
+ },
870
+ onDragEnd: () => {
871
+ dragged.current = void 0;
872
+ setDropOn(void 0);
873
+ }
874
+ },
875
+ `${item.target}-${item.id}`
876
+ );
877
+ if (board === void 0) {
878
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-page", children: [
879
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-head", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: t.title }) }),
880
+ error === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mishu-empty", children: t.loading }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-error", children: [
881
+ t.failed,
882
+ error
883
+ ] })
884
+ ] });
885
+ }
886
+ const { metrics } = board;
887
+ const keep = (card2) => source === "all" || card2.source === source;
888
+ const columns = {
889
+ handle: board.columns.handle.filter(keep),
890
+ remember: board.columns.remember.filter(keep),
891
+ done: (() => {
892
+ const groups = board.columns.done.groups.map((g) => ({ ...g, items: g.items.filter(keep) })).filter((g) => g.items.length > 0);
893
+ return { total: groups.reduce((n, g) => n + g.items.length, 0), groups };
894
+ })()
895
+ };
896
+ const everything = [...board.columns.handle, ...board.columns.remember, ...board.columns.done.groups.flatMap((g) => g.items)];
897
+ const count = (s) => everything.filter((c) => s === "all" || c.source === s).length;
898
+ const sources = [
899
+ { id: "all", label: t.all },
900
+ { id: "github", label: t.sourceGithub },
901
+ { id: "mail", label: t.sourceMail },
902
+ { id: "manual", label: t.sourceManual }
903
+ ];
904
+ const template = `minmax(0, ${widths[0]}fr) 10px minmax(0, ${widths[1]}fr) 10px minmax(0, ${widths[2]}fr)`;
905
+ const divider = (index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
906
+ "div",
907
+ {
908
+ className: "mishu-divider",
909
+ role: "separator",
910
+ "aria-orientation": "vertical",
911
+ title: t.resize,
912
+ onPointerDown: startResize(index),
913
+ onDoubleClick: resetWidths
914
+ }
915
+ );
916
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-page", "data-mishu-board": "", children: [
917
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-head", children: [
918
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-title", children: [
919
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: t.title }),
920
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-tabs", role: "tablist", children: [
921
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === "board", className: tab === "board" ? "active" : "", onClick: () => setTab("board"), children: t.tabBoard }),
922
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === "settings", className: tab === "settings" ? "active" : "", onClick: () => setTab("settings"), children: t.tabSettings })
923
+ ] })
924
+ ] }),
925
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-sources", children: [
926
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
927
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("i", { className: `mishu-dot ${board.sources.github.state}` }),
928
+ board.sources.github.text,
929
+ board.sources.github.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AskAI, { topic: { kind: "github-error" }, lang, locale, openChat: openChat2, compact: true }) : null
930
+ ] }),
931
+ board.sources.mail.map((m) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
932
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("i", { className: `mishu-dot ${m.state}` }),
933
+ m.text,
934
+ m.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AskAI, { topic: { kind: "mail-error", accountId: m.id }, lang, locale, openChat: openChat2, compact: true }) : null
935
+ ] }, m.id)),
936
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "mishu-btn", disabled: syncing, onClick: () => {
937
+ void sync();
938
+ }, children: syncing ? t.syncing : t.sync })
939
+ ] })
940
+ ] }),
941
+ tab === "settings" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MishuSettings, { lang, locale, openChat: openChat2 }) : null,
942
+ tab === "settings" ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
943
+ error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-error", children: [
944
+ t.failed,
945
+ error
946
+ ] }),
947
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "mishu-summary", children: [
948
+ board.summary,
949
+ " ",
950
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AskAI, { topic: { kind: "summary" }, lang, locale, openChat: openChat2, compact: true })
951
+ ] }),
952
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metrics", children: [
953
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric", children: [
954
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-label", children: t.metricHandle }),
955
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric-value", children: [
956
+ metrics.handle,
957
+ metrics.overdue > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("small", { className: "mishu-danger", children: [
958
+ metrics.overdue,
959
+ " ",
960
+ t.metricOverdue
961
+ ] }) : null
962
+ ] })
963
+ ] }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric", children: [
965
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-label", children: t.metricSoon }),
966
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-value", children: metrics.dueSoon })
967
+ ] }),
968
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric", children: [
969
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-label", children: t.metricClosed }),
970
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-value", children: metrics.closedToday })
971
+ ] }),
972
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric", children: [
973
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-metric-label", children: t.metricShadow }),
974
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-metric-value", children: [
975
+ metrics.shadow,
976
+ board.markRead === "shadow" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("small", { className: "mishu-warn", children: t.shadowTag }) : null
977
+ ] })
978
+ ] })
979
+ ] }),
980
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-filters", role: "group", children: sources.map((s) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", "aria-pressed": source === s.id, className: `mishu-chip ${source === s.id ? "active" : ""}`, onClick: () => setSource(s.id), children: [
981
+ s.label,
982
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: count(s.id) })
983
+ ] }, s.id)) }),
984
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-columns", ref: columnsRef, style: { ["--mishu-cols"]: template }, children: [
985
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: `mishu-col ${dropOn === "handle" ? "drop" : ""}`, ...dropProps("handle"), "aria-label": t.handle, children: [
986
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-col-head", children: [
987
+ t.handle,
988
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: columns.handle.length })
989
+ ] }),
990
+ columns.handle.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-empty", children: t.emptyHandle }) : columns.handle.map((item) => card(item, "handle"))
991
+ ] }),
992
+ divider(0),
993
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: `mishu-col ${dropOn === "remember" ? "drop" : ""}`, ...dropProps("remember"), "aria-label": t.remember, title: t.dropRemember, children: [
994
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-col-head", children: [
995
+ t.remember,
996
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: columns.remember.length })
997
+ ] }),
998
+ columns.remember.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-empty", children: t.emptyRemember }) : columns.remember.map((item) => card(item, "remember")),
999
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AddForm, { lang, locale, onAdded: (next) => setBoard(next) })
1000
+ ] }),
1001
+ divider(1),
1002
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: `mishu-col ${dropOn === "done" ? "drop" : ""}`, ...dropProps("done"), "aria-label": t.done, title: t.dropDone, children: [
1003
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-col-head", children: [
1004
+ t.done,
1005
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: columns.done.total })
1006
+ ] }),
1007
+ columns.done.groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-empty", children: t.emptyDone }) : columns.done.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "mishu-group", children: [
1008
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("summary", { children: [
1009
+ group.label,
1010
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: group.items.length })
1011
+ ] }),
1012
+ group.items.map((item) => card(item, "done"))
1013
+ ] }, group.reason)),
1014
+ columns.done.total > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mishu-hint", children: t.doneHint }) : null,
1015
+ metrics.shadow > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-banner", children: t.shadow(metrics.shadow) }) : null
1016
+ ] })
1017
+ ] })
1018
+ ] })
1019
+ ] });
1020
+ }
1021
+ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, onAct, onDragStart, onDragEnd }) {
1022
+ const t = TEXT[lang];
1023
+ const [open, setOpen] = (0, import_react3.useState)(false);
1024
+ const [detail, setDetail] = (0, import_react3.useState)();
1025
+ const explain = item.explain;
1026
+ const compact = column === "done";
1027
+ const toggle = () => {
1028
+ const next = !open;
1029
+ setOpen(next);
1030
+ if (next && item.target === "matter") {
1031
+ void mishuApi.detail(locale(), item.id).then((r) => setDetail(r.ok ? r.detail : { error: r.message }));
1032
+ }
1033
+ };
1034
+ const row = (name, text, className = "") => text === null || text === void 0 || text === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `mishu-row-explain ${className}`, children: [
1035
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "mishu-row-label", children: name }),
1036
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: text })
1037
+ ] });
1038
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1039
+ "div",
1040
+ {
1041
+ className: `mishu-card ${item.tone === "normal" ? "" : item.tone}`,
1042
+ draggable: item.target === "matter" && column !== "done",
1043
+ onDragStart: (event) => {
1044
+ event.dataTransfer.effectAllowed = "move";
1045
+ onDragStart();
1046
+ },
1047
+ onDragEnd,
1048
+ children: [
1049
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-card-title", children: item.title }),
1050
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-card-meta", children: item.meta }),
1051
+ !compact && explain !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-explain", children: [
1052
+ row(t.what, explain.what),
1053
+ row(column === "remember" ? t.whyKeep : t.why, explain.why),
1054
+ row(t.fix, explain.fix, "mishu-fix")
1055
+ ] }) : null,
1056
+ !compact && explain === null && item.note !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-card-note", children: item.note }) : null,
1057
+ open ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-detail", children: detail === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-empty", children: t.loading }) : "error" in detail ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-danger", children: detail.error }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1058
+ compact && detail.explain !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1059
+ row(t.what, detail.explain.what),
1060
+ row(t.whyDone, detail.explain.why)
1061
+ ] }) : null,
1062
+ detail.did.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-row-explain", children: [
1063
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "mishu-row-label", children: t.did }),
1064
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: detail.did.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: line }, i)) })
1065
+ ] }) : null,
1066
+ detail.messages.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-messages", children: [
1067
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-row-label", children: t.messages(detail.messages.length) }),
1068
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { children: detail.messages.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { children: [
1069
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: m.at }),
1070
+ " ",
1071
+ m.title
1072
+ ] }, i)) })
1073
+ ] }) : null
1074
+ ] }) }) : null,
1075
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-actions", children: [
1076
+ column === "handle" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AskAI, { topic: item.target === "series" ? { kind: "series", id: item.id } : { kind: "matter", id: item.id }, lang, locale, openChat: openChat2 }) : null,
1077
+ item.actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1078
+ "button",
1079
+ {
1080
+ type: "button",
1081
+ className: `mishu-btn ${index === 0 ? "primary" : ""}`,
1082
+ disabled: busy && action !== "open",
1083
+ onClick: () => onAct(action),
1084
+ children: action === "open" && explain?.link !== void 0 ? explain.link.label : label[action]
1085
+ },
1086
+ action
1087
+ )),
1088
+ item.target === "matter" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", "aria-expanded": open, onClick: toggle, children: open ? t.hide : compact ? t.explainDone : t.detail }) : null,
1089
+ column === "handle" ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AskAI, { topic: item.target === "series" ? { kind: "series", id: item.id } : { kind: "matter", id: item.id }, lang, locale, openChat: openChat2, compact: true })
1090
+ ] })
1091
+ ]
1092
+ }
1093
+ );
1094
+ }
1095
+ var EMPTY = { title: "", due: "", repeat: "none", category: "other", note: "" };
1096
+ function AddForm({ lang, locale, onAdded }) {
1097
+ const t = TEXT[lang];
1098
+ const [open, setOpen] = (0, import_react3.useState)(false);
1099
+ const [item, setItem] = (0, import_react3.useState)(EMPTY);
1100
+ const [preview, setPreview] = (0, import_react3.useState)();
1101
+ const [saving, setSaving] = (0, import_react3.useState)(false);
1102
+ (0, import_react3.useEffect)(() => {
1103
+ if (!open || item.title.trim() === "" || item.due === "") {
1104
+ setPreview(void 0);
1105
+ return;
1106
+ }
1107
+ const timer = setTimeout(() => {
1108
+ void mishuApi.preview(locale(), item).then((r) => setPreview(r.ok ? { ok: true, text: r.text } : { ok: false, text: r.message }));
1109
+ }, 250);
1110
+ return () => clearTimeout(timer);
1111
+ }, [open, item, locale]);
1112
+ if (!open) {
1113
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", className: "mishu-btn mishu-add-toggle", onClick: () => setOpen(true), children: [
1114
+ "+ ",
1115
+ t.add
1116
+ ] });
1117
+ }
1118
+ const set = (key) => (event) => setItem({ ...item, [key]: event.target.value });
1119
+ const save = async () => {
1120
+ setSaving(true);
1121
+ const result = await mishuApi.add(locale(), item);
1122
+ setSaving(false);
1123
+ if (result.ok) {
1124
+ onAdded(result.board);
1125
+ setItem(EMPTY);
1126
+ setOpen(false);
1127
+ } else {
1128
+ setPreview({ ok: false, text: result.message });
1129
+ }
1130
+ };
1131
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-add", children: [
1132
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "mishu-field", children: [
1133
+ t.addTitle,
1134
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { value: item.title, placeholder: t.addTitlePlaceholder, onChange: set("title") })
1135
+ ] }),
1136
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-row", children: [
1137
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "mishu-field", children: [
1138
+ t.addDue,
1139
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { type: "date", value: item.due, onChange: set("due") })
1140
+ ] }),
1141
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "mishu-field", children: [
1142
+ t.addRepeat,
1143
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("select", { value: item.repeat, onChange: set("repeat"), children: Object.entries(t.repeats).map(([value, text]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value, children: text }, value)) })
1144
+ ] })
1145
+ ] }),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-row", children: [
1147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "mishu-field", children: [
1148
+ t.addCategory,
1149
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("select", { value: item.category, onChange: set("category"), children: Object.entries(t.categories).map(([value, text]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value, children: text }, value)) })
1150
+ ] }),
1151
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "mishu-field", children: [
1152
+ t.addNote,
1153
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { value: item.note, onChange: set("note") })
1154
+ ] })
1155
+ ] }),
1156
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `mishu-preview ${preview?.ok === false ? "mishu-danger" : ""}`, children: preview?.text ?? t.previewHint }),
1157
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-actions", children: [
1158
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: saving || preview?.ok !== true, onClick: () => {
1159
+ void save();
1160
+ }, children: t.save }),
1161
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => {
1162
+ setOpen(false);
1163
+ setItem(EMPTY);
1164
+ }, children: t.cancel })
1165
+ ] }),
1166
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mishu-hint", children: t.chatHint })
1167
+ ] });
1168
+ }
1169
+
1170
+ // src/client/styles.ts
1171
+ var v = (name, fallback) => `var(--dsw-alias-${name}, ${fallback})`;
1172
+ var TEXT2 = v("label-primary", "CanvasText");
1173
+ var MUTED = v("label-secondary", "GrayText");
1174
+ var FAINT = v("label-tertiary", "GrayText");
1175
+ var LINE = v("border-l2", "rgba(127,127,127,.22)");
1176
+ var LINE_STRONG = v("border-l3", "rgba(127,127,127,.35)");
1177
+ var LAYER1 = v("bg-layer-1", "rgba(127,127,127,.06)");
1178
+ var LAYER2 = v("bg-layer-2", "rgba(127,127,127,.10)");
1179
+ var HOVER = v("interactive-bg-hover", "rgba(127,127,127,.12)");
1180
+ var DANGER = v("state-error-primary", "#d14343");
1181
+ var WARN = v("state-warn-primary", "#b7791f");
1182
+ var OK = v("state-success-primary", "#2f855a");
1183
+ var ACCENT = v("brand-primary", "#4d6bfe");
1184
+ var STYLES = `
1185
+ .mishu-page{box-sizing:border-box;height:100%;overflow:auto;padding:20px 24px 32px;color:${TEXT2};font-size:13px;line-height:1.5}
1186
+ .mishu-page *{box-sizing:border-box}
1187
+ .mishu-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:8px}
1188
+ .mishu-head h1{font-size:18px;font-weight:600;margin:0}
1189
+ .mishu-sources{display:flex;align-items:center;gap:10px;color:${MUTED};font-size:12px;flex-wrap:wrap}
1190
+ .mishu-dot{display:inline-block;width:7px;height:7px;border-radius:50%;margin-right:4px;vertical-align:1px;background:${FAINT}}
1191
+ .mishu-dot.ok{background:${OK}}.mishu-dot.error{background:${DANGER}}
1192
+ .mishu-summary{font-size:15px;margin:4px 0 14px;max-width:72ch}
1193
+ .mishu-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:16px}
1194
+ .mishu-metric{background:${LAYER1};border-radius:10px;padding:10px 12px}
1195
+ .mishu-metric-label{font-size:12px;color:${MUTED}}
1196
+ .mishu-metric-value{font-size:22px;font-weight:600;line-height:1.3}
1197
+ .mishu-metric-value small{font-size:12px;font-weight:400;margin-left:6px}
1198
+ .mishu-danger{color:${DANGER}}.mishu-warn{color:${WARN}}
1199
+ .mishu-columns{display:grid;grid-template-columns:var(--mishu-cols,minmax(0,1fr) 10px minmax(0,1fr) 10px minmax(0,1fr));gap:0;align-items:stretch}
1200
+ .mishu-divider{cursor:col-resize;position:relative;touch-action:none}
1201
+ .mishu-divider::after{content:'';position:absolute;top:8px;bottom:8px;left:4px;width:2px;border-radius:1px;background:transparent;transition:background .12s}
1202
+ .mishu-divider:hover::after,.mishu-divider:active::after{background:${ACCENT}}
1203
+ .mishu-col{background:${LAYER1};border-radius:12px;padding:10px;min-height:120px;min-width:0;border:1px solid transparent;transition:border-color .12s;align-self:start}
1204
+ .mishu-col.drop{border-color:${ACCENT};border-style:dashed}
1205
+ .mishu-col-head{display:flex;justify-content:space-between;align-items:baseline;font-weight:600;margin:2px 4px 8px}
1206
+ .mishu-col-head span{color:${MUTED};font-weight:400}
1207
+ .mishu-empty{color:${FAINT};padding:8px 4px}
1208
+ .mishu-card{background:${LAYER2};border:1px solid ${LINE};border-radius:8px;padding:8px 10px;margin-bottom:8px}
1209
+ .mishu-card[draggable=true]{cursor:grab}
1210
+ .mishu-card.danger{border-color:${DANGER}}
1211
+ .mishu-card-title{font-weight:600;word-break:break-word}
1212
+ .mishu-card-meta{font-size:12px;color:${MUTED};margin-top:2px}
1213
+ .mishu-card.danger .mishu-card-meta{color:${DANGER}}
1214
+ .mishu-card.warn .mishu-card-meta{color:${WARN}}
1215
+ .mishu-card-note{font-size:12px;color:${MUTED};margin-top:4px;word-break:break-word}
1216
+ .mishu-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
1217
+ .mishu-explain{margin-top:6px;display:flex;flex-direction:column;gap:4px}
1218
+ .mishu-row-explain{display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px;font-size:12px;line-height:1.55;word-break:break-word}
1219
+ .mishu-row-label{color:${FAINT};white-space:nowrap;font-size:12px}
1220
+ .mishu-fix span:last-child{color:${TEXT2}}
1221
+ .mishu-detail{margin-top:8px;padding-top:8px;border-top:1px dashed ${LINE};display:flex;flex-direction:column;gap:6px}
1222
+ .mishu-messages ul{margin:4px 0 0;padding-left:16px;font-size:12px;color:${MUTED}}
1223
+ .mishu-messages li span{color:${FAINT};margin-right:4px}
1224
+ .mishu-btn-quiet{border-color:transparent;color:${MUTED}}
1225
+ .mishu-btn{font:inherit;font-size:12px;color:${TEXT2};background:transparent;border:1px solid ${LINE_STRONG};border-radius:6px;padding:2px 9px;cursor:pointer}
1226
+ .mishu-btn:hover{background:${HOVER}}
1227
+ .mishu-btn:disabled{opacity:.5;cursor:default}
1228
+ .mishu-btn.primary{border-color:${ACCENT};color:${ACCENT}}
1229
+ .mishu-group{border-top:1px solid ${LINE};padding:6px 4px}
1230
+ .mishu-group summary{cursor:pointer;display:flex;justify-content:space-between;list-style:none}
1231
+ .mishu-group summary::-webkit-details-marker{display:none}
1232
+ .mishu-group summary span{color:${MUTED}}
1233
+ .mishu-group .mishu-card{margin-top:6px}
1234
+ .mishu-hint{font-size:12px;color:${FAINT};margin:6px 4px 0}
1235
+ .mishu-banner{margin-top:10px;padding:8px 10px;border-radius:8px;border:1px solid ${WARN};color:${WARN};font-size:12px}
1236
+ .mishu-error{margin-bottom:12px;padding:8px 10px;border-radius:8px;border:1px solid ${DANGER};color:${DANGER};font-size:12px}
1237
+ .mishu-add{border:1px dashed ${LINE_STRONG};border-radius:8px;padding:8px;margin-top:4px}
1238
+ .mishu-add-toggle{width:100%;text-align:left;border-style:dashed}
1239
+ .mishu-field{display:flex;flex-direction:column;gap:2px;margin-bottom:6px;font-size:12px;color:${MUTED}}
1240
+ .mishu-field input,.mishu-field select{font:inherit;font-size:13px;color:${TEXT2};background:${LAYER2};border:1px solid ${LINE_STRONG};border-radius:6px;padding:4px 6px;width:100%}
1241
+ .mishu-row{display:grid;grid-template-columns:1fr 1fr;gap:6px}
1242
+ .mishu-preview{white-space:pre-wrap;font-size:12px;background:${LAYER2};border-radius:6px;padding:6px 8px;margin:4px 0 6px;color:${TEXT2}}
1243
+ .mishu-preview.mishu-danger{color:${DANGER}}
1244
+ .mishu-add>.mishu-hint{margin-bottom:8px}
1245
+ .mishu-title{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
1246
+ .mishu-tabs{display:flex;gap:2px;background:${LAYER1};border-radius:8px;padding:2px}
1247
+ .mishu-tabs button{font:inherit;font-size:13px;color:${MUTED};background:transparent;border:0;border-radius:6px;padding:3px 12px;cursor:pointer}
1248
+ .mishu-tabs button.active{background:${LAYER2};color:${TEXT2}}
1249
+ .mishu-filters{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 10px}
1250
+ .mishu-chip{font:inherit;font-size:12px;color:${MUTED};background:transparent;border:1px solid ${LINE_STRONG};border-radius:999px;padding:2px 10px;cursor:pointer;display:inline-flex;gap:6px;align-items:center}
1251
+ .mishu-chip span{color:${FAINT}}
1252
+ .mishu-chip.active{border-color:${ACCENT};color:${ACCENT}}
1253
+ .mishu-chip.active span{color:${ACCENT}}
1254
+ .mishu-settings{display:flex;flex-direction:column;gap:12px;max-width:760px}
1255
+ .mishu-panel{background:${LAYER1};border-radius:12px;padding:12px 14px}
1256
+ .mishu-panel h2{font-size:14px;font-weight:600;margin:0 0 8px}
1257
+ .mishu-grid5{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;margin-bottom:8px}
1258
+ .mishu-check{display:flex;align-items:center;gap:6px;font-size:13px;margin:4px 0 8px;color:${TEXT2}}
1259
+ .mishu-ok{padding:6px 10px;border-radius:8px;border:1px solid ${OK};color:${OK};font-size:12px}
1260
+ .mishu-ai-wrap{display:inline-flex;align-items:center;gap:6px;vertical-align:middle;flex-wrap:wrap}
1261
+ .mishu-ai{font:inherit;font-size:12px;font-weight:700;letter-spacing:.02em;color:#fff;border:0;border-radius:999px;padding:3px 11px;cursor:pointer;background:linear-gradient(120deg,#6d5dfc 0%,#c850c0 50%,#ff8a3d 100%);background-size:160% 100%;transition:background-position .3s,transform .1s}
1262
+ .mishu-ai:hover{background-position:100% 0}
1263
+ .mishu-ai:active{transform:scale(.97)}
1264
+ .mishu-ai:disabled{opacity:.6;cursor:default}
1265
+ .mishu-ai.compact{font-size:11px;padding:1px 8px;margin-left:4px}
1266
+ .mishu-ai:focus-visible{outline:2px solid ${ACCENT};outline-offset:2px}
1267
+ .mishu-ai-note{font-size:11px;color:${MUTED}}
1268
+ @media (max-width:820px){.mishu-columns{grid-template-columns:1fr;gap:12px}.mishu-divider{display:none}.mishu-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.mishu-grid5{grid-template-columns:repeat(2,minmax(0,1fr))}}
1269
+ `;
1270
+
1271
+ // src/client/index.tsx
1272
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1273
+ var PACKAGE_NAME = "dsh-mishu";
1274
+ var inject = ["slots", "locale"];
1275
+ var PANEL_ID = "dsh-mishu";
1276
+ var NS = "dsh-mishu";
1277
+ var openChat;
1278
+ function MishuIcon({ size }) {
1279
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
1280
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "5", y: "4", width: "14", height: "17", rx: "2" }),
1281
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 4h6v3H9z" }),
1282
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 12l2 2 4-4" }),
1283
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 17h6" })
1284
+ ] });
1285
+ }
1286
+ function apply(ctx) {
1287
+ ctx.effect(() => ctx.locale.register(NS, { zh: { panel: "\u5C0F\u79D8\u4E66" }, en: { panel: "Secretary" } }), "dsh-mishu: dictionaries");
1288
+ ctx.effect(() => {
1289
+ const style = document.createElement("style");
1290
+ style.dataset.dshPlugin = PACKAGE_NAME;
1291
+ style.textContent = STYLES;
1292
+ document.head.append(style);
1293
+ return () => {
1294
+ style.remove();
1295
+ };
1296
+ }, "dsh-mishu: styles");
1297
+ const t = ctx.locale.bind(NS);
1298
+ const locale = () => ctx.locale.getSnapshot().active;
1299
+ ctx.inject(["uiWorkspace"], (workspaceCtx) => {
1300
+ workspaceCtx.effect(() => {
1301
+ openChat = (prompt) => workspaceCtx.uiWorkspace.startSession(void 0, { prompt, clearPreviousDraft: true });
1302
+ return () => {
1303
+ openChat = void 0;
1304
+ };
1305
+ }, "dsh-mishu: +AI opens a chat");
1306
+ });
1307
+ ctx.slots.inject("main", () => ctx.slots.register({
1308
+ name: "main",
1309
+ key: PANEL_ID,
1310
+ locale: NS,
1311
+ inject: () => ({ locale, openChat: (prompt) => openChat === void 0 ? false : (openChat(prompt), true) })
1312
+ }, MishuBoard));
1313
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
1314
+ name: "sidebar.panellist",
1315
+ id: PANEL_ID,
1316
+ order: 30,
1317
+ locale: NS,
1318
+ label: () => t("panel")
1319
+ }, MishuIcon));
1320
+ }
1321
+
1322
+ return module.exports;
1323
+ }
1324
+ });