@celljs/ta-sync 0.0.0-stage → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/index.js ADDED
@@ -0,0 +1,2018 @@
1
+ // web-src/i18n.ts
2
+ var en = {
3
+ title: "Sync",
4
+ devices: "My devices",
5
+ asksTitle: "A computer asks to join",
6
+ asksBody: "It gets your settings, instructions, skills and extensions, and what else you chose to sync. Allow only computers of your own.",
7
+ later: "Later",
8
+ lead: "Keep your settings, skills, instructions and extensions the same on your other computers. No account: the computers talk end to end through the relay, which cannot read what goes.",
9
+ enable: "Turn on sync",
10
+ asksWhen: "Asked {when}",
11
+ joinHint: "Paste the link of Add a device on a computer that syncs.",
12
+ joinAction: "Join",
13
+ leadShort: "Your settings, skills, instructions and extensions the same on each of your computers. No account; sealed end to end.",
14
+ leadFolderShort: "Your settings, skills, instructions and extensions the same on each of your computers, through a folder of your cloud drive. No relay at all.",
15
+ viaRelay: "Through {name}",
16
+ viaFolder: "Through the folder {name}",
17
+ leadStoreShort: "Your settings, skills, instructions and extensions the same on each of your computers, through storage of your own (WebDAV, S3, a git repository), sealed before it leaves. No relay at all.",
18
+ inviteStoreHint: "On the other computer, open Settings → Sync → Join a sync in Ta and paste this link. It holds the key of the sync and the sign-in of your storage, for good: show it only to your own computers.",
19
+ stopStore: "This computer stops syncing and keeps what it has now; the others go on through the storage.",
20
+ waitingHint: "It goes on by itself once allowed.",
21
+ replacedShort: "What a sync replaced here is kept. ",
22
+ showFolder: "Show in folder",
23
+ leadFolder: "Keep your settings, skills, instructions and extensions the same on your other computers through the folder {path}, which your cloud drive keeps the same on them. No relay, no account: Ta seals everything it writes there.",
24
+ inFolder: "Through the folder {path}",
25
+ inviteFolderHint: "On the other computer, open Settings → Sync → Join a sync in Ta and paste this link. It holds the key of the sync for good: show it only to your own computers. The other computer needs the same folder of the drive.",
26
+ stopFolder: "This computer stops syncing and keeps what it has now; the others go on through the folder.",
27
+ join: "Join a sync",
28
+ joinTitle: "Join a sync",
29
+ joinPlaceholder: "The link of Add a device on the other computer",
30
+ scan: "Scan",
31
+ scanHint: "Scan the code of Add a device on the other computer",
32
+ waiting: "Asked to join: waiting for {owner} to let this computer in.",
33
+ refused: "{owner} did not let this computer in.",
34
+ gone: "This sync ended.",
35
+ restart: "Start again",
36
+ cancel: "Cancel",
37
+ connecting: "Connecting to the relay…",
38
+ thisDevice: "This computer",
39
+ online: "Online",
40
+ offline: "Offline",
41
+ lastSync: "Last synced {when}",
42
+ owner: "Adds devices",
43
+ addDevice: "Add a device",
44
+ inviteTitle: "Add a device",
45
+ inviteHint: "On the other computer open Settings → Sync → Join a sync in Ta and paste this link or scan the code. This computer then asks you to let it in. The link works for 7 days.",
46
+ making: "Making a link…",
47
+ copy: "Copy link",
48
+ copied: "Copied",
49
+ newLink: "New link",
50
+ syncNow: "Sync now",
51
+ syncing: "Syncing…",
52
+ stop: "Stop sync",
53
+ stopOwner: "Every computer stops syncing, each keeping what it has now.",
54
+ stopMember: "This computer stops syncing and keeps what it has now.",
55
+ remove: "Remove",
56
+ asks: "{name} asks to join this sync",
57
+ allow: "Allow",
58
+ refuse: "Refuse",
59
+ removeConfirm: "Remove {name}? It stops syncing and keeps what it has now.",
60
+ report: "Sent {sent} · received {received}",
61
+ upToDate: "Up to date",
62
+ skipped: "Not synced: {ids}",
63
+ replaced: "What a sync replaced or deleted here is kept in {dir}",
64
+ whatTitle: "What to sync",
65
+ failed: "Could not do it: {message}",
66
+ now: "just now",
67
+ minutes: "{n} min ago",
68
+ settings: "Settings",
69
+ settingsHint: "settings.json (models, theme and the rest, not paths and commands of this computer) and keybindings",
70
+ instructions: "Instructions",
71
+ instructionsHint: "AGENTS.md, SYSTEM.md and the other instructions of every project",
72
+ skills: "Skills, prompts and themes",
73
+ skillsHint: "What is in skills/, prompts/ and themes/ of Ta",
74
+ models: "Models and MCP",
75
+ modelsHint: "models.json and mcp.json, which may hold API keys: sealed end to end, they reach only your computers",
76
+ extensions: "Extensions",
77
+ extensionsHint: "Packages installed from npm or git, and the extensions you made",
78
+ data: "Data of extensions",
79
+ dataHint: "What extensions keep for you everywhere, as the look of Ta and of your double",
80
+ identity: "Identity and rooms",
81
+ identityHint: "The same you in rooms on every computer, with your rooms and friends; the one in use answers when someone asks your double",
82
+ identityAskTitle: "Be the same you in rooms on your computers?",
83
+ identityAskBody: "Your identity, rooms and friends go to the computers of this sync, sealed. If another computer shares it already, this one takes on its identity; the rooms this one is in keep the identity they were joined with. Whoever has your identity can pass for you: share it only between your own computers.",
84
+ identityAskConfirm: "Share"
85
+ };
86
+ var zh = {
87
+ title: "设备同步",
88
+ devices: "我的设备",
89
+ asksTitle: "有电脑申请加入同步",
90
+ asksBody: "它会拿到你的设置、指令、技能、扩展,以及你选择同步的其他内容。只同意你自己的电脑。",
91
+ later: "稍后",
92
+ lead: "让你的其他电脑也有同样的设置、技能、指令和扩展。不用登录账号:电脑之间端到端加密,经中继传递,中继看不到内容。",
93
+ enable: "开启同步",
94
+ asksWhen: "{when}申请",
95
+ joinHint: "粘贴已同步的电脑上“添加设备”给出的链接。",
96
+ joinAction: "加入",
97
+ leadShort: "让你的每台电脑都有同样的设置、技能、指令和扩展。不用账号,端到端加密。",
98
+ leadFolderShort: "经网盘里的文件夹,让你的每台电脑都有同样的设置、技能、指令和扩展。完全不经过中继。",
99
+ viaRelay: "经 {name}",
100
+ viaFolder: "经文件夹 {name}",
101
+ leadStoreShort: "经你自己的存储(WebDAV、S3、git 仓库),让你的每台电脑都有同样的设置、技能、指令和扩展。离开电脑前就已加密,完全不经过中继。",
102
+ inviteStoreHint: "在另一台电脑的 Ta 里打开 设置 → 设备同步 → 加入已有的同步,粘贴这个链接。链接里有同步的密钥和你存储的登录信息,长期有效,只给你自己的电脑。",
103
+ stopStore: "这台电脑停止同步,保留现在的内容;其他电脑继续经这个存储同步。",
104
+ waitingHint: "对方同意后自动开始。",
105
+ replacedShort: "同步覆盖的原有内容已留底。",
106
+ showFolder: "在文件夹中显示",
107
+ leadFolder: "通过网盘在几台电脑间保持一致的文件夹 {path},让你的其他电脑也有同样的设置、技能、指令和扩展。不经过中继,不用账号:Ta 写进去的内容都先加密。",
108
+ inFolder: "经文件夹 {path} 同步",
109
+ inviteFolderHint: "在另一台电脑的 Ta 里打开 设置 → 设备同步 → 加入已有的同步,粘贴这个链接。链接里有同步的密钥且长期有效,只给你自己的电脑。另一台电脑需要能访问网盘里的同一个文件夹。",
110
+ stopFolder: "这台电脑停止同步,保留现在的内容;其他电脑继续经文件夹同步。",
111
+ join: "加入已有的同步",
112
+ joinTitle: "加入已有的同步",
113
+ joinPlaceholder: "另一台电脑上“添加设备”给出的链接",
114
+ scan: "扫码",
115
+ scanHint: "扫描另一台电脑上“添加设备”的二维码",
116
+ waiting: "已申请加入,等 {owner} 那台电脑同意。",
117
+ refused: "{owner} 没有同意这台电脑加入。",
118
+ gone: "这次同步已经结束。",
119
+ restart: "重新开始",
120
+ cancel: "取消",
121
+ connecting: "正在连接中继…",
122
+ thisDevice: "本机",
123
+ online: "在线",
124
+ offline: "离线",
125
+ lastSync: "上次同步:{when}",
126
+ owner: "负责添加设备",
127
+ addDevice: "添加设备",
128
+ inviteTitle: "添加设备",
129
+ inviteHint: "在另一台电脑的 Ta 里打开 设置 → 设备同步 → 加入已有的同步,粘贴这个链接或扫码。之后这台电脑会请你同意。链接 7 天内有效。",
130
+ making: "正在生成链接…",
131
+ copy: "复制链接",
132
+ copied: "已复制",
133
+ newLink: "换一个链接",
134
+ syncNow: "立即同步",
135
+ syncing: "正在同步…",
136
+ stop: "停止同步",
137
+ stopOwner: "所有电脑都会停止同步,各自保留现在的内容。",
138
+ stopMember: "这台电脑停止同步,保留现在的内容。",
139
+ remove: "移除",
140
+ asks: "{name} 申请加入同步",
141
+ allow: "同意",
142
+ refuse: "拒绝",
143
+ removeConfirm: "移除 {name}?它会停止同步,保留现在的内容。",
144
+ report: "发出 {sent} 项 · 收到 {received} 项",
145
+ upToDate: "已是最新",
146
+ skipped: "没有同步:{ids}",
147
+ replaced: "同步覆盖或删除的内容保存在 {dir}",
148
+ whatTitle: "同步哪些内容",
149
+ failed: "没有成功:{message}",
150
+ now: "刚刚",
151
+ minutes: "{n} 分钟前",
152
+ settings: "设置",
153
+ settingsHint: "settings.json 里的模型、主题等(本机的路径和命令除外),以及快捷键",
154
+ instructions: "指令",
155
+ instructionsHint: "AGENTS.md、SYSTEM.md 等对所有项目生效的指令",
156
+ skills: "技能、提示词和主题",
157
+ skillsHint: "Ta 的 skills/、prompts/、themes/ 里的内容",
158
+ models: "模型与 MCP",
159
+ modelsHint: "models.json 和 mcp.json,可能含 API 密钥:端到端加密,只到你自己的电脑",
160
+ extensions: "扩展",
161
+ extensionsHint: "从 npm、git 安装的扩展包,以及你自己做的扩展",
162
+ data: "扩展数据",
163
+ dataHint: "扩展声明要同步的数据,比如 Ta 的外观设置和分身的样子",
164
+ identity: "身份与房间",
165
+ identityHint: "每台电脑在房间里都是同一个你,房间和 好友也一样;别人 @ 你的分身时,由正在用的那台回答",
166
+ identityAskTitle: "让这几台电脑在房间里都是同一个你?",
167
+ identityAskBody: "你的身份、房间和 好友会加密同步到这些电脑。如果另一台电脑已经共享了身份,这台会换成它的身份;这台原来所在的房间保留原来的身份。拿到身份的人就能冒充你,只在自己的电脑之间打开。",
168
+ identityAskConfirm: "共享"
169
+ };
170
+ var SyncWords;
171
+ ((SyncWords) => {
172
+ function of(language) {
173
+ return /^zh/i.test(language) ? zh : en;
174
+ }
175
+ SyncWords.of = of;
176
+ function format(text, values) {
177
+ return text.replace(/\{(\w+)\}/g, (match, key) => values[key] === undefined ? match : String(values[key]));
178
+ }
179
+ SyncWords.format = format;
180
+ function resource(words, resource2) {
181
+ return { label: words[resource2], hint: words[`${resource2}Hint`] };
182
+ }
183
+ SyncWords.resource = resource;
184
+ function when(words, at, now = Date.now()) {
185
+ const minutes = Math.floor((now - at) / 60000);
186
+ if (minutes < 1) {
187
+ return words.now;
188
+ }
189
+ if (minutes < 60) {
190
+ return format(words.minutes, { n: minutes });
191
+ }
192
+ const date = new Date(at);
193
+ const pad = (value) => String(value).padStart(2, "0");
194
+ const time = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
195
+ return new Date(now).toDateString() === date.toDateString() ? time : `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${time}`;
196
+ }
197
+ SyncWords.when = when;
198
+ })(SyncWords ||= {});
199
+
200
+ // web-src/migrate-i18n.ts
201
+ var en2 = {
202
+ title: "Move to another computer",
203
+ lead: "Take everything to a new computer at once, the conversations too, as WeChat moves a chat history. Straight over your network, sealed end to end; nothing goes through the relay.",
204
+ outTitle: "From this computer",
205
+ outHint: "Choose what goes, then show the code to the new computer.",
206
+ inTitle: "To this computer",
207
+ inHint: "Receive from the computer you move from.",
208
+ fileTitle: "Backup file",
209
+ fileHint: "For a computer on another network, or to keep: everything in one file you carry yourself.",
210
+ start: "Start",
211
+ tabOut: "Send",
212
+ tabIn: "Receive",
213
+ tabFile: "Backup",
214
+ replacedLead: "What it replaced here is kept in",
215
+ readyTitle: "Ready to move",
216
+ waitingFor: "Waiting for the new computer…",
217
+ keepOpen: "Keep both computers awake and Ta open until it ends.",
218
+ waitingCompare: "Compare it with the code on the old computer, then allow it there.",
219
+ compareHint: "Allow only if the new computer shows the same code.",
220
+ doneFrom: "Moved from {name}",
221
+ factConversations: "conversations",
222
+ factItems: "settings and the like",
223
+ factData: "extensions' data",
224
+ showReplaced: "What it replaced",
225
+ orLink: "Or a link",
226
+ writeBackup: "Back up this computer",
227
+ lookingBackups: "Looking for backups…",
228
+ chosenSize: "{size} chosen",
229
+ nothing: "none",
230
+ receive: "Receive",
231
+ exportFile: "Back up to a file",
232
+ importFile: "Restore from a file",
233
+ nearby: "Nearby",
234
+ looking: "Looking for computers moving out on this network…",
235
+ noneNearby: "None yet: on the old computer, open Move to another computer and press Start.",
236
+ paste: "Or paste the link of the old computer",
237
+ pastePlaceholder: "ta-move://…",
238
+ scan: "Scan its code",
239
+ scanHint: "Scan the code on the computer you move from",
240
+ showCode: "On the new computer, open Settings → Move to another computer → Receive, and pick this one nearby, paste the link or scan the code with the Ta app paired with it.",
241
+ addresses: "This computer: {addresses}",
242
+ copy: "Copy link",
243
+ copied: "Copied",
244
+ asks: "{name} wants to receive everything",
245
+ compare: "Check that it shows {code}",
246
+ allow: "Allow",
247
+ refuse: "Refuse",
248
+ connecting: "Connecting to {name}…",
249
+ waiting: "Waiting for {name} to allow it",
250
+ sending: "Sending to {name}",
251
+ sendingFile: "Writing the backup",
252
+ receiving: "Receiving from {name}",
253
+ readingFile: "Restoring {name}",
254
+ doneOut: "Moved to {name}.",
255
+ doneFile: "Backed up",
256
+ showFile: "Show in folder",
257
+ doneIn: "Moved from {name}: {conversations} conversations, {items} settings and the like, the data of {data} extensions.",
258
+ kept: "{n} conversations were here already.",
259
+ replaced: "What it replaced here is kept in {dir}",
260
+ restart: "Extensions came: load them now, or they load when Ta starts again.",
261
+ skipped: "Not moved: {ids}",
262
+ failed: "It did not work: {message}",
263
+ again: "Done",
264
+ cancel: "Cancel",
265
+ password: "Password (optional)",
266
+ passwordNeeded: "Password",
267
+ passwordHint: "With a password the file is sealed; sign-ins and the identity go only so.",
268
+ backups: "Backups found",
269
+ noBackups: "No backup in Downloads, Desktop or your home folder",
270
+ pathPlaceholder: "The path of a .tabackup file",
271
+ restore: "Restore",
272
+ encrypted: "with a password",
273
+ of: "{done} of {total}",
274
+ conversations: "Conversations",
275
+ settings: "Settings",
276
+ instructions: "Instructions",
277
+ skills: "Skills, prompts and themes",
278
+ extensions: "Extensions",
279
+ data: "Data of extensions",
280
+ models: "Models and MCP",
281
+ changes: "Snapshots of changes",
282
+ credentials: "Sign-ins",
283
+ credentialsHint: "API keys and bot sign-ins",
284
+ identity: "Identity and rooms",
285
+ identityHint: "Who you are in rooms, the rooms and friends: whoever has them can pass for you",
286
+ identitySwitched: "In rooms you are now who you were on {name}: {rooms} rooms came. Rooms this computer was in keep its own identity.",
287
+ identityMerged: "{rooms} rooms and {friends} friends were added to yours.",
288
+ reload: "Load extensions"
289
+ };
290
+ var zh2 = {
291
+ title: "迁移到另一台电脑",
292
+ lead: "像微信迁移聊天记录一样,把所有内容(包括对话)一次搬到新电脑。在你的网络里直连传输、端到端加密,不经过中继。",
293
+ outTitle: "从这台电脑迁出",
294
+ outHint: "选好要迁移的内容,再把二维码给新电脑。",
295
+ inTitle: "迁入到这台电脑",
296
+ inHint: "从旧电脑接收。",
297
+ fileTitle: "备份文件",
298
+ fileHint: "两台电脑不在同一个网络,或者想留一份:全部内容存成一个文件,自己带过去。",
299
+ start: "开始",
300
+ tabOut: "迁出",
301
+ tabIn: "迁入",
302
+ tabFile: "备份文件",
303
+ replacedLead: "被替换的原有内容保存在",
304
+ readyTitle: "准备迁出",
305
+ waitingFor: "等待新电脑连接…",
306
+ keepOpen: "完成前请保持两台电脑开着 Ta、不要休眠。",
307
+ waitingCompare: "核对旧电脑上显示的数字,一致后在旧电脑上点同意。",
308
+ compareHint: "新电脑上显示的数字一致时再同意。",
309
+ doneFrom: "已从 {name} 迁入",
310
+ factConversations: "个对话",
311
+ factItems: "项设置等",
312
+ factData: "个扩展的数据",
313
+ showReplaced: "查看被替换的内容",
314
+ orLink: "或者用链接",
315
+ writeBackup: "备份这台电脑",
316
+ lookingBackups: "正在查找备份…",
317
+ chosenSize: "已选 {size}",
318
+ nothing: "无",
319
+ receive: "接收",
320
+ exportFile: "备份到文件",
321
+ importFile: "从文件恢复",
322
+ nearby: "附近的电脑",
323
+ looking: "正在查找这个网络里准备迁出的电脑…",
324
+ noneNearby: "还没有:在旧电脑上打开“迁移到另一台电脑”,点“开始”。",
325
+ paste: "或者粘贴旧电脑给出的链接",
326
+ pastePlaceholder: "ta-move://…",
327
+ scan: "扫码",
328
+ scanHint: "扫描旧电脑上的二维码",
329
+ showCode: "在新电脑上打开 设置 → 迁移到另一台电脑 → 接收,从附近的电脑里选这一台,或粘贴链接,或用连着新电脑的 Ta 手机 App 扫码。",
330
+ addresses: "本机地址:{addresses}",
331
+ copy: "复制链接",
332
+ copied: "已复制",
333
+ asks: "{name} 请求接收",
334
+ compare: "请确认对方显示的是 {code}",
335
+ allow: "同意",
336
+ refuse: "拒绝",
337
+ connecting: "正在连接 {name}…",
338
+ waiting: "等 {name} 同意",
339
+ sending: "正在发送到 {name}",
340
+ sendingFile: "正在写备份文件",
341
+ receiving: "正在从 {name} 接收",
342
+ readingFile: "正在恢复 {name}",
343
+ doneOut: "已迁移到 {name}。",
344
+ doneFile: "已备份",
345
+ showFile: "在文件夹中显示",
346
+ doneIn: "已从 {name} 迁入:{conversations} 个对话,{items} 项设置等,{data} 个扩展的数据。",
347
+ kept: "有 {n} 个对话这台电脑上已经有了。",
348
+ replaced: "被替换的原有内容保存在 {dir}",
349
+ restart: "迁入了扩展:现在加载,或者下次启动 Ta 时加载。",
350
+ skipped: "没有迁移:{ids}",
351
+ failed: "没有成功:{message}",
352
+ again: "完成",
353
+ cancel: "取消",
354
+ password: "密码(可选)",
355
+ passwordNeeded: "密码",
356
+ passwordHint: "设了密码文件会加密;只有设了密码,登录凭据和身份才会写进去。",
357
+ backups: "找到的备份",
358
+ noBackups: "下载、桌面和个人文件夹里没有备份",
359
+ pathPlaceholder: ".tabackup 文件的路径",
360
+ restore: "恢复",
361
+ encrypted: "有密码",
362
+ of: "{done} / {total}",
363
+ conversations: "对话",
364
+ settings: "设置",
365
+ instructions: "指令",
366
+ skills: "技能、提示词和主题",
367
+ extensions: "扩展",
368
+ data: "扩展数据",
369
+ models: "模型与 MCP",
370
+ changes: "改动快照",
371
+ credentials: "登录凭据",
372
+ credentialsHint: "API 密钥和机器人的登录",
373
+ identity: "身份与房间",
374
+ identityHint: "你在房间里的身份、房间和 好友,拿到的人就能冒充你",
375
+ identitySwitched: "房间里你现在是「{name}」上的身份,带来 {rooms} 个房间;这台电脑原来所在的房间保留原身份。",
376
+ identityMerged: "加进来 {rooms} 个房间和 {friends} 位 好友。",
377
+ reload: "加载扩展"
378
+ };
379
+ var MoveWordsUtil;
380
+ ((MoveWordsUtil) => {
381
+ function of(language) {
382
+ return /^zh/i.test(language) ? zh2 : en2;
383
+ }
384
+ MoveWordsUtil.of = of;
385
+ function format(text, values) {
386
+ return text.replace(/\{(\w+)\}/g, (match, key) => values[key] === undefined ? match : String(values[key]));
387
+ }
388
+ MoveWordsUtil.format = format;
389
+ function category(words, category2) {
390
+ return words[category2];
391
+ }
392
+ MoveWordsUtil.category = category;
393
+ function size(bytes) {
394
+ if (bytes < 1024) {
395
+ return `${bytes} B`;
396
+ }
397
+ if (bytes < 1024 * 1024) {
398
+ return `${Math.round(bytes / 1024)} KB`;
399
+ }
400
+ if (bytes < 1024 * 1024 * 1024) {
401
+ return `${(bytes / 1024 / 1024).toFixed(bytes < 10 * 1024 * 1024 ? 1 : 0)} MB`;
402
+ }
403
+ return `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GB`;
404
+ }
405
+ MoveWordsUtil.size = size;
406
+ })(MoveWordsUtil ||= {});
407
+
408
+ // web-src/migrate-protocol.ts
409
+ var MIGRATE_CATEGORIES = [
410
+ "conversations",
411
+ "settings",
412
+ "instructions",
413
+ "skills",
414
+ "extensions",
415
+ "data",
416
+ "models",
417
+ "changes",
418
+ "credentials",
419
+ "identity"
420
+ ];
421
+ var DEFAULT_CATEGORIES = {
422
+ conversations: true,
423
+ settings: true,
424
+ instructions: true,
425
+ skills: true,
426
+ extensions: true,
427
+ data: true,
428
+ models: true,
429
+ changes: false,
430
+ credentials: false,
431
+ identity: false
432
+ };
433
+ var MIGRATE_STATUS_KEY = "migrate";
434
+
435
+ // web-src/react.ts
436
+ var React;
437
+ function bind(react) {
438
+ React = react;
439
+ }
440
+ var idle = () => [false, async (action) => await action()];
441
+ function useBusy(ui) {
442
+ return (ui.useBusy ?? idle)();
443
+ }
444
+
445
+ // web-src/pictures.tsx
446
+ function Laptop({ x, y, accent }) {
447
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("rect", {
448
+ className: accent ? "ta-pic-accent" : "ta-pic-frame",
449
+ x,
450
+ y,
451
+ width: "52",
452
+ height: "34",
453
+ rx: "5"
454
+ }), /* @__PURE__ */ React.createElement("rect", {
455
+ className: "ta-pic-line",
456
+ x: x + 9,
457
+ y: y + 10,
458
+ width: "26",
459
+ height: "5",
460
+ rx: "2.5"
461
+ }), /* @__PURE__ */ React.createElement("rect", {
462
+ className: "ta-pic-line ta-pic-soft",
463
+ x: x + 9,
464
+ y: y + 19,
465
+ width: "18",
466
+ height: "5",
467
+ rx: "2.5"
468
+ }), /* @__PURE__ */ React.createElement("rect", {
469
+ className: "ta-pic-line",
470
+ x: x - 7,
471
+ y: y + 37,
472
+ width: "66",
473
+ height: "5",
474
+ rx: "2.5"
475
+ }));
476
+ }
477
+ function Lock({ x, y }) {
478
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("rect", {
479
+ className: "ta-pic-mark",
480
+ x: x - 7,
481
+ y: y - 1,
482
+ width: "14",
483
+ height: "11",
484
+ rx: "2.5"
485
+ }), /* @__PURE__ */ React.createElement("path", {
486
+ className: "ta-pic-shackle",
487
+ d: `M${x - 4} ${y - 1}v-3a4 4 0 0 1 8 0v3`
488
+ }));
489
+ }
490
+ function RelaySyncPicture({ pi }) {
491
+ const Picture = pi.ui.Picture;
492
+ if (!Picture) {
493
+ return null;
494
+ }
495
+ return /* @__PURE__ */ React.createElement(Picture, {
496
+ width: 240,
497
+ height: 76,
498
+ frame: false,
499
+ className: "tsy-pic"
500
+ }, /* @__PURE__ */ React.createElement(Laptop, {
501
+ x: 18,
502
+ y: 16,
503
+ accent: true
504
+ }), /* @__PURE__ */ React.createElement(Laptop, {
505
+ x: 170,
506
+ y: 16
507
+ }), /* @__PURE__ */ React.createElement("circle", {
508
+ className: "ta-pic-frame",
509
+ cx: "120",
510
+ cy: "34",
511
+ r: "17"
512
+ }), /* @__PURE__ */ React.createElement(Lock, {
513
+ x: 120,
514
+ y: 34
515
+ }), /* @__PURE__ */ React.createElement("path", {
516
+ className: "ta-pic-path",
517
+ d: "M80 34h20M140 34h20"
518
+ }), /* @__PURE__ */ React.createElement("circle", {
519
+ className: "ta-pic-mark ta-pic-go",
520
+ cx: "90",
521
+ cy: "34",
522
+ r: "2.6"
523
+ }), /* @__PURE__ */ React.createElement("circle", {
524
+ className: "ta-pic-mark ta-pic-go ta-pic-go-back",
525
+ cx: "150",
526
+ cy: "34",
527
+ r: "2.6"
528
+ }));
529
+ }
530
+ function FolderSyncPicture({ pi }) {
531
+ const Picture = pi.ui.Picture;
532
+ if (!Picture) {
533
+ return null;
534
+ }
535
+ return /* @__PURE__ */ React.createElement(Picture, {
536
+ width: 240,
537
+ height: 76,
538
+ frame: false,
539
+ className: "tsy-pic"
540
+ }, /* @__PURE__ */ React.createElement(Laptop, {
541
+ x: 18,
542
+ y: 22,
543
+ accent: true
544
+ }), /* @__PURE__ */ React.createElement(Laptop, {
545
+ x: 170,
546
+ y: 22
547
+ }), /* @__PURE__ */ React.createElement("path", {
548
+ className: "ta-pic-frame",
549
+ d: "M98 42a12 12 0 0 1 3-23 16 16 0 0 1 30-3 11 11 0 0 1 12 15 9 9 0 0 1-3 11z"
550
+ }), /* @__PURE__ */ React.createElement("path", {
551
+ className: "ta-pic-accent",
552
+ d: "M110 27h7l3 3h11v10h-21z"
553
+ }), /* @__PURE__ */ React.createElement("path", {
554
+ className: "ta-pic-path",
555
+ d: "M80 40l14-6M160 40l-14-6"
556
+ }), /* @__PURE__ */ React.createElement("circle", {
557
+ className: "ta-pic-mark ta-pic-go",
558
+ cx: "88",
559
+ cy: "37",
560
+ r: "2.6"
561
+ }), /* @__PURE__ */ React.createElement("circle", {
562
+ className: "ta-pic-mark ta-pic-go ta-pic-go-back",
563
+ cx: "152",
564
+ cy: "37",
565
+ r: "2.6"
566
+ }));
567
+ }
568
+ function MovePicture({ pi }) {
569
+ const Picture = pi.ui.Picture;
570
+ if (!Picture) {
571
+ return null;
572
+ }
573
+ return /* @__PURE__ */ React.createElement(Picture, {
574
+ width: 240,
575
+ height: 76,
576
+ frame: false,
577
+ className: "tsy-pic"
578
+ }, /* @__PURE__ */ React.createElement(Laptop, {
579
+ x: 18,
580
+ y: 16
581
+ }), /* @__PURE__ */ React.createElement(Laptop, {
582
+ x: 170,
583
+ y: 16,
584
+ accent: true
585
+ }), [0, 1, 2].map((i) => /* @__PURE__ */ React.createElement("rect", {
586
+ key: i,
587
+ className: "ta-pic-pane ta-pic-go",
588
+ style: { animationDelay: `${i * 0.45}s` },
589
+ x: 110,
590
+ y: 24 + i * 7,
591
+ width: "20",
592
+ height: "5",
593
+ rx: "2.5"
594
+ })), /* @__PURE__ */ React.createElement("rect", {
595
+ className: "ta-pic-pane",
596
+ x: "88",
597
+ y: "62",
598
+ width: "64",
599
+ height: "5",
600
+ rx: "2.5"
601
+ }), /* @__PURE__ */ React.createElement("rect", {
602
+ className: "ta-pic-mark tsy-pic-fill",
603
+ x: "88",
604
+ y: "62",
605
+ width: "64",
606
+ height: "5",
607
+ rx: "2.5"
608
+ }));
609
+ }
610
+ function LookingPicture({ pi }) {
611
+ const Picture = pi.ui.Picture;
612
+ if (!Picture) {
613
+ return null;
614
+ }
615
+ return /* @__PURE__ */ React.createElement(Picture, {
616
+ width: 240,
617
+ height: 76,
618
+ frame: false,
619
+ className: "tsy-pic"
620
+ }, /* @__PURE__ */ React.createElement(Laptop, {
621
+ x: 94,
622
+ y: 20,
623
+ accent: true
624
+ }), /* @__PURE__ */ React.createElement("circle", {
625
+ className: "ta-pic-accent ta-pic-pulse",
626
+ cx: "120",
627
+ cy: "37",
628
+ r: "22"
629
+ }), /* @__PURE__ */ React.createElement("circle", {
630
+ className: "ta-pic-accent ta-pic-pulse tsy-pic-later",
631
+ cx: "120",
632
+ cy: "37",
633
+ r: "22"
634
+ }));
635
+ }
636
+ function DonePicture({ pi }) {
637
+ const Picture = pi.ui.Picture;
638
+ if (!Picture) {
639
+ return null;
640
+ }
641
+ return /* @__PURE__ */ React.createElement(Picture, {
642
+ width: 240,
643
+ height: 76,
644
+ frame: false,
645
+ className: "tsy-pic"
646
+ }, /* @__PURE__ */ React.createElement(Laptop, {
647
+ x: 94,
648
+ y: 18,
649
+ accent: true
650
+ }), /* @__PURE__ */ React.createElement("circle", {
651
+ className: "ta-pic-mark",
652
+ cx: "148",
653
+ cy: "20",
654
+ r: "10"
655
+ }), /* @__PURE__ */ React.createElement("path", {
656
+ className: "ta-pic-tick",
657
+ d: "M143.5 20.5l3 3 6-6.5"
658
+ }));
659
+ }
660
+
661
+ // web-src/move-panel.tsx
662
+ function message(error) {
663
+ return error instanceof Error ? error.message : String(error);
664
+ }
665
+ function useMove(store) {
666
+ const [status, setStatus] = React.useState(store.status);
667
+ React.useEffect(() => {
668
+ setStatus(store.status);
669
+ return store.subscribe(() => setStatus(store.status));
670
+ }, [store]);
671
+ return status;
672
+ }
673
+ function useWords(pi) {
674
+ return MoveWordsUtil.of(pi.ui.language);
675
+ }
676
+ function Action({ pi, label, primary, run, disabled }) {
677
+ const [busy, start] = useBusy(pi.ui);
678
+ const words = useWords(pi);
679
+ const click = () => void start(async () => {
680
+ try {
681
+ await run();
682
+ } catch (error) {
683
+ pi.ui.notify(MoveWordsUtil.format(words.failed, { message: message(error) }), "error");
684
+ }
685
+ });
686
+ return /* @__PURE__ */ React.createElement("button", {
687
+ type: "button",
688
+ className: `ta-button${primary ? " ta-primary" : ""}${busy ? " ta-busy" : ""}`,
689
+ disabled: busy || disabled,
690
+ onClick: click
691
+ }, busy && /* @__PURE__ */ React.createElement("span", {
692
+ className: "ta-spinner ta-busy-mark"
693
+ }), /* @__PURE__ */ React.createElement("span", null, label));
694
+ }
695
+ function Progress({ pi, done, total }) {
696
+ const words = useWords(pi);
697
+ const share = total > 0 ? Math.min(1, done / total) : 0;
698
+ return /* @__PURE__ */ React.createElement("div", {
699
+ className: "tsy-progress-box"
700
+ }, /* @__PURE__ */ React.createElement("div", {
701
+ className: "tsy-total"
702
+ }, /* @__PURE__ */ React.createElement("p", {
703
+ className: "tsy-big-number"
704
+ }, Math.floor(share * 100), "%"), /* @__PURE__ */ React.createElement("span", {
705
+ className: "tsy-size"
706
+ }, MoveWordsUtil.format(words.of, { done: MoveWordsUtil.size(done), total: MoveWordsUtil.size(total) }))), /* @__PURE__ */ React.createElement("div", {
707
+ className: "tsy-progress",
708
+ role: "progressbar",
709
+ "aria-valuenow": Math.round(share * 100),
710
+ "aria-valuemin": 0,
711
+ "aria-valuemax": 100
712
+ }, /* @__PURE__ */ React.createElement("div", {
713
+ className: "tsy-progress-bar",
714
+ style: { width: `${share * 100}%` }
715
+ })));
716
+ }
717
+ function Categories({
718
+ pi,
719
+ chosen,
720
+ setChosen,
721
+ counts
722
+ }) {
723
+ const words = useWords(pi);
724
+ const Check = pi.ui.icons.Check;
725
+ const listed = [...MIGRATE_CATEGORIES].sort((a, b) => Number(!!counts && !counts[a]?.files) - Number(!!counts && !counts[b]?.files));
726
+ return /* @__PURE__ */ React.createElement("div", {
727
+ className: "tsy-what"
728
+ }, listed.map((category) => {
729
+ const count = counts?.[category];
730
+ const empty = !!counts && !count?.files;
731
+ const on = chosen.has(category) && !empty;
732
+ return /* @__PURE__ */ React.createElement("label", {
733
+ key: category,
734
+ className: `tsy-what-row tsy-check${empty ? " tsy-empty" : ""}`
735
+ }, /* @__PURE__ */ React.createElement("input", {
736
+ type: "checkbox",
737
+ checked: on,
738
+ disabled: empty,
739
+ onChange: () => {
740
+ const next = new Set(chosen);
741
+ on ? next.delete(category) : next.add(category);
742
+ setChosen(next);
743
+ }
744
+ }), /* @__PURE__ */ React.createElement("span", {
745
+ className: "tsy-check-mark",
746
+ "data-on": on ? "" : undefined
747
+ }, Check && /* @__PURE__ */ React.createElement(Check, {
748
+ size: 12,
749
+ strokeWidth: 3
750
+ })), /* @__PURE__ */ React.createElement("span", {
751
+ className: "tsy-what-text"
752
+ }, /* @__PURE__ */ React.createElement("span", {
753
+ className: "tsy-what-label"
754
+ }, MoveWordsUtil.category(words, category)), category === "credentials" && /* @__PURE__ */ React.createElement("span", {
755
+ className: "tsy-line"
756
+ }, words.credentialsHint), category === "identity" && /* @__PURE__ */ React.createElement("span", {
757
+ className: "tsy-line tsy-warn"
758
+ }, words.identityHint)), /* @__PURE__ */ React.createElement("span", {
759
+ className: "tsy-size"
760
+ }, count ? count.files ? MoveWordsUtil.size(count.bytes) : words.nothing : ""));
761
+ }));
762
+ }
763
+ function OutView({ pi, store, out }) {
764
+ const words = useWords(pi);
765
+ const [copied, setCopied] = React.useState(false);
766
+ if (out.state === "open" && out.link) {
767
+ return /* @__PURE__ */ React.createElement("div", {
768
+ className: "tsy-panel tsy-hero"
769
+ }, /* @__PURE__ */ React.createElement("p", {
770
+ className: "tsy-title"
771
+ }, words.readyTitle), pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
772
+ className: "tsy-qr"
773
+ }, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
774
+ text: out.link,
775
+ label: words.outTitle
776
+ })), /* @__PURE__ */ React.createElement("p", {
777
+ className: "tsy-lead"
778
+ }, words.showCode), /* @__PURE__ */ React.createElement("p", {
779
+ className: "tsy-status"
780
+ }, /* @__PURE__ */ React.createElement("span", {
781
+ className: "ta-spinner"
782
+ }), /* @__PURE__ */ React.createElement("span", null, words.waitingFor)), !!out.addresses?.length && /* @__PURE__ */ React.createElement("p", {
783
+ className: "tsy-line"
784
+ }, MoveWordsUtil.format(words.addresses, { addresses: out.addresses.join(" · ") })), /* @__PURE__ */ React.createElement("div", {
785
+ className: "tsy-actions"
786
+ }, /* @__PURE__ */ React.createElement("button", {
787
+ type: "button",
788
+ className: "ta-button",
789
+ onClick: () => void navigator.clipboard?.writeText(out.link).then(() => setCopied(true))
790
+ }, copied ? words.copied : words.copy), /* @__PURE__ */ React.createElement(Action, {
791
+ pi,
792
+ label: words.cancel,
793
+ run: () => store.call("migrateCloseOut")
794
+ })));
795
+ }
796
+ if (out.state === "sending") {
797
+ return /* @__PURE__ */ React.createElement("div", {
798
+ className: "tsy-panel"
799
+ }, /* @__PURE__ */ React.createElement(MovePicture, {
800
+ pi
801
+ }), /* @__PURE__ */ React.createElement("p", {
802
+ className: "tsy-big"
803
+ }, out.kind === "file" ? words.sendingFile : MoveWordsUtil.format(words.sending, { name: out.to ?? "" })), out.progress && /* @__PURE__ */ React.createElement(Progress, {
804
+ pi,
805
+ done: out.progress.done,
806
+ total: out.progress.total
807
+ }), /* @__PURE__ */ React.createElement("p", {
808
+ className: "tsy-line"
809
+ }, words.keepOpen));
810
+ }
811
+ const done = out.state === "done";
812
+ return /* @__PURE__ */ React.createElement("div", {
813
+ className: "tsy-panel tsy-hero"
814
+ }, done && /* @__PURE__ */ React.createElement(DonePicture, {
815
+ pi
816
+ }), /* @__PURE__ */ React.createElement("p", {
817
+ className: `tsy-big${done ? "" : " tsy-warn"}`
818
+ }, done ? out.kind === "file" ? MoveWordsUtil.format(words.doneFile, { path: out.path ?? "" }) : MoveWordsUtil.format(words.doneOut, { name: out.to ?? "" }) : MoveWordsUtil.format(words.failed, { message: out.error ?? "" })), done && out.path && /* @__PURE__ */ React.createElement("p", {
819
+ className: "tsy-path"
820
+ }, out.path), /* @__PURE__ */ React.createElement("div", {
821
+ className: "tsy-actions"
822
+ }, done && out.path && pi.ui.desktop && /* @__PURE__ */ React.createElement("button", {
823
+ type: "button",
824
+ className: "ta-button",
825
+ onClick: () => void pi.ui.desktop?.showItemInFolder(out.path)
826
+ }, words.showFile), /* @__PURE__ */ React.createElement(Action, {
827
+ pi,
828
+ primary: true,
829
+ label: words.again,
830
+ run: () => store.call("migrateCloseOut")
831
+ })));
832
+ }
833
+ function InView({ pi, store, into }) {
834
+ const words = useWords(pi);
835
+ const name = into.manifest?.from.name ?? into.from ?? "";
836
+ if (into.state === "connecting" || into.state === "waiting") {
837
+ const waiting = into.state === "waiting" && into.code;
838
+ return /* @__PURE__ */ React.createElement("div", {
839
+ className: "tsy-panel tsy-hero"
840
+ }, /* @__PURE__ */ React.createElement(MovePicture, {
841
+ pi
842
+ }), waiting ? /* @__PURE__ */ React.createElement("div", {
843
+ className: "tsy-code-box"
844
+ }, /* @__PURE__ */ React.createElement("p", {
845
+ className: "tsy-big"
846
+ }, MoveWordsUtil.format(words.waiting, { name })), /* @__PURE__ */ React.createElement("div", {
847
+ className: "tsy-code"
848
+ }, into.code), /* @__PURE__ */ React.createElement("p", {
849
+ className: "tsy-line"
850
+ }, words.waitingCompare)) : /* @__PURE__ */ React.createElement("p", {
851
+ className: "tsy-status"
852
+ }, /* @__PURE__ */ React.createElement("span", {
853
+ className: "ta-spinner"
854
+ }), /* @__PURE__ */ React.createElement("span", null, MoveWordsUtil.format(words.connecting, { name }))));
855
+ }
856
+ if (into.state === "receiving") {
857
+ return /* @__PURE__ */ React.createElement("div", {
858
+ className: "tsy-panel"
859
+ }, /* @__PURE__ */ React.createElement(MovePicture, {
860
+ pi
861
+ }), /* @__PURE__ */ React.createElement("p", {
862
+ className: "tsy-big"
863
+ }, MoveWordsUtil.format(into.kind === "file" ? words.readingFile : words.receiving, { name })), into.progress && /* @__PURE__ */ React.createElement(Progress, {
864
+ pi,
865
+ done: into.progress.done,
866
+ total: into.progress.total
867
+ }), /* @__PURE__ */ React.createElement("p", {
868
+ className: "tsy-line"
869
+ }, words.keepOpen));
870
+ }
871
+ const report = into.report;
872
+ if (into.state === "failed" || !report) {
873
+ return /* @__PURE__ */ React.createElement("div", {
874
+ className: "tsy-panel tsy-hero"
875
+ }, /* @__PURE__ */ React.createElement("p", {
876
+ className: "tsy-big tsy-warn"
877
+ }, MoveWordsUtil.format(words.failed, { message: into.error ?? "" })), /* @__PURE__ */ React.createElement("div", {
878
+ className: "tsy-actions"
879
+ }, /* @__PURE__ */ React.createElement(Action, {
880
+ pi,
881
+ primary: true,
882
+ label: words.again,
883
+ run: () => store.call("migrateCloseIn")
884
+ })));
885
+ }
886
+ const notes = [];
887
+ if (report.keptConversations) {
888
+ notes.push({ text: MoveWordsUtil.format(words.kept, { n: report.keptConversations }) });
889
+ }
890
+ if (report.extensions) {
891
+ notes.push({ text: words.restart });
892
+ }
893
+ if (report.identity?.switched) {
894
+ notes.push({ text: MoveWordsUtil.format(words.identitySwitched, { name, rooms: report.identity.rooms }) });
895
+ } else if (report.identity && (report.identity.rooms || report.identity.friends)) {
896
+ notes.push({ text: MoveWordsUtil.format(words.identityMerged, { rooms: report.identity.rooms, friends: report.identity.friends }) });
897
+ }
898
+ if (report.skipped.length) {
899
+ notes.push({ text: MoveWordsUtil.format(words.skipped, { ids: report.skipped.map((each) => each.id).join(", ") }), warn: true });
900
+ }
901
+ return /* @__PURE__ */ React.createElement("div", {
902
+ className: "tsy-panel"
903
+ }, /* @__PURE__ */ React.createElement("div", {
904
+ className: "tsy-hero"
905
+ }, /* @__PURE__ */ React.createElement(DonePicture, {
906
+ pi
907
+ }), /* @__PURE__ */ React.createElement("p", {
908
+ className: "tsy-big"
909
+ }, MoveWordsUtil.format(words.doneFrom, { name }))), /* @__PURE__ */ React.createElement("div", {
910
+ className: "tsy-facts"
911
+ }, /* @__PURE__ */ React.createElement("div", {
912
+ className: "tsy-fact"
913
+ }, /* @__PURE__ */ React.createElement("b", null, report.conversations), /* @__PURE__ */ React.createElement("span", null, words.factConversations)), /* @__PURE__ */ React.createElement("div", {
914
+ className: "tsy-fact"
915
+ }, /* @__PURE__ */ React.createElement("b", null, report.items), /* @__PURE__ */ React.createElement("span", null, words.factItems)), /* @__PURE__ */ React.createElement("div", {
916
+ className: "tsy-fact"
917
+ }, /* @__PURE__ */ React.createElement("b", null, report.data), /* @__PURE__ */ React.createElement("span", null, words.factData))), notes.map((line) => /* @__PURE__ */ React.createElement("p", {
918
+ key: line.text,
919
+ className: `tsy-line${line.warn ? " tsy-warn" : ""}`
920
+ }, line.text)), report.replaced && !pi.ui.desktop && /* @__PURE__ */ React.createElement("p", {
921
+ className: "tsy-line"
922
+ }, words.replacedLead, " ", /* @__PURE__ */ React.createElement("span", {
923
+ className: "tsy-path"
924
+ }, report.replaced)), /* @__PURE__ */ React.createElement("div", {
925
+ className: "tsy-actions tsy-end"
926
+ }, report.extensions ? /* @__PURE__ */ React.createElement(Action, {
927
+ pi,
928
+ label: words.reload,
929
+ run: () => pi.reloadExtensions()
930
+ }) : null, report.replaced && pi.ui.desktop ? /* @__PURE__ */ React.createElement("button", {
931
+ type: "button",
932
+ className: "ta-button",
933
+ onClick: () => void pi.ui.desktop?.showItemInFolder(report.replaced)
934
+ }, words.showReplaced) : null, /* @__PURE__ */ React.createElement(Action, {
935
+ pi,
936
+ primary: true,
937
+ label: words.again,
938
+ run: () => store.call("migrateCloseIn")
939
+ })));
940
+ }
941
+ function ReceiveView({ pi, store, status }) {
942
+ const words = useWords(pi);
943
+ const [link, setLink] = React.useState("");
944
+ const receive = (text) => store.call("migrateReceive", text.trim());
945
+ const scan = async () => {
946
+ const text = (await pi.ui.scanCode?.(words.scanHint))?.trim();
947
+ if (text) {
948
+ await receive(text);
949
+ }
950
+ };
951
+ return /* @__PURE__ */ React.createElement("div", {
952
+ className: "tsy-panel"
953
+ }, !(status.nearby ?? []).length && /* @__PURE__ */ React.createElement(LookingPicture, {
954
+ pi
955
+ }), /* @__PURE__ */ React.createElement("p", {
956
+ className: "tsy-section"
957
+ }, words.nearby), /* @__PURE__ */ React.createElement("div", {
958
+ className: "tsy-devices"
959
+ }, (status.nearby ?? []).length ? status.nearby?.map((each) => /* @__PURE__ */ React.createElement("div", {
960
+ key: each.link,
961
+ className: "tsy-device"
962
+ }, /* @__PURE__ */ React.createElement("span", {
963
+ className: "tsy-device-icon"
964
+ }, pi.ui.icons.Laptop && /* @__PURE__ */ React.createElement(pi.ui.icons.Laptop, {
965
+ size: 18
966
+ })), /* @__PURE__ */ React.createElement("span", {
967
+ className: "tsy-device-text"
968
+ }, /* @__PURE__ */ React.createElement("span", {
969
+ className: "tsy-device-name"
970
+ }, each.name), /* @__PURE__ */ React.createElement("span", {
971
+ className: "tsy-device-line"
972
+ }, each.address)), /* @__PURE__ */ React.createElement(Action, {
973
+ pi,
974
+ primary: true,
975
+ label: words.receive,
976
+ run: () => receive(each.link)
977
+ }))) : /* @__PURE__ */ React.createElement("div", {
978
+ className: "tsy-device"
979
+ }, /* @__PURE__ */ React.createElement("span", {
980
+ className: "tsy-status"
981
+ }, /* @__PURE__ */ React.createElement("span", {
982
+ className: "ta-spinner"
983
+ }), /* @__PURE__ */ React.createElement("span", null, status.nearby ? words.noneNearby : words.looking)))), /* @__PURE__ */ React.createElement("p", {
984
+ className: "tsy-section"
985
+ }, words.orLink), /* @__PURE__ */ React.createElement("div", {
986
+ className: "tsy-row"
987
+ }, /* @__PURE__ */ React.createElement("input", {
988
+ className: "tsy-field",
989
+ value: link,
990
+ placeholder: words.pastePlaceholder,
991
+ "aria-label": words.paste,
992
+ onChange: (event) => setLink(event.target.value),
993
+ onKeyDown: (event) => event.key === "Enter" && link.trim() && void receive(link).catch((error) => pi.ui.notify(message(error), "error"))
994
+ }), /* @__PURE__ */ React.createElement(Action, {
995
+ pi,
996
+ label: words.receive,
997
+ disabled: !link.trim(),
998
+ run: () => receive(link)
999
+ }), pi.ui.scanCode && /* @__PURE__ */ React.createElement(Action, {
1000
+ pi,
1001
+ label: words.scan,
1002
+ run: scan
1003
+ })));
1004
+ }
1005
+ function FileView({ pi, store, chosen }) {
1006
+ const words = useWords(pi);
1007
+ const [password, setPassword] = React.useState("");
1008
+ const [path, setPath] = React.useState("");
1009
+ const [restorePassword, setRestorePassword] = React.useState("");
1010
+ const [backups, setBackups] = React.useState();
1011
+ React.useEffect(() => {
1012
+ pi.callHost("migrateBackups").then(setBackups, () => setBackups([]));
1013
+ }, [pi]);
1014
+ const picked = backups?.find((each) => each.path === path);
1015
+ return /* @__PURE__ */ React.createElement("div", {
1016
+ className: "tsy-panel"
1017
+ }, /* @__PURE__ */ React.createElement("p", {
1018
+ className: "tsy-section"
1019
+ }, words.writeBackup), /* @__PURE__ */ React.createElement("div", {
1020
+ className: "tsy-row"
1021
+ }, /* @__PURE__ */ React.createElement("input", {
1022
+ className: "tsy-field",
1023
+ type: "password",
1024
+ value: password,
1025
+ placeholder: words.password,
1026
+ "aria-label": words.password,
1027
+ onChange: (event) => setPassword(event.target.value)
1028
+ }), /* @__PURE__ */ React.createElement(Action, {
1029
+ pi,
1030
+ label: words.exportFile,
1031
+ disabled: !chosen.size,
1032
+ run: () => store.call("migrateExport", [...chosen], password)
1033
+ })), /* @__PURE__ */ React.createElement("p", {
1034
+ className: "tsy-line"
1035
+ }, words.passwordHint), /* @__PURE__ */ React.createElement("p", {
1036
+ className: "tsy-section"
1037
+ }, words.backups), /* @__PURE__ */ React.createElement("div", {
1038
+ className: "tsy-devices"
1039
+ }, backups?.length ? backups.slice(0, 5).map((each) => /* @__PURE__ */ React.createElement("button", {
1040
+ key: each.path,
1041
+ type: "button",
1042
+ className: `tsy-device tsy-pick${each.path === path ? " tsy-picked" : ""}`,
1043
+ onClick: () => setPath(each.path)
1044
+ }, /* @__PURE__ */ React.createElement("span", {
1045
+ className: "tsy-device-icon"
1046
+ }, pi.ui.icons.FileArchive && /* @__PURE__ */ React.createElement(pi.ui.icons.FileArchive, {
1047
+ size: 18
1048
+ })), /* @__PURE__ */ React.createElement("span", {
1049
+ className: "tsy-device-text"
1050
+ }, /* @__PURE__ */ React.createElement("span", {
1051
+ className: "tsy-device-name"
1052
+ }, each.name), /* @__PURE__ */ React.createElement("span", {
1053
+ className: "tsy-device-line"
1054
+ }, [MoveWordsUtil.size(each.size), new Date(each.modifiedAt).toLocaleString(), each.encrypted ? words.encrypted : ""].filter(Boolean).join(" · "))))) : /* @__PURE__ */ React.createElement("div", {
1055
+ className: "tsy-device"
1056
+ }, /* @__PURE__ */ React.createElement("span", {
1057
+ className: "tsy-status"
1058
+ }, !backups && /* @__PURE__ */ React.createElement("span", {
1059
+ className: "ta-spinner"
1060
+ }), /* @__PURE__ */ React.createElement("span", null, backups ? words.noBackups : words.lookingBackups)))), /* @__PURE__ */ React.createElement("div", {
1061
+ className: "tsy-row"
1062
+ }, /* @__PURE__ */ React.createElement("input", {
1063
+ className: "tsy-field",
1064
+ value: path,
1065
+ placeholder: words.pathPlaceholder,
1066
+ "aria-label": words.pathPlaceholder,
1067
+ onChange: (event) => setPath(event.target.value)
1068
+ }), (picked?.encrypted ?? true) && /* @__PURE__ */ React.createElement("input", {
1069
+ className: "tsy-field tsy-short",
1070
+ type: "password",
1071
+ value: restorePassword,
1072
+ placeholder: picked?.encrypted ? words.passwordNeeded : words.password,
1073
+ "aria-label": words.password,
1074
+ onChange: (event) => setRestorePassword(event.target.value)
1075
+ }), /* @__PURE__ */ React.createElement(Action, {
1076
+ pi,
1077
+ label: words.restore,
1078
+ disabled: !path.trim(),
1079
+ run: () => store.call("migrateImport", path.trim(), restorePassword)
1080
+ })));
1081
+ }
1082
+ function MovePanel({ pi, store }) {
1083
+ const words = useWords(pi);
1084
+ const status = useMove(store);
1085
+ const [tab, setTab] = React.useState("out");
1086
+ const [chosen, setChosen] = React.useState(() => new Set(MIGRATE_CATEGORIES.filter((category) => DEFAULT_CATEGORIES[category])));
1087
+ const [counts, setCounts] = React.useState();
1088
+ React.useEffect(() => {
1089
+ pi.callHost("migrateCounts").then(setCounts, () => {
1090
+ return;
1091
+ });
1092
+ }, [pi]);
1093
+ const receiving = tab === "in" && !status.in;
1094
+ React.useEffect(() => {
1095
+ if (!receiving) {
1096
+ return;
1097
+ }
1098
+ pi.callHost("migrateDiscover").catch(() => {
1099
+ return;
1100
+ });
1101
+ return () => void pi.callHost("migrateStopDiscovering").catch(() => {
1102
+ return;
1103
+ });
1104
+ }, [pi, receiving]);
1105
+ if (status.in) {
1106
+ return /* @__PURE__ */ React.createElement(InView, {
1107
+ pi,
1108
+ store,
1109
+ into: status.in
1110
+ });
1111
+ }
1112
+ if (status.out) {
1113
+ return /* @__PURE__ */ React.createElement(OutView, {
1114
+ pi,
1115
+ store,
1116
+ out: status.out
1117
+ });
1118
+ }
1119
+ const tabs = [
1120
+ ["out", words.tabOut],
1121
+ ["in", words.tabIn],
1122
+ ["file", words.tabFile]
1123
+ ];
1124
+ const total = counts ? [...chosen].reduce((sum, category) => sum + (counts[category]?.bytes ?? 0), 0) : undefined;
1125
+ return /* @__PURE__ */ React.createElement("div", {
1126
+ className: "tsy-panel"
1127
+ }, /* @__PURE__ */ React.createElement("div", {
1128
+ className: "tsy-hero"
1129
+ }, tab !== "in" && /* @__PURE__ */ React.createElement(MovePicture, {
1130
+ pi
1131
+ }), /* @__PURE__ */ React.createElement("p", {
1132
+ className: "tsy-lead"
1133
+ }, words.lead)), /* @__PURE__ */ React.createElement("div", {
1134
+ className: "ta-segmented tsy-tabs",
1135
+ role: "tablist"
1136
+ }, tabs.map(([key, label]) => /* @__PURE__ */ React.createElement("button", {
1137
+ key,
1138
+ type: "button",
1139
+ role: "tab",
1140
+ "aria-selected": tab === key,
1141
+ className: tab === key ? "ta-on" : "",
1142
+ onClick: () => setTab(key)
1143
+ }, label))), tab === "in" ? /* @__PURE__ */ React.createElement(ReceiveView, {
1144
+ pi,
1145
+ store,
1146
+ status
1147
+ }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
1148
+ className: "tsy-line"
1149
+ }, tab === "out" ? words.outHint : words.fileHint), /* @__PURE__ */ React.createElement(Categories, {
1150
+ pi,
1151
+ chosen,
1152
+ setChosen,
1153
+ counts
1154
+ }), tab === "out" ? /* @__PURE__ */ React.createElement("div", {
1155
+ className: "tsy-total"
1156
+ }, /* @__PURE__ */ React.createElement("span", {
1157
+ className: "tsy-size"
1158
+ }, total !== undefined ? MoveWordsUtil.format(words.chosenSize, { size: MoveWordsUtil.size(total) }) : ""), /* @__PURE__ */ React.createElement(Action, {
1159
+ pi,
1160
+ primary: true,
1161
+ label: words.start,
1162
+ disabled: !chosen.size,
1163
+ run: () => store.call("migrateOpen", [...chosen].filter((category) => !counts || counts[category]?.files))
1164
+ })) : /* @__PURE__ */ React.createElement(FileView, {
1165
+ pi,
1166
+ store,
1167
+ chosen
1168
+ })));
1169
+ }
1170
+ function MoveAskDialog({ pi, store, close }) {
1171
+ const words = useWords(pi);
1172
+ const asks = useMove(store).out?.asks ?? [];
1173
+ const seen = React.useRef(false);
1174
+ React.useEffect(() => {
1175
+ if (asks.length) {
1176
+ seen.current = true;
1177
+ } else if (seen.current) {
1178
+ close();
1179
+ }
1180
+ }, [asks.length, close]);
1181
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1182
+ title: words.title,
1183
+ onClose: close
1184
+ }, /* @__PURE__ */ React.createElement("div", {
1185
+ className: "tsy-dialog"
1186
+ }, asks.map((ask) => /* @__PURE__ */ React.createElement("div", {
1187
+ key: ask.ask,
1188
+ className: "tsy-panel"
1189
+ }, /* @__PURE__ */ React.createElement("div", {
1190
+ className: "tsy-code-box"
1191
+ }, /* @__PURE__ */ React.createElement("p", {
1192
+ className: "tsy-big"
1193
+ }, MoveWordsUtil.format(words.asks, { name: ask.name })), /* @__PURE__ */ React.createElement("div", {
1194
+ className: "tsy-code"
1195
+ }, ask.code), /* @__PURE__ */ React.createElement("p", {
1196
+ className: "tsy-line"
1197
+ }, words.compareHint)), /* @__PURE__ */ React.createElement("div", {
1198
+ className: "tsy-actions tsy-end"
1199
+ }, /* @__PURE__ */ React.createElement(Action, {
1200
+ pi,
1201
+ label: words.refuse,
1202
+ run: () => store.call("migrateAnswer", ask.ask, false)
1203
+ }), /* @__PURE__ */ React.createElement(Action, {
1204
+ pi,
1205
+ primary: true,
1206
+ label: words.allow,
1207
+ run: () => store.call("migrateAnswer", ask.ask, true)
1208
+ }))))));
1209
+ }
1210
+
1211
+ // web-src/move-store.ts
1212
+ class MoveStore {
1213
+ pi;
1214
+ current = {};
1215
+ listeners = new Set;
1216
+ constructor(pi) {
1217
+ this.pi = pi;
1218
+ pi.callHost("migrateStatus").then((status) => this.set(status), () => {
1219
+ return;
1220
+ });
1221
+ pi.storage.onChange((keys) => {
1222
+ if (keys.includes(MIGRATE_STATUS_KEY)) {
1223
+ pi.storage.get(MIGRATE_STATUS_KEY).then((status) => this.set(status ?? {}));
1224
+ }
1225
+ });
1226
+ }
1227
+ get status() {
1228
+ return this.current;
1229
+ }
1230
+ subscribe(listener) {
1231
+ this.listeners.add(listener);
1232
+ return () => this.listeners.delete(listener);
1233
+ }
1234
+ async call(method, ...params) {
1235
+ const status = await this.pi.callHost(method, ...params);
1236
+ this.set(status);
1237
+ return status;
1238
+ }
1239
+ set(status) {
1240
+ if (!status) {
1241
+ return;
1242
+ }
1243
+ this.current = status;
1244
+ for (const listener of this.listeners) {
1245
+ listener();
1246
+ }
1247
+ }
1248
+ }
1249
+
1250
+ // web-src/sync-protocol.ts
1251
+ var SYNC_PACKAGE = "@celljs/ta-sync";
1252
+ var SYNC_VIEW = `${SYNC_PACKAGE}/devices`;
1253
+ var SYNC_RESOURCES = ["settings", "instructions", "skills", "models", "extensions", "data", "identity"];
1254
+ var SyncKeys;
1255
+ ((SyncKeys) => {
1256
+ SyncKeys.RESOURCES = "resources";
1257
+ SyncKeys.REPORT = "report";
1258
+ SyncKeys.STATUS = "status";
1259
+ SyncKeys.JOINING = "joining";
1260
+ })(SyncKeys ||= {});
1261
+ var SyncStateKeys;
1262
+ ((SyncStateKeys) => {
1263
+ SyncStateKeys.ITEM = "item:";
1264
+ SyncStateKeys.BLOB = "blob:";
1265
+ SyncStateKeys.DEVICE = "device:";
1266
+ function item(id) {
1267
+ return `${SyncStateKeys.ITEM}${id}`;
1268
+ }
1269
+ SyncStateKeys.item = item;
1270
+ function blob(hash, index) {
1271
+ return `${SyncStateKeys.BLOB}${hash}:${index}`;
1272
+ }
1273
+ SyncStateKeys.blob = blob;
1274
+ function device(member) {
1275
+ return `${SyncStateKeys.DEVICE}${member}`;
1276
+ }
1277
+ SyncStateKeys.device = device;
1278
+ })(SyncStateKeys ||= {});
1279
+ var SyncDeclarations;
1280
+ ((SyncDeclarations) => {
1281
+ SyncDeclarations.SHELL = {
1282
+ "@celljs/ta-web": ["settings", "assistant.species", "assistant.gait"]
1283
+ };
1284
+ function keys(manifest) {
1285
+ const pi = manifest && typeof manifest === "object" ? manifest.pi : undefined;
1286
+ const sync = pi?.sync;
1287
+ return Array.isArray(sync) ? [...new Set(sync.filter((key) => typeof key === "string" && key.length > 0 && key.length <= 200))] : [];
1288
+ }
1289
+ SyncDeclarations.keys = keys;
1290
+ })(SyncDeclarations ||= {});
1291
+
1292
+ // web-src/panel.tsx
1293
+ function message2(error) {
1294
+ return error instanceof Error ? error.message : String(error);
1295
+ }
1296
+ function useStatus(store) {
1297
+ const [status, setStatus] = React.useState(store.status);
1298
+ React.useEffect(() => {
1299
+ setStatus(store.status);
1300
+ return store.subscribe(() => setStatus(store.status));
1301
+ }, [store]);
1302
+ return status;
1303
+ }
1304
+ function useWords2(pi) {
1305
+ return SyncWords.of(pi.ui.language);
1306
+ }
1307
+ function Action2({ pi, label, primary, danger, run }) {
1308
+ const [busy, start] = useBusy(pi.ui);
1309
+ const words = useWords2(pi);
1310
+ const click = () => void start(async () => {
1311
+ try {
1312
+ await run();
1313
+ } catch (error) {
1314
+ pi.ui.notify(SyncWords.format(words.failed, { message: message2(error) }), "error");
1315
+ }
1316
+ });
1317
+ const kind = primary ? " ta-primary" : danger ? " ta-danger" : "";
1318
+ return /* @__PURE__ */ React.createElement("button", {
1319
+ type: "button",
1320
+ className: `ta-button${kind}${busy ? " ta-busy" : ""}`,
1321
+ disabled: busy,
1322
+ onClick: click
1323
+ }, busy && /* @__PURE__ */ React.createElement("span", {
1324
+ className: "ta-spinner ta-busy-mark"
1325
+ }), /* @__PURE__ */ React.createElement("span", null, label));
1326
+ }
1327
+ function AskDialog({ pi, store, close }) {
1328
+ const words = useWords2(pi);
1329
+ const asks = useStatus(store)?.asks ?? [];
1330
+ const seen = React.useRef(false);
1331
+ React.useEffect(() => {
1332
+ if (asks.length) {
1333
+ seen.current = true;
1334
+ } else if (seen.current) {
1335
+ close();
1336
+ }
1337
+ }, [asks.length, close]);
1338
+ const Icon = pi.ui.icons.Laptop;
1339
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1340
+ title: words.asksTitle,
1341
+ onClose: close
1342
+ }, /* @__PURE__ */ React.createElement("div", {
1343
+ className: "tsy-dialog"
1344
+ }, /* @__PURE__ */ React.createElement(RelaySyncPicture, {
1345
+ pi
1346
+ }), asks.map((ask) => /* @__PURE__ */ React.createElement("div", {
1347
+ key: ask.ask,
1348
+ className: "tsy-panel"
1349
+ }, /* @__PURE__ */ React.createElement("div", {
1350
+ className: "tsy-device tsy-ask"
1351
+ }, /* @__PURE__ */ React.createElement("span", {
1352
+ className: "tsy-device-icon"
1353
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
1354
+ size: 18
1355
+ })), /* @__PURE__ */ React.createElement("span", {
1356
+ className: "tsy-device-text"
1357
+ }, /* @__PURE__ */ React.createElement("span", {
1358
+ className: "tsy-device-name"
1359
+ }, ask.name), /* @__PURE__ */ React.createElement("span", {
1360
+ className: "tsy-device-line"
1361
+ }, SyncWords.format(words.asksWhen, { when: SyncWords.when(words, ask.at) })))), /* @__PURE__ */ React.createElement("p", {
1362
+ className: "tsy-lead"
1363
+ }, words.asksBody.replace("{name}", ask.name)), /* @__PURE__ */ React.createElement("div", {
1364
+ className: "tsy-actions tsy-end"
1365
+ }, /* @__PURE__ */ React.createElement("button", {
1366
+ type: "button",
1367
+ className: "ta-button",
1368
+ onClick: close
1369
+ }, words.later), /* @__PURE__ */ React.createElement(Action2, {
1370
+ pi,
1371
+ label: words.refuse,
1372
+ run: () => store.call("answer", ask.ask, false)
1373
+ }), /* @__PURE__ */ React.createElement(Action2, {
1374
+ pi,
1375
+ primary: true,
1376
+ label: words.allow,
1377
+ run: () => store.call("answer", ask.ask, true)
1378
+ }))))));
1379
+ }
1380
+ function InviteDialog({ pi, close, folder, store }) {
1381
+ const words = useWords2(pi);
1382
+ const [link, setLink] = React.useState();
1383
+ const [error, setError] = React.useState();
1384
+ const [copied, setCopied] = React.useState(false);
1385
+ const make = React.useCallback((renew) => {
1386
+ setError(undefined);
1387
+ setCopied(false);
1388
+ pi.callHost("invite", renew).then((made) => setLink(made.link), (failure) => setError(message2(failure)));
1389
+ }, [pi]);
1390
+ React.useEffect(() => make(false), [make]);
1391
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1392
+ title: words.inviteTitle,
1393
+ onClose: close
1394
+ }, /* @__PURE__ */ React.createElement("div", {
1395
+ className: "tsy-dialog"
1396
+ }, link ? /* @__PURE__ */ React.createElement(React.Fragment, null, pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
1397
+ className: "tsy-qr"
1398
+ }, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
1399
+ text: link,
1400
+ label: words.inviteTitle
1401
+ })), /* @__PURE__ */ React.createElement("p", {
1402
+ className: "tsy-lead"
1403
+ }, store ? words.inviteStoreHint : folder ? words.inviteFolderHint : words.inviteHint), /* @__PURE__ */ React.createElement("div", {
1404
+ className: "tsy-link-box",
1405
+ title: link
1406
+ }, link), /* @__PURE__ */ React.createElement("div", {
1407
+ className: "tsy-actions tsy-end"
1408
+ }, /* @__PURE__ */ React.createElement("button", {
1409
+ type: "button",
1410
+ className: "ta-button ta-primary",
1411
+ onClick: () => void navigator.clipboard?.writeText(link).then(() => setCopied(true))
1412
+ }, copied ? words.copied : words.copy), !folder && /* @__PURE__ */ React.createElement("button", {
1413
+ type: "button",
1414
+ className: "ta-button",
1415
+ onClick: () => make(true)
1416
+ }, words.newLink))) : error ? /* @__PURE__ */ React.createElement("p", {
1417
+ className: "tsy-error"
1418
+ }, error) : /* @__PURE__ */ React.createElement("p", {
1419
+ className: "tsy-lead"
1420
+ }, words.making)));
1421
+ }
1422
+ function JoinDialog({ pi, store, close }) {
1423
+ const words = useWords2(pi);
1424
+ const [link, setLink] = React.useState("");
1425
+ const [error, setError] = React.useState();
1426
+ const [busy, start] = useBusy(pi.ui);
1427
+ const join = (text) => void start(async () => {
1428
+ setError(undefined);
1429
+ try {
1430
+ await store.call("join", text.trim());
1431
+ close();
1432
+ } catch (failure) {
1433
+ setError(message2(failure));
1434
+ }
1435
+ });
1436
+ const scan = async () => {
1437
+ const text = (await pi.ui.scanCode?.(words.scanHint))?.trim();
1438
+ if (text) {
1439
+ setLink(text);
1440
+ join(text);
1441
+ }
1442
+ };
1443
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1444
+ title: words.joinTitle,
1445
+ onClose: close
1446
+ }, /* @__PURE__ */ React.createElement("div", {
1447
+ className: "tsy-dialog"
1448
+ }, /* @__PURE__ */ React.createElement("p", {
1449
+ className: "tsy-lead"
1450
+ }, words.joinHint), /* @__PURE__ */ React.createElement("input", {
1451
+ className: "tsy-field",
1452
+ autoFocus: true,
1453
+ value: link,
1454
+ placeholder: words.joinPlaceholder,
1455
+ "aria-label": words.joinPlaceholder,
1456
+ onChange: (event) => setLink(event.target.value),
1457
+ onKeyDown: (event) => event.key === "Enter" && link.trim() && join(link)
1458
+ }), error && /* @__PURE__ */ React.createElement("p", {
1459
+ className: "tsy-error"
1460
+ }, error), /* @__PURE__ */ React.createElement("div", {
1461
+ className: "tsy-actions tsy-end"
1462
+ }, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
1463
+ type: "button",
1464
+ className: "ta-button",
1465
+ onClick: () => void scan()
1466
+ }, words.scan), /* @__PURE__ */ React.createElement("button", {
1467
+ type: "button",
1468
+ className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
1469
+ disabled: busy || !link.trim(),
1470
+ onClick: () => join(link)
1471
+ }, busy && /* @__PURE__ */ React.createElement("span", {
1472
+ className: "ta-spinner ta-busy-mark"
1473
+ }), /* @__PURE__ */ React.createElement("span", null, words.joinAction)))));
1474
+ }
1475
+ function DeviceRow({ pi, store, device, owner }) {
1476
+ const words = useWords2(pi);
1477
+ const Icon = (/darwin|win32|linux/.test(device.platform ?? "") ? pi.ui.icons.Laptop : pi.ui.icons.MonitorSmartphone) ?? pi.ui.icons.Server;
1478
+ const parts = device.self ? [words.thisDevice] : device.online ? [words.online] : device.at && !device.owner ? [] : [words.offline];
1479
+ if (device.at) {
1480
+ parts.push(SyncWords.format(words.lastSync, { when: SyncWords.when(words, device.at) }));
1481
+ }
1482
+ if (device.owner) {
1483
+ parts.push(words.owner);
1484
+ }
1485
+ const remove = async () => {
1486
+ if (await pi.ui.confirm(SyncWords.format(words.removeConfirm, { name: device.name }))) {
1487
+ await store.call("removeDevice", device.member);
1488
+ }
1489
+ };
1490
+ return /* @__PURE__ */ React.createElement("div", {
1491
+ className: "tsy-device"
1492
+ }, /* @__PURE__ */ React.createElement("span", {
1493
+ className: "tsy-device-icon"
1494
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
1495
+ size: 18
1496
+ })), /* @__PURE__ */ React.createElement("span", {
1497
+ className: "tsy-device-text"
1498
+ }, /* @__PURE__ */ React.createElement("span", {
1499
+ className: "tsy-device-name"
1500
+ }, device.name), /* @__PURE__ */ React.createElement("span", {
1501
+ className: "tsy-device-line"
1502
+ }, /* @__PURE__ */ React.createElement("span", {
1503
+ className: `tsy-dot${device.online ? " tsy-on" : ""}`
1504
+ }), /* @__PURE__ */ React.createElement("span", null, parts.join(" · ")))), owner && !device.self && /* @__PURE__ */ React.createElement("button", {
1505
+ type: "button",
1506
+ className: "tsy-link tsy-danger",
1507
+ onClick: () => void remove().catch((error) => pi.ui.notify(message2(error), "error"))
1508
+ }, words.remove));
1509
+ }
1510
+ function Status({ pi, status }) {
1511
+ const words = useWords2(pi);
1512
+ const last = status.last;
1513
+ const problem = status.folder?.problem ?? status.store?.problem;
1514
+ if (problem || last?.error) {
1515
+ return /* @__PURE__ */ React.createElement("p", {
1516
+ className: "tsy-status tsy-warn"
1517
+ }, /* @__PURE__ */ React.createElement("span", {
1518
+ className: "tsy-dot",
1519
+ style: { background: "var(--ta-yellow)" }
1520
+ }), /* @__PURE__ */ React.createElement("span", null, problem ?? SyncWords.format(words.failed, { message: last?.error ?? "" })));
1521
+ }
1522
+ if (status.syncing) {
1523
+ return /* @__PURE__ */ React.createElement("p", {
1524
+ className: "tsy-status"
1525
+ }, /* @__PURE__ */ React.createElement("span", {
1526
+ className: "ta-spinner"
1527
+ }), /* @__PURE__ */ React.createElement("span", null, words.syncing));
1528
+ }
1529
+ if (!last) {
1530
+ return null;
1531
+ }
1532
+ const counts = last.sent || last.received ? SyncWords.format(words.report, { sent: last.sent, received: last.received }) : words.upToDate;
1533
+ return /* @__PURE__ */ React.createElement("p", {
1534
+ className: "tsy-status"
1535
+ }, /* @__PURE__ */ React.createElement("span", {
1536
+ className: "tsy-dot tsy-on"
1537
+ }), /* @__PURE__ */ React.createElement("span", null, `${SyncWords.format(words.lastSync, { when: SyncWords.when(words, last.at) })} · ${counts}`));
1538
+ }
1539
+ function Via({ pi, status }) {
1540
+ const words = useWords2(pi);
1541
+ if (!status.via) {
1542
+ return null;
1543
+ }
1544
+ const Icon = status.where === "folder" ? pi.ui.icons.Folder : status.where === "store" ? pi.ui.icons.Cloud : pi.ui.icons.Server;
1545
+ return /* @__PURE__ */ React.createElement("span", {
1546
+ className: "tsy-via",
1547
+ title: status.folder?.path ?? status.store?.where
1548
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
1549
+ size: 13
1550
+ }), /* @__PURE__ */ React.createElement("span", null, SyncWords.format(status.where === "folder" ? words.viaFolder : words.viaRelay, { name: status.via })));
1551
+ }
1552
+ function Notes({ pi, status }) {
1553
+ const words = useWords2(pi);
1554
+ const last = status.last;
1555
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !!last?.skipped.length && /* @__PURE__ */ React.createElement("p", {
1556
+ className: "tsy-line tsy-warn"
1557
+ }, SyncWords.format(words.skipped, { ids: last.skipped.map((item) => item.id).join(", ") })), !!status.replaced.count && /* @__PURE__ */ React.createElement("p", {
1558
+ className: "tsy-line"
1559
+ }, words.replacedShort, pi.ui.desktop ? /* @__PURE__ */ React.createElement("button", {
1560
+ type: "button",
1561
+ className: "tsy-link",
1562
+ onClick: () => void pi.ui.desktop?.showItemInFolder(status.replaced.dir)
1563
+ }, words.showFolder) : null));
1564
+ }
1565
+ function SyncPanel({ pi, store }) {
1566
+ const words = useWords2(pi);
1567
+ const status = useStatus(store);
1568
+ if (!status) {
1569
+ return /* @__PURE__ */ React.createElement("p", {
1570
+ className: "tsy-status"
1571
+ }, /* @__PURE__ */ React.createElement("span", {
1572
+ className: "ta-spinner"
1573
+ }), /* @__PURE__ */ React.createElement("span", null, words.connecting));
1574
+ }
1575
+ const openJoin = () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(JoinDialog, {
1576
+ pi,
1577
+ store,
1578
+ close
1579
+ }));
1580
+ const inStore = status.where === "store";
1581
+ const folder = status.where === "folder" || inStore;
1582
+ const picture = folder ? /* @__PURE__ */ React.createElement(FolderSyncPicture, {
1583
+ pi
1584
+ }) : /* @__PURE__ */ React.createElement(RelaySyncPicture, {
1585
+ pi
1586
+ });
1587
+ if (status.state === "off") {
1588
+ return /* @__PURE__ */ React.createElement("div", {
1589
+ className: "tsy-panel tsy-hero"
1590
+ }, picture, /* @__PURE__ */ React.createElement("p", {
1591
+ className: "tsy-lead"
1592
+ }, inStore ? words.leadStoreShort : folder ? words.leadFolderShort : words.leadShort), /* @__PURE__ */ React.createElement(Via, {
1593
+ pi,
1594
+ status
1595
+ }), /* @__PURE__ */ React.createElement("div", {
1596
+ className: "tsy-actions"
1597
+ }, /* @__PURE__ */ React.createElement(Action2, {
1598
+ pi,
1599
+ primary: true,
1600
+ label: words.enable,
1601
+ run: () => store.call("enable")
1602
+ }), /* @__PURE__ */ React.createElement("button", {
1603
+ type: "button",
1604
+ className: "ta-button",
1605
+ onClick: () => void openJoin()
1606
+ }, words.join)));
1607
+ }
1608
+ if (status.state !== "on") {
1609
+ const owner = status.ownerName ?? "…";
1610
+ const text = status.state === "waiting" ? words.waiting : status.state === "refused" ? words.refused : words.gone;
1611
+ return /* @__PURE__ */ React.createElement("div", {
1612
+ className: "tsy-panel tsy-hero"
1613
+ }, picture, /* @__PURE__ */ React.createElement("p", {
1614
+ className: "tsy-big"
1615
+ }, SyncWords.format(text, { owner })), status.state === "waiting" && /* @__PURE__ */ React.createElement("p", {
1616
+ className: "tsy-status"
1617
+ }, /* @__PURE__ */ React.createElement("span", {
1618
+ className: "ta-spinner"
1619
+ }), /* @__PURE__ */ React.createElement("span", null, words.waitingHint)), /* @__PURE__ */ React.createElement("div", {
1620
+ className: "tsy-actions"
1621
+ }, /* @__PURE__ */ React.createElement(Action2, {
1622
+ pi,
1623
+ label: status.state === "waiting" ? words.cancel : words.restart,
1624
+ run: () => store.call("leave")
1625
+ })));
1626
+ }
1627
+ const stop = async () => {
1628
+ if (await pi.ui.confirm(words.stop, inStore ? words.stopStore : folder ? words.stopFolder : status.owner ? words.stopOwner : words.stopMember)) {
1629
+ await store.call("leave");
1630
+ }
1631
+ };
1632
+ return /* @__PURE__ */ React.createElement("div", {
1633
+ className: "tsy-panel"
1634
+ }, /* @__PURE__ */ React.createElement("div", {
1635
+ className: "tsy-total"
1636
+ }, /* @__PURE__ */ React.createElement(Via, {
1637
+ pi,
1638
+ status
1639
+ }), !folder && !status.connected && /* @__PURE__ */ React.createElement("span", {
1640
+ className: "tsy-status"
1641
+ }, /* @__PURE__ */ React.createElement("span", {
1642
+ className: "ta-spinner"
1643
+ }), /* @__PURE__ */ React.createElement("span", null, words.connecting))), /* @__PURE__ */ React.createElement("div", {
1644
+ className: "tsy-devices"
1645
+ }, status.asks.map((ask) => /* @__PURE__ */ React.createElement("div", {
1646
+ key: ask.ask,
1647
+ className: "tsy-device"
1648
+ }, /* @__PURE__ */ React.createElement("span", {
1649
+ className: "tsy-device-icon"
1650
+ }, pi.ui.icons.UserPlus && /* @__PURE__ */ React.createElement(pi.ui.icons.UserPlus, {
1651
+ size: 18
1652
+ })), /* @__PURE__ */ React.createElement("span", {
1653
+ className: "tsy-device-text"
1654
+ }, /* @__PURE__ */ React.createElement("span", {
1655
+ className: "tsy-device-name"
1656
+ }, SyncWords.format(words.asks, { name: ask.name }))), /* @__PURE__ */ React.createElement(Action2, {
1657
+ pi,
1658
+ label: words.refuse,
1659
+ run: () => store.call("answer", ask.ask, false)
1660
+ }), /* @__PURE__ */ React.createElement(Action2, {
1661
+ pi,
1662
+ primary: true,
1663
+ label: words.allow,
1664
+ run: () => store.call("answer", ask.ask, true)
1665
+ }))), status.devices.map((device) => /* @__PURE__ */ React.createElement(DeviceRow, {
1666
+ key: device.member,
1667
+ pi,
1668
+ store,
1669
+ device,
1670
+ owner: status.owner
1671
+ }))), /* @__PURE__ */ React.createElement(Status, {
1672
+ pi,
1673
+ status
1674
+ }), /* @__PURE__ */ React.createElement(Notes, {
1675
+ pi,
1676
+ status
1677
+ }), /* @__PURE__ */ React.createElement("div", {
1678
+ className: "tsy-actions"
1679
+ }, (status.owner || folder) && /* @__PURE__ */ React.createElement("button", {
1680
+ type: "button",
1681
+ className: "ta-button ta-primary",
1682
+ onClick: () => void pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog, {
1683
+ pi,
1684
+ close,
1685
+ folder,
1686
+ store: inStore
1687
+ }))
1688
+ }, words.addDevice), /* @__PURE__ */ React.createElement(Action2, {
1689
+ pi,
1690
+ label: words.syncNow,
1691
+ run: () => store.call("syncNow")
1692
+ }), /* @__PURE__ */ React.createElement(Action2, {
1693
+ pi,
1694
+ label: words.stop,
1695
+ run: stop
1696
+ })));
1697
+ }
1698
+ function ResourceSwitch({ pi, store, resource }) {
1699
+ const status = useStatus(store);
1700
+ const words = useWords2(pi);
1701
+ const { label } = SyncWords.resource(words, resource);
1702
+ const checked = status?.resources[resource] ?? false;
1703
+ const change = async (on) => {
1704
+ if (on && resource === "identity" && !await pi.ui.confirm(words.identityAskTitle, words.identityAskBody, { confirmLabel: words.identityAskConfirm })) {
1705
+ return;
1706
+ }
1707
+ await store.call("setResources", { [resource]: on });
1708
+ };
1709
+ const Switch = pi.ui.Switch;
1710
+ if (Switch) {
1711
+ return /* @__PURE__ */ React.createElement(Switch, {
1712
+ checked,
1713
+ label,
1714
+ disabled: !status,
1715
+ onChange: (on) => change(on).catch((error) => pi.ui.notify(message2(error), "error"))
1716
+ });
1717
+ }
1718
+ return /* @__PURE__ */ React.createElement("input", {
1719
+ type: "checkbox",
1720
+ role: "switch",
1721
+ className: "ta-switch",
1722
+ checked,
1723
+ "aria-checked": checked,
1724
+ "aria-label": label,
1725
+ onChange: (event) => void change(event.target.checked).catch((error) => pi.ui.notify(message2(error), "error"))
1726
+ });
1727
+ }
1728
+ function SyncPage({ pi, store }) {
1729
+ const words = useWords2(pi);
1730
+ return /* @__PURE__ */ React.createElement("div", {
1731
+ className: "tsy-page"
1732
+ }, /* @__PURE__ */ React.createElement(SyncPanel, {
1733
+ pi,
1734
+ store
1735
+ }), /* @__PURE__ */ React.createElement("h2", null, words.whatTitle), /* @__PURE__ */ React.createElement("div", {
1736
+ className: "tsy-what"
1737
+ }, SYNC_RESOURCES.map((resource) => {
1738
+ const { label, hint } = SyncWords.resource(words, resource);
1739
+ return /* @__PURE__ */ React.createElement("div", {
1740
+ key: resource,
1741
+ className: "tsy-what-row"
1742
+ }, /* @__PURE__ */ React.createElement("span", {
1743
+ className: "tsy-what-text"
1744
+ }, /* @__PURE__ */ React.createElement("span", {
1745
+ className: "tsy-what-label"
1746
+ }, label), /* @__PURE__ */ React.createElement("span", {
1747
+ className: "tsy-line"
1748
+ }, hint)), /* @__PURE__ */ React.createElement(ResourceSwitch, {
1749
+ pi,
1750
+ store,
1751
+ resource
1752
+ }));
1753
+ })));
1754
+ }
1755
+
1756
+ // web-src/style.ts
1757
+ var STYLE = `
1758
+ .tsy-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; animation: tsy-in 200ms var(--ta-ease); }
1759
+ @keyframes tsy-in { from { opacity: 0; transform: translateY(3px); } }
1760
+ .tsy-pic { display: block; width: 100%; max-width: 280px; height: auto; align-self: center; margin: 2px 0 4px; }
1761
+ .tsy-pic-fill { transform-box: fill-box; transform-origin: left; animation: tsy-fill 2.4s ease-in-out infinite; }
1762
+ @keyframes tsy-fill { 0% { transform: scaleX(.08); } 70%, 100% { transform: scaleX(1); } }
1763
+ .tsy-pic-later { animation-delay: .9s; }
1764
+ .tsy-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 6px 4px 2px; }
1765
+ .tsy-hero .tsy-lead { max-width: 460px; text-wrap: balance; }
1766
+ .tsy-hero .tsy-actions { justify-content: center; margin-top: 6px; }
1767
+ .tsy-title { margin: 0; color: var(--ta-text); font-size: calc(15px * var(--ta-font-scale)); font-weight: 600; }
1768
+ .tsy-via { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--ta-hover); color: var(--ta-secondary); font-size: calc(12px * var(--ta-font-scale)); }
1769
+ .tsy-via svg { flex: none; }
1770
+ .tsy-status { display: flex; align-items: center; gap: 8px; min-height: 22px; margin: 0; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1771
+ .tsy-status .tsy-dot { width: 7px; height: 7px; }
1772
+ .tsy-status.tsy-warn { color: var(--ta-yellow); }
1773
+ .tsy-status .ta-spinner { width: 12px; height: 12px; }
1774
+ .tsy-big { margin: 0; color: var(--ta-text); font-size: calc(14px * var(--ta-font-scale)); line-height: 1.6; }
1775
+ .tsy-code-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 12px; border-radius: 14px; background: var(--ta-raised); }
1776
+ .tsy-code-box .tsy-code { align-self: center; background: none; padding: 0; font-size: calc(30px * var(--ta-font-scale)); letter-spacing: .24em; margin-right: -.24em; }
1777
+ .tsy-code-box .tsy-line { text-align: center; }
1778
+ .tsy-actions .ta-button { min-width: 72px; justify-content: center; }
1779
+ .tsy-check-mark { flex: none; display: grid; place-items: center; width: 18px; height: 18px; box-sizing: border-box; border: 1.5px solid var(--ta-border-field); border-radius: 5px; color: #fff; transition: background 120ms, border-color 120ms; }
1780
+ .tsy-check-mark[data-on] { border-color: var(--ta-green); background: var(--ta-green); }
1781
+ .tsy-check-mark svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: opacity 120ms, transform 160ms var(--ta-ease); }
1782
+ .tsy-check-mark[data-on] svg { opacity: 1; transform: none; }
1783
+ .tsy-check input { position: absolute; opacity: 0; pointer-events: none; }
1784
+ .tsy-check:focus-within .tsy-check-mark { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ta-green) 25%, transparent); }
1785
+ .tsy-check { position: relative; transition: background 120ms; }
1786
+ @media (hover: hover) { .tsy-check:not(.tsy-empty):hover, .tsy-pick:hover { background: var(--ta-hover); } }
1787
+ .tsy-check.tsy-empty { cursor: default; opacity: .5; }
1788
+ .tsy-device { transition: background 120ms; }
1789
+ .tsy-devices .tsy-device + .tsy-device { border-top: 1px solid var(--ta-border-muted); }
1790
+ .tsy-device-name { display: flex; align-items: center; gap: 6px; }
1791
+ .tsy-qr { box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
1792
+ .tsy-ask { border: 1px solid var(--ta-border-muted); border-radius: 12px; }
1793
+ .tsy-size { flex: none; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1794
+ .tsy-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
1795
+ .tsy-total .tsy-line { font-variant-numeric: tabular-nums; }
1796
+ .tsy-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
1797
+ .tsy-tabs button { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
1798
+ .tsy-section { margin: 4px 0 -4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1799
+ .tsy-path { overflow-wrap: anywhere; font-family: var(--ta-mono); font-size: calc(11.5px * var(--ta-font-scale)); color: var(--ta-secondary); }
1800
+ .tsy-progress { height: 8px; border-radius: 4px; }
1801
+ .tsy-progress-bar { border-radius: 4px; transition: width .4s var(--ta-ease); }
1802
+ .tsy-big-number { margin: 0; color: var(--ta-text); font-size: calc(22px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; }
1803
+ .tsy-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
1804
+ .tsy-fact { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--ta-raised); }
1805
+ .tsy-fact b { color: var(--ta-text); font-size: calc(18px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; }
1806
+ .tsy-fact span { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1807
+ .tsy-end { justify-content: flex-end; }
1808
+ .tsy-lead { margin: 0; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: calc(20px * var(--ta-font-scale)); }
1809
+ .tsy-actions { display: flex; gap: 8px; flex-wrap: wrap; }
1810
+ .tsy-devices { display: flex; flex-direction: column; border: 1px solid var(--ta-border-muted); border-radius: 12px; overflow: hidden; }
1811
+ .tsy-device { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 52px; }
1812
+ .tsy-device + .tsy-device { border-top: 1px solid var(--ta-border-muted); }
1813
+ .tsy-device-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ta-raised); color: var(--ta-secondary); }
1814
+ .tsy-device-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
1815
+ .tsy-device-name { color: var(--ta-text); font-size: calc(14px * var(--ta-font-scale)); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1816
+ .tsy-device-line { display: flex; align-items: center; gap: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1817
+ .tsy-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ta-border-field); flex: none; }
1818
+ .tsy-dot.tsy-on { background: var(--ta-green); }
1819
+ .tsy-line { margin: 0; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(18px * var(--ta-font-scale)); overflow-wrap: anywhere; }
1820
+ .tsy-line.tsy-warn { color: var(--ta-yellow); }
1821
+ .tsy-link { padding: 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-link); font: inherit; font-size: calc(12px * var(--ta-font-scale)); cursor: pointer; }
1822
+ .tsy-link:hover { background: var(--ta-hover); }
1823
+ .tsy-link.tsy-danger { color: var(--ta-red); }
1824
+ .tsy-dialog { display: flex; flex-direction: column; gap: 14px; width: min(400px, calc(100vw - 48px)); }
1825
+ .tsy-dialog .tsy-qr { width: 200px; }
1826
+ .tsy-dialog .tsy-link-box { max-height: 3.4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
1827
+ .tsy-qr { align-self: center; width: 188px; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--ta-border-muted); }
1828
+ .tsy-qr svg { display: block; width: 100%; height: auto; }
1829
+ .tsy-link-box { padding: 8px 10px; border-radius: 8px; background: var(--ta-code); font-family: var(--ta-mono); font-size: calc(11.5px * var(--ta-font-scale)); color: var(--ta-secondary); overflow-wrap: anywhere; }
1830
+ .tsy-field { width: 100%; box-sizing: border-box; height: 36px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); }
1831
+ [data-touch] .tsy-field { font-size: max(16px, calc(13px * var(--ta-font-scale))); }
1832
+ .tsy-error { margin: 0; color: var(--ta-red); font-size: calc(12px * var(--ta-font-scale)); }
1833
+ .tsy-page { padding: 24px 20px 40px; max-width: 640px; margin: 0 auto; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
1834
+ .tsy-page h2 { margin: 0; font-size: calc(15px * var(--ta-font-scale)); font-weight: 600; color: var(--ta-text); }
1835
+ .tsy-what { display: flex; flex-direction: column; border: 1px solid var(--ta-border-muted); border-radius: 12px; }
1836
+ .tsy-what-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
1837
+ .tsy-what-row + .tsy-what-row { border-top: 1px solid var(--ta-border-muted); }
1838
+ .tsy-what-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
1839
+ .tsy-what-label { color: var(--ta-text); font-size: calc(13px * var(--ta-font-scale)); }
1840
+ .tsy-check { cursor: pointer; }
1841
+ .tsy-check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--ta-green); }
1842
+ .tsy-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
1843
+ .tsy-row .tsy-field { flex: 1 1 200px; width: auto; }
1844
+ .tsy-row .tsy-short { flex: 0 1 140px; }
1845
+ .tsy-code { align-self: flex-start; padding: 6px 14px; border-radius: 10px; background: var(--ta-raised); color: var(--ta-text); font-family: var(--ta-mono); font-size: calc(24px * var(--ta-font-scale)); letter-spacing: 0.18em; font-variant-numeric: tabular-nums; }
1846
+ .tsy-progress-box { display: flex; flex-direction: column; gap: 6px; }
1847
+ .tsy-progress { height: 6px; border-radius: 3px; background: var(--ta-raised); overflow: hidden; }
1848
+ .tsy-progress-bar { height: 100%; border-radius: 3px; background: var(--ta-green); transition: width 0.3s ease; }
1849
+ .tsy-pick { width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
1850
+ .tsy-picked { background: var(--ta-hover); }
1851
+ `;
1852
+ function injectStyle() {
1853
+ const element = document.createElement("style");
1854
+ element.dataset.taPackage = "ta-sync";
1855
+ element.textContent = STYLE;
1856
+ document.head.appendChild(element);
1857
+ return () => element.remove();
1858
+ }
1859
+
1860
+ // web-src/sync-store.ts
1861
+ class SyncStore {
1862
+ pi;
1863
+ current;
1864
+ listeners = new Set;
1865
+ constructor(pi) {
1866
+ this.pi = pi;
1867
+ pi.callHost("status").then((status) => this.set(status), () => {
1868
+ return;
1869
+ });
1870
+ pi.storage.onChange((keys) => {
1871
+ if (keys.includes(SyncKeys.STATUS)) {
1872
+ pi.storage.get(SyncKeys.STATUS).then((status) => status && this.set(status));
1873
+ }
1874
+ });
1875
+ }
1876
+ get status() {
1877
+ return this.current;
1878
+ }
1879
+ subscribe(listener) {
1880
+ this.listeners.add(listener);
1881
+ return () => this.listeners.delete(listener);
1882
+ }
1883
+ async call(method, ...params) {
1884
+ const status = await this.pi.callHost(method, ...params);
1885
+ this.set(status);
1886
+ return status;
1887
+ }
1888
+ set(status) {
1889
+ if (!status) {
1890
+ return;
1891
+ }
1892
+ this.current = status;
1893
+ for (const listener of this.listeners) {
1894
+ listener();
1895
+ }
1896
+ }
1897
+ }
1898
+
1899
+ // web-src/index.tsx
1900
+ function settings(pi, store) {
1901
+ const words = () => SyncWords.of(pi.ui.language);
1902
+ return {
1903
+ title: () => words().title,
1904
+ icon: pi.ui.icons.RefreshCw,
1905
+ rows: [
1906
+ {
1907
+ key: "devices",
1908
+ label: "",
1909
+ search: () => `${words().devices} ${words().leadShort}`,
1910
+ stacked: true,
1911
+ render: () => /* @__PURE__ */ React.createElement(SyncPanel, {
1912
+ pi,
1913
+ store
1914
+ })
1915
+ },
1916
+ ...SYNC_RESOURCES.map((resource) => ({
1917
+ key: resource,
1918
+ label: () => SyncWords.resource(words(), resource).label,
1919
+ description: () => SyncWords.resource(words(), resource).hint,
1920
+ render: () => /* @__PURE__ */ React.createElement(ResourceSwitch, {
1921
+ pi,
1922
+ store,
1923
+ resource
1924
+ })
1925
+ }))
1926
+ ]
1927
+ };
1928
+ }
1929
+ function activate(pi) {
1930
+ bind(pi.React);
1931
+ const removeStyle = injectStyle();
1932
+ const store = new SyncStore(pi);
1933
+ pi.registerSettings(settings(pi, store));
1934
+ const asked = new Set;
1935
+ let open;
1936
+ const stopAsks = store.subscribe(() => {
1937
+ const asks = store.status?.asks ?? [];
1938
+ const fresh = asks.filter((ask) => !asked.has(ask.ask));
1939
+ for (const ask of fresh) {
1940
+ asked.add(ask.ask);
1941
+ }
1942
+ if (fresh.length && !open) {
1943
+ open = pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(AskDialog, {
1944
+ pi,
1945
+ store,
1946
+ close: () => {
1947
+ open = undefined;
1948
+ close();
1949
+ }
1950
+ }));
1951
+ }
1952
+ });
1953
+ const moves = new MoveStore(pi);
1954
+ pi.registerSettings({
1955
+ title: () => MoveWordsUtil.of(pi.ui.language).title,
1956
+ icon: pi.ui.icons.FolderInput,
1957
+ rows: [
1958
+ {
1959
+ key: "move",
1960
+ label: "",
1961
+ search: () => `${MoveWordsUtil.of(pi.ui.language).title} ${MoveWordsUtil.of(pi.ui.language).lead}`,
1962
+ stacked: true,
1963
+ render: () => /* @__PURE__ */ React.createElement(MovePanel, {
1964
+ pi,
1965
+ store: moves
1966
+ })
1967
+ }
1968
+ ]
1969
+ });
1970
+ pi.registerView("move", {
1971
+ title: () => MoveWordsUtil.of(pi.ui.language).title,
1972
+ icon: pi.ui.icons.FolderInput,
1973
+ discover: true,
1974
+ render: () => /* @__PURE__ */ React.createElement("div", {
1975
+ className: "tsy-page"
1976
+ }, /* @__PURE__ */ React.createElement(MovePanel, {
1977
+ pi,
1978
+ store: moves
1979
+ }))
1980
+ });
1981
+ const movesAsked = new Set;
1982
+ let moveOpen;
1983
+ const stopMoveAsks = moves.subscribe(() => {
1984
+ const fresh = (moves.status.out?.asks ?? []).filter((ask) => !movesAsked.has(ask.ask));
1985
+ for (const ask of fresh) {
1986
+ movesAsked.add(ask.ask);
1987
+ }
1988
+ if (fresh.length && !moveOpen) {
1989
+ moveOpen = pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(MoveAskDialog, {
1990
+ pi,
1991
+ store: moves,
1992
+ close: () => {
1993
+ moveOpen = undefined;
1994
+ close();
1995
+ }
1996
+ }));
1997
+ }
1998
+ });
1999
+ pi.registerView("devices", {
2000
+ title: () => SyncWords.of(pi.ui.language).title,
2001
+ icon: pi.ui.icons.RefreshCw,
2002
+ discover: true,
2003
+ render: () => /* @__PURE__ */ React.createElement(SyncPage, {
2004
+ pi,
2005
+ store
2006
+ })
2007
+ });
2008
+ return () => {
2009
+ stopAsks();
2010
+ open?.();
2011
+ stopMoveAsks();
2012
+ moveOpen?.();
2013
+ removeStyle();
2014
+ };
2015
+ }
2016
+ export {
2017
+ activate as default
2018
+ };