dsh-workbench-host 0.0.0-stage → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1885 @@
1
+ // 由 scripts/build-addon-clients.mjs 生成;请修改对应 client/client.src.cjs 后重新构建。
2
+ window.__ModuleLoader__ = window.__ModuleLoader__ || { modules: {}, load: function (m) { this.modules[m.id] = m.factory; } };
3
+ window.__ModuleLoader__.load({
4
+ id: "dsh-workbench-host",
5
+ factory: function (require) {
6
+ var module = { exports: {} };
7
+ var exports = module.exports;
8
+ "use strict";
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ try {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ } catch (e) {
14
+ throw mod = 0, e;
15
+ }
16
+ };
17
+
18
+ // packages/shell/client/locale.cjs
19
+ var require_locale = __commonJS({
20
+ "packages/shell/client/locale.cjs"(exports2, module2) {
21
+ "use strict";
22
+ var LOCALE2 = {
23
+ zh: {
24
+ nav: "\u5DE5\u4F5C\u53F0",
25
+ title: "\u5DE5\u4F5C\u53F0",
26
+ tagline: "\u79BB\u7EBF\u4F18\u5148 \xB7 \u4E1A\u52A1\u63D2\u4EF6\u7531 DSH \u5B89\u88C5",
27
+ tab_account: "\u8D26\u53F7\u4E0E\u540C\u6B65",
28
+ tab_addons: "\u5B50\u63D2\u4EF6",
29
+ tab_backup: "\u6570\u636E\u5907\u4EFD",
30
+ backup_desc: "\u6309\u6A21\u5757\u5BFC\u51FA\u6216\u5BFC\u5165\u672C\u5730\u6570\u636E\uFF1B\u5BFC\u5165\u53EA\u5408\u5E76\uFF0C\u4E0D\u5220\u9664\u5DF2\u6709\u6570\u636E",
31
+ backup_modules: "\u9009\u62E9\u8981\u5BFC\u51FA\u7684\u6A21\u5757",
32
+ backup_export_result: "\u5BFC\u51FA\u7ED3\u679C",
33
+ backup_select_all: "\u5168\u9009",
34
+ backup_clear: "\u6E05\u7A7A",
35
+ backup_export: "\u5BFC\u51FA\u5907\u4EFD",
36
+ backup_import: "\u5BFC\u5165\u5907\u4EFD",
37
+ backup_exporting: "\u6B63\u5728\u5BFC\u51FA\u2026",
38
+ backup_importing: "\u6B63\u5728\u5BFC\u5165\u2026",
39
+ backup_no_modules: "\u5F53\u524D\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u6A21\u5757",
40
+ backup_select_required: "\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u6A21\u5757",
41
+ backup_import_result: "\u5BFC\u5165\u7ED3\u679C",
42
+ backup_summary: "\u6C47\u603B",
43
+ backup_detail: "\u6A21\u5757\u660E\u7EC6",
44
+ backup_status: "\u72B6\u6001",
45
+ backup_imported: "\u5BFC\u5165",
46
+ backup_skipped: "\u8DF3\u8FC7",
47
+ backup_failed: "\u5931\u8D25",
48
+ backup_ok: "\u6210\u529F",
49
+ backup_partial: "\u90E8\u5206\u6210\u529F",
50
+ backup_failed_status: "\u5931\u8D25",
51
+ backup_skipped_status: "\u8DF3\u8FC7",
52
+ backup_exported_at: "\u5BFC\u51FA\u65F6\u95F4",
53
+ backup_shell_version: "\u58F3\u7248\u672C",
54
+ backup_format: "\u5907\u4EFD\u683C\u5F0F",
55
+ backup_incompatible: "\u5907\u4EFD\u683C\u5F0F\u7248\u672C\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u5347\u7EA7\u5DE5\u4F5C\u53F0\u540E\u518D\u5BFC\u5165",
56
+ backup_invalid: "\u5907\u4EFD\u6587\u4EF6\u65E0\u6548",
57
+ backup_file_hint: "\u652F\u6301 .zip \u5907\u4EFD\u5305",
58
+ backup_download_started: "\u5DF2\u5F00\u59CB\u4E0B\u8F7D\u5907\u4EFD",
59
+ backup_import_done: "\u5BFC\u5165\u5B8C\u6210",
60
+ backup_export_failed: "\u5BFC\u51FA\u5931\u8D25",
61
+ backup_import_failed: "\u5BFC\u5165\u5931\u8D25",
62
+ backup_no_import: "\u672A\u5B9E\u73B0\u5BFC\u5165",
63
+ backup_no_export: "\u672A\u5B9E\u73B0\u5BFC\u51FA",
64
+ backup_refresh: "\u91CD\u65B0\u8BFB\u53D6\u6A21\u5757",
65
+ backup_cap_export: "\u53EF\u5BFC\u51FA",
66
+ backup_cap_import: "\u53EF\u5BFC\u5165",
67
+ backup_dup_policy: "\u91CD\u590D ID \u65F6",
68
+ backup_dup_newest: "\u4EE5\u65F6\u95F4\u6700\u65B0\u4E3A\u4E3B",
69
+ backup_dup_skip: "\u4FDD\u7559\u672C\u5730\uFF08\u8DF3\u8FC7\uFF09",
70
+ backup_dup_overwrite: "\u7528\u5907\u4EFD\u8986\u76D6",
71
+ backup_dup_hint: "\u5BFC\u5165\u65F6\u5BF9\u540C ID \u8BB0\u5F55\u7684\u5904\u7406\u65B9\u5F0F",
72
+ backup_policy: "\u7B56\u7565",
73
+ back_home: "\u8FD4\u56DE\u9996\u9875",
74
+ open: "\u6253\u5F00",
75
+ manage: "\u5DE5\u4F5C\u53F0\u7BA1\u7406",
76
+ home_hint: "\u70B9\u5F00\u5361\u7247\u8FDB\u5165\u4E1A\u52A1\u63D2\u4EF6\uFF1B\u5B89\u88C5\u4E0E\u5378\u8F7D\u5728 DSH \u63D2\u4EF6\u7BA1\u7406\u91CC",
77
+ account_desc: "\u767B\u5F55\u4E91\u7AEF\u8D26\u53F7\uFF0C\u5907\u4EFD\u4E0E\u540C\u6B65\u6570\u636E",
78
+ tab_audit: "\u5BA1\u8BA1\u65E5\u5FD7",
79
+ audit_desc: "\u672C\u673A\u884C\u4E3A\u8D26\u672C\uFF1A\u8C01\u5728\u4F55\u65F6\u8C03\u7528\u4E86\u54EA\u4E2A action\u3001\u6210\u529F\u4E0E\u5426\uFF1B\u5BC6\u7801\u4E0E token \u7B49\u53C2\u6570\u5DF2\u8131\u654F",
80
+ audit_filters: "\u7B5B\u9009",
81
+ audit_action_prefix: "action \u524D\u7F00",
82
+ audit_actor: "\u5165\u53E3",
83
+ audit_ok: "\u7ED3\u679C",
84
+ audit_all: "\u5168\u90E8",
85
+ audit_ok_only: "\u53EA\u770B\u6210\u529F",
86
+ audit_fail_only: "\u53EA\u770B\u5931\u8D25",
87
+ audit_q: "\u5173\u952E\u5B57",
88
+ audit_since: "\u8D77\u59CB\u65E5\u671F",
89
+ audit_until: "\u7ED3\u675F\u65E5\u671F",
90
+ audit_search: "\u67E5\u8BE2",
91
+ audit_refresh: "\u5237\u65B0",
92
+ audit_empty: "\u5F53\u524D\u7B5B\u9009\u65E0\u8BB0\u5F55",
93
+ audit_load_failed: "\u8BFB\u53D6\u5BA1\u8BA1\u65E5\u5FD7\u5931\u8D25",
94
+ audit_time: "\u65F6\u95F4",
95
+ audit_action: "action",
96
+ audit_target: "\u76EE\u6807",
97
+ audit_duration: "\u8017\u65F6",
98
+ audit_detail: "\u53C2\u6570\u4E0E\u7ED3\u679C",
99
+ audit_error: "\u9519\u8BEF",
100
+ audit_active: "\u7B5B\u9009\u4E2D",
101
+ audit_clear: "\u6E05\u9664\u7B5B\u9009",
102
+ audit_loading: "\u67E5\u8BE2\u4E2D\u2026",
103
+ audit_page_size: "\u6BCF\u9875\u6761\u6570",
104
+ audit_stats: "\u8FD1 30 \u5929\uFF08\u4E0D\u53D7\u4E0A\u65B9\u7B5B\u9009\u5F71\u54CD\uFF09",
105
+ audit_total: "\u5171",
106
+ audit_failed: "\u5931\u8D25",
107
+ audit_prev: "\u4E0A\u4E00\u9875",
108
+ audit_next: "\u4E0B\u4E00\u9875",
109
+ audit_page: "\u9875",
110
+ audit_retention: "\u9ED8\u8BA4\u4FDD\u7559 90 \u5929\uFF1B\u53EF\u7528 audit.prune \u8C03\u6574\u4FDD\u7559\u671F",
111
+ audit_reads_hint: "\u53EA\u8BFB action \u9ED8\u8BA4\u4E0D\u8BB0\uFF1Bmeta.audit.recordReads=1 \u65F6\u8BB0\u5F55",
112
+ addons_desc: "\u5B89\u88C5\u3001\u5347\u7EA7\u6216\u5378\u8F7D\u5B50\u63D2\u4EF6",
113
+ no_views: "\u8BE5\u5B50\u63D2\u4EF6\u6CA1\u6709\u6CE8\u518C\u754C\u9762",
114
+ addon_loading: "\u6B63\u5728\u52A0\u8F7D\u5B50\u63D2\u4EF6\u754C\u9762\u2026",
115
+ addon_unavailable: "\u5B50\u63D2\u4EF6\u754C\u9762\u4E0D\u53EF\u7528",
116
+ views: "\u4E2A\u89C6\u56FE",
117
+ addons_installed: "\u5DF2\u5B89\u88C5\u7684\u5B50\u63D2\u4EF6",
118
+ addons_cloud: "\u4E91\u7AEF\u76EE\u5F55",
119
+ install: "\u5B89\u88C5",
120
+ upgrade: "\u5347\u7EA7",
121
+ installed: "\u5DF2\u5B89\u88C5",
122
+ uninstall: "\u5378\u8F7D",
123
+ confirm_uninstall: "\u786E\u8BA4\u5378\u8F7D",
124
+ installing: "\u6B63\u5728\u5B89\u88C5\u2026",
125
+ refresh: "\u5237\u65B0\u76EE\u5F55",
126
+ no_installed: "\u8FD8\u6CA1\u6709\u5B89\u88C5\u4E1A\u52A1\u63D2\u4EF6\u2014\u2014\u5728 DSH \u63D2\u4EF6\u7BA1\u7406\u91CC\u5B89\u88C5\u4EFB\u52A1\u8BB0\u5F55\u3001\u6807\u7B7E\u6216\u7AD9\u70B9",
127
+ no_catalog: "\u4E91\u7AEF\u76EE\u5F55\u4E3A\u7A7A\u6216\u4E0D\u53EF\u8FBE",
128
+ catalog_loading: "\u6B63\u5728\u8BFB\u53D6\u4E91\u7AEF\u76EE\u5F55\u2026",
129
+ cached_notice: "\u4E91\u7AEF\u4E0D\u53EF\u8FBE\uFF0C\u663E\u793A\u4E0A\u6B21\u7F13\u5B58\u7684\u76EE\u5F55",
130
+ install_failed: "\u5B89\u88C5\u5931\u8D25",
131
+ uninstall_failed: "\u5378\u8F7D\u5931\u8D25",
132
+ load_failed: "\u5BA2\u6237\u7AEF\u52A0\u8F7D\u5931\u8D25",
133
+ data_kept: "\u5378\u8F7D\u53EA\u5220\u4EE3\u7801\uFF0C\u6570\u636E\u4FDD\u7559\uFF1B\u91CD\u88C5\u540E\u6570\u636E\u4ECD\u5728",
134
+ addon_error: "\u52A0\u8F7D\u5F02\u5E38",
135
+ source_cloud: "\u4E91\u7AEF",
136
+ source_local: "\u672C\u5730\u76EE\u5F55",
137
+ version: "\u7248\u672C",
138
+ latest: "\u6700\u65B0",
139
+ shell_version: "\u58F3\u7248\u672C",
140
+ delete: "\u5220\u9664",
141
+ login: "\u767B\u5F55",
142
+ signup: "\u6CE8\u518C",
143
+ email: "\u90AE\u7BB1",
144
+ password: "\u5BC6\u7801",
145
+ logout: "\u9000\u51FA\u767B\u5F55",
146
+ logged_in_as: "\u5DF2\u767B\u5F55",
147
+ not_logged_in: "\u672A\u767B\u5F55\u2014\u2014\u6570\u636E\u4EC5\u5B58\u672C\u673A SQLite",
148
+ sync_now: "\u7ACB\u5373\u540C\u6B65",
149
+ sync_pushed: "\u63A8\u9001",
150
+ sync_pulled: "\u62C9\u53D6",
151
+ device_name: "\u672C\u8BBE\u5907",
152
+ sync_status: "\u540C\u6B65\u72B6\u6001",
153
+ sync_last: "\u4E0A\u6B21\u540C\u6B65",
154
+ sync_never: "\u5C1A\u672A\u540C\u6B65",
155
+ sync_conflicts: "\u51B2\u7A81",
156
+ sync_failed_tables: "\u5931\u8D25\u7684\u8868",
157
+ sync_clock: "\u65F6\u949F\u504F\u79FB",
158
+ sync_no_conflicts: "\u6CA1\u6709\u5F85\u5904\u7406\u7684\u51B2\u7A81",
159
+ sync_conflict_hint: "\u540C\u4E00\u884C\u5728\u672C\u5730\u548C\u4E91\u7AEF\u90FD\u88AB\u4FEE\u6539\uFF0C\u9009\u62E9\u4FDD\u7559\u54EA\u4E2A\u7248\u672C",
160
+ sync_keep_local: "\u4FDD\u7559\u672C\u5730",
161
+ sync_keep_server: "\u91C7\u7528\u4E91\u7AEF",
162
+ sync_dismiss: "\u5FFD\u7565",
163
+ sync_resolve_failed: "\u51B2\u7A81\u5904\u7406\u5931\u8D25",
164
+ sync_ok: "\u540C\u6B65\u5B8C\u6210",
165
+ sync_partial: "\u90E8\u5206\u8868\u540C\u6B65\u5931\u8D25",
166
+ cloud_status: "\u4E91\u7AEF\u8FDE\u63A5\u72B6\u6001",
167
+ cloud_checking: "\u68C0\u67E5\u4E91\u7AEF\u2026",
168
+ cloud_checking_hint: "\u6B63\u5728\u68C0\u67E5\u4E91\u7AEF\u8FDE\u63A5",
169
+ cloud_local: "\u672C\u5730\u6A21\u5F0F",
170
+ cloud_local_hint: "\u672A\u767B\u5F55\u4E91\u7AEF\uFF1B\u6570\u636E\u53EA\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u4ECD\u53EF\u6B63\u5E38\u4F7F\u7528",
171
+ cloud_syncing: "\u6B63\u5728\u540C\u6B65\u2026",
172
+ cloud_syncing_hint: "\u6B63\u5728\u4E0E\u4E91\u7AEF\u540C\u6B65\u6570\u636E",
173
+ cloud_online: "\u4E91\u7AEF\u5DF2\u8FDE\u63A5",
174
+ cloud_online_hint: "\u8D26\u53F7\u5DF2\u8FDE\u63A5\uFF0C\u6570\u636E\u4F1A\u81EA\u52A8\u540C\u6B65",
175
+ cloud_offline: "\u4E91\u7AEF\u8FDE\u63A5\u5931\u8D25",
176
+ cloud_offline_hint: "\u65E0\u6CD5\u8FDE\u63A5\u5230\u4E91\u7AEF\uFF1B\u672C\u5730\u6570\u636E\u4ECD\u53EF\u6B63\u5E38\u4F7F\u7528",
177
+ cloud_never: "\u7B49\u5F85\u9996\u6B21\u540C\u6B65",
178
+ cloud_never_hint: "\u5DF2\u767B\u5F55\u4E91\u7AEF\uFF0C\u6B63\u5728\u7B49\u5F85\u9996\u8F6E\u540C\u6B65",
179
+ cloud_sync_failed: "\u540C\u6B65\u5F02\u5E38",
180
+ cloud_sync_failed_hint: "\u4E91\u7AEF\u53EF\u8FDE\u63A5\uFF0C\u4F46\u4E0A\u6B21\u540C\u6B65\u672A\u5B8C\u5168\u6210\u529F",
181
+ cloud_open: "\u6253\u5F00\u8D26\u53F7\u4E0E\u540C\u6B65",
182
+ record_label: "\u8BB0\u5F55\u6A21\u5F0F",
183
+ record_on: "\u8BB0\u5F55\u4E2D",
184
+ record_off: "\u8BB0\u5F55",
185
+ record_on_title: "\u672C\u4F1A\u8BDD\u8BB0\u5F55\u6A21\u5F0F\u5DF2\u5F00\u542F\uFF0C\u70B9\u51FB\u5173\u95ED",
186
+ record_off_title: "\u5F00\u542F\u540E\u628A\u5B8C\u6210\u7684\u53EF\u4EA4\u4ED8\u5185\u5BB9\u8BB0\u5230\u5DE5\u4F5C\u53F0\uFF08\u4EC5\u672C\u4F1A\u8BDD\uFF09",
187
+ record_busy: "\u5207\u6362\u4E2D",
188
+ record_error: "\u5207\u6362\u5931\u8D25",
189
+ record_failed_short: "\u8BB0\u5F55\u5931\u8D25"
190
+ },
191
+ en: {
192
+ nav: "Workbench",
193
+ title: "Workbench",
194
+ tagline: "Offline-first \xB7 addons installed by DSH",
195
+ tab_account: "Account & Sync",
196
+ tab_addons: "Addons",
197
+ tab_backup: "Data backup",
198
+ backup_desc: "Export or import local data per module; import merges and never deletes existing rows",
199
+ backup_modules: "Modules to export",
200
+ backup_export_result: "Export result",
201
+ backup_select_all: "Select all",
202
+ backup_clear: "Clear",
203
+ backup_export: "Export backup",
204
+ backup_import: "Import backup",
205
+ backup_exporting: "Exporting\u2026",
206
+ backup_importing: "Importing\u2026",
207
+ backup_no_modules: "No exportable modules",
208
+ backup_select_required: "Select at least one module",
209
+ backup_import_result: "Import result",
210
+ backup_summary: "Summary",
211
+ backup_detail: "Module details",
212
+ backup_status: "Status",
213
+ backup_imported: "imported",
214
+ backup_skipped: "skipped",
215
+ backup_failed: "failed",
216
+ backup_ok: "ok",
217
+ backup_partial: "partial",
218
+ backup_failed_status: "failed",
219
+ backup_skipped_status: "skipped",
220
+ backup_exported_at: "Exported at",
221
+ backup_shell_version: "Shell version",
222
+ backup_format: "Format",
223
+ backup_incompatible: "Backup format is incompatible; update the workbench before importing",
224
+ backup_invalid: "Invalid backup file",
225
+ backup_file_hint: "Supports .zip backups",
226
+ backup_download_started: "Backup download started",
227
+ backup_import_done: "Import finished",
228
+ backup_export_failed: "Export failed",
229
+ backup_import_failed: "Import failed",
230
+ backup_no_import: "Import not implemented",
231
+ backup_no_export: "Export not implemented",
232
+ backup_refresh: "Reload modules",
233
+ backup_cap_export: "export",
234
+ backup_cap_import: "import",
235
+ backup_dup_policy: "On duplicate ID",
236
+ backup_dup_newest: "Keep newest by time",
237
+ backup_dup_skip: "Keep local (skip)",
238
+ backup_dup_overwrite: "Overwrite with backup",
239
+ backup_dup_hint: "How to handle rows with the same ID on import",
240
+ backup_policy: "Policy",
241
+ back_home: "Back to home",
242
+ open: "Open",
243
+ manage: "Manage",
244
+ home_hint: "Open a card to enter a domain; install or remove plugins in DSH",
245
+ account_desc: "Sign in to back up and sync your data",
246
+ tab_audit: "Audit log",
247
+ audit_desc: "A local ledger of who called which action and how it went; passwords and tokens are redacted",
248
+ audit_filters: "Filters",
249
+ audit_action_prefix: "Action prefix",
250
+ audit_actor: "Actor",
251
+ audit_ok: "Result",
252
+ audit_all: "All",
253
+ audit_ok_only: "Succeeded",
254
+ audit_fail_only: "Failed",
255
+ audit_q: "Keyword",
256
+ audit_since: "Since",
257
+ audit_until: "Until",
258
+ audit_search: "Search",
259
+ audit_refresh: "Refresh",
260
+ audit_empty: "No audit records match",
261
+ audit_load_failed: "Failed to load the audit log",
262
+ audit_time: "Time",
263
+ audit_action: "Action",
264
+ audit_target: "Target",
265
+ audit_duration: "Duration",
266
+ audit_detail: "Arguments & result",
267
+ audit_error: "Error",
268
+ audit_active: "Filtering",
269
+ audit_clear: "Clear filters",
270
+ audit_loading: "Loading\u2026",
271
+ audit_page_size: "Records per page",
272
+ audit_stats: "Last 30 days (unaffected by filters)",
273
+ audit_total: "total",
274
+ audit_failed: "failed",
275
+ audit_prev: "Previous",
276
+ audit_next: "Next",
277
+ audit_page: "page",
278
+ audit_retention: "Retained for 90 days by default; adjust with audit.prune",
279
+ audit_reads_hint: "Read-only actions are not recorded unless meta.audit.recordReads=1",
280
+ addons_desc: "Install, update or uninstall addons",
281
+ no_views: "This addon has no UI",
282
+ addon_loading: "Loading addon UI\u2026",
283
+ addon_unavailable: "Addon UI unavailable",
284
+ views: "views",
285
+ addons_installed: "Installed addons",
286
+ addons_cloud: "Cloud catalog",
287
+ install: "Install",
288
+ upgrade: "Update",
289
+ installed: "Installed",
290
+ uninstall: "Uninstall",
291
+ confirm_uninstall: "Confirm uninstall",
292
+ installing: "Installing\u2026",
293
+ refresh: "Refresh catalog",
294
+ no_installed: "No domains yet \u2014 install Tasks, Tags or Sites from DSH plugins",
295
+ no_catalog: "Catalog is empty or unreachable",
296
+ catalog_loading: "Loading catalog\u2026",
297
+ cached_notice: "Cloud unreachable \u2014 showing the cached catalog",
298
+ install_failed: "Install failed",
299
+ uninstall_failed: "Uninstall failed",
300
+ load_failed: "client failed to load",
301
+ data_kept: "Uninstall removes code only; data is kept and reappears after reinstall",
302
+ addon_error: "load error",
303
+ source_cloud: "cloud",
304
+ source_local: "local dir",
305
+ version: "version",
306
+ latest: "latest",
307
+ shell_version: "shell",
308
+ delete: "Delete",
309
+ login: "Login",
310
+ signup: "Sign up",
311
+ email: "Email",
312
+ password: "Password",
313
+ logout: "Log out",
314
+ logged_in_as: "Signed in",
315
+ not_logged_in: "Not signed in \u2014 data stays local",
316
+ sync_now: "Sync now",
317
+ sync_pushed: "pushed",
318
+ sync_pulled: "pulled",
319
+ device_name: "This device",
320
+ sync_status: "Sync status",
321
+ sync_last: "Last sync",
322
+ sync_never: "Never synced",
323
+ sync_conflicts: "Conflicts",
324
+ sync_failed_tables: "Failed tables",
325
+ sync_clock: "Clock offset",
326
+ sync_no_conflicts: "No pending conflicts",
327
+ sync_conflict_hint: "The same row changed locally and remotely; choose which version to keep",
328
+ sync_keep_local: "Keep local",
329
+ sync_keep_server: "Use remote",
330
+ sync_dismiss: "Dismiss",
331
+ sync_resolve_failed: "Failed to resolve conflict",
332
+ sync_ok: "Sync complete",
333
+ sync_partial: "Some tables failed",
334
+ cloud_status: "Cloud connection",
335
+ cloud_checking: "Checking cloud\u2026",
336
+ cloud_checking_hint: "Checking the cloud connection",
337
+ cloud_local: "Local only",
338
+ cloud_local_hint: "Not signed in; data stays on this device",
339
+ cloud_syncing: "Syncing\u2026",
340
+ cloud_syncing_hint: "Syncing data with the cloud",
341
+ cloud_online: "Cloud connected",
342
+ cloud_online_hint: "Signed in; data syncs automatically",
343
+ cloud_offline: "Cloud unreachable",
344
+ cloud_offline_hint: "Cannot reach the cloud; local data still works",
345
+ cloud_never: "Waiting for first sync",
346
+ cloud_never_hint: "Signed in; waiting for the first sync",
347
+ cloud_sync_failed: "Sync issue",
348
+ cloud_sync_failed_hint: "Cloud is reachable but the last sync did not fully succeed",
349
+ cloud_open: "Open Account & Sync",
350
+ record_label: "Record mode",
351
+ record_on: "Recording",
352
+ record_off: "Record",
353
+ record_on_title: "Record mode is on for this session; click to turn it off",
354
+ record_off_title: "Record finished deliverables to the workbench (this session only)",
355
+ record_busy: "Switching",
356
+ record_error: "Switch failed",
357
+ record_failed_short: "Failed"
358
+ }
359
+ };
360
+ module2.exports = LOCALE2;
361
+ }
362
+ });
363
+
364
+ // packages/shell/client/styles.cjs
365
+ var require_styles = __commonJS({
366
+ "packages/shell/client/styles.cjs"(exports2, module2) {
367
+ "use strict";
368
+ var CSS2 = [
369
+ ".wb-root{--wb-line:var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent));--wb-surface:var(--dsw-alias-bg-layer-1,color-mix(in oklab,currentColor 4%,transparent));display:flex;flex-direction:column;height:100%;box-sizing:border-box;overflow:auto;color:inherit;font-size:13px;background:var(--dsw-alias-bg-base,var(--dsw-alias-bg-layer-2,color-mix(in oklab,currentColor 4%,transparent)));padding:24px 28px}",
370
+ ".wb-inner{display:flex;flex-direction:column;gap:16px;width:100%;max-width:1040px;margin:0 auto}",
371
+ ".wb-hero{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap}",
372
+ ".wb-hero h2{margin:0;font-size:18px;font-weight:650;letter-spacing:.2px}",
373
+ ".wb-tag{font-size:12px;opacity:.62;margin-top:4px;display:block;line-height:1.5}",
374
+ ".wb-cloud{display:inline-flex;align-items:center;gap:7px;max-width:100%;padding:6px 11px;border:1px solid var(--wb-line);border-radius:999px;background:var(--wb-surface);color:inherit;font:inherit;font-size:12px;line-height:1.2;cursor:pointer;white-space:nowrap;transition:border-color .15s ease,background .15s ease}",
375
+ ".wb-cloud:hover{border-color:var(--dsw-alias-brand-primary,#11a89b)}",
376
+ ".wb-cloud:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#11a89b);outline-offset:2px}",
377
+ ".wb-cloud-dot{width:7px;height:7px;border-radius:50%;background:currentColor;opacity:.4;flex:none}",
378
+ ".wb-cloud.local{opacity:.7}",
379
+ ".wb-cloud.on .wb-cloud-dot{background:var(--dsw-alias-state-success-primary,#18a058);opacity:1;box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-state-success-primary,#18a058) 16%,transparent)}",
380
+ ".wb-cloud.off{border-color:color-mix(in oklab,var(--dsw-alias-state-error-primary,#e5484d) 35%,var(--wb-line));background:color-mix(in oklab,var(--dsw-alias-state-error-primary,#e5484d) 5%,var(--wb-surface))}",
381
+ ".wb-cloud.off .wb-cloud-dot{background:var(--dsw-alias-state-error-primary,#e5484d);opacity:1}",
382
+ ".wb-cloud.warn{border-color:color-mix(in oklab,var(--dsw-alias-state-warn-primary,#d48806) 35%,var(--wb-line))}",
383
+ ".wb-cloud.warn .wb-cloud-dot{background:var(--dsw-alias-state-warn-primary,#d48806);opacity:1}",
384
+ ".wb-cloud.syncing .wb-cloud-dot{background:var(--dsw-alias-brand-primary,#11a89b);opacity:1;animation:wb-cloud-pulse 1.2s ease-in-out infinite}",
385
+ "@keyframes wb-cloud-pulse{0%,100%{box-shadow:0 0 0 0 color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 0%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 18%,transparent)}}",
386
+ "@media (prefers-reduced-motion:reduce){.wb-cloud.syncing .wb-cloud-dot{animation:none}}",
387
+ ".wb-tabs{display:flex;gap:6px;border-bottom:1px solid var(--wb-line);margin-bottom:2px}",
388
+ ".wb-tab{border:none;background:transparent;color:inherit;opacity:.6;padding:9px 14px;cursor:pointer;font-size:13px;border-bottom:2px solid transparent;margin-bottom:-1px;transition:opacity .15s ease,border-color .15s ease}",
389
+ ".wb-tab:hover{opacity:.9}",
390
+ ".wb-tab.on{opacity:1;border-bottom-color:var(--dsw-alias-brand-primary,#11a89b);font-weight:600}",
391
+ ".wb-card{background:var(--wb-surface);border:1px solid var(--wb-line);border-radius:12px;padding:14px 16px}",
392
+ ".wb-form{display:flex;gap:8px;align-items:center;background:var(--wb-surface);border:1px solid var(--wb-line);border-radius:12px;padding:10px;flex-wrap:wrap}",
393
+ ".wb-input,.wb-select{background:transparent;color:inherit;border:1px solid var(--wb-line);border-radius:8px;padding:8px 11px;font-size:13px;outline:none;transition:border-color .15s ease}",
394
+ ".wb-input:focus,.wb-select:focus{border-color:var(--dsw-alias-brand-primary,#11a89b)}",
395
+ ".wb-btn{background:var(--dsw-alias-brand-primary,#11a89b);color:var(--dsw-alias-label-primary-inverted,#fff);border:none;border-radius:8px;padding:8px 16px;cursor:pointer;font-size:13px;font-weight:600;transition:filter .15s ease}",
396
+ ".wb-btn:hover{filter:brightness(1.08)}",
397
+ ".wb-btn:disabled{opacity:.55;cursor:default;filter:none}",
398
+ ".wb-btn.ghost{background:transparent;border:1px solid var(--wb-line);color:inherit;font-weight:400;opacity:.8}",
399
+ ".wb-btn.danger{background:transparent;border:1px solid var(--dsw-alias-state-error-primary,#e5484d);color:var(--dsw-alias-state-error-primary,#e5484d);font-weight:500}",
400
+ ".wb-sec{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:2px 0 0}",
401
+ ".wb-sec h3{margin:0;font-size:13px;font-weight:650;letter-spacing:.2px}",
402
+ ".wb-sec .wb-hint{font-size:11.5px;opacity:.5}",
403
+ ".wb-addon{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:12px 14px;border:1px solid var(--wb-line);border-radius:10px;background:var(--wb-surface)}",
404
+ ".wb-addon+.wb-addon{margin-top:8px}",
405
+ ".wb-addon-main{min-width:0;display:flex;flex-direction:column;gap:2px}",
406
+ ".wb-addon-title{font-weight:600;font-size:13.5px}",
407
+ ".wb-addon-meta{font-size:11.5px;opacity:.52;margin-top:3px;line-height:1.5;word-break:break-word}",
408
+ ".wb-addon-desc{font-size:12px;opacity:.66;margin-top:2px;line-height:1.5}",
409
+ ".wb-actions{display:flex;gap:6px;align-items:center;flex:none;flex-wrap:wrap;justify-content:flex-end}",
410
+ ".wb-badge{font-size:10.5px;padding:2px 7px;border-radius:999px;border:1px solid var(--wb-line);opacity:.7;margin-left:6px;white-space:nowrap}",
411
+ ".wb-err{font-size:12px;color:var(--dsw-alias-state-error-primary,#e5484d);margin-top:4px;line-height:1.5;word-break:break-word}",
412
+ ".wb-msg{font-size:12.5px;opacity:.55;padding:20px 0;text-align:center;line-height:1.6}",
413
+ ".wb-empty-cta{padding:26px 14px}",
414
+ ".wb-stack{display:flex;flex-direction:column;gap:10px}",
415
+ ".wb-home-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(236px,1fr));gap:12px}",
416
+ ".wb-home-card{display:flex;flex-direction:column;gap:6px;text-align:left;background:var(--wb-surface);border:1px solid var(--wb-line);border-radius:14px;padding:16px 16px 14px;color:inherit;font:inherit;cursor:pointer;transition:transform .12s ease,border-color .12s ease,background .12s ease}",
417
+ ".wb-home-card:hover{border-color:var(--dsw-alias-brand-primary,#11a89b);transform:translateY(-1px)}",
418
+ ".wb-home-card:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#11a89b);outline-offset:2px}",
419
+ ".wb-home-top{display:flex;align-items:center;justify-content:space-between;gap:8px}",
420
+ ".wb-home-icon{width:34px;height:34px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 14%,transparent);color:var(--dsw-alias-brand-primary,#11a89b);font-size:16px;font-weight:650;flex:none}",
421
+ ".wb-home-title{font-size:14px;font-weight:650;margin-top:4px;line-height:1.4}",
422
+ ".wb-home-desc{font-size:12px;opacity:.62;line-height:1.55;min-height:34px}",
423
+ ".wb-home-card.dim{opacity:.72}",
424
+ ".wb-home-grid.manage{margin-top:2px}",
425
+ ".wb-wide{max-width:1280px}",
426
+ ".wb-page-head{display:flex;flex-direction:column;gap:8px;padding-bottom:2px}",
427
+ ".wb-page-top{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}",
428
+ ".wb-back{border:1px solid var(--wb-line);background:transparent;color:inherit;border-radius:8px;padding:6px 11px;cursor:pointer;font:inherit;font-size:12px;opacity:.75;display:inline-flex;align-items:center;gap:5px}",
429
+ ".wb-back:hover{opacity:1;border-color:var(--dsw-alias-brand-primary,#11a89b)}",
430
+ ".wb-page-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
431
+ ".wb-page-title h2{margin:0;font-size:19px;font-weight:650;letter-spacing:.2px}",
432
+ ".wb-page-desc{font-size:12px;opacity:.6;line-height:1.5}",
433
+ ".wb-page-tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--wb-line)}",
434
+ ".wb-page-loading{display:flex;flex-direction:column;gap:8px;align-items:flex-start}",
435
+ ".wb-grow{flex:1;min-width:0}",
436
+ ".wb-immersive{position:fixed;inset:0;z-index:700;height:100vh;box-sizing:border-box;padding:var(--dsh-frame-top-clearance,0px) 0 0;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-layer-1,#faf7ea));backdrop-filter:saturate(1.05) blur(10px);overflow:hidden}",
437
+ ".wb-immersive-bar{display:flex;align-items:center;gap:10px;padding:9px 22px;border-bottom:1px solid var(--wb-line);flex:none;background:transparent}",
438
+ ".wb-immersive-title{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:600;opacity:.85}",
439
+ ".wb-immersive-title .wb-home-icon{width:24px;height:24px;border-radius:7px;font-size:12px}",
440
+ ".wb-immersive-main{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:18px 24px 24px}",
441
+ ".wb-immersive-main>.wb-inner{max-width:none}",
442
+ "@media (max-width:760px){.wb-root{padding:16px}.wb-home-grid{grid-template-columns:1fr}.wb-page-title h2{font-size:17px}.wb-immersive{padding:var(--dsh-frame-top-clearance,0px) 0 0}.wb-immersive-bar{padding:8px 14px}.wb-immersive-main{padding:14px 16px 20px}.wb-immersive-title span:not(.wb-home-icon):not(.wb-badge){display:none}}",
443
+ ".wb-backup{display:flex;flex-direction:column;gap:14px}",
444
+ ".wb-backup-item{display:flex;flex-direction:column}",
445
+ ".wb-backup-row{display:flex;align-items:flex-start;gap:10px;padding:11px 13px;border:1px solid var(--wb-line);border-radius:10px;background:var(--wb-surface)}",
446
+ ".wb-backup-row.open{border-radius:10px 10px 0 0}",
447
+ ".wb-backup-row-main{display:flex;align-items:flex-start;gap:10px;flex:1;min-width:0;cursor:pointer}",
448
+ ".wb-backup-row input{margin-top:3px;accent-color:var(--dsw-alias-brand-primary,#11a89b)}",
449
+ ".wb-backup-gear{flex:none;width:28px;height:28px;border-radius:8px;border:1px solid transparent;background:transparent;color:inherit;opacity:.5;cursor:pointer;font-size:14px;line-height:1;display:inline-flex;align-items:center;justify-content:center;padding:0;margin-top:-3px}",
450
+ ".wb-backup-gear:hover,.wb-backup-gear.active{opacity:1;border-color:var(--wb-line);background:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 10%,transparent)}",
451
+ ".wb-backup-config{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:9px 13px 11px;border:1px solid var(--wb-line);border-top:none;border-radius:0 0 10px 10px;margin-top:-1px;background:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 5%,var(--wb-surface))}",
452
+ ".wb-backup-config-label{font-size:12px;font-weight:600;opacity:.8}",
453
+ ".wb-backup-config .wb-select{padding:6px 9px;font-size:12px;background:var(--wb-surface)}",
454
+ ".wb-backup-main{min-width:0;display:flex;flex-direction:column;gap:2px}",
455
+ ".wb-backup-name{font-weight:600;font-size:13px}",
456
+ ".wb-backup-meta{font-size:11.5px;opacity:.52;line-height:1.5}",
457
+ ".wb-backup-table-list{display:flex;flex-direction:column;gap:1px}",
458
+ ".wb-backup-table{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;line-height:1.8;opacity:.62;white-space:nowrap}",
459
+ ".wb-backup-result-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 0;border-top:1px solid var(--wb-line)}",
460
+ ".wb-backup-result-row:first-of-type{border-top:0;padding-top:0}",
461
+ ".wb-backup-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}",
462
+ ".wb-backup-note{font-size:12px;opacity:.6;line-height:1.55}",
463
+ ".wb-backup-report{display:flex;flex-direction:column;gap:8px}",
464
+ ".wb-audit-filters{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end;margin-top:10px}",
465
+ ".wb-audit-field{display:flex;flex:1 1 150px;min-width:0;flex-direction:column;gap:5px;font-size:12px}",
466
+ ".wb-audit-field .wb-input,.wb-audit-field .wb-select{width:100%;min-width:0;box-sizing:border-box;height:36px;padding:6px 9px;font-size:12px}",
467
+ ".wb-audit-summary{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:12px;font-size:12px;overflow-wrap:anywhere}",
468
+ ".wb-audit-summary span{min-width:0}.wb-audit-row:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#11a89b);outline-offset:-2px}",
469
+ "@media(max-width:480px){.wb-audit-field{flex-basis:100%}.wb-audit-pager{flex-wrap:wrap}.wb-audit-filters .wb-btn{flex:1}}",
470
+ ".wb-audit-table{width:100%;border-collapse:collapse;font-size:12px}",
471
+ ".wb-audit-table th{text-align:left;font-weight:600;opacity:.6;padding:6px 8px;border-bottom:1px solid var(--wb-line);white-space:nowrap}",
472
+ ".wb-audit-table td{padding:7px 8px;border-bottom:1px solid var(--wb-line);vertical-align:top}",
473
+ ".wb-audit-row{cursor:pointer}",
474
+ ".wb-audit-row:hover td{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 5%,transparent)}",
475
+ ".wb-audit-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px}",
476
+ ".wb-audit-ok{color:#1a9c6a;font-weight:600}",
477
+ ".wb-audit-fail{color:#d0483c;font-weight:600}",
478
+ ".wb-audit-dim{opacity:.55}",
479
+ ".wb-audit-pre{white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.6;background:color-mix(in oklab,var(--wb-line) 18%,transparent);border-radius:8px;padding:9px 11px;margin:6px 0 4px}",
480
+ ".wb-audit-pager{display:flex;align-items:center;gap:10px;margin-top:12px}",
481
+ ".wb-backup-table{width:100%;border-collapse:collapse;font-size:12px}",
482
+ ".wb-backup-table th,.wb-backup-table td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--wb-line);vertical-align:top}",
483
+ ".wb-backup-table th{font-weight:600;opacity:.66;font-size:11.5px}",
484
+ ".wb-backup-table td.num{white-space:nowrap;opacity:.8}",
485
+ ".wb-backup-status{font-weight:600}",
486
+ ".wb-backup-status.ok{color:var(--dsw-alias-state-success-primary,#18a058)}",
487
+ ".wb-backup-status.partial{color:var(--dsw-alias-state-warn-primary,#d48806)}",
488
+ ".wb-backup-status.failed{color:var(--dsw-alias-state-error-primary,#e5484d)}",
489
+ ".wb-backup-status.skipped{opacity:.55}",
490
+ ".wb-backup-file{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}",
491
+ ".wb-sync-status{display:flex;gap:16px;flex-wrap:wrap;font-size:12px;opacity:.7;margin-top:10px;line-height:1.6}",
492
+ ".wb-sync-status b{font-weight:600;opacity:.9}",
493
+ ".wb-conflict{display:flex;align-items:center;gap:10px;justify-content:space-between;flex-wrap:wrap;padding:9px 0;border-top:1px solid var(--wb-line);font-size:12px}",
494
+ ".wb-conflict:first-of-type{border-top:0;padding-top:0}",
495
+ ".wb-conflict-main{min-width:0;display:flex;flex-direction:column;gap:2px}",
496
+ ".wb-conflict-meta{font-size:11px;opacity:.55;word-break:break-word}",
497
+ ".wb-conflict-actions{display:flex;gap:6px;flex:none}",
498
+ ".wb-record-pill{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border:1px solid var(--wb-line,var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent)));border-radius:999px;background:color-mix(in oklab,currentColor 3%,transparent);color:inherit;cursor:pointer;font:inherit;font-size:12px;line-height:1;opacity:.62;white-space:nowrap;transition:opacity .15s ease,border-color .15s ease,background .15s ease}",
499
+ ".wb-record-pill:hover{opacity:.95;border-color:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 35%,var(--wb-line,var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent))))}",
500
+ ".wb-record-pill.on{opacity:1;border-color:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 45%,transparent);background:color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 10%,transparent)}",
501
+ ".wb-record-pill:disabled{opacity:.4;cursor:default}",
502
+ ".wb-record-pill.err{opacity:1;border-color:var(--dsw-alias-state-error-primary,#e5484d);color:var(--dsw-alias-state-error-primary,#e5484d)}",
503
+ ".wb-record-pill.err .wb-record-dot{background:currentColor;opacity:1}",
504
+ ".wb-record-dot{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.5;flex:none}",
505
+ ".wb-record-pill.on .wb-record-dot{background:var(--dsw-alias-brand-primary,#11a89b);opacity:1;box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,#11a89b) 18%,transparent)}"
506
+ ].join("\n");
507
+ module2.exports = CSS2;
508
+ }
509
+ });
510
+
511
+ // packages/shell/client/system-tabs.cjs
512
+ var require_system_tabs = __commonJS({
513
+ "packages/shell/client/system-tabs.cjs"(exports2, module2) {
514
+ "use strict";
515
+ module2.exports = function createSystemTabs(react2, jsx2, useApi2) {
516
+ function AccountTab2(props) {
517
+ var t = props.t;
518
+ var api = useApi2();
519
+ var st = react2.useState(null);
520
+ var me = st[0];
521
+ var setMe = st[1];
522
+ var st2 = react2.useState({ email: "", password: "", signup: false });
523
+ var form = st2[0];
524
+ var setForm = st2[1];
525
+ var st3 = react2.useState("");
526
+ var msg = st3[0];
527
+ var setMsg = st3[1];
528
+ var st4 = react2.useState(false);
529
+ var syncing = st4[0];
530
+ var setSyncing = st4[1];
531
+ var st5 = react2.useState(null);
532
+ var syncStatus = st5[0];
533
+ var setSyncStatus = st5[1];
534
+ var st6 = react2.useState([]);
535
+ var conflicts = st6[0];
536
+ var setConflicts = st6[1];
537
+ function refreshSync() {
538
+ api.get("/sync/status").then(function(r) {
539
+ if (r && r.ok) setSyncStatus(r);
540
+ });
541
+ api.get("/sync/conflicts?limit=20").then(function(r) {
542
+ setConflicts(r && Array.isArray(r.conflicts) ? r.conflicts : []);
543
+ });
544
+ }
545
+ function refresh() {
546
+ api.get("/account").then(function(r) {
547
+ setMe(r);
548
+ if (r && r.logged_in) refreshSync();
549
+ });
550
+ }
551
+ react2.useEffect(function() {
552
+ refresh();
553
+ }, []);
554
+ react2.useEffect(function() {
555
+ if (!me || !me.logged_in) return void 0;
556
+ var es = new EventSource("/workbench/api/events");
557
+ function onSync() {
558
+ refreshSync();
559
+ }
560
+ es.addEventListener("sync-done", onSync);
561
+ es.addEventListener("sync-status", onSync);
562
+ return function() {
563
+ es.close();
564
+ };
565
+ }, [me && me.logged_in]);
566
+ function submit() {
567
+ api.post("/account/login", { email: form.email, password: form.password, signup: form.signup }).then(function(r) {
568
+ setMsg(r.ok ? "" : r.error || "failed");
569
+ refresh();
570
+ });
571
+ }
572
+ function resolve(id, action) {
573
+ api.post("/sync/conflicts/" + id + "/resolve", { action }).then(function(r) {
574
+ if (!r || !r.ok) setMsg(t("sync_resolve_failed"));
575
+ refreshSync();
576
+ });
577
+ }
578
+ if (!me) return jsx2.jsx("div", { className: "wb-card", children: jsx2.jsx("span", { className: "wb-msg", children: "\u2026" }) });
579
+ if (!me.logged_in) {
580
+ return jsx2.jsxs("div", { className: "wb-card", children: [
581
+ jsx2.jsx("div", { className: "wb-msg", style: { marginBottom: 10 }, children: t("not_logged_in") }),
582
+ jsx2.jsxs("div", { className: "wb-form", children: [
583
+ jsx2.jsx("input", { className: "wb-input", placeholder: t("email"), value: form.email, onChange: function(e) {
584
+ setForm(Object.assign({}, form, { email: e.target.value }));
585
+ } }),
586
+ jsx2.jsx("input", { className: "wb-input", type: "password", placeholder: t("password"), value: form.password, onChange: function(e) {
587
+ setForm(Object.assign({}, form, { password: e.target.value }));
588
+ }, onKeyDown: function(e) {
589
+ if (e.key === "Enter") submit();
590
+ } }),
591
+ jsx2.jsx("label", { className: "wb-msg", children: jsx2.jsxs("span", { children: [
592
+ jsx2.jsx("input", { type: "checkbox", checked: form.signup, onChange: function(e) {
593
+ setForm(Object.assign({}, form, { signup: e.target.checked }));
594
+ } }),
595
+ " ",
596
+ t("signup")
597
+ ] }) }),
598
+ jsx2.jsx("button", { className: "wb-btn", onClick: submit, children: form.signup ? t("signup") : t("login") })
599
+ ] }),
600
+ msg ? jsx2.jsx("div", { className: "wb-err", style: { marginTop: 8 }, children: msg }) : null
601
+ ] });
602
+ }
603
+ var failed = syncStatus && Array.isArray(syncStatus.failed_tables) ? syncStatus.failed_tables : [];
604
+ return jsx2.jsxs("div", { className: "wb-stack", children: [
605
+ jsx2.jsxs("div", { className: "wb-card", children: [
606
+ jsx2.jsxs("div", { children: [t("logged_in_as"), " ", me.user ? me.user.email : "", " (", t("device_name"), ")"] }),
607
+ jsx2.jsxs("div", { className: "wb-form", style: { marginTop: 10 }, children: [
608
+ jsx2.jsx("button", { className: "wb-btn", disabled: syncing, onClick: function() {
609
+ setSyncing(true);
610
+ api.post("/sync/now").then(function(r) {
611
+ setSyncing(false);
612
+ if (r && r.ok && Array.isArray(r.failed_tables) && r.failed_tables.length) {
613
+ setMsg(t("sync_partial") + ": " + r.failed_tables.join(", "));
614
+ } else {
615
+ setMsg(r && r.ok ? t("sync_ok") + " \xB7 " + t("sync_pushed") + " " + r.pushed + " \xB7 " + t("sync_pulled") + " " + r.pulled : r && r.error || "fail");
616
+ }
617
+ refreshSync();
618
+ });
619
+ }, children: syncing ? "\u2026" : t("sync_now") }),
620
+ jsx2.jsx("button", { className: "wb-btn ghost", onClick: function() {
621
+ api.post("/account/logout").then(refresh);
622
+ }, children: t("logout") })
623
+ ] }),
624
+ msg ? jsx2.jsx("div", { className: "wb-msg", style: { marginTop: 8 }, children: msg }) : null,
625
+ syncStatus ? jsx2.jsxs("div", { className: "wb-sync-status", children: [
626
+ jsx2.jsxs("span", { children: [t("sync_last"), ": ", jsx2.jsx("b", { children: syncStatus.last_sync_at ? new Date(syncStatus.last_sync_at).toLocaleString() : t("sync_never") })] }),
627
+ jsx2.jsxs("span", { children: [t("sync_conflicts"), ": ", jsx2.jsx("b", { children: syncStatus.conflicts || 0 })] }),
628
+ failed.length ? jsx2.jsxs("span", { children: [t("sync_failed_tables"), ": ", jsx2.jsx("b", { children: failed.join(", ") })] }) : null,
629
+ syncStatus.clock_offset ? jsx2.jsxs("span", { children: [t("sync_clock"), ": ", jsx2.jsx("b", { children: syncStatus.clock_offset + "ms" })] }) : null
630
+ ] }) : null
631
+ ] }),
632
+ jsx2.jsxs("div", { className: "wb-card", children: [
633
+ jsx2.jsxs("div", { className: "wb-sec", children: [
634
+ jsx2.jsx("h3", { children: t("sync_conflicts") + " (" + conflicts.length + ")" }),
635
+ jsx2.jsx("span", { className: "wb-hint", children: t("sync_conflict_hint") })
636
+ ] }),
637
+ conflicts.length ? conflicts.map(function(c) {
638
+ return jsx2.jsxs("div", { className: "wb-conflict", children: [
639
+ jsx2.jsxs("div", { className: "wb-conflict-main", children: [
640
+ jsx2.jsx("div", { children: (c.table_name || "") + " \xB7 " + (c.row_id || "") }),
641
+ jsx2.jsx("div", { className: "wb-conflict-meta", children: (c.kind || "") + (c.server_updated_at ? " \xB7 " + new Date(c.server_updated_at).toLocaleString() : "") })
642
+ ] }),
643
+ jsx2.jsxs("div", { className: "wb-conflict-actions", children: [
644
+ jsx2.jsx("button", { className: "wb-btn ghost", onClick: function() {
645
+ resolve(c.id, "keep_local");
646
+ }, children: t("sync_keep_local") }),
647
+ jsx2.jsx("button", { className: "wb-btn ghost", onClick: function() {
648
+ resolve(c.id, "keep_server");
649
+ }, children: t("sync_keep_server") }),
650
+ jsx2.jsx("button", { className: "wb-btn ghost", onClick: function() {
651
+ resolve(c.id, "dismiss");
652
+ }, children: t("sync_dismiss") })
653
+ ] })
654
+ ] }, c.id);
655
+ }) : jsx2.jsx("div", { className: "wb-msg", children: t("sync_no_conflicts") })
656
+ ] })
657
+ ] });
658
+ }
659
+ function BackupTab2(props) {
660
+ var t = props.t;
661
+ var lang = props.lang;
662
+ var addons = props.addons || [];
663
+ var exportable = addons.filter(function(a) {
664
+ return a && a.backup && a.backup.export;
665
+ });
666
+ var idsKey = exportable.map(function(a) {
667
+ return a.id;
668
+ }).join(",");
669
+ var st = react2.useState({});
670
+ var selected = st[0];
671
+ var setSelected = st[1];
672
+ var st2 = react2.useState("");
673
+ var busy = st2[0];
674
+ var setBusy = st2[1];
675
+ var st3 = react2.useState("");
676
+ var msg = st3[0];
677
+ var setMsg = st3[1];
678
+ var st4 = react2.useState(null);
679
+ var report = st4[0];
680
+ var setReport = st4[1];
681
+ var st5 = react2.useState(null);
682
+ var exported = st5[0];
683
+ var setExported = st5[1];
684
+ var st6 = react2.useState({});
685
+ var policies = st6[0];
686
+ var setPolicies = st6[1];
687
+ var st7 = react2.useState({});
688
+ var openConfig = st7[0];
689
+ var setOpenConfig = st7[1];
690
+ var fileRef = react2.useRef(null);
691
+ react2.useEffect(function() {
692
+ setSelected(function(prev) {
693
+ var next = {};
694
+ var changed = false;
695
+ exportable.forEach(function(a) {
696
+ if (prev[a.id]) next[a.id] = true;
697
+ else next[a.id] = true;
698
+ if (!prev[a.id]) changed = true;
699
+ });
700
+ Object.keys(prev).forEach(function(id) {
701
+ if (!exportable.some(function(a) {
702
+ return a.id === id;
703
+ })) changed = true;
704
+ });
705
+ return changed ? next : prev;
706
+ });
707
+ }, [idsKey]);
708
+ var allSelected = exportable.length > 0 && exportable.every(function(a) {
709
+ return selected[a.id];
710
+ });
711
+ function toggle(id) {
712
+ var next = Object.assign({}, selected);
713
+ next[id] = !next[id];
714
+ setSelected(next);
715
+ }
716
+ function selectAll(flag) {
717
+ var next = {};
718
+ exportable.forEach(function(a) {
719
+ next[a.id] = flag;
720
+ });
721
+ setSelected(next);
722
+ }
723
+ function policyOf(id) {
724
+ return policies[id] || "newest";
725
+ }
726
+ function policyLabel(policy) {
727
+ if (policy === "skip") return t("backup_dup_skip");
728
+ if (policy === "overwrite") return t("backup_dup_overwrite");
729
+ return t("backup_dup_newest");
730
+ }
731
+ function setPolicy(id, value) {
732
+ setPolicies(function(prev) {
733
+ var next = Object.assign({}, prev);
734
+ next[id] = value;
735
+ return next;
736
+ });
737
+ }
738
+ function toggleConfig(id) {
739
+ setOpenConfig(function(prev) {
740
+ var next = Object.assign({}, prev);
741
+ next[id] = !next[id];
742
+ return next;
743
+ });
744
+ }
745
+ function statusLabel(status) {
746
+ if (status === "ok") return t("backup_ok");
747
+ if (status === "partial") return t("backup_partial");
748
+ if (status === "skipped") return t("backup_skipped_status");
749
+ return t("backup_failed_status");
750
+ }
751
+ function doExport() {
752
+ if (busy) return;
753
+ var chosen = exportable.filter(function(a) {
754
+ return selected[a.id];
755
+ });
756
+ var ids = chosen.map(function(a) {
757
+ return a.id;
758
+ });
759
+ if (!ids.length) {
760
+ setMsg(t("backup_select_required"));
761
+ return;
762
+ }
763
+ setBusy("export");
764
+ setMsg("");
765
+ setReport(null);
766
+ setExported(null);
767
+ var url = "/workbench/api/backup/export?modules=" + ids.map(encodeURIComponent).join(",");
768
+ fetch(url).then(function(r) {
769
+ if (!r.ok) {
770
+ return r.json().catch(function() {
771
+ return {};
772
+ }).then(function(j) {
773
+ throw new Error(j && j.error || "HTTP " + r.status);
774
+ });
775
+ }
776
+ var cd = r.headers.get("content-disposition") || "";
777
+ var m = /filename="?([^";]+)"?/.exec(cd);
778
+ var name = m ? m[1] : "dsh-workbench-backup.zip";
779
+ return r.blob().then(function(blob) {
780
+ var href = URL.createObjectURL(blob);
781
+ var a = document.createElement("a");
782
+ a.href = href;
783
+ a.download = name;
784
+ document.body.appendChild(a);
785
+ a.click();
786
+ a.remove();
787
+ setTimeout(function() {
788
+ URL.revokeObjectURL(href);
789
+ }, 1500);
790
+ setMsg(t("backup_download_started"));
791
+ var rows = [];
792
+ chosen.forEach(function(a2) {
793
+ var tables = a2.tables || [];
794
+ if (!tables.length) rows.push({ id: a2.id + ":*", table: "\u2014", module: a2.title || a2.id, version: a2.version });
795
+ tables.forEach(function(table) {
796
+ rows.push({ id: a2.id + ":" + table, table, module: a2.title || a2.id, version: a2.version });
797
+ });
798
+ });
799
+ setExported(rows);
800
+ });
801
+ }).catch(function(e) {
802
+ setMsg(t("backup_export_failed") + ": " + String(e && e.message || e));
803
+ }).then(function() {
804
+ setBusy("");
805
+ });
806
+ }
807
+ function doImport(ev) {
808
+ var file = ev.target.files && ev.target.files[0];
809
+ ev.target.value = "";
810
+ if (!file || busy) return;
811
+ setBusy("import");
812
+ setMsg("");
813
+ setReport(null);
814
+ var policyMap = {};
815
+ exportable.forEach(function(a) {
816
+ policyMap[a.id] = policyOf(a.id);
817
+ });
818
+ fetch("/workbench/api/backup/import", { method: "POST", headers: { "content-type": "application/zip", "x-wb-backup-policy": JSON.stringify(policyMap) }, body: file }).then(function(r) {
819
+ if (r.status === 422) {
820
+ return r.json().catch(function() {
821
+ return {};
822
+ }).then(function() {
823
+ setMsg(t("backup_incompatible"));
824
+ return null;
825
+ });
826
+ }
827
+ return r.json().catch(function() {
828
+ return null;
829
+ }).then(function(j) {
830
+ if (!r.ok) throw new Error(j && j.error || "HTTP " + r.status);
831
+ if (!j) throw new Error(t("backup_invalid"));
832
+ setReport(j);
833
+ setMsg(j.ok ? t("backup_import_done") : t("backup_import_result"));
834
+ return j;
835
+ });
836
+ }).catch(function(e) {
837
+ setMsg(t("backup_import_failed") + ": " + String(e && e.message || e));
838
+ }).then(function() {
839
+ setBusy("");
840
+ });
841
+ }
842
+ function moduleCaps(a) {
843
+ var caps = [];
844
+ if (a.backup && a.backup.export) caps.push(t("backup_cap_export"));
845
+ if (a.backup && a.backup.import) caps.push(t("backup_cap_import"));
846
+ return caps.join(" \xB7 ");
847
+ }
848
+ return jsx2.jsxs("div", { className: "wb-backup", children: [
849
+ jsx2.jsxs("div", { className: "wb-card", children: [
850
+ jsx2.jsxs("div", { className: "wb-sec", children: [
851
+ jsx2.jsx("h3", { children: t("backup_modules") }),
852
+ jsx2.jsxs("div", { className: "wb-backup-actions", children: [
853
+ jsx2.jsx("button", { className: "wb-btn ghost", disabled: !exportable.length, onClick: function() {
854
+ selectAll(true);
855
+ }, children: t("backup_select_all") }),
856
+ jsx2.jsx("button", { className: "wb-btn ghost", disabled: !exportable.length, onClick: function() {
857
+ selectAll(false);
858
+ }, children: t("backup_clear") })
859
+ ] })
860
+ ] }),
861
+ exportable.length ? jsx2.jsx("div", { className: "wb-stack", style: { marginTop: 10 }, children: exportable.map(function(a) {
862
+ var open = !!openConfig[a.id];
863
+ return jsx2.jsxs(react2.Fragment, { children: [
864
+ jsx2.jsxs("div", { className: "wb-backup-row" + (open ? " open" : ""), children: [
865
+ jsx2.jsxs("label", { className: "wb-backup-row-main", children: [
866
+ jsx2.jsx("input", { type: "checkbox", checked: !!selected[a.id], onChange: function() {
867
+ toggle(a.id);
868
+ } }),
869
+ jsx2.jsxs("span", { className: "wb-backup-main", children: [
870
+ jsx2.jsxs("span", { className: "wb-backup-name", children: [a.title || a.id, jsx2.jsx("span", { className: "wb-badge", children: "v" + (a.version || "?") })] }),
871
+ jsx2.jsx("span", { className: "wb-backup-meta", children: moduleCaps(a) }),
872
+ a.description ? jsx2.jsx("span", { className: "wb-backup-meta", children: a.description }) : null
873
+ ] })
874
+ ] }),
875
+ jsx2.jsx("button", {
876
+ type: "button",
877
+ className: "wb-backup-gear" + (open ? " active" : ""),
878
+ title: t("backup_dup_policy"),
879
+ "aria-label": t("backup_dup_policy"),
880
+ "aria-expanded": open,
881
+ onClick: function() {
882
+ toggleConfig(a.id);
883
+ },
884
+ children: "\u2699"
885
+ })
886
+ ] }),
887
+ open ? jsx2.jsxs("div", { className: "wb-backup-config", children: [
888
+ jsx2.jsx("span", { className: "wb-backup-config-label", children: t("backup_dup_policy") }),
889
+ jsx2.jsx("select", {
890
+ className: "wb-select",
891
+ value: policyOf(a.id),
892
+ onChange: function(e) {
893
+ setPolicy(a.id, e.target.value);
894
+ },
895
+ children: [
896
+ jsx2.jsx("option", { value: "newest", children: t("backup_dup_newest") }),
897
+ jsx2.jsx("option", { value: "skip", children: t("backup_dup_skip") }),
898
+ jsx2.jsx("option", { value: "overwrite", children: t("backup_dup_overwrite") })
899
+ ]
900
+ }),
901
+ jsx2.jsx("span", { className: "wb-backup-note", children: t("backup_dup_hint") })
902
+ ] }) : null
903
+ ] }, a.id);
904
+ }) }) : jsx2.jsx("div", { className: "wb-msg", children: t("backup_no_modules") }),
905
+ jsx2.jsxs("div", { className: "wb-backup-actions", style: { marginTop: 12 }, children: [
906
+ jsx2.jsx("button", { className: "wb-btn", disabled: !!busy || !exportable.length, onClick: doExport, children: busy === "export" ? t("backup_exporting") : t("backup_export") }),
907
+ jsx2.jsx("button", { className: "wb-btn ghost", disabled: !!busy, onClick: function() {
908
+ if (fileRef.current) fileRef.current.click();
909
+ }, children: busy === "import" ? t("backup_importing") : t("backup_import") }),
910
+ jsx2.jsx("span", { className: "wb-backup-note", children: t("backup_file_hint") })
911
+ ] }),
912
+ jsx2.jsx("input", { ref: fileRef, type: "file", accept: ".zip,application/zip", className: "wb-backup-file", onChange: doImport }),
913
+ msg ? jsx2.jsx("div", { className: "wb-msg", style: { textAlign: "left", padding: "10px 0 0", opacity: 0.8 }, children: msg }) : null
914
+ ] }),
915
+ exported ? jsx2.jsxs("div", { className: "wb-card wb-backup-report", children: [
916
+ jsx2.jsxs("div", { className: "wb-sec", children: [
917
+ jsx2.jsx("h3", { children: t("backup_export_result") }),
918
+ jsx2.jsx("span", { className: "wb-hint", children: t("backup_download_started") })
919
+ ] }),
920
+ jsx2.jsx("div", { className: "wb-stack", children: exported.map(function(a) {
921
+ return jsx2.jsxs("div", { className: "wb-backup-result-row", children: [
922
+ jsx2.jsx("span", { className: "wb-backup-table", children: a.table }),
923
+ jsx2.jsxs("span", { className: "wb-backup-meta", children: [a.module, jsx2.jsx("span", { className: "wb-badge", children: "v" + (a.version || "?") })] })
924
+ ] }, a.id);
925
+ }) })
926
+ ] }) : null,
927
+ report ? jsx2.jsxs("div", { className: "wb-card wb-backup-report", children: [
928
+ jsx2.jsxs("div", { className: "wb-sec", children: [
929
+ jsx2.jsx("h3", { children: t("backup_import_result") }),
930
+ jsx2.jsxs("span", { className: "wb-hint", children: [
931
+ t("backup_summary"),
932
+ ": ",
933
+ t("backup_ok") + " " + report.summary.ok + " \xB7 ",
934
+ t("backup_partial") + " " + report.summary.partial + " \xB7 ",
935
+ t("backup_failed") + " " + report.summary.failed + " \xB7 ",
936
+ t("backup_skipped") + " " + report.summary.skipped
937
+ ] })
938
+ ] }),
939
+ jsx2.jsxs("div", { className: "wb-backup-meta", children: [
940
+ t("backup_exported_at") + ": " + (report.exportedAt || "?"),
941
+ " \xB7 " + t("backup_shell_version") + ": " + (report.shellVersion || "?"),
942
+ " \xB7 " + t("backup_format") + ": v" + report.formatVersion
943
+ ] }),
944
+ jsx2.jsx("table", { className: "wb-backup-table", children: [
945
+ jsx2.jsxs("thead", { children: [
946
+ jsx2.jsxs("tr", { children: [
947
+ jsx2.jsx("th", { children: t("backup_detail") }),
948
+ jsx2.jsx("th", { children: t("backup_status") }),
949
+ jsx2.jsx("th", { children: t("backup_policy") }),
950
+ jsx2.jsx("th", { children: t("backup_imported") }),
951
+ jsx2.jsx("th", { children: t("backup_skipped") }),
952
+ jsx2.jsx("th", { children: t("backup_failed") })
953
+ ] })
954
+ ] }),
955
+ jsx2.jsxs("tbody", { children: (report.results || []).map(function(r) {
956
+ return jsx2.jsxs("tr", { children: [
957
+ jsx2.jsxs("td", { children: [
958
+ jsx2.jsx("div", { children: r.title || r.id }),
959
+ r.message ? jsx2.jsx("div", { className: "wb-backup-meta", children: r.message }) : null
960
+ ] }),
961
+ jsx2.jsx("td", { children: jsx2.jsx("span", { className: "wb-backup-status " + r.status, children: statusLabel(r.status) }) }),
962
+ jsx2.jsx("td", { className: "wb-backup-meta", children: policyLabel(r.policy) }),
963
+ jsx2.jsx("td", { className: "num", children: r.imported || 0 }),
964
+ jsx2.jsx("td", { className: "num", children: r.skipped || 0 }),
965
+ jsx2.jsx("td", { className: "num", children: r.failed || 0 })
966
+ ] }, r.id);
967
+ }) })
968
+ ] })
969
+ ] }) : null
970
+ ] });
971
+ }
972
+ function AuditTab2(props) {
973
+ var t = props.t;
974
+ var fst = react2.useState({ action: "", actor: "", ok: "", q: "", since: "", until: "" });
975
+ var filters = fst[0];
976
+ var setFilters = fst[1];
977
+ var pst = react2.useState(1);
978
+ var page = pst[0];
979
+ var setPage = pst[1];
980
+ var zst = react2.useState(50);
981
+ var pageSize = zst[0];
982
+ var setPageSize = zst[1];
983
+ var dst = react2.useState(null);
984
+ var data = dst[0];
985
+ var setData = dst[1];
986
+ var sst = react2.useState(null);
987
+ var stats = sst[0];
988
+ var setStats = sst[1];
989
+ var bst = react2.useState(false);
990
+ var busy = bst[0];
991
+ var setBusy = bst[1];
992
+ var est = react2.useState("");
993
+ var err = est[0];
994
+ var setErr = est[1];
995
+ var ost = react2.useState(null);
996
+ var openId = ost[0];
997
+ var setOpenId = ost[1];
998
+ var latest = react2.useRef(0);
999
+ var currentFilters = react2.useRef(filters);
1000
+ function query(p, size, filters2) {
1001
+ var qs = new URLSearchParams();
1002
+ if (filters2.action) qs.set("actionPrefix", filters2.action);
1003
+ if (filters2.actor) qs.set("actor", filters2.actor);
1004
+ if (filters2.ok !== "") qs.set("ok", filters2.ok);
1005
+ if (filters2.q) qs.set("q", filters2.q);
1006
+ if (filters2.since) qs.set("since", filters2.since);
1007
+ if (filters2.until) qs.set("until", filters2.until);
1008
+ qs.set("page", String(p));
1009
+ qs.set("pageSize", String(size || pageSize));
1010
+ qs.set("stats", "1");
1011
+ qs.set("rangeDays", "30");
1012
+ return qs.toString();
1013
+ }
1014
+ function load(p, size, selected) {
1015
+ var request = ++latest.current;
1016
+ setData(null);
1017
+ setOpenId(null);
1018
+ setPage(p || page);
1019
+ setBusy(true);
1020
+ setErr("");
1021
+ fetch("/workbench/api/audit?" + query(p || page, size, selected || currentFilters.current)).then(function(r) {
1022
+ return r.json();
1023
+ }).then(function(j) {
1024
+ if (request !== latest.current) return;
1025
+ if (!j || j.ok === false) throw new Error(j && j.error || t("audit_load_failed"));
1026
+ setData(j);
1027
+ setStats(j.stats || null);
1028
+ setPage(j.page || 1);
1029
+ }).catch(function(e) {
1030
+ if (request === latest.current) setErr(String(e && e.message || e));
1031
+ }).then(function() {
1032
+ if (request === latest.current) setBusy(false);
1033
+ });
1034
+ }
1035
+ react2.useEffect(function() {
1036
+ load(1);
1037
+ return function() {
1038
+ latest.current++;
1039
+ };
1040
+ }, []);
1041
+ function applyFilters(next) {
1042
+ currentFilters.current = next;
1043
+ setFilters(next);
1044
+ load(1, pageSize, next);
1045
+ }
1046
+ function field(key, value) {
1047
+ applyFilters(Object.assign({}, currentFilters.current, { [key]: value }));
1048
+ }
1049
+ function clearFilters() {
1050
+ applyFilters({ action: "", actor: "", ok: "", q: "", since: "", until: "" });
1051
+ }
1052
+ function search() {
1053
+ load(1);
1054
+ }
1055
+ function setSize(n) {
1056
+ var size = Math.max(10, Math.min(200, Number(n) || 50));
1057
+ setPageSize(size);
1058
+ load(1, size);
1059
+ }
1060
+ function fmtTime(ms) {
1061
+ try {
1062
+ var d = new Date(Number(ms));
1063
+ return d.toLocaleString();
1064
+ } catch (e) {
1065
+ return String(ms);
1066
+ }
1067
+ }
1068
+ function shortJson(text, limit) {
1069
+ if (!text) return "";
1070
+ return String(text).length > (limit || 400) ? String(text).slice(0, limit || 400) + "\u2026" : String(text);
1071
+ }
1072
+ var active = Object.keys(filters).filter(function(key) {
1073
+ return filters[key] !== "";
1074
+ });
1075
+ var labels = { action: "audit_action_prefix", actor: "audit_actor", ok: "audit_ok", q: "audit_q", since: "audit_since", until: "audit_until" };
1076
+ function labeled(key, control) {
1077
+ return jsx2.jsxs("label", { className: "wb-audit-field", children: [jsx2.jsx("span", { children: t(labels[key]) }), control] }, key);
1078
+ }
1079
+ var summary = active.map(function(key) {
1080
+ return t(labels[key]) + "=" + (key === "ok" ? t(filters.ok === "true" ? "audit_ok_only" : "audit_fail_only") : filters[key]);
1081
+ }).join(" \xB7 ");
1082
+ var records = data && data.records || [];
1083
+ var total = data ? data.total : 0;
1084
+ var totalPages = Math.max(1, Math.ceil(total / pageSize));
1085
+ var statsText = stats ? t("audit_stats") + "\uFF1A" + totalOf(stats) + " \xB7 " + t("audit_failed") + " " + (stats.failed || 0) : "";
1086
+ function totalOf(s) {
1087
+ return t("audit_total") + " " + (s.total || 0);
1088
+ }
1089
+ return jsx2.jsxs(react2.Fragment, { children: [
1090
+ jsx2.jsxs("div", { className: "wb-card", children: [
1091
+ jsx2.jsxs("div", { className: "wb-sec", children: [
1092
+ jsx2.jsx("h3", { children: t("audit_filters") }),
1093
+ jsx2.jsx("span", { className: "wb-hint", children: statsText })
1094
+ ] }),
1095
+ jsx2.jsxs("form", { className: "wb-audit-filters", onSubmit: function(e) {
1096
+ e.preventDefault();
1097
+ search();
1098
+ }, children: [
1099
+ labeled("action", jsx2.jsx("input", { className: "wb-input", placeholder: t("audit_action_prefix"), value: filters.action, onChange: function(e) {
1100
+ field("action", e.target.value);
1101
+ } })),
1102
+ labeled("actor", jsx2.jsx("select", { className: "wb-select", "aria-label": t("audit_actor"), value: filters.actor, onChange: function(e) {
1103
+ field("actor", e.target.value);
1104
+ }, children: [
1105
+ jsx2.jsx("option", { value: "", children: t("audit_all") + " \xB7 " + t("audit_actor") }),
1106
+ jsx2.jsx("option", { value: "agent", children: "agent" }),
1107
+ jsx2.jsx("option", { value: "ui", children: "ui" }),
1108
+ jsx2.jsx("option", { value: "sync", children: "sync" })
1109
+ ] })),
1110
+ labeled("ok", jsx2.jsx("select", { className: "wb-select", "aria-label": t("audit_ok"), value: filters.ok, onChange: function(e) {
1111
+ field("ok", e.target.value);
1112
+ }, children: [
1113
+ jsx2.jsx("option", { value: "", children: t("audit_all") + " \xB7 " + t("audit_ok") }),
1114
+ jsx2.jsx("option", { value: "true", children: t("audit_ok_only") }),
1115
+ jsx2.jsx("option", { value: "false", children: t("audit_fail_only") })
1116
+ ] })),
1117
+ labeled("q", jsx2.jsx("input", { className: "wb-input", placeholder: t("audit_q"), value: filters.q, onChange: function(e) {
1118
+ field("q", e.target.value);
1119
+ } })),
1120
+ labeled("since", jsx2.jsx("input", { className: "wb-input", type: "date", title: t("audit_since"), value: filters.since, onChange: function(e) {
1121
+ field("since", e.target.value);
1122
+ } })),
1123
+ labeled("until", jsx2.jsx("input", { className: "wb-input", type: "date", title: t("audit_until"), value: filters.until, onChange: function(e) {
1124
+ field("until", e.target.value);
1125
+ } })),
1126
+ jsx2.jsx("button", { className: "wb-btn", type: "submit", disabled: busy, children: busy ? "\u2026" : t("audit_search") }),
1127
+ jsx2.jsx("button", { className: "wb-btn ghost", type: "button", disabled: busy, onClick: function() {
1128
+ load(page);
1129
+ }, children: t("audit_refresh") })
1130
+ ] }),
1131
+ jsx2.jsxs("div", { className: "wb-audit-summary", role: "status", "aria-live": "polite", children: [
1132
+ jsx2.jsx("span", { children: (summary ? t("audit_active") + "\uFF1A" + summary : t("audit_all")) + " \xB7 " + (busy ? t("audit_loading") : err ? t("audit_load_failed") : t("audit_total") + " " + total) }),
1133
+ active.length ? jsx2.jsx("button", { type: "button", className: "wb-btn ghost", onClick: clearFilters, children: t("audit_clear") }) : null
1134
+ ] }),
1135
+ err ? jsx2.jsx("div", { className: "wb-err", style: { marginTop: 10 }, children: err }) : null,
1136
+ jsx2.jsx("div", { className: "wb-hint", style: { marginTop: 10 }, children: t("audit_reads_hint") + " \xB7 " + t("audit_retention") })
1137
+ ] }),
1138
+ jsx2.jsxs("div", { className: "wb-card", children: [
1139
+ jsx2.jsxs("div", { className: "wb-sec", children: [
1140
+ jsx2.jsx("h3", { children: t("tab_audit") }),
1141
+ jsx2.jsx("span", { className: "wb-hint", children: (busy ? t("audit_loading") : err ? t("audit_load_failed") : t("audit_total") + " " + total) + " \xB7 " + page + " / " + totalPages + " " + t("audit_page") })
1142
+ ] }),
1143
+ records.length ? jsx2.jsx("div", { style: { overflowX: "auto" }, children: jsx2.jsxs("table", { className: "wb-audit-table", children: [
1144
+ jsx2.jsx("thead", { children: jsx2.jsxs("tr", { children: [
1145
+ jsx2.jsx("th", { children: t("audit_time") }),
1146
+ jsx2.jsx("th", { children: t("audit_actor") }),
1147
+ jsx2.jsx("th", { children: t("audit_action") }),
1148
+ jsx2.jsx("th", { children: t("audit_ok") }),
1149
+ jsx2.jsx("th", { children: t("audit_target") }),
1150
+ jsx2.jsx("th", { children: t("audit_duration") })
1151
+ ] }) }),
1152
+ jsx2.jsx("tbody", { children: records.map(function(r) {
1153
+ var open = openId === r.id;
1154
+ return jsx2.jsxs(react2.Fragment, { children: [
1155
+ jsx2.jsxs("tr", { className: "wb-audit-row", tabIndex: 0, "aria-expanded": open, onKeyDown: function(e) {
1156
+ if (e.key === "Enter" || e.key === " ") {
1157
+ e.preventDefault();
1158
+ setOpenId(open ? null : r.id);
1159
+ }
1160
+ }, onClick: function() {
1161
+ setOpenId(open ? null : r.id);
1162
+ }, children: [
1163
+ jsx2.jsx("td", { className: "wb-audit-mono", children: fmtTime(r.at) }),
1164
+ jsx2.jsx("td", { children: jsx2.jsx("span", { className: "wb-badge", children: r.actor }) }),
1165
+ jsx2.jsx("td", { className: "wb-audit-mono", children: r.action }),
1166
+ jsx2.jsx("td", { children: r.ok ? jsx2.jsx("span", { className: "wb-audit-ok", children: "\u2713" }) : jsx2.jsx("span", { className: "wb-audit-fail", children: "\u2717" }) }),
1167
+ jsx2.jsx("td", { className: "wb-audit-mono wb-audit-dim", children: r.target || "\u2014" }),
1168
+ jsx2.jsx("td", { className: "wb-audit-dim", children: (r.durationMs || 0) + " ms" })
1169
+ ] }),
1170
+ open ? jsx2.jsx("tr", { children: jsx2.jsx("td", { colSpan: 6, children: jsx2.jsxs("div", { children: [
1171
+ r.error ? jsx2.jsxs("div", { children: [jsx2.jsx("div", { className: "wb-audit-dim", children: t("audit_error") }), jsx2.jsx("div", { className: "wb-audit-pre", children: r.error })] }) : null,
1172
+ jsx2.jsxs("div", { children: [jsx2.jsx("div", { className: "wb-audit-dim", children: t("audit_detail") + " \xB7 id=" + r.id }), jsx2.jsx("div", { className: "wb-audit-pre", children: shortJson(r.args, 1200) || "{}" }), r.result ? jsx2.jsx("div", { className: "wb-audit-pre", children: shortJson(r.result, 1200) }) : null] })
1173
+ ] }) }) }) : null
1174
+ ] }, r.id);
1175
+ }) })
1176
+ ] }) }) : jsx2.jsxs("div", { className: "wb-msg", children: [busy ? t("audit_loading") : err ? t("audit_load_failed") : t("audit_empty"), !busy && !err && active.length ? jsx2.jsx("button", { className: "wb-btn ghost", onClick: clearFilters, children: t("audit_clear") }) : null] }),
1177
+ jsx2.jsxs("div", { className: "wb-audit-pager", children: [
1178
+ jsx2.jsx("button", { className: "wb-btn ghost", disabled: busy || page <= 1, onClick: function() {
1179
+ load(page - 1);
1180
+ }, children: t("audit_prev") }),
1181
+ jsx2.jsx("button", { className: "wb-btn ghost", disabled: busy || page >= totalPages, onClick: function() {
1182
+ load(page + 1);
1183
+ }, children: t("audit_next") }),
1184
+ jsx2.jsx("select", { className: "wb-select", "aria-label": t("audit_page_size"), value: String(pageSize), onChange: function(e) {
1185
+ setSize(e.target.value);
1186
+ }, children: [20, 50, 100, 200].map(function(n) {
1187
+ return jsx2.jsx("option", { value: String(n), children: n + " / " + t("audit_page") }, n);
1188
+ }) })
1189
+ ] })
1190
+ ] })
1191
+ ] });
1192
+ }
1193
+ return { AccountTab: AccountTab2, BackupTab: BackupTab2, AuditTab: AuditTab2 };
1194
+ };
1195
+ }
1196
+ });
1197
+
1198
+ // packages/shell/client/view-tabs.cjs
1199
+ var require_view_tabs = __commonJS({
1200
+ "packages/shell/client/view-tabs.cjs"(exports2, module2) {
1201
+ "use strict";
1202
+ module2.exports = function createViewTabs(react2, pickTitle2) {
1203
+ var h2 = react2.createElement;
1204
+ return function ViewTabs2(props) {
1205
+ if (props.views.length < 2) return null;
1206
+ return h2("div", { className: "wb-page-tabs" }, props.views.map(function(view) {
1207
+ var title = pickTitle2(view.title, props.lang) || view.id;
1208
+ var on = props.activeView && view.id === props.activeView.id;
1209
+ var Icon = typeof view.icon === "function" ? view.icon : null;
1210
+ return h2("button", {
1211
+ key: view.id,
1212
+ type: "button",
1213
+ className: "wb-tab" + (on ? " on" : ""),
1214
+ "aria-label": title,
1215
+ onClick: function() {
1216
+ props.go("addon:" + props.addonId + ":" + view.id);
1217
+ }
1218
+ }, Icon ? h2("span", {
1219
+ "aria-hidden": true,
1220
+ style: { display: "inline-flex", verticalAlign: "middle", marginRight: 6 }
1221
+ }, h2(Icon, { size: 14, strokeWidth: 2, "aria-hidden": true })) : null, title);
1222
+ }));
1223
+ };
1224
+ };
1225
+ }
1226
+ });
1227
+
1228
+ // packages/shell/client/view-outlet.cjs
1229
+ var require_view_outlet = __commonJS({
1230
+ "packages/shell/client/view-outlet.cjs"(exports2, module2) {
1231
+ "use strict";
1232
+ var React = require("react");
1233
+ var h2 = React.createElement;
1234
+ function Slot(props) {
1235
+ var root = React.useRef(null), scroll = React.useRef([]);
1236
+ React.useLayoutEffect(function() {
1237
+ if (!props.active) return;
1238
+ var positions = scroll.current.slice();
1239
+ function restore() {
1240
+ positions.forEach(function(p) {
1241
+ p.node.scrollTop = p.top;
1242
+ p.node.scrollLeft = p.left;
1243
+ });
1244
+ }
1245
+ restore();
1246
+ var frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame(restore) : null;
1247
+ function remember() {
1248
+ var positions2 = [], node = root.current;
1249
+ while (node) {
1250
+ positions2.push({ node, top: node.scrollTop, left: node.scrollLeft });
1251
+ node = node.parentElement;
1252
+ }
1253
+ scroll.current = positions2;
1254
+ }
1255
+ document.addEventListener("scroll", remember, true);
1256
+ return function() {
1257
+ if (frame !== null) cancelAnimationFrame(frame);
1258
+ document.removeEventListener("scroll", remember, true);
1259
+ };
1260
+ }, [props.active]);
1261
+ return h2(
1262
+ "div",
1263
+ { ref: root, hidden: !props.active, "data-view-id": props.view.id },
1264
+ h2(props.view.component, Object.assign({}, props.viewProps, { active: props.active }))
1265
+ );
1266
+ }
1267
+ module2.exports = function ViewOutlet2(props) {
1268
+ var kept = React.useRef({});
1269
+ if (props.view.keepAlive) kept.current[props.view.id] = props;
1270
+ var entries = Object.keys(kept.current).map(function(id) {
1271
+ return kept.current[id];
1272
+ });
1273
+ if (!props.view.keepAlive) entries.push(props);
1274
+ return h2(React.Fragment, null, entries.map(function(entry) {
1275
+ return h2(Slot, { key: entry.view.id, view: entry.view, viewProps: entry.viewProps, active: entry.view.id === props.view.id });
1276
+ }));
1277
+ };
1278
+ }
1279
+ });
1280
+
1281
+ // packages/shell/client/client.src.cjs
1282
+ var react = require("react");
1283
+ var jsx = require("react/jsx-runtime");
1284
+ var h = react.createElement;
1285
+ var NS = "workbench";
1286
+ var LOCALE = require_locale();
1287
+ var CSS = require_styles();
1288
+ var registry = /* @__PURE__ */ new Map();
1289
+ var listeners = /* @__PURE__ */ new Set();
1290
+ var apiCache = /* @__PURE__ */ new Map();
1291
+ var addonState = { addons: [], loaded: false, shellVersion: "" };
1292
+ var storeListeners = /* @__PURE__ */ new Set();
1293
+ var cloudStatusListeners = /* @__PURE__ */ new Set();
1294
+ var recordModes = {};
1295
+ var recordListeners = /* @__PURE__ */ new Set();
1296
+ var stream = null;
1297
+ var lastAddonError = null;
1298
+ function setRecordMode(sessionId, enabled) {
1299
+ if (!sessionId) return;
1300
+ recordModes[sessionId] = !!enabled;
1301
+ recordListeners.forEach(function(fn) {
1302
+ try {
1303
+ fn(sessionId, !!enabled);
1304
+ } catch (e) {
1305
+ console.error(e);
1306
+ }
1307
+ });
1308
+ }
1309
+ function notifyStore() {
1310
+ storeListeners.forEach(function(fn) {
1311
+ try {
1312
+ fn();
1313
+ } catch (e) {
1314
+ console.error(e);
1315
+ }
1316
+ });
1317
+ }
1318
+ function notifyCloudStatus() {
1319
+ cloudStatusListeners.forEach(function(fn) {
1320
+ try {
1321
+ fn();
1322
+ } catch (e) {
1323
+ console.error(e);
1324
+ }
1325
+ });
1326
+ }
1327
+ function broadcast(payload) {
1328
+ listeners.forEach(function(fn) {
1329
+ try {
1330
+ fn(payload);
1331
+ } catch (e) {
1332
+ console.error(e);
1333
+ }
1334
+ });
1335
+ }
1336
+ function apiFor(id) {
1337
+ var cached = apiCache.get(id);
1338
+ if (cached) return cached;
1339
+ var api = {
1340
+ call: function(action, args) {
1341
+ var targetId = id;
1342
+ var name = String(action || "");
1343
+ var dot = name.indexOf(".");
1344
+ if (dot > 0) {
1345
+ var hinted = "wb-addon-" + name.slice(0, dot);
1346
+ if (hinted !== id && registry.has(hinted)) targetId = hinted;
1347
+ }
1348
+ return fetch("/workbench/api/domains/" + encodeURIComponent(targetId) + "/actions/" + encodeURIComponent(action), {
1349
+ method: "POST",
1350
+ headers: { "content-type": "application/json" },
1351
+ body: JSON.stringify(args || {})
1352
+ }).then(function(r) {
1353
+ return r.json();
1354
+ }).catch(function(e) {
1355
+ return { ok: false, error: String(e && e.message || e) };
1356
+ });
1357
+ },
1358
+ // 只读 schema 快照:宿主 /workbench/api/schema 与 actions.list(detail=true) 同源,
1359
+ // 供工作台 Action 页渲染运行时注册;不走 action 执行链路,也不会产生审计记录。
1360
+ schema: function(domain) {
1361
+ var q = domain ? "?domain=" + encodeURIComponent(domain) : "";
1362
+ return fetch("/workbench/api/schema" + q).then(function(r) {
1363
+ return r.json();
1364
+ }).catch(function(e) {
1365
+ return { ok: false, error: String(e && e.message || e) };
1366
+ });
1367
+ },
1368
+ subscribe: function(fn) {
1369
+ listeners.add(fn);
1370
+ return function() {
1371
+ listeners.delete(fn);
1372
+ };
1373
+ }
1374
+ };
1375
+ apiCache.set(id, api);
1376
+ return api;
1377
+ }
1378
+ function registerAddon(mod) {
1379
+ if (!mod || typeof mod.id !== "string" || !Array.isArray(mod.views)) {
1380
+ console.error("[dsh-workbench] registerAddon \u53C2\u6570\u4E0D\u5408\u6CD5", mod);
1381
+ return;
1382
+ }
1383
+ registry.set(mod.id, mod);
1384
+ notifyStore();
1385
+ }
1386
+ function setAddons(list) {
1387
+ addonState.addons = Array.isArray(list) ? list : [];
1388
+ addonState.loaded = true;
1389
+ var alive = {};
1390
+ addonState.addons.forEach(function(a) {
1391
+ alive[a.id] = a;
1392
+ });
1393
+ registry.forEach(function(_m, id) {
1394
+ if (!alive[id]) registry.delete(id);
1395
+ });
1396
+ notifyStore();
1397
+ }
1398
+ function refreshAddons() {
1399
+ return fetch("/workbench/api/domains").then(function(r) {
1400
+ return r.json();
1401
+ }).then(function(j) {
1402
+ if (j && j.domains) {
1403
+ addonState.shellVersion = j.shellVersion || addonState.shellVersion;
1404
+ setAddons(j.domains);
1405
+ }
1406
+ return j;
1407
+ }).catch(function(e) {
1408
+ console.warn("[dsh-workbench] \u8BFB\u53D6\u4E1A\u52A1\u63D2\u4EF6\u5931\u8D25", e);
1409
+ return null;
1410
+ });
1411
+ }
1412
+ function ensureStream() {
1413
+ if (stream) return;
1414
+ stream = new EventSource("/workbench/api/events");
1415
+ stream.addEventListener("domains-changed", function(e) {
1416
+ try {
1417
+ setAddons(JSON.parse(e.data));
1418
+ } catch (err) {
1419
+ console.warn(err);
1420
+ }
1421
+ });
1422
+ stream.addEventListener("domain-event", function(e) {
1423
+ try {
1424
+ broadcast(JSON.parse(e.data));
1425
+ } catch (err) {
1426
+ console.warn(err);
1427
+ }
1428
+ });
1429
+ stream.addEventListener("record-mode", function(e) {
1430
+ try {
1431
+ var payload = JSON.parse(e.data);
1432
+ if (payload && payload.sessionId) setRecordMode(payload.sessionId, payload.enabled);
1433
+ } catch (err) {
1434
+ console.warn(err);
1435
+ }
1436
+ });
1437
+ stream.addEventListener("sync-done", notifyCloudStatus);
1438
+ stream.addEventListener("account-changed", notifyCloudStatus);
1439
+ }
1440
+ function useAddonStore() {
1441
+ var st = react.useState(0);
1442
+ var bump = st[1];
1443
+ react.useEffect(function() {
1444
+ ensureStream();
1445
+ var fn = function() {
1446
+ bump(function(x) {
1447
+ return x + 1;
1448
+ });
1449
+ };
1450
+ storeListeners.add(fn);
1451
+ if (!addonState.loaded) refreshAddons();
1452
+ return function() {
1453
+ storeListeners.delete(fn);
1454
+ };
1455
+ }, []);
1456
+ return addonState;
1457
+ }
1458
+ window.__WB_HOST__ = {
1459
+ react,
1460
+ jsx,
1461
+ h,
1462
+ registerAddon,
1463
+ get addons() {
1464
+ return addonState.addons;
1465
+ },
1466
+ error: function() {
1467
+ return lastAddonError;
1468
+ }
1469
+ };
1470
+ function useApi() {
1471
+ var base = "/workbench/api";
1472
+ return react.useMemo(function() {
1473
+ return {
1474
+ get: function(p) {
1475
+ return fetch(base + p).then(function(r) {
1476
+ return r.json();
1477
+ });
1478
+ },
1479
+ post: function(p, b) {
1480
+ return fetch(base + p, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(b || {}) }).then(function(r) {
1481
+ return r.json();
1482
+ });
1483
+ },
1484
+ del: function(p) {
1485
+ return fetch(base + p, { method: "DELETE" }).then(function(r) {
1486
+ return r.json();
1487
+ });
1488
+ }
1489
+ };
1490
+ }, []);
1491
+ }
1492
+ function useCloudStatus() {
1493
+ var api = useApi();
1494
+ var st = react.useState(null);
1495
+ var status = st[0];
1496
+ var setStatus = st[1];
1497
+ react.useEffect(function() {
1498
+ var alive = true;
1499
+ function load() {
1500
+ api.get("/sync/status").then(function(r) {
1501
+ if (alive && r && r.ok) setStatus(r);
1502
+ }).catch(function() {
1503
+ });
1504
+ }
1505
+ load();
1506
+ var timer = setInterval(load, 15e3);
1507
+ function onVisible() {
1508
+ if (typeof document !== "undefined" && document.visibilityState === "visible") load();
1509
+ }
1510
+ if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVisible);
1511
+ cloudStatusListeners.add(load);
1512
+ return function() {
1513
+ alive = false;
1514
+ clearInterval(timer);
1515
+ if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisible);
1516
+ cloudStatusListeners.delete(load);
1517
+ };
1518
+ }, [api]);
1519
+ return status;
1520
+ }
1521
+ function cloudView(status, t) {
1522
+ if (!status) return { kind: "local", label: t("cloud_checking"), hint: t("cloud_checking_hint") };
1523
+ var failed = Array.isArray(status.failed_tables) ? status.failed_tables : [];
1524
+ if (!status.logged_in) return { kind: "local", label: t("cloud_local"), hint: t("cloud_local_hint") };
1525
+ if (status.running) return { kind: "syncing", label: t("cloud_syncing"), hint: t("cloud_syncing_hint") };
1526
+ if (status.cloud && status.cloud.reachable === false) return { kind: "off", label: t("cloud_offline"), hint: t("cloud_offline_hint") };
1527
+ if (!status.last_sync_at) return { kind: "warn", label: t("cloud_never"), hint: t("cloud_never_hint") };
1528
+ if (status.last_sync_ok === false || failed.length) return { kind: "warn", label: t("cloud_sync_failed"), hint: t("cloud_sync_failed_hint") };
1529
+ return { kind: "on", label: t("cloud_online"), hint: t("cloud_online_hint") };
1530
+ }
1531
+ function cloudTitle(view, status, t) {
1532
+ var parts = [view.hint];
1533
+ if (status && status.logged_in) {
1534
+ parts.push(t("sync_last") + ": " + (status.last_sync_at ? new Date(status.last_sync_at).toLocaleString() : t("sync_never")));
1535
+ if (status.conflicts) parts.push(t("sync_conflicts") + ": " + status.conflicts);
1536
+ var failed = Array.isArray(status.failed_tables) ? status.failed_tables : [];
1537
+ if (failed.length) parts.push(t("sync_failed_tables") + ": " + failed.join(", "));
1538
+ if (status.last_sync_error) parts.push(status.last_sync_error);
1539
+ if (status.cloud && status.cloud.error) parts.push(status.cloud.error);
1540
+ }
1541
+ return parts.join(" \xB7 ");
1542
+ }
1543
+ function CloudStatusPill(props) {
1544
+ var t = props.t;
1545
+ var status = useCloudStatus();
1546
+ var view = cloudView(status, t);
1547
+ var title = cloudTitle(view, status, t);
1548
+ return jsx.jsxs("button", {
1549
+ type: "button",
1550
+ className: "wb-cloud " + view.kind,
1551
+ onClick: props.onOpen,
1552
+ title,
1553
+ "aria-label": t("cloud_status") + ": " + view.label + " \u2014 " + view.hint + " \xB7 " + t("cloud_open"),
1554
+ "data-cloud-state": view.kind,
1555
+ children: [
1556
+ jsx.jsx("span", { className: "wb-cloud-dot" }),
1557
+ jsx.jsx("span", { className: "wb-cloud-label", children: view.label })
1558
+ ]
1559
+ });
1560
+ }
1561
+ function pickTitle(title, lang) {
1562
+ if (!title) return "";
1563
+ if (typeof title === "string") return title;
1564
+ return title[lang] || title.zh || title.en || "";
1565
+ }
1566
+ function currentLang() {
1567
+ var raw = document && document.documentElement && document.documentElement.lang || typeof navigator !== "undefined" && navigator.language || "zh";
1568
+ return String(raw).toLowerCase().indexOf("zh") === 0 ? "zh" : "en";
1569
+ }
1570
+ var systemTabs = require_system_tabs()(react, jsx, useApi);
1571
+ var AccountTab = systemTabs.AccountTab;
1572
+ var BackupTab = systemTabs.BackupTab;
1573
+ var AuditTab = systemTabs.AuditTab;
1574
+ var ViewTabs = require_view_tabs()(react, pickTitle);
1575
+ var ViewOutlet = require_view_outlet();
1576
+ function ensureCss() {
1577
+ if (typeof document === "undefined") return;
1578
+ if (document.getElementById("wb-css")) return;
1579
+ var s = document.createElement("style");
1580
+ s.id = "wb-css";
1581
+ s.setAttribute("data-plugin-css", NS);
1582
+ s.textContent = CSS;
1583
+ document.head.appendChild(s);
1584
+ }
1585
+ function WorkbenchPage(props) {
1586
+ var t = props.t;
1587
+ var store = useAddonStore();
1588
+ var rs = react.useState("home");
1589
+ var route = rs[0];
1590
+ var setRoute = rs[1];
1591
+ var navigation = react.useState({});
1592
+ var viewParams = navigation[0];
1593
+ var lang = currentLang();
1594
+ react.useEffect(function() {
1595
+ ensureCss();
1596
+ }, []);
1597
+ var addons = (store.addons || []).filter(function(a) {
1598
+ return a && a.enabled;
1599
+ });
1600
+ var currentAddon = null;
1601
+ if (route.indexOf("addon:") === 0) {
1602
+ var parts = route.split(":");
1603
+ var wanted = parts[1] || "";
1604
+ addons.forEach(function(a) {
1605
+ if (a.id === wanted) currentAddon = a;
1606
+ });
1607
+ }
1608
+ var mod = currentAddon ? registry.get(currentAddon.id) : null;
1609
+ var clientViews = mod && Array.isArray(mod.views) ? mod.views : [];
1610
+ var manifestViews = currentAddon && Array.isArray(currentAddon.views) ? currentAddon.views : [];
1611
+ var viewList = clientViews.length ? clientViews : manifestViews;
1612
+ var wantedView = route.indexOf("addon:") === 0 ? route.split(":")[2] || "" : "";
1613
+ var activeView = null;
1614
+ viewList.forEach(function(v) {
1615
+ if (v.id === wantedView) activeView = v;
1616
+ });
1617
+ if (!activeView && viewList.length) activeView = viewList[0];
1618
+ function go(next, params) {
1619
+ navigation[1](params || {});
1620
+ setRoute(next);
1621
+ }
1622
+ function navigateView(viewId, params) {
1623
+ if (currentAddon && viewList.some(function(v) {
1624
+ return v.id === viewId;
1625
+ })) {
1626
+ go("addon:" + currentAddon.id + ":" + viewId, params);
1627
+ }
1628
+ }
1629
+ function cardIcon(title) {
1630
+ return String(title || "?").slice(0, 1);
1631
+ }
1632
+ function openAddon(a) {
1633
+ var m = registry.get(a.id);
1634
+ var v = m && m.views && m.views[0] || a.views && a.views[0] || null;
1635
+ go("addon:" + a.id + ":" + (v && v.id ? v.id : ""));
1636
+ }
1637
+ function pageHead(title, desc) {
1638
+ return jsx.jsxs("div", { className: "wb-page-head", children: [
1639
+ jsx.jsx("div", { className: "wb-page-top", children: [
1640
+ jsx.jsx("button", { className: "wb-back", onClick: function() {
1641
+ go("home");
1642
+ }, children: "\u2190 " + t("back_home") })
1643
+ ] }),
1644
+ jsx.jsxs("div", { className: "wb-page-title", children: [
1645
+ jsx.jsx("span", { className: "wb-home-icon", children: cardIcon(title) }),
1646
+ jsx.jsx("h2", { children: title })
1647
+ ] }),
1648
+ desc ? jsx.jsx("div", { className: "wb-page-desc", children: desc }) : null
1649
+ ] });
1650
+ }
1651
+ function addonCard(a) {
1652
+ var m = registry.get(a.id);
1653
+ var v = m && m.views && m.views[0] || a.views && a.views[0] || null;
1654
+ var title = a.title || pickTitle(v && v.title, lang) || a.id;
1655
+ var count = m && m.views ? m.views.length : a.views ? a.views.length : 0;
1656
+ return jsx.jsxs("button", { type: "button", className: "wb-home-card" + (a.error ? " dim" : ""), onClick: function() {
1657
+ openAddon(a);
1658
+ }, children: [
1659
+ jsx.jsxs("div", { className: "wb-home-top", children: [
1660
+ jsx.jsx("span", { className: "wb-home-icon", children: cardIcon(a.title || title) }),
1661
+ jsx.jsx("span", { className: "wb-badge", children: "v" + (a.version || "?") })
1662
+ ] }),
1663
+ jsx.jsx("div", { className: "wb-home-title", children: title }),
1664
+ jsx.jsx("div", { className: "wb-home-desc", children: a.description || (count > 1 ? count + " " + t("views") : "") }),
1665
+ a.error ? jsx.jsx("div", { className: "wb-err", children: t("addon_error") + ": " + a.error }) : null
1666
+ ] }, a.id);
1667
+ }
1668
+ function systemCard(key, icon, title, desc) {
1669
+ return jsx.jsxs("button", { type: "button", className: "wb-home-card", onClick: function() {
1670
+ go(key);
1671
+ }, children: [
1672
+ jsx.jsxs("div", { className: "wb-home-top", children: [
1673
+ jsx.jsx("span", { className: "wb-home-icon", children: icon })
1674
+ ] }),
1675
+ jsx.jsx("div", { className: "wb-home-title", children: title }),
1676
+ jsx.jsx("div", { className: "wb-home-desc", children: desc })
1677
+ ] }, key);
1678
+ }
1679
+ if (route === "backup") {
1680
+ return jsx.jsxs("div", { className: "wb-root", children: [
1681
+ jsx.jsxs("div", { className: "wb-inner wb-wide", children: [pageHead(t("tab_backup"), t("backup_desc")), jsx.jsx(BackupTab, { t, lang, addons })] })
1682
+ ] });
1683
+ }
1684
+ if (route === "audit") {
1685
+ return jsx.jsxs("div", { className: "wb-root", children: [
1686
+ jsx.jsxs("div", { className: "wb-inner wb-wide", children: [pageHead(t("tab_audit"), t("audit_desc")), jsx.jsx(AuditTab, { t })] })
1687
+ ] });
1688
+ }
1689
+ if (route === "account") {
1690
+ return jsx.jsxs("div", { className: "wb-root", children: [
1691
+ jsx.jsxs("div", { className: "wb-inner wb-wide", children: [pageHead(t("tab_account"), t("account_desc")), jsx.jsx(AccountTab, { t })] })
1692
+ ] });
1693
+ }
1694
+ if (currentAddon) {
1695
+ var canRender = activeView && typeof activeView.component === "function";
1696
+ var addonTitle = currentAddon.title || pickTitle(activeView && activeView.title, lang) || currentAddon.id;
1697
+ return jsx.jsxs("div", { className: "wb-root wb-immersive", children: [
1698
+ jsx.jsxs("div", { className: "wb-immersive-bar", children: [
1699
+ jsx.jsx("button", { className: "wb-back", onClick: function() {
1700
+ go("home");
1701
+ }, children: "\u2190 " + t("back_home") }),
1702
+ jsx.jsx("div", { className: "wb-grow" }),
1703
+ jsx.jsxs("div", { className: "wb-immersive-title", children: [
1704
+ jsx.jsx("span", { className: "wb-home-icon", children: cardIcon(addonTitle) }),
1705
+ jsx.jsx("span", { children: addonTitle }),
1706
+ jsx.jsx("span", { className: "wb-badge", children: "v" + (currentAddon.version || "?") })
1707
+ ] })
1708
+ ] }),
1709
+ jsx.jsxs("div", { className: "wb-immersive-main", children: [
1710
+ jsx.jsxs("div", { className: "wb-inner wb-wide", children: [
1711
+ jsx.jsx(ViewTabs, { views: viewList, activeView, addonId: currentAddon.id, lang, go }),
1712
+ currentAddon.error ? jsx.jsx("div", { className: "wb-card", children: jsx.jsx("div", { className: "wb-err", children: t("addon_error") + ": " + currentAddon.error }) }) : canRender ? jsx.jsx(ViewOutlet, { view: activeView, viewProps: { api: apiFor(currentAddon.id), lang, addonId: currentAddon.id, t, viewParams, onNavigate: navigateView } }, currentAddon.id) : !viewList.length ? jsx.jsx("div", { className: "wb-card", children: jsx.jsx("div", { className: "wb-msg", children: t("no_views") }) }) : jsx.jsx("div", { className: "wb-card", children: jsx.jsx("div", { className: "wb-page-loading", children: jsx.jsx("div", { className: "wb-msg", style: { padding: "4px 0" }, children: lastAddonError ? t("addon_unavailable") + " \xB7 " + lastAddonError : t("addon_loading") }) }) })
1713
+ ] })
1714
+ ] })
1715
+ ] });
1716
+ }
1717
+ return jsx.jsxs("div", { className: "wb-root", children: [
1718
+ jsx.jsxs("div", { className: "wb-inner", children: [
1719
+ jsx.jsxs("div", { className: "wb-hero", children: [
1720
+ jsx.jsxs("div", { children: [jsx.jsx("h2", { children: t("title") }), jsx.jsx("span", { className: "wb-tag", children: t("tagline") })] }),
1721
+ jsx.jsx(CloudStatusPill, { t, onOpen: function() {
1722
+ go("account");
1723
+ } })
1724
+ ] }),
1725
+ addons.length ? jsx.jsx("div", { className: "wb-home-grid", children: addons.map(addonCard) }) : jsx.jsx("div", { className: "wb-card", children: jsx.jsx("div", { className: "wb-msg wb-empty-cta", children: t("no_installed") }) }),
1726
+ jsx.jsxs("div", { className: "wb-sec", children: [
1727
+ jsx.jsx("h3", { children: t("manage") }),
1728
+ jsx.jsx("span", { className: "wb-hint", children: t("home_hint") })
1729
+ ] }),
1730
+ jsx.jsxs("div", { className: "wb-home-grid manage", children: [
1731
+ systemCard("backup", "\u2913", t("tab_backup"), t("backup_desc")),
1732
+ systemCard("audit", "\u25A4", t("tab_audit"), t("audit_desc")),
1733
+ systemCard("account", "\u2601", t("tab_account"), t("account_desc"))
1734
+ ] })
1735
+ ] })
1736
+ ] });
1737
+ }
1738
+ var RecordToggle = function(props) {
1739
+ var sid = props && props.sessionId;
1740
+ var st = react.useState(false);
1741
+ var on = st[0];
1742
+ var setOn = st[1];
1743
+ var bst = react.useState(false);
1744
+ var busy = bst[0];
1745
+ var setBusy = bst[1];
1746
+ var est = react.useState("");
1747
+ var err = est[0];
1748
+ var setErr = est[1];
1749
+ var t = props && props.t;
1750
+ react.useEffect(function() {
1751
+ if (!sid) return;
1752
+ var fn = function(changed, value) {
1753
+ if (changed === sid) setOn(!!value);
1754
+ };
1755
+ recordListeners.add(fn);
1756
+ ensureStream();
1757
+ fetch("/workbench/api/record?sessionId=" + encodeURIComponent(sid)).then(function(r) {
1758
+ return r.json();
1759
+ }).then(function(j) {
1760
+ if (j && j.ok) setRecordMode(sid, !!j.enabled);
1761
+ }).catch(function() {
1762
+ });
1763
+ return function() {
1764
+ recordListeners.delete(fn);
1765
+ };
1766
+ }, [sid]);
1767
+ function toggle() {
1768
+ if (!sid || busy) return;
1769
+ setBusy(true);
1770
+ setErr("");
1771
+ fetch("/workbench/api/record", {
1772
+ method: "POST",
1773
+ headers: { "content-type": "application/json" },
1774
+ body: JSON.stringify({ sessionId: sid, enabled: !on })
1775
+ }).then(function(r) {
1776
+ return r.json();
1777
+ }).then(function(j) {
1778
+ if (!j || !j.ok) throw new Error(j && j.error || "request failed");
1779
+ setRecordMode(sid, !!j.enabled);
1780
+ }).catch(function(e) {
1781
+ var msg = String(e && e.message || e);
1782
+ setErr(msg);
1783
+ try {
1784
+ console.warn("[dsh-workbench] record toggle failed:", msg);
1785
+ } catch (_) {
1786
+ }
1787
+ }).then(function() {
1788
+ setBusy(false);
1789
+ });
1790
+ }
1791
+ if (!sid) return null;
1792
+ var label = busy ? t("record_busy") : err ? t("record_failed_short") : on ? t("record_on") : t("record_off");
1793
+ var title = err ? t("record_error") + ": " + err : on ? t("record_on_title") : t("record_off_title");
1794
+ return h(
1795
+ "button",
1796
+ {
1797
+ type: "button",
1798
+ className: "wb-record-pill" + (on ? " on" : "") + (err ? " err" : ""),
1799
+ onClick: toggle,
1800
+ disabled: busy,
1801
+ title,
1802
+ "aria-label": t("record_label") + ": " + label,
1803
+ "aria-pressed": on ? "true" : "false"
1804
+ },
1805
+ h("span", { className: "wb-record-dot" }),
1806
+ h("span", { className: "wb-record-label", children: label })
1807
+ );
1808
+ };
1809
+ var exports_ = {
1810
+ name: NS,
1811
+ inject: ["slots", "locale", "theme"],
1812
+ apply: function(ctx) {
1813
+ try {
1814
+ ensureCss();
1815
+ var PanellistIcon = function() {
1816
+ return h(
1817
+ "svg",
1818
+ { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": 2, "stroke-linecap": "round", "stroke-linejoin": "round" },
1819
+ h("rect", { x: 3, y: 3, width: 7, height: 7, rx: 1 }),
1820
+ h("rect", { x: 14, y: 3, width: 7, height: 7, rx: 1 }),
1821
+ h("rect", { x: 3, y: 14, width: 7, height: 7, rx: 1 }),
1822
+ h("rect", { x: 14, y: 14, width: 7, height: 7, rx: 1 })
1823
+ );
1824
+ };
1825
+ ctx.effect(function() {
1826
+ return ctx.locale.register(NS, LOCALE);
1827
+ }, "wb-locale");
1828
+ var t = ctx.locale.bind(NS);
1829
+ ctx.slots.inject("sidebar.panellist", function() {
1830
+ return ctx.slots.register(
1831
+ { name: "sidebar.panellist", id: NS, order: 62, label: function() {
1832
+ return t("nav");
1833
+ } },
1834
+ function() {
1835
+ return h(PanellistIcon, {});
1836
+ }
1837
+ );
1838
+ });
1839
+ ctx.slots.inject("main", function() {
1840
+ return ctx.slots.register(
1841
+ { name: "main", key: NS, locale: NS, inject: function() {
1842
+ return { t };
1843
+ } },
1844
+ function() {
1845
+ try {
1846
+ return jsx.jsx(WorkbenchPage, { t });
1847
+ } catch (e) {
1848
+ window.__wbSlotErr = String(e && e.stack || e);
1849
+ throw e;
1850
+ }
1851
+ }
1852
+ );
1853
+ });
1854
+ ctx.slots.inject("settings.plugins.tab", function() {
1855
+ return ctx.slots.register(
1856
+ { name: "settings.plugins.tab", id: NS, order: 65, label: function() {
1857
+ return t("nav");
1858
+ }, locale: NS, inject: function() {
1859
+ return { t };
1860
+ } },
1861
+ function() {
1862
+ return h(WorkbenchPage, { t });
1863
+ }
1864
+ );
1865
+ });
1866
+ ctx.slots.inject("conversation.input.left", function() {
1867
+ return ctx.slots.register(
1868
+ { name: "conversation.input.left", id: NS + "-record", order: 40, label: function() {
1869
+ return t("record_label");
1870
+ } },
1871
+ function(props) {
1872
+ return h(RecordToggle, { sessionId: props && props.sessionId, t });
1873
+ }
1874
+ );
1875
+ });
1876
+ } catch (e) {
1877
+ console.error("[dsh-workbench] apply crashed:", e, e && e.stack);
1878
+ throw e;
1879
+ }
1880
+ }
1881
+ };
1882
+ module.exports = exports_;
1883
+ return module.exports;
1884
+ },
1885
+ });